pi-agent-ide 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/chunk-CM3XGY72.js +3 -0
- package/dist/{chunk-4W7GH3T7.js → chunk-Z2MNHSJ4.js} +1 -1
- package/dist/entry-34.js +1 -1
- package/dist/entry-35.js +3 -3
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-ast/src/ast/manager.ts +13 -1
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search-text/package.json +9 -9
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +5 -5
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/ast/manager.ts +13 -1
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/dist/chunk-UEVGZUII.js +0 -3
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-constant",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-text": "0.8.
|
|
10
|
-
"pi-agent-text-editor": "0.8.
|
|
9
|
+
"pi-agent-text": "0.8.4",
|
|
10
|
+
"pi-agent-text-editor": "0.8.4"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-exact",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"pi-agent-text": "0.8.
|
|
16
|
-
"pi-agent-text-editor": "0.8.
|
|
15
|
+
"pi-agent-text": "0.8.4",
|
|
16
|
+
"pi-agent-text-editor": "0.8.4"
|
|
17
17
|
},
|
|
18
18
|
"pi": {
|
|
19
19
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-anchor-line-hash",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"pi-agent-invariant": "0.8.
|
|
16
|
-
"pi-agent-read": "0.8.
|
|
17
|
-
"pi-agent-text": "0.8.
|
|
18
|
-
"pi-agent-text-editor": "0.8.
|
|
15
|
+
"pi-agent-invariant": "0.8.4",
|
|
16
|
+
"pi-agent-read": "0.8.4",
|
|
17
|
+
"pi-agent-text": "0.8.4",
|
|
18
|
+
"pi-agent-text-editor": "0.8.4"
|
|
19
19
|
},
|
|
20
20
|
"pi": {
|
|
21
21
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-renderer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"pi-agent-invariant": "0.8.
|
|
10
|
-
"pi-agent-text-editor": "0.8.
|
|
11
|
-
"pi-agent-tool-call-interception": "0.8.
|
|
12
|
-
"pi-agent-tool-ui": "0.8.
|
|
9
|
+
"pi-agent-invariant": "0.8.4",
|
|
10
|
+
"pi-agent-text-editor": "0.8.4",
|
|
11
|
+
"pi-agent-tool-call-interception": "0.8.4",
|
|
12
|
+
"pi-agent-tool-ui": "0.8.4"
|
|
13
13
|
},
|
|
14
14
|
"pi": {
|
|
15
15
|
"extensions": [
|
package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-text-editor-stale-anchor",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-invariant": "0.8.
|
|
7
|
-
"pi-agent-read": "0.8.
|
|
8
|
-
"pi-agent-resource": "0.8.
|
|
9
|
-
"pi-agent-text-editor": "0.8.
|
|
6
|
+
"pi-agent-invariant": "0.8.4",
|
|
7
|
+
"pi-agent-read": "0.8.4",
|
|
8
|
+
"pi-agent-resource": "0.8.4",
|
|
9
|
+
"pi-agent-text-editor": "0.8.4"
|
|
10
10
|
},
|
|
11
11
|
"pi": {
|
|
12
12
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-ast",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"pi-agent-doctor": "0.8.
|
|
16
|
-
"pi-agent-documentation": "0.8.
|
|
17
|
-
"pi-agent-invariant": "0.8.
|
|
18
|
-
"pi-agent-read": "0.8.
|
|
19
|
-
"pi-agent-resource": "0.8.
|
|
20
|
-
"pi-agent-search": "0.8.
|
|
21
|
-
"pi-agent-search-text": "0.8.
|
|
22
|
-
"pi-agent-text": "0.8.
|
|
23
|
-
"pi-agent-text-editor": "0.8.
|
|
24
|
-
"pi-agent-tool-call-interception": "0.8.
|
|
25
|
-
"pi-agent-tool-ui": "0.8.
|
|
15
|
+
"pi-agent-doctor": "0.8.4",
|
|
16
|
+
"pi-agent-documentation": "0.8.4",
|
|
17
|
+
"pi-agent-invariant": "0.8.4",
|
|
18
|
+
"pi-agent-read": "0.8.4",
|
|
19
|
+
"pi-agent-resource": "0.8.4",
|
|
20
|
+
"pi-agent-search": "0.8.4",
|
|
21
|
+
"pi-agent-search-text": "0.8.4",
|
|
22
|
+
"pi-agent-text": "0.8.4",
|
|
23
|
+
"pi-agent-text-editor": "0.8.4",
|
|
24
|
+
"pi-agent-tool-call-interception": "0.8.4",
|
|
25
|
+
"pi-agent-tool-ui": "0.8.4"
|
|
26
26
|
},
|
|
27
27
|
"pi": {
|
|
28
28
|
"extensions": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@earendil-works/pi-coding-agent": "*",
|
|
34
34
|
"@earendil-works/pi-tui": "*",
|
|
35
|
-
"pi-agent-ide": "0.8.
|
|
35
|
+
"pi-agent-ide": "0.8.4",
|
|
36
36
|
"typebox": "*"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -42,6 +42,12 @@ Named AST fields that represent block-level bodies.
|
|
|
42
42
|
*/
|
|
43
43
|
const BODY_FIELDS = new Set(["body", "consequence", "alternative", "handler", "finalizer"]);
|
|
44
44
|
|
|
45
|
+
/** Identify a child among its siblings; parsers return a new wrapper object on each access. */
|
|
46
|
+
function siblingKey(node: SyntaxNode): string {
|
|
47
|
+
const { startPosition: start, endPosition: end } = node;
|
|
48
|
+
return `${node.type}:${start.row}:${start.column}:${end.row}:${end.column}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
let initPromise: Promise<void> | undefined;
|
|
46
52
|
const loadedLanguages = new Map<string, Promise<WTS.Language>>();
|
|
47
53
|
|
|
@@ -230,6 +236,9 @@ export class AstScopeManager {
|
|
|
230
236
|
}
|
|
231
237
|
|
|
232
238
|
// 1. Collect block bodies from named fields (body, consequence, alternative, etc.)
|
|
239
|
+
// Field children are also named children; step 3 must not walk them again, or every
|
|
240
|
+
// nesting level doubles the traversal and large files freeze the session.
|
|
241
|
+
const visitedFieldChildren = new Set<string>();
|
|
233
242
|
for (const fieldName of BODY_FIELDS) {
|
|
234
243
|
const child = node.childForFieldName(fieldName);
|
|
235
244
|
|
|
@@ -237,6 +246,8 @@ export class AstScopeManager {
|
|
|
237
246
|
continue;
|
|
238
247
|
}
|
|
239
248
|
|
|
249
|
+
visitedFieldChildren.add(siblingKey(child));
|
|
250
|
+
|
|
240
251
|
const startLine = child.startPosition.row + 1;
|
|
241
252
|
const endLine = child.endPosition.row + 1;
|
|
242
253
|
const isMultiLine = endLine - startLine >= 3;
|
|
@@ -276,8 +287,9 @@ export class AstScopeManager {
|
|
|
276
287
|
}
|
|
277
288
|
}
|
|
278
289
|
|
|
279
|
-
// 3. Recurse into
|
|
290
|
+
// 3. Recurse into the remaining named children (to find nested constructs)
|
|
280
291
|
for (const child of node.namedChildren) {
|
|
292
|
+
if (visitedFieldChildren.has(siblingKey(child))) continue;
|
|
281
293
|
this.collectCandidates(child, candidates, depth + 1);
|
|
282
294
|
}
|
|
283
295
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-changes",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"pi-agent-doctor": "0.8.
|
|
16
|
-
"pi-agent-documentation": "0.8.
|
|
17
|
-
"pi-agent-invariant": "0.8.
|
|
18
|
-
"pi-agent-read": "0.8.
|
|
19
|
-
"pi-agent-resource": "0.8.
|
|
20
|
-
"pi-agent-text": "0.8.
|
|
21
|
-
"pi-agent-text-editor": "0.8.
|
|
15
|
+
"pi-agent-doctor": "0.8.4",
|
|
16
|
+
"pi-agent-documentation": "0.8.4",
|
|
17
|
+
"pi-agent-invariant": "0.8.4",
|
|
18
|
+
"pi-agent-read": "0.8.4",
|
|
19
|
+
"pi-agent-resource": "0.8.4",
|
|
20
|
+
"pi-agent-text": "0.8.4",
|
|
21
|
+
"pi-agent-text-editor": "0.8.4"
|
|
22
22
|
},
|
|
23
23
|
"pi": {
|
|
24
24
|
"extensions": [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-formatter",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.8.
|
|
6
|
+
"pi-agent-doctor": "0.8.4"
|
|
7
7
|
},
|
|
8
8
|
"pi": {
|
|
9
9
|
"extensions": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@earendil-works/pi-coding-agent": "*",
|
|
15
|
-
"pi-agent-ide": "0.8.
|
|
15
|
+
"pi-agent-ide": "0.8.4"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"pi-agent-ide": {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lint",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.8.
|
|
7
|
-
"pi-agent-invariant": "0.8.
|
|
8
|
-
"pi-agent-read": "0.8.
|
|
9
|
-
"pi-agent-resource": "0.8.
|
|
10
|
-
"pi-agent-text": "0.8.
|
|
6
|
+
"pi-agent-doctor": "0.8.4",
|
|
7
|
+
"pi-agent-invariant": "0.8.4",
|
|
8
|
+
"pi-agent-read": "0.8.4",
|
|
9
|
+
"pi-agent-resource": "0.8.4",
|
|
10
|
+
"pi-agent-text": "0.8.4"
|
|
11
11
|
},
|
|
12
12
|
"pi": {
|
|
13
13
|
"extensions": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@earendil-works/pi-coding-agent": "*",
|
|
19
|
-
"pi-agent-ide": "0.8.
|
|
19
|
+
"pi-agent-ide": "0.8.4"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
22
22
|
"pi-agent-ide": {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-ide-lsp",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"pi-agent-doctor": "0.8.
|
|
7
|
-
"pi-agent-invariant": "0.8.
|
|
8
|
-
"pi-agent-read": "0.8.
|
|
9
|
-
"pi-agent-resource": "0.8.
|
|
10
|
-
"pi-agent-search": "0.8.
|
|
11
|
-
"pi-agent-text": "0.8.
|
|
12
|
-
"pi-agent-text-editor": "0.8.
|
|
6
|
+
"pi-agent-doctor": "0.8.4",
|
|
7
|
+
"pi-agent-invariant": "0.8.4",
|
|
8
|
+
"pi-agent-read": "0.8.4",
|
|
9
|
+
"pi-agent-resource": "0.8.4",
|
|
10
|
+
"pi-agent-search": "0.8.4",
|
|
11
|
+
"pi-agent-text": "0.8.4",
|
|
12
|
+
"pi-agent-text-editor": "0.8.4"
|
|
13
13
|
},
|
|
14
14
|
"pi": {
|
|
15
15
|
"extensions": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@earendil-works/pi-coding-agent": "*",
|
|
21
|
-
"pi-agent-ide": "0.8.
|
|
21
|
+
"pi-agent-ide": "0.8.4"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
24
24
|
"pi-agent-ide": {
|
package/dist/chunk-UEVGZUII.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as S}from"./chunk-ZPT5D4VP.js";import{a as d}from"./chunk-EI7MMDWY.js";import{createRequire as j}from"node:module";import{Lang as y,parse as T,registerDynamicLanguage as F}from"@ast-grep/napi";var R=j(new URL("../src/plugins/pi-agent-ide-ast/src/ast/native-parser.ts",import.meta.url).href),B={bash:"@ast-grep/lang-bash",csharp:"@ast-grep/lang-csharp",dart:"@ast-grep/lang-dart",elixir:"@ast-grep/lang-elixir",go:"@ast-grep/lang-go",html:"@ast-grep/lang-html",java:"@ast-grep/lang-java",kotlin:"@ast-grep/lang-kotlin",lua:"@ast-grep/lang-lua",markdown:"@ast-grep/lang-markdown",php:"@ast-grep/lang-php",ruby:"@ast-grep/lang-ruby",scala:"@ast-grep/lang-scala",sql:"@ast-grep/lang-sql",swift:"@ast-grep/lang-swift"},D={".bash":"bash",".cs":"csharp",".css":y.Css,".less":y.Css,".scss":y.Css,".dart":"dart",".ex":"elixir",".exs":"elixir",".go":"go",".htm":"html",".html":"html",".java":"java",".kt":"kotlin",".kts":"kotlin",".lua":"lua",".md":"markdown",".mdx":"markdown",".php":"php",".rb":"ruby",".rake":"ruby",".scala":"scala",".sc":"scala",".sql":"sql",".sh":"bash",".swift":"swift"},N=!1;function O(){if(N)return;let r={};for(let[e,t]of Object.entries(B))r[e]=R(t);F(r),N=!0}d(O,"ensureLanguagesRegistered");function C(r,e){let t=D[r];if(t)return O(),{rootNode:new b(T(t,e).root(),e)}}d(C,"parseNativeDocument");var b=class r{constructor(e,t){this.node=e;this.source=t}static{d(this,"NativeSyntaxNode")}get type(){return String(this.node.kind())}get text(){return this.node.text()}get isNamed(){return this.node.isNamed()}get hasError(){return this.type==="ERROR"||this.node.children().some(e=>new r(e,this.source).hasError)}get startIndex(){return k(this.source,this.node.range().start.index)}get endIndex(){return k(this.source,this.node.range().end.index)}get startPosition(){let{line:e,column:t}=this.node.range().start;return{row:e,column:t}}get endPosition(){let{line:e,column:t}=this.node.range().end;return{row:e,column:t}}get parent(){let e=this.node.parent();return e?new r(e,this.source):null}get namedChildCount(){return this.namedChildren.length}get namedChildren(){return this.node.children().filter(e=>e.isNamed()).map(e=>new r(e,this.source))}childForFieldName(e){let t=this.node.field(e);return t?new r(t,this.source):null}};function k(r,e){return Buffer.from(r).subarray(0,e).toString("utf8").length}d(k,"byteOffsetToStringIndex");import{createHash as q}from"node:crypto";import{createRequire as W}from"node:module";import L from"node:path";import*as p from"web-tree-sitter";var I=W(new URL("../src/plugins/pi-agent-ide-ast/src/ast/manager.ts",import.meta.url).href),M=new Set(["program","module"]),x=new Set(["body","consequence","alternative","handler","finalizer"]),A,E=new Map;function $(r){switch(r){case".ts":case".tsx":case".mts":case".cts":return"tree-sitter-typescript/tree-sitter-typescript.wasm";case".js":case".jsx":case".mjs":case".cjs":return"tree-sitter-javascript/tree-sitter-javascript.wasm";case".py":case".pyi":return"tree-sitter-python/tree-sitter-python.wasm";case".rs":return"tree-sitter-rust/tree-sitter-rust.wasm";case".c":case".cc":case".hh":case".hxx":case".cpp":case".cxx":case".h":case".hpp":return"tree-sitter-cpp/tree-sitter-cpp.wasm";case".json":case".jsonc":return"tree-sitter-json/tree-sitter-json.wasm";case".yaml":case".yml":return"@tree-sitter-grammars/tree-sitter-yaml/tree-sitter-yaml.wasm";case".toml":return"@tree-sitter-grammars/tree-sitter-toml/tree-sitter-toml.wasm";default:return}}d($,"grammarWasmPath");async function G(r){let e=$(r);if(!e)return;A??=p.Parser.init(),await A;let t=E.get(e);if(t===void 0){let i=I.resolve(e);t=p.Language.load(i),E.set(e,t)}let a=await t,o=new p.Parser;return o.setLanguage(a),o}d(G,"ensureParser");async function U(r,e,t){if(t.length===0)return;let a=r.includes("://")||L.isAbsolute(r)?r:L.resolve(e,r),o=L.extname(a).toLowerCase(),i=t.join(`
|
|
2
|
-
`),l=await G(o);if(l)try{return l.parse(i)??void 0}finally{l.delete()}return C(o,i)}d(U,"parseDocument");function P(r,e,t){let a=r.slice(Math.max(0,e-1),Math.max(0,t)).join(`
|
|
3
|
-
`);return q("sha1").update(a).digest("hex").slice(0,4).toUpperCase()}d(P,"hashScope");var w=class extends S{static{d(this,"AstScopeTextAnchor")}constructor(e,t,a,o){super(`scope-${e}-${t}${o===void 0?"":`-${o}`}`,a)}};function f(r,e,t,a){return new w(r,e,t,a)}d(f,"createScopeAnchor");var v=class{static{d(this,"AstScopeManager")}async getDocumentScopes(e,t,a){if(a.length===0)return[];let o=await U(e,t,a);if(!o)return[];let i=[];return this.collectCandidates(o.rootNode,i),this.buildEntries(i,a)}collectCandidates(e,t,a=0,o=!1){if(a>100||!e.isNamed)return;let i=e.type;if(!i||M.has(i)){for(let c of e.namedChildren)this.collectCandidates(c,t,a+1);return}for(let c of x){let n=e.childForFieldName(c);if(!n?.isNamed)continue;let s=n.startPosition.row+1,g=n.endPosition.row+1,h=g-s>=3,u=[...x].some(m=>n.childForFieldName(m)!==null);h&&!u&&t.push({startLine:s,endLine:g,kind:`${i}.${c}`,fromBodyField:!0}),this.collectCandidates(n,t,a+1,!0)}if(![...x].some(c=>e.childForFieldName(c)!==null)&&!o){let c=e.startPosition.row+1,n=e.endPosition.row+1;n-c>=3&&e.namedChildren.length>0&&t.push({startLine:c,endLine:n,kind:i,fromBodyField:!1})}for(let c of e.namedChildren)this.collectCandidates(c,t,a+1)}buildEntries(e,t){let a=new Map;for(let n of e){let s=a.get(n.startLine);(!s||n.endLine>s.endLine||n.endLine===s.endLine&&n.fromBodyField&&!s.fromBodyField)&&a.set(n.startLine,n)}let o=[...a.values()].sort((n,s)=>n.startLine-s.startLine||s.endLine-n.endLine),i=[];for(let n of o)i.some(g=>g.startLine<n.startLine&&g.endLine===n.endLine)||i.push(n);let l=new Map;for(let n of i){let s=P(t,n.startLine,n.endLine);l.set(s,(l.get(s)??0)+1)}let c=new Map;return i.map(n=>{let s=P(t,n.startLine,n.endLine),g=l.get(s)??1,h=(c.get(s)??0)+1;c.set(s,h);let u=g>1?h:void 0;return{name:n.kind,kind:n.kind,startLine:n.startLine,endLine:n.endLine,depth:i.filter(m=>m!==n&&m.startLine<=n.startLine&&m.endLine>=n.endLine&&(m.startLine<n.startLine||m.endLine>n.endLine)).length,hash:s,blockHash:s,...u!==void 0&&{occurrence:u},beginAnchor:f("begin",s,n.startLine,u),endScopeAnchor:f("end",s,n.endLine,u),scopeBeginAnchor:f("begin",s,n.startLine,u),scopeEndAnchor:f("end",s,n.endLine,u)}})}};export{D as a,U as b,v as c};
|