From 9363324e0e1855d4d0297397100ac2ecd7e8e0e8 Mon Sep 17 00:00:00 2001 From: justsisyphus Date: Fri, 16 Jan 2026 10:40:44 +0900 Subject: [PATCH] refactor(lsp): clean up lsp_servers references and update prompts to use PascalCase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove dead lsp_servers function from tools.ts - Update utils.ts to reference LspServers (OpenCode built-in) - Update AGENTS.md: 7 tools → 3 tools - Update init-deep.ts prompts to use PascalCase OpenCode tools - Update refactor.ts prompts to use PascalCase OpenCode tools --- .../builtin-commands/templates/init-deep.ts | 14 +++++------ .../builtin-commands/templates/refactor.ts | 16 ++++++------- src/tools/AGENTS.md | 4 ++-- src/tools/lsp/tools.ts | 23 ------------------- src/tools/lsp/utils.ts | 2 +- 5 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/features/builtin-commands/templates/init-deep.ts b/src/features/builtin-commands/templates/init-deep.ts index 5fe2bb93..2f3eeed6 100644 --- a/src/features/builtin-commands/templates/init-deep.ts +++ b/src/features/builtin-commands/templates/init-deep.ts @@ -114,19 +114,19 @@ If \`--create-new\`: Read all existing first (preserve context) → then delete #### 3. LSP Codemap (if available) \`\`\` -lsp_servers() # Check availability +LspServers() # Check availability # Entry points (parallel) -lsp_symbols(filePath="src/index.ts", scope="document") -lsp_symbols(filePath="main.py", scope="document") +LspDocumentSymbols(filePath="src/index.ts") +LspDocumentSymbols(filePath="main.py") # Key symbols (parallel) -lsp_symbols(filePath=".", scope="workspace", query="class") -lsp_symbols(filePath=".", scope="workspace", query="interface") -lsp_symbols(filePath=".", scope="workspace", query="function") +LspWorkspaceSymbols(filePath=".", query="class") +LspWorkspaceSymbols(filePath=".", query="interface") +LspWorkspaceSymbols(filePath=".", query="function") # Centrality for top exports -lsp_find_references(filePath="...", line=X, character=Y) +LspFindReferences(filePath="...", line=X, character=Y) \`\`\` **LSP Fallback**: If unavailable, rely on explore agents + AST-grep. diff --git a/src/features/builtin-commands/templates/refactor.ts b/src/features/builtin-commands/templates/refactor.ts index 94513a4b..9712254e 100644 --- a/src/features/builtin-commands/templates/refactor.ts +++ b/src/features/builtin-commands/templates/refactor.ts @@ -149,14 +149,14 @@ While background agents are running, use direct tools: \`\`\`typescript // Find definition(s) -lsp_goto_definition(filePath, line, character) // Where is it defined? +LspGotoDefinition(filePath, line, character) // Where is it defined? // Find ALL usages across workspace -lsp_find_references(filePath, line, character, includeDeclaration=true) +LspFindReferences(filePath, line, character, includeDeclaration=true) -// Get file structure (scope='document') or search symbols (scope='workspace') -lsp_symbols(filePath, scope="document") // Hierarchical outline -lsp_symbols(filePath, scope="workspace", query="[target_symbol]") // Search by name +// Get file structure +LspDocumentSymbols(filePath) // Hierarchical outline +LspWorkspaceSymbols(filePath, query="[target_symbol]") // Search by name // Get current diagnostics lsp_diagnostics(filePath) // Errors, warnings before we start @@ -587,9 +587,9 @@ If any of these occur, **STOP and consult user**: You already know these tools. Use them intelligently: ## LSP Tools -Leverage the full LSP toolset (\`lsp_*\`) for precision analysis. Key patterns: -- **Understand before changing**: \`lsp_goto_definition\` to grasp context -- **Impact analysis**: \`lsp_find_references\` to map all usages before modification +Leverage LSP tools for precision analysis. Key patterns: +- **Understand before changing**: \`LspGotoDefinition\` to grasp context +- **Impact analysis**: \`LspFindReferences\` to map all usages before modification - **Safe refactoring**: \`lsp_prepare_rename\` → \`lsp_rename\` for symbol renames - **Continuous verification**: \`lsp_diagnostics\` after every change diff --git a/src/tools/AGENTS.md b/src/tools/AGENTS.md index 277f4eb1..26243e95 100644 --- a/src/tools/AGENTS.md +++ b/src/tools/AGENTS.md @@ -1,7 +1,7 @@ # TOOLS KNOWLEDGE BASE ## OVERVIEW -Custom tools extending agent capabilities: LSP (7 tools), AST-aware search/replace, background tasks, and multimodal analysis. +Custom tools extending agent capabilities: LSP (3 tools), AST-aware search/replace, background tasks, and multimodal analysis. ## STRUCTURE ``` @@ -30,7 +30,7 @@ tools/ ## TOOL CATEGORIES | Category | Tools | Purpose | |----------|-------|---------| -| LSP | lsp_goto_definition, lsp_find_references, lsp_symbols, lsp_diagnostics, lsp_rename, etc. | IDE-grade code intelligence (7 tools) | +| LSP | lsp_diagnostics, lsp_prepare_rename, lsp_rename | IDE-grade code intelligence (3 tools) | | AST | ast_grep_search, ast_grep_replace | Structural pattern matching/rewriting | | Search | grep, glob | Timeout-safe file and content search | | Session | session_list, session_read, session_search, session_info | History navigation and retrieval | diff --git a/src/tools/lsp/tools.ts b/src/tools/lsp/tools.ts index 412f5db4..2f7657d9 100644 --- a/src/tools/lsp/tools.ts +++ b/src/tools/lsp/tools.ts @@ -1,5 +1,4 @@ import { tool, type ToolDefinition } from "@opencode-ai/plugin/tool" -import { getAllServers } from "./config" import { DEFAULT_MAX_DIAGNOSTICS, } from "./constants" @@ -68,28 +67,6 @@ export const lsp_diagnostics: ToolDefinition = tool({ }, }) -export const lsp_servers: ToolDefinition = tool({ - description: "List available LSP servers and installation status.", - args: {}, - execute: async (_args, context) => { - try { - const servers = getAllServers() - const lines = servers.map((s) => { - if (s.disabled) { - return `${s.id} [disabled] - ${s.extensions.join(", ")}` - } - const status = s.installed ? "[installed]" : "[not installed]" - return `${s.id} ${status} - ${s.extensions.join(", ")}` - }) - const output = lines.join("\n") - return output - } catch (e) { - const output = `Error: ${e instanceof Error ? e.message : String(e)}` - return output - } - }, -}) - export const lsp_prepare_rename: ToolDefinition = tool({ description: "Check if rename is valid. Use BEFORE lsp_rename.", args: { diff --git a/src/tools/lsp/utils.ts b/src/tools/lsp/utils.ts index 810021f7..e54a0680 100644 --- a/src/tools/lsp/utils.ts +++ b/src/tools/lsp/utils.ts @@ -55,7 +55,7 @@ export function formatServerLookupError(result: Exclude