From 38ae7595685ae9a216f531a538066af0aadd7dfe Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:44:25 -0500 Subject: [PATCH] fix: stale manifest cleanup, resolve with project_path, AGENTS.md add docs - remove_tracked_files: count only still-existing files as remaining; user-deleted files no longer prevent manifest cleanup - init --agent: pass project_path to resolve_agent_pack so project-level overrides (.specify/agents/) are honored during --here init - AGENTS.md: update agent add to show --from requirement and note catalog fetch is not yet implemented --- AGENTS.md | 4 +++- src/specify_cli/__init__.py | 2 +- src/specify_cli/agent_pack.py | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 6fc9303f1..664418dea 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -453,9 +453,11 @@ specify init --here --agent gemini --ai-skills # With skills | `specify agent search [query]` | Search agents by name, ID, description, or tags | | `specify agent validate ` | Validate an agent pack directory | | `specify agent export ` | Export an agent pack for editing | -| `specify agent add ` | Install an agent pack from a local path | +| `specify agent add --from ` | Install an agent pack from a local directory | | `specify agent remove ` | Remove a cached/override agent pack | +> **Note:** `specify agent add ` without `--from ` is reserved for future catalog-based installation, which is not yet implemented. + ### Pack resolution order Agent packs resolve by priority (highest first): diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index ea432804b..f4378e743 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -1877,7 +1877,7 @@ def init( if use_agent_pack: from .agent_pack import resolve_agent_pack, load_bootstrap, PackResolutionError, AgentPackError try: - resolved = resolve_agent_pack(selected_ai) + resolved = resolve_agent_pack(selected_ai, project_path=project_path) agent_bootstrap = load_bootstrap(resolved.path, resolved.manifest) console.print(f"[dim]Pack-based flow: {resolved.manifest.name} ({resolved.source})[/dim]") except (PackResolutionError, AgentPackError) as exc: diff --git a/src/specify_cli/agent_pack.py b/src/specify_cli/agent_pack.py index 7899fba6e..d77404bf2 100644 --- a/src/specify_cli/agent_pack.py +++ b/src/specify_cli/agent_pack.py @@ -695,12 +695,17 @@ def remove_tracked_files( abs_path.unlink() removed.append(rel_path) - # Clean up the install manifest only when all tracked files were - # removed. If some were skipped (modified), keep the manifest so - # those files remain tracked for future teardown attempts. + # Clean up the install manifest only when no tracked files remain + # on disk. Files already deleted by the user count as gone, not + # as "remaining" — only files that still exist and were skipped + # (e.g. modified without --force) prevent manifest cleanup. if manifest_file.is_file(): - remaining = len(entries) - len(removed) - if remaining == 0: + still_on_disk = sum( + 1 for rel_path in entries + if (project_path / rel_path).is_file() + and rel_path not in removed + ) + if still_on_disk == 0: manifest_file.unlink(missing_ok=True) return removed