mirror of
https://github.com/github/spec-kit.git
synced 2026-03-21 21:03:08 +00:00
Move file recording to finalize_setup() — called after init pipeline writes files
Address code review: setup() now only creates directories, while finalize_setup() (on base class) scans the agent's commands_dir for all files and records them. This ensures files are tracked after the full init pipeline has written them, not before. - Add AgentBootstrap.finalize_setup() that scans commands_dir - Remove premature record_installed_files() from all 25 setup() methods - agent_switch calls finalize_setup() after setup() completes - Update test helper to match new pattern Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/spec-kit/sessions/779eabf6-21d5-428b-9f01-dd363df4c84a
This commit is contained in:
committed by
GitHub
parent
b5a5e3fc35
commit
a63c248c80
@@ -80,16 +80,13 @@ def _write_bootstrap(pack_dir: Path, class_name: str = "TestAgent", agent_dir: s
|
||||
bootstrap_file.write_text(textwrap.dedent(f"""\
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
from specify_cli.agent_pack import AgentBootstrap, record_installed_files, remove_tracked_files
|
||||
from specify_cli.agent_pack import AgentBootstrap, remove_tracked_files
|
||||
|
||||
class {class_name}(AgentBootstrap):
|
||||
AGENT_DIR = "{agent_dir}"
|
||||
|
||||
def setup(self, project_path: Path, script_type: str, options: Dict[str, Any]) -> None:
|
||||
commands_dir = project_path / self.AGENT_DIR / "commands"
|
||||
commands_dir.mkdir(parents=True, exist_ok=True)
|
||||
installed = [p for p in commands_dir.rglob("*") if p.is_file()]
|
||||
record_installed_files(project_path, self.manifest.id, installed)
|
||||
(project_path / self.AGENT_DIR / "commands").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def teardown(self, project_path: Path, *, force: bool = False) -> None:
|
||||
remove_tracked_files(project_path, self.manifest.id, force=force)
|
||||
@@ -279,10 +276,17 @@ class TestBootstrapContract:
|
||||
b.setup(project, "sh", {})
|
||||
assert (project / ".test-agent" / "commands").is_dir()
|
||||
|
||||
# The install manifest should exist in .specify/
|
||||
# Simulate the init pipeline writing a file
|
||||
cmd_file = project / ".test-agent" / "commands" / "hello.md"
|
||||
cmd_file.write_text("hello", encoding="utf-8")
|
||||
|
||||
# finalize_setup records files for tracking
|
||||
b.finalize_setup(project)
|
||||
assert _manifest_path(project, "test-agent").is_file()
|
||||
|
||||
b.teardown(project)
|
||||
# The tracked file should be removed
|
||||
assert not cmd_file.exists()
|
||||
# Install manifest itself should be cleaned up
|
||||
assert not _manifest_path(project, "test-agent").is_file()
|
||||
# Directories are preserved (only files are removed)
|
||||
|
||||
Reference in New Issue
Block a user