Skip to content

Fix --dev extension agent symlinks#2554

Open
NgoQuocViet2001 wants to merge 3 commits into
github:mainfrom
NgoQuocViet2001:ai/dev-extension-symlink-artifacts
Open

Fix --dev extension agent symlinks#2554
NgoQuocViet2001 wants to merge 3 commits into
github:mainfrom
NgoQuocViet2001:ai/dev-extension-symlink-artifacts

Conversation

@NgoQuocViet2001
Copy link
Copy Markdown

@NgoQuocViet2001 NgoQuocViet2001 commented May 14, 2026

Description

Fixes #2451.

specify extension add --dev now asks extension registration to link generated agent command files when possible. The registrar writes rendered output into an extension-local .specify-dev cache and points the agent-facing command file at it, while falling back to a normal copy when symlink creation is unavailable. The same option is threaded through extension skill registration, and unregister now removes symlinked command entries too.

Follow-up review fixes also harden .specify-dev cache writes against path traversal and allow existing dev-mode SKILL.md symlinks to refresh their generated cache content on subsequent dev installs without overwriting user-managed non-symlink skills.

Testing

  • Tested locally with PYTHONIOENCODING=utf-8 PYTHONUTF8=1 uv run specify --help
    • Note: plain uv run specify --help on this Windows cp1252 console hit an existing banner UnicodeEncodeError; the UTF-8 run passed.
  • uv sync --extra test
  • uv run pytest tests/test_extensions.py
  • uv run pytest tests/test_extension_skills.py
  • uv run pytest tests/integrations/test_integration_subcommand.py -k "extension_add or switch_migrates_extension_commands or switch_migrates_copilot_skills_extension_commands"
  • uvx ruff check src/specify_cli/agents.py src/specify_cli/extensions.py src/specify_cli/__init__.py
  • git diff --check

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

This PR was implemented with OpenAI Codex assistance. Codex helped identify the regression path, make the code changes, add tests, run validation, address review feedback, and draft this PR; I reviewed the resulting diff and test output before submission.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 the specify extension add --dev regression (#2451) by enabling dev-mode installations to symlink generated agent artifacts to an extension-local .specify-dev cache when the OS supports symlinks, while preserving a copy-based fallback when symlinks can’t be created.

Changes:

  • Thread a link_outputs/link_commands option through extension install + command registration so dev installs can symlink agent command files to cached rendered outputs.
  • Extend the same dev-linking behavior to extension skill registration (SKILL.md generation) with a symlink fallback-to-copy strategy.
  • Add tests covering symlink behavior and fallback behavior for Copilot agent command registration and extension add --dev.
Show a summary per file
File Description
tests/test_extensions.py Adds symlink capability detection plus dev-mode tests for symlinked Copilot agent command files and copy fallback.
src/specify_cli/extensions.py Threads link_commands through extension install and skill registration; implements dev-cache + symlink logic for SKILL.md outputs.
src/specify_cli/agents.py Adds link_outputs support in command registration, writing rendered outputs to .specify-dev and symlinking agent-facing files; updates unregister behavior for symlinks.
src/specify_cli/init.py Enables link_commands=True for extension add --dev installs.

Copilot's findings

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 2

Comment thread src/specify_cli/agents.py Outdated
Comment thread src/specify_cli/extensions.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread src/specify_cli/agents.py Outdated
Comment thread src/specify_cli/extensions.py Outdated
Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

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

Please address Copilot feedback. If not applicable, please explain why

@NgoQuocViet2001
Copy link
Copy Markdown
Author

Addressed the remaining Copilot feedback in 8064be3.

  • src/specify_cli/agents.py now catches ValueError alongside OSError when computing the dev-mode symlink target, so Windows cross-drive relpath failures fall back to a normal copy.
  • src/specify_cli/extensions.py applies the same fallback for dev-mode skill registration.
  • Added regression coverage for both relpath-failure fallback paths.

Validation:

  • uv run pytest tests/test_extensions.py::TestCommandRegistrar::test_dev_register_commands_falls_back_to_copy_when_symlink_fails tests/test_extensions.py::TestCommandRegistrar::test_dev_register_commands_falls_back_to_copy_when_relpath_fails tests/test_extension_skills.py::TestExtensionSkillRegistration::test_dev_skill_registration_falls_back_to_copy_when_relpath_fails tests/test_extension_skills.py::TestExtensionSkillRegistration::test_dev_skill_symlink_refreshes_existing_cache -> 3 passed, 1 skipped
  • uvx ruff check src/specify_cli/agents.py src/specify_cli/extensions.py -> passed
  • git diff --check -> passed

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 add --dev broken

3 participants