mirror of
https://github.com/github/spec-kit.git
synced 2026-03-25 06:43:09 +00:00
fix: address PR review round 2 — legacy rmtree confirmation, agent_pack flag, registrar alias, manifest ID validation
- Legacy rmtree: prompt user before deleting agent directory in legacy fallback path (both no-manifest and AgentPackError cases), respects --force - Set options['agent_pack'] = True during agent_switch so projects originally created with --ai reflect pack-based management after switch - Add cursor-agent alias in CommandRegistrar.AGENT_CONFIGS so extension re-registration works when switching to/from cursor-agent - Validate manifest.id matches agent_id in resolve_agent_pack() to prevent malicious override packs from injecting different IDs
This commit is contained in:
@@ -2697,6 +2697,12 @@ def agent_switch(
|
|||||||
if agent_folder:
|
if agent_folder:
|
||||||
agent_dir = project_path / agent_folder.rstrip("/")
|
agent_dir = project_path / agent_folder.rstrip("/")
|
||||||
if agent_dir.is_dir():
|
if agent_dir.is_dir():
|
||||||
|
if not force:
|
||||||
|
console.print(f"[yellow]No install manifest found for '{current_agent}' (legacy project).[/yellow]")
|
||||||
|
console.print(f" Directory to remove: {agent_dir}")
|
||||||
|
if not typer.confirm("Remove this directory?"):
|
||||||
|
console.print("[dim]Aborted. Use --force to skip this check.[/dim]")
|
||||||
|
raise typer.Exit(0)
|
||||||
shutil.rmtree(agent_dir)
|
shutil.rmtree(agent_dir)
|
||||||
console.print(f" [green]✓[/green] {current_agent} directory removed (legacy)")
|
console.print(f" [green]✓[/green] {current_agent} directory removed (legacy)")
|
||||||
else:
|
else:
|
||||||
@@ -2708,6 +2714,12 @@ def agent_switch(
|
|||||||
if agent_folder:
|
if agent_folder:
|
||||||
agent_dir = project_path / agent_folder.rstrip("/")
|
agent_dir = project_path / agent_folder.rstrip("/")
|
||||||
if agent_dir.is_dir():
|
if agent_dir.is_dir():
|
||||||
|
if not force:
|
||||||
|
console.print(f"[yellow]No agent pack found for '{current_agent}' (legacy project).[/yellow]")
|
||||||
|
console.print(f" Directory to remove: {agent_dir}")
|
||||||
|
if not typer.confirm("Remove this directory?"):
|
||||||
|
console.print("[dim]Aborted. Use --force to skip this check.[/dim]")
|
||||||
|
raise typer.Exit(0)
|
||||||
shutil.rmtree(agent_dir)
|
shutil.rmtree(agent_dir)
|
||||||
console.print(f" [green]✓[/green] {current_agent} directory removed (legacy)")
|
console.print(f" [green]✓[/green] {current_agent} directory removed (legacy)")
|
||||||
|
|
||||||
@@ -2757,6 +2769,7 @@ def agent_switch(
|
|||||||
|
|
||||||
# Update init options
|
# Update init options
|
||||||
options["ai"] = agent_id
|
options["ai"] = agent_id
|
||||||
|
options["agent_pack"] = True
|
||||||
options.pop("agent_switch_error", None) # clear any previous error
|
options.pop("agent_switch_error", None) # clear any previous error
|
||||||
init_options_file.write_text(json.dumps(options, indent=2), encoding="utf-8")
|
init_options_file.write_text(json.dumps(options, indent=2), encoding="utf-8")
|
||||||
|
|
||||||
|
|||||||
@@ -721,6 +721,14 @@ def resolve_agent_pack(
|
|||||||
manifest_file = pack_dir / MANIFEST_FILENAME
|
manifest_file = pack_dir / MANIFEST_FILENAME
|
||||||
if manifest_file.is_file():
|
if manifest_file.is_file():
|
||||||
manifest = AgentManifest.from_yaml(manifest_file)
|
manifest = AgentManifest.from_yaml(manifest_file)
|
||||||
|
# Verify the manifest's declared ID matches the requested
|
||||||
|
# agent_id to prevent a malicious override from injecting
|
||||||
|
# a different ID (used for file paths and module names).
|
||||||
|
if manifest.id != agent_id:
|
||||||
|
raise PackResolutionError(
|
||||||
|
f"Agent pack manifest ID '{manifest.id}' does not match "
|
||||||
|
f"requested ID '{agent_id}' (in {pack_dir})."
|
||||||
|
)
|
||||||
if source == "embedded":
|
if source == "embedded":
|
||||||
embedded_manifest = manifest
|
embedded_manifest = manifest
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ class CommandRegistrar:
|
|||||||
"args": "$ARGUMENTS",
|
"args": "$ARGUMENTS",
|
||||||
"extension": ".md"
|
"extension": ".md"
|
||||||
},
|
},
|
||||||
|
"cursor-agent": {
|
||||||
|
"dir": ".cursor/commands",
|
||||||
|
"format": "markdown",
|
||||||
|
"args": "$ARGUMENTS",
|
||||||
|
"extension": ".md"
|
||||||
|
},
|
||||||
"qwen": {
|
"qwen": {
|
||||||
"dir": ".qwen/commands",
|
"dir": ".qwen/commands",
|
||||||
"format": "markdown",
|
"format": "markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user