2025-12-24 17:11:18 +09:00
|
|
|
# TOOLS KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
Custom tools: 11 LSP tools, AST-aware search/replace, file ops with timeouts, background task management, session navigation.
|
2025-12-24 17:11:18 +09:00
|
|
|
|
|
|
|
|
## STRUCTURE
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
tools/
|
|
|
|
|
├── ast-grep/ # AST-aware code search/replace (25 languages)
|
2026-01-02 10:42:38 +09:00
|
|
|
│ ├── napi.ts # @ast-grep/napi binding (preferred)
|
|
|
|
|
│ └── cli.ts # @ast-grep/cli fallback
|
2025-12-24 17:11:18 +09:00
|
|
|
├── background-task/ # Async agent task management
|
|
|
|
|
├── call-omo-agent/ # Spawn explore/librarian agents
|
2026-01-02 10:42:38 +09:00
|
|
|
├── glob/ # File pattern matching (60s timeout)
|
|
|
|
|
├── grep/ # Content search (60s timeout)
|
2025-12-24 17:11:18 +09:00
|
|
|
├── interactive-bash/ # Tmux session management
|
|
|
|
|
├── look-at/ # Multimodal analysis (PDF, images)
|
2026-01-02 10:42:38 +09:00
|
|
|
├── lsp/ # 11 LSP tools (611 lines client.ts)
|
2025-12-24 17:11:18 +09:00
|
|
|
│ ├── client.ts # LSP connection lifecycle
|
|
|
|
|
│ ├── config.ts # Server configurations
|
2025-12-25 17:04:16 +09:00
|
|
|
│ └── tools.ts # Tool implementations
|
2026-01-02 10:42:38 +09:00
|
|
|
├── session-manager/ # OpenCode session file ops
|
2026-01-02 00:14:38 +09:00
|
|
|
├── skill/ # Skill loading and execution
|
|
|
|
|
├── skill-mcp/ # Skill-embedded MCP invocation
|
2025-12-24 17:11:18 +09:00
|
|
|
├── slashcommand/ # Slash command execution
|
|
|
|
|
└── index.ts # builtinTools export
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## TOOL CATEGORIES
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
| Category | Tools |
|
|
|
|
|
|----------|-------|
|
|
|
|
|
| LSP | lsp_hover, lsp_goto_definition, lsp_find_references, lsp_document_symbols, lsp_workspace_symbols, lsp_diagnostics, lsp_servers, lsp_prepare_rename, lsp_rename, lsp_code_actions, lsp_code_action_resolve |
|
|
|
|
|
| AST | ast_grep_search, ast_grep_replace |
|
|
|
|
|
| File Search | grep, glob |
|
|
|
|
|
| Session | session_list, session_read, session_search, session_info |
|
|
|
|
|
| Background | background_task, background_output, background_cancel |
|
|
|
|
|
| Multimodal | look_at |
|
|
|
|
|
| Terminal | interactive_bash |
|
|
|
|
|
| Skills | skill, skill_mcp |
|
|
|
|
|
| Agents | call_omo_agent |
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## HOW TO ADD
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
1. Create `src/tools/my-tool/`
|
|
|
|
|
2. Files: `constants.ts`, `types.ts`, `tools.ts`, `index.ts`
|
2025-12-24 17:11:18 +09:00
|
|
|
3. Add to `builtinTools` in `src/tools/index.ts`
|
|
|
|
|
|
|
|
|
|
## LSP SPECIFICS
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
- Lazy init on first use, auto-shutdown on idle
|
|
|
|
|
- Config priority: opencode.json > oh-my-opencode.json > defaults
|
|
|
|
|
- Servers: typescript-language-server, pylsp, gopls, rust-analyzer
|
2025-12-24 17:11:18 +09:00
|
|
|
|
|
|
|
|
## AST-GREP SPECIFICS
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
- Meta-variables: `$VAR` (single), `$$$` (multiple)
|
|
|
|
|
- Pattern must be valid AST node, not fragment
|
|
|
|
|
- Prefers napi binding for performance
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## ANTI-PATTERNS
|
2025-12-24 17:11:18 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
- No timeout on file ops (always use, default 60s)
|
|
|
|
|
- Sync file operations (use async/await)
|
|
|
|
|
- Ignoring LSP errors (graceful handling required)
|
|
|
|
|
- Raw subprocess for ast-grep (prefer napi)
|