diff --git a/src/plugin/tool-registry.test.ts b/src/plugin/tool-registry.test.ts index bb8d40c4d..7cf6d2374 100644 --- a/src/plugin/tool-registry.test.ts +++ b/src/plugin/tool-registry.test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from "bun:test" import { tool } from "@opencode-ai/plugin" import type { ToolsRecord } from "./types" -import { trimToolsToCap } from "./tool-registry" +import { createToolRegistry, trimToolsToCap } from "./tool-registry" const fakeTool = tool({ description: "test tool", @@ -27,3 +27,57 @@ describe("#given tool trimming prioritization", () => { expect(filteredTools).toHaveProperty("read") }) }) + +describe("#given task_system configuration", () => { + test("#when task_system is omitted #then task tools are not registered by default", () => { + const result = createToolRegistry({ + ctx: { directory: "/tmp" } as Parameters[0]["ctx"], + pluginConfig: {}, + managers: { + backgroundManager: {}, + tmuxSessionManager: {}, + skillMcpManager: {}, + } as Parameters[0]["managers"], + skillContext: { + mergedSkills: [], + availableSkills: [], + browserProvider: "playwright", + disabledSkills: new Set(), + }, + availableCategories: [], + }) + + expect(result.taskSystemEnabled).toBe(false) + expect(result.filteredTools).not.toHaveProperty("task_create") + expect(result.filteredTools).not.toHaveProperty("task_get") + expect(result.filteredTools).not.toHaveProperty("task_list") + expect(result.filteredTools).not.toHaveProperty("task_update") + }) + + test("#when task_system is enabled #then task tools are registered", () => { + const result = createToolRegistry({ + ctx: { directory: "/tmp" } as Parameters[0]["ctx"], + pluginConfig: { + experimental: { task_system: true }, + }, + managers: { + backgroundManager: {}, + tmuxSessionManager: {}, + skillMcpManager: {}, + } as Parameters[0]["managers"], + skillContext: { + mergedSkills: [], + availableSkills: [], + browserProvider: "playwright", + disabledSkills: new Set(), + }, + availableCategories: [], + }) + + expect(result.taskSystemEnabled).toBe(true) + expect(result.filteredTools).toHaveProperty("task_create") + expect(result.filteredTools).toHaveProperty("task_get") + expect(result.filteredTools).toHaveProperty("task_list") + expect(result.filteredTools).toHaveProperty("task_update") + }) +}) diff --git a/src/plugin/tool-registry.ts b/src/plugin/tool-registry.ts index a493dde51..81d4c9ba0 100644 --- a/src/plugin/tool-registry.ts +++ b/src/plugin/tool-registry.ts @@ -29,7 +29,7 @@ import { } from "../tools" import { getMainSessionID } from "../features/claude-code-session-state" import { filterDisabledTools } from "../shared/disabled-tools" -import { log } from "../shared" +import { isTaskSystemEnabled, log } from "../shared" import type { Managers } from "../create-managers" import type { SkillContext } from "./skill-context" @@ -175,8 +175,7 @@ export function createToolRegistry(args: { nativeSkills: "skills" in ctx ? (ctx as { skills: SkillLoadOptions["nativeSkills"] }).skills : undefined, }) - // task_system defaults to true since v3.14 — delegation (oracle, subagents) requires it - const taskSystemEnabled = pluginConfig.experimental?.task_system ?? true + const taskSystemEnabled = isTaskSystemEnabled(pluginConfig) const taskToolsRecord: Record = taskSystemEnabled ? { task_create: createTaskCreateTool(pluginConfig, ctx),