fix: find plans in nested spec directories#3405
Open
marcelsafin wants to merge 2 commits into
Open
Conversation
The agent-context mtime fallback used a one-level specs/*/plan.md glob, so scoped layouts (specs/<scope>/<feature>/plan.md via SPECIFY_FEATURE_DIRECTORY) never matched and the SPECKIT block was written without a plan path. Recurse in both script variants and update the command doc wording. Fixes github#3024 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes agent-context extension plan auto-discovery for repositories that organize specs in nested directories (e.g. specs/<scope>/<feature>/plan.md) by making the mtime-based fallback search recursive in both Bash and PowerShell variants.
Changes:
- Update Bash script fallback from a one-level glob to recursive
**/plan.mddiscovery. - Update PowerShell script fallback to recursively find
plan.mdunderspecs/and select the most recently modified. - Add tests covering nested plan discovery for both script variants and update command documentation wording.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/extensions/test_extension_agent_context.py | Adds regression tests ensuring nested specs/**/plan.md is discovered via the mtime fallback. |
| extensions/agent-context/scripts/powershell/update-agent-context.ps1 | Switches fallback plan discovery to recursive Get-ChildItem -Recurse -File -Filter plan.md. |
| extensions/agent-context/scripts/bash/update-agent-context.sh | Switches fallback plan discovery to recursive specs.glob("**/plan.md"). |
| extensions/agent-context/commands/speckit.agent-context.update.md | Updates docs to describe any-depth plan auto-detection behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
310
to
314
| plans = sorted( | ||
| specs.glob("*/plan.md"), | ||
| specs.glob("**/plan.md"), | ||
| key=lambda p: p.stat().st_mtime, | ||
| reverse=True, | ||
| ) |
Contributor
Author
There was a problem hiding this comment.
Switched to max(..., default=None), same behavior without sorting the full list.
| - **PowerShell**: `.specify/extensions/agent-context/scripts/powershell/update-agent-context.ps1 [plan_path]` | ||
|
|
||
| When `plan_path` is omitted, the script auto-detects the most recently modified `specs/*/plan.md`. | ||
| When `plan_path` is omitted, the script auto-detects the most recently modified `specs/**/plan.md` (any depth, so scoped layouts like `specs/<scope>/<feature>/plan.md` are found). |
Contributor
Author
There was a problem hiding this comment.
Missed that one, updated the Behavior section to the any-depth wording.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes #3024
The agent-context extension's plan auto-discovery (mtime fallback) globbed one level only:
specs/*/plan.md. Repos that scope specs viaSPECIFY_FEATURE_DIRECTORYput plans atspecs/<scope>/<feature>/plan.md, so the glob matched nothing and the SPECKIT block silently refreshed without a plan path.Both script variants now recurse: the bash variant's embedded Python uses
specs.glob("**/plan.md")and the PowerShell variant usesGet-ChildItem -Recurse -File -Filter plan.md. Most-recently-modified match still wins, and the feature.json path (which already handles nested directories) stays untouched. The command doc's one-level wording is updated.Testing
uv run specify --helpuv sync && uv run pytest(3810 passed)New
TestPlanDiscoverytests run both script variants against a project with an older flat plan and a newer nested plan, and assert the nested one lands in AGENTS.md (also proving mtime ordering across depths).AI Disclosure
Written with GitHub Copilot CLI; I reviewed the diff and test results.