Per reviewer feedback (code-yeongyu), keep the 'skill' tool as the main tool and merge slashcommand functionality INTO it, rather than the reverse. Changes: - skill/tools.ts: Add command discovery (discoverCommandsSync) support; handle both SKILL.md skills and .omo/commands/ slash commands in a single tool; show combined listing in tool description - skill/types.ts: Add 'commands' option to SkillLoadOptions - skill/constants.ts: Update description to mention both skills and commands - plugin/tool-registry.ts: Replace createSlashcommandTool with createSkillTool; register tool as 'skill' instead of 'slashcommand' - tools/index.ts: Export createSkillTool instead of createSlashcommandTool - plugin/tool-execute-before.ts: Update tool name checks from 'slashcommand' to 'skill'; update arg name from 'command' to 'name' - agents/dynamic-agent-prompt-builder.ts: Categorize 'skill' tool as 'command' - tools/skill-mcp/tools.ts: Update hint message to reference 'skill' tool - hooks/auto-slash-command/executor.ts: Update error message The slashcommand/ module files are kept (they provide shared utilities used by the skill tool), but the slashcommand tool itself is no longer registered.
145 lines
4.5 KiB
TypeScript
145 lines
4.5 KiB
TypeScript
import type { ToolDefinition } from "@opencode-ai/plugin"
|
|
|
|
import type {
|
|
AvailableCategory,
|
|
} from "../agents/dynamic-agent-prompt-builder"
|
|
import type { OhMyOpenCodeConfig } from "../config"
|
|
import type { PluginContext, ToolsRecord } from "./types"
|
|
|
|
import {
|
|
builtinTools,
|
|
createBackgroundTools,
|
|
createCallOmoAgent,
|
|
createLookAt,
|
|
createSkillMcpTool,
|
|
createSkillTool,
|
|
createGrepTools,
|
|
createGlobTools,
|
|
createAstGrepTools,
|
|
createSessionManagerTools,
|
|
createDelegateTask,
|
|
discoverCommandsSync,
|
|
interactive_bash,
|
|
createTaskCreateTool,
|
|
createTaskGetTool,
|
|
createTaskList,
|
|
createTaskUpdateTool,
|
|
createHashlineEditTool,
|
|
} from "../tools"
|
|
import { getMainSessionID } from "../features/claude-code-session-state"
|
|
import { filterDisabledTools } from "../shared/disabled-tools"
|
|
import { log } from "../shared"
|
|
|
|
import type { Managers } from "../create-managers"
|
|
import type { SkillContext } from "./skill-context"
|
|
|
|
export type ToolRegistryResult = {
|
|
filteredTools: ToolsRecord
|
|
taskSystemEnabled: boolean
|
|
}
|
|
|
|
export function createToolRegistry(args: {
|
|
ctx: PluginContext
|
|
pluginConfig: OhMyOpenCodeConfig
|
|
managers: Pick<Managers, "backgroundManager" | "tmuxSessionManager" | "skillMcpManager">
|
|
skillContext: SkillContext
|
|
availableCategories: AvailableCategory[]
|
|
}): ToolRegistryResult {
|
|
const { ctx, pluginConfig, managers, skillContext, availableCategories } = args
|
|
|
|
const backgroundTools = createBackgroundTools(managers.backgroundManager, ctx.client)
|
|
const callOmoAgent = createCallOmoAgent(ctx, managers.backgroundManager, pluginConfig.disabled_agents ?? [])
|
|
|
|
const isMultimodalLookerEnabled = !(pluginConfig.disabled_agents ?? []).some(
|
|
(agent) => agent.toLowerCase() === "multimodal-looker",
|
|
)
|
|
const lookAt = isMultimodalLookerEnabled ? createLookAt(ctx) : null
|
|
|
|
const delegateTask = createDelegateTask({
|
|
manager: managers.backgroundManager,
|
|
client: ctx.client,
|
|
directory: ctx.directory,
|
|
userCategories: pluginConfig.categories,
|
|
agentOverrides: pluginConfig.agents,
|
|
gitMasterConfig: pluginConfig.git_master,
|
|
sisyphusJuniorModel: pluginConfig.agents?.["sisyphus-junior"]?.model,
|
|
browserProvider: skillContext.browserProvider,
|
|
disabledSkills: skillContext.disabledSkills,
|
|
availableCategories,
|
|
availableSkills: skillContext.availableSkills,
|
|
onSyncSessionCreated: async (event) => {
|
|
log("[index] onSyncSessionCreated callback", {
|
|
sessionID: event.sessionID,
|
|
parentID: event.parentID,
|
|
title: event.title,
|
|
})
|
|
await managers.tmuxSessionManager.onSessionCreated({
|
|
type: "session.created",
|
|
properties: {
|
|
info: {
|
|
id: event.sessionID,
|
|
parentID: event.parentID,
|
|
title: event.title,
|
|
},
|
|
},
|
|
})
|
|
},
|
|
})
|
|
|
|
const getSessionIDForMcp = (): string => getMainSessionID() || ""
|
|
|
|
const skillMcpTool = createSkillMcpTool({
|
|
manager: managers.skillMcpManager,
|
|
getLoadedSkills: () => skillContext.mergedSkills,
|
|
getSessionID: getSessionIDForMcp,
|
|
})
|
|
|
|
const commands = discoverCommandsSync(ctx.directory)
|
|
const skillTool = createSkillTool({
|
|
commands,
|
|
skills: skillContext.mergedSkills,
|
|
mcpManager: managers.skillMcpManager,
|
|
getSessionID: getSessionIDForMcp,
|
|
gitMasterConfig: pluginConfig.git_master,
|
|
})
|
|
|
|
const taskSystemEnabled = pluginConfig.experimental?.task_system ?? false
|
|
const taskToolsRecord: Record<string, ToolDefinition> = taskSystemEnabled
|
|
? {
|
|
task_create: createTaskCreateTool(pluginConfig, ctx),
|
|
task_get: createTaskGetTool(pluginConfig),
|
|
task_list: createTaskList(pluginConfig),
|
|
task_update: createTaskUpdateTool(pluginConfig, ctx),
|
|
}
|
|
: {}
|
|
|
|
const hashlineEnabled = pluginConfig.experimental?.hashline_edit ?? true
|
|
const hashlineToolsRecord: Record<string, ToolDefinition> = hashlineEnabled
|
|
? { edit: createHashlineEditTool() }
|
|
: {}
|
|
|
|
const allTools: Record<string, ToolDefinition> = {
|
|
...builtinTools,
|
|
...createGrepTools(ctx),
|
|
...createGlobTools(ctx),
|
|
...createAstGrepTools(ctx),
|
|
...createSessionManagerTools(ctx),
|
|
...backgroundTools,
|
|
call_omo_agent: callOmoAgent,
|
|
...(lookAt ? { look_at: lookAt } : {}),
|
|
task: delegateTask,
|
|
skill_mcp: skillMcpTool,
|
|
skill: skillTool,
|
|
interactive_bash,
|
|
...taskToolsRecord,
|
|
...hashlineToolsRecord,
|
|
}
|
|
|
|
const filteredTools = filterDisabledTools(allTools, pluginConfig.disabled_tools)
|
|
|
|
return {
|
|
filteredTools,
|
|
taskSystemEnabled,
|
|
}
|
|
}
|