fix: recover active skills registration for extensions
Description
Fixes #2769.
Extension command registration now resolves the initialized active skills-backed agent's skills directory before writing command artifacts. If that active skills directory is missing, extension install can recreate it safely and register the command artifact instead of leaving registry state out of sync with generated files.
The recovery path is limited to extension command registration. Preset registration keeps the existing directory-detection behavior, and shared skills directories are still guarded so unrelated agents are not marked as registered, including when the active shared-dir registration fails after recreating the directory.
Testing
- [x] Tested locally with
uv run specify --help - [x] Ran existing tests with
uv sync && uv run pytest - [x] Tested with a sample project (if applicable)
Additional details:
UV_CACHE_DIR=/tmp/uv-cache uv sync --extra test && UV_CACHE_DIR=/tmp/uv-cache uv run pytest -qβ3312 passed, 40 skipped, 19 warnings in 74.72sUV_CACHE_DIR=/tmp/uv-cache uv run pytest tests/test_extension_skills.py -qβ40 passed in 0.38sUV_CACHE_DIR=/tmp/uv-cache uv run pytest -qβ3313 passed, 40 skipped, 19 warnings in 75.10sUV_CACHE_DIR=/tmp/uv-cache uv run specify --helpβ command completed and printed CLI help- Sample project flow:
specify init <tmp>/sample --ai claude --no-git --ignore-agent-tools, removed.claude/skills, then ranspecify extension add selftest; registry recorded the Claude command and.claude/skills/speckit-selftest-extension/SKILL.mdwas created. git diff --check HEAD~1..HEADβ clean
AI Disclosure
- [ ] I did not use AI assistance for this contribution
- [x] I did use AI assistance (describe below)
I used Codex to help reproduce the issue, draft the regression tests, and propose the implementation. I reviewed the diffs, checked the active/shared skills directory edge cases, ran the tests above, and refined the change before preparing this PR.
Addressed the Copilot review feedback in b84bd53494ad7f059cbd23abddaebfa9145114ae:
- Set
active_created_skills_dirimmediately after the missing active skills-dir recovery path resolves the directory, so shared-dir agents are not treated as detected even if active registration later raisesOSError. - Added regression coverage for the shared
.agents/skillscase where activeagyregistration fails andcodexmust not register. - Added explicit
encoding="utf-8"to the testread_text()call. - Re-ran
UV_CACHE_DIR=/tmp/uv-cache uv run pytest tests/test_extension_skills.py -qβ40 passed in 0.38s. - Re-ran
UV_CACHE_DIR=/tmp/uv-cache uv run pytest -qβ3313 passed, 40 skipped, 19 warnings in 75.10s.
The comment about ExtensionManager.install_from_directory() not using the new flag appears to be covered already. That path calls the extension wrapper CommandRegistrar.register_commands_for_all_agents(...), which delegates with create_missing_active_skills_dir=True.
Addressed the latest Copilot feedback in 673fc935: missing active skills-dir recovery now preserves Hermesβ configured global ~/.hermes/skills output instead of redirecting registration to the project-local marker.
Local verification: targeted extension tests passed, and the full suite passed: 3374 passed, 40 skipped, 19 warnings.
Addressed the latest Copilot feedback in 24ae633: detect_dir markers now require Path.is_dir() so regular files do not count as integrations.
Local verification: targeted extension tests passed, and the full suite passed: 3375 passed, 40 skipped.
Please make sure checklist is after plan
Addressed the latest review feedback in 8a3f907: checklist now stays after plan, and unusable skills dirs skip registration instead of aborting install.
Local verification: targeted tests passed, and the full suite passed: 3378 passed, 40 skipped, 19 warnings.