Ver Fonte

Remove reminder system-transform no-ops

Alvin Unreal há 3 meses atrás
pai
commit
4eac3c656f

+ 0 - 41
src/hooks/post-file-tool-nudge/index.test.ts

@@ -28,19 +28,6 @@ describe('post-file-tool-nudge hook', () => {
     expect(output.output).toContain('</internal_reminder>');
   });
 
-  test('system transform is no-op (cache-safe)', async () => {
-    const hook = createPostFileToolNudgeHook();
-    const system = { system: ['base system prompt'] };
-
-    await hook['experimental.chat.system.transform'](
-      { sessionID: 's1' },
-      system,
-    );
-
-    expect(system.system).toEqual(['base system prompt']);
-    expect(system.system.join('\n')).not.toContain(PHASE_REMINDER_TEXT);
-  });
-
   test('does not duplicate reminder in same tool output', async () => {
     const hook = createPostFileToolNudgeHook();
     const output = createOutput();
@@ -104,32 +91,4 @@ describe('post-file-tool-nudge hook', () => {
     expect(output.output).toBe('real content');
     expect(output.output).not.toContain(PHASE_REMINDER_TEXT);
   });
-
-  test('handles session.deleted event without error', async () => {
-    const hook = createPostFileToolNudgeHook();
-
-    await hook.event({
-      event: {
-        type: 'session.deleted',
-        properties: { info: { id: 's1' } },
-      },
-    });
-
-    // Should not throw
-    expect(true).toBe(true);
-  });
-
-  test('handles session.deleted with sessionID property', async () => {
-    const hook = createPostFileToolNudgeHook();
-
-    await hook.event({
-      event: {
-        type: 'session.deleted',
-        properties: { sessionID: 's1' },
-      },
-    });
-
-    // Should not throw
-    expect(true).toBe(true);
-  });
 });

+ 0 - 31
src/hooks/post-file-tool-nudge/index.ts

@@ -13,28 +13,10 @@ interface ToolExecuteAfterInput {
   callID?: string;
 }
 
-interface ChatSystemTransformInput {
-  sessionID?: string;
-}
-
-interface ChatSystemTransformOutput {
-  system: string[];
-}
-
 interface ToolExecuteAfterOutput {
   output?: unknown;
 }
 
-interface EventInput {
-  event: {
-    type: string;
-    properties?: {
-      info?: { id?: string };
-      sessionID?: string;
-    };
-  };
-}
-
 interface PostFileToolNudgeOptions {
   shouldInject?: (sessionID: string) => boolean;
 }
@@ -77,18 +59,5 @@ export function createPostFileToolNudgeHook(
 
       appendReminder(output);
     },
-    'experimental.chat.system.transform': async (
-      _input: ChatSystemTransformInput,
-      _output: ChatSystemTransformOutput,
-    ): Promise<void> => {
-      // Kept as a no-op for hook shape compatibility. Dynamic reminders must
-      // not mutate the system prompt because OpenCode prompt-caches system
-      // messages as the stable prefix.
-    },
-    event: async (input: EventInput): Promise<void> => {
-      if (input.event.type !== 'session.deleted') {
-        return;
-      }
-    },
   };
 }

+ 2 - 36
src/hooks/task-session-manager/index.test.ts

@@ -77,43 +77,9 @@ describe('task-session-manager hook', () => {
     expect(userMessage.parts[0].text).toContain('</resumable_sessions>');
   });
 
-  test('system transform is no-op (cache-safe)', async () => {
+  test('does not expose a system transform for resumable sessions', async () => {
     const { hook } = createHook();
-
-    await hook['tool.execute.before'](
-      {
-        tool: 'task',
-        sessionID: 'parent-1',
-        callID: 'call-1',
-      },
-      {
-        args: {
-          subagent_type: 'explorer',
-          description: 'config schema',
-        },
-      },
-    );
-
-    await hook['tool.execute.after'](
-      {
-        tool: 'task',
-        sessionID: 'parent-1',
-        callID: 'call-1',
-      },
-      {
-        output:
-          'task_id: child-1 (for resuming to continue this task if needed)',
-      },
-    );
-
-    const system = { system: ['base'] };
-    await hook['experimental.chat.system.transform'](
-      { sessionID: 'parent-1' },
-      system,
-    );
-
-    expect(system.system).toEqual(['base']);
-    expect(system.system.join('\n')).not.toContain('Resumable Sessions');
+    expect('experimental.chat.system.transform' in hook).toBe(false);
   });
 
   test('resolves remembered aliases to real task ids before execution', async () => {

+ 0 - 12
src/hooks/task-session-manager/index.ts

@@ -335,18 +335,6 @@ export function createTaskSessionManagerHook(
       pruneContext();
     },
 
-    'experimental.chat.system.transform': async (
-      input: { sessionID?: string },
-      _output: { system: string[] },
-    ): Promise<void> => {
-      if (!input.sessionID || !options.shouldManageSession(input.sessionID)) {
-        return;
-      }
-      // Kept as a no-op for hook shape compatibility. Dynamic resumable
-      // sessions are injected into request-local message context instead of
-      // the cached system prompt.
-    },
-
     'experimental.chat.messages.transform': async (
       _input: Record<string, never>,
       output: { messages: ChatMessage[] },

+ 2 - 21
src/hooks/todo-continuation/index.test.ts

@@ -129,7 +129,7 @@ describe('createTodoContinuationHook', () => {
       expect(toolOutput.output).not.toContain(TODO_HYGIENE_REMINDER);
     });
 
-    test('system transform is no-op (cache-safe)', async () => {
+    test('does not expose a system transform handler', async () => {
       const ctx = createMockContext({
         todoResult: {
           data: [
@@ -143,27 +143,8 @@ describe('createTodoContinuationHook', () => {
         },
       });
       const hook = createTodoContinuationHook(ctx);
-      const system = { system: ['base'] };
 
-      await hook.handleMessagesTransform(
-        userMessages(
-          'continue with the unfinished work',
-          'main1',
-          'orchestrator',
-        ),
-      );
-      await hook.handleToolExecuteAfter({
-        tool: 'todowrite',
-        sessionID: 'main1',
-      });
-      await hook.handleToolExecuteAfter({ tool: 'read', sessionID: 'main1' });
-      await hook.handleChatSystemTransform({ sessionID: 'main1' }, system);
-
-      expect(system.system).toEqual(['base']);
-      expect(system.system.join('\n')).not.toContain(TODO_HYGIENE_REMINDER);
-      expect(system.system.join('\n')).not.toContain(
-        TODO_FINAL_ACTIVE_REMINDER,
-      );
+      expect('handleChatSystemTransform' in hook).toBe(false);
     });
 
     test('injects hygiene reminder into tool output after todowrite activity', async () => {

+ 0 - 5
src/hooks/todo-continuation/index.ts

@@ -129,10 +129,6 @@ export function createTodoContinuationHook(
     },
     output?: { output?: unknown },
   ) => Promise<void>;
-  handleChatSystemTransform: (
-    input: { sessionID?: string },
-    output: { system: string[] },
-  ) => Promise<void>;
   handleMessagesTransform: (output: {
     messages: ChatTransformMessage[];
   }) => Promise<void>;
@@ -819,7 +815,6 @@ export function createTodoContinuationHook(
   return {
     tool: { auto_continue: autoContinue },
     handleToolExecuteAfter: hygiene.handleToolExecuteAfter,
-    handleChatSystemTransform: hygiene.handleChatSystemTransform,
     handleMessagesTransform,
     handleEvent,
     handleChatMessage,

+ 2 - 9
src/hooks/todo-continuation/todo-hygiene.test.ts

@@ -51,19 +51,12 @@ describe('todo hygiene', () => {
     expect(freshOutput.output).toContain(TODO_HYGIENE_REMINDER);
   });
 
-  test('system transform is no-op (cache-safe)', async () => {
+  test('does not expose a system transform handler', async () => {
     const hook = createTodoHygiene({
       getTodoState: async () => createState(),
     });
-    const system = { system: ['base'] };
 
-    hook.handleRequestStart({ sessionID: 's1' });
-    await hook.handleToolExecuteAfter({ tool: 'todowrite', sessionID: 's1' });
-    await hook.handleToolExecuteAfter({ tool: 'read', sessionID: 's1' });
-    await hook.handleChatSystemTransform({ sessionID: 's1' }, system);
-
-    expect(system.system).toEqual(['base']);
-    expect(system.system.join('\n')).not.toContain(TODO_HYGIENE_REMINDER);
+    expect('handleChatSystemTransform' in hook).toBe(false);
   });
 
   test('does not arm before the current request calls todowrite', async () => {

+ 0 - 53
src/hooks/todo-continuation/todo-hygiene.ts

@@ -17,14 +17,6 @@ interface ToolOutput {
   output?: unknown;
 }
 
-interface SystemInput {
-  sessionID?: string;
-}
-
-interface SystemOutput {
-  system: string[];
-}
-
 interface EventInput {
   type: string;
   properties?: {
@@ -214,51 +206,6 @@ export function createTodoHygiene(options: Options) {
       }
     },
 
-    async handleChatSystemTransform(
-      input: SystemInput,
-      _output: SystemOutput,
-    ): Promise<void> {
-      if (!input.sessionID) {
-        return;
-      }
-
-      const reasons = pending.get(input.sessionID);
-      if (!reasons || reasons.size === 0) {
-        return;
-      }
-
-      const reminder = pick(reasons);
-
-      if (options.shouldInject && !options.shouldInject(input.sessionID)) {
-        clear(input.sessionID);
-        return;
-      }
-
-      try {
-        const state = await options.getTodoState(input.sessionID);
-        if (!state.hasOpenTodos) {
-          clear(input.sessionID);
-          return;
-        }
-
-        pending.delete(input.sessionID);
-        options.log?.('Injected todo hygiene reminder', {
-          sessionID: input.sessionID,
-          reminder,
-          reasons: Array.from(reasons),
-        });
-      } catch (error) {
-        pending.delete(input.sessionID);
-        options.log?.(
-          'Skipped todo hygiene reminder: failed to inspect todos',
-          {
-            sessionID: input.sessionID,
-            error: error instanceof Error ? error.message : String(error),
-          },
-        );
-      }
-    },
-
     handleEvent(event: EventInput): void {
       if (event.type !== 'session.deleted') {
         return;

+ 0 - 12
src/index.ts

@@ -754,18 +754,6 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
         },
       );
 
-      await postFileToolNudgeHook.event(
-        input as {
-          event: {
-            type: string;
-            properties?: {
-              info?: { id?: string };
-              sessionID?: string;
-            };
-          };
-        },
-      );
-
       await taskSessionManagerHook.event(
         input as {
           event: {