Skip to content

fix(agent-context): discover nested plan.md in scoped layouts (#3024)#3301

Open
Noor-ul-ain001 wants to merge 3 commits into
github:mainfrom
Noor-ul-ain001:fix/3024-nested-plan-discovery
Open

fix(agent-context): discover nested plan.md in scoped layouts (#3024)#3301
Noor-ul-ain001 wants to merge 3 commits into
github:mainfrom
Noor-ul-ain001:fix/3024-nested-plan-discovery

Conversation

@Noor-ul-ain001

@Noor-ul-ain001 Noor-ul-ain001 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #3024. The agent-context updater discovered plan.md only one level deep (specs/*/plan.md), so scoped layouts created via SPECIFY_FEATURE_DIRECTORY — e.g. specs/<scope>/<feature>/plan.md — were never found, and no plan reference was written into the context file.

Changes

  • bash (update-agent-context.sh): specs.glob("*/plan.md")specs.rglob("plan.md").
  • PowerShell (update-agent-context.ps1): one-level Get-ChildItem-Recurse.
  • PowerShell bug also fixed: the follow-up [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 surrounding try/catch, leaving $PlanPath empty 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 a specs/scope/001-feature/plan.md is discovered — which the old one-level glob would miss. The PowerShell test fails without the GetRelativePath fix 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 clean main — pre-existing environment artifacts, not touched by this change.

…#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>
@Noor-ul-ain001 Noor-ul-ain001 requested a review from mnriem as a code owner July 2, 2026 04:20
…n-discovery

# Conflicts:
#	extensions/agent-context/scripts/bash/update-agent-context.sh
#	extensions/agent-context/scripts/powershell/update-agent-context.ps1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.md is 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,
)
Comment thread tests/extensions/test_extension_agent_context.py Outdated

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: agent-context extension ignores scoped/nested spec directories (SPECIFY_FEATURE_DIRECTORY), so plan auto-discovery finds nothing

3 participants