From e54f7479163b0d09770e09f141aaf2d5a9cc6814 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 10 Apr 2026 18:47:17 +0900 Subject: [PATCH] fix(tests): replace as any with typed PluginInput mocks --- src/hooks/keyword-detector/index.test.ts | 17 +++++++++-------- .../ultrawork-edge-trigger.test.ts | 3 ++- src/hooks/stop-continuation-guard/index.test.ts | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/hooks/keyword-detector/index.test.ts b/src/hooks/keyword-detector/index.test.ts index c54ff1c6e..dba360400 100644 --- a/src/hooks/keyword-detector/index.test.ts +++ b/src/hooks/keyword-detector/index.test.ts @@ -1,4 +1,5 @@ import { describe, expect, test, beforeEach, afterEach, spyOn } from "bun:test" +import type { PluginInput } from "@opencode-ai/plugin" import { createKeywordDetectorHook } from "./index" import { setMainSession, updateSessionAgent, clearSessionAgent, _resetForTesting } from "../../features/claude-code-session-state" import { ContextCollector } from "../../features/context-injector" @@ -31,7 +32,7 @@ describe("keyword-detector message transform", () => { showToast: async () => {}, }, }, - } as any + } as unknown as PluginInput } test("should prepend ultrawork message to text part", async () => { @@ -119,12 +120,12 @@ describe("keyword-detector session filtering", () => { return { client: { tui: { - showToast: async (opts: any) => { + showToast: async (opts: { body: { title: string } }) => { toastCalls.push(opts.body.title) }, }, }, - } as any + } as unknown as PluginInput } test("should skip non-ultrawork keywords in non-main session (using mainSessionID check)", async () => { @@ -264,12 +265,12 @@ describe("keyword-detector word boundary", () => { return { client: { tui: { - showToast: async (opts: any) => { + showToast: async (opts: { body: { title: string } }) => { toastCalls.push(opts.body.title) }, }, }, - } as any + } as unknown as PluginInput } test("should NOT trigger ultrawork on partial matches like 'StatefulWidget' containing 'ulw'", async () => { @@ -363,7 +364,7 @@ describe("keyword-detector system-reminder filtering", () => { showToast: async () => {}, }, }, - } as any + } as unknown as PluginInput } test("should NOT trigger search mode from keywords inside tags", async () => { @@ -554,7 +555,7 @@ describe("keyword-detector agent-specific ultrawork messages", () => { showToast: async () => {}, }, }, - } as any + } as unknown as PluginInput } test("should skip ultrawork injection when agent is prometheus", async () => { @@ -771,7 +772,7 @@ describe("keyword-detector non-OMO agent skipping", () => { showToast: async () => {}, }, }, - } as any + } as unknown as PluginInput } test("should skip all keyword injection for OpenCode-Builder agent", async () => { diff --git a/src/hooks/keyword-detector/ultrawork-edge-trigger.test.ts b/src/hooks/keyword-detector/ultrawork-edge-trigger.test.ts index a2e60dd88..f2fbfefa4 100644 --- a/src/hooks/keyword-detector/ultrawork-edge-trigger.test.ts +++ b/src/hooks/keyword-detector/ultrawork-edge-trigger.test.ts @@ -1,4 +1,5 @@ import { afterEach, beforeEach, describe, expect, test } from "bun:test" +import type { PluginInput } from "@opencode-ai/plugin" import { createKeywordDetectorHook } from "./index" import { _resetForTesting, setMainSession } from "../../features/claude-code-session-state" @@ -18,7 +19,7 @@ function createMockPluginInput(toastCalls: string[] = []) { }, }, }, - } as any + } as unknown as PluginInput } function createMockRalphLoop(startLoopCalls: StartLoopCall[]) { diff --git a/src/hooks/stop-continuation-guard/index.test.ts b/src/hooks/stop-continuation-guard/index.test.ts index 65d1a17b8..4bf177d79 100644 --- a/src/hooks/stop-continuation-guard/index.test.ts +++ b/src/hooks/stop-continuation-guard/index.test.ts @@ -2,6 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test" import { mkdtempSync, rmSync } from "node:fs" import { join } from "node:path" import { tmpdir } from "node:os" +import type { PluginInput } from "@opencode-ai/plugin" import type { BackgroundManager, BackgroundTask } from "../../features/background-agent" import { readContinuationMarker } from "../../features/run-continuation-state" import { createStopContinuationGuardHook } from "./index" @@ -37,7 +38,7 @@ describe("stop-continuation-guard", () => { }, }, directory: createTempDir(), - } as any + } as unknown as PluginInput } function createBackgroundTask(status: BackgroundTask["status"], id: string): BackgroundTask {