feat(extensions): per-event hook lists with priority ordering
Description
Extension manifests allowed only one command per hook event, and hooks fired in insertion order with no way to control sequencing. Resolves #2378.
Each hook event in extension.yml may now be a single mapping (existing form)
or a list of mappings, with an optional integer priority (>= 1, default 10;
lower runs first, stable on ties). Existing single-mapping manifests are
unaffected. This hook-entry priority is independent of the extension-level
priority used for preset/template resolution.
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)
18 new unit tests in tests/test_extensions.py cover list/single validation,
priority ordering, dedup, and backward compatibility. End-to-end: installed a
sample extension with a two-command after_plan list via specify extension add — both registered with priorities and resolved in priority order.
AI Disclosure
- [ ] I did not use AI assistance for this contribution
- [x] I did use AI assistance (describe below)
Implemented with AI assistance (Claude Code); reviewed by me before submission.
Thanks for the thorough implementation and test coverage — behavior matches #2378's acceptance criteria cleanly, and the back-compat story holds up (existing single-mapping manifests and pre-priority on-disk configs both keep working).
Before merging, could you extend the docs to match the new manifest surface?
-
EXTENSION-API-REFERENCE.md — the
hooks:schema only shows the single-mapping form. Please document that each event accepts either a mapping or a list of mappings, and addpriority(int ≥ 1, default 10, lower runs first, stable on ties) to the per-entry field reference. -
EXTENSION-DEVELOPMENT-GUIDE.md — add a short example of the list form with
priority, ideally mirroring the use case in #2378 (verify before report onafter_plan).
While you're in the reference doc, worth a one-liner that within a single manifest list, a repeated command is deduped as "last wins" and moved to the end (so it also breaks equal-priority ties in authoring order). New-feature semantic only — no back-compat impact — but extension authors should know.
Thanks for the review. Updated the docs in d63be38.
Addressed in 60138aa (the snippet now shows both the single-mapping and list forms). https://github.com/github/spec-kit/pull/2798#discussion_r3356254639