Files
deepseek-harness/packages/lsp/tool-lsp
Turtle 38c7a9fbf4 feat(release): publish package source, declaration maps, and documentation (#5884)
* feat(release): publish package source, declaration maps, and documentation

Every release member publishes its TypeScript source and the declaration
maps that resolve into it, and @deepseek-ai/dsh publishes the repository
Markdown documentation staged from docs/ at prepack time.

The ./src/* export most members already declared now resolves for an
installed consumer, and a consumer editor follows a declaration to the
implementation. Bundled JavaScript maps stay unpublished; the vendored
family and the Desktop runtime file policy are unchanged.

Rationale: .agents/notes/implemented/process/2026-10-08-published-source-and-docs.md

* feat(release): publish JavaScript maps and compress bundles

Every emitted JavaScript map ships beside the bundle it describes, and the
workspace build and the client preset compress bundles without mangling
identifiers.

The documentation payload now mirrors the website publication manifest and
is removed again by `postpack`; Desktop and the Python executable exclude
the published source, documentation, and maps; `clean` removes a staged
copy. Typert's publication contract gains the Remote declaration map.

* fix(release): keep node bundles readable for the worker image

The browser worker image lowers `yield*` only as a whole statement and
rewrites `for await` loops by their source layout, so compressed node-side
entries either fail that lowering or lower to unparseable code. Only the
browser bundles keep compression, which removes about a third of their text.

The bundle-purity assertion now matches the module-loader call regardless of
the quote style compression picks, and the release-pack fixture exercises
the installed package's new documentation requirement.

* feat(release): publish the whole documentation tree

`@deepseek-ai/dsh` copies `docs/` in full instead of the website's page
set: the maintainer documents, the generated migration records, the
translation guidelines, and the `*.i18n.yaml` consistency records ship
with the installed package, so the documentation's own links resolve
without a checkout.

* feat(release): publish the upgrade guides with the documentation

The staged documentation keeps the website's page set and adds every
`docs/upgrade-guide/` document, which is what an installed reader consults
when a released change breaks something. The rest of the maintainer tree
stays out.

* test(release): expect source and maps in master's new payload cases

* feat(release): keep installed docs and source readable in Desktop

Desktop keeps the published src/ and docs/ trees inside app.asar, and
every model shell call receives DSH_INSTALL_DIR and DSH_NODE_EXECUTABLE
so an agent can read them through Electron's Node mode. Staging also
generates docs/upgrade-guide/README.md, an index of the upgrade guides
grouped by the release they upgrade from.

Minified client bundles print string literals with backticks: the
worker image packer now recognizes those chunk requests, client license
banners are prepended after minification so their text survives, and
the affected artifact tests accept either quote.

* test(desktop): read archived docs through the Windows PowerShell form

Regenerate the config catalog for the shifted shell-env source line.

* test(desktop): wait for the GUI-subsystem Electron process from PowerShell

* build(release): publish source and maps from the message-quotes package

* build(release): publish source and maps from packages new on master

* build(release): publish source and maps from the tool-office package
2026-11-05 00:22:36 +08:00
..

description, kind
description kind
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. package-reference

@deepseek-ai/dsh-tool-lsp

English | 中文

Summary

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.

Table of Contents


Use this package

Queries use the Session's current working directory as their workspace root. Changing directory affects subsequent queries without changing an already running server's root.

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.

The tool

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.

What the model gets back

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.

Configuration

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.

Failures and recovery

The tool requires an Agent Session; a non-agent call fails with LSP_WORKSPACE_REQUIRED before any query. The working-directory service supplies and validates its current root. 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.


Understand the implementation

Implementation internals — click to expand

This section explains the design decisions behind the tool and where the code realizes them; observable behavior is covered in Use this package.

Design notes

  • Consumer-only. The tool runtime-injects only tools, lsp, and systemPrompt, imports no provider, and passes only exec.signal to the seam.
  • Coordinate conversion. parseLspArgs validates that line and character are positive integers and converts them to the seam's zero-based positions; rendered locations convert back to one-based form.
  • Canonical result passthrough. The tool returns the seam's closed union ({ kind: 'locations', locations, resolvedWorkspaceUri } or { kind: 'hover', hover }) so native renderers can inspect every acquired location and zero-based range directly.
  • Execution-world URI rendering. renderUri resolves a file: URI against the provider's canonical workspace URI — workspace-relative inside it, URI-derived absolute outside it, verbatim when malformed or not file: — never applying host-platform path rules to the session cwd.
  • Caps after rendering. maxLocations bounds the item count first, then maxResultChars bounds the complete rendered text including its omission or truncation marker.
  • Generic search-card presentation. presentLspCall renders a { card: 'generic', kind: 'search', title, locations: [{ path, line }] } view; the args-derived title carries the operation and one-based cursor, and follow-along focuses the queried line while the title preserves the column.

Source map

File Role
src/index.ts Plugin entry: config schema, tool registration, system-prompt section, execution
src/render.ts Pure formatting, coordinate conversion, URI resolution, result caps, UI presentation

Further Exploration

Read these pages when the package-level contract is not enough. They move from the model-facing surface to the seam and the provider.


Model Experience

System prompt

What the model sees

One system-prompt section (first-party order 2200) positions LSP as a precision aid with the following text:

Verbatim guidance
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.

Token effect

Fixed guidance cost on every request while the plugin is active.

KV Cache effect

Prefix-stable while the plugin scope and guidance text are unchanged; activation or disposal may invalidate reuse from this section.

Tool schema

What the model sees

The model sees the generated lsp schema.

Token effect

Fixed schema cost on every request while enabled; the timeoutMs budget is never sent to the model.

KV Cache effect

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.

Results

What the model sees

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.

Token effect

Capped per tool result by maxResultChars, with maxLocations additionally bounding navigation item count.

KV Cache effect

Tool results append after the cached request prefix and do not directly invalidate it.

UI presentation

What the model sees

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.

Token effect

Zero direct token effect because rendering is client-side only.

KV Cache effect

None; UI presentation is outside the model request.

Known Limitations and Deferred Work

These limits define when the tool is a poor fit. They are current package constraints, not a task backlog.

  • UTF-16 cursor coordinates — columns are exact for the protocol but hard for a model to count around non-BMP characters; an off-symbol position may return empty results, so the prompt explains the convention without encouraging broad LSP use.
  • No cross-server completeness promise — supported servers may return empty or partial results depending on indexing readiness; the tool promises no completeness across languages or servers.

Dev Note

Working context for maintainers — click to expand

None.