0541c58cb3
- Split unified Task tool into individual tools (TaskCreate, TaskGet, TaskList, TaskUpdate) - Update schema to Claude Code field names (subject, blockedBy, blocks, activeForm, owner, metadata) - Add OpenCode Todo API sync layer (todo-sync.ts) - Implement Todo sync on task create/update for continuation enforcement - Add comprehensive tests for all tools (96 tests total) - Update AGENTS.md documentation Breaking Changes: - Field names changed: title→subject, dependsOn→blockedBy, open→pending - Tool names changed: task→task_create, task_get, task_list, task_update Closes: todo-continuation-enforcer now sees Task-created items
3.4 KiB
3.4 KiB
TOOLS KNOWLEDGE BASE
OVERVIEW
20+ tools across 7 categories. Two patterns: Direct ToolDefinition (static) and Factory Function (context-dependent).
Categories: LSP (6), AST-Grep (2), Search (2), Session (4), Agent delegation (2), Background (2), Skill (3)
STRUCTURE
tools/
├── [tool-name]/
│ ├── index.ts # Barrel export
│ ├── tools.ts # ToolDefinition or factory
│ ├── types.ts # Zod schemas
│ └── constants.ts # Fixed values
├── lsp/ # 6 tools: definition, references, symbols, diagnostics, rename (client.ts 540 lines)
├── ast-grep/ # 2 tools: search, replace (25 languages)
├── delegate-task/ # Category-based routing (1135 lines)
├── session-manager/ # 4 tools: list, read, search, info
├── grep/ # Custom grep with timeout (60s, 10MB)
├── glob/ # 60s timeout, 100 file limit
├── interactive-bash/ # Tmux session management
├── look-at/ # Multimodal PDF/image
├── skill/ # Skill execution
├── skill-mcp/ # Skill MCP operations
├── slashcommand/ # Slash command dispatch
├── call-omo-agent/ # Direct agent invocation
└── background-task/ # background_output, background_cancel
TOOL CATEGORIES
| Category | Tools | Pattern |
|---|---|---|
| LSP | lsp_goto_definition, lsp_find_references, lsp_symbols, lsp_diagnostics, lsp_prepare_rename, lsp_rename | Direct |
| Search | ast_grep_search, ast_grep_replace, grep, glob | Direct |
| Session | session_list, session_read, session_search, session_info | Direct |
| Task | task_create, task_get, task_list, task_update | Factory |
| Agent | delegate_task, call_omo_agent | Factory |
| Background | background_output, background_cancel | Factory |
| System | interactive_bash, look_at | Mixed |
| Skill | skill, skill_mcp, slashcommand | Factory |
TASK TOOLS
Claude Code compatible task management.
- task_create: Creates a new task. Auto-generates ID and syncs to Todo.
- Args:
subject,description,activeForm,blocks,blockedBy,owner,metadata
- Args:
- task_get: Retrieves a task by ID.
- Args:
id
- Args:
- task_list: Lists active tasks. Filters out completed/deleted by default.
- Args:
status,parentID
- Args:
- task_update: Updates task fields. Supports additive
addBlocks/addBlockedBy.- Args:
id,subject,description,status,activeForm,addBlocks,addBlockedBy,owner,metadata
- Args:
HOW TO ADD
- Create
src/tools/[name]/with standard files - Use
tool()from@opencode-ai/plugin/tool - Export from
src/tools/index.ts - Static tools →
builtinTools, Factory → separate export
TOOL PATTERNS
Direct ToolDefinition:
export const grep: ToolDefinition = tool({
description: "...",
args: { pattern: tool.schema.string() },
execute: async (args) => result,
})
Factory Function (context-dependent):
export function createDelegateTask(ctx, manager): ToolDefinition {
return tool({ execute: async (args) => { /* uses ctx */ } })
}
NAMING
- Tool names: snake_case (
lsp_goto_definition) - Functions: camelCase (
createDelegateTask) - Directories: kebab-case (
delegate-task/)
ANTI-PATTERNS
- Sequential bash: Use
&&or delegation - Raw file ops: Never mkdir/touch in tool logic
- Sleep: Use polling loops