From 37981066b555637b5cfe55ec2140dca6c6645fe7 Mon Sep 17 00:00:00 2001 From: jnjpng Date: Thu, 5 Feb 2026 19:53:14 -0800 Subject: [PATCH] chore: remove setup hooks (#845) Co-authored-by: Letta --- src/cli/components/HooksManager.tsx | 1 - src/hooks/index.ts | 22 ------------ src/hooks/types.ts | 11 ------ src/tests/hooks/integration.test.ts | 53 ----------------------------- src/tests/hooks/loader.test.ts | 5 ++- src/tests/settings-manager.test.ts | 3 +- 6 files changed, 3 insertions(+), 92 deletions(-) diff --git a/src/cli/components/HooksManager.tsx b/src/cli/components/HooksManager.tsx index 5ddae7e..410db8d 100644 --- a/src/cli/components/HooksManager.tsx +++ b/src/cli/components/HooksManager.tsx @@ -81,7 +81,6 @@ const HOOK_EVENTS: { event: HookEvent; description: string }[] = [ { event: "Stop", description: "When the agent finishes responding" }, { event: "SubagentStop", description: "When a subagent completes" }, { event: "PreCompact", description: "Before context compaction" }, - { event: "Setup", description: "When invoked with --init flags" }, { event: "SessionStart", description: "When a session starts" }, { event: "SessionEnd", description: "When a session ends" }, ]; diff --git a/src/hooks/index.ts b/src/hooks/index.ts index af1c582..5336146 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -15,7 +15,6 @@ import type { PreToolUseHookInput, SessionEndHookInput, SessionStartHookInput, - SetupHookInput, StopHookInput, SubagentStopHookInput, UserPromptSubmitHookInput, @@ -358,27 +357,6 @@ export async function runPreCompactHooks( return executeHooksParallel(hooks, input, workingDirectory); } -/** - * Run Setup hooks when CLI is invoked with init flags - */ -export async function runSetupHooks( - initType: "init" | "init-only" | "maintenance", - workingDirectory: string = process.cwd(), -): Promise { - const hooks = await getHooksForEvent("Setup", undefined, workingDirectory); - if (hooks.length === 0) { - return { blocked: false, errored: false, feedback: [], results: [] }; - } - - const input: SetupHookInput = { - event_type: "Setup", - working_directory: workingDirectory, - init_type: initType, - }; - - return executeHooks(hooks, input, workingDirectory); -} - /** * Run SessionStart hooks when a session begins * Unlike other hooks, SessionStart collects stdout (not stderr) on exit 2 diff --git a/src/hooks/types.ts b/src/hooks/types.ts index e0a8489..4cb91ad 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -19,7 +19,6 @@ export type SimpleHookEvent = | "Stop" // Runs when the agent finishes responding (can block) | "SubagentStop" // Runs when subagent tasks complete (can block) | "PreCompact" // Runs before a compact operation (cannot block) - | "Setup" // Runs when invoked with --init, --init-only, or --maintenance flags | "SessionStart" // Runs when a new session starts or is resumed | "SessionEnd"; // Runs when session ends (cannot block) @@ -395,15 +394,6 @@ export interface PreCompactHookInput extends HookInputBase { conversation_id?: string; } -/** - * Input for Setup hooks - */ -export interface SetupHookInput extends HookInputBase { - event_type: "Setup"; - /** Which init flag was used */ - init_type: "init" | "init-only" | "maintenance"; -} - /** * Input for SessionStart hooks */ @@ -449,6 +439,5 @@ export type HookInput = | StopHookInput | SubagentStopHookInput | PreCompactHookInput - | SetupHookInput | SessionStartHookInput | SessionEndHookInput; diff --git a/src/tests/hooks/integration.test.ts b/src/tests/hooks/integration.test.ts index 6c63cbb..b788ca9 100644 --- a/src/tests/hooks/integration.test.ts +++ b/src/tests/hooks/integration.test.ts @@ -15,7 +15,6 @@ import { runPreToolUseHooks, runSessionEndHooks, runSessionStartHooks, - runSetupHooks, runStopHooks, runSubagentStopHooks, runUserPromptSubmitHooks, @@ -854,58 +853,6 @@ describe.skipIf(isWindows)("Hooks Integration Tests", () => { }); }); - // ============================================================================ - // Setup Hooks - // ============================================================================ - - describe("Setup hooks", () => { - test("runs on init", async () => { - createHooksConfig({ - Setup: [ - { - matcher: "*", - hooks: [{ type: "command", command: "echo 'initializing'" }], - }, - ], - }); - - const result = await runSetupHooks("init", tempDir); - - expect(result.results[0]?.stdout).toBe("initializing"); - }); - - test("runs on maintenance", async () => { - createHooksConfig({ - Setup: [ - { - matcher: "*", - hooks: [{ type: "command", command: "echo 'maintenance mode'" }], - }, - ], - }); - - const result = await runSetupHooks("maintenance", tempDir); - - expect(result.results[0]?.stdout).toBe("maintenance mode"); - }); - - test("receives init_type in input", async () => { - createHooksConfig({ - Setup: [ - { - matcher: "*", - hooks: [{ type: "command", command: "cat" }], - }, - ], - }); - - const result = await runSetupHooks("init-only", tempDir); - - const parsed = JSON.parse(result.results[0]?.stdout || "{}"); - expect(parsed.init_type).toBe("init-only"); - }); - }); - // ============================================================================ // SessionStart Hooks // ============================================================================ diff --git a/src/tests/hooks/loader.test.ts b/src/tests/hooks/loader.test.ts index 06b59fc..39c8395 100644 --- a/src/tests/hooks/loader.test.ts +++ b/src/tests/hooks/loader.test.ts @@ -393,7 +393,7 @@ describe("Hooks Loader", () => { }); }); - describe("All 11 hook events", () => { + describe("All 10 hook events", () => { const allEvents: HookEvent[] = [ "PreToolUse", "PostToolUse", @@ -403,12 +403,11 @@ describe("Hooks Loader", () => { "Stop", "SubagentStop", "PreCompact", - "Setup", "SessionStart", "SessionEnd", ]; - test("config can have all 11 event types", () => { + test("config can have all 10 event types", () => { const config: HooksConfig = {}; for (const event of allEvents) { if (isToolEvent(event)) { diff --git a/src/tests/settings-manager.test.ts b/src/tests/settings-manager.test.ts index 52ef3cf..9eae527 100644 --- a/src/tests/settings-manager.test.ts +++ b/src/tests/settings-manager.test.ts @@ -648,7 +648,7 @@ describe("Settings Manager - Hooks", () => { ); }); - test("All 11 hook event types can be configured", async () => { + test("All 10 hook event types can be configured", async () => { const allHookEvents = [ "PreToolUse", "PostToolUse", @@ -658,7 +658,6 @@ describe("Settings Manager - Hooks", () => { "Stop", "SubagentStop", "PreCompact", - "Setup", "SessionStart", "SessionEnd", ] as const;