chore: remove setup hooks (#845)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -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" },
|
||||
];
|
||||
|
||||
@@ -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<HookExecutionResult> {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
// ============================================================================
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user