description: "The model-facing lsp tool: four read-only code-navigation operations with one-based UTF-16 cursor coordinates, bounded results, and hover text, for users and maintainers composing model code navigation."
English | 中文
dsh-tool-lsp lets a model navigate code through one read-only lsp tool: open a symbol's definition, find references and implementations, or read hover documentation. Requests use one-based UTF-16 line and character positions. Navigation results are bounded, grouped by file, and labeled when locations are omitted or text is truncated; hover results are normalized and distinguish missing information from errors. The package requires a configured LSP provider and a session workspace root. Choose it when textual search is ambiguous or a change needs precise symbol relationships; ordinary navigation should continue to use search and read.
An agent uses lsp when textual matches are ambiguous or before a change that needs precise definitions, implementations, or references; the tool's prompt guidance tells it to prefer search/read for ordinary navigation.
lsp takes operation (goToDefinition, findReferences, goToImplementation, or hover), file_path, line, and character. line and character are positive one-based UTF-16 cursor coordinates; an off-symbol position may return no results. findReferences always includes the declaration, so impact analysis never misses the defining site. Provider choice, language id, workspace root, limits, timeout, and executable stay outside model input.
Navigation returns path:line:character locations grouped by file (one-based); hover returns normalized text or a no-hover notice. Empty locations and no hover are successful no-result responses. Results are capped first by maxLocations and then by maxResultChars, with omission and truncation markers inside the complete cap; the caps affect only presentation, not the canonical result value.
| Key | Default | Meaning |
|---|---|---|
maxLocations |
100 |
Largest number of rendered locations before an omission marker |
maxResultChars |
16000 |
Largest complete rendered result, including truncation metadata |
timeoutMs |
60000 |
Tool-call timeout budget enforced by dsh-tool-call-timeout-policy; covers the complete queued open/query/close lifecycle and is not model-configurable |
The generated configuration catalog is the exhaustive source for every accepted field.
The tool requires a session workspace root (header.cwd) with no fallback; absence fails with LSP_WORKSPACE_REQUIRED before any query. When no provider handles the file's extension, the query fails with LSP_UNAVAILABLE; malformed provider payloads remain structured LSP_MALFORMED_RESPONSE errors. These surface to the model as error tool results it can read and route on.
Read these pages when the package-level contract is not enough. They move from the model-facing surface to the seam and the provider.
LspError codes.One system-prompt section (first-party order 2200) positions LSP as a precision aid with the following text:
Use search/read for ordinary navigation. Use lsp when textual matches are ambiguous or before a change requires precise definitions, implementations, or references. Positions are one-based line and character (UTF-16) at the cursor; an off-symbol position may return no results. findReferences always includes the declaration.
Fixed guidance cost on every request while the plugin is active.
Prefix-stable while the plugin scope and guidance text are unchanged; activation or disposal may invalidate reuse from this section.
The model sees the generated lsp schema.
Fixed schema cost on every request while enabled; the timeoutMs budget is never sent to the model.
Prefix-stable while the visible tool definition and order are unchanged; registration lifecycle or scoped restrictions may invalidate reuse from the first changed schema token.
File-grouped path:line:character location lines or normalized hover text, capped first by maxLocations and then by maxResultChars; omission and truncation markers are included inside the complete character cap. These caps affect only Native/model presentation, not the canonical value. Empty results use distinct No results. / No hover information. lines.
Capped per tool result by maxResultChars, with maxLocations additionally bounding navigation item count.
Tool results append after the cached request prefix and do not directly invalidate it.
Nothing. The client renders a generic search card — { card: 'generic', kind: 'search', title, locations: [{ path, line }] } — whose args-derived title carries the operation and one-based cursor; follow-along focuses the queried line while the title preserves the column.
Zero direct token effect because rendering is client-side only.
None; UI presentation is outside the model request.
These limits define when the tool is a poor fit. They are current package constraints, not a task backlog.