Skip to content

fix: discover nested agent context plans#3061

Open
luohui1 wants to merge 1 commit into
github:mainfrom
luohui1:fix/3024-agent-context-nested-plan
Open

fix: discover nested agent context plans#3061
luohui1 wants to merge 1 commit into
github:mainfrom
luohui1:fix/3024-agent-context-nested-plan

Conversation

@luohui1

@luohui1 luohui1 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #3024 by making the agent-context update scripts discover the newest plan.md anywhere under specs/, including nested/scoped feature directories such as specs/scope/feature/plan.md.

Bash and PowerShell script behavior stays in parity, and the extension command documentation now describes recursive plan discovery. The Bash script comments now match the implementation: discovery is handled by a Python pathlib scan with stat() sorting.

Split out from #3053 after maintainer feedback to keep each bug fix in its own PR.

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

Additional validation after addressing review feedback:

  • uv run --extra test python -m pytest tests/extensions/test_extension_agent_context.py -q - 35 passed, 1 skipped
  • uvx ruff check tests/extensions/test_extension_agent_context.py - passed
  • uvx ruff format --check tests/extensions/test_extension_agent_context.py - passed
  • git diff --check - passed

Manual test results

Agent: Codex (GPT-5) | OS/Shell: Windows 11 / PowerShell 7.5.4

Command tested Notes
.specify/extensions/agent-context/scripts/bash/update-agent-context.sh Covered by regression test with nested specs/scope/feature/plan.md.
.specify/extensions/agent-context/scripts/powershell/update-agent-context.ps1 Covered by regression test with nested specs/scope/feature/plan.md.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

This PR was implemented by Codex (GPT-5) acting as an AI coding agent on behalf of @luohui1. The agent read the repository contribution/security/code-of-conduct docs and issue templates, inspected the relevant code paths, implemented the changes, ran the validation listed above, and prepared this PR description.

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

This PR fixes the bundled agent-context extension’s plan auto-discovery so it finds the most recently modified plan.md anywhere under specs/, including nested/scoped feature directories (e.g. specs/scope/feature/plan.md). This aligns the behavior with SPECIFY_FEATURE_DIRECTORY layouts and keeps Bash/PowerShell behavior in parity.

Changes:

  • Update Bash plan discovery from specs/*/plan.md to recursive specs/**/plan.md.
  • Update PowerShell plan discovery to recurse under specs/ and select the newest plan.md.
  • Add regression tests for nested plan discovery and update extension command docs to describe the recursive behavior.
Show a summary per file
File Description
tests/extensions/test_extension_agent_context.py Adds regression tests to ensure both scripts resolve nested specs/.../plan.md paths.
extensions/agent-context/scripts/powershell/update-agent-context.ps1 Switches plan discovery to recursive search under specs/ and picks most recently modified match.
extensions/agent-context/scripts/bash/update-agent-context.sh Switches plan discovery to recursive **/plan.md glob and updates related comments.
extensions/agent-context/commands/speckit.agent-context.update.md Updates documentation to describe recursive plan discovery behavior.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread extensions/agent-context/scripts/bash/update-agent-context.sh 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. If not applicable, please explain why

@luohui1 luohui1 force-pushed the fix/3024-agent-context-nested-plan branch from 6fc53da to aff4285 Compare June 22, 2026 05:04
@mnriem mnriem requested a review from Copilot June 22, 2026 14:08

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.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment on lines 128 to 136
_plan_abs="$("$_python" - "$PROJECT_ROOT" <<'PY'
import sys, os
from pathlib import Path
specs = Path(sys.argv[1]) / "specs"
plans = sorted(
specs.glob("*/plan.md"),
specs.glob("**/plan.md"),
key=lambda p: p.stat().st_mtime,
reverse=True,
)
Comment on lines +476 to +478
assert result.returncode == 0, result.stderr
text = (tmp_path / "CLAUDE.md").read_text(encoding="utf-8")
assert "specs/scope/feature/plan.md" in text
Comment on lines +499 to +501
assert result.returncode == 0, result.stderr
text = (tmp_path / "CLAUDE.md").read_text(encoding="utf-8")
assert "specs/scope/feature/plan.md" in text
@mnriem

mnriem commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

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