You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug-fix] Fix extension-skill-path-rewrite: rewrite extension refs for skills - #5364
Proposed fix for issue #5363, applying the remediation from the bug assessment.
Verdict: valid · Severity: medium
Summary
Updated extension path rewriting so skill content rewrites only to existing extension paths, supports nested shorthand references via unique suffix resolution, and emits skill-directory-relative paths for generated SKILL.md files.
Changes
File
Change
Notes
src/specify_cli/agents.py
modified
Reworked rewrite_extension_paths to resolve existing paths (including nested suffix matches) and compute relative rewrites for skills.
src/specify_cli/extensions/__init__.py
modified
Passed project_root/skill_dir into rewrite call during extension skill generation.
src/specify_cli/presets/_manager_skills.py
modified
Passed project_root/skill_dir into rewrite call during extension-skill restore flow.
tests/test_extension_skills.py
modified
Updated existing assertions and added regressions for nested path rewriting and Copilot skill-relative path output.
Tests Added or Updated
tests/test_extension_skills.py::TestExtensionSkillRegistration::test_skill_registration_rewrites_extension_subdir_paths — now asserts skill-dir-relative installed paths.
Commands run: python3 -m pytest -q tests/test_extension_skills.py -k "scripted_path_placeholders or rewrites_extension_subdir_paths or rewrites_nested_extension_refs or copilot_skill_registration_rewrites_relative_to_skill_dir" → failed (No module named pytest in this runner).
Commands run: uv run pytest -q tests/test_extension_skills.py -k "scripted_path_placeholders or rewrites_extension_subdir_paths or rewrites_nested_extension_refs or copilot_skill_registration_rewrites_relative_to_skill_dir" → blocked in this runner (permission-gated interactive approval unavailable).
The nested shorthand resolver intentionally rewrites only when a suffix maps to a single extension path; ambiguous shorthand remains unchanged.
Path rewrite behavior for skill outputs now depends on skill directory depth by design; reviewers should confirm expected behavior across integrations that consume skill files differently.
…L dir
Apply the remediation from the bug assessment on issue
#5363.
Refs #5363
Assisted-by: GitHub Copilot (model: gpt-5.3-codex, autonomous)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Path rewriting still mishandles trailing punctuation and expanded script paths, leaving generated references broken and preventing new rewrite tests from passing.
This PR addresses #5363 by updating extension reference rewriting so generated agent skills can locate files stored in the installed extension directory.
Changes:
Restricts rewrites to existing paths and adds unique-suffix resolution for nested references.
Passes project and skill-directory context during skill generation and restoration.
Updates path assertions and adds nested-reference and Copilot regression tests.
File
Description
tests/test_extension_skills.py
Updates relative-path expectations and adds nested-reference and Copilot coverage.
src/specify_cli/presets/_manager_skills.py
Supplies destination context when restoring extension skills.
src/specify_cli/extensions/__init__.py
Supplies destination context when generating extension skills.
src/specify_cli/agents.py
Adds existence checks, suffix lookup, and skill-relative path calculation.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved path-handling defects break fragment links, cross-drive Windows registration, and project-root script invocations, while reference resolution can consume excessive CPU.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The tokenizer mishandles bundled paths containing spaces or parentheses and exhibits quadratic behavior on malformed extension text, causing broken resource references and potentially CPU-bound installations.
Quoted paths with spaces or parentheses are not resolved
src/specify_cli/agents.py:270
The new tokenizer stops at spaces and parentheses even inside quoted or backtick-delimited paths, leaving existing bundled files such as agents/reviewer guide.md and agents/reviewer(v2).md unresolved. This regresses the previous prefix-based rewrite, so generated skills look for these resources beside SKILL.md instead of in the installed extension. Recognize complete delimited paths before checking existence, and add regressions for both filename forms.
Malformed extension text can trigger quadratic token scanning
src/specify_cli/agents.py:270
The token regex permits repeated rescanning and backtracking, giving it quadratic worst-case behavior on malformed extension command text. Processing downloaded extension bodies can therefore leave installation CPU-bound. Replace it with bounded token scanning that preserves supported filename and Markdown syntax, and add coverage that guards against excessive rescanning.
Handle delimited filenames and balanced Markdown paths with forward-only scanning. Bound punctuation resolution and compare execution directories by filesystem identity so Windows short paths do not fail CI.
Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use one project-root base for recognized inline-command executables and operands, retain skill-relative standalone resource links, and emit explicit command working-directory guidance. Exercise generated commands that read bundled files through scripts and tools.
Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Resource paths in shell commands are rewritten relative to the skill directory despite an unchanged working directory, causing previously valid project-root commands to fail with FileNotFoundError.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate memory-exhaustion risk from unbounded output expansion and correctness risks in command, Markdown, and URL path rewriting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug fix — extension-skill-path-rewrite
Proposed fix for issue #5363, applying the remediation from the bug assessment.
Verdict: valid · Severity: medium
Summary
Updated extension path rewriting so skill content rewrites only to existing extension paths, supports nested shorthand references via unique suffix resolution, and emits skill-directory-relative paths for generated
SKILL.mdfiles.Changes
src/specify_cli/agents.pyrewrite_extension_pathsto resolve existing paths (including nested suffix matches) and compute relative rewrites for skills.src/specify_cli/extensions/__init__.pyproject_root/skill_dirinto rewrite call during extension skill generation.src/specify_cli/presets/_manager_skills.pyproject_root/skill_dirinto rewrite call during extension-skill restore flow.tests/test_extension_skills.pyTests Added or Updated
tests/test_extension_skills.py::TestExtensionSkillRegistration::test_skill_registration_rewrites_extension_subdir_paths— now asserts skill-dir-relative installed paths.tests/test_extension_skills.py::TestExtensionSkillRegistration::test_skill_registration_rewrites_nested_extension_refs— pins nested shorthand resolution.tests/test_extension_skills.py::TestExtensionSkillRegistration::test_copilot_skill_registration_rewrites_relative_to_skill_dir— pins Copilot skill-relative rewrite behavior.Local Verification
python3 -m pytest -q tests/test_extension_skills.py -k "scripted_path_placeholders or rewrites_extension_subdir_paths or rewrites_nested_extension_refs or copilot_skill_registration_rewrites_relative_to_skill_dir"→ failed (No module named pytestin this runner).uv run pytest -q tests/test_extension_skills.py -k "scripted_path_placeholders or rewrites_extension_subdir_paths or rewrites_nested_extension_refs or copilot_skill_registration_rewrites_relative_to_skill_dir"→ blocked in this runner (permission-gated interactive approval unavailable).python3 -m py_compile src/specify_cli/agents.py src/specify_cli/extensions/__init__.py src/specify_cli/presets/_manager_skills.py tests/test_extension_skills.py→ passed.Deviations from Assessment
None.
Risks & Review Notes
Refs #5363 · cc
@markuswondrak