@shanepadgett/tau-agent 0.27.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.
- package/extensions/context/sync.ts +1 -9
- package/extensions/context-pruning/prune.ts +2 -2
- package/extensions/explore/README.md +13 -21
- package/extensions/explore/ast/adapter.ts +97 -0
- package/extensions/explore/ast/engine.ts +470 -0
- package/extensions/explore/ast/format/ast-search.ts +97 -0
- package/extensions/explore/ast/format/composite.ts +26 -0
- package/extensions/explore/ast/format/context.ts +66 -0
- package/extensions/explore/ast/format/deps.ts +86 -0
- package/extensions/explore/ast/format/discover.ts +85 -0
- package/extensions/explore/ast/format/impact.ts +105 -0
- package/extensions/explore/ast/format/outline.ts +66 -0
- package/extensions/explore/ast/format/relationships.ts +81 -0
- package/extensions/explore/ast/format/show.ts +38 -0
- package/extensions/explore/ast/grammars/kotlin.wasm +0 -0
- package/extensions/explore/ast/grammars/manifest.json +41 -0
- package/extensions/explore/ast/grammars/manifest.ts +99 -0
- package/extensions/explore/ast/grammars/odin.wasm +0 -0
- package/extensions/explore/ast/grammars/swift.wasm +0 -0
- package/extensions/explore/ast/graph/file-graph.ts +360 -0
- package/extensions/explore/ast/graph/relationships.ts +597 -0
- package/extensions/explore/ast/identity.ts +119 -0
- package/extensions/explore/ast/ir.ts +136 -0
- package/extensions/explore/ast/languages/csharp-file-deps.ts +189 -0
- package/extensions/explore/ast/languages/csharp.ts +493 -0
- package/extensions/explore/ast/languages/file-dep-util.ts +120 -0
- package/extensions/explore/ast/languages/fixtures/sample.cs +17 -0
- package/extensions/explore/ast/languages/fixtures/sample.java +21 -0
- package/extensions/explore/ast/languages/fixtures/sample.kt +15 -0
- package/extensions/explore/ast/languages/fixtures/sample.odin +28 -0
- package/extensions/explore/ast/languages/fixtures/sample.rs +31 -0
- package/extensions/explore/ast/languages/fixtures/sample.swift +25 -0
- package/extensions/explore/ast/languages/go-file-deps.ts +139 -0
- package/extensions/explore/ast/languages/go.ts +545 -0
- package/extensions/explore/ast/languages/java.ts +412 -0
- package/extensions/explore/ast/languages/jvm-file-deps.ts +217 -0
- package/extensions/explore/ast/languages/kotlin.ts +611 -0
- package/extensions/explore/ast/languages/odin-file-deps.ts +175 -0
- package/extensions/explore/ast/languages/odin.ts +407 -0
- package/extensions/explore/ast/languages/rust-file-deps.ts +159 -0
- package/extensions/explore/ast/languages/rust.ts +506 -0
- package/extensions/explore/ast/languages/swift-file-deps.ts +59 -0
- package/extensions/explore/ast/languages/swift.ts +466 -0
- package/extensions/explore/ast/languages/tree.ts +220 -0
- package/extensions/explore/ast/languages/typescript-file-deps.ts +259 -0
- package/extensions/explore/ast/languages/typescript-package-surface.ts +440 -0
- package/extensions/explore/ast/languages/typescript.ts +751 -0
- package/extensions/explore/ast/markdown.ts +145 -0
- package/extensions/explore/ast/package-surface.ts +42 -0
- package/extensions/explore/ast/queries/ast-search.ts +306 -0
- package/extensions/explore/ast/queries/composite-target.ts +77 -0
- package/extensions/explore/ast/queries/context.ts +406 -0
- package/extensions/explore/ast/queries/discover.ts +427 -0
- package/extensions/explore/ast/queries/impact.ts +250 -0
- package/extensions/explore/ast/queries/outline.ts +203 -0
- package/extensions/explore/ast/queries/show.ts +262 -0
- package/extensions/explore/ast/query.ts +48 -0
- package/extensions/explore/ast/read/hook.ts +125 -0
- package/extensions/explore/ast/read/policy.ts +55 -0
- package/extensions/explore/ast/registry.ts +120 -0
- package/extensions/explore/ast/scan.ts +76 -0
- package/extensions/explore/ast/slice.ts +44 -0
- package/extensions/explore/ast/tools/ast-search.ts +138 -0
- package/extensions/explore/ast/tools/context.ts +126 -0
- package/extensions/explore/ast/tools/deps.ts +72 -0
- package/extensions/explore/ast/tools/discover.ts +208 -0
- package/extensions/explore/ast/tools/impact.ts +135 -0
- package/extensions/explore/ast/tools/outline.ts +200 -0
- package/extensions/explore/ast/tools/relationships.ts +160 -0
- package/extensions/explore/ast/tools/render.ts +121 -0
- package/extensions/explore/ast/tools/reverse-deps.ts +72 -0
- package/extensions/explore/ast/tools/show.ts +116 -0
- package/extensions/explore/guidance.ts +52 -0
- package/extensions/explore/index.ts +82 -92
- package/extensions/explore/read/autoread.ts +118 -0
- package/extensions/explore/settings.ts +49 -31
- package/extensions/explore/traverse.ts +254 -91
- package/extensions/handoff/index.ts +1 -1
- package/extensions/publish/index.ts +18 -85
- package/extensions/publish/publish-ui.ts +0 -4
- package/extensions/soul/README.md +7 -4
- package/extensions/soul/index.ts +11 -5
- package/extensions/soul/prompt.ts +31 -13
- package/extensions/soul/settings.ts +7 -2
- package/extensions/subagent/agents/context-sync.md +6 -10
- package/extensions/subagent/agents/review.md +24 -55
- package/extensions/subagent/agents/scout.md +38 -115
- package/extensions/subagent/run.ts +1 -1
- package/extensions/tau-help/help.md +2 -4
- package/package.json +6 -4
- package/schemas/tau.schema.json +35 -30
- package/{extensions/explore → shared}/autoread.ts +21 -7
- package/shared/events.ts +1 -1
- package/shared/full-file-knowledge.ts +49 -0
- package/extensions/explore/ast-guidance.ts +0 -67
- package/extensions/explore/ast-languages.ts +0 -61
- package/extensions/explore/ast-tools.ts +0 -1994
- package/extensions/explore/ast-worker.ts +0 -1025
- package/extensions/explore/find.ts +0 -147
- package/extensions/explore/full-file-knowledge.ts +0 -234
- package/extensions/explore/grep.ts +0 -749
- package/extensions/explore/limits.ts +0 -22
- package/extensions/explore/ls.ts +0 -113
- package/extensions/explore/orientation-state.ts +0 -280
- package/extensions/explore/path-display.ts +0 -41
- package/extensions/explore/path-tree.ts +0 -150
- package/extensions/explore/read-cache.ts +0 -273
- package/extensions/explore/read-snapshots.ts +0 -57
- package/extensions/explore/read-stats-panel.ts +0 -176
- package/extensions/explore/read-stats.ts +0 -138
- package/extensions/explore/read.ts +0 -372
- package/extensions/explore/result.ts +0 -29
- package/native-bin/darwin-arm64/tau-ast +0 -0
|
@@ -1,113 +1,103 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { loadTauExtensionSettings } from "../../shared/settings/load.ts";
|
|
3
|
+
import { onTauEvent } from "../../shared/events.ts";
|
|
5
4
|
import { createTemporaryOutputStore } from "../../shared/temporary-output-store.ts";
|
|
6
|
-
import { createToolRowStateStore } from "../../shared/tool-row-state.
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
import { createToolRowStateStore } from "../../shared/tool-row-state.ts";
|
|
6
|
+
import { createExploreEngine, type ExploreEngine } from "./ast/engine.ts";
|
|
7
|
+
import { createFileGraph, type ExploreFileGraph } from "./ast/graph/file-graph.ts";
|
|
8
|
+
import { registerReadOutlineHook } from "./ast/read/hook.ts";
|
|
9
|
+
import { createAstSearchTool } from "./ast/tools/ast-search.ts";
|
|
10
|
+
import { createContextTool } from "./ast/tools/context.ts";
|
|
11
|
+
import { createDepsTool } from "./ast/tools/deps.ts";
|
|
12
|
+
import { createDiscoverTool } from "./ast/tools/discover.ts";
|
|
13
|
+
import { createImpactTool } from "./ast/tools/impact.ts";
|
|
14
|
+
import { createOutlineTool } from "./ast/tools/outline.ts";
|
|
15
|
+
import {
|
|
16
|
+
createCalleesTool,
|
|
17
|
+
createCallersTool,
|
|
18
|
+
createImplementationsTool,
|
|
19
|
+
createReferencesTool,
|
|
20
|
+
} from "./ast/tools/relationships.ts";
|
|
21
|
+
import { createReverseDepsTool } from "./ast/tools/reverse-deps.ts";
|
|
22
|
+
import { createShowTool } from "./ast/tools/show.ts";
|
|
23
|
+
import { registerExploreGuidance } from "./guidance.ts";
|
|
24
|
+
import { registerExploreAutoread } from "./read/autoread.ts";
|
|
20
25
|
|
|
21
26
|
export default function exploreExtension(pi: ExtensionAPI): void {
|
|
22
|
-
let settings = exploreSettings.defaults;
|
|
23
27
|
const rowState = createToolRowStateStore(pi, "explore.tool-row-state");
|
|
24
|
-
const readCache = createReadCacheStore();
|
|
25
|
-
const readSnapshots = createReadSnapshotStore();
|
|
26
|
-
const astClient = new AstWorkerClient();
|
|
27
|
-
const orientation = createOrientationState(() => astClient.supportedLanguages());
|
|
28
28
|
const temporaryOutput = createTemporaryOutputStore();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
pi.registerTool(
|
|
51
|
-
pi.registerTool(
|
|
52
|
-
pi.registerTool(
|
|
53
|
-
pi.registerTool(
|
|
54
|
-
pi.registerTool(
|
|
55
|
-
pi.registerTool(
|
|
56
|
-
pi.registerTool(
|
|
57
|
-
pi.registerTool(
|
|
58
|
-
pi.registerTool(
|
|
59
|
-
pi.registerTool(
|
|
60
|
-
pi.registerTool(
|
|
61
|
-
pi.registerTool(
|
|
62
|
-
pi
|
|
63
|
-
pi
|
|
64
|
-
pi
|
|
65
|
-
|
|
66
|
-
cwd: ctx.cwd,
|
|
67
|
-
workerLanguages: () => astClient.supportedLanguages(),
|
|
68
|
-
discoveryBudget: AST_DISCOVERY_BUDGET,
|
|
69
|
-
});
|
|
70
|
-
return guidance ? { systemPrompt: `${event.systemPrompt}\n\n${guidance}` } : undefined;
|
|
71
|
-
});
|
|
72
|
-
pi.registerCommand("read-stats", {
|
|
73
|
-
description: "Show estimated read token and cost savings for this session",
|
|
74
|
-
async handler(_args, ctx) {
|
|
75
|
-
if (ctx.mode !== "tui") {
|
|
76
|
-
ctx.ui.notify("Read stats require TUI mode", "error");
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
await showReadStats(ctx, orientation);
|
|
80
|
-
},
|
|
81
|
-
});
|
|
29
|
+
let engine: ExploreEngine | undefined;
|
|
30
|
+
let graph: ExploreFileGraph | undefined;
|
|
31
|
+
|
|
32
|
+
const engineFor = (cwd: string): ExploreEngine => {
|
|
33
|
+
const absoluteCwd = resolve(cwd);
|
|
34
|
+
if (engine !== undefined && engine.cwd === absoluteCwd) return engine;
|
|
35
|
+
engine?.shutdown();
|
|
36
|
+
graph?.clear();
|
|
37
|
+
engine = createExploreEngine({ cwd: absoluteCwd });
|
|
38
|
+
graph = createFileGraph(engine);
|
|
39
|
+
return engine;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const graphFor = (cwd: string): ExploreFileGraph => {
|
|
43
|
+
engineFor(cwd);
|
|
44
|
+
if (graph === undefined) {
|
|
45
|
+
throw new Error("Explore file graph failed to initialize");
|
|
46
|
+
}
|
|
47
|
+
return graph;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
pi.registerTool(createOutlineTool(rowState, temporaryOutput, engineFor));
|
|
51
|
+
pi.registerTool(createShowTool(rowState, engineFor));
|
|
52
|
+
pi.registerTool(createDiscoverTool(rowState, temporaryOutput, engineFor));
|
|
53
|
+
pi.registerTool(createAstSearchTool(rowState, temporaryOutput, engineFor));
|
|
54
|
+
pi.registerTool(createDepsTool(rowState, engineFor, graphFor));
|
|
55
|
+
pi.registerTool(createReverseDepsTool(rowState, engineFor, graphFor));
|
|
56
|
+
pi.registerTool(createCallersTool(rowState, engineFor, graphFor));
|
|
57
|
+
pi.registerTool(createCalleesTool(rowState, engineFor, graphFor));
|
|
58
|
+
pi.registerTool(createReferencesTool(rowState, engineFor, graphFor));
|
|
59
|
+
pi.registerTool(createImplementationsTool(rowState, engineFor, graphFor));
|
|
60
|
+
pi.registerTool(createImpactTool(rowState, temporaryOutput, engineFor, graphFor));
|
|
61
|
+
pi.registerTool(createContextTool(rowState, temporaryOutput, engineFor, graphFor));
|
|
62
|
+
registerReadOutlineHook(pi, engineFor);
|
|
63
|
+
registerExploreAutoread(pi, rowState, engineFor);
|
|
64
|
+
registerExploreGuidance(pi, engineFor);
|
|
65
|
+
|
|
82
66
|
pi.on("session_start", async (_event, ctx) => {
|
|
83
|
-
settings = await loadTauExtensionSettings(ctx, exploreSettings);
|
|
84
67
|
await temporaryOutput.shutdown();
|
|
85
68
|
await temporaryOutput.start();
|
|
86
69
|
rowState.clear();
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
engine?.shutdown();
|
|
71
|
+
graph?.clear();
|
|
72
|
+
engine = createExploreEngine({ cwd: ctx.cwd });
|
|
73
|
+
graph = createFileGraph(engine);
|
|
89
74
|
});
|
|
75
|
+
|
|
90
76
|
onTauEvent(pi, "explore.ast", "tau:file-mutation.applied", (event) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
})),
|
|
77
|
+
if (engine === undefined) return;
|
|
78
|
+
const paths = event.changes.flatMap((change) => {
|
|
79
|
+
const main = resolve(event.cwd, change.path);
|
|
80
|
+
if (change.move === undefined) return [main];
|
|
81
|
+
return [main, resolve(event.cwd, change.move.from), resolve(event.cwd, change.move.to)];
|
|
82
|
+
});
|
|
83
|
+
engine.invalidate(paths);
|
|
84
|
+
const topologyChanged = event.changes.some(
|
|
85
|
+
(change) => change.kind === "add" || change.kind === "delete" || change.move !== undefined,
|
|
101
86
|
);
|
|
87
|
+
if (topologyChanged) graph?.clear();
|
|
88
|
+
else graph?.invalidate(paths);
|
|
102
89
|
});
|
|
103
|
-
|
|
90
|
+
|
|
104
91
|
pi.on("session_tree", () => {
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
engine?.clear();
|
|
93
|
+
graph?.clear();
|
|
107
94
|
});
|
|
95
|
+
|
|
108
96
|
pi.on("session_shutdown", async () => {
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
engine?.shutdown();
|
|
98
|
+
engine = undefined;
|
|
99
|
+
graph?.clear();
|
|
100
|
+
graph = undefined;
|
|
111
101
|
await temporaryOutput.shutdown();
|
|
112
102
|
});
|
|
113
103
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { prepareAutoreadMessage, registerAutoread, type PreparedAutoreadMessage } from "../../../shared/autoread.ts";
|
|
5
|
+
import { createCompleteFileMeta } from "../../../shared/full-file-knowledge.ts";
|
|
6
|
+
import { loadTauExtensionSettings } from "../../../shared/settings/load.ts";
|
|
7
|
+
import type { ToolRowStateStore } from "../../../shared/tool-row-state.ts";
|
|
8
|
+
import type { ExploreEngine } from "../ast/engine.ts";
|
|
9
|
+
import { formatOutlineFile } from "../ast/format/outline.ts";
|
|
10
|
+
import { formatLargeReadOutline, shouldOutlineFullRead, type ExploreReadSettings } from "../ast/read/policy.ts";
|
|
11
|
+
import { outlinePath } from "../ast/queries/outline.ts";
|
|
12
|
+
import exploreSettings from "../settings.ts";
|
|
13
|
+
import { resolveExplorePath } from "../traverse.ts";
|
|
14
|
+
|
|
15
|
+
const DEFAULT_OUTLINE_OPTIONS = {
|
|
16
|
+
includePrivate: false,
|
|
17
|
+
includeDocs: false,
|
|
18
|
+
names: [] as readonly string[],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function registerExploreAutoread(
|
|
22
|
+
pi: ExtensionAPI,
|
|
23
|
+
rowState: ToolRowStateStore,
|
|
24
|
+
engineFor: (cwd: string) => ExploreEngine,
|
|
25
|
+
): void {
|
|
26
|
+
let readSettings: ExploreReadSettings = exploreSettings.defaults.read;
|
|
27
|
+
|
|
28
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
29
|
+
const settings = await loadTauExtensionSettings(ctx, exploreSettings);
|
|
30
|
+
readSettings = settings.read;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
registerAutoread(pi, rowState, async (options) => {
|
|
34
|
+
return prepareExploreAutoreadMessage({
|
|
35
|
+
...options,
|
|
36
|
+
engine: engineFor(options.cwd),
|
|
37
|
+
readSettings,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function prepareExploreAutoreadMessage(options: {
|
|
43
|
+
rowId: string;
|
|
44
|
+
path: string;
|
|
45
|
+
cwd: string;
|
|
46
|
+
source: string;
|
|
47
|
+
batchId: string;
|
|
48
|
+
signal: AbortSignal | undefined;
|
|
49
|
+
isLifecycleCurrent: () => boolean;
|
|
50
|
+
maximumBytes?: number;
|
|
51
|
+
engine: ExploreEngine;
|
|
52
|
+
readSettings: ExploreReadSettings;
|
|
53
|
+
}): Promise<PreparedAutoreadMessage> {
|
|
54
|
+
const { engine, readSettings, ...shared } = options;
|
|
55
|
+
if (!readSettings.enabled) return prepareAutoreadMessage(shared);
|
|
56
|
+
|
|
57
|
+
const absolutePath = resolveExplorePath(options.cwd, options.path);
|
|
58
|
+
if (engine.registry.adapterForPath(absolutePath) === undefined) {
|
|
59
|
+
return prepareAutoreadMessage(shared);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
assertPreparationCurrent(options.signal, options.isLifecycleCurrent);
|
|
63
|
+
|
|
64
|
+
let lineCount: number;
|
|
65
|
+
try {
|
|
66
|
+
const source = await engine.sourceForFile(absolutePath);
|
|
67
|
+
lineCount = source.ir.lineCount;
|
|
68
|
+
} catch {
|
|
69
|
+
return prepareAutoreadMessage(shared);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!shouldOutlineFullRead(lineCount, readSettings.structureThresholdLines)) {
|
|
73
|
+
return prepareAutoreadMessage(shared);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const abort = options.signal ?? new AbortController().signal;
|
|
77
|
+
const result = await outlinePath(engine, options.path, DEFAULT_OUTLINE_OPTIONS, abort);
|
|
78
|
+
assertPreparationCurrent(options.signal, options.isLifecycleCurrent);
|
|
79
|
+
if (result.mode !== "file") {
|
|
80
|
+
return prepareAutoreadMessage(shared);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const outlineBody =
|
|
84
|
+
result.file.rows.length === 0 ? "No declarations" : formatOutlineFile(result.file, engine.cwd, false);
|
|
85
|
+
const outlineText = formatLargeReadOutline(outlineBody);
|
|
86
|
+
const messageContent = `${options.path}\n${outlineText}`;
|
|
87
|
+
const pathKey = resolve(options.cwd, options.path);
|
|
88
|
+
const readCache = createCompleteFileMeta({
|
|
89
|
+
pathKey,
|
|
90
|
+
presentation: "plain",
|
|
91
|
+
servedHash: createHash("sha256").update(outlineText, "utf8").digest("hex"),
|
|
92
|
+
mode: "baseline",
|
|
93
|
+
sourceText: outlineText,
|
|
94
|
+
returnedText: messageContent,
|
|
95
|
+
totalLines: lineCount,
|
|
96
|
+
summary: `outline (${lineCount} lines)`,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
customType: "tau.autoread",
|
|
101
|
+
content: messageContent,
|
|
102
|
+
display: true,
|
|
103
|
+
details: {
|
|
104
|
+
rowId: options.rowId,
|
|
105
|
+
path: options.path,
|
|
106
|
+
cwd: options.cwd,
|
|
107
|
+
source: options.source,
|
|
108
|
+
batchId: options.batchId,
|
|
109
|
+
status: "read",
|
|
110
|
+
readCache,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function assertPreparationCurrent(signal: AbortSignal | undefined, isLifecycleCurrent: () => boolean): void {
|
|
116
|
+
signal?.throwIfAborted();
|
|
117
|
+
if (!isLifecycleCurrent()) throw new Error("Autoread preparation crossed a session lifecycle boundary");
|
|
118
|
+
}
|
|
@@ -1,46 +1,64 @@
|
|
|
1
|
-
import { relative, resolve } from "node:path";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
|
-
import { matchGlob, posixPath } from "../../shared/glob.ts";
|
|
4
2
|
import { defineTauExtensionSettings } from "../../shared/settings/define.ts";
|
|
5
3
|
|
|
6
|
-
export interface ExploreReadGateSettings {
|
|
7
|
-
includeGlobs: string[];
|
|
8
|
-
excludeGlobs: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
4
|
export default defineTauExtensionSettings({
|
|
12
5
|
key: "explore",
|
|
13
6
|
defaults: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
context: {
|
|
8
|
+
defaultBudgetTokens: 8000 as number,
|
|
9
|
+
},
|
|
10
|
+
read: {
|
|
11
|
+
enabled: true as boolean,
|
|
12
|
+
structureThresholdLines: 200 as number,
|
|
13
|
+
maxRangeLines: 200 as number,
|
|
17
14
|
},
|
|
18
15
|
},
|
|
19
16
|
schema: Type.Object(
|
|
20
17
|
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
context: Type.Optional(
|
|
19
|
+
Type.Object(
|
|
20
|
+
{
|
|
21
|
+
defaultBudgetTokens: Type.Optional(
|
|
22
|
+
Type.Integer({
|
|
23
|
+
default: 8000,
|
|
24
|
+
minimum: 1,
|
|
25
|
+
description: "Default token budget for context when the caller omits budget.",
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
},
|
|
29
|
+
{ additionalProperties: false },
|
|
30
|
+
),
|
|
31
|
+
),
|
|
32
|
+
read: Type.Optional(
|
|
33
|
+
Type.Object(
|
|
34
|
+
{
|
|
35
|
+
enabled: Type.Optional(
|
|
36
|
+
Type.Boolean({
|
|
37
|
+
default: true,
|
|
38
|
+
description:
|
|
39
|
+
"Master switch for Explore structural read overlay and large-source autoread outline path. When false, Pi read and autoread keep ordinary full bodies.",
|
|
40
|
+
}),
|
|
41
|
+
),
|
|
42
|
+
structureThresholdLines: Type.Optional(
|
|
43
|
+
Type.Integer({
|
|
44
|
+
default: 200,
|
|
45
|
+
minimum: 1,
|
|
46
|
+
description:
|
|
47
|
+
"Registered source at or under this line count may be full-read. Above it, full read model-visible result is outline only.",
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
maxRangeLines: Type.Optional(
|
|
51
|
+
Type.Integer({
|
|
52
|
+
default: 200,
|
|
53
|
+
minimum: 1,
|
|
54
|
+
description: "Maximum lines returned by one ranged read on registered source.",
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
{ additionalProperties: false },
|
|
59
|
+
),
|
|
34
60
|
),
|
|
35
61
|
},
|
|
36
62
|
{ additionalProperties: false },
|
|
37
63
|
),
|
|
38
64
|
});
|
|
39
|
-
|
|
40
|
-
export function matchesExploreReadGate(path: string, cwd: string, settings: ExploreReadGateSettings): boolean {
|
|
41
|
-
const projectPath = posixPath(relative(resolve(cwd), resolve(path)));
|
|
42
|
-
return (
|
|
43
|
-
settings.includeGlobs.some((pattern) => matchGlob(pattern, projectPath)) &&
|
|
44
|
-
!settings.excludeGlobs.some((pattern) => matchGlob(pattern, projectPath))
|
|
45
|
-
);
|
|
46
|
-
}
|