@mrclrchtr/supi-code-intelligence 11.4.0 → 12.0.0
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.
- package/CHANGELOG.md +22 -0
- package/README.md +13 -7
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +21 -16
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +25 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +7 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +64 -11
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
- package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +57 -12
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +22 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +51 -23
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +3 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
- package/package.json +5 -5
- package/src/analysis/health/server-status.ts +41 -12
- package/src/analysis/target/anchored-structural.ts +4 -1
- package/src/analysis/target/symbol.ts +1 -1
- package/src/session/find-types.ts +8 -4
- package/src/session/find-workflow.ts +11 -16
- package/src/session/input/health-refactor.ts +48 -34
- package/src/session/input/workflows.ts +45 -46
- package/src/session/inspect/file-point.ts +2 -2
- package/src/session/inspect-types.ts +1 -1
- package/src/session/inspect-workflow.ts +3 -3
- package/src/session/refactor-file-actions.ts +122 -0
- package/src/session/refactor-plan-pipeline.ts +152 -0
- package/src/session/refactor-plans.ts +18 -15
- package/src/session/refactor-types.ts +24 -12
- package/src/session/refactor-workflow.ts +68 -243
- package/src/tool/code_find/execute.ts +6 -7
- package/src/tool/code_find/spec.ts +9 -16
- package/src/tool/code_find/tui.ts +12 -6
- package/src/tool/code_graph/spec.ts +6 -0
- package/src/tool/code_health/spec.ts +6 -0
- package/src/tool/code_health/structured-schema.ts +4 -4
- package/src/tool/code_health/structured.ts +15 -17
- package/src/tool/code_inspect/execute.ts +1 -1
- package/src/tool/code_inspect/markdown.ts +33 -6
- package/src/tool/code_inspect/result.ts +1 -1
- package/src/tool/code_inspect/spec.ts +14 -6
- package/src/tool/code_inspect/structured.ts +2 -2
- package/src/tool/code_inspect/tui.ts +2 -2
- package/src/tool/code_orientation/spec.ts +8 -0
- package/src/tool/code_refactor_apply/result.ts +2 -1
- package/src/tool/code_refactor_apply/spec.ts +7 -0
- package/src/tool/code_refactor_plan/execute.ts +0 -2
- package/src/tool/code_refactor_plan/result.ts +23 -13
- package/src/tool/code_refactor_plan/spec.ts +8 -2
- package/src/tool/code_refactor_plan/structured.ts +59 -12
- package/src/tool/code_refactor_plan/tui.ts +14 -17
- package/src/tool/code_resolve/markdown.ts +1 -1
- package/src/tool/code_resolve/spec.ts +6 -0
- package/src/tool/namespace.ts +14 -0
- package/src/tool/refactor-markdown.ts +55 -15
- package/src/tool/register.ts +3 -0
- package/src/tool/result/refactor-preview.ts +118 -0
- package/src/tool/result/refactor-unavailable.ts +16 -0
- package/src/tool/result/refactor.ts +8 -2
- package/src/tool/schemas.ts +63 -20
- package/src/tool/specs.ts +3 -0
- package/src/ui/status-overlay.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [12.0.0]
|
|
4
|
+
|
|
5
|
+
- **Breaking:** `code_find` takes one `search` selector instead of flat `query`, `mode`, and `kind`: `search: { ast: { kind, query } }` or `search: { semantic: { query } }`. A semantic search can no longer carry an AST kind. `scope` is renamed to `scopes`, because it takes a list; `code_resolve` and `code_health` keep the single-path `scope`. Migration: `{ query, mode: "ast", kind, scope }` becomes `{ search: { ast: { kind, query } }, scopes }`.
|
|
6
|
+
- **Breaking:** `code_inspect` takes `anchor` instead of `point`, the same `{ file, line, character }` name the other `code_*` tools use. The result reports the inspected location as `anchor` too, so `inspect.anchor` can be passed straight to another tool's `target.anchor`.
|
|
7
|
+
- `code_inspect` no longer sends a stray `~optional` keyword in its `maxResults` schema.
|
|
8
|
+
- `code_inspect` shows at most the first 12 lines (1,200 characters) of the syntax node's text and names the line range to read for the rest. Previously an anchor on a blank line or leading whitespace selected the file's root node and printed the whole file. Codemode results still carry the full text.
|
|
9
|
+
- Codemode now lists the `code_*` tools under a `code` namespace heading, so scripts can find them with `describeNamespace("code")` or `searchTools(query, { namespace: "code" })`. `describeNamespace` also returns the recommended call order. Every `code_*` tool now declares audited `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint` annotations, which permission extensions can read from `pi.getAllTools()`. Only `code_refactor_apply` is marked destructive. `code_orientation` is marked open-world because consented Gradle observation can reach the network ([#582](https://github.com/mrclrchtr/supi/issues/582)).
|
|
10
|
+
- `code_refactor_plan` now previews code actions that only run a server command, such as kotlin-lsp extract variable and organize imports. SuPi runs the one selected command, captures the edit the server pushes, refuses it so no file changes, and stores it as the plan; the plan shows where its edit came from. This also works with clangd tweaks such as "Extract subexpression to variable", which report an error after their edit is refused. When a command pushes no edit, the reason notes there may be nothing to change. Only refactor, organize-imports, and fix-all commands run ([#584](https://github.com/mrclrchtr/supi/issues/584)).
|
|
11
|
+
- **Breaking:** `code_refactor_plan` takes only `operation`, and each operation names its own scope: `rename_symbol: { target, newName }`, `code_action: { file, range, kind, title? }` for server refactors such as `refactor.extract` (a range whose start equals its end marks a cursor position; positions outside the file are rejected before the server is asked), and `source_action: { file, kind, title? }` for whole-file actions such as `source.organizeImports`. Files outside the routed language server's project root are refused before the server is asked. Import cleanup and unused-code removal no longer need a symbol anchor. Extraction now works where the server returns exact edits (for example gopls, rust-analyzer, and jdtls); the preview shows the server's generated name, which `rename_symbol` can change afterwards. When several matching actions produce different edits, the result lists each action's kind and title to pass back as `title`. Migration: move `target` into `rename_symbol`, replace `update_imports` with `source_action` kind `source.organizeImports`, `delete_dead_code` with kind `source.removeUnused` or `source.removeUnusedImports`, and `extract_function`/`extract_variable` with `code_action` kind `refactor.extract` ([#583](https://github.com/mrclrchtr/supi/issues/583)).
|
|
12
|
+
- Kotlin local variables and parameters can be targeted by anchor (for example for `rename_symbol` after an extraction) when kotlin-lsp lists no document symbol for them. Previously the structural fallback recognized only `identifier` name tokens, not Kotlin's `simple_identifier`, and reported "No symbol target resolved".
|
|
13
|
+
- `code_refactor_plan` previews combine several edits on one line into one before/after entry, such as `- total` / `+ sumDoubled`, instead of showing the fragments a server like kotlin-lsp returns (`sumD`, `ub`, `ed`). The stored plan and the reported edit counts are unchanged, and the shown edits never stop in the middle of such a line.
|
|
14
|
+
- When a refactor plan or apply fails because a file changed while it ran (for example a plan running in parallel with an apply), the error now ends with "Retry after concurrent edits finish."
|
|
15
|
+
- `code_health` operation support lists `code_action` and `source_action` with the `refactor*` and `source*` kinds each server advertises, instead of fixed import, dead-code, and extraction entries. Servers that advertise the empty kind or no kind list, such as rust-analyzer, are marked as possibly returning unlisted kinds.
|
|
16
|
+
- An explicit `code_health` refresh that runs while a crashed language server is being replaced no longer makes the replacement fail. Previously, the request waiting on that replacement got no server and the recovery was recorded as cancelled, even though the new server was running.
|
|
17
|
+
- C and C++ headers mapped to another language by `code-intelligence.fileAssociations` (for example `**/*.h` as `cpp`) now use the language server's own diagnostics when the server registers them for that language. Previously, these headers were matched against the default C language, so the server's diagnostics for C++ never applied to them, and C-only diagnostics could be requested for files opened as C++.
|
|
18
|
+
- `code_health` server details are shorter. Operations with the same limit are listed together, so the extraction explanation appears once instead of once per operation, and operations a server does not support show only "server unsupported". Previously, every server, including bash and html, repeated a long typescript-language-server explanation twice.
|
|
19
|
+
- Cancelling a structural request, or reaching its deadline, no longer restarts the structural Worker. Previously every cancellation waited for the hard-stop timeout and discarded cached parse trees, so the next AST request parsed again from scratch.
|
|
20
|
+
- AST results for large files are much faster: converting node positions re-split the whole file for every node, which made extraction slow down quadratically with file size. On an 8,000-line TypeScript file, call-site extraction dropped from about 10 s to 0.3 s, and outline and export extraction from several seconds to under 0.2 s, so these requests no longer hit their deadlines on large files.
|
|
21
|
+
- Export extraction for JavaScript and TypeScript is more accurate: `export default "foo"` is reported as a default export instead of `export * from "foo"`, every name in `export var a, b` is listed, and `export import X = Y.Z` is listed as an `alias` export.
|
|
22
|
+
- In files containing a carriage return that is not part of a CRLF line ending (for example inside a template literal), AST positions after that character are correct again. Previously later lines were shifted, so ranges were truncated and some valid `code_inspect` positions were rejected as beyond the end of the line.
|
|
23
|
+
- Call ranges for Java, Kotlin, and Ruby now cover only the called expression (such as `a.b` in `a.b(1)`), as in other languages, instead of the whole call with its arguments and block. A Kotlin call with a trailing lambda, such as `bar(1) { it }`, is now reported once instead of twice in call search and `code_graph` callees.
|
|
24
|
+
|
|
3
25
|
## [11.4.0]
|
|
4
26
|
|
|
5
27
|
- `code_orientation` with a directory focus no longer embeds an instruction file (such as `CLAUDE.md`) that the agent already read in full with `read` since the latest compaction. Reads with `offset` or `limit`, truncated reads, and failed reads do not count. In observed sessions, about a quarter of embedded instruction text repeated a file the agent had just read.
|
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ The full extension registers all eight tools at startup; it does not load them o
|
|
|
59
59
|
| `code_resolve` | Resolve a real symbol anchor or semantic query to target handles, or list a file's declarations |
|
|
60
60
|
| `code_inspect` | Inspect syntax, the enclosing declaration, hover information, definitions, and nearby diagnostics at one point |
|
|
61
61
|
| `code_graph` | Find semantic references and implementations, or structural calls from the enclosing scope |
|
|
62
|
-
| `code_find` | Search with
|
|
62
|
+
| `code_find` | Search with exactly one `search` mode: `ast: { kind, query }` or `semantic: { query }` |
|
|
63
63
|
| `code_health` | Report diagnostic observations and language-server health |
|
|
64
64
|
| `code_refactor_plan` | Store a semantic refactor preview without changing files |
|
|
65
65
|
| `code_refactor_apply` | Apply a fresh stored plan after file and edit checks |
|
|
@@ -70,7 +70,7 @@ Example tool calls:
|
|
|
70
70
|
|
|
71
71
|
```javascript
|
|
72
72
|
code_orientation({ focus: { path: "packages/api" } })
|
|
73
|
-
code_find({ query: "PaymentProvider"
|
|
73
|
+
code_find({ search: { semantic: { query: "PaymentProvider" } }, scopes: ["packages/api"] })
|
|
74
74
|
code_health({ scope: "packages/api/src/index.ts", refresh: true })
|
|
75
75
|
```
|
|
76
76
|
|
|
@@ -90,12 +90,12 @@ All eight tools declare native output schemas and return JSON-serializable `stru
|
|
|
90
90
|
| Tool | Native data |
|
|
91
91
|
|---|---|
|
|
92
92
|
| Resolve | `targets` with reusable `handle` values, candidate selection, and evidence counts |
|
|
93
|
-
| Inspect | `
|
|
93
|
+
| Inspect | `anchor`, independently completed/partial/unavailable `sections` with `data`, recovery, bounded definitions/diagnostics, provenance, and next queries |
|
|
94
94
|
| Orientation | `focusKind`, named section `facts`, selected `workspace` inventories/declarations/relationships and Gradle observations when applicable, instructions, limitations, and optional captured `snapshot` |
|
|
95
95
|
| Graph | Per-relation `sections` with bounded `items` and evidence |
|
|
96
96
|
| Find | Bounded `matches`; AST scan policy, exclusions, limitations, and failures |
|
|
97
97
|
| Health | Requested `includedSections` and `level`, actual `diagnostics` with scope and confirmation evidence, all collected `servers`, workspace inventory scope, capability state, warnings, and separate `refresh` outcomes |
|
|
98
|
-
| Refactor Plan | `planId`, operation,
|
|
98
|
+
| Refactor Plan | `planId`, operation, `file`, rename `target` or action `range`, the selected `action` kind and title, every exact edit in `edits`, file/edit counts, provenance, and `nextAction`; ambiguous results list candidate kinds and titles |
|
|
99
99
|
| Refactor Apply | Explicit `kind: "applied"`, changed `files` with per-file counts, and total file/edit counts |
|
|
100
100
|
|
|
101
101
|
Check `kind` before consuming evidence. Invalid input and candidate selection remain corrective returned outcomes; real execution/capability failures and cancellation throw. Internal providers, target records, fingerprints, mutation authority, and session state are not exposed. Apply recovery consumes original document identities in `details.data.recoveryFiles`, independently of display paths and script data.
|
|
@@ -110,7 +110,7 @@ Semantic exclusion examples distinguish the original `observedPath` rejected by
|
|
|
110
110
|
|
|
111
111
|
Orientation groups equivalent syntax-recovery warnings by source, reason, and error ranges, listing all affected operations once. Native recovery facts retain every per-operation observation; distinct warnings remain separate.
|
|
112
112
|
|
|
113
|
-
Source points, target positions, Inspect source coordinates, and Orientation source-item coordinates use one-based lines and UTF-16 columns. Refactor edit ranges and Orientation provider ranges (hover, definitions, diagnostics), like syntax-recovery ranges, use zero-based lines and UTF-16 columns; range ends are exclusive. Health messages use one-based lines.
|
|
113
|
+
Source points, target positions, `code_action` ranges, Inspect source coordinates, and Orientation source-item coordinates use one-based lines and UTF-16 columns. Refactor edit ranges and Orientation provider ranges (hover, definitions, diagnostics), like syntax-recovery ranges, use zero-based lines and UTF-16 columns; range ends are exclusive. Health messages use one-based lines.
|
|
114
114
|
|
|
115
115
|
Registered-tool tests validate results against the registered output schemas and JSON round-tripping; Pi does not validate output schemas at runtime. Separate deterministic integration tests execute all five migrated tools through Pi's real default codemode route, including fixture mutation by Apply. These tests use controlled providers, not live language-server qualification.
|
|
116
116
|
|
|
@@ -166,9 +166,15 @@ Candidate selection for Graph, Resolve, and Orientation uses one structured tran
|
|
|
166
166
|
|
|
167
167
|
### Refactor checks
|
|
168
168
|
|
|
169
|
-
The planner accepts
|
|
169
|
+
The planner accepts exactly one operation, each with its own scope:
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
| Operation | Input | Server request |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `rename_symbol` | `target` (handle or name anchor) and `newName` | `textDocument/rename` |
|
|
174
|
+
| `code_action` | `file`, one-based `range` (equal `start` and `end` mark a cursor position), `kind` under `refactor` (for example `refactor.extract`), optional `title` | Code actions for the range |
|
|
175
|
+
| `source_action` | `file`, `kind` under `source` (for example `source.organizeImports`), optional `title` | Code actions for the whole file |
|
|
176
|
+
|
|
177
|
+
Files outside the routed language server's project root are refused before any request, and `code_action` ranges must lie inside the file. `kind` matches the action kind and its dotted sub-kinds, never the title; `quickfix` and other kinds are rejected. Disabled actions never match. When matching actions produce different edits, the result is ambiguous and lists each candidate's kind and exact title; repeat the call with `title`. For an action that only runs a server command (for example on kotlin-lsp or clangd), SuPi runs that one command, captures the single edit the server pushes, refuses it so no file changes, and stores it as the plan; the plan shows `**Source:** edit captured from the server command`. Only `refactor*`, `source.organizeImports`, and `source.fixAll` commands run, never other `source.*` commands, and only commands the server lists when it lists any. Several matching command actions are reported as ambiguous without running any. Running a command may still change server-side state such as caches. Code actions choose their own names (such as `newVar` or `var_name`); the preview shows them, and `rename_symbol` can rename them after apply. Which kinds work depends on the server: `code_health` lists the advertised `refactor*` and `source*` kinds per server and marks servers, such as rust-analyzer, that may also return kinds they do not list. Unsupported operations do not fall back to text edits.
|
|
172
178
|
|
|
173
179
|
Rename can discover affected files and repeat the request once after validated same-route enrollment, with a limit of 64 files. A null server document version for an open file is accepted only with a verified request snapshot of synchronized content. Plans retain its content fingerprint and client version; unknown or mismatched state remains unavailable.
|
|
174
180
|
|
|
@@ -193,31 +193,53 @@ export interface WorkspaceEdit {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
|
|
198
|
-
export type RefactorOperation =
|
|
199
|
-
| "rename_symbol"
|
|
200
|
-
| "extract_function"
|
|
201
|
-
| "extract_variable"
|
|
202
|
-
| "rename_file"
|
|
203
|
-
| "move_file"
|
|
204
|
-
| "update_imports"
|
|
205
|
-
| "delete_dead_code";
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Operation-aware refactor planning request.
|
|
196
|
+
* Operation-aware refactor planning request. Each operation carries only the
|
|
197
|
+
* scope it needs:
|
|
209
198
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
199
|
+
* - `rename_symbol`: one symbol position and the new name.
|
|
200
|
+
* - `code_action`: one file range and a CodeActionKind prefix under `refactor`.
|
|
201
|
+
* - `source_action`: one whole file and a CodeActionKind prefix under `source`.
|
|
202
|
+
*
|
|
203
|
+
* `kind` matches the requested kind and its dotted sub-kinds. `title`, when
|
|
204
|
+
* present, selects one action by its exact title.
|
|
213
205
|
*/
|
|
214
|
-
export
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
206
|
+
export type RefactorRequest =
|
|
207
|
+
| {
|
|
208
|
+
operation: "rename_symbol";
|
|
209
|
+
file: string;
|
|
210
|
+
position: CodePosition;
|
|
211
|
+
newName: string;
|
|
212
|
+
}
|
|
213
|
+
| {
|
|
214
|
+
operation: "code_action";
|
|
215
|
+
file: string;
|
|
216
|
+
range: SourceRange;
|
|
217
|
+
kind: string;
|
|
218
|
+
title?: string;
|
|
219
|
+
}
|
|
220
|
+
| {
|
|
221
|
+
operation: "source_action";
|
|
222
|
+
file: string;
|
|
223
|
+
kind: string;
|
|
224
|
+
title?: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/** Supported refactor operation names. */
|
|
228
|
+
export type RefactorOperation = RefactorRequest["operation"];
|
|
229
|
+
|
|
230
|
+
/** The code action selected for a precise code- or source-action plan. */
|
|
231
|
+
export interface RefactorActionIdentity {
|
|
232
|
+
/** Server-reported CodeActionKind. */
|
|
233
|
+
kind: string;
|
|
234
|
+
/** Server-reported action title. */
|
|
235
|
+
title: string;
|
|
236
|
+
/**
|
|
237
|
+
* How the edits were obtained: `edit` from the action itself (after
|
|
238
|
+
* `codeAction/resolve` when needed), or `captured-command` from the single
|
|
239
|
+
* `workspace/applyEdit` the server pushed while running the action's command.
|
|
240
|
+
* Captured edits were refused, never applied.
|
|
241
|
+
*/
|
|
242
|
+
provenance?: "edit" | "captured-command";
|
|
221
243
|
}
|
|
222
244
|
|
|
223
245
|
/**
|
|
@@ -228,6 +250,10 @@ export interface DisambiguationCandidate {
|
|
|
228
250
|
file?: string;
|
|
229
251
|
line?: number;
|
|
230
252
|
character?: number;
|
|
253
|
+
/** Server-reported CodeActionKind, for code-action candidates. */
|
|
254
|
+
kind?: string;
|
|
255
|
+
/** Exact action title to pass back as `title`, for code-action candidates. */
|
|
256
|
+
title?: string;
|
|
231
257
|
}
|
|
232
258
|
|
|
233
259
|
/**
|
|
@@ -241,6 +267,8 @@ export type RefactorResult =
|
|
|
241
267
|
| {
|
|
242
268
|
kind: "precise";
|
|
243
269
|
edits: WorkspaceEdit;
|
|
270
|
+
/** The selected code action, for code- and source-action plans. */
|
|
271
|
+
action?: RefactorActionIdentity;
|
|
244
272
|
/** Provider roots authorized by the semantic route. Consumers canonicalize before storage. */
|
|
245
273
|
authorizedMutationRoots: string[];
|
|
246
274
|
}
|
|
@@ -59,8 +59,8 @@ A configured route is not a ready server. Features depend on the active server,
|
|
|
59
59
|
| Hover, definitions, references, implementations, document/workspace symbols | Supported through the server's corresponding LSP methods; availability and coverage differ by server. |
|
|
60
60
|
| Diagnostics | Native pull, the eligible TypeScript request adapter, or ambient push. Push observation alone cannot confirm that a file is clean. See the diagnostic policy below. |
|
|
61
61
|
| `rename_symbol` | Requires server rename support and validated text edits; uses `prepareRename` when advertised. |
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
62
|
+
| `code_action` | Requires a code action of the requested `refactor*` kind for the range that produces validated text edits, directly or by capturing the one edit its command pushes. Names generated by the server appear unchanged in the plan. |
|
|
63
|
+
| `source_action` | Requires a code action of the requested `source*` kind for the whole document that produces validated text edits, directly or (for `source.organizeImports` and `source.fixAll`) by capturing the one edit its command pushes. |
|
|
64
64
|
|
|
65
65
|
The [operation-support model](src/config/operation-support.ts) separates server advertisement from SuPi planning limits. A server can advertise an action that SuPi cannot safely turn into a plan.
|
|
66
66
|
|
|
@@ -106,7 +106,7 @@ The required [Linux/macOS CI matrix](../../.github/workflows/ci.yml) keeps [sele
|
|
|
106
106
|
|
|
107
107
|
[Bounded config comparisons](__tests__/integration/typescript-config-coverage.test.ts) compare TS6 and native TS7 `--showConfig` root-file coverage for TS/JS defaults, include/exclude, `allowJs`/`checkJs`, inherited patterns (including late-created files), and separate referenced projects. These cases found no false exclusion; filtering is unchanged. **Config coverage state is not TypeScript program membership**: imports may bring excluded files into a program, and references do not merge root-file lists.
|
|
108
108
|
|
|
109
|
-
Native
|
|
109
|
+
Native TypeScript 7 offers `source.removeUnusedImports` through the same safe plan/apply workflow ([#554](https://github.com/mrclrchtr/supi/issues/554)); it removes unused imports only, not arbitrary unused declarations. Native TypeScript 7 advertises no `refactor*` kinds, so `code_action` extraction is unavailable there; no TLS/native feature-parity claim is made. Only the pinned combinations are tested, not every stable TS7 release. Focused qualification passed on macOS arm64 (Node 24.22.1) and Linux arm64 (Debian container, Node 24.22.0), including the native/TS6 public TS/JS matrix. The unused-import follow-up has local macOS arm64 verification only; its Linux verification remains pending. The pinned Linux/macOS CI jobs remain pending until they run; this is not a qualification claim for the complete multi-language baseline.
|
|
110
110
|
|
|
111
111
|
### Java startup and project JDKs
|
|
112
112
|
|
|
@@ -320,21 +320,26 @@ Disable one language with `lsp.servers.<language>.enabled: false`. Use `/supi-ci
|
|
|
320
320
|
- explicit ready, pending, inactive, disabled, and unavailable registry states
|
|
321
321
|
- a `SemanticProvider` adapter for `supi-code-runtime`
|
|
322
322
|
- precise rename and code-action edit conversion
|
|
323
|
-
-
|
|
323
|
+
- code-action kind-prefix filters, exact-title selection, and standard lazy edit resolution
|
|
324
324
|
- negotiated operation support in project-server status
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
Code- and source-action planners request exactly the caller's kind with `only` and
|
|
327
|
+
match the returned `CodeAction.kind` or its dotted descendants, never the title.
|
|
328
|
+
Entries outside `only` are dropped before validation. Disabled actions never match;
|
|
329
|
+
an optional exact title narrows the matches. Edit-only actions are validated before
|
|
330
|
+
planning. One eligible command-only action (`refactor*`, `source.organizeImports*`,
|
|
331
|
+
`source.fixAll*`; a command the server lists when it lists any) runs once: SuPi
|
|
332
|
+
advertises `workspace.applyEdit`, refuses every pushed edit with `applied: false`,
|
|
333
|
+
and plans the single edit captured while the command runs or shortly after it
|
|
334
|
+
answers, even when the server then reports the command as failed because the
|
|
335
|
+
edit was refused (clangd does). A timed-out or cancelled command keeps refusing late edits until it
|
|
336
|
+
settles. Touched open documents are re-sent as full text under a new version.
|
|
337
|
+
Running a command may still change server-side state. Resource operations,
|
|
338
|
+
snippets, annotations, malformed actions, and stale responses stay unavailable. Distinct matching plans return an
|
|
339
|
+
ambiguous result with each candidate's kind and title instead of selecting the first
|
|
340
|
+
action. Rename uses `prepareRename` when the server advertises it and otherwise uses
|
|
341
|
+
direct standard rename. Code actions choose generated names; plans preview them as
|
|
342
|
+
the server returns them.
|
|
338
343
|
|
|
339
344
|
Rename responses that need additional document state can trigger one bounded discovery/enrollment retry. SuPi validates edit shape and canonical mutation paths, enrolls at most 64 affected files on the same route, and requests fresh edits. The first response is not a plan. Numeric versions must still match. A null version for an open document requires verified synchronized-content evidence; the plan retains the request fingerprint and client version. Missing snapshots, changed inputs, a larger follow-up edit set, and unsafe edits remain unavailable. Planning and apply revalidate these preconditions; no version is discarded to make an edit fit.
|
|
340
345
|
|
package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts
CHANGED
|
@@ -193,31 +193,53 @@ export interface WorkspaceEdit {
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
|
|
198
|
-
export type RefactorOperation =
|
|
199
|
-
| "rename_symbol"
|
|
200
|
-
| "extract_function"
|
|
201
|
-
| "extract_variable"
|
|
202
|
-
| "rename_file"
|
|
203
|
-
| "move_file"
|
|
204
|
-
| "update_imports"
|
|
205
|
-
| "delete_dead_code";
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Operation-aware refactor planning request.
|
|
196
|
+
* Operation-aware refactor planning request. Each operation carries only the
|
|
197
|
+
* scope it needs:
|
|
209
198
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
199
|
+
* - `rename_symbol`: one symbol position and the new name.
|
|
200
|
+
* - `code_action`: one file range and a CodeActionKind prefix under `refactor`.
|
|
201
|
+
* - `source_action`: one whole file and a CodeActionKind prefix under `source`.
|
|
202
|
+
*
|
|
203
|
+
* `kind` matches the requested kind and its dotted sub-kinds. `title`, when
|
|
204
|
+
* present, selects one action by its exact title.
|
|
213
205
|
*/
|
|
214
|
-
export
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
206
|
+
export type RefactorRequest =
|
|
207
|
+
| {
|
|
208
|
+
operation: "rename_symbol";
|
|
209
|
+
file: string;
|
|
210
|
+
position: CodePosition;
|
|
211
|
+
newName: string;
|
|
212
|
+
}
|
|
213
|
+
| {
|
|
214
|
+
operation: "code_action";
|
|
215
|
+
file: string;
|
|
216
|
+
range: SourceRange;
|
|
217
|
+
kind: string;
|
|
218
|
+
title?: string;
|
|
219
|
+
}
|
|
220
|
+
| {
|
|
221
|
+
operation: "source_action";
|
|
222
|
+
file: string;
|
|
223
|
+
kind: string;
|
|
224
|
+
title?: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/** Supported refactor operation names. */
|
|
228
|
+
export type RefactorOperation = RefactorRequest["operation"];
|
|
229
|
+
|
|
230
|
+
/** The code action selected for a precise code- or source-action plan. */
|
|
231
|
+
export interface RefactorActionIdentity {
|
|
232
|
+
/** Server-reported CodeActionKind. */
|
|
233
|
+
kind: string;
|
|
234
|
+
/** Server-reported action title. */
|
|
235
|
+
title: string;
|
|
236
|
+
/**
|
|
237
|
+
* How the edits were obtained: `edit` from the action itself (after
|
|
238
|
+
* `codeAction/resolve` when needed), or `captured-command` from the single
|
|
239
|
+
* `workspace/applyEdit` the server pushed while running the action's command.
|
|
240
|
+
* Captured edits were refused, never applied.
|
|
241
|
+
*/
|
|
242
|
+
provenance?: "edit" | "captured-command";
|
|
221
243
|
}
|
|
222
244
|
|
|
223
245
|
/**
|
|
@@ -228,6 +250,10 @@ export interface DisambiguationCandidate {
|
|
|
228
250
|
file?: string;
|
|
229
251
|
line?: number;
|
|
230
252
|
character?: number;
|
|
253
|
+
/** Server-reported CodeActionKind, for code-action candidates. */
|
|
254
|
+
kind?: string;
|
|
255
|
+
/** Exact action title to pass back as `title`, for code-action candidates. */
|
|
256
|
+
title?: string;
|
|
231
257
|
}
|
|
232
258
|
|
|
233
259
|
/**
|
|
@@ -241,6 +267,8 @@ export type RefactorResult =
|
|
|
241
267
|
| {
|
|
242
268
|
kind: "precise";
|
|
243
269
|
edits: WorkspaceEdit;
|
|
270
|
+
/** The selected code action, for code- and source-action plans. */
|
|
271
|
+
action?: RefactorActionIdentity;
|
|
244
272
|
/** Provider roots authorized by the semantic route. Consumers canonicalize before storage. */
|
|
245
273
|
authorizedMutationRoots: string[];
|
|
246
274
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Language Server Protocol runtime for SuPi code intelligence",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vscode-jsonrpc": "^10.0.0",
|
|
39
39
|
"vscode-languageserver-protocol": "^3.18.5",
|
|
40
40
|
"vscode-languageserver-types": "^3.18.5",
|
|
41
|
-
"@mrclrchtr/supi-code-runtime": "
|
|
42
|
-
"@mrclrchtr/supi-core": "
|
|
41
|
+
"@mrclrchtr/supi-code-runtime": "12.0.0",
|
|
42
|
+
"@mrclrchtr/supi-core": "12.0.0"
|
|
43
43
|
},
|
|
44
44
|
"bundledDependencies": [
|
|
45
45
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Public API surface for the LSP session-scoped service.
|
|
2
2
|
|
|
3
|
+
export type { CommandEditCaptureResult } from "./client/client-edit-capture.ts";
|
|
3
4
|
export { isMissingFileError } from "./client/client-file-state.ts";
|
|
4
5
|
export {
|
|
5
6
|
getExplicitlyDisabledLanguages,
|
|
@@ -7,10 +8,8 @@ export {
|
|
|
7
8
|
loadConfig,
|
|
8
9
|
} from "./config/config.ts";
|
|
9
10
|
export {
|
|
10
|
-
codeActionKindsForOperation,
|
|
11
11
|
getServerOperationSupport,
|
|
12
12
|
isCodeActionKindInRange,
|
|
13
|
-
REFACTOR_CODE_ACTION_KINDS,
|
|
14
13
|
supportsCodeActionResolve,
|
|
15
14
|
supportsCodeActions,
|
|
16
15
|
supportsPrepareRename,
|
|
@@ -91,6 +90,7 @@ export type {
|
|
|
91
90
|
ProcessCrashRecoveryOutcome,
|
|
92
91
|
ProcessCrashRecoveryReport,
|
|
93
92
|
RecoverDiagnosticsResult,
|
|
93
|
+
RoutedCodeActionResponse,
|
|
94
94
|
RoutedMutationDocumentSnapshot,
|
|
95
95
|
RoutedMutationResponse,
|
|
96
96
|
SemanticReadinessResult,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// dynamic set for `textDocument/diagnostic` is non-empty.
|
|
8
8
|
|
|
9
9
|
import { posix as posixPath } from "node:path";
|
|
10
|
+
import type { CFamilyFileAssociationResolver } from "@mrclrchtr/supi-code-runtime/api";
|
|
10
11
|
import { uriToFile } from "@mrclrchtr/supi-core/path";
|
|
11
12
|
import { detectLanguageId } from "../utils.ts";
|
|
12
13
|
|
|
@@ -51,12 +52,21 @@ export function isValidDocumentSelector(value: unknown): boolean {
|
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Match one valid document selector against a file URI.
|
|
57
|
+
*
|
|
58
|
+
* Pass the client's file associations so the language matches the ID sent in
|
|
59
|
+
* `didOpen` (for example, a `.h` file associated with `cpp`).
|
|
60
|
+
*/
|
|
61
|
+
export function isDocumentSelectorApplicable(
|
|
62
|
+
selector: unknown,
|
|
63
|
+
uri: string,
|
|
64
|
+
associations?: CFamilyFileAssociationResolver,
|
|
65
|
+
): boolean {
|
|
56
66
|
if (selector === undefined || selector === null) return true;
|
|
57
67
|
if (!isValidDocumentSelector(selector)) return false;
|
|
58
68
|
if (!Array.isArray(selector) || selector.length === 0) return false;
|
|
59
|
-
const language = detectLanguageId(uriToFile(uri));
|
|
69
|
+
const language = detectLanguageId(uriToFile(uri), associations);
|
|
60
70
|
const scheme = readUriScheme(uri);
|
|
61
71
|
const filePath = uriToFile(uri).replaceAll("\\", "/");
|
|
62
72
|
return selector.some((entry) => {
|
|
@@ -237,22 +237,17 @@ export class ClientDiagnostics {
|
|
|
237
237
|
for (const update of updates) {
|
|
238
238
|
const document = this.#openDocs.get(update.document.uri);
|
|
239
239
|
if (!document) throw new Error("Semantic input changed while synchronization was running.");
|
|
240
|
-
this.#synchronizeTrackedDocument(
|
|
241
|
-
update.document.uri,
|
|
242
|
-
update.document.filePath,
|
|
243
|
-
update.content,
|
|
244
|
-
document,
|
|
245
|
-
);
|
|
240
|
+
this.#synchronizeTrackedDocument(update.document, update.content, document);
|
|
246
241
|
this.#failedUris.delete(update.document.uri);
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
244
|
|
|
250
245
|
/** Apply one tracked-document change with the shared client state. */
|
|
251
246
|
#synchronizeTrackedDocument(
|
|
252
|
-
uri: string,
|
|
253
|
-
filePath: string,
|
|
247
|
+
{ uri, filePath }: { readonly uri: string; readonly filePath: string },
|
|
254
248
|
content: string,
|
|
255
249
|
document: OpenDocumentState,
|
|
250
|
+
options: { fullText?: boolean } = {},
|
|
256
251
|
): void {
|
|
257
252
|
synchronizeTrackedDocument({
|
|
258
253
|
uri,
|
|
@@ -267,6 +262,7 @@ export class ClientDiagnostics {
|
|
|
267
262
|
markUnversionedSyncMoment: () => this.#unversionedPushSyncMoments.set(uri, Date.now()),
|
|
268
263
|
clearFailedFile: () => this.#failedUris.delete(uri),
|
|
269
264
|
open: () => this.didOpen(filePath, content),
|
|
265
|
+
...(options.fullText ? { fullText: true } : {}),
|
|
270
266
|
});
|
|
271
267
|
}
|
|
272
268
|
|
|
@@ -394,7 +390,27 @@ export class ClientDiagnostics {
|
|
|
394
390
|
const nextFingerprint = fingerprintDocumentContent(content);
|
|
395
391
|
if (doc.contentFingerprint === nextFingerprint) return;
|
|
396
392
|
this.#advanceInputRevision();
|
|
397
|
-
this.#synchronizeTrackedDocument(uri, filePath, content, doc);
|
|
393
|
+
this.#synchronizeTrackedDocument({ uri, filePath }, content, doc);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Re-send an open document's tracked content under a new version, even when
|
|
398
|
+
* it is unchanged. The tracked content matches disk: semantic requests
|
|
399
|
+
* synchronize open documents with disk before they run. Used after a server ran a command whose pushed
|
|
400
|
+
* edit was refused, so the server's model matches the client again.
|
|
401
|
+
* Returns the versions before and after, or null when the document is not open.
|
|
402
|
+
*/
|
|
403
|
+
resynchronizeOpenDocument(filePath: string): { from: number; to: number } | null {
|
|
404
|
+
if (!this.host.isOperational()) return null;
|
|
405
|
+
const uri = fileToUri(filePath);
|
|
406
|
+
const doc = this.#openDocs.get(uri);
|
|
407
|
+
if (!doc) return null;
|
|
408
|
+
const from = doc.version;
|
|
409
|
+
this.#advanceInputRevision();
|
|
410
|
+
// Full text: the server may have changed its own copy, so a range computed
|
|
411
|
+
// from the client's content could no longer cover the whole document.
|
|
412
|
+
this.#synchronizeTrackedDocument({ uri, filePath }, doc.content, doc, { fullText: true });
|
|
413
|
+
return { from, to: doc.version };
|
|
398
414
|
}
|
|
399
415
|
|
|
400
416
|
/** Send a save after a disk change that the input barrier observed. */
|
|
@@ -73,6 +73,8 @@ interface SynchronizeDocumentOptions {
|
|
|
73
73
|
documentSync: NormalizedDocumentSync;
|
|
74
74
|
waiters: DiagnosticWaitRegistry;
|
|
75
75
|
sendNotification: NotificationSender;
|
|
76
|
+
/** Send the whole text without a range, even under incremental sync (LSP allows both). */
|
|
77
|
+
fullText?: boolean;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
function endPosition(content: string): { line: number; character: number } {
|
|
@@ -117,11 +119,9 @@ export function synchronizeDocument(options: SynchronizeDocumentOptions): void {
|
|
|
117
119
|
retainDocumentSynchronization(options);
|
|
118
120
|
options.document.version = options.version;
|
|
119
121
|
options.document.synchronizationId = options.synchronizationId;
|
|
120
|
-
const changes =
|
|
121
|
-
options.
|
|
122
|
-
options.content,
|
|
123
|
-
options.documentSync.change,
|
|
124
|
-
);
|
|
122
|
+
const changes = options.fullText
|
|
123
|
+
? [{ text: options.content }]
|
|
124
|
+
: contentChanges(options.document.content, options.content, options.documentSync.change);
|
|
125
125
|
options.document.content = options.content;
|
|
126
126
|
options.document.contentFingerprint = fingerprintDocumentContent(options.content);
|
|
127
127
|
if (options.documentSync.change === TextDocumentSyncKind.None) return;
|
|
@@ -161,6 +161,7 @@ export function synchronizeTrackedDocument(options: {
|
|
|
161
161
|
markUnversionedSyncMoment?(): void;
|
|
162
162
|
clearFailedFile?(): void;
|
|
163
163
|
open(): void;
|
|
164
|
+
fullText?: boolean;
|
|
164
165
|
}): void {
|
|
165
166
|
if (!options.document) {
|
|
166
167
|
options.open();
|
|
@@ -177,6 +178,7 @@ export function synchronizeTrackedDocument(options: {
|
|
|
177
178
|
documentSync: options.documentSync,
|
|
178
179
|
waiters: options.waiters,
|
|
179
180
|
sendNotification: options.sendNotification,
|
|
181
|
+
...(options.fullText ? { fullText: true } : {}),
|
|
180
182
|
});
|
|
181
183
|
options.clearFailedFile?.();
|
|
182
184
|
}
|