@@ -778,6 +778,36 @@ def test_adjust_script_paths_does_not_mutate_input(self):
778778 assert adjusted ["scripts" ]["sh" ] == ".specify/scripts/bash/setup-plan.sh {ARGS}"
779779 assert adjusted ["scripts" ]["ps" ] == ".specify/scripts/powershell/setup-plan.ps1 {ARGS}"
780780
781+ def test_adjust_script_paths_preserves_extension_local_paths (self ):
782+ """Extension-local script paths should not be rewritten into .specify/.specify."""
783+ from specify_cli .agents import CommandRegistrar as AgentCommandRegistrar
784+ registrar = AgentCommandRegistrar ()
785+ original = {
786+ "scripts" : {
787+ "sh" : ".specify/extensions/test-ext/scripts/setup.sh {ARGS}" ,
788+ "ps" : "scripts/powershell/setup-plan.ps1 {ARGS}" ,
789+ }
790+ }
791+
792+ adjusted = registrar ._adjust_script_paths (original )
793+
794+ assert adjusted ["scripts" ]["sh" ] == ".specify/extensions/test-ext/scripts/setup.sh {ARGS}"
795+ assert adjusted ["scripts" ]["ps" ] == ".specify/scripts/powershell/setup-plan.ps1 {ARGS}"
796+
797+ def test_rewrite_project_relative_paths_preserves_extension_local_body_paths (self ):
798+ """Body rewrites should preserve extension-local assets while fixing top-level refs."""
799+ from specify_cli .agents import CommandRegistrar as AgentCommandRegistrar
800+
801+ body = (
802+ "Read `.specify/extensions/test-ext/templates/spec.md`\n "
803+ "Run scripts/bash/setup-plan.sh\n "
804+ )
805+
806+ rewritten = AgentCommandRegistrar ._rewrite_project_relative_paths (body )
807+
808+ assert ".specify/extensions/test-ext/templates/spec.md" in rewritten
809+ assert ".specify/scripts/bash/setup-plan.sh" in rewritten
810+
781811 def test_render_toml_command_handles_embedded_triple_double_quotes (self ):
782812 """TOML renderer should stay valid when body includes triple double-quotes."""
783813 from specify_cli .agents import CommandRegistrar as AgentCommandRegistrar
0 commit comments