The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
fix(cli): require confirmation for instructions file deletes (#11504)
馨冉81cea89d6b55
diff --git a/cli/src/__tests__/agent-lifecycle.test.ts b/cli/src/__tests__/agent-lifecycle.test.tsindex 73f602ab0e..0410be70c7 100644--- a/cli/src/__tests__/agent-lifecycle.test.ts+++ b/cli/src/__tests__/agent-lifecycle.test.ts@@ -109,7 +109,7 @@ describe("agent lifecycle commands", () => {await run(["agent", "instructions-bundle:update", AGENT_ID, "--payload-json", JSON.stringify({ mode: "managed" })]);await run(["agent", "instructions-file:get", AGENT_ID, "--path", "AGENTS.md"]);await run(["agent", "instructions-file:put", AGENT_ID, "--path", "AGENTS.md", "--content", "hello"]);- await run(["agent", "instructions-file:delete", AGENT_ID, "--path", "AGENTS.md"]);+ await run(["agent", "instructions-file:delete", AGENT_ID, "--path", "AGENTS.md", "--yes"]);expect(fetchMock.mock.calls.map((call) => [call[1]?.method ?? "GET", call[0]])).toEqual([["PATCH", `http://localhost:3100/api/agents/${AGENT_ID}/permissions`],@@ -130,6 +130,20 @@ describe("agent lifecycle commands", () => {["DELETE", `http://localhost:3100/api/agents/${AGENT_ID}/instructions-bundle/file?path=AGENTS.md`],]);});++ it("refuses to delete an instructions file without confirmation", async () => {+ const fetchMock = vi.fn().mockImplementation(() => Promise.resolve(jsonResponse()));+ vi.stubGlobal("fetch", fetchMock);+ vi.spyOn(process, "exit").mockImplementation(((code?: string | number | null) => {+ throw new Error(`exit:${code ?? 0}`);+ }) as typeof process.exit);++ await expect(run(["agent", "instructions-file:delete", AGENT_ID, "--path", "AGENTS.md"])).rejects.toThrow(+ "exit:1",+ );++ expect(fetchMock).not.toHaveBeenCalled();+ });});function jsonResponse(body: unknown = { ok: true }, init: ResponseInit = { status: 200 }): Response {diff --git a/cli/src/commands/client/agent.ts b/cli/src/commands/client/agent.tsindex 50e1a4388c..c8e6a122f5 100644--- a/cli/src/commands/client/agent.ts+++ b/cli/src/commands/client/agent.ts@@ -77,6 +77,7 @@ interface AgentSkillsSyncOptions extends BaseClientOptions {interface AgentInstructionsFileOptions extends BaseClientOptions {path: string;+ yes?: boolean;}interface AgentInstructionsFilePutOptions extends BaseClientOptions {@@ -720,8 +721,10 @@ export function registerAgentCommands(program: Command): void {.description("Delete an agent instructions file").argument("<agentId>", "Agent ID").requiredOption("--path <path>", "Bundle-relative file path")+ .option("--yes", "Confirm deletion").action(async (agentId: string, opts: AgentInstructionsFileOptions) => {try {+ if (!opts.yes) throw new Error("Refusing to delete without --yes");const ctx = resolveCommandContext(opts);const query = new URLSearchParams({ path: opts.path });const result = await ctx.api.delete(`${apiPath`/api/agents/${agentId}/instructions-bundle/file`}?${query.toString()}`);diff --git a/doc/CLI.md b/doc/CLI.mdindex 7efb1eb580..592621eb51 100644--- a/doc/CLI.md+++ b/doc/CLI.md@@ -566,7 +566,7 @@ npx paperclipai agent instructions-bundle <agent-id>npx paperclipai agent instructions-bundle:update <agent-id> --payload-json '{"mode":"managed"}'npx paperclipai agent instructions-file:get <agent-id> --path AGENTS.mdnpx paperclipai agent instructions-file:put <agent-id> --path AGENTS.md --content-file ./AGENTS.md-npx paperclipai agent instructions-file:delete <agent-id> --path AGENTS.md+npx paperclipai agent instructions-file:delete <agent-id> --path AGENTS.md --yes```Agent config, instructions, skills, project env, environment, secret, and workspace edits affect the next run. Active runs finish with the config they started with. When a saved session, reused workspace, or sandbox lease no longer matches the effective next-run config, Paperclip may start fresh execution and records non-sensitive freshness categories in run result JSON and workspace operation logs.