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
Resolve extension hooks with native pre/post scripts - #4883
Replace repeated in-prompt parsing and ordering of extension pre/post hooks with native, self-contained Bash, PowerShell, and Python dispatch scripts. Agent command templates consume the ordered JSON result and invoke the selected extension commands; the scripts do not attempt to execute agent commands. Render the script path across command, skill, and preset installations, and serialize the supported canonical configuration for the native resolvers. Invalid or unsupported configuration fails explicitly rather than silently dropping hooks.
The ten core hook-bearing command templates shrink from 18,736 to 14,680 words (4,056 fewer; 21.6%). Tests cover priority/order, disabled/conditional/optional hooks, invalid input, cross-runtime parity, integration rendering, and package contents; the GitHub extension command stays in parity with its core counterpart.
Testing
Tested locally with uv run specify --help
Ran existing tests with uv sync && uv run pytest
Tested with a sample project (if applicable)
Equivalent local checks: .venv/bin/specify --help — passed; LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -q --tb=short — 9,839 passed, 19 skipped, 62 warnings; git diff --check — passed. The exact checklist commands and an agent-driven sample-project slash-command run were not performed, so their boxes remain unchecked.
Manual test results
Agent: Not run | OS/Shell: macOS / Bash, PowerShell and Python resolver behavior covered by automated tests
Command tested
Notes
Agent-driven slash commands
Not run; automated command-rendering and hook-dispatch tests passed.
AI Disclosure
I did not use AI assistance for this contribution
I did use AI assistance (fill in the disclosure below)
AI disclosure: Implemented with GitHub Copilot using GPT-6 Sol in autonomous agent mode (reasoning effort not explicitly configured; default settings). AI authored the implementation, tests, and documentation; no human line-by-line review is claimed.
Validate condition types to keep hook behavior consistent
scripts/python/pre_hooks.py:49
condition is never type-validated. For example, YAML condition: false is loaded here as a falsey boolean and the hook executes, while the Bash/PowerShell parsers retain false as non-empty text and skip the same hook. Since the documented field is a string or null, reject non-string/non-null values before filtering so the selected script variant cannot change whether a mandatory hook runs.
Existing configs are incompatible after parser migration
src/specify_cli/extensions/__init__.py:5729
This only canonicalizes .specify/extensions.yml on its next write. Projects upgraded from an earlier release can still have valid PyYAML output wrapped at the previous default width; both new native parsers reject those continuation lines, so upgrading the integration can make every hook check fail until some unrelated extension command rewrites the file. Migrate/rewrite existing configuration during the shared-infrastructure upgrade, or keep the native parsers compatible with the previously emitted layout.
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Use Bash 3-compatible scalar checks, validate condition types across runtimes, and canonicalize existing extension configuration when shared infrastructure is installed or upgraded. Guard invalid and symlinked configurations and cover old wrapped YAML with executable resolver regressions.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Addressed this review in 2865187. The Bash resolver no longer uses Bash 4-only lowercase expansion; a regression invokes both hook phases through macOS /bin/bash 3.2. All three resolvers now reject non-string/non-null condition values consistently. Shared-infrastructure installation/upgrade canonicalizes existing valid extension YAML, including legacy wrapped prompts, before native dispatch; invalid and symlinked config is not overwritten. Validation: LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -q --tb=short — 9,928 passed, 19 skipped, 62 warnings before the final symlink guard; after that guard, the affected hook, upgrade, and template suites passed (300 passed). /bin/bash -n scripts/bash/pre-hooks.sh scripts/bash/post-hooks.sh and git diff --check passed. Posted on behalf of @mnriem by GitHub Copilot (GPT-6 Sol, autonomous agent mode, default reasoning settings); AI authored this fix, regression tests, documentation update, and review-round summary, with no human line-by-line review claimed.
Validate YAML fields in every event, not only the target
scripts/bash/pre-hooks.sh:232
Fields are parsed only while $target is true, so malformed YAML scalars in any other event are silently accepted. For example, resolving before_plan succeeds when before_tasks contains extension: 'unterminated, whereas the Python resolver rejects the file during safe_load. Validate every event's fields while collecting only the requested event so invalid configuration cannot produce variant-dependent success.
Validate non-target event entries for cross-runtime parity
scripts/powershell/pre-hooks.ps1:137
Non-target event entries bypass Add-HookField, so malformed quoted scalars or unsupported field values elsewhere in the same YAML file are never validated. The same file therefore fails under Python but succeeds under PowerShell depending on which event is requested. Parse/validate every event and only gate adding hooks to the result on $target.
Standardize priority range normalization across runtimes
scripts/python/pre_hooks.py:63
Priority normalization has no shared numeric range across runtimes. For example, 2147483648 is retained here and by Bash but PowerShell falls back to 10; a 16-digit value is retained here while both native variants fall back. This changes hook order based on the installed script variant. Define one supported range/coercion rule in all three resolvers and cover its boundaries in the parity test.
Addressed this review in 219c013. Migration now rejects a symlinked .specify parent as well as a symlinked extensions.yml, without modifying the external config. Bash and PowerShell validate fields in non-target events; Python now validates every configured event too, while all three return hooks only for the requested event. Priorities share the same coercion and 1..2147483647 range, with out-of-range values falling back to 10; cross-runtime tests cover the boundaries and ordering. Validation on this exact change: LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -q --tb=short — 9,966 passed, 19 skipped, 62 warnings; /bin/bash -n scripts/bash/pre-hooks.sh scripts/bash/post-hooks.sh and git diff --check passed. Posted on behalf of @mnriem by GitHub Copilot (GPT-6 Sol, autonomous agent mode, default reasoning settings); AI authored the fix, tests, documentation, and this review-round summary, with no human line-by-line review claimed.
Reject empty quoted identifiers in Bash for every event, update the upstream deprecation contract to assert scripted dispatch, and bump the GitHub extension and catalog to 1.0.3 so installed copies receive the command update.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
After emitting the block above you MUST actually invoke the hook and wait for it to finish before continuing. Run it the same way you would run the command yourself in this agent/session (the invocation may differ from the literal `{command}` id shown above, e.g. a skills-mode agent runs it as `/skill:speckit-...` or `$speckit-...`). Emitting the block alone does not run the hook.
- If no hooks are registered or `.specify/extensions.yml` does not exist, skip silently
Run `{PRE_HOOK_SCRIPT} taskstoissues` from the project root and read its JSON result. If it fails or returns `error`, tell the user why no hooks were checked (including mandatory hooks), then continue the core command. For each returned hook in order: invoke mandatory commands in this agent and wait for completion before proceeding; surface optional commands with their prompt and description without executing them automatically. Use the invocation syntax for the installed agent/skills mode. If `hooks` is empty, continue silently.
Invoke Bash explicitly when Git Bash is usable and skip Bash-only cases otherwise; retain native PowerShell and Python coverage on Windows while preserving Bash coverage on macOS and Linux.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This replacement drops the contract that skills explain how dispatcher IDs map to installed command names. The resolver still returns dotted IDs such as speckit.git.commit, while skills are registered under hyphenated names and agent-specific prefixes. SkillsIntegration._inject_hook_command_note() (and the Cline/Junie overrides) only matches the removed - For each executable hook... wording, so the generated skills now contain no conversion guidance; these assertions mask that regression. Update the post-processing trigger for the new dispatch wording and retain coverage for slash, dollar, and /skill: invocation forms.
Preflight rejects a regular file at the projection cache path before enable, disable, or remove can change installed state. Add before-and-after regression coverage for all three commands.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Addressed review 5507557083 in 203b04b. A regular file at .specify/hook-dispatch now fails preflight before enable, disable, or remove can change extension state. Added public CLI regressions for all three mutations: all three failed before the fix with NotADirectoryError and now pass while verifying the registry, installed files, configuration, and colliding file remain unchanged. The focused registration and command tests passed (37 passed). The preceding commit passed both Windows pytest jobs (3.13 and 3.14); CI for this commit is newly running.
Posted on behalf of @mnriem with GitHub Copilot (GPT-6 Sol, autonomous mode); AI-authored code, tests, documentation, and review-round summary.
Check config symlinks before existence so missing targets cannot bypass CLI preflight. Cover enable, disable, remove, and direct saves while preserving installed state and projection files.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Bound Bash projection priorities to the supported maximum
scripts/bash/pre-hooks.sh:295
The projection shape accepts any positive-length integer, so Bash also returns priorities above the supported 2147483647 maximum while PowerShell rejects them. Bound this field in the shape validation so a digest-consistent but semantically invalid projection fails consistently across runtimes.
Reject priorities above the documented maximum in Python validation
scripts/python/pre_hooks.py:63
This validation accepts projected priorities above the documented 2147483647 maximum, unlike the PowerShell reader. A cache entry with a matching digest and priority: 2147483648 therefore succeeds in Python instead of being rejected as a semantically invalid projection, breaking cross-runtime parity.
Reject malformed hook configuration before installing shared assets. Reject projected priorities above the supported maximum in Bash and Python, with before-and-after regression coverage for each delivery path.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Provision dispatchers when installing or removing wrapping presets
src/specify_cli/integrations/base.py:832
This substitution can produce commands that point to files that do not exist. Preset registration calls template processing and resolve_skill_placeholders directly (presets/_manager_commands.py:226 and _manager_skills.py:783) but never installs shared infrastructure. Thus, installing or removing a wrapping preset in a pre-1.1.3 project renders the new hook paths while the project still lacks the dispatchers. Provision the selected dispatchers as part of preset lifecycle/reconciliation (or fail before writing the rendered command), and cover an actual preset install starting without these files.
Reject bare hook mappings and events in the Bash and PowerShell legacy resolvers. Ensure preset install and removal have the selected hook dispatchers before rendering core command references, with command and skill lifecycle regressions.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Share cache-path validation between extension mutation preflight and direct saves so directory collisions fail before changing installed state or deleting the projection snapshot. Cover named and unrelated cache entries across enable, disable, remove, and direct saves.
Assisted-by: GitHub Copilot (model: GPT-6 Sol, autonomous)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Provision hook dispatchers only for effective hook references
src/specify_cli/presets/_manager.py:407
This provisions hook dispatchers for every command override, including the default replace strategy. A replace preset fully discards the lower core command (presets/ARCHITECTURE.md:47-56), but the helper synthesizes {CORE_TEMPLATE} and therefore sees the core hook placeholders anyway. As a result, a replacement command with no hook references can fail installation on a missing or symlinked dispatcher. Determine this from the effective rendered/composed command (and add a replace-strategy regression test) before requiring dispatchers.
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
triage-nice-to-haveVerdict: evidence-backed fix or greenlit feature — land after review
2 participants
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.
Description
Replace repeated in-prompt parsing and ordering of extension pre/post hooks with native, self-contained Bash, PowerShell, and Python dispatch scripts. Agent command templates consume the ordered JSON result and invoke the selected extension commands; the scripts do not attempt to execute agent commands. Render the script path across command, skill, and preset installations, and serialize the supported canonical configuration for the native resolvers. Invalid or unsupported configuration fails explicitly rather than silently dropping hooks.
The ten core hook-bearing command templates shrink from 18,736 to 14,680 words (4,056 fewer; 21.6%). Tests cover priority/order, disabled/conditional/optional hooks, invalid input, cross-runtime parity, integration rendering, and package contents; the GitHub extension command stays in parity with its core counterpart.
Testing
uv run specify --helpuv sync && uv run pytestEquivalent local checks:
.venv/bin/specify --help— passed;LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -q --tb=short— 9,839 passed, 19 skipped, 62 warnings;git diff --check— passed. The exact checklist commands and an agent-driven sample-project slash-command run were not performed, so their boxes remain unchecked.Manual test results
Agent: Not run | OS/Shell: macOS / Bash, PowerShell and Python resolver behavior covered by automated tests
AI Disclosure
AI disclosure: Implemented with GitHub Copilot using GPT-6 Sol in autonomous agent mode (reasoning effort not explicitly configured; default settings). AI authored the implementation, tests, and documentation; no human line-by-line review is claimed.