@mrclrchtr/supi-code-intelligence 4.3.0 → 4.5.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/README.md +83 -218
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- 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/client/client-refresh.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +6 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- 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/package.json +8 -7
- package/src/extension.ts +2 -2
- package/src/{ui/markdown → overview}/overview-data.ts +1 -1
- package/src/overview/types.ts +21 -0
- package/src/session/orientation/collect.ts +39 -26
- package/src/{ui/markdown → session/orientation}/gather.ts +44 -24
- package/src/session/orientation-types.ts +23 -0
- package/src/session/orientation-workflow.ts +1 -11
- package/src/types/execution.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/details.ts +0 -18
- package/src/ui/markdown/types.ts +0 -75
- /package/src/{ui/markdown → overview}/overview.ts +0 -0
package/README.md
CHANGED
|
@@ -6,267 +6,132 @@
|
|
|
6
6
|
</a>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
# @mrclrchtr/supi-code-intelligence
|
|
9
|
+
# @mrclrchtr/supi-code-intelligence — LSP and Tree-sitter AST Code Intelligence for Pi
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Gives the [Pi coding agent](https://github.com/earendil-works/pi) direct, model-callable LSP semantic navigation and Tree-sitter AST structural code analysis.
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
pi install npm:@mrclrchtr/supi-code-intelligence
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
For local development:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
pi install ./packages/supi-code-intelligence
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Quickstart
|
|
26
|
-
|
|
27
|
-
The extension detects project languages and starts matching language servers. Install the required server binaries on `PATH`:
|
|
28
|
-
|
|
29
|
-
| Language | Binary |
|
|
30
|
-
|---|---|
|
|
31
|
-
| TypeScript / JavaScript | `typescript-language-server` |
|
|
32
|
-
| Python | `pyright-langserver` |
|
|
33
|
-
| Rust | `rust-analyzer` |
|
|
34
|
-
| Go | `gopls` |
|
|
35
|
-
| C / C++ | `clangd` |
|
|
36
|
-
| Bash | `bash-language-server` |
|
|
37
|
-
| HTML | `vscode-html-language-server` |
|
|
38
|
-
| SQL | `sql-language-server` |
|
|
39
|
-
| Ruby | `ruby-lsp` |
|
|
40
|
-
| Java | `jdtls` |
|
|
41
|
-
| Kotlin | `kotlin-lsp` |
|
|
42
|
-
| R | `R` with `languageserver` |
|
|
43
|
-
|
|
44
|
-
Semantic and structural support intentionally differ where the syntax differs: Ruby LSP handles ERB templates, and gopls handles `go.mod`, while AST search excludes both rather than parsing them with the wrong Tree-sitter grammar. Ruby gemspecs and KornShell files use the existing Ruby and Bash structural grammars.
|
|
45
|
-
|
|
46
|
-
Check runtime status with:
|
|
13
|
+
## LSP + AST, directly available to the agent
|
|
47
14
|
|
|
48
|
-
|
|
49
|
-
/supi-ci-status
|
|
50
|
-
```
|
|
15
|
+
Instead of relying on file reads and text search alone, Pi can call focused `code_*` tools backed by:
|
|
51
16
|
|
|
52
|
-
|
|
17
|
+
- **Language servers (LSP)** for types, definitions, references, implementations, diagnostics, workspace symbols, and semantic refactoring.
|
|
18
|
+
- **Tree-sitter ASTs** for syntax, outlines, source structure, structural search, and outgoing calls.
|
|
53
19
|
|
|
54
|
-
|
|
20
|
+
The two sources complement each other without silently pretending one is the other. Results say which capability supplied the evidence and when semantic or structural analysis is unavailable.
|
|
55
21
|
|
|
56
|
-
|
|
22
|
+
## What your agent gets
|
|
57
23
|
|
|
58
|
-
|
|
59
|
-
- `code_inspect` — inspect exact point facts
|
|
60
|
-
- `code_orientation` — orient around a workspace, module, directory, file, or resolved symbol
|
|
61
|
-
- `code_graph` — collect references, structural callees, and implementations
|
|
62
|
-
- `code_find` — explicit AST structural or semantic workspace-symbol search
|
|
63
|
-
- `code_health` — report live diagnostics, server status, and supplemental Capability Warnings
|
|
64
|
-
- `code_refactor_plan` — preview a precise semantic refactor without mutation
|
|
65
|
-
- `code_refactor_apply` — apply a stored plan after freshness checks
|
|
24
|
+
After installation, keep asking Pi normal coding questions. The agent can:
|
|
66
25
|
|
|
67
|
-
|
|
26
|
+
- **Map an unfamiliar repository** — understand workspaces, packages, entry points, dependencies, and local `CLAUDE.md` or `AGENTS.md` instructions before editing.
|
|
27
|
+
- **Navigate precisely with LSP** — identify the exact symbol at a source location and inspect its type, definition, enclosing declaration, and nearby diagnostics.
|
|
28
|
+
- **Follow relationships across LSP and AST evidence** — find references, implementations, and outgoing calls without guessing from matching text.
|
|
29
|
+
- **Search parsed code structure** — query AST definitions, types, interfaces, classes, methods, enums, imports, exports, and call sites.
|
|
30
|
+
- **Check live project health** — inspect language-server status and current errors or warnings, with an option to refresh stale diagnostics.
|
|
31
|
+
- **Refactor safely** — preview language-aware renames and extractions before applying them. Plans are rejected if the files changed in the meantime.
|
|
32
|
+
- **See uncertainty clearly** — results distinguish “nothing found” from incomplete or unavailable analysis and disclose omitted matches.
|
|
68
33
|
|
|
69
|
-
|
|
34
|
+
When Pi recognizes a workspace, the agent also receives an architecture overview near the start of the session, so it can orient before spending turns opening files.
|
|
70
35
|
|
|
71
|
-
##
|
|
36
|
+
## Example requests
|
|
72
37
|
|
|
73
|
-
|
|
38
|
+
You do not need to learn the tool-call syntax. Try asking Pi:
|
|
74
39
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
40
|
+
- “Map this repository and explain where authentication lives.”
|
|
41
|
+
- “Find every use and implementation of `PaymentProvider`.”
|
|
42
|
+
- “What does `executeAskUser` call, and where is it referenced?”
|
|
43
|
+
- “Find all exported interfaces under `packages/api`.”
|
|
44
|
+
- “Check this project for current language-server diagnostics.”
|
|
45
|
+
- “Rename `oldName` to `newName`, but show me the refactor plan before applying it.”
|
|
81
46
|
|
|
82
|
-
|
|
47
|
+
## See it in action
|
|
83
48
|
|
|
84
|
-
|
|
49
|
+
Select any screenshot to open it at full resolution.
|
|
85
50
|
|
|
86
|
-
|
|
51
|
+
### Understand the workspace
|
|
87
52
|
|
|
88
|
-
|
|
53
|
+
[![Workspace orientation showing package files, manifest details, and relationships][workspace-orientation]][workspace-orientation]
|
|
89
54
|
|
|
90
|
-
###
|
|
55
|
+
### Inspect an exact symbol
|
|
91
56
|
|
|
92
|
-
|
|
57
|
+
[![Symbol inspection showing syntax, hover information, definition, and diagnostics][symbol-inspection]][symbol-inspection]
|
|
93
58
|
|
|
94
|
-
|
|
95
|
-
- fingerprint-checked
|
|
96
|
-
- stale after a touched file changes
|
|
97
|
-
- not persisted across sessions
|
|
59
|
+
### Follow references and calls
|
|
98
60
|
|
|
99
|
-
|
|
61
|
+
[![Relationship graph showing references and direct calls][relationship-graph]][relationship-graph]
|
|
100
62
|
|
|
101
|
-
|
|
63
|
+
### Check live health
|
|
102
64
|
|
|
103
|
-
|
|
65
|
+
[![Code health showing diagnostics and running language servers][code-health]][code-health]
|
|
104
66
|
|
|
105
|
-
|
|
106
|
-
code_resolve({ target: { file: "src/billing.ts" }, maxResults: 10 })
|
|
107
|
-
→ choose one member targetId from the returned Target group
|
|
108
|
-
```
|
|
67
|
+
### Preview a safe refactor
|
|
109
68
|
|
|
110
|
-
|
|
69
|
+
[![Refactor plan previewing a semantic rename without changing files][refactor-plan]][refactor-plan]
|
|
111
70
|
|
|
112
|
-
|
|
71
|
+
## Agent tools
|
|
113
72
|
|
|
114
|
-
|
|
115
|
-
code_resolve({ target: { symbol: { query: "myFunction", scope: "packages/app" } } })
|
|
116
|
-
→ capture targetId
|
|
73
|
+
The package adds eight tools that Pi selects as needed:
|
|
117
74
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```text
|
|
129
|
-
code_orientation({ focus: { path: "packages/my-package" } })
|
|
130
|
-
code_orientation({ focus: { module: "@scope/my-package" } })
|
|
131
|
-
code_orientation({ focus: { target: { handle: "tg-…" } } })
|
|
132
|
-
```
|
|
75
|
+
| Tool | What it lets the agent do |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `code_orientation` | Understand a workspace, package, directory, file, or symbol before reading broadly |
|
|
78
|
+
| `code_resolve` | Resolve an exact symbol, disambiguate matches, or list declarations in a file |
|
|
79
|
+
| `code_inspect` | Combine AST syntax with LSP type, definition, symbol, and diagnostic facts at one source location |
|
|
80
|
+
| `code_graph` | Follow LSP references and implementations plus AST calls made by a symbol |
|
|
81
|
+
| `code_find` | Search LSP workspace symbols or parsed AST source structure rather than raw text |
|
|
82
|
+
| `code_health` | Check live diagnostics, language servers, and code-intelligence availability |
|
|
83
|
+
| `code_refactor_plan` | Preview a precise rename or extraction without changing files |
|
|
84
|
+
| `code_refactor_apply` | Apply a fresh refactor plan after safety checks |
|
|
133
85
|
|
|
134
|
-
|
|
86
|
+
Pi's built-in `grep` remains the right tool for literal or regular-expression searches; these tools add symbol and source-structure awareness.
|
|
135
87
|
|
|
136
|
-
|
|
88
|
+
## Install
|
|
137
89
|
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
point: { file: "src/index.ts", line: 12, character: 8 },
|
|
141
|
-
maxResults: 10
|
|
142
|
-
})
|
|
90
|
+
```bash
|
|
91
|
+
pi install npm:@mrclrchtr/supi-code-intelligence
|
|
143
92
|
```
|
|
144
93
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### Search code-aware evidence
|
|
94
|
+
To try it for one run without installing:
|
|
148
95
|
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
code_find({ query: "widget", mode: "ast", kind: "definition" })
|
|
152
|
-
code_find({ query: "@scope/package", mode: "ast", kind: "import", scope: ["src"] })
|
|
96
|
+
```bash
|
|
97
|
+
pi -e npm:@mrclrchtr/supi-code-intelligence
|
|
153
98
|
```
|
|
154
99
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- `semantic` — workspace symbols; rejects `kind`
|
|
158
|
-
- `ast` — structured source-shape search; requires `kind`
|
|
159
|
-
|
|
160
|
-
Use PI's `grep` tool for literal or regex source search when it is active. `code_find` does not redirect removed text/regex calls to another tool.
|
|
161
|
-
|
|
162
|
-
AST `kind` accepts exactly `definition`, `import`, `export`, `call`, `type`, `interface`, `class`, `method`, and `enum`. Outline-backed kinds support every vendored grammar family; HTML definitions are elements with non-empty `id` attributes, while SQL definitions are supported `CREATE` declarations and shallow table/type members. Imports and exports remain JavaScript/TypeScript-only. AST `call` finds written call-site names, not symbol identity. Use `code_graph` references on a resolved target for symbol-identity relationships.
|
|
163
|
-
|
|
164
|
-
#### AST Scan universe
|
|
100
|
+
## Language support
|
|
165
101
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
Every explicit scope root is honored before descendant exclusions resume. An operation-eligible source file explicitly selected under `node_modules`, for example, is analyzed. An exact file whose grammar does not support the selected operation is invalid rather than redirected; a directory containing only operation-ineligible source is unavailable. Mixed scopes remain complete over their declared operation-specific universe and disclose operation exclusions. Duplicate, nested, and overlapping scopes are canonically deduplicated.
|
|
169
|
-
|
|
170
|
-
AST Scan details disclose the structural operation, supported extensions, roots, policy exclusions, eligible/analyzed file counts, and runtime limitations. Complete scans retain exact match totals. Unreadable paths, provider failures, the 5,000-file safety cap, or the 10-second deadline produce partial evidence with an unknown match total; skipped file counts are not reported as omitted matches.
|
|
171
|
-
|
|
172
|
-
### Check health
|
|
173
|
-
|
|
174
|
-
```text
|
|
175
|
-
code_health({ refresh: true, include: ["diagnostics", "servers"] })
|
|
176
|
-
```
|
|
102
|
+
Structural code search is bundled with the package. Full symbol navigation, references, diagnostics, and semantic refactoring require the matching language server on `PATH`.
|
|
177
103
|
|
|
178
|
-
|
|
104
|
+
The extension detects project languages and starts installed servers automatically:
|
|
179
105
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
106
|
+
| Language | Required binary |
|
|
107
|
+
|---|---|
|
|
108
|
+
| TypeScript / JavaScript | `typescript-language-server` |
|
|
109
|
+
| Python | `pyright-langserver` |
|
|
110
|
+
| Rust | `rust-analyzer` |
|
|
111
|
+
| Go | `gopls` |
|
|
112
|
+
| C / C++ | `clangd` |
|
|
113
|
+
| Bash | `bash-language-server` |
|
|
114
|
+
| HTML | `vscode-html-language-server` |
|
|
115
|
+
| SQL | `sql-language-server` |
|
|
116
|
+
| Ruby | `ruby-lsp` |
|
|
117
|
+
| Java | `jdtls` |
|
|
118
|
+
| Kotlin | `kotlin-lsp` |
|
|
119
|
+
| R | `R` with the `languageserver` package |
|
|
183
120
|
|
|
184
|
-
|
|
185
|
-
code_refactor_plan({
|
|
186
|
-
target: { handle: "tg-…" },
|
|
187
|
-
operation: { rename_symbol: { newName: "newName" } }
|
|
188
|
-
})
|
|
189
|
-
→ review edits and capture planId
|
|
121
|
+
If a server is missing, the agent can still use available workspace and structural evidence. Semantic features report that they are unavailable rather than silently guessing.
|
|
190
122
|
|
|
191
|
-
|
|
192
|
-
```
|
|
123
|
+
## Status and settings
|
|
193
124
|
|
|
194
|
-
|
|
125
|
+
Open the status view to see detected languages, running or missing servers, and capability warnings:
|
|
195
126
|
|
|
196
127
|
```text
|
|
197
|
-
|
|
198
|
-
extract_function: {
|
|
199
|
-
newName: "computeValue",
|
|
200
|
-
range: {
|
|
201
|
-
start: { line: 10, character: 3 },
|
|
202
|
-
end: { line: 12, character: 20 }
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Planning never writes files. Application is the sole mutator, acquires sorted per-file mutation queues, revalidates fingerprints and edit safety, and rolls back earlier writes if a later write fails.
|
|
209
|
-
|
|
210
|
-
## Graph evidence
|
|
211
|
-
|
|
212
|
-
`code_graph.relations` accepts only:
|
|
213
|
-
|
|
214
|
-
- `references` — semantic, symbol-identity evidence
|
|
215
|
-
- `callees` — structural outgoing calls as written in source
|
|
216
|
-
- `implements` — semantic implementation evidence
|
|
217
|
-
- `all` — exactly the three relations above and must be the only list item
|
|
218
|
-
|
|
219
|
-
`calleeDepth: "direct"` excludes nested function/method/callback scopes; `"deep"` includes them. Structural callees are not callers and are not symbol-identity relationships.
|
|
220
|
-
|
|
221
|
-
Imports and exports remain available as explicit AST search kinds in `code_find`; they are not graph relation families. Test identity is not inferred: use PI grep for literal/regex source search or AST `call` when appropriate, neither of which claims that a match is a test.
|
|
222
|
-
|
|
223
|
-
## Honest correctness
|
|
224
|
-
|
|
225
|
-
- Semantic, structural, and filesystem evidence retain their provenance.
|
|
226
|
-
- Required capability failures are explicit; tools do not silently switch substrates.
|
|
227
|
-
- `maxResults` is a display cap. Results disclose shown, total, and omitted evidence when known.
|
|
228
|
-
- AST results declare their Scan universe; interrupted enumeration or analysis never becomes a complete absence claim.
|
|
229
|
-
- Invalid semantic-provider locations are omitted from project/external facts and disclosed separately as partial evidence.
|
|
230
|
-
- `code_health` reports live observations and does not infer analyzer results from conventional report files.
|
|
231
|
-
- Zero matches are successful searches, not tool failures.
|
|
232
|
-
|
|
233
|
-
## Startup and settings
|
|
234
|
-
|
|
235
|
-
Detected language servers start concurrently. In polyglot workspaces, disable unneeded servers in `.pi/supi/config.json` or `~/.pi/agent/supi/config.json`:
|
|
236
|
-
|
|
237
|
-
```json
|
|
238
|
-
{
|
|
239
|
-
"lsp": {
|
|
240
|
-
"servers": {
|
|
241
|
-
"python": { "enabled": false },
|
|
242
|
-
"rust": { "enabled": false }
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
128
|
+
/supi-ci-status
|
|
246
129
|
```
|
|
247
130
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
## Architecture
|
|
251
|
-
|
|
252
|
-
- `supi-code-intelligence` owns the Workspace code-intelligence session, workflow policy, Tool result assembly, and public tool family.
|
|
253
|
-
- `supi-code-runtime` owns canonical provider contracts and workspace capability state.
|
|
254
|
-
- `supi-lsp` owns semantic lifecycle and the Workspace LSP runtime.
|
|
255
|
-
- `supi-tree-sitter` owns structural parser reuse.
|
|
256
|
-
- The process-shared Workspace provider host starts LSP and Tree-sitter once per canonical workspace and releases them after the final session lease. Target and refactor handles remain session-local.
|
|
257
|
-
- The Headless inspection profile is for managed child sessions and registers only the six non-mutating inspection tools; it omits refactors, settings, UI, commands, and overview injection.
|
|
258
|
-
|
|
259
|
-
Markdown and TUI are adapters over assembled typed results. Providers, clients, mutable targets, and the LSP manager do not cross the workflow seam.
|
|
260
|
-
|
|
261
|
-
See:
|
|
262
|
-
|
|
263
|
-
- [`docs/adr/0015-workspace-session-and-tool-result-assembly.md`](../../docs/adr/0015-workspace-session-and-tool-result-assembly.md)
|
|
264
|
-
- [`docs/adr/0016-workspace-lsp-runtime-interface.md`](../../docs/adr/0016-workspace-lsp-runtime-interface.md)
|
|
265
|
-
- [`docs/adr/0017-focused-code-tools-and-evidence-policy.md`](../../docs/adr/0017-focused-code-tools-and-evidence-policy.md)
|
|
266
|
-
- [`docs/adr/0002-refactor-planner-applier-split.md`](../../docs/adr/0002-refactor-planner-applier-split.md)
|
|
267
|
-
|
|
268
|
-
## Package exports
|
|
131
|
+
Use `/supi-settings` to disable language servers you do not need or change the instruction filenames surfaced during directory orientation. The defaults are `CLAUDE.md` and `AGENTS.md`.
|
|
269
132
|
|
|
270
|
-
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
133
|
+
[workspace-orientation]: https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-code-intelligence/assets/workspace-orientation.png
|
|
134
|
+
[symbol-inspection]: https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-code-intelligence/assets/symbol-inspection.png
|
|
135
|
+
[relationship-graph]: https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-code-intelligence/assets/relationship-graph.png
|
|
136
|
+
[code-health]: https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-code-intelligence/assets/code-health.png
|
|
137
|
+
[refactor-plan]: https://raw.githubusercontent.com/mrclrchtr/supi/main/packages/supi-code-intelligence/assets/refactor-plan.png
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "SuPi code-runtime — shared workspace context, capability contracts, and canonical types for the code-understanding stack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "SuPi code-runtime — shared workspace context, capability contracts, and canonical types for the code-understanding stack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "SuPi LSP runtime — Language Server Protocol integration library for pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"vscode-jsonrpc": "^9.0.0",
|
|
38
38
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
39
39
|
"vscode-languageserver-types": "^3.17.5",
|
|
40
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
41
|
-
"@mrclrchtr/supi-core": "4.
|
|
40
|
+
"@mrclrchtr/supi-code-runtime": "4.5.0",
|
|
41
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
42
42
|
},
|
|
43
43
|
"bundledDependencies": [
|
|
44
44
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -85,7 +85,7 @@ function sendDidChange(client: LspClient, uri: string, version: number, content:
|
|
|
85
85
|
/** Send an RPC notification through the client. */
|
|
86
86
|
function sendNotification(client: LspClient, method: string, params: unknown): void {
|
|
87
87
|
const rpc = accessClient(client).rpc;
|
|
88
|
-
if (rpc) rpc.sendNotification(method, params);
|
|
88
|
+
if (rpc) void rpc.sendNotification(method, params);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/** Clear open doc and diagnostic state for a URI. */
|
|
@@ -223,7 +223,7 @@ export class LspClient {
|
|
|
223
223
|
})) as InitializeResult;
|
|
224
224
|
|
|
225
225
|
this.capabilities = result.capabilities;
|
|
226
|
-
this.rpc.sendNotification("initialized", {});
|
|
226
|
+
void this.rpc.sendNotification("initialized", {});
|
|
227
227
|
this._status = "running";
|
|
228
228
|
|
|
229
229
|
this.armNoProgressTimer();
|
|
@@ -306,7 +306,7 @@ export class LspClient {
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
this.openDocs.set(uri, { version: 1, languageId });
|
|
309
|
-
this.rpc.sendNotification("textDocument/didOpen", {
|
|
309
|
+
void this.rpc.sendNotification("textDocument/didOpen", {
|
|
310
310
|
textDocument: {
|
|
311
311
|
uri,
|
|
312
312
|
languageId,
|
|
@@ -330,7 +330,7 @@ export class LspClient {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
doc.version++;
|
|
333
|
-
this.rpc.sendNotification("textDocument/didChange", {
|
|
333
|
+
void this.rpc.sendNotification("textDocument/didChange", {
|
|
334
334
|
textDocument: { uri, version: doc.version } satisfies VersionedTextDocumentIdentifier,
|
|
335
335
|
contentChanges: [{ text: content }],
|
|
336
336
|
});
|
|
@@ -345,7 +345,7 @@ export class LspClient {
|
|
|
345
345
|
|
|
346
346
|
if (!wasOpen || !this.rpc || this._status !== "running") return;
|
|
347
347
|
|
|
348
|
-
this.rpc.sendNotification("textDocument/didClose", {
|
|
348
|
+
void this.rpc.sendNotification("textDocument/didClose", {
|
|
349
349
|
textDocument: { uri } satisfies TextDocumentIdentifier,
|
|
350
350
|
});
|
|
351
351
|
}
|
|
@@ -364,7 +364,7 @@ export class LspClient {
|
|
|
364
364
|
removedFiles.push(filePath);
|
|
365
365
|
|
|
366
366
|
if (wasOpen && this.rpc && this._status === "running") {
|
|
367
|
-
this.rpc.sendNotification("textDocument/didClose", {
|
|
367
|
+
void this.rpc.sendNotification("textDocument/didClose", {
|
|
368
368
|
textDocument: { uri } satisfies TextDocumentIdentifier,
|
|
369
369
|
});
|
|
370
370
|
}
|
|
@@ -421,7 +421,7 @@ export class LspClient {
|
|
|
421
421
|
/** Notify the server that watched workspace files changed. */
|
|
422
422
|
notifyWorkspaceFileChanges(changes: FileEvent[]): void {
|
|
423
423
|
if (!this.rpc || this._status !== "running" || changes.length === 0) return;
|
|
424
|
-
this.rpc.sendNotification("workspace/didChangeWatchedFiles", {
|
|
424
|
+
void this.rpc.sendNotification("workspace/didChangeWatchedFiles", {
|
|
425
425
|
changes,
|
|
426
426
|
} satisfies DidChangeWatchedFilesParams);
|
|
427
427
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "SuPi code-runtime — shared workspace context, capability contracts, and canonical types for the code-understanding stack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "4.
|
|
32
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-tree-sitter",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "SuPi Tree-sitter library — structural AST analysis for pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"web-tree-sitter": "^0.26.8",
|
|
37
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
38
|
-
"@mrclrchtr/supi-core": "4.
|
|
37
|
+
"@mrclrchtr/supi-code-runtime": "4.5.0",
|
|
38
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
39
39
|
},
|
|
40
40
|
"bundledDependencies": [
|
|
41
41
|
"@mrclrchtr/supi-code-runtime",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-intelligence",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.5.0",
|
|
4
|
+
"description": "LSP and Tree-sitter AST code intelligence for the Pi coding agent — semantic navigation, structural search, diagnostics, and safe refactoring",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"impact-analysis",
|
|
27
27
|
"refactoring",
|
|
28
28
|
"lsp",
|
|
29
|
-
"tree-sitter"
|
|
29
|
+
"tree-sitter",
|
|
30
|
+
"ast"
|
|
30
31
|
],
|
|
31
32
|
"type": "module",
|
|
32
33
|
"files": [
|
|
@@ -34,10 +35,10 @@
|
|
|
34
35
|
],
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"yaml": "^2.9.0",
|
|
37
|
-
"@mrclrchtr/supi-code-runtime": "4.
|
|
38
|
-
"@mrclrchtr/supi-
|
|
39
|
-
"@mrclrchtr/supi-
|
|
40
|
-
"@mrclrchtr/supi-
|
|
38
|
+
"@mrclrchtr/supi-code-runtime": "4.5.0",
|
|
39
|
+
"@mrclrchtr/supi-lsp": "4.5.0",
|
|
40
|
+
"@mrclrchtr/supi-tree-sitter": "4.5.0",
|
|
41
|
+
"@mrclrchtr/supi-core": "4.5.0"
|
|
41
42
|
},
|
|
42
43
|
"bundledDependencies": [
|
|
43
44
|
"@mrclrchtr/supi-code-runtime",
|
package/src/extension.ts
CHANGED
|
@@ -5,6 +5,8 @@ import type { BeforeAgentStartEventResult, ExtensionAPI } from "@earendil-works/
|
|
|
5
5
|
import { buildArchitectureModel } from "./analysis/architecture/discovery.ts";
|
|
6
6
|
import { createCodeIntelligenceApp } from "./app/app.ts";
|
|
7
7
|
import { registerCodeIntelligenceSettings } from "./config.ts";
|
|
8
|
+
import { estimateTokens, OVERVIEW_TOKEN_BUDGET, renderOverview } from "./overview/overview.ts";
|
|
9
|
+
import { buildOverviewData } from "./overview/overview-data.ts";
|
|
8
10
|
import type { WorkspaceCodeIntelligenceSession } from "./session/session.ts";
|
|
9
11
|
import { registerLspSessionLifecycle } from "./substrate/lsp/lifecycle.ts";
|
|
10
12
|
import { registerWorkspaceRecoveryHandler } from "./substrate/lsp/recovery.ts";
|
|
@@ -12,8 +14,6 @@ import { registerLspSettings } from "./substrate/lsp/settings.ts";
|
|
|
12
14
|
import { createLspAdapterState } from "./substrate/lsp/state.ts";
|
|
13
15
|
import { registerCodeIntelligenceTools } from "./tool/register.ts";
|
|
14
16
|
import { registerLspFooterContribution } from "./ui/footer.ts";
|
|
15
|
-
import { estimateTokens, OVERVIEW_TOKEN_BUDGET, renderOverview } from "./ui/markdown/overview.ts";
|
|
16
|
-
import { buildOverviewData } from "./ui/markdown/overview-data.ts";
|
|
17
17
|
import { registerCiStatusCommand } from "./ui/status-command.ts";
|
|
18
18
|
|
|
19
19
|
const OVERVIEW_CUSTOM_TYPE = "code-intelligence-overview";
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
ArchitectureModel,
|
|
8
8
|
ManifestField,
|
|
9
9
|
ModuleInfo,
|
|
10
|
-
} from "
|
|
10
|
+
} from "../analysis/architecture/model.ts";
|
|
11
11
|
import type { OverviewData, OverviewModule } from "./types.ts";
|
|
12
12
|
|
|
13
13
|
/** Grammar ID to short language tag for the overview. */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Use-case data for the workspace architecture overview. */
|
|
2
|
+
|
|
3
|
+
/** One discovered workspace package and its manifest-declared surface. */
|
|
4
|
+
export interface OverviewModule {
|
|
5
|
+
name: string;
|
|
6
|
+
shortName: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
/** Manifest-declared package relationships to other discovered packages. */
|
|
9
|
+
declaredDependencies: string[];
|
|
10
|
+
/** Field-labelled manifest path declarations, never selected by precedence. */
|
|
11
|
+
declaredEntrypoints: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Project-level overview data rendered by the overview markdown adapter. */
|
|
15
|
+
export interface OverviewData {
|
|
16
|
+
projectName: string | null;
|
|
17
|
+
projectDescription: string | null;
|
|
18
|
+
modules: OverviewModule[];
|
|
19
|
+
/** Detected source languages (e.g. ["ts", "js", "py"]). */
|
|
20
|
+
detectedLanguages: string[] | null;
|
|
21
|
+
}
|
|
@@ -15,19 +15,17 @@ import {
|
|
|
15
15
|
readNextTarget,
|
|
16
16
|
} from "../../analysis/read-next.ts";
|
|
17
17
|
import { diagnosticMessageString } from "../../substrate/lsp/utils.ts";
|
|
18
|
-
import { gatherTreeSitterContext } from "../../ui/markdown/gather.ts";
|
|
19
18
|
import type {
|
|
20
19
|
OrientationDeps,
|
|
21
20
|
OrientationInput,
|
|
22
|
-
OrientationSection,
|
|
23
|
-
OrientationTarget,
|
|
24
|
-
} from "../../ui/markdown/types.ts";
|
|
25
|
-
import type {
|
|
26
21
|
OrientationItem,
|
|
27
22
|
OrientationResultData,
|
|
23
|
+
OrientationSection,
|
|
28
24
|
OrientationSectionData,
|
|
29
25
|
} from "../orientation-types.ts";
|
|
26
|
+
import type { TargetStoreEntry } from "../target-store.ts";
|
|
30
27
|
import { collectContextOrientationFacts } from "./context-facts.ts";
|
|
28
|
+
import { gatherSubstrateContext } from "./gather.ts";
|
|
31
29
|
|
|
32
30
|
interface TargetSectionCollection {
|
|
33
31
|
readonly items: OrientationItem[];
|
|
@@ -126,7 +124,7 @@ async function executeTargetOrientation(
|
|
|
126
124
|
|
|
127
125
|
async function buildRequestedSection(options: {
|
|
128
126
|
section: OrientationSection;
|
|
129
|
-
target:
|
|
127
|
+
target: Readonly<TargetStoreEntry> | null | undefined;
|
|
130
128
|
deps: OrientationDeps;
|
|
131
129
|
limit: number;
|
|
132
130
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>;
|
|
@@ -159,7 +157,7 @@ async function buildRequestedSection(options: {
|
|
|
159
157
|
|
|
160
158
|
/** Build enriched defs section: tree-sitter definitions + LSP definition targets. */
|
|
161
159
|
async function buildEnrichedDefsSection(
|
|
162
|
-
target:
|
|
160
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
163
161
|
deps: OrientationDeps,
|
|
164
162
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
165
163
|
limit: number,
|
|
@@ -206,7 +204,7 @@ async function buildEnrichedDefsSection(
|
|
|
206
204
|
}
|
|
207
205
|
|
|
208
206
|
async function collectDefinitionTargets(
|
|
209
|
-
target:
|
|
207
|
+
target: Readonly<TargetStoreEntry>,
|
|
210
208
|
deps: OrientationDeps,
|
|
211
209
|
limit: number,
|
|
212
210
|
): Promise<
|
|
@@ -226,8 +224,8 @@ async function collectDefinitionTargets(
|
|
|
226
224
|
}
|
|
227
225
|
try {
|
|
228
226
|
const result = await deps.provider.definition(target.file, {
|
|
229
|
-
line: target.
|
|
230
|
-
character: target.
|
|
227
|
+
line: target.displayLine - 1,
|
|
228
|
+
character: target.displayCharacter - 1,
|
|
231
229
|
});
|
|
232
230
|
if (result.kind === "unavailable") {
|
|
233
231
|
return {
|
|
@@ -275,7 +273,7 @@ async function collectDefinitionTargets(
|
|
|
275
273
|
}
|
|
276
274
|
|
|
277
275
|
async function buildDiagnosticsSection(
|
|
278
|
-
target:
|
|
276
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
279
277
|
deps: OrientationDeps,
|
|
280
278
|
limit: number,
|
|
281
279
|
): Promise<TargetSectionCollection> {
|
|
@@ -306,7 +304,7 @@ async function buildDiagnosticsSection(
|
|
|
306
304
|
);
|
|
307
305
|
}
|
|
308
306
|
const nearby = result.data.filter(
|
|
309
|
-
(diagnostic) => Math.abs((diagnostic.range.start.line ?? 0) + 1 - target.
|
|
307
|
+
(diagnostic) => Math.abs((diagnostic.range.start.line ?? 0) + 1 - target.displayLine) <= 5,
|
|
310
308
|
);
|
|
311
309
|
const evidence =
|
|
312
310
|
result.kind === "partial"
|
|
@@ -380,7 +378,7 @@ function unavailableTargetSection(
|
|
|
380
378
|
|
|
381
379
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: JSDoc parsing naturally has state-machine complexity
|
|
382
380
|
async function buildDocsSection(
|
|
383
|
-
target:
|
|
381
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
384
382
|
deps: OrientationDeps,
|
|
385
383
|
limit: number,
|
|
386
384
|
): Promise<TargetSectionCollection> {
|
|
@@ -404,7 +402,7 @@ async function buildDocsSection(
|
|
|
404
402
|
try {
|
|
405
403
|
const content = readFileSync(targetFile, "utf-8");
|
|
406
404
|
const lines = content.split("\n");
|
|
407
|
-
const startIdx = Math.max(0, target.
|
|
405
|
+
const startIdx = Math.max(0, target.displayLine - 2);
|
|
408
406
|
let jsdocStart = -1;
|
|
409
407
|
let jsdocEnd = -1;
|
|
410
408
|
|
|
@@ -483,16 +481,22 @@ async function buildDocsSection(
|
|
|
483
481
|
}
|
|
484
482
|
|
|
485
483
|
async function maybeGatherTreeContext(
|
|
486
|
-
target:
|
|
484
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
487
485
|
deps: OrientationDeps,
|
|
488
486
|
) {
|
|
489
487
|
if (!target) return null;
|
|
490
488
|
const relPath = path.relative(deps.cwd, target.file);
|
|
491
|
-
return
|
|
489
|
+
return gatherSubstrateContext(
|
|
490
|
+
deps.provider,
|
|
491
|
+
relPath,
|
|
492
|
+
target.displayLine,
|
|
493
|
+
target.displayCharacter,
|
|
494
|
+
target.anchorKind !== "declaration",
|
|
495
|
+
);
|
|
492
496
|
}
|
|
493
497
|
|
|
494
498
|
function buildDefinitionItems(
|
|
495
|
-
target:
|
|
499
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
496
500
|
cwd: string,
|
|
497
501
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
498
502
|
): OrientationItem[] {
|
|
@@ -507,6 +511,12 @@ function buildDefinitionItems(
|
|
|
507
511
|
text: `Symbol: \`${target.name}\`${target.kind ? ` (${target.kind})` : ""}`,
|
|
508
512
|
});
|
|
509
513
|
}
|
|
514
|
+
if (target.anchorKind === "declaration") {
|
|
515
|
+
items.push({
|
|
516
|
+
kind: "paragraph",
|
|
517
|
+
text: "Node and hover evidence withheld: this target has a declaration anchor, and position-strict substrates require a name anchor (ADR 0003).",
|
|
518
|
+
});
|
|
519
|
+
}
|
|
510
520
|
if (treeContext?.nodeInfo?.type) {
|
|
511
521
|
items.push({ kind: "list-item", text: `Node: \`${treeContext.nodeInfo.type}\`` });
|
|
512
522
|
}
|
|
@@ -593,22 +603,25 @@ function hoverBodyItems(lines: readonly string[]): OrientationItem[] {
|
|
|
593
603
|
return items;
|
|
594
604
|
}
|
|
595
605
|
|
|
596
|
-
function formatFocusTarget(target:
|
|
606
|
+
function formatFocusTarget(target: Readonly<TargetStoreEntry>, cwd: string): string {
|
|
597
607
|
const relPath = path.relative(cwd, target.file) || target.file;
|
|
598
|
-
return `${relPath}:${target.
|
|
608
|
+
return `${relPath}:${target.displayLine}:${target.displayCharacter}`;
|
|
599
609
|
}
|
|
600
610
|
|
|
601
|
-
function buildNextQueries(
|
|
611
|
+
function buildNextQueries(
|
|
612
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
613
|
+
cwd: string,
|
|
614
|
+
): string[] {
|
|
602
615
|
if (!target) return ["Use `code_orientation` for a neutral orientation summary."];
|
|
603
616
|
|
|
604
617
|
const relPath = path.relative(cwd, target.file) || target.file;
|
|
605
618
|
return [
|
|
606
|
-
`\`code_graph\` with \`target: { anchor: { file: "${relPath}", line: ${target.
|
|
619
|
+
`\`code_graph\` with \`target: { anchor: { file: "${relPath}", line: ${target.displayLine}, character: ${target.displayCharacter} } }\` for relation follow-up`,
|
|
607
620
|
];
|
|
608
621
|
}
|
|
609
622
|
|
|
610
623
|
function buildReadNextGuidance(
|
|
611
|
-
target:
|
|
624
|
+
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
612
625
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
613
626
|
cwd: string,
|
|
614
627
|
): ReadNextItem[] {
|
|
@@ -616,18 +629,18 @@ function buildReadNextGuidance(
|
|
|
616
629
|
const relPath = path.relative(cwd, target.file) || target.file;
|
|
617
630
|
const enclosing = findEnclosingOutlineItem(target, treeContext);
|
|
618
631
|
if (enclosing) {
|
|
619
|
-
return [readNextEnclosingScope(relPath, enclosing, target.
|
|
632
|
+
return [readNextEnclosingScope(relPath, enclosing, target.displayLine)];
|
|
620
633
|
}
|
|
621
|
-
return [readNextTarget(relPath, target.
|
|
634
|
+
return [readNextTarget(relPath, target.displayLine, "inspect the target implementation")];
|
|
622
635
|
}
|
|
623
636
|
|
|
624
637
|
function findEnclosingOutlineItem(
|
|
625
|
-
target:
|
|
638
|
+
target: Readonly<TargetStoreEntry>,
|
|
626
639
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
627
640
|
): { name: string; kind: string; startLine: number; endLine: number } | null {
|
|
628
641
|
if (!treeContext || treeContext.outline.length === 0) return null;
|
|
629
642
|
const candidates = treeContext.outline.filter(
|
|
630
|
-
(item) => item.startLine <= target.
|
|
643
|
+
(item) => item.startLine <= target.displayLine && item.endLine >= target.displayLine,
|
|
631
644
|
);
|
|
632
645
|
if (candidates.length === 0) return null;
|
|
633
646
|
const matchingName = candidates.find((item) => target.name && item.name === target.name);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Substrate context gathering for symbol
|
|
2
|
+
* Substrate context gathering for symbol-centered Orientation.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Best-effort tree-sitter node/outline/imports/exports context plus LSP
|
|
5
|
+
* hover/definition at one target position. Consumed by the Orientation
|
|
6
|
+
* evidence collector in `collect.ts`.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import type {
|
|
@@ -11,13 +12,18 @@ import type {
|
|
|
11
12
|
StructuralProvider,
|
|
12
13
|
} from "@mrclrchtr/supi-code-runtime/api";
|
|
13
14
|
|
|
15
|
+
/** Structural provider subset plus optional semantic hover/definition used for gathering. */
|
|
14
16
|
export type ContextGatherProvider = Pick<
|
|
15
17
|
StructuralProvider,
|
|
16
18
|
"nodeAt" | "outline" | "imports" | "exports"
|
|
17
19
|
> &
|
|
18
20
|
Partial<Pick<SemanticProvider, "hover" | "definition">>;
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Best-effort substrate evidence at one target position. `null` fields mean
|
|
24
|
+
* the evidence was unavailable, not that the position is invalid.
|
|
25
|
+
*/
|
|
26
|
+
export interface SubstrateContext {
|
|
21
27
|
nodeInfo: {
|
|
22
28
|
type: string;
|
|
23
29
|
text: string;
|
|
@@ -40,32 +46,46 @@ export interface TreeSitterContext {
|
|
|
40
46
|
definition: Array<{ uri: string; range: SourceRange }> | null;
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Gather best-effort substrate context at one target position.
|
|
51
|
+
*
|
|
52
|
+
* `line`/`character` are 1-based display coordinates; LSP hover/definition
|
|
53
|
+
* queries convert to 0-based internally. Position-strict operations
|
|
54
|
+
* (tree-sitter `nodeAt`, hover-at) run only when `positionStrict` is true —
|
|
55
|
+
* callers holding a declaration-anchor target must pass false (ADR 0003).
|
|
56
|
+
* File-level evidence (outline, imports, exports) and position-tolerant
|
|
57
|
+
* definition lookups run regardless. Failures degrade to `null`/empty.
|
|
58
|
+
*/
|
|
43
59
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: best-effort substrate gathering with independent try/catch blocks kept together for readability
|
|
44
|
-
|
|
60
|
+
// biome-ignore lint/complexity/useMaxParams: one internal gather call site carries the full position context
|
|
61
|
+
export async function gatherSubstrateContext(
|
|
45
62
|
provider: ContextGatherProvider | null,
|
|
46
63
|
relPath: string,
|
|
47
64
|
line: number,
|
|
48
65
|
character: number,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
let
|
|
53
|
-
let
|
|
54
|
-
let
|
|
55
|
-
let
|
|
66
|
+
positionStrict: boolean,
|
|
67
|
+
): Promise<SubstrateContext> {
|
|
68
|
+
let nodeInfo: SubstrateContext["nodeInfo"] = null;
|
|
69
|
+
let outline: SubstrateContext["outline"] = [];
|
|
70
|
+
let imports: SubstrateContext["imports"] = [];
|
|
71
|
+
let exports: SubstrateContext["exports"] = [];
|
|
72
|
+
let hover: SubstrateContext["hover"] = null;
|
|
73
|
+
let definition: SubstrateContext["definition"] = null;
|
|
56
74
|
|
|
57
75
|
if (!provider) return { nodeInfo, outline, imports, exports, hover, definition: null };
|
|
58
76
|
|
|
59
77
|
try {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
if (positionStrict) {
|
|
79
|
+
const nodeResult = await provider.nodeAt(relPath, line, character);
|
|
80
|
+
if (nodeResult.kind === "success") {
|
|
81
|
+
nodeInfo = {
|
|
82
|
+
type: nodeResult.data.type,
|
|
83
|
+
text: nodeResult.data.text,
|
|
84
|
+
startLine: nodeResult.data.startLine,
|
|
85
|
+
startCharacter: nodeResult.data.startCharacter,
|
|
86
|
+
ancestry: nodeResult.data.ancestry ?? [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
90
|
|
|
71
91
|
const outlineResult = await provider.outline(relPath);
|
|
@@ -91,8 +111,8 @@ export async function gatherTreeSitterContext(
|
|
|
91
111
|
}));
|
|
92
112
|
}
|
|
93
113
|
|
|
94
|
-
// Best-effort hover — LSP expects 0-based coordinates
|
|
95
|
-
if (provider.hover) {
|
|
114
|
+
// Best-effort hover — LSP expects 0-based coordinates; hover-at is position-strict.
|
|
115
|
+
if (positionStrict && provider.hover) {
|
|
96
116
|
try {
|
|
97
117
|
const hoverResult = await provider.hover(relPath, {
|
|
98
118
|
line: line - 1,
|
|
@@ -104,7 +124,7 @@ export async function gatherTreeSitterContext(
|
|
|
104
124
|
}
|
|
105
125
|
}
|
|
106
126
|
|
|
107
|
-
// Best-effort definition — LSP expects 0-based coordinates
|
|
127
|
+
// Best-effort definition — LSP expects 0-based coordinates; definitions are position-tolerant.
|
|
108
128
|
if (provider.definition) {
|
|
109
129
|
try {
|
|
110
130
|
const defResult = await provider.definition(relPath, {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
|
|
3
|
+
import type { ArchitectureModel } from "../analysis/architecture/model.ts";
|
|
2
4
|
import type { EvidenceListMetadata } from "../analysis/evidence.ts";
|
|
3
5
|
import type { InstructionFilesMetadata } from "../analysis/instruction-files.ts";
|
|
6
|
+
import type { CodeProvider } from "../analysis/provider.ts";
|
|
4
7
|
import type { ReadNextItem } from "../analysis/read-next.ts";
|
|
5
8
|
import type { OrientationTargetInput, TargetSymbolKind } from "./target-input.ts";
|
|
6
9
|
import type { AnchorKind, TargetStoreEntry } from "./target-store.ts";
|
|
@@ -16,6 +19,26 @@ export interface OrientationWorkflowInput {
|
|
|
16
19
|
readonly maxResults?: number;
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
/** Section keys the Orientation evidence collector gathers for a precise target. */
|
|
23
|
+
export type OrientationSection = "defs" | "docs" | "diagnostics";
|
|
24
|
+
|
|
25
|
+
/** Input to the Orientation evidence collector. */
|
|
26
|
+
export interface OrientationInput {
|
|
27
|
+
/** Resolved target entry, consumed read-only; absent for context orientation. */
|
|
28
|
+
target?: Readonly<TargetStoreEntry> | null;
|
|
29
|
+
/** Resolved orientation focus path for project/module/directory/file orientation. */
|
|
30
|
+
focus?: string;
|
|
31
|
+
maxResults?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Capabilities the Orientation evidence collector requires. */
|
|
35
|
+
export interface OrientationDeps {
|
|
36
|
+
readonly model: ArchitectureModel;
|
|
37
|
+
readonly provider: CodeProvider | null;
|
|
38
|
+
readonly cwd: string;
|
|
39
|
+
readonly lspRuntime: WorkspaceLspRuntimeState;
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
/**
|
|
20
43
|
* Presentation-neutral content atom a collector emits for one Orientation
|
|
21
44
|
* section. Collectors never build headings, section notes, or document
|
|
@@ -148,17 +148,7 @@ async function orientTarget(options: {
|
|
|
148
148
|
reason: readiness.kind === "timeout" ? "Semantic readiness timed out" : readiness.reason,
|
|
149
149
|
};
|
|
150
150
|
const result = await executeOrientation(
|
|
151
|
-
{
|
|
152
|
-
target: {
|
|
153
|
-
file: entry.file,
|
|
154
|
-
line: entry.displayLine,
|
|
155
|
-
character: entry.displayCharacter,
|
|
156
|
-
name: entry.name,
|
|
157
|
-
kind: entry.kind,
|
|
158
|
-
anchorKind: entry.anchorKind,
|
|
159
|
-
},
|
|
160
|
-
maxResults,
|
|
161
|
-
},
|
|
151
|
+
{ target: entry, maxResults },
|
|
162
152
|
{
|
|
163
153
|
model,
|
|
164
154
|
provider,
|
package/src/types/execution.ts
CHANGED
package/src/types/index.ts
CHANGED
package/src/types/details.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility export for tool-result detail shapes.
|
|
3
|
-
*
|
|
4
|
-
* Public code-intelligence details are assembled in `src/tool/result/`.
|
|
5
|
-
* Import new result assembly code from `../tool/result/types.ts` directly.
|
|
6
|
-
*/
|
|
7
|
-
export type {
|
|
8
|
-
AnchoredResolutionMetadata,
|
|
9
|
-
AnchoredResolutionSource,
|
|
10
|
-
ContextDetails,
|
|
11
|
-
DisambiguationCandidate,
|
|
12
|
-
HealthDetails,
|
|
13
|
-
HealthSectionDetails,
|
|
14
|
-
InspectDetails,
|
|
15
|
-
OrientationSectionDetails,
|
|
16
|
-
ResolveDetails,
|
|
17
|
-
SearchDetails,
|
|
18
|
-
} from "../tool/result/types.ts";
|
package/src/ui/markdown/types.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Shared typed data interfaces between use-case and presentation layers.
|
|
2
|
-
|
|
3
|
-
import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
|
|
4
|
-
import type { ArchitectureModel } from "../../analysis/architecture/model.ts";
|
|
5
|
-
import type { CodeProvider } from "../../analysis/provider.ts";
|
|
6
|
-
import type { AnchorKind } from "../../session/target-store.ts";
|
|
7
|
-
import type { InspectDetails } from "../../types/details.ts";
|
|
8
|
-
|
|
9
|
-
// ── Overview use-case ───────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export interface OverviewModule {
|
|
12
|
-
name: string;
|
|
13
|
-
shortName: string;
|
|
14
|
-
description: string | null;
|
|
15
|
-
/** Manifest-declared package relationships to other discovered packages. */
|
|
16
|
-
declaredDependencies: string[];
|
|
17
|
-
/** Field-labelled manifest path declarations, never selected by precedence. */
|
|
18
|
-
declaredEntrypoints: string[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface OverviewData {
|
|
22
|
-
projectName: string | null;
|
|
23
|
-
projectDescription: string | null;
|
|
24
|
-
modules: OverviewModule[];
|
|
25
|
-
/** Detected source languages (e.g. ["ts", "js", "py"]). */
|
|
26
|
-
detectedLanguages: string[] | null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ── Inspect use-case ─────────────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
export interface InspectInput {
|
|
32
|
-
file: string;
|
|
33
|
-
line: number;
|
|
34
|
-
character: number;
|
|
35
|
-
maxResults?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface InspectDeps {
|
|
39
|
-
provider: CodeProvider | null;
|
|
40
|
-
cwd: string;
|
|
41
|
-
lspRuntime: WorkspaceLspRuntimeState;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface InspectUseCaseResult {
|
|
45
|
-
content: string;
|
|
46
|
-
details: InspectDetails;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// ── Orientation use-case ─────────────────────────────────────────────────
|
|
50
|
-
|
|
51
|
-
export type OrientationSection = "defs" | "docs" | "diagnostics";
|
|
52
|
-
|
|
53
|
-
export interface OrientationTarget {
|
|
54
|
-
file: string;
|
|
55
|
-
line: number;
|
|
56
|
-
character: number;
|
|
57
|
-
name: string | null;
|
|
58
|
-
kind: string | null;
|
|
59
|
-
/** Which anchor this target carries; strict consumers refuse declaration anchors. */
|
|
60
|
-
anchorKind: AnchorKind;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface OrientationInput {
|
|
64
|
-
target?: OrientationTarget | null;
|
|
65
|
-
/** Resolved orientation focus path for project/module/directory/file orientation. */
|
|
66
|
-
focus?: string;
|
|
67
|
-
maxResults?: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface OrientationDeps {
|
|
71
|
-
model: ArchitectureModel;
|
|
72
|
-
provider: CodeProvider | null;
|
|
73
|
-
cwd: string;
|
|
74
|
-
lspRuntime: WorkspaceLspRuntimeState;
|
|
75
|
-
}
|
|
File without changes
|