@mrclrchtr/supi-code-intelligence 1.1.2 → 1.1.3

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 CHANGED
@@ -1,223 +1,56 @@
1
1
  # @mrclrchtr/supi-code-intelligence
2
2
 
3
- SuPi Code Intelligence extensionthe main agent-facing code understanding tool for [pi](https://github.com/earendil-works/pi).
3
+ Project understanding for PIyour agent knows your codebase before you ask.
4
4
 
5
- Registers the `code_intel` tool with seven high-level actions and injects structural project context into the agent's first turn.
5
+ The first thing an agent does in a new project is read files to figure out what's there. Code Intelligence skips that — it auto-injects a compact project map on turn one, so the agent is already oriented.
6
6
 
7
- ## Injection Points
7
+ Beyond the overview, it gives the agent high-level analysis: architecture briefs, impact assessment, call tracing, and smart search that knows when to use LSP vs. tree-sitter vs. text search.
8
8
 
9
- The extension hooks into pi's lifecycle at six points:
9
+ ## What you get
10
10
 
11
- | # | Injection Point | What It Does |
12
- |---|---|---|
13
- | 1 | `package.json` → `pi.extensions` | Manifest entry that tells pi to load the extension at startup |
14
- | 2 | `pi.registerTool({ name: "code_intel", ... })` | Makes the `code_intel` tool callable from agent turns |
15
- | 3 | `promptGuidelines` (7 guidelines) | Flattened into the system prompt's `Guidelines:` section — teaches the agent *when* to use each action |
16
- | 4 | `promptSnippet` (1 line) | Injected near the tool definition in context — short reminder to use `code_intel` over broad file reads |
17
- | 5 | `pi.on("session_start", ...)` | Resets injection dedup state and scans the active branch to avoid re-injecting on reload/resume |
18
- | 6 | `pi.on("before_agent_start", ...)` | On the first agent turn, builds an architecture model and injects a compact Markdown overview as a custom message (`customType: "code-intelligence-overview"`, `display: false`) — the agent sees it in conversation context without UI clutter |
11
+ ### Instant orientation
19
12
 
20
- ### First-Turn Overview Flow
13
+ Every session starts with a project map in the agent's context: what packages exist, how they depend on each other, which files matter. The agent walks in knowing your codebase instead of discovering it file by file.
21
14
 
22
- 1. `session_start` fires → resets `hasInjectedOverview`, scans branch for existing `code-intelligence-overview` custom message
23
- 2. First `before_agent_start` fires → calls `buildArchitectureModel(ctx.cwd)` to parse the project
24
- 3. If modules are found, `generateOverview(model)` produces a dense Markdown summary (~500 tokens, max 8 modules) with git context when available
25
- 4. Returns a `BeforeAgentStartEventResult` with a `customMessage`; pi places it in the agent's context
26
- 5. Subsequent turns skip injection entirely
15
+ ### Architecture-level questions
27
16
 
28
- ## Tool Actions
17
+ Ask "what's in this package?" or "what depends on this module?" The agent gets a structural answer, not a file listing.
29
18
 
30
- ### `brief` — Architecture overviews and focused briefs
19
+ ### Impact analysis
31
20
 
32
- Scopes: project (no params), package/directory (`path`), file (`file`), or anchored symbol (`file`, `line`, and `character`).
21
+ Before a change: "show me everything that would break." The agent sees direct callers, downstream dependents, and risk level before touching code.
33
22
 
34
- - Project-level brief: module listing, dependency graph, "start here" recommendations, suggested next queries
35
- - Focused brief (`path` or anchored symbol): stripped-down version with a single module or symbol focus
36
- - Non-module directory briefs now recurse into descendant structure, summarize nested source files, and include lightweight public-surface / import-export summaries for JS/TS trees
37
- - Now includes git context (branch, dirty files, last commit) when inside a git repository
38
- - Can surface optional priority signals such as diagnostics, low coverage, and unused-code hints when available
39
- - Metadata returned: `BriefDetails` with confidence, focus target, public surfaces, dependency summary
23
+ ### Smarter search
40
24
 
41
- ### `callers` Find call sites for a symbol
25
+ `code_intel pattern` is text search that knows about code structure. Search for definitions (not just any text match), group by directory, or filter by import/export. Falls back from LSP to tree-sitter to ripgrep automatically.
42
26
 
43
- - LSP-first (references query), falls back to heuristic text search (word-boundary ripgrep)
44
- - File-only requests now expand across discovered exported targets when possible, so you can ask for callers of a module surface without coordinates
45
- - Results grouped by file with ranked, contextual call sites
46
- - Confidence labeling: `semantic` (LSP), `heuristic` (text search)
47
-
48
- ### `callees` — Structural outgoing call map
49
-
50
- - Structural tree-sitter analysis for all grammars configured in `supi-tree-sitter`
51
- - Finds outgoing function/method calls from an anchored position
52
- - Supports JavaScript/TypeScript, Python, Rust, Go, C/C++, Java, Kotlin, Ruby, Bash, and R
53
-
54
- ### `implementations` — Find concrete implementations
55
-
56
- - Resolves interface/abstract method implementations via LSP
57
- - Falls back to heuristic text search for `implements`/`extends` patterns
58
-
59
- ### `affected` — Blast-radius analysis
60
-
61
- Before changing exported APIs, shared helpers, config surfaces, or cross-package contracts:
62
- - Direct references (callers/importers)
63
- - Downstream dependents (transitive)
64
- - Risk level: `low` | `medium` | `high`
65
- - Likely test files
66
- - File-only requests now expand across discovered exported targets when possible
67
- - Optional priority signals highlight diagnostics, low coverage, and unused-code hints when available
68
- - Returns `AffectedDetails` metadata
69
-
70
- ### `index` — Factual project map
71
-
72
- A non-interpretive project overview for quick orientation:
73
-
74
- - File counts by language/extension
75
- - Top-level directory tree with file counts
76
- - Landmark config files detected (package.json, tsconfig.json, Makefile, etc.)
77
- - Skips low-signal directories (`node_modules`, `dist`, `build`, `.git`)
78
-
79
- Use when you need to understand "what's here?" before diving into specific files.
80
-
81
- ```json
82
- { "action": "index" }
83
- ```
84
-
85
- ### `pattern` — Bounded, scope-aware text search
86
-
87
- Optimized for common agent lookups:
88
-
89
- - `pattern` is treated as a **literal string by default**
90
- - Set `regex: true` to opt into raw ripgrep regex semantics
91
- - Structured JS/TS searches support `kind: "definition" | "export" | "import"` to avoid regex look-around hacks when you care about declarations instead of raw text lines
92
- - Definition/export searches include duplicate-definition summaries when the same symbol appears in multiple files
93
- - Structured scans are capped and may return a partial-result warning when the scope is too large or times out; narrow `path` or `pattern` for complete coverage
94
- - Malformed regex input returns an explicit error instead of a misleading "No matches found"
95
- - Nearby matches in the same file deduplicate overlapping context lines to reduce token waste
96
- - Results grouped with file and context lines
97
- - `summary: true` returns aggregate counts by directory instead of line-level matches (useful for "how common is this pattern?")
98
-
99
- Examples:
27
+ ## Install
100
28
 
101
- ```json
102
- { "action": "pattern", "pattern": "sendMessage({", "path": "packages/" }
103
- { "action": "pattern", "pattern": "register(Settings|Config)", "path": "packages/", "regex": true }
104
- { "action": "pattern", "pattern": "payment", "kind": "definition", "path": "src/" }
105
- { "action": "pattern", "pattern": "createServerFn", "summary": true }
29
+ ```bash
30
+ pi install npm:@mrclrchtr/supi-code-intelligence
106
31
  ```
107
32
 
108
- ## Language & File Type Support
109
-
110
- | Feature / Language | JS/TS | Python | Rust | Go | Java/Kotlin | Ruby | PHP | Swift | C/C++ | Other text |
111
- |---|---|---|---|---|---|---|---|---|---|---|
112
- | **`index`** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
113
- | **`brief` (project)** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅¹ |
114
- | **`brief` (directory/file)** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
115
- | **`callers`** | ✅ | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ⚠️³ |
116
- | **`callees`** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ❌ |
117
- | **`implementations`** | ✅ | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ⚠️³ |
118
- | **`affected`** | ✅ | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ✅² | ⚠️³ |
119
- | **`pattern`** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅⁴ |
120
-
121
- **Legend:**
122
- - **✅** Fully supported for that action.
123
- - **⚠️** Partial or best-effort support (see footnotes).
124
- - **❌** Not supported for that action.
125
- - **¹** Project-level brief works for any project with a recognized manifest (`package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, etc.).
126
- - **²** Requires an active LSP server for semantic resolution; falls back to heuristic text search otherwise.
127
- - **³** Heuristic text-search fallback only; no semantic or structural resolution.
128
- - **⁴** `pattern` works on any text file. Binary files (`.png`, `.jpg`, `.zip`, `.pdf`, etc.) are explicitly rejected.
129
-
130
- ## Confidence Labeling
131
-
132
- Every result carries a `confidence` label from the result metadata:
133
-
134
- | Label | Meaning |
135
- |---|---|
136
- | `semantic` | Truth from LSP (definitions, references, diagnostics) |
137
- | `structural` | From tree-sitter AST (outlines, imports/exports, syntax) |
138
- | `heuristic` | Text search / best-effort inference |
139
- | `unavailable` | No data could be produced |
140
-
141
- ## Result Metadata
33
+ ## Quick look
142
34
 
143
- **Contract:** `details` is returned for every action handler execution. It is
144
- `undefined` *only* when the request is rejected before any handler runs
145
- (parameter validation errors, unknown action, missing required `pattern`).
35
+ | Action | What the agent can ask |
36
+ |--------|----------------------|
37
+ | `brief` | "Summarize this package / file / project" |
38
+ | `callers` | "Who calls this function?" |
39
+ | `callees` | "What does this function call?" |
40
+ | `affected` | "What breaks if I change this?" |
41
+ | `pattern` | "Find this text / pattern" |
42
+ | `index` | "What's in this project?" |
43
+ | `implementations` | "What implements this interface?" |
146
44
 
147
- For no-result and error states, `details` carries `confidence: "unavailable"` or
148
- `confidence: "heuristic"` with appropriately zeroed counts, so consumers always
149
- get structured metadata back.
45
+ Every result includes a confidence label (semantic / structural / heuristic) so the agent knows how much to trust the answer.
150
46
 
151
- - **`brief`** `BriefDetails` (confidence, focus target, start-here suggestions, public surfaces, dependency summary, omitted count, next queries, optional priority signals)
152
- - **`search`** → `SearchDetails` (callers/callees/implementations/pattern: confidence, scope, candidate count, omitted count)
153
- - **`affected`** → `AffectedDetails` (direct count, downstream count, risk level, likely tests, check-next list, optional priority signals)
47
+ ## For extension developers
154
48
 
155
- ## Parameter Validation
156
-
157
- The tool enforces these rules and returns explicit error messages:
158
-
159
- - `line`/`character` require `file`, not `path` — `path` is for scope/focus, `file` anchors a position
160
- - `file` that points to a directory is rejected — use `path` for directory scoping
161
- - `pattern.kind` must be one of `definition`, `export`, or `import`
162
- - Unknown actions are rejected with a list of supported actions
163
-
164
- ## Architecture
165
-
166
- Each action employs an appropriate fallback chain from the available services:
167
-
168
- - **`@mrclrchtr/supi-lsp`** — Semantic truth via LSP (references, symbols, implementations, diagnostics)
169
- - **`@mrclrchtr/supi-tree-sitter`** — Structural extraction (outlines, imports/exports, callees, syntax context)
170
- - **`@mrclrchtr/supi-core`** — Project/root utilities (root walking, known-root mapping, path containment)
171
-
172
- **Per-action fallback chains:** `callers`, `implementations`, and `affected` use LSP → ripgrep text search; `callees` uses tree-sitter AST analysis; `brief` uses the architecture model (plus tree-sitter outline for anchored briefs); `pattern` and `index` use filesystem and text-search primitives.
173
-
174
- ### Programmatic API
175
-
176
- The package exports its internal APIs for use by peer extensions:
49
+ The architecture model and brief generator are exported for reuse:
177
50
 
178
51
  ```ts
179
- // Architecture model
180
- export type { ArchitectureModel, DependencyEdge, ModuleInfo } from "./architecture.ts";
181
- export { buildArchitectureModel, findModuleForPath, getDependencies, getDependents } from "./architecture.ts";
182
-
183
- // Brief generation
184
- export { generateFocusedBrief, generateOverview, generateProjectBrief } from "./brief.ts";
185
-
186
- // Target resolution
187
- export type { ResolvedTarget, TargetResolutionResult } from "./target-resolution.ts";
188
- export { normalizePath, resolveAnchoredTarget, resolveSymbolTarget, toZeroBased } from "./target-resolution.ts";
189
-
190
- // Result types
191
- export type { AffectedDetails, BriefDetails, CodeIntelResult, ConfidenceMode, DisambiguationCandidate, SearchDetails } from "./types.ts";
192
- ```
52
+ import { buildArchitectureModel, generateOverview } from "@mrclrchtr/supi-code-intelligence";
193
53
 
194
- ## Session Integration
195
-
196
- - The overview custom message type (`code-intelligence-overview`) uses `display: false` so it appears in the LLM context but not in the TUI message log
197
- - On `session_start`, the extension scans the session branch for an existing overview to avoid re-injecting on `/reload` or session resume
198
- - The `hasInjectedOverview` flag is per-session, reset each `session_start`
199
-
200
- ## Prompt Guidelines (full text)
201
-
202
- These seven guidelines are injected into the system prompt:
203
-
204
- > - Use `code_intel brief` before editing an unfamiliar package, directory, or file to get architecture context and reduce blind reads.
205
- > - Use `code_intel affected` before changing exported APIs, shared helpers, config surfaces, or cross-package contracts to check blast radius and risk; file-only requests now expand across exported targets when possible.
206
- > - Use `code_intel callers` before modifying a function to verify all call sites; use `callees` and `implementations` for dependency and interface analysis, and use file-only `callers` when you need the export surface of a module.
207
- > - Use `code_intel pattern` for bounded, scope-aware text search when the question is textual rather than semantic; it treats patterns as literal strings by default, supports `regex: true`, and supports `kind: "definition" | "export" | "import"` for structured searches.
208
- > - Use `code_intel brief` and `code_intel affected` priority signals to notice diagnostics, low coverage, or unused-code hints before editing risky files.
209
- > - Use `code_intel index` for a factual project map (file counts, directory structure, landmark files) when you need to orient yourself in a new codebase.
210
- > - After `code_intel` narrows the target, use raw `lsp` and `tree_sitter` tools for precise drill-down on exact symbols, types, or AST nodes.
211
- > - Do not prefer `code_intel` over direct file reads or lower-level tools for trivial, already-localized edits or exact symbol/AST drill-down tasks.
212
-
213
- ## Install
214
-
215
- Included in the `@mrclrchtr/supi` meta-package, or install standalone:
216
-
217
- ```bash
218
- pi install npm:@mrclrchtr/supi-code-intelligence
54
+ const model = await buildArchitectureModel("/project");
55
+ const overview = generateOverview(model);
219
56
  ```
220
-
221
- ## License
222
-
223
- MIT
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,5 +22,13 @@
22
22
  "@earendil-works/pi-coding-agent": "*",
23
23
  "@earendil-works/pi-tui": "*"
24
24
  },
25
+ "peerDependenciesMeta": {
26
+ "@earendil-works/pi-coding-agent": {
27
+ "optional": true
28
+ },
29
+ "@earendil-works/pi-tui": {
30
+ "optional": true
31
+ }
32
+ },
25
33
  "main": "src/index.ts"
26
34
  }
@@ -1,112 +1,66 @@
1
1
  # @mrclrchtr/supi-lsp
2
2
 
3
- Language Server Protocol integration for the [pi coding agent](https://github.com/earendil-works/pi).
3
+ Language Server Protocol for PI your agent navigates code like an IDE.
4
4
 
5
- ## Install
6
-
7
- ```bash
8
- pi install npm:@mrclrchtr/supi-lsp
9
- ```
10
-
11
- ## What it adds
12
-
13
- - `lsp` tool with `hover`, `definition`, `references`, `diagnostics`, `symbols`, `rename`, `code_actions`, `workspace_symbol`, `search`, `symbol_hover`, and `recover`
14
- - Stable system-prompt guidance that tells the agent to prefer LSP over grep/rg for code navigation
15
- - Proactive project scanning and eager startup of detected language servers
16
- - Automatic stale-diagnostic recovery when workspace sentinels change (`package.json`, root lockfiles, `tsconfig*`, generated `*.d.ts` files`) before the next agent turn, plus immediate recovery after successful `write` or `edit` calls for those paths
17
- - Inline diagnostic surfacing around reads, writes, and edits
18
- - Compact diagnostic context injection when outstanding diagnostics change, with stale-diagnostic warnings when needed
19
- - `/lsp-status` status overlay
5
+ Without LSP, agents grep and guess. With it, they jump to definitions, find every reference, rename across files, and catch type errors inline. The same precision you get from an editor, available to your agent.
20
6
 
21
- ## Public library API
7
+ ## What you get
22
8
 
23
- In addition to the extension entrypoint, `@mrclrchtr/supi-lsp` exports a reusable session-scoped service API for peer extensions:
9
+ ### Navigate with precision
24
10
 
25
- ```ts
26
- import { getSessionLspService, SessionLspService } from "@mrclrchtr/supi-lsp";
27
-
28
- const state = getSessionLspService("/project");
11
+ Go-to-definition, find-references, rename, hover types. The agent stops guessing and starts navigating your codebase with IDE-level accuracy.
29
12
 
30
- if (state.kind === "ready") {
31
- const service = state.service;
32
- const hover = await service.hover("src/index.ts", { line: 5, character: 10 });
33
- const defs = await service.definition("src/index.ts", { line: 5, character: 10 });
34
- const refs = await service.references("src/index.ts", { line: 5, character: 10 });
35
- const impls = await service.implementation("src/index.ts", { line: 5, character: 10 });
36
- const symbols = await service.documentSymbols("src/index.ts");
37
- const projectServers = service.getProjectServers();
38
- }
39
- ```
13
+ ### Catch problems immediately
40
14
 
41
- Peer extensions can import from the package root without reaching into private files.
15
+ Type errors, warnings, and hints surface inline after every edit. The agent sees mistakes as it makes them — not 10 turns later when tests fail.
42
16
 
43
- ## Tool actions
17
+ ### Always ready
44
18
 
45
- The `lsp` tool supports these actions:
19
+ Servers start automatically for your project. The agent gets language-aware guidance at session start and stale diagnostics are refreshed when dependencies change.
46
20
 
47
- - `hover`: type info at a position
48
- - `definition`: go to definition
49
- - `references`: find all references
50
- - `diagnostics`: per-file or project-wide diagnostics
51
- - `symbols`: document symbols
52
- - `rename`: workspace-wide rename
53
- - `code_actions`: quick fixes at a position
54
- - `workspace_symbol`: fuzzy symbol search across the project
55
- - `search`: symbol search with text fallback
56
- - `symbol_hover`: hover by symbol name
57
- - `recover`: refresh diagnostics after workspace-wide dependency, config, or generated-type changes
58
-
59
- Line and character positions are **1-based**.
60
-
61
- Example:
21
+ ## Install
62
22
 
63
- ```json
64
- {
65
- "action": "definition",
66
- "file": "src/index.ts",
67
- "line": 12,
68
- "character": 8
69
- }
23
+ ```bash
24
+ pi install npm:@mrclrchtr/supi-lsp
70
25
  ```
71
26
 
72
- ## Configuration
27
+ ## Quick look
73
28
 
74
- If your install surface includes `/supi-settings` (for example via `@mrclrchtr/supi`), this package contributes an LSP settings section there. Use that panel to:
29
+ The agent gets an `lsp` tool. The most-used actions:
75
30
 
76
- - enable or disable LSP globally
77
- - control the severity threshold
78
- - select active language servers
79
- - configure file exclusion patterns
31
+ | Action | What the agent can do |
32
+ |--------|----------------------|
33
+ | `hover` | See the type of any symbol |
34
+ | `definition` | Jump to where something is defined |
35
+ | `references` | Find every usage across the project |
36
+ | `diagnostics` | See errors, warnings, and hints |
37
+ | `rename` | Rename across the entire project |
80
38
 
81
- ## Commands
39
+ Full action reference: the agent's system prompt includes complete guidelines for all 11 actions (hover, definition, references, diagnostics, symbols, rename, code_actions, workspace_symbol, search, symbol_hover, recover). All positions are 1-based.
82
40
 
83
- `/lsp-status` toggles an overlay showing active language servers and outstanding diagnostics:
41
+ ## Settings
84
42
 
85
- ```text
86
- λ LSP inspector /lsp-status toggles
87
- 3 servers running • 12 open files • 5 errors • 2 warnings
43
+ Configure via `/supi-settings` (LSP panel):
88
44
 
89
- Servers
90
- typescript running 24 open files
91
- python running 8 open files
92
- bash running 0 open files
45
+ - Enable or disable LSP per project
46
+ - Set diagnostic severity threshold (errors only, or include warnings/hints)
47
+ - Choose which language servers to activate
48
+ - Add file exclusion patterns (gitignore-style globs)
93
49
 
94
- Problems
95
- src/lsp.ts:42 Cannot find name 'foo' ts(2304)
96
- src/manager.ts:108 Property 'bar' does not exist ts(2339)
97
- ```
50
+ Settings are stored in `~/.pi/agent/supi/config.json` (global) or `.pi/supi/config.json` (project). The `/lsp-status` command shows active servers and outstanding diagnostics.
98
51
 
99
- When no servers are available, the overlay shows `no LSP servers available for this project`. A compact status summary is always visible in the pi status bar.
52
+ ## For extension developers
100
53
 
101
- ## Requirements
54
+ This package exports a reusable session-scoped LSP service. Peer extensions can query the same LSP runtime without starting duplicate servers:
102
55
 
103
- - `@earendil-works/pi-coding-agent`
104
- - `@earendil-works/pi-tui`
105
- - `typebox`
106
- - relevant language servers installed and available on `PATH`
107
- - `@mrclrchtr/supi-core`
56
+ ```ts
57
+ import { getSessionLspService, SessionLspService } from "@mrclrchtr/supi-lsp";
108
58
 
109
- ## Source
59
+ const state = getSessionLspService("/project");
60
+ if (state.kind === "ready") {
61
+ const defs = await state.service.definition("src/index.ts", { line: 5, character: 10 });
62
+ const refs = await state.service.references("src/index.ts", { line: 5, character: 10 });
63
+ }
64
+ ```
110
65
 
111
- - Extension entrypoint: `lsp.ts`
112
- - Public library surface: `index.ts`
66
+ Import from the package root — no need to reach into internal files.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -22,5 +22,13 @@
22
22
  "@earendil-works/pi-coding-agent": "*",
23
23
  "@earendil-works/pi-tui": "*"
24
24
  },
25
+ "peerDependenciesMeta": {
26
+ "@earendil-works/pi-coding-agent": {
27
+ "optional": true
28
+ },
29
+ "@earendil-works/pi-tui": {
30
+ "optional": true
31
+ }
32
+ },
25
33
  "main": "src/index.ts"
26
34
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-lsp",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "SuPi LSP extension — Language Server Protocol integration for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "!__tests__"
22
22
  ],
23
23
  "dependencies": {
24
- "@mrclrchtr/supi-core": "1.1.2"
24
+ "@mrclrchtr/supi-core": "1.1.3"
25
25
  },
26
26
  "bundledDependencies": [
27
27
  "@mrclrchtr/supi-core"
@@ -32,6 +32,20 @@
32
32
  "@earendil-works/pi-tui": "*",
33
33
  "typebox": "*"
34
34
  },
35
+ "peerDependenciesMeta": {
36
+ "@earendil-works/pi-ai": {
37
+ "optional": true
38
+ },
39
+ "@earendil-works/pi-coding-agent": {
40
+ "optional": true
41
+ },
42
+ "@earendil-works/pi-tui": {
43
+ "optional": true
44
+ },
45
+ "typebox": {
46
+ "optional": true
47
+ }
48
+ },
35
49
  "pi": {
36
50
  "extensions": [
37
51
  "./src/lsp.ts"
@@ -1,97 +1,65 @@
1
1
  # @mrclrchtr/supi-tree-sitter
2
2
 
3
- Tree-sitter structural analysis for the [pi coding agent](https://github.com/earendil-works/pi).
3
+ Structural code analysis for PI your agent parses code, not just text.
4
4
 
5
- This package registers a `tree_sitter` tool and also exports a small TypeScript service API for other SuPi extensions. It is designed as a standalone structural-analysis substrate: it does not depend on `supi-lsp` or semantic language-server tooling, and it remains correct and useful when installed by itself.
5
+ Grep matches strings. Tree-sitter parses structure functions, classes, imports, call chains. The agent stops pattern-matching and starts understanding your code.
6
6
 
7
- ## Install
7
+ ## What you get
8
8
 
9
- ```bash
10
- pi install npm:@mrclrchtr/supi-tree-sitter
11
- ```
9
+ ### See code structure
12
10
 
13
- Standalone installs include the runtime grammar dependencies needed for the supported non-vendored languages. Kotlin and SQL use vendored WASM grammars bundled with this package.
11
+ Extract functions, classes, interfaces, and methods from any file. The agent knows what lives where without reading every line.
14
12
 
15
- It is also bundled by the full SuPi meta-package:
13
+ ### Trace call chains
16
14
 
17
- ```bash
18
- pi install npm:@mrclrchtr/supi
19
- ```
15
+ Find every function call from a given location. The agent follows the code's actual shape instead of guessing from text proximity.
20
16
 
21
- ## Supported files
17
+ ### 14 languages
22
18
 
23
- The runtime can parse these file families:
19
+ JavaScript, TypeScript, Python, Rust, Go, C, C++, Java, Kotlin, Ruby, Bash, HTML, R, SQL — get structural analysis for every project you touch.
24
20
 
25
- - **JavaScript / TypeScript**`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`
26
- - **Python** — `.py`, `.pyi`
27
- - **Rust** — `.rs`
28
- - **Go** — `.go`, `.mod`
29
- - **C / C++** — `.c`, `.h`, `.cpp`, `.hpp`, `.cc`, `.cxx`, `.hxx`, `.c++`, `.h++`
30
- - **Java** — `.java`
31
- - **Kotlin** — `.kt`, `.kts`
32
- - **Ruby** — `.rb`
33
- - **Bash / Shell** — `.sh`, `.bash`, `.zsh`
34
- - **HTML** — `.html`, `.htm`, `.xhtml`
35
- - **R** — `.r`
36
- - **SQL** — `.sql`
21
+ Works standalone or alongside LSP. Grammar files are vendored no native toolchain required at install time.
22
+
23
+ ## Install
37
24
 
38
- Grammar `.wasm` files are resolved from installed package metadata for npm-shipped grammars, not from repository-relative paths.
25
+ ```bash
26
+ pi install npm:@mrclrchtr/supi-tree-sitter
27
+ ```
39
28
 
40
- ## `tree_sitter` tool
29
+ ## Quick look
41
30
 
42
- Actions:
31
+ The agent gets a `tree_sitter` tool with these actions:
43
32
 
44
- - `outline` list structural declarations such as functions, classes, interfaces, methods, and variables (**currently JavaScript / TypeScript only**)
45
- - `imports` — list import statements and module specifiers (**currently JavaScript / TypeScript only**)
46
- - `exports` list exported declarations, re-exports, and TypeScript `export =` assignments (**currently JavaScript / TypeScript only**)
47
- - `node_at` return the smallest syntax node at a 1-based `line`/`character` position, plus ancestry (all supported grammars)
48
- - `query` run a custom Tree-sitter query and return captures (all supported grammars)
49
- - `callees` find outgoing function/method calls from a position; supports all grammars with a callee query configured
33
+ | Action | What it does |
34
+ |--------|-------------|
35
+ | `outline` | List functions, classes, interfaces in a file |
36
+ | `callees` | Find all function calls from a position |
37
+ | `imports` / `exports` | See what a file imports and exports |
38
+ | `node_at` | Inspect the AST node at any line/column |
39
+ | `query` | Run a custom Tree-sitter query |
50
40
 
51
- Coordinates are 1-based and compatible with the `lsp` tool. `character` is a UTF-16 code-unit column. Relative file paths resolve from the pi session working directory.
41
+ `outline`, `imports`, and `exports` are currently JavaScript/TypeScript only. `node_at`, `query`, and `callees` work across all 14 supported languages. Coordinates are 1-based, matching the `lsp` tool convention.
52
42
 
53
- Large result sets are capped at 100 emitted items per tool response. For outlines, nested children count toward the same cap so deeply nested classes do not bypass the limit.
43
+ ## For extension developers
54
44
 
55
- ## Service API
45
+ This package exports a reusable session-scoped parsing service:
56
46
 
57
47
  ```ts
58
48
  import { createTreeSitterSession } from "@mrclrchtr/supi-tree-sitter";
59
49
 
60
- const session = createTreeSitterSession(process.cwd());
61
- try {
62
- const parseable = await session.canParse("src/index.ts");
63
- if (parseable.kind === "success") {
64
- console.log(parseable.data.file, parseable.data.language);
65
- }
66
-
67
- const outline = await session.outline("src/index.ts");
68
- if (outline.kind === "success") {
69
- console.log(outline.data);
70
- }
71
-
72
- const callees = await session.calleesAt("src/index.ts", 1, 10);
73
- if (callees.kind === "success") {
74
- console.log(callees.data.enclosingScope.name, callees.data.callees);
75
- }
76
- } finally {
77
- session.dispose();
78
- }
79
- ```
80
-
81
- `canParse(file)` validates that a supported file can be read and parsed, then returns the resolved file path and grammar id. It does not expose the raw Tree-sitter tree; use `outline`, `query`, `imports`, `exports`, `nodeAt`, or `calleesAt` for structured results.
82
-
83
- `calleesAt(file, line, character)` extracts structural outgoing calls from the enclosing function/method scope at the given position. It returns the enclosing scope name and a deduplicated list of callees with their source ranges.
50
+ const session = createTreeSitterSession("/project");
84
51
 
85
- Exported types include `TreeSitterResult`, `TreeSitterSession`, `OutlineItem`, `ImportRecord`, `ExportRecord`, `NodeAtResult`, `QueryCapture`, `CalleesAtResult`, `SourceRange`, `GrammarId`, and `SupportedExtension`.
52
+ // Check if a file is parseable
53
+ const result = await session.canParse("src/index.ts");
86
54
 
87
- Always call `dispose()` when the session is no longer needed. The runtime lazily initializes grammars, reuses parser instances within a session, deduplicates concurrent first-use grammar initialization, and retries after initialization failures.
55
+ // Get structural outline
56
+ const outline = await session.outline("src/index.ts");
88
57
 
89
- ## Positioning
58
+ // Trace outgoing calls from a position
59
+ const callees = await session.calleesAt("src/index.ts", 42, 10);
90
60
 
91
- `supi-tree-sitter` is the structural-analysis substrate in SuPi's layered code-understanding stack:
92
-
93
- - `supi-tree-sitter` — parser-backed structural analysis (this package)
94
- - `supi-lsp` — live semantic analysis through language servers
95
- - `supi-code-intelligence` — higher-level agent-facing analysis built on top of both substrates
61
+ // Always clean up
62
+ session.dispose();
63
+ ```
96
64
 
97
- Each substrate can be installed and used independently. `supi-tree-sitter` does not require `supi-lsp` to be present, and its prompt guidance is written so it remains correct in standalone installs.
65
+ Import from the package root. No internal imports needed. Call `dispose()` when done.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "SuPi Tree-sitter extension — structural AST analysis for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,6 +30,17 @@
30
30
  "@earendil-works/pi-coding-agent": "*",
31
31
  "typebox": "*"
32
32
  },
33
+ "peerDependenciesMeta": {
34
+ "@earendil-works/pi-ai": {
35
+ "optional": true
36
+ },
37
+ "@earendil-works/pi-coding-agent": {
38
+ "optional": true
39
+ },
40
+ "typebox": {
41
+ "optional": true
42
+ }
43
+ },
33
44
  "pi": {
34
45
  "extensions": [
35
46
  "./src/tree-sitter.ts"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "SuPi Code Intelligence extension — architecture briefs, caller/callee analysis, impact assessment, and pattern search for pi",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,9 +19,9 @@
19
19
  "src/**/*.ts"
20
20
  ],
21
21
  "dependencies": {
22
- "@mrclrchtr/supi-core": "1.1.2",
23
- "@mrclrchtr/supi-lsp": "1.1.2",
24
- "@mrclrchtr/supi-tree-sitter": "1.1.2"
22
+ "@mrclrchtr/supi-core": "1.1.3",
23
+ "@mrclrchtr/supi-lsp": "1.1.3",
24
+ "@mrclrchtr/supi-tree-sitter": "1.1.3"
25
25
  },
26
26
  "bundledDependencies": [
27
27
  "@mrclrchtr/supi-core",
@@ -33,6 +33,17 @@
33
33
  "@earendil-works/pi-coding-agent": "*",
34
34
  "typebox": "*"
35
35
  },
36
+ "peerDependenciesMeta": {
37
+ "@earendil-works/pi-ai": {
38
+ "optional": true
39
+ },
40
+ "@earendil-works/pi-coding-agent": {
41
+ "optional": true
42
+ },
43
+ "typebox": {
44
+ "optional": true
45
+ }
46
+ },
36
47
  "pi": {
37
48
  "extensions": [
38
49
  "./src/code-intelligence.ts"