@shanepadgett/tau-agent 0.28.0 → 0.28.1
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.
|
@@ -83,6 +83,12 @@ export type Decl = {
|
|
|
83
83
|
endOffset: number;
|
|
84
84
|
/** Decl start → body open; signature = source.slice(startOffset, signatureEndOffset). */
|
|
85
85
|
signatureEndOffset: number;
|
|
86
|
+
/** Initializer/body spans replaced with compact markers when a signature cannot be one contiguous source slice. */
|
|
87
|
+
signatureOmissions?: Array<{
|
|
88
|
+
startOffset: number;
|
|
89
|
+
endOffset: number;
|
|
90
|
+
replacement: string;
|
|
91
|
+
}>;
|
|
86
92
|
/** Absent when no body. */
|
|
87
93
|
bodyStartOffset?: number;
|
|
88
94
|
bodyEndOffset?: number;
|
|
@@ -300,6 +300,32 @@ function valueIsFunction(value: Node | null): boolean {
|
|
|
300
300
|
);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
function compactInitializer(value: Node): Decl["signatureOmissions"] {
|
|
304
|
+
const omissions: NonNullable<Decl["signatureOmissions"]> = [];
|
|
305
|
+
for (const callable of value.descendantsOfType([
|
|
306
|
+
ARROW_FUNCTION,
|
|
307
|
+
FUNCTION_EXPRESSION,
|
|
308
|
+
FUNCTION_DECLARATION,
|
|
309
|
+
GENERATOR_FUNCTION_DECLARATION,
|
|
310
|
+
])) {
|
|
311
|
+
const body = field(callable, "body");
|
|
312
|
+
if (body === null) continue;
|
|
313
|
+
if (
|
|
314
|
+
omissions.some((omission) => body.startIndex >= omission.startOffset && body.endIndex <= omission.endOffset)
|
|
315
|
+
) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
omissions.push({
|
|
319
|
+
startOffset: body.startIndex,
|
|
320
|
+
endOffset: body.endIndex,
|
|
321
|
+
replacement: body.type === "statement_block" ? "{ … }" : "…",
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
if (omissions.length > 0) return omissions;
|
|
325
|
+
if (value.startPosition.row === value.endPosition.row) return undefined;
|
|
326
|
+
return [{ startOffset: value.startIndex, endOffset: value.endIndex, replacement: "…" }];
|
|
327
|
+
}
|
|
328
|
+
|
|
303
329
|
function walkStatementList(nodes: readonly Node[], owner: string, source: string, exportedDefault: boolean): Decl[] {
|
|
304
330
|
const decls: Decl[] = [];
|
|
305
331
|
for (const node of nodes) {
|
|
@@ -482,7 +508,10 @@ function declsFromExport(node: Node, owner: string, source: string): Decl[] {
|
|
|
482
508
|
},
|
|
483
509
|
body,
|
|
484
510
|
);
|
|
485
|
-
if (body === null)
|
|
511
|
+
if (body === null) {
|
|
512
|
+
decl.signatureEndOffset = node.endIndex;
|
|
513
|
+
decl.signatureOmissions = compactInitializer(value);
|
|
514
|
+
}
|
|
486
515
|
return [applyDoc(decl, doc)];
|
|
487
516
|
}
|
|
488
517
|
|
|
@@ -523,7 +552,10 @@ function variableDecls(node: Node, owner: string, exported: boolean, doc: DocSpa
|
|
|
523
552
|
},
|
|
524
553
|
body,
|
|
525
554
|
);
|
|
526
|
-
if (body === null)
|
|
555
|
+
if (body === null) {
|
|
556
|
+
decl.signatureEndOffset = spanNode.endIndex;
|
|
557
|
+
if (value !== null) decl.signatureOmissions = compactInitializer(value);
|
|
558
|
+
}
|
|
527
559
|
out.push(i === 0 ? applyDoc(decl, doc) : decl);
|
|
528
560
|
}
|
|
529
561
|
return out;
|
|
@@ -583,6 +615,9 @@ function classMembers(body: Node, owner: string, source: string): Decl[] {
|
|
|
583
615
|
doc,
|
|
584
616
|
visibilityOf(node),
|
|
585
617
|
);
|
|
618
|
+
if (decl !== undefined && !isFn && value !== null) {
|
|
619
|
+
decl.signatureOmissions = compactInitializer(value);
|
|
620
|
+
}
|
|
586
621
|
if (decl !== undefined) out.push(decl);
|
|
587
622
|
continue;
|
|
588
623
|
}
|
|
@@ -4,7 +4,20 @@ import type { Decl } from "./ir.ts";
|
|
|
4
4
|
|
|
5
5
|
/** Decl signature: [startOffset, signatureEndOffset) — no docs, no body. */
|
|
6
6
|
export function signatureText(decl: Decl, source: string): string {
|
|
7
|
-
return
|
|
7
|
+
return signatureSlice(decl, source, decl.startOffset);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function signatureSlice(decl: Decl, source: string, startOffset: number): string {
|
|
11
|
+
if (decl.signatureOmissions === undefined) return source.slice(startOffset, decl.signatureEndOffset);
|
|
12
|
+
|
|
13
|
+
let text = "";
|
|
14
|
+
let cursor = startOffset;
|
|
15
|
+
for (const omission of decl.signatureOmissions) {
|
|
16
|
+
if (omission.startOffset < cursor || omission.endOffset > decl.signatureEndOffset) continue;
|
|
17
|
+
text += source.slice(cursor, omission.startOffset) + omission.replacement;
|
|
18
|
+
cursor = omission.endOffset;
|
|
19
|
+
}
|
|
20
|
+
return text + source.slice(cursor, decl.signatureEndOffset);
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
/** Attached doc comment text, or undefined when none. */
|
|
@@ -27,5 +40,5 @@ export function signatureWithDocsText(decl: Decl, source: string): string {
|
|
|
27
40
|
if (decl.docStartOffset === undefined || decl.docEndOffset === undefined) {
|
|
28
41
|
return signatureText(decl, source);
|
|
29
42
|
}
|
|
30
|
-
return
|
|
43
|
+
return signatureSlice(decl, source, decl.docStartOffset);
|
|
31
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shanepadgett/tau-agent",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "Tau is a custom agentic harness built with pi extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ast-grep/wasm": "0.45.0",
|
|
38
|
-
"@shanepadgett/tau-tui": "0.28.
|
|
38
|
+
"@shanepadgett/tau-tui": "0.28.1",
|
|
39
39
|
"@vscode/tree-sitter-wasm": "0.3.1",
|
|
40
40
|
"image-size": "2.0.2",
|
|
41
41
|
"smol-toml": "1.7.0",
|