Skip to content

Commit cdde8da

Browse files
authored
Optimize LSP tool descriptions for token efficiency (#71)
* bump up dependencies * Optimize LSP tool descriptions for token efficiency - Reduce verbose descriptions to concise versions (~63% character reduction) - Minimize parameter descriptions (1826 → 671 characters) - Remove redundant describe() calls for self-explanatory parameters - Total: ~390 tokens saved from system prompts 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent d7ce740 commit cdde8da

File tree

3 files changed

+46
-58
lines changed

3 files changed

+46
-58
lines changed

bun.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"dependencies": {
88
"@ast-grep/cli": "^0.40.0",
99
"@ast-grep/napi": "^0.40.0",
10-
"@code-yeongyu/comment-checker": "^0.5.0",
10+
"@code-yeongyu/comment-checker": "^0.6.0",
1111
"@openauthjs/openauth": "^0.4.3",
12-
"@opencode-ai/plugin": "^1.0.150",
12+
"@opencode-ai/plugin": "^1.0.162",
1313
"hono": "^4.10.4",
1414
"picomatch": "^4.0.2",
1515
"xdg-basedir": "^5.1.0",
@@ -68,13 +68,13 @@
6868

6969
"@ast-grep/napi-win32-x64-msvc": ["@ast-grep/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-Hk2IwfPqMFGZt5SRxsoWmGLxBXxprow4LRp1eG6V8EEiJCNHxZ9ZiEaIc5bNvMDBjHVSnqZAXT22dROhrcSKQg=="],
7070

71-
"@code-yeongyu/comment-checker": ["@code-yeongyu/comment-checker@0.5.0", "", { "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "comment-checker": "bin/comment-checker" } }, "sha512-rKD2qQnTVUacsVQtpu3I5Sxi09X/XpOwS9fcmbUv1yfUL6llraaPuLmmxMBMRcmm7Zu31yEPVKCeUkVODfRL1g=="],
71+
"@code-yeongyu/comment-checker": ["@code-yeongyu/comment-checker@0.6.0", "", { "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ], "bin": { "comment-checker": "bin/comment-checker" } }, "sha512-VtDPrhbUJcb5BIS18VMcY/N/xSLbMr6dpU9MO1NYQyEDhI4pSIx07K4gOlCutG/nHVCjO+HEarn8rttODP+5UA=="],
7272

7373
"@openauthjs/openauth": ["@openauthjs/[email protected]", "", { "dependencies": { "@standard-schema/spec": "1.0.0-beta.3", "aws4fetch": "1.0.20", "jose": "5.9.6" }, "peerDependencies": { "arctic": "^2.2.2", "hono": "^4.0.0" } }, "sha512-RlnjqvHzqcbFVymEwhlUEuac4utA5h4nhSK/i2szZuQmxTIqbGUxZ+nM+avM+VV4Ing+/ZaNLKILoXS3yrkOOw=="],
7474

75-
"@opencode-ai/plugin": ["@opencode-ai/[email protected].150", "", { "dependencies": { "@opencode-ai/sdk": "1.0.150", "zod": "4.1.8" } }, "sha512-XmY3yydk120GBv2KeLxSZlElFx4Zx9TYLa3bS9X1TxXot42UeoMLEi3Xa46yboYnWwp4bC9Fu+Gd1E7hypG8Jw=="],
75+
"@opencode-ai/plugin": ["@opencode-ai/[email protected].162", "", { "dependencies": { "@opencode-ai/sdk": "1.0.162", "zod": "4.1.8" } }, "sha512-tiJw7SCfSlG/3tY2O0J2UT06OLuazOzsv1zYlFbLxLy/EVedtW0pzxYalO20a4e//vInvOXFkhd2jLyB5vNEVA=="],
7676

77-
"@opencode-ai/sdk": ["@opencode-ai/[email protected].150", "", {}, "sha512-Nz9Di8UD/GK01w3N+jpiGNB733pYkNY8RNLbuE/HUxEGSP5apbXBY0IdhbW7859sXZZK38kF1NqOx4UxwBf4Bw=="],
77+
"@opencode-ai/sdk": ["@opencode-ai/[email protected].162", "", {}, "sha512-+XqRErBUt9eb1m3i/7WkZc/QCKCCjTaGV3MvhLhs/CUwbUn767D/ugzcG/i2ec8j/4nQmjJbjPDRmrQfvF1Qjw=="],
7878

7979
"@oslojs/asn1": ["@oslojs/[email protected]", "", { "dependencies": { "@oslojs/binary": "1.0.0" } }, "sha512-zw/wn0sj0j0QKbIXfIlnEcTviaCzYOY3V5rAyjR6YtOByFtJiT574+8p9Wlach0lZH9fddD4yb9laEAIl4vXQA=="],
8080

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
"dependencies": {
4949
"@ast-grep/cli": "^0.40.0",
5050
"@ast-grep/napi": "^0.40.0",
51-
"@code-yeongyu/comment-checker": "^0.5.0",
51+
"@code-yeongyu/comment-checker": "^0.6.0",
5252
"@openauthjs/openauth": "^0.4.3",
53-
"@opencode-ai/plugin": "^1.0.150",
53+
"@opencode-ai/plugin": "^1.0.162",
5454
"hono": "^4.10.4",
5555
"picomatch": "^4.0.2",
5656
"xdg-basedir": "^5.1.0",

src/tools/lsp/tools.ts

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ import type {
3535

3636

3737
export const lsp_hover = tool({
38-
description:
39-
"Get type information, documentation, and signature for a symbol at a specific position in a file. Use this when you need to understand what a variable, function, class, or any identifier represents.",
38+
description: "Get type info, docs, and signature for a symbol at position.",
4039
args: {
41-
filePath: tool.schema.string().describe("The absolute path to the file"),
42-
line: tool.schema.number().min(1).describe("Line number (1-based)"),
43-
character: tool.schema.number().min(0).describe("Character position (0-based)"),
40+
filePath: tool.schema.string(),
41+
line: tool.schema.number().min(1).describe("1-based"),
42+
character: tool.schema.number().min(0).describe("0-based"),
4443
},
4544
execute: async (args, context) => {
4645
try {
@@ -57,12 +56,11 @@ export const lsp_hover = tool({
5756
})
5857

5958
export const lsp_goto_definition = tool({
60-
description:
61-
"Jump to the source definition of a symbol (variable, function, class, type, import, etc.). Use this when you need to find WHERE something is defined.",
59+
description: "Jump to symbol definition. Find WHERE something is defined.",
6260
args: {
63-
filePath: tool.schema.string().describe("The absolute path to the file"),
64-
line: tool.schema.number().min(1).describe("Line number (1-based)"),
65-
character: tool.schema.number().min(0).describe("Character position (0-based)"),
61+
filePath: tool.schema.string(),
62+
line: tool.schema.number().min(1).describe("1-based"),
63+
character: tool.schema.number().min(0).describe("0-based"),
6664
},
6765
execute: async (args, context) => {
6866
try {
@@ -95,12 +93,11 @@ export const lsp_goto_definition = tool({
9593
})
9694

9795
export const lsp_find_references = tool({
98-
description:
99-
"Find ALL usages/references of a symbol across the entire workspace. Use this when you need to understand the impact of changing something.",
96+
description: "Find ALL usages/references of a symbol across the entire workspace.",
10097
args: {
101-
filePath: tool.schema.string().describe("The absolute path to the file"),
102-
line: tool.schema.number().min(1).describe("Line number (1-based)"),
103-
character: tool.schema.number().min(0).describe("Character position (0-based)"),
98+
filePath: tool.schema.string(),
99+
line: tool.schema.number().min(1).describe("1-based"),
100+
character: tool.schema.number().min(0).describe("0-based"),
104101
includeDeclaration: tool.schema.boolean().optional().describe("Include the declaration itself"),
105102
},
106103
execute: async (args, context) => {
@@ -133,10 +130,9 @@ export const lsp_find_references = tool({
133130
})
134131

135132
export const lsp_document_symbols = tool({
136-
description:
137-
"Get a hierarchical outline of all symbols (classes, functions, methods, variables, types, constants) in a single file. Use this to quickly understand a file's structure.",
133+
description: "Get hierarchical outline of all symbols in a file.",
138134
args: {
139-
filePath: tool.schema.string().describe("The absolute path to the file"),
135+
filePath: tool.schema.string(),
140136
},
141137
execute: async (args, context) => {
142138
try {
@@ -172,12 +168,11 @@ export const lsp_document_symbols = tool({
172168
})
173169

174170
export const lsp_workspace_symbols = tool({
175-
description:
176-
"Search for symbols by name across the ENTIRE workspace/project. Use this when you know (or partially know) a symbol's name but don't know which file it's in.",
171+
description: "Search symbols by name across ENTIRE workspace.",
177172
args: {
178-
filePath: tool.schema.string().describe("A file path in the workspace to determine the workspace root"),
179-
query: tool.schema.string().describe("The symbol name to search for (supports fuzzy matching)"),
180-
limit: tool.schema.number().optional().describe("Maximum number of results to return"),
173+
filePath: tool.schema.string(),
174+
query: tool.schema.string().describe("Symbol name (fuzzy match)"),
175+
limit: tool.schema.number().optional().describe("Max results"),
181176
},
182177
execute: async (args, context) => {
183178
try {
@@ -208,10 +203,9 @@ export const lsp_workspace_symbols = tool({
208203
})
209204

210205
export const lsp_diagnostics = tool({
211-
description:
212-
"Get all errors, warnings, and hints for a file from the language server. Use this to check if code has type errors, syntax issues, or linting problems BEFORE running the build.",
206+
description: "Get errors, warnings, hints from language server BEFORE running build.",
213207
args: {
214-
filePath: tool.schema.string().describe("The absolute path to the file"),
208+
filePath: tool.schema.string(),
215209
severity: tool.schema
216210
.enum(["error", "warning", "information", "hint", "all"])
217211
.optional()
@@ -256,7 +250,7 @@ export const lsp_diagnostics = tool({
256250
})
257251

258252
export const lsp_servers = tool({
259-
description: "List all available LSP servers and check if they are installed. Use this to see what language support is available.",
253+
description: "List available LSP servers and installation status.",
260254
args: {},
261255
execute: async (_args, context) => {
262256
try {
@@ -278,12 +272,11 @@ export const lsp_servers = tool({
278272
})
279273

280274
export const lsp_prepare_rename = tool({
281-
description:
282-
"Check if a symbol at a specific position can be renamed. Use this BEFORE attempting to rename to validate the operation and get the current symbol name.",
275+
description: "Check if rename is valid. Use BEFORE lsp_rename.",
283276
args: {
284-
filePath: tool.schema.string().describe("The absolute path to the file"),
285-
line: tool.schema.number().min(1).describe("Line number (1-based)"),
286-
character: tool.schema.number().min(0).describe("Character position (0-based)"),
277+
filePath: tool.schema.string(),
278+
line: tool.schema.number().min(1).describe("1-based"),
279+
character: tool.schema.number().min(0).describe("0-based"),
287280
},
288281
execute: async (args, context) => {
289282
try {
@@ -303,13 +296,12 @@ export const lsp_prepare_rename = tool({
303296
})
304297

305298
export const lsp_rename = tool({
306-
description:
307-
"Rename a symbol across the entire workspace. This APPLIES the rename to all files. Use lsp_prepare_rename first to check if rename is possible.",
299+
description: "Rename symbol across entire workspace. APPLIES changes to all files.",
308300
args: {
309-
filePath: tool.schema.string().describe("The absolute path to the file"),
310-
line: tool.schema.number().min(1).describe("Line number (1-based)"),
311-
character: tool.schema.number().min(0).describe("Character position (0-based)"),
312-
newName: tool.schema.string().describe("The new name for the symbol"),
301+
filePath: tool.schema.string(),
302+
line: tool.schema.number().min(1).describe("1-based"),
303+
character: tool.schema.number().min(0).describe("0-based"),
304+
newName: tool.schema.string().describe("New symbol name"),
313305
},
314306
execute: async (args, context) => {
315307
try {
@@ -327,14 +319,13 @@ export const lsp_rename = tool({
327319
})
328320

329321
export const lsp_code_actions = tool({
330-
description:
331-
"Get available code actions for a range in the file. Code actions include quick fixes, refactorings (extract, inline, rewrite), and source actions (organize imports, fix all). Use this to discover what automated changes the language server can perform.",
322+
description: "Get available quick fixes, refactorings, and source actions (organize imports, fix all).",
332323
args: {
333-
filePath: tool.schema.string().describe("The absolute path to the file"),
334-
startLine: tool.schema.number().min(1).describe("Start line number (1-based)"),
335-
startCharacter: tool.schema.number().min(0).describe("Start character position (0-based)"),
336-
endLine: tool.schema.number().min(1).describe("End line number (1-based)"),
337-
endCharacter: tool.schema.number().min(0).describe("End character position (0-based)"),
324+
filePath: tool.schema.string(),
325+
startLine: tool.schema.number().min(1).describe("1-based"),
326+
startCharacter: tool.schema.number().min(0).describe("0-based"),
327+
endLine: tool.schema.number().min(1).describe("1-based"),
328+
endCharacter: tool.schema.number().min(0).describe("0-based"),
338329
kind: tool.schema
339330
.enum([
340331
"quickfix",
@@ -372,13 +363,10 @@ export const lsp_code_actions = tool({
372363
})
373364

374365
export const lsp_code_action_resolve = tool({
375-
description:
376-
"Resolve and APPLY a code action. This resolves the full details and applies the changes to files. Use after getting a code action from lsp_code_actions.",
366+
description: "Resolve and APPLY a code action from lsp_code_actions.",
377367
args: {
378-
filePath: tool.schema
379-
.string()
380-
.describe("The absolute path to a file in the workspace (used to find the LSP server)"),
381-
codeAction: tool.schema.string().describe("The code action JSON object as returned by lsp_code_actions (stringified)"),
368+
filePath: tool.schema.string(),
369+
codeAction: tool.schema.string().describe("Code action JSON from lsp_code_actions"),
382370
},
383371
execute: async (args, context) => {
384372
try {

0 commit comments

Comments
 (0)