Skip to content

fix extension-local script path rewriting#3364

Open
ZhiyaoWen999 wants to merge 1 commit into
github:mainfrom
ZhiyaoWen999:fix/3358-extension-script-paths
Open

fix extension-local script path rewriting#3364
ZhiyaoWen999 wants to merge 1 commit into
github:mainfrom
ZhiyaoWen999:fix/3358-extension-script-paths

Conversation

@ZhiyaoWen999

Copy link
Copy Markdown

Summary

Fixes #3358.

Extension command materialization now keeps extension-owned scripts/... references under .specify/extensions/<extension_id>/scripts/... instead of rewriting them to core .specify/scripts/....

Root Cause

CommandRegistrar.rewrite_project_relative_paths() treated every top-level scripts/ reference as a core project script. That is correct for built-in commands and ../../scripts/... references, but extension command sources may use scripts/... to refer to helper scripts shipped inside the extension archive.

During skills/materialization, those paths were rewritten to .specify/scripts/..., where extension helper scripts do not exist.

Changes

  • Added optional extension context to script path rewriting and skill placeholder resolution.
  • Passed the installed extension id through extension command and skill registration paths.
  • Preserved existing behavior for core scripts such as ../../scripts/..., which still resolve to .specify/scripts/....
  • Added regression coverage for direct path rewriting and auto-registered extension skills.

Validation

  • PYTHONPATH=src .venv/bin/python -m ruff check src/specify_cli/agents.py src/specify_cli/extensions/__init__.py tests/test_extensions.py tests/test_extension_skills.py
  • PYTHONPATH=src .venv/bin/python -m pytest tests/test_extensions.py tests/test_extension_skills.py -q
  • PYTHONPATH=src .venv/bin/python -m pytest tests/test_presets.py -q
  • git diff --check

AI Disclosure

I used Codex to investigate the issue, implement the fix, add tests, and run validation. I reviewed the code paths and test results before submitting.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes extension command materialization so that extension-owned scripts/... references remain extension-local under .specify/extensions/<extension_id>/scripts/... instead of being rewritten into core .specify/scripts/..., addressing #3358.

Changes:

  • Added an optional extension_id context to CommandRegistrar.rewrite_project_relative_paths() and plumbed it through command/skill rendering flows.
  • Updated extension command + skill registration to pass manifest.id so top-level scripts/ resolves into the installed extension directory when materializing extension content.
  • Added regression tests covering both direct path rewriting and auto-registered extension skills.
Show a summary per file
File Description
src/specify_cli/agents.py Adds extension_id-aware rewriting so extension scripts/ paths resolve under .specify/extensions/<id>/scripts/ during rendering.
src/specify_cli/extensions/__init__.py Passes manifest.id through extension registration/materialization so extension context is applied consistently.
tests/test_extensions.py Extends unit coverage for _adjust_script_paths() and rewrite_project_relative_paths() with extension context behavior.
tests/test_extension_skills.py Adds regression coverage ensuring auto-registered skills preserve extension-local script paths and don’t rewrite into .specify/scripts/.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Low

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Extension materialization rewrites extension-local script paths to .specify/scripts/, breaking installed extensions

3 participants