Skip to content

[Bug]: agent-context Python port misses nested plans (one-level glob), a parity regression of #3024 #3733

Description

@matecardoso

What happened

The agent-context extension's Python port (extensions/agent-context/scripts/python/update_agent_context.py) uses a one-level scan in its plan-path mtime fallback:

plans = sorted(
    (root / "specs").glob("*/plan.md"),   # line ~176
    key=lambda p: p.stat().st_mtime,
    reverse=True,
)

This does not match nested scoped layouts such as specs/<scope>/<feature>/plan.md. As a result, when no explicit plan_path is given and feature.json is absent, the managed context section is written without the plan link.

Why this is a regression

The Bash and PowerShell ports already search recursively for exactly this case, explicitly referencing #3024:

  • Bash: specs.rglob("plan.md")
  • PowerShell: Get-ChildItem ... -Recurse

The command documentation (speckit.agent-context.update.md) also promises recursive discovery. Issue #3024 fixed Bash/PowerShell, but the later Python port (#3387) reintroduced the one-level glob, so the three ports are no longer in parity and the Python one violates the documented contract.

Expected

The Python port discovers the most recently modified plan.md anywhere under specs/, matching the Bash/PowerShell ports and the documented behavior.

Fix

(root / "specs").rglob("plan.md"). PR incoming with a parity regression test (fails on the one-level glob, passes with the recursive scan).

Version

Reproduced on main (0.14.2 / 0.14.3.dev0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions