@mrclrchtr/supi-code-intelligence 11.3.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 +33 -0
- package/README.md +15 -9
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +22 -17
- 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 +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/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/config/tsconfig-scope.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +67 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
- 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/provider/semantic-symbol-mapper.ts +22 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +106 -16
- 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/README.md +1 -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 +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
- 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/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
- 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/helpers.ts +0 -7
- package/src/analysis/relations/implementations.ts +5 -0
- package/src/analysis/relations/references.ts +5 -0
- package/src/analysis/target/anchored-structural.ts +4 -1
- package/src/analysis/target/file-merge.ts +162 -0
- package/src/analysis/target/file-outline-omissions.ts +146 -0
- package/src/analysis/target/file-refinement.ts +7 -7
- package/src/analysis/target/file.ts +44 -156
- package/src/analysis/target/symbol.ts +5 -1
- package/src/analysis/target/types.ts +32 -6
- package/src/api.ts +1 -1
- package/src/app/app.ts +9 -3
- package/src/session/find-types.ts +8 -4
- package/src/session/find-workflow.ts +11 -16
- package/src/session/graph/collect.ts +2 -0
- package/src/session/graph-types.ts +3 -1
- package/src/session/graph-workflow.ts +5 -4
- 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/orientation/workspace-context.ts +3 -0
- package/src/session/orientation-workflow.ts +6 -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 +70 -244
- package/src/session/session.ts +87 -12
- package/src/session/target-workflow.ts +23 -21
- 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/section.ts +4 -0
- 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/directory-navigation.ts +20 -31
- package/src/tool/code_orientation/spec.ts +8 -0
- package/src/tool/code_orientation/workspace-output.ts +40 -13
- package/src/tool/code_orientation/workspace-sections.ts +45 -2
- 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/guidance.ts +1 -1
- package/src/tool/code_resolve/markdown.ts +121 -34
- package/src/tool/code_resolve/result.ts +18 -15
- package/src/tool/code_resolve/spec.ts +6 -0
- package/src/tool/code_resolve/structured.ts +43 -10
- 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/model-budget.ts +2 -2
- 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/result/types.ts +13 -10
- package/src/tool/schemas.ts +63 -20
- package/src/tool/specs.ts +3 -0
- package/src/ui/status-overlay.ts +1 -1
- package/src/ui/tui/common.ts +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
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
|
+
|
|
25
|
+
## [11.4.0]
|
|
26
|
+
|
|
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.
|
|
28
|
+
- A symbol query with no workspace-symbol match now explains that only files in projects the language server has loaded are searched, and points to an AST definition search with `code_find`, a `target.file` lookup, or an anchor. Previously it suggested retrying `code_resolve`, the tool that had just failed ([#576](https://github.com/mrclrchtr/supi/issues/576)).
|
|
29
|
+
- TypeScript and TSX files with import types that take type arguments, such as `import("typebox").Static<T>`, now parse completely. Previously, AST results (`code_find`, file outlines, callees) for directories containing such a file were marked incomplete, so an empty search could not confirm that a name does not exist.
|
|
30
|
+
- `code_orientation` with a directory focus again shows the focused package's declared entry points (such as `exports` and `main` paths) inline, and lists all direct files in one compact line instead of the first ten, unless `maxResults` is set. Sections moved to captured details are named in one note instead of a separate "Captured navigation" section.
|
|
31
|
+
- `code_graph` references and implementations with the TypeScript server now report an incomplete result, naming the unloaded projects, when another `tsconfig.json` that includes the target file (such as a `__tests__` project that includes `../src`) has no open file. Previously, matches from such projects were silently missing and the result looked complete. Top-level declarations that their module does not export stay complete, because no other project can reference them.
|
|
32
|
+
- With the TypeScript 6 or earlier server (tsserver), `code_graph` implementations in workspaces with several TypeScript projects are now reported as incomplete: tsserver searches implementations only in the target file's project. The note suggests references or TypeScript 7 instead of opening more files.
|
|
33
|
+
- `code_resolve` with a file target now reports a **file outline** instead of a "Target group": the result heading reads `# File outline of …`, structured output uses `kind: "file-outline"` and `unknownLevelCount`, and messages from `code_graph`, `code_orientation`, and `code_refactor_plan` explain that they need one declaration handle from the outline. Each declaration is classified as top-level, member (inside a class, interface, enum, namespace, or object literal), or local (inside a function or method body) instead of a single "nested" category.
|
|
34
|
+
- The `code_resolve` file outline now lists only a file's own top-level declarations and members, with members indented below their class or interface. Imported names, names in `export { … }` lists, `export … from` statements (including `export *`, so a barrel file no longer looks empty), and declarations inside function bodies are counted under "Not listed" with their line span and the call that retrieves them. Declaration kinds are shown in lower case regardless of their source, and decorated Python functions and methods no longer appear twice. Rows are shorter: evidence notes appear only for declarations the language server did not confirm. For a large TypeScript file the default view now shows its classes and functions instead of only imports, and the full outline uses about a third fewer tokens.
|
|
35
|
+
|
|
3
36
|
## [11.3.0]
|
|
4
37
|
|
|
5
38
|
- Added package-specific release notes for code navigation, diagnostics, and refactoring.
|
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
|
|
|
@@ -137,7 +137,7 @@ Automatic collection stays within the session working directory. Ancestor Git ro
|
|
|
137
137
|
- Metadata readers cover Node `package.json` and workspace declarations, Python `[project]` in `pyproject.toml`, Rust `Cargo.toml`, and Go `go.mod` / `go.work`. They do not run build tools or project code.
|
|
138
138
|
- Unsupported, dynamic, inherited, malformed, and unresolved declarations are disclosed. Go replacement directives and unsupported quoted-string escapes are not interpreted. Native project kinds remain separate; nearby Python or Rust projects do not become Node workspace members.
|
|
139
139
|
- Project declaration groups share their observed kind and project-relative identity source. Identical membership declarations share their native kind, source field, and value. List limits and omission counts still apply to individual declarations and memberships, not groups. A membership group refers to listed projects only when their identities match exactly; otherwise it lists member paths.
|
|
140
|
-
- Explicit directory results keep project identity, direct directories/files, applicable instructions, and collection problems inline. Complete ancillary sections (extension counts, nested declarations, memberships,
|
|
140
|
+
- Explicit directory results keep project identity, direct directories/files, the focused project's declared paths (manifest entry points), applicable instructions, and collection problems inline. Without `maxResults`, direct files are listed in full as one compact line, until the navigation budget applies the default cap. Complete ancillary sections (extension counts, nested declarations, memberships, and dependency topology) move to captured details, named in one note. Incomplete ancillary observations remain inline. Root-focused Orientation also keeps project declarations and memberships inline for workspace navigation.
|
|
141
141
|
- Captured directory diagrams retain separate dependency categories and declared values. Unique declared-name matches do not prove installed dependency resolution or runtime architecture.
|
|
142
142
|
- The inventory retains at most 10,000 entries. An explicit in-root directory is collected before unrelated paths use that budget. External directory focus uses its own observation. Metadata files have a 1 MiB read limit. The first-turn collector has a 10-second deadline; tool calls use their request control. Results disclose incomplete collection.
|
|
143
143
|
|
|
@@ -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
|
|
|
@@ -317,7 +323,7 @@ The first matching rule wins; no match keeps the extension default. Patterns are
|
|
|
317
323
|
|
|
318
324
|
Global association values and untrusted project values do not apply. The workspace provider host captures one rule set for AST grammar selection and LSP document language IDs. Restart Pi, or release all sessions that share the host and reload, to use changed rules. This setting has no settings-overlay editor. It does not bypass exclusions or establish compiler flags.
|
|
319
325
|
|
|
320
|
-
Directory orientation checks the path from the workspace root to the focused directory. It selects the first valid configured instruction file per directory, skips files already loaded by Pi
|
|
326
|
+
Directory orientation checks the path from the workspace root to the focused directory. It selects the first valid configured instruction file per directory, skips files already loaded by Pi, shown on the active branch, or read in full with `read` since the latest compaction, and shows at most 200 lines per file. Resolved instruction paths must stay inside the workspace. These snippets are tool output, not additions to Pi's system prompt.
|
|
321
327
|
|
|
322
328
|
## Privacy and security
|
|
323
329
|
|
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
StructuralProvider,
|
|
15
15
|
StructuralResult,
|
|
16
16
|
} from "./capability/types.ts";
|
|
17
|
+
export { childDeclarationLevel } from "./declaration-level.ts";
|
|
17
18
|
export type {
|
|
18
19
|
CFamilyExtension,
|
|
19
20
|
CFamilyFileAssociationResolver,
|
|
@@ -50,7 +51,7 @@ export type {
|
|
|
50
51
|
CodeResult,
|
|
51
52
|
CodeSymbol,
|
|
52
53
|
ConfidenceMode,
|
|
53
|
-
|
|
54
|
+
DeclarationLevel,
|
|
54
55
|
DisambiguationCandidate,
|
|
55
56
|
DocumentCodeSymbol,
|
|
56
57
|
DocumentEditPrecondition,
|
|
@@ -59,6 +60,7 @@ export type {
|
|
|
59
60
|
ImportData,
|
|
60
61
|
NodeAtData,
|
|
61
62
|
OutlineData,
|
|
63
|
+
RefactorActionIdentity,
|
|
62
64
|
RefactorOperation,
|
|
63
65
|
RefactorRequest,
|
|
64
66
|
RefactorResult,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DeclarationLevel } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
/** Declarations whose body holds statements, so nested declarations are local to it. */
|
|
4
|
+
const FUNCTION_LIKE_KINDS = new Set(["function", "method", "constructor"]);
|
|
5
|
+
/** Bindings whose value may be a function (locals) or an object literal (members). */
|
|
6
|
+
const VALUE_BINDING_KINDS = new Set(["variable", "constant", "property", "field"]);
|
|
7
|
+
/** Kinds that name an entry of an object, type, or enum rather than a statement-level binding. */
|
|
8
|
+
const MEMBER_ENTRY_KINDS = new Set(["property", "field", "method", "enummember", "key", "event"]);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Level of a declaration reported directly inside `parent`.
|
|
12
|
+
*
|
|
13
|
+
* Inside a local declaration everything stays local. A function, method, or
|
|
14
|
+
* constructor makes its nested declarations local. A variable, constant,
|
|
15
|
+
* property, or field holds either a function body (nested bindings are local)
|
|
16
|
+
* or an object literal (nested properties and methods are members). Every
|
|
17
|
+
* other container — class, interface, enum, struct, namespace, module, or a
|
|
18
|
+
* document section — makes its nested declarations members.
|
|
19
|
+
*
|
|
20
|
+
* Kinds compare case-insensitively, so LSP SymbolKind names and Tree-sitter
|
|
21
|
+
* outline kinds share one rule.
|
|
22
|
+
*/
|
|
23
|
+
export function childDeclarationLevel(
|
|
24
|
+
parent: { readonly kind: string | null; readonly level: DeclarationLevel },
|
|
25
|
+
childKind: string | null,
|
|
26
|
+
): Exclude<DeclarationLevel, "top-level" | "unknown"> {
|
|
27
|
+
if (parent.level === "local") return "local";
|
|
28
|
+
const parentKind = parent.kind?.toLowerCase() ?? "";
|
|
29
|
+
if (FUNCTION_LIKE_KINDS.has(parentKind)) return "local";
|
|
30
|
+
if (VALUE_BINDING_KINDS.has(parentKind)) {
|
|
31
|
+
return MEMBER_ENTRY_KINDS.has(childKind?.toLowerCase() ?? "") ? "member" : "local";
|
|
32
|
+
}
|
|
33
|
+
return "member";
|
|
34
|
+
}
|
|
@@ -34,8 +34,16 @@ export interface SymbolAnchor {
|
|
|
34
34
|
character: number;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Where a declaration sits within its file, as reported by a provider.
|
|
39
|
+
*
|
|
40
|
+
* - `top-level`: directly in the file, not inside another declaration.
|
|
41
|
+
* - `member`: directly inside a class, interface, enum, struct, namespace,
|
|
42
|
+
* module, or object literal (methods, fields, properties, enum members).
|
|
43
|
+
* - `local`: inside the body of a function, method, or constructor.
|
|
44
|
+
* - `unknown`: the provider reported a flat symbol list without hierarchy.
|
|
45
|
+
*/
|
|
46
|
+
export type DeclarationLevel = "top-level" | "member" | "local" | "unknown";
|
|
39
47
|
|
|
40
48
|
/**
|
|
41
49
|
* A discovered symbol / declaration.
|
|
@@ -54,7 +62,7 @@ export interface CodeSymbol {
|
|
|
54
62
|
file: string;
|
|
55
63
|
declarationAnchor: SymbolAnchor;
|
|
56
64
|
nameAnchor?: SymbolAnchor;
|
|
57
|
-
/** Named
|
|
65
|
+
/** Named enclosing declaration when reported; absence does not prove a top-level declaration. */
|
|
58
66
|
container?: string | null;
|
|
59
67
|
}
|
|
60
68
|
|
|
@@ -63,10 +71,10 @@ export interface CodeSymbol {
|
|
|
63
71
|
*
|
|
64
72
|
* `unknown` means the provider returned a flat observation without an actual
|
|
65
73
|
* hierarchy. A reported container name remains metadata and does not promote
|
|
66
|
-
* a flat observation to known
|
|
74
|
+
* a flat observation to a known level.
|
|
67
75
|
*/
|
|
68
76
|
export interface DocumentCodeSymbol extends CodeSymbol {
|
|
69
|
-
|
|
77
|
+
level: DeclarationLevel;
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
// ── Result types ───────────────────────────────────────────────────────
|
|
@@ -185,31 +193,53 @@ export interface WorkspaceEdit {
|
|
|
185
193
|
}
|
|
186
194
|
|
|
187
195
|
/**
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
| "rename_file"
|
|
195
|
-
| "move_file"
|
|
196
|
-
| "update_imports"
|
|
197
|
-
| "delete_dead_code";
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Operation-aware refactor planning request.
|
|
196
|
+
* Operation-aware refactor planning request. Each operation carries only the
|
|
197
|
+
* scope it needs:
|
|
198
|
+
*
|
|
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`.
|
|
201
202
|
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* explicitly and honestly until shared workspace-edit resource ops exist.
|
|
203
|
+
* `kind` matches the requested kind and its dotted sub-kinds. `title`, when
|
|
204
|
+
* present, selects one action by its exact title.
|
|
205
205
|
*/
|
|
206
|
-
export
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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";
|
|
213
243
|
}
|
|
214
244
|
|
|
215
245
|
/**
|
|
@@ -220,6 +250,10 @@ export interface DisambiguationCandidate {
|
|
|
220
250
|
file?: string;
|
|
221
251
|
line?: number;
|
|
222
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;
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
/**
|
|
@@ -233,6 +267,8 @@ export type RefactorResult =
|
|
|
233
267
|
| {
|
|
234
268
|
kind: "precise";
|
|
235
269
|
edits: WorkspaceEdit;
|
|
270
|
+
/** The selected code action, for code- and source-action plans. */
|
|
271
|
+
action?: RefactorActionIdentity;
|
|
236
272
|
/** Provider roots authorized by the semantic route. Consumers canonicalize before storage. */
|
|
237
273
|
authorizedMutationRoots: string[];
|
|
238
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
|
|
|
@@ -100,13 +100,13 @@ For example, select a compiler installed as `my-ts6` without changing the TLS co
|
|
|
100
100
|
- `code_health` and `/supi-ci-status` show the `native` or `tsserver` backend and resolved compiler version when known, separately from wrapper version. Manual/legacy-fallback launches have no inferred compiler identity. Missing versions remain unknown. Selection failures identify the package/root and a corrective action.
|
|
101
101
|
- Topmost-root collapsing remains unchanged. Mixed nested backends, Windows live qualification, dependency watchers, performance benchmarking, and full TLS/native feature parity are outside this change. Existing legacy TLS support is not deliberately removed.
|
|
102
102
|
|
|
103
|
-
Focused qualification
|
|
103
|
+
Focused qualification uses the native TypeScript 7 alias (`@typescript/native`), TLS, ordinary TypeScript 6, and `@typescript/typescript6` backed by `@typescript/old` → TypeScript 6. Exact versions come from the root `package.json` and lockfile; the wrapper's dependency range does not fix its compiler version, so the lockfile does. SuPi retains TS6 for its compiler-API dependency and legacy-server tests. Workspace typechecking and declaration builds use the native TS7 launcher directly to avoid ambiguity between the installed `tsc` binaries.
|
|
104
104
|
|
|
105
105
|
The required [Linux/macOS CI matrix](../../.github/workflows/ci.yml) keeps [selection/layout tests](__tests__/unit/typescript-launch.test.ts), [real native lifecycle tests](__tests__/integration/workspace-runtime.integration.typescript-native.test.ts), and [wrapper lifecycle tests](__tests__/integration/workspace-runtime.integration.typescript-launch.test.ts) separate from the [public TS/JS semantic matrix](../supi-code-intelligence/__tests__/acceptance/language-baseline-harness.ts). Required missing/unavailable behavior fails rather than skips. The matrix covers hover, definitions, references, meaningful implementations, document/workspace symbols, confirmed error → clean diagnostics, refresh, cross-file invalidation, Unicode-safe rename plan/apply and stale-plan rejection, and precise organize-imports. The TypeScript public matrix also checks unused-import removal, unchanged source during planning, stale-plan rejection, and preservation of unrelated text; native support is imports-only. Native TSX/JSX and module suffixes receive routing/synchronization checks rather than duplicate matrices. Existing stale-result and edit-safety suites remain in place.
|
|
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/api.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
StructuralProvider,
|
|
15
15
|
StructuralResult,
|
|
16
16
|
} from "./capability/types.ts";
|
|
17
|
+
export { childDeclarationLevel } from "./declaration-level.ts";
|
|
17
18
|
export type {
|
|
18
19
|
CFamilyExtension,
|
|
19
20
|
CFamilyFileAssociationResolver,
|
|
@@ -50,7 +51,7 @@ export type {
|
|
|
50
51
|
CodeResult,
|
|
51
52
|
CodeSymbol,
|
|
52
53
|
ConfidenceMode,
|
|
53
|
-
|
|
54
|
+
DeclarationLevel,
|
|
54
55
|
DisambiguationCandidate,
|
|
55
56
|
DocumentCodeSymbol,
|
|
56
57
|
DocumentEditPrecondition,
|
|
@@ -59,6 +60,7 @@ export type {
|
|
|
59
60
|
ImportData,
|
|
60
61
|
NodeAtData,
|
|
61
62
|
OutlineData,
|
|
63
|
+
RefactorActionIdentity,
|
|
62
64
|
RefactorOperation,
|
|
63
65
|
RefactorRequest,
|
|
64
66
|
RefactorResult,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DeclarationLevel } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
/** Declarations whose body holds statements, so nested declarations are local to it. */
|
|
4
|
+
const FUNCTION_LIKE_KINDS = new Set(["function", "method", "constructor"]);
|
|
5
|
+
/** Bindings whose value may be a function (locals) or an object literal (members). */
|
|
6
|
+
const VALUE_BINDING_KINDS = new Set(["variable", "constant", "property", "field"]);
|
|
7
|
+
/** Kinds that name an entry of an object, type, or enum rather than a statement-level binding. */
|
|
8
|
+
const MEMBER_ENTRY_KINDS = new Set(["property", "field", "method", "enummember", "key", "event"]);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Level of a declaration reported directly inside `parent`.
|
|
12
|
+
*
|
|
13
|
+
* Inside a local declaration everything stays local. A function, method, or
|
|
14
|
+
* constructor makes its nested declarations local. A variable, constant,
|
|
15
|
+
* property, or field holds either a function body (nested bindings are local)
|
|
16
|
+
* or an object literal (nested properties and methods are members). Every
|
|
17
|
+
* other container — class, interface, enum, struct, namespace, module, or a
|
|
18
|
+
* document section — makes its nested declarations members.
|
|
19
|
+
*
|
|
20
|
+
* Kinds compare case-insensitively, so LSP SymbolKind names and Tree-sitter
|
|
21
|
+
* outline kinds share one rule.
|
|
22
|
+
*/
|
|
23
|
+
export function childDeclarationLevel(
|
|
24
|
+
parent: { readonly kind: string | null; readonly level: DeclarationLevel },
|
|
25
|
+
childKind: string | null,
|
|
26
|
+
): Exclude<DeclarationLevel, "top-level" | "unknown"> {
|
|
27
|
+
if (parent.level === "local") return "local";
|
|
28
|
+
const parentKind = parent.kind?.toLowerCase() ?? "";
|
|
29
|
+
if (FUNCTION_LIKE_KINDS.has(parentKind)) return "local";
|
|
30
|
+
if (VALUE_BINDING_KINDS.has(parentKind)) {
|
|
31
|
+
return MEMBER_ENTRY_KINDS.has(childKind?.toLowerCase() ?? "") ? "member" : "local";
|
|
32
|
+
}
|
|
33
|
+
return "member";
|
|
34
|
+
}
|