From cbbc7bd075a78cc04b067baff1d68326d5f1c3d7 Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Sun, 1 Feb 2026 14:16:21 +0900 Subject: [PATCH] refactor: remove orphaned compaction-context-injector hook Hook was disconnected from plugin flow since commit 4a82ff40. Never called at runtime, superseded by preemptive-compaction hook. --- .../compaction-context-injector/index.test.ts | 102 ------------------ .../compaction-context-injector/index.ts | 76 ------------- src/hooks/index.ts | 1 - 3 files changed, 179 deletions(-) delete mode 100644 src/hooks/compaction-context-injector/index.test.ts delete mode 100644 src/hooks/compaction-context-injector/index.ts diff --git a/src/hooks/compaction-context-injector/index.test.ts b/src/hooks/compaction-context-injector/index.test.ts deleted file mode 100644 index 7c141f4d..00000000 --- a/src/hooks/compaction-context-injector/index.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { describe, expect, it, mock, beforeEach } from "bun:test" - -// Mock dependencies before importing -const mockInjectHookMessage = mock(() => true) -mock.module("../../features/hook-message-injector", () => ({ - injectHookMessage: mockInjectHookMessage, -})) - -mock.module("../../shared/logger", () => ({ - log: () => {}, -})) - -mock.module("../../shared/system-directive", () => ({ - createSystemDirective: (type: string) => `[DIRECTIVE:${type}]`, - SystemDirectiveTypes: { - TODO_CONTINUATION: "TODO CONTINUATION", - RALPH_LOOP: "RALPH LOOP", - BOULDER_CONTINUATION: "BOULDER CONTINUATION", - DELEGATION_REQUIRED: "DELEGATION REQUIRED", - SINGLE_TASK_ONLY: "SINGLE TASK ONLY", - COMPACTION_CONTEXT: "COMPACTION CONTEXT", - CONTEXT_WINDOW_MONITOR: "CONTEXT WINDOW MONITOR", - PROMETHEUS_READ_ONLY: "PROMETHEUS READ-ONLY", - }, -})) - -import { createCompactionContextInjector } from "./index" -import type { SummarizeContext } from "./index" - -describe("createCompactionContextInjector", () => { - beforeEach(() => { - mockInjectHookMessage.mockClear() - }) - - describe("Agent Verification State preservation", () => { - it("includes Agent Verification State section in compaction prompt", async () => { - // given - const injector = createCompactionContextInjector() - const context: SummarizeContext = { - sessionID: "test-session", - providerID: "anthropic", - modelID: "claude-sonnet-4-5", - usageRatio: 0.85, - directory: "/test/dir", - } - - // when - await injector(context) - - // then - expect(mockInjectHookMessage).toHaveBeenCalledTimes(1) - const calls = mockInjectHookMessage.mock.calls as unknown as [string, string, unknown][] - const injectedPrompt = calls[0]?.[1] ?? "" - expect(injectedPrompt).toContain("Agent Verification State") - expect(injectedPrompt).toContain("Current Agent") - expect(injectedPrompt).toContain("Verification Progress") - }) - - it("includes Momus-specific context for reviewer agents", async () => { - // given - const injector = createCompactionContextInjector() - const context: SummarizeContext = { - sessionID: "test-session", - providerID: "anthropic", - modelID: "claude-sonnet-4-5", - usageRatio: 0.9, - directory: "/test/dir", - } - - // when - await injector(context) - - // then - const calls = mockInjectHookMessage.mock.calls as unknown as [string, string, unknown][] - const injectedPrompt = calls[0]?.[1] ?? "" - expect(injectedPrompt).toContain("Previous Rejections") - expect(injectedPrompt).toContain("Acceptance Status") - expect(injectedPrompt).toContain("reviewer agents") - }) - - it("preserves file verification progress in compaction prompt", async () => { - // given - const injector = createCompactionContextInjector() - const context: SummarizeContext = { - sessionID: "test-session", - providerID: "anthropic", - modelID: "claude-sonnet-4-5", - usageRatio: 0.95, - directory: "/test/dir", - } - - // when - await injector(context) - - // then - const calls = mockInjectHookMessage.mock.calls as unknown as [string, string, unknown][] - const injectedPrompt = calls[0]?.[1] ?? "" - expect(injectedPrompt).toContain("Pending Verifications") - expect(injectedPrompt).toContain("Files already verified") - }) - }) -}) diff --git a/src/hooks/compaction-context-injector/index.ts b/src/hooks/compaction-context-injector/index.ts deleted file mode 100644 index 836e706e..00000000 --- a/src/hooks/compaction-context-injector/index.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { injectHookMessage } from "../../features/hook-message-injector" -import { log } from "../../shared/logger" -import { createSystemDirective, SystemDirectiveTypes } from "../../shared/system-directive" - -export interface SummarizeContext { - sessionID: string - providerID: string - modelID: string - usageRatio: number - directory: string -} - -const SUMMARIZE_CONTEXT_PROMPT = `${createSystemDirective(SystemDirectiveTypes.COMPACTION_CONTEXT)} - -When summarizing this session, you MUST include the following sections in your summary: - -## 1. User Requests (As-Is) -- List all original user requests exactly as they were stated -- Preserve the user's exact wording and intent - -## 2. Final Goal -- What the user ultimately wanted to achieve -- The end result or deliverable expected - -## 3. Work Completed -- What has been done so far -- Files created/modified -- Features implemented -- Problems solved - -## 4. Remaining Tasks -- What still needs to be done -- Pending items from the original request -- Follow-up tasks identified during the work - -## 5. Active Working Context (For Seamless Continuation) -- **Files**: Paths of files currently being edited or frequently referenced -- **Code in Progress**: Key code snippets, function signatures, or data structures under active development -- **External References**: Documentation URLs, library APIs, or external resources being consulted -- **State & Variables**: Important variable names, configuration values, or runtime state relevant to ongoing work - -## 6. MUST NOT Do (Critical Constraints) -- Things that were explicitly forbidden -- Approaches that failed and should not be retried -- User's explicit restrictions or preferences -- Anti-patterns identified during the session - -## 7. Agent Verification State (Critical for Reviewers) -- **Current Agent**: What agent is running (momus, oracle, etc.) -- **Verification Progress**: Files already verified/validated -- **Pending Verifications**: Files still needing verification -- **Previous Rejections**: If reviewer agent, what was rejected and why -- **Acceptance Status**: Current state of review process - -This section is CRITICAL for reviewer agents (momus, oracle) to maintain continuity. - -This context is critical for maintaining continuity after compaction. -` - -export function createCompactionContextInjector() { - return async (ctx: SummarizeContext): Promise => { - log("[compaction-context-injector] injecting context", { sessionID: ctx.sessionID }) - - const success = injectHookMessage(ctx.sessionID, SUMMARIZE_CONTEXT_PROMPT, { - agent: "general", - model: { providerID: ctx.providerID, modelID: ctx.modelID }, - path: { cwd: ctx.directory }, - }) - - if (success) { - log("[compaction-context-injector] context injected", { sessionID: ctx.sessionID }) - } else { - log("[compaction-context-injector] injection failed", { sessionID: ctx.sessionID }) - } - } -} diff --git a/src/hooks/index.ts b/src/hooks/index.ts index c8f3c0c3..51911ca3 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -9,7 +9,6 @@ export { createDirectoryReadmeInjectorHook } from "./directory-readme-injector"; export { createEmptyTaskResponseDetectorHook } from "./empty-task-response-detector"; export { createAnthropicContextWindowLimitRecoveryHook, type AnthropicContextWindowLimitRecoveryOptions } from "./anthropic-context-window-limit-recovery"; -export { createCompactionContextInjector } from "./compaction-context-injector"; export { createThinkModeHook } from "./think-mode"; export { createClaudeCodeHooksHook } from "./claude-code-hooks"; export { createRulesInjectorHook } from "./rules-injector";