@namzu/lsp 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +17 -245
  3. package/package.json +63 -64
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @namzu/lsp
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 075dfdf: Stop the README from making the package unpublishable.
8
+
9
+ A paragraph documenting the tool's path-containment boundary named a traversal path literally. npm's registry sits behind a WAF whose managed rules match path-traversal signatures in a request body, and `npm publish` sends the README as part of that body — so every publish of this package was rejected with a generic `403 Forbidden` about permissions, from CI and from a maintainer's machine alike. The prose is the payload; the text now describes traversal without spelling one, and says so in place so nobody puts it back.
10
+
11
+ This is why `@namzu/lsp` has no released versions before `0.2.0` despite being in the repository since 2026-08-16.
12
+
13
+ - b2c005c: Make each README an npm package page rather than the package's manual.
14
+
15
+ `@namzu/sdk`'s README was a twenty-four-section architecture tour, 45 KB of it; the others ran to several hundred lines each. That is the right shape for a single-package repository, where the README _is_ the documentation, and the wrong one here — it duplicated a `docs/` tree that already existed, and nothing checked that the two agreed.
16
+
17
+ Each README is now what a reader needs in the first minute: what the package is, install with its Node requirement, one working example, and links. The long-form material moved into `docs/` whole — `docs/sdk/architecture.md`, `docs/cli/reference.md`, `docs/packages/<name>.md` — where the doc gates cover it.
18
+
19
+ Two documentation defects fell out of the move, both in `@namzu/telemetry`'s session-export example, and both had been shipping: the config field is `redactors` and takes a list, not `redactor` taking one; and `secretRedactor` is a factory that has to be called. The required `destination` field was missing from the example entirely. They surfaced because a README is gated by nothing and `docs/` is compiled against the built SDK.
20
+
21
+ No API change.
22
+
3
23
  ## 0.2.0
4
24
 
5
25
  ### Minor Changes
package/README.md CHANGED
@@ -2,10 +2,9 @@
2
2
  type: Reference
3
3
  title: "@namzu/lsp"
4
4
  description: >-
5
- Language-server-backed code navigation for @namzu/sdk. Drives a real language
6
- server over stdio to resolve a symbol by name, by declaration, by every use
7
- and by hover, routing one server per language. Separate from the kernel so a
8
- consumer who never navigates code spawns nothing.
5
+ Language-server-backed code navigation for Namzu agents. Definitions,
6
+ references, symbols and diagnostics from a real server rather than from
7
+ grep, with one server per language routed by file extension.
9
8
  tags: [readme, package, lsp, code-navigation]
10
9
  timestamp: 2026-08-17T00:00:00Z
11
10
  status: active
@@ -16,36 +15,21 @@ diataxis: reference
16
15
 
17
16
  <h1>@namzu/lsp</h1>
18
17
 
19
- **Symbol resolution for [`@namzu/sdk`](https://www.npmjs.com/package/@namzu/sdk), so an agent asked for call sites gets the ones `grep` cannot see.**
18
+ **Language-server-backed code navigation for Namzu agents.**
20
19
 
21
- [![License: FSL-1.1-MIT](https://img.shields.io/badge/license-FSL--1.1--MIT-blue.svg)](https://github.com/cogitave/namzu/blob/main/LICENSE.md)
22
- [![npm](https://img.shields.io/npm/v/@namzu/lsp.svg?label=%40namzu%2Flsp)](https://www.npmjs.com/package/@namzu/lsp)
20
+ [![npm](https://img.shields.io/npm/v/@namzu/lsp.svg)](https://www.npmjs.com/package/@namzu/lsp)
21
+ [![build](https://github.com/cogitave/namzu/actions/workflows/ci.yml/badge.svg)](https://github.com/cogitave/namzu/actions/workflows/ci.yml)
22
+ [![license](https://img.shields.io/badge/license-FSL--1.1--MIT-blue.svg)](https://github.com/cogitave/namzu/blob/main/LICENSE.md)
23
23
 
24
- [Install](#install) · [Wire it up](#wire-it-up) · [Four operations](#four-operations) · [Three answers](#three-answers-not-two) · [One server per language](#one-server-per-language) · [Options](#options)
24
+ [Install](#install) · [Usage](#usage) · [Documentation](#documentation)
25
25
 
26
26
  </div>
27
27
 
28
28
  ---
29
29
 
30
- ## What this is
31
-
32
- The whole code-navigation surface a namzu agent had was `grep` (regex over
33
- file text) and `glob` (filename patterns). Ask for every call site of
34
- `computeTotal` and you get the comment that mentions it, the string literal
35
- that names it, and the unrelated same-named function in another scope — and
36
- you **miss** the call site that arrives through a re-export or a destructure,
37
- which is exactly the one a rename has to get right.
38
-
39
- This package closes that. It drives a real language server over its stdin and
40
- stdout — `Content-Length` framing rather than JSON lines, since a response
41
- carrying source text contains newlines; the `initialize`/`shutdown` handshake;
42
- request correlation — and implements the `CodeNavigationProvider` seam the
43
- kernel declares.
44
-
45
- It is separate from the kernel because the kernel owns the shape a tool
46
- programs against and this owns the process that answers. A consumer who never
47
- navigates code carries no extra dependency and spawns no server: the `lsp`
48
- tool is not registered at all in a run that has no provider.
30
+ Code navigation for an agent — definitions, references, symbols and
31
+ diagnostics — served by a real language server rather than by grep. One
32
+ server per language, routed by file extension, disposed with the run.
49
33
 
50
34
  ## Install
51
35
 
@@ -53,12 +37,9 @@ tool is not registered at all in a run that has no provider.
53
37
  pnpm add @namzu/sdk @namzu/lsp
54
38
  ```
55
39
 
56
- `@namzu/sdk` (>=1.0.0) is a peer dependency. This package has no runtime
57
- dependencies of its own — the transport is `node:child_process` and the wire
58
- is JSON — and it does not install a language server for you. You bring the
59
- binary; this drives it.
40
+ `@namzu/sdk` is a peer dependency. Install both.
60
41
 
61
- ## Wire it up
42
+ ## Usage
62
43
 
63
44
  ```ts
64
45
  import { RoutingCodeNavigationProvider } from '@namzu/lsp'
@@ -80,220 +61,11 @@ for (const tool of getCodeNavigationTools(codeNavigation)) registry.register(too
80
61
  await codeNavigation.dispose()
81
62
  ```
82
63
 
83
- `getCodeNavigationTools(undefined)` returns `[]`, so the `lsp` tool is **not
84
- registered at all** in a run that cannot use it. A tool that is always present
85
- and always answers "unavailable" costs a decision on every turn to say
86
- nothing, and it teaches a model that a capability exists when it does not.
87
-
88
- Registration is only half the wiring. The tool reads its provider from
89
- `ToolContext.codeNavigation`, and nothing in the run loop fills that field in
90
- for you — `sandbox` reaches a run through the executor, and code navigation
91
- has no equivalent seam. Set `codeNavigation` on the tool context the tool is
92
- executed with. A tool that is registered but reaches a context without a
93
- provider refuses by naming the missing piece rather than answering "no
94
- results", but that refusal is a wiring bug report, not a mode to run in.
95
-
96
- For a single-language workspace, skip the router:
97
-
98
- ```ts
99
- import { StdioCodeNavigationProvider } from '@namzu/lsp'
100
-
101
- const codeNavigation = new StdioCodeNavigationProvider({
102
- command: 'ts-server',
103
- args: ['--stdio'],
104
- rootDir: process.cwd(),
105
- })
106
- ```
107
-
108
- ## Four operations
109
-
110
- ```ts
111
- import type { CodeNavigationProvider } from '@namzu/lsp'
112
-
113
- declare const nav: CodeNavigationProvider
114
-
115
- const byName = await nav.symbols('computeTotal') // no position needed
116
- const declaredAt = await nav.definition('/repo/src/total.ts', 12, 6)
117
- const usedAt = await nav.references('/repo/src/total.ts', 12, 6)
118
- const typeOf = await nav.hover('/repo/src/total.ts', 12, 6)
119
-
120
- await nav.dispose()
121
- ```
122
-
123
- | | |
124
- |---|---|
125
- | `symbols(query, scope?)` | Find a declaration **by name**, with no position. |
126
- | `definition(file, line, character)` | Where the symbol under the position is declared. |
127
- | `references(file, line, character)` | Everywhere it is used, **excluding** the declaration. |
128
- | `hover(file, line, character)` | Its resolved type and documentation. |
129
-
130
- **Start with `symbols`.** The other three need a line and a character, and an
131
- agent starting from a name has neither — so without it every navigation begins
132
- with a grep, which is the text path this package exists to replace,
133
- reintroduced as its own prerequisite.
134
-
135
- The declaration is left out of `references` deliberately: an agent asking who
136
- calls this wants the call sites, and including the declaration inflates the
137
- count by one and reads as a caller that does not exist.
138
-
139
- Positions are zero-based, matching the wire. Paths come back the other way —
140
- `file://` stripped and percent-decoding undone — so a caller gets something it
141
- can hand straight to `readFile`.
142
-
143
- ## Three answers, not two
144
-
145
- ```ts
146
- import type { SourceLocation, SymbolLocation } from '@namzu/lsp'
147
-
148
- type CodeNavigationResult =
149
- | { readonly kind: 'locations'; readonly locations: readonly SourceLocation[] }
150
- | { readonly kind: 'unsupported'; readonly reason: string }
151
- | { readonly kind: 'failed'; readonly error: string }
152
-
153
- type SymbolSearchResult =
154
- | { readonly kind: 'symbols'; readonly symbols: readonly SymbolLocation[] }
155
- | { readonly kind: 'unsupported'; readonly reason: string }
156
- | { readonly kind: 'failed'; readonly error: string }
157
-
158
- type HoverResult =
159
- | { readonly kind: 'hover'; readonly contents: string }
160
- | { readonly kind: 'unsupported'; readonly reason: string }
161
- | { readonly kind: 'failed'; readonly error: string }
162
- ```
163
-
164
- `unsupported` means nothing here can answer that question — the server does
165
- not implement the method, does not declare the capability, or no server is
166
- configured for the file's language. A caller can fall back to `grep` and *say*
167
- the answer is textual. `failed` means something broke, and the answer is
168
- unknown.
169
-
170
- **Neither is `{ kind: 'locations', locations: [] }`.** An empty list means "I
171
- looked, and there are none", which is a real answer and the one a deletion
172
- depends on. A provider that answered a missing binary with an empty list would
173
- tell an agent a symbol has no callers, and the agent would delete it. So a
174
- server that never completes `initialize` produces `failed` naming the binary,
175
- inside a bounded startup timeout — and the failure is *remembered*, so a run
176
- that asks twenty times does not spawn twenty servers against a binary that is
177
- not there.
178
-
179
- `hover` carries the same distinction one level down: `contents` may be the
180
- empty string, because hovering over whitespace or a comment resolves to
181
- nothing, and that has to read differently from a server that broke.
182
-
183
- `SymbolLocation` extends `SourceLocation` with the symbol's `name`, and with
184
- `symbolKind` and `containerName` when the server supplied them.
185
-
186
- ### Capabilities are read, not probed
187
-
188
- What a server can do is taken from the `initialize` **result**, never
189
- discovered by sending a request and interpreting the error. A server with a
190
- workspace index answers `workspace/symbol`; one with only document symbols
191
- falls back to `textDocument/documentSymbol`, which needs a `scope` to look in
192
- and says so when it is missing; one declaring neither is `unsupported`, naming
193
- both. `hover` is refused up front only when the server explicitly declares
194
- `hoverProvider: false`.
195
-
196
- Sending the request and swallowing the error works until a server answers an
197
- error for a different reason — a transient one, a malformed query — and the
198
- fallback then fires for a capability the server has. The handshake already
199
- carries the answer.
200
-
201
- Two consequences of that split are worth knowing before you read a result.
202
- A server with a workspace index gets the query and decides what matches, so
203
- `scope` chooses which server answers rather than narrowing what it searches;
204
- the `documentSymbol` fallback is the path that filters, and it filters by
205
- plain substring on the symbol name. And the `documentSymbol` reply is a
206
- **tree**, which is walked — a reader that took only the top level would miss
207
- every method, which is most of what somebody searching by name is looking for.
208
-
209
- ## One server per language
210
-
211
- `RoutingCodeNavigationProvider` maps a file extension to a server, starts one
212
- lazily on first use, and reuses it. Starting every configured server up front
213
- pays for languages a run never touches; starting one per request pays the
214
- `initialize` handshake — seconds, for an indexing server — on every call.
215
- `startedCount()` reports how many are running, which is how the reuse is
216
- asserted: a per-request spawn is fast enough on a quick machine to pass a
217
- timing assertion.
218
-
219
- A file whose extension maps to nothing is `unsupported` **naming the
220
- extension**. It is not routed to a default, because a default sends the file
221
- to a server that cannot read it, which answers nothing, which reads as a
222
- symbol with no references.
223
-
224
- A `symbols` call with **no** scope asks every configured language and
225
- concatenates what they found. If nothing was found anywhere, the reason
226
- matters: a `failed` from any server wins, and when *every* server said
227
- `unsupported` that is what comes back — "nobody looked" is not "the name does
228
- not exist".
229
-
230
- Extensions are lower-cased on the way in, so a `.TS` on a case-insensitive
231
- filesystem is not reported as an unconfigured language.
232
-
233
- ## Options
234
-
235
- ```ts
236
- import type {
237
- CodeNavigationRoute,
238
- RoutingCodeNavigationOptions,
239
- StdioCodeNavigationOptions,
240
- } from '@namzu/lsp'
241
- ```
242
-
243
- `StdioCodeNavigationOptions` — one server:
244
-
245
- | Option | Default | Notes |
246
- |---|---|---|
247
- | `command` | — | required; the server binary |
248
- | `args` | none | argv for it, e.g. `['--stdio']` |
249
- | `rootDir` | — | required; the child's working directory, and the `rootUri` and workspace folder sent in `initialize` |
250
- | `startupTimeoutMs` | `15_000` | how long `initialize` may take before the provider reports `failed` |
251
- | `requestTimeoutMs` | `20_000` | how long any one request may take |
252
- | `env` | inherited | merged **over** the parent environment; omit it and the child inherits unchanged |
253
-
254
- `RoutingCodeNavigationOptions` — one server per language:
255
-
256
- | Option | Default | Notes |
257
- |---|---|---|
258
- | `routes` | — | required; each a `CodeNavigationRoute` of `extensions` (with the dot) and one `server` |
259
- | `createProvider` | `new StdioCodeNavigationProvider(…)` | how a route becomes a provider; injectable so a test can count spawns |
260
-
261
- ## Containment is the tool's job
262
-
263
- Every path the `lsp` builtin is given is resolved inside the run's working
264
- directory *before* it reaches the server, through the same containment helper
265
- `read` and `edit` use. A language server indexes a workspace and will happily
266
- answer about `../../etc/passwd` if asked; the boundary belongs to the tool,
267
- not to the process it drives. Calling a provider directly bypasses that, so a host
268
- that does its own dispatch owns the check.
269
-
270
- ## Disposal
271
-
272
- `dispose()` sends the `shutdown`/`exit` handshake **before** killing, so a
273
- server holding a lock file or mid-write on an index gets to finish, and falls
274
- back to `SIGKILL` on a bounded timeout so one that ignores `exit` cannot keep
275
- the run alive. Every in-flight request is rejected rather than left hanging,
276
- and the provider refuses further work instead of quietly respawning.
277
-
278
- `RoutingCodeNavigationProvider.dispose()` disposes every server it started.
279
-
280
- ## Status
281
-
282
- `0.x`. The two provider classes and the result unions are what the kernel's
283
- `lsp` builtin programs against, and the surface can still move before 1.0.
284
- `CodeNavigationProvider`, `SourceLocation`, `SymbolLocation` and the three
285
- result unions are re-exported here from `@namzu/sdk` rather than re-declared —
286
- the dependency direction is `sdk ← lsp`, so the kernel owns the shape and this
287
- package implements it, and a second declaration would be a copy that can
288
- drift.
289
-
290
- ## Further reading
64
+ ## Documentation
291
65
 
292
- - [`docs/sdk/tools/code-navigation.md`](../../docs/sdk/tools/code-navigation.md)
293
- — why the result union has three members, why the tool is absent without a
294
- provider, and how routing decides which server answers.
66
+ - [Code navigation — routing, the four operations and containment](https://github.com/cogitave/namzu/blob/main/docs/packages/lsp.md)
67
+ - [Namzu docs](https://github.com/cogitave/namzu/tree/main/docs)
295
68
 
296
69
  ## License
297
70
 
298
- FSL-1.1-MIT, converting to MIT two years after each release. Same as
299
- `@namzu/sdk`.
71
+ FSL-1.1-MIT, converting to MIT two years after each release.
package/package.json CHANGED
@@ -1,65 +1,64 @@
1
1
  {
2
- "name": "@namzu/lsp",
3
- "version": "0.2.0",
4
- "description": "Language-server-backed code navigation for @namzu/sdk. Resolves definitions and references through a real language server over stdio, so an agent asked for call sites gets symbol resolution rather than regex matches.",
5
- "license": "FSL-1.1-MIT",
6
- "type": "module",
7
- "homepage": "https://github.com/cogitave/namzu#readme",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/cogitave/namzu.git",
11
- "directory": "packages/lsp"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/cogitave/namzu/issues"
15
- },
16
- "main": "./dist/index.js",
17
- "types": "./dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
22
- }
23
- },
24
- "files": [
25
- "dist",
26
- "!dist/**/*.test.*",
27
- "!dist/**/*.proc-test.*",
28
- "!dist/**/__tests__",
29
- "!dist/**/__fixtures__",
30
- "!dist/**/test-setup.*",
31
- "src",
32
- "!src/**/*.test.*",
33
- "!src/**/*.proc-test.*",
34
- "!src/**/__tests__",
35
- "!src/**/__fixtures__",
36
- "!src/**/test-setup.*",
37
- "LICENSE.md",
38
- "README.md",
39
- "CHANGELOG.md"
40
- ],
41
- "publishConfig": {
42
- "access": "public",
43
- "provenance": true
44
- },
45
- "scripts": {
46
- "build": "tsc --build",
47
- "dev": "tsc --build --watch",
48
- "lint": "biome check src/",
49
- "lint:fix": "biome check --write src/",
50
- "format": "biome format --write src/",
51
- "test": "vitest run --passWithNoTests",
52
- "typecheck": "tsc --noEmit",
53
- "prepublishOnly": "pnpm lint && pnpm typecheck && pnpm build"
54
- },
55
- "peerDependencies": {
56
- "@namzu/sdk": ">=1.0.0"
57
- },
58
- "devDependencies": {
59
- "@biomejs/biome": "^1.9.4",
60
- "@namzu/sdk": "workspace:^",
61
- "@types/node": "^22.19.17",
62
- "typescript": "^5.5.0",
63
- "vitest": "^3.2.6"
64
- }
65
- }
2
+ "name": "@namzu/lsp",
3
+ "version": "0.2.1",
4
+ "description": "Language-server-backed code navigation for @namzu/sdk. Resolves definitions and references through a real language server over stdio, so an agent asked for call sites gets symbol resolution rather than regex matches.",
5
+ "license": "FSL-1.1-MIT",
6
+ "type": "module",
7
+ "homepage": "https://github.com/cogitave/namzu#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/cogitave/namzu.git",
11
+ "directory": "packages/lsp"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/cogitave/namzu/issues"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "!dist/**/*.test.*",
27
+ "!dist/**/*.proc-test.*",
28
+ "!dist/**/__tests__",
29
+ "!dist/**/__fixtures__",
30
+ "!dist/**/test-setup.*",
31
+ "src",
32
+ "!src/**/*.test.*",
33
+ "!src/**/*.proc-test.*",
34
+ "!src/**/__tests__",
35
+ "!src/**/__fixtures__",
36
+ "!src/**/test-setup.*",
37
+ "LICENSE.md",
38
+ "README.md",
39
+ "CHANGELOG.md"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true
44
+ },
45
+ "peerDependencies": {
46
+ "@namzu/sdk": ">=1.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@biomejs/biome": "^1.9.4",
50
+ "@types/node": "^22.19.17",
51
+ "typescript": "^5.5.0",
52
+ "vitest": "^3.2.6",
53
+ "@namzu/sdk": "^30.0.1"
54
+ },
55
+ "scripts": {
56
+ "build": "tsc --build",
57
+ "dev": "tsc --build --watch",
58
+ "lint": "biome check src/",
59
+ "lint:fix": "biome check --write src/",
60
+ "format": "biome format --write src/",
61
+ "test": "vitest run --passWithNoTests",
62
+ "typecheck": "tsc --noEmit"
63
+ }
64
+ }