@mrclrchtr/supi-tree-sitter 1.1.2 → 1.2.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 +38 -70
- package/package.json +12 -1
package/README.md
CHANGED
|
@@ -1,97 +1,65 @@
|
|
|
1
1
|
# @mrclrchtr/supi-tree-sitter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Structural code analysis for PI — your agent parses code, not just text.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
7
|
+
## What you get
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
pi install npm:@mrclrchtr/supi-tree-sitter
|
|
11
|
-
```
|
|
9
|
+
### See code structure
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
Extract functions, classes, interfaces, and methods from any file. The agent knows what lives where without reading every line.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
### Trace call chains
|
|
16
14
|
|
|
17
|
-
|
|
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
|
-
|
|
17
|
+
### 14 languages
|
|
22
18
|
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
25
|
+
```bash
|
|
26
|
+
pi install npm:@mrclrchtr/supi-tree-sitter
|
|
27
|
+
```
|
|
39
28
|
|
|
40
|
-
##
|
|
29
|
+
## Quick look
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
The agent gets a `tree_sitter` tool with these actions:
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
+
## For extension developers
|
|
54
44
|
|
|
55
|
-
|
|
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(
|
|
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
|
-
|
|
52
|
+
// Check if a file is parseable
|
|
53
|
+
const result = await session.canParse("src/index.ts");
|
|
86
54
|
|
|
87
|
-
|
|
55
|
+
// Get structural outline
|
|
56
|
+
const outline = await session.outline("src/index.ts");
|
|
88
57
|
|
|
89
|
-
|
|
58
|
+
// Trace outgoing calls from a position
|
|
59
|
+
const callees = await session.calleesAt("src/index.ts", 42, 10);
|
|
90
60
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
65
|
+
Import from the package root. No internal imports needed. Call `dispose()` when done.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-tree-sitter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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"
|