2025-12-24 17:11:18 +09:00
|
|
|
# TOOLS KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-02-08 17:51:30 +09:00
|
|
|
113 tools across 8 categories. Two patterns: Direct ToolDefinition (static) and Factory Function (context-dependent).
|
2026-02-01 19:26:57 +09:00
|
|
|
|
2026-02-06 18:59:58 +09:00
|
|
|
**Categories**: LSP (6), AST-Grep (2), Search (2), Session (4), Task (4), Agent delegation (2), Background (2), Skill (3), System (2)
|
2025-12-24 17:11:18 +09:00
|
|
|
|
|
|
|
|
## STRUCTURE
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2025-12-24 17:11:18 +09:00
|
|
|
```
|
|
|
|
|
tools/
|
2026-01-17 19:16:49 +09:00
|
|
|
├── [tool-name]/
|
2026-01-17 22:01:56 +09:00
|
|
|
│ ├── index.ts # Barrel export
|
2026-01-26 11:48:30 +09:00
|
|
|
│ ├── tools.ts # ToolDefinition or factory
|
2026-01-17 22:01:56 +09:00
|
|
|
│ ├── types.ts # Zod schemas
|
2026-01-23 02:14:08 +09:00
|
|
|
│ └── constants.ts # Fixed values
|
2026-02-06 18:59:58 +09:00
|
|
|
├── lsp/ # 6 tools: definition, references, symbols, diagnostics, rename (client.ts 803 lines)
|
2026-01-23 02:14:08 +09:00
|
|
|
├── ast-grep/ # 2 tools: search, replace (25 languages)
|
2026-02-06 18:59:58 +09:00
|
|
|
├── delegate-task/ # Category-based routing (executor.ts 983 lines, constants.ts 552 lines)
|
2026-02-03 16:21:31 +09:00
|
|
|
├── task/ # 4 tools: create, get, list, update (Claude Code compatible)
|
2026-01-17 22:01:56 +09:00
|
|
|
├── session-manager/ # 4 tools: list, read, search, info
|
2026-01-26 14:56:55 +09:00
|
|
|
├── grep/ # Custom grep with timeout (60s, 10MB)
|
2026-01-23 02:14:08 +09:00
|
|
|
├── glob/ # 60s timeout, 100 file limit
|
2026-01-17 22:01:56 +09:00
|
|
|
├── interactive-bash/ # Tmux session management
|
2026-02-06 18:59:58 +09:00
|
|
|
├── look-at/ # Multimodal PDF/image (307 lines)
|
2026-01-17 22:01:56 +09:00
|
|
|
├── skill/ # Skill execution
|
|
|
|
|
├── skill-mcp/ # Skill MCP operations
|
|
|
|
|
├── slashcommand/ # Slash command dispatch
|
2026-02-06 18:59:58 +09:00
|
|
|
├── call-omo-agent/ # Direct agent invocation (358 lines)
|
|
|
|
|
└── background-task/ # background_output, background_cancel (734 lines)
|
2025-12-24 17:11:18 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## TOOL CATEGORIES
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
| Category | Tools | Pattern |
|
2026-01-17 22:01:56 +09:00
|
|
|
|----------|-------|---------|
|
2026-01-26 11:48:30 +09:00
|
|
|
| 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 |
|
2026-02-02 12:01:43 +09:00
|
|
|
| Task | task_create, task_get, task_list, task_update | Factory |
|
2026-02-06 16:01:54 +09:00
|
|
|
| Agent | task, call_omo_agent | Factory |
|
2026-01-26 11:48:30 +09:00
|
|
|
| Background | background_output, background_cancel | Factory |
|
|
|
|
|
| System | interactive_bash, look_at | Mixed |
|
|
|
|
|
| Skill | skill, skill_mcp, slashcommand | Factory |
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-02-02 12:01:43 +09:00
|
|
|
## TASK TOOLS
|
|
|
|
|
|
|
|
|
|
Claude Code compatible task management.
|
|
|
|
|
|
|
|
|
|
- **task_create**: Creates a new task. Auto-generates ID and syncs to Todo.
|
|
|
|
|
- **task_get**: Retrieves a task by ID.
|
|
|
|
|
- **task_list**: Lists active tasks. Filters out completed/deleted by default.
|
|
|
|
|
- **task_update**: Updates task fields. Supports additive `addBlocks`/`addBlockedBy`.
|
|
|
|
|
|
2026-01-17 19:16:49 +09:00
|
|
|
## HOW TO ADD
|
2026-01-17 22:01:56 +09:00
|
|
|
|
|
|
|
|
1. Create `src/tools/[name]/` with standard files
|
2026-01-23 02:14:08 +09:00
|
|
|
2. Use `tool()` from `@opencode-ai/plugin/tool`
|
2026-01-17 22:01:56 +09:00
|
|
|
3. Export from `src/tools/index.ts`
|
2026-01-26 11:48:30 +09:00
|
|
|
4. Static tools → `builtinTools`, Factory → separate export
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
## TOOL PATTERNS
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
**Direct ToolDefinition**:
|
|
|
|
|
```typescript
|
|
|
|
|
export const grep: ToolDefinition = tool({
|
|
|
|
|
description: "...",
|
|
|
|
|
args: { pattern: tool.schema.string() },
|
|
|
|
|
execute: async (args) => result,
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**Factory Function** (context-dependent):
|
|
|
|
|
```typescript
|
|
|
|
|
export function createDelegateTask(ctx, manager): ToolDefinition {
|
|
|
|
|
return tool({ execute: async (args) => { /* uses ctx */ } })
|
|
|
|
|
}
|
|
|
|
|
```
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
## NAMING
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-01-26 11:48:30 +09:00
|
|
|
- **Tool names**: snake_case (`lsp_goto_definition`)
|
|
|
|
|
- **Functions**: camelCase (`createDelegateTask`)
|
|
|
|
|
- **Directories**: kebab-case (`delegate-task/`)
|
2026-01-13 21:00:00 +09:00
|
|
|
|
|
|
|
|
## ANTI-PATTERNS
|
2026-01-17 22:01:56 +09:00
|
|
|
|
2026-01-23 02:14:08 +09:00
|
|
|
- **Sequential bash**: Use `&&` or delegation
|
2026-01-17 22:01:56 +09:00
|
|
|
- **Raw file ops**: Never mkdir/touch in tool logic
|
2026-01-23 02:14:08 +09:00
|
|
|
- **Sleep**: Use polling loops
|