From 47769d5f49961f3dbc380d18be113d9f0cea7bb5 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 3 Apr 2026 17:08:05 +0900 Subject: [PATCH] fix(tasks-hook): share task_system resolution Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../tasks-todowrite-disabler/hook.test.ts | 40 +++++++++++++++++++ src/hooks/tasks-todowrite-disabler/hook.ts | 5 ++- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/hooks/tasks-todowrite-disabler/hook.test.ts diff --git a/src/hooks/tasks-todowrite-disabler/hook.test.ts b/src/hooks/tasks-todowrite-disabler/hook.test.ts new file mode 100644 index 000000000..e737cc03c --- /dev/null +++ b/src/hooks/tasks-todowrite-disabler/hook.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, test } from "bun:test" + +import { REPLACEMENT_MESSAGE } from "./constants" +import { createTasksTodowriteDisablerHook } from "./hook" + +describe("createTasksTodowriteDisablerHook", () => { + describe("#given experimental.task_system is omitted", () => { + test("#when TodoWrite runs #then it is allowed by default", async () => { + // given + const hook = createTasksTodowriteDisablerHook({}) + + // when + const result = hook["tool.execute.before"]( + { tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" }, + { args: {} }, + ) + + // then + await expect(result).resolves.toBeUndefined() + }) + }) + + describe("#given experimental.task_system is enabled", () => { + test("#when TodoWrite runs #then it is blocked", async () => { + // given + const hook = createTasksTodowriteDisablerHook({ + experimental: { task_system: true }, + }) + + // when + const result = hook["tool.execute.before"]( + { tool: "TodoWrite", sessionID: "ses_123", callID: "call_123" }, + { args: {} }, + ) + + // then + await expect(result).rejects.toThrow(REPLACEMENT_MESSAGE) + }) + }) +}) diff --git a/src/hooks/tasks-todowrite-disabler/hook.ts b/src/hooks/tasks-todowrite-disabler/hook.ts index 9449cfea8..17d156b08 100644 --- a/src/hooks/tasks-todowrite-disabler/hook.ts +++ b/src/hooks/tasks-todowrite-disabler/hook.ts @@ -1,3 +1,4 @@ +import { isTaskSystemEnabled } from "../../shared/task-system-enabled"; import { BLOCKED_TOOLS, REPLACEMENT_MESSAGE } from "./constants"; export interface TasksTodowriteDisablerConfig { @@ -9,14 +10,14 @@ export interface TasksTodowriteDisablerConfig { export function createTasksTodowriteDisablerHook( config: TasksTodowriteDisablerConfig, ) { - const isTaskSystemEnabled = config.experimental?.task_system ?? true; + const taskSystemEnabled = isTaskSystemEnabled(config); return { "tool.execute.before": async ( input: { tool: string; sessionID: string; callID: string }, _output: { args: Record }, ) => { - if (!isTaskSystemEnabled) { + if (!taskSystemEnabled) { return; }