fix(agent-context): discover nested plan.md in scoped layouts (#3024)#3301
Open
Noor-ul-ain001 wants to merge 3 commits into
Open
fix(agent-context): discover nested plan.md in scoped layouts (#3024)#3301Noor-ul-ain001 wants to merge 3 commits into
Noor-ul-ain001 wants to merge 3 commits into
Conversation
…#3024) The agent-context updater only looked for plan.md one level deep (specs/*/plan.md), so scoped layouts created via SPECIFY_FEATURE_DIRECTORY (specs/<scope>/<feature>/plan.md) were never picked up and no plan reference was written into the context file. Recurse into specs/ in both the bash (rglob) and PowerShell (-Recurse) scripts. In the PowerShell script, also replace [System.IO.Path]::GetRelativePath, which is .NET Core 2.1+ only and throws under Windows PowerShell 5.1 (.NET Framework); the exception was swallowed by the surrounding try/catch, leaving the plan path empty on 5.1 even when a plan was found. Compute the project-relative path by stripping the root prefix instead. Add regression tests for both scripts covering nested discovery. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n-discovery # Conflicts: # extensions/agent-context/scripts/bash/update-agent-context.sh # extensions/agent-context/scripts/powershell/update-agent-context.ps1
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the bundled agent-context extension’s plan auto-discovery so it can find plan.md in nested/scoped spec layouts (e.g. specs/<scope>/<feature>/plan.md) and correctly write a plan reference into the managed context section.
Changes:
- Bash updater: switches plan discovery from one-level globbing to recursive discovery under
specs/. - PowerShell updater: switches to recursive discovery and replaces a
.NET-version-sensitive relative-path call with PS 5.1–compatible prefix stripping. - Adds regression tests ensuring nested
specs/scope/001-feature/plan.mdis discovered by both updaters.
Show a summary per file
| File | Description |
|---|---|
| tests/extensions/test_extension_agent_context.py | Adds regression tests covering nested/scoped plan discovery for bash and PowerShell updaters. |
| extensions/agent-context/scripts/powershell/update-agent-context.ps1 | Updates plan discovery to recurse under specs/ and uses PS 5.1–compatible path relativization logic. |
| extensions/agent-context/scripts/bash/update-agent-context.sh | Updates plan discovery to recurse under specs/ for scoped layouts. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Low
Comment on lines
313
to
317
| plans = sorted( | ||
| specs.glob("*/plan.md"), | ||
| specs.rglob("plan.md"), | ||
| key=lambda p: p.stat().st_mtime, | ||
| reverse=True, | ||
| ) |
mnriem
requested changes
Jul 2, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
Please address Copilot feedback
Co-authored-by: Copilot Autofix powered by AI <175728472+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.
Summary
Fixes #3024. The agent-context updater discovered
plan.mdonly one level deep (specs/*/plan.md), so scoped layouts created viaSPECIFY_FEATURE_DIRECTORY— e.g.specs/<scope>/<feature>/plan.md— were never found, and no plan reference was written into the context file.Changes
update-agent-context.sh):specs.glob("*/plan.md")→specs.rglob("plan.md").update-agent-context.ps1): one-levelGet-ChildItem→-Recurse.[System.IO.Path]::GetRelativePath(...)is .NET Core 2.1+ only and throws under Windows PowerShell 5.1 (.NET Framework). The exception was swallowed by the surroundingtry/catch, leaving$PlanPathempty on 5.1 even when a plan was found — so nested discovery silently produced no plan reference on the most common Windows shell. Replaced with a direct root-prefix strip, matching the script's existing path helpers.Tests
Added regression tests for both scripts (
test_bash_script_discovers_nested_plan,test_powershell_script_discovers_nested_plan) asserting aspecs/scope/001-feature/plan.mdis discovered — which the old one-level glob would miss. The PowerShell test fails without theGetRelativePathfix and passes with it.Verified locally: both new tests pass. Two unrelated bash tests in the same module (
rejects_symlink_escape,deduplicates_context_files_in_order) fail only under Git-for-Windows MSYS bash and reproduce on cleanmain— pre-existing environment artifacts, not touched by this change.