spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix: recover active skills registration for extensions

Open minbang930 opened this issue 5 months ago β€’ 5 comments

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.72s
  • UV_CACHE_DIR=/tmp/uv-cache uv run pytest tests/test_extension_skills.py -q β€” 40 passed in 0.38s
  • UV_CACHE_DIR=/tmp/uv-cache uv run pytest -q β€” 3313 passed, 40 skipped, 19 warnings in 75.10s
  • UV_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 ran specify extension add selftest; registry recorded the Claude command and .claude/skills/speckit-selftest-extension/SKILL.md was 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.

minbang930 avatar Jun 02 '26 03:06 minbang930

Addressed the Copilot review feedback in b84bd53494ad7f059cbd23abddaebfa9145114ae:

  • Set active_created_skills_dir immediately 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 raises OSError.
  • Added regression coverage for the shared .agents/skills case where active agy registration fails and codex must not register.
  • Added explicit encoding="utf-8" to the test read_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.

minbang930 avatar Jun 02 '26 03:06 minbang930

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.

minbang930 avatar Jun 02 '26 19:06 minbang930

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.

minbang930 avatar Jun 03 '26 13:06 minbang930

Please make sure checklist is after plan

mnriem avatar Jun 03 '26 21:06 mnriem

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.

minbang930 avatar Jun 03 '26 23:06 minbang930