@mrclrchtr/supi-code-intelligence 11.2.0 → 11.4.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/CHANGELOG.md +30 -0
- package/README.md +19 -9
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +40 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +151 -44
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +318 -58
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +68 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +9 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +9 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
- package/package.json +6 -5
- package/src/analysis/health/server-status.ts +6 -2
- package/src/analysis/helpers.ts +0 -7
- package/src/analysis/relations/implementations.ts +5 -0
- package/src/analysis/relations/references.ts +5 -0
- package/src/analysis/search/exclusions.ts +47 -0
- package/src/analysis/search/paths.ts +32 -9
- package/src/analysis/target/anchored-structural.ts +3 -8
- package/src/analysis/target/anchored.ts +4 -20
- package/src/analysis/target/file-merge.ts +162 -0
- package/src/analysis/target/file-outline-omissions.ts +146 -0
- package/src/analysis/target/file-refinement.ts +7 -7
- package/src/analysis/target/file.ts +44 -156
- package/src/analysis/target/identity.ts +1 -1
- package/src/analysis/target/latex-label-container.ts +6 -6
- package/src/analysis/target/latex-section-anchor.ts +6 -6
- package/src/analysis/target/resolution.ts +18 -0
- package/src/analysis/target/symbol.ts +44 -12
- package/src/analysis/target/types.ts +38 -7
- package/src/api.ts +1 -1
- package/src/app/app.ts +9 -3
- package/src/extension.ts +17 -11
- package/src/session/graph/collect.ts +3 -10
- package/src/session/graph-types.ts +5 -1
- package/src/session/graph-workflow.ts +6 -4
- package/src/session/inspect/collect.ts +8 -2
- package/src/session/inspect/file-point.ts +2 -3
- package/src/session/inspect-workflow.ts +1 -1
- package/src/session/orientation/collect.ts +54 -16
- package/src/session/orientation/context-sections.ts +2 -3
- package/src/session/orientation/facts.ts +9 -1
- package/src/session/orientation/workspace-context.ts +3 -0
- package/src/session/orientation-types.ts +3 -0
- package/src/session/orientation-workflow.ts +24 -8
- package/src/session/refactor-identity.ts +76 -0
- package/src/session/refactor-workflow.ts +14 -16
- package/src/session/session.ts +87 -12
- package/src/session/target-store.ts +3 -18
- package/src/session/target-workflow.ts +56 -37
- package/src/substrate/lsp/recovery.ts +5 -5
- package/src/tool/code_find/render.ts +8 -4
- package/src/tool/code_find/result.ts +78 -6
- package/src/tool/code_find/spec.ts +4 -3
- package/src/tool/code_find/structured.ts +25 -9
- package/src/tool/code_graph/details.ts +1 -0
- package/src/tool/code_graph/display.ts +1 -1
- package/src/tool/code_graph/guidance.ts +1 -1
- package/src/tool/code_graph/markdown.ts +11 -6
- package/src/tool/code_graph/read-next.ts +38 -9
- package/src/tool/code_graph/reference-selection.ts +30 -0
- package/src/tool/code_graph/result.ts +25 -118
- package/src/tool/code_graph/section.ts +137 -0
- package/src/tool/code_graph/spec.ts +3 -3
- package/src/tool/code_graph/structured.ts +17 -6
- package/src/tool/code_health/display-paths.ts +92 -0
- package/src/tool/code_health/file-scope-markdown.ts +3 -2
- package/src/tool/code_health/result.ts +4 -2
- package/src/tool/code_health/spec.ts +3 -3
- package/src/tool/code_health/structured-schema.ts +44 -44
- package/src/tool/code_inspect/spec.ts +5 -1
- package/src/tool/code_inspect/structured.ts +1 -2
- package/src/tool/code_orientation/directory-navigation.ts +20 -31
- package/src/tool/code_orientation/execute.ts +1 -1
- package/src/tool/code_orientation/result.ts +22 -5
- package/src/tool/code_orientation/structured-schema.ts +46 -36
- package/src/tool/code_orientation/structured-workspace.ts +2 -1
- package/src/tool/code_orientation/structured.ts +6 -12
- package/src/tool/code_orientation/workspace-format.ts +2 -5
- package/src/tool/code_orientation/workspace-output.ts +40 -13
- package/src/tool/code_orientation/workspace-sections.ts +48 -4
- package/src/tool/code_refactor_apply/result.ts +1 -1
- package/src/tool/code_refactor_plan/result.ts +2 -1
- package/src/tool/code_refactor_plan/structured.ts +2 -3
- package/src/tool/code_resolve/guidance.ts +1 -1
- package/src/tool/code_resolve/markdown.ts +127 -64
- package/src/tool/code_resolve/result.ts +41 -25
- package/src/tool/code_resolve/structured.ts +49 -18
- package/src/tool/result/model-budget.ts +2 -2
- package/src/tool/result/refactor.ts +8 -5
- package/src/tool/result/structured.ts +8 -5
- package/src/tool/result/types.ts +31 -24
- package/src/tool/schemas.ts +5 -5
- package/src/ui/status-command.ts +37 -1
- package/src/ui/status-overlay.ts +70 -51
- package/src/ui/status-presentation.ts +108 -0
- package/src/ui/tui/common.ts +10 -10
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
readNextEnclosingScope,
|
|
16
16
|
readNextTarget,
|
|
17
17
|
} from "../../analysis/read-next.ts";
|
|
18
|
+
import { isNonFileUri, toDisplayPath } from "../../analysis/search/paths.ts";
|
|
18
19
|
import { diagnosticMessageString } from "../../substrate/lsp/utils.ts";
|
|
19
20
|
import type {
|
|
20
21
|
OrientationDeps,
|
|
@@ -26,7 +27,7 @@ import type {
|
|
|
26
27
|
} from "../orientation-types.ts";
|
|
27
28
|
import type { TargetStoreEntry } from "../target-store.ts";
|
|
28
29
|
import { collectContextOrientationFacts } from "./context-facts.ts";
|
|
29
|
-
import { gatherSubstrateContext } from "./gather.ts";
|
|
30
|
+
import { gatherSubstrateContext, type SubstrateContext } from "./gather.ts";
|
|
30
31
|
|
|
31
32
|
interface TargetSectionCollection {
|
|
32
33
|
readonly items: OrientationItem[];
|
|
@@ -142,7 +143,7 @@ async function buildRequestedSection(options: {
|
|
|
142
143
|
switch (section) {
|
|
143
144
|
case "defs": {
|
|
144
145
|
const result = await buildEnrichedDefsSection(target, deps, treeContext, limit);
|
|
145
|
-
const contextFacts = targetContextFacts(treeContext, limit);
|
|
146
|
+
const contextFacts = targetContextFacts(treeContext, limit, deps.cwd);
|
|
146
147
|
const operations = treeContext?.operations;
|
|
147
148
|
const semanticObserved =
|
|
148
149
|
result.hasSemanticEvidence ||
|
|
@@ -177,10 +178,11 @@ async function buildRequestedSection(options: {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
/** Select
|
|
181
|
+
/** Select independent source observations with public locations and unchanged evidence status. */
|
|
181
182
|
function targetContextFacts(
|
|
182
183
|
treeContext: Awaited<ReturnType<typeof maybeGatherTreeContext>>,
|
|
183
184
|
limit: number,
|
|
185
|
+
cwd: string,
|
|
184
186
|
) {
|
|
185
187
|
return treeContext
|
|
186
188
|
? {
|
|
@@ -217,7 +219,7 @@ function targetContextFacts(
|
|
|
217
219
|
: null,
|
|
218
220
|
recovery: treeContext.recovery.map(({ operation, file, reason, errorRanges }) => ({
|
|
219
221
|
operation,
|
|
220
|
-
file,
|
|
222
|
+
file: toDisplayPath(cwd, file),
|
|
221
223
|
reason,
|
|
222
224
|
errorRanges: errorRanges.map(publicRange),
|
|
223
225
|
})),
|
|
@@ -225,9 +227,16 @@ function targetContextFacts(
|
|
|
225
227
|
...treeContext.operations.definition,
|
|
226
228
|
...(treeContext.definition !== null
|
|
227
229
|
? {
|
|
228
|
-
entries: treeContext.definition
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
entries: treeContext.definition.slice(0, limit).map(({ uri, range }) => ({
|
|
231
|
+
...(isNonFileUri(uri)
|
|
232
|
+
? {
|
|
233
|
+
uri,
|
|
234
|
+
navigation: "unavailable" as const,
|
|
235
|
+
reason: "Provider URI is not a local filesystem source.",
|
|
236
|
+
}
|
|
237
|
+
: { file: toDisplayPath(cwd, uri) }),
|
|
238
|
+
range: publicRange(range),
|
|
239
|
+
})),
|
|
231
240
|
collectedCount: treeContext.definition.length,
|
|
232
241
|
omittedCount: Math.max(0, treeContext.definition.length - limit),
|
|
233
242
|
}
|
|
@@ -254,9 +263,9 @@ async function buildEnrichedDefsSection(
|
|
|
254
263
|
limit: number,
|
|
255
264
|
): Promise<TargetSectionCollection> {
|
|
256
265
|
const items = buildDefinitionItems(target, deps.cwd, treeContext);
|
|
257
|
-
const recovery = treeContext?.recovery ?? [];
|
|
266
|
+
const recovery = groupedRecovery(treeContext?.recovery ?? [], deps.cwd);
|
|
258
267
|
const recoveryReason = recovery
|
|
259
|
-
.map(({
|
|
268
|
+
.map(({ operations, reason }) => `${operations.join(", ")}: ${reason}`)
|
|
260
269
|
.join("; ");
|
|
261
270
|
const recoveryRanges = uniqueRecoveryRanges(recovery);
|
|
262
271
|
const hasSemanticContext = Boolean(
|
|
@@ -379,7 +388,7 @@ async function collectDefinitionTargets(
|
|
|
379
388
|
};
|
|
380
389
|
}
|
|
381
390
|
const locations = result.data.map((definition) => ({
|
|
382
|
-
file:
|
|
391
|
+
file: toDisplayPath(deps.cwd, uriToFile(definition.uri)),
|
|
383
392
|
range: publicRange(definition.range),
|
|
384
393
|
}));
|
|
385
394
|
const evidence =
|
|
@@ -398,7 +407,7 @@ async function collectDefinitionTargets(
|
|
|
398
407
|
return {
|
|
399
408
|
items: evidence.items.map((location) => ({
|
|
400
409
|
kind: "paragraph",
|
|
401
|
-
text: `\`${location.file}:${location.range.start.line + 1}:${location.range.start.character + 1}
|
|
410
|
+
text: `\`${location.file}:${location.range.start.line + 1}:${location.range.start.character + 1}\`${isNonFileUri(location.file) ? " (provider URI; filesystem navigation unavailable)" : ""}`,
|
|
402
411
|
})),
|
|
403
412
|
facts: { definitions: evidence.items },
|
|
404
413
|
hasSemanticEvidence: true,
|
|
@@ -690,6 +699,33 @@ function uniqueRecoveryRanges(
|
|
|
690
699
|
return [...ranges.values()];
|
|
691
700
|
}
|
|
692
701
|
|
|
702
|
+
/** Group only equivalent display warnings; native per-operation observations remain untouched. */
|
|
703
|
+
function groupedRecovery(recovery: SubstrateContext["recovery"], cwd: string) {
|
|
704
|
+
const groups = new Map<
|
|
705
|
+
string,
|
|
706
|
+
{
|
|
707
|
+
file: string;
|
|
708
|
+
reason: string;
|
|
709
|
+
errorRanges: readonly SourceRange[];
|
|
710
|
+
operations: string[];
|
|
711
|
+
}
|
|
712
|
+
>();
|
|
713
|
+
for (const item of recovery) {
|
|
714
|
+
const file = toDisplayPath(cwd, item.file);
|
|
715
|
+
const key = JSON.stringify([file, item.reason, item.errorRanges]);
|
|
716
|
+
const existing = groups.get(key);
|
|
717
|
+
if (existing) existing.operations.push(item.operation);
|
|
718
|
+
else
|
|
719
|
+
groups.set(key, {
|
|
720
|
+
file,
|
|
721
|
+
reason: item.reason,
|
|
722
|
+
errorRanges: item.errorRanges,
|
|
723
|
+
operations: [item.operation],
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
return [...groups.values()];
|
|
727
|
+
}
|
|
728
|
+
|
|
693
729
|
function buildDefinitionItems(
|
|
694
730
|
target: Readonly<TargetStoreEntry> | null | undefined,
|
|
695
731
|
cwd: string,
|
|
@@ -715,14 +751,16 @@ function buildDefinitionItems(
|
|
|
715
751
|
if (treeContext?.nodeInfo?.type) {
|
|
716
752
|
items.push({ kind: "list-item", text: `Node: \`${treeContext.nodeInfo.type}\`` });
|
|
717
753
|
}
|
|
718
|
-
for (const recovery of treeContext?.recovery ?? []) {
|
|
754
|
+
for (const recovery of groupedRecovery(treeContext?.recovery ?? [], cwd)) {
|
|
719
755
|
const locations = recovery.errorRanges.map(
|
|
720
756
|
(range) => `L${range.start.line + 1}:${range.start.character + 1}`,
|
|
721
757
|
);
|
|
722
758
|
const suffix = locations.length > 0 ? ` Errors: ${locations.join(", ")}.` : "";
|
|
759
|
+
const reason = recovery.reason.trim();
|
|
760
|
+
const punctuation = /[.!?]$/.test(reason) ? "" : ".";
|
|
723
761
|
items.push({
|
|
724
762
|
kind: "paragraph",
|
|
725
|
-
text: `Partial ${recovery.
|
|
763
|
+
text: `Partial ${recovery.operations.join(", ")} evidence in \`${recovery.file}\`: ${reason}${punctuation}${suffix}`,
|
|
726
764
|
});
|
|
727
765
|
}
|
|
728
766
|
if (treeContext?.hover?.contents) {
|
|
@@ -809,7 +847,7 @@ function hoverBodyItems(lines: readonly string[]): OrientationItem[] {
|
|
|
809
847
|
}
|
|
810
848
|
|
|
811
849
|
function formatFocusTarget(target: Readonly<TargetStoreEntry>, cwd: string): string {
|
|
812
|
-
const relPath =
|
|
850
|
+
const relPath = toDisplayPath(cwd, target.file);
|
|
813
851
|
return `${relPath}:${target.displayLine}:${target.displayCharacter}`;
|
|
814
852
|
}
|
|
815
853
|
|
|
@@ -819,7 +857,7 @@ function buildNextQueries(
|
|
|
819
857
|
): string[] {
|
|
820
858
|
if (!target) return ["Use `code_orientation` for a neutral orientation summary."];
|
|
821
859
|
|
|
822
|
-
const relPath =
|
|
860
|
+
const relPath = toDisplayPath(cwd, target.file);
|
|
823
861
|
return [
|
|
824
862
|
`\`code_graph\` with \`target: { anchor: { file: "${relPath}", line: ${target.displayLine}, character: ${target.displayCharacter} } }\` for relation follow-up`,
|
|
825
863
|
];
|
|
@@ -831,7 +869,7 @@ function buildReadNextGuidance(
|
|
|
831
869
|
cwd: string,
|
|
832
870
|
): ReadNextItem[] {
|
|
833
871
|
if (!target) return [];
|
|
834
|
-
const relPath =
|
|
872
|
+
const relPath = toDisplayPath(cwd, target.file);
|
|
835
873
|
const enclosing = findEnclosingOutlineItem(target, treeContext);
|
|
836
874
|
if (enclosing) {
|
|
837
875
|
return [readNextEnclosingScope(relPath, enclosing, target.displayLine)];
|
|
@@ -12,6 +12,7 @@ import type { WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
|
|
|
12
12
|
import type { EvidenceListMetadata, EvidencePartialReason } from "../../analysis/evidence.ts";
|
|
13
13
|
import { createEvidenceList } from "../../analysis/evidence.ts";
|
|
14
14
|
import type { CodeProvider } from "../../analysis/provider.ts";
|
|
15
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
15
16
|
import type {
|
|
16
17
|
OrientationProvenance,
|
|
17
18
|
OrientationResultData,
|
|
@@ -381,9 +382,7 @@ export function filesystemProvenance(cwd: string, target: string): OrientationPr
|
|
|
381
382
|
}
|
|
382
383
|
|
|
383
384
|
export function displayPath(cwd: string, target: string): string {
|
|
384
|
-
|
|
385
|
-
if (relative.length === 0) return ".";
|
|
386
|
-
return relative.startsWith("../") || relative === ".." ? target : relative;
|
|
385
|
+
return toDisplayPath(cwd, target);
|
|
387
386
|
}
|
|
388
387
|
|
|
389
388
|
export function formatManifestValue(value: unknown): string {
|
|
@@ -75,7 +75,15 @@ export interface OrientationFacts {
|
|
|
75
75
|
readonly definitions?: readonly { readonly file: string; readonly range: SourceRange }[];
|
|
76
76
|
/** Independent context query; unavailable observations have no manufactured entries or counts. */
|
|
77
77
|
readonly contextDefinitions?: import("./gather.ts").ContextObservationStatus & {
|
|
78
|
-
readonly entries?: readonly
|
|
78
|
+
readonly entries?: readonly (
|
|
79
|
+
| { readonly file: string; readonly range: SourceRange }
|
|
80
|
+
| {
|
|
81
|
+
readonly uri: string;
|
|
82
|
+
readonly range: SourceRange;
|
|
83
|
+
readonly navigation: "unavailable";
|
|
84
|
+
readonly reason: string;
|
|
85
|
+
}
|
|
86
|
+
)[];
|
|
79
87
|
readonly collectedCount?: number;
|
|
80
88
|
readonly omittedCount?: number;
|
|
81
89
|
};
|
|
@@ -20,6 +20,8 @@ export interface WorkspaceOrientationFacts {
|
|
|
20
20
|
/** Absolute explicit focus, or null for the session working directory. */
|
|
21
21
|
readonly focus: string | null;
|
|
22
22
|
readonly maxResults: number;
|
|
23
|
+
/** True when the caller set `maxResults`; directory file lists then honor it exactly. */
|
|
24
|
+
readonly maxResultsExplicit?: boolean;
|
|
23
25
|
readonly overview?: boolean;
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -64,6 +66,7 @@ export async function orientWorkspaceContext(
|
|
|
64
66
|
cwd: options.cwd,
|
|
65
67
|
focus,
|
|
66
68
|
maxResults: request.maxResults ?? 10,
|
|
69
|
+
maxResultsExplicit: request.maxResults !== undefined,
|
|
67
70
|
}),
|
|
68
71
|
focusKind: workspaceFocusKind(request),
|
|
69
72
|
},
|
|
@@ -10,6 +10,7 @@ import type { InstructionFilesMetadata } from "../analysis/instruction-files.ts"
|
|
|
10
10
|
import type { CodeProvider } from "../analysis/provider.ts";
|
|
11
11
|
import type { ReadNextItem } from "../analysis/read-next.ts";
|
|
12
12
|
import type { TargetCandidateCompleteness } from "../analysis/target/types.ts";
|
|
13
|
+
import type { AnchoredResolutionMetadata } from "../types/index.ts";
|
|
13
14
|
import type { OrientationTargetInput, TargetSymbolKind } from "./target-input.ts";
|
|
14
15
|
import type { AnchorKind, TargetStoreEntry } from "./target-store.ts";
|
|
15
16
|
|
|
@@ -135,6 +136,8 @@ export interface OrientationResultData {
|
|
|
135
136
|
/** Captured generic workspace facts; absent for the unchanged file and symbol paths. */
|
|
136
137
|
readonly workspace?: import("./orientation/workspace-context.ts").WorkspaceOrientationFacts;
|
|
137
138
|
readonly target?: Readonly<TargetStoreEntry>;
|
|
139
|
+
/** Current anchored focus observation, separate from reusable target facts. */
|
|
140
|
+
readonly resolution?: AnchoredResolutionMetadata;
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
export type OrientationWorkflowOutcome =
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** Session-owned Orientation workflow. */
|
|
2
2
|
|
|
3
3
|
import { existsSync, statSync } from "node:fs";
|
|
4
|
-
import { relative } from "node:path";
|
|
5
4
|
import { buildArchitectureModel } from "../analysis/architecture/discovery.ts";
|
|
6
5
|
import type { ArchitectureModel } from "../analysis/architecture/model.ts";
|
|
7
6
|
import {
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
} from "../analysis/instruction-files.ts";
|
|
11
10
|
import { createStructuralCodeProvider, withSemanticRequestControl } from "../analysis/provider.ts";
|
|
12
11
|
import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
|
|
13
|
-
import { normalizePath } from "../analysis/search/paths.ts";
|
|
12
|
+
import { normalizePath, toDisplayPath } from "../analysis/search/paths.ts";
|
|
14
13
|
import { loadCodeIntelligenceConfig } from "../config.ts";
|
|
15
14
|
import type { CapabilityAdapter } from "./capability-adapter.ts";
|
|
16
15
|
import { parseOrientationWorkflowInput } from "./input/workflows.ts";
|
|
@@ -31,6 +30,8 @@ import { reportProgress, throwIfAborted, type WorkflowControl } from "./workflow
|
|
|
31
30
|
export interface OrientationWorkflowDeps extends TargetWorkflowDeps {
|
|
32
31
|
readonly capability: CapabilityAdapter;
|
|
33
32
|
readonly nativeInstructionPaths: Set<string>;
|
|
33
|
+
/** Absolute files read in full since the latest compaction; not embedded again. */
|
|
34
|
+
readonly fullyReadPaths: Set<string>;
|
|
34
35
|
readonly surfacedInstructionDirs: Set<string>;
|
|
35
36
|
/** Whether the project is trusted — controls instruction-file discovery. */
|
|
36
37
|
readonly projectTrusted: boolean;
|
|
@@ -123,10 +124,11 @@ async function orientTarget(options: {
|
|
|
123
124
|
control,
|
|
124
125
|
);
|
|
125
126
|
throwIfAborted(control);
|
|
126
|
-
if (target.kind === "
|
|
127
|
+
if (target.kind === "file-outline") {
|
|
127
128
|
return {
|
|
128
129
|
kind: "invalid-input",
|
|
129
|
-
message:
|
|
130
|
+
message:
|
|
131
|
+
"Orientation on a target requires one declaration, not a whole file. Pass one handle from the file outline as target.handle, or use focus.path for the file.",
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
if (target.kind === "disambiguation" || target.kind === "kind-mismatch") {
|
|
@@ -195,7 +197,16 @@ async function orientTarget(options: {
|
|
|
195
197
|
throwIfAborted(control);
|
|
196
198
|
return {
|
|
197
199
|
kind: "completed",
|
|
198
|
-
data: addTargetSummary(
|
|
200
|
+
data: addTargetSummary(
|
|
201
|
+
{
|
|
202
|
+
...result,
|
|
203
|
+
focusKind: "symbol",
|
|
204
|
+
...(target.resolution ? { resolution: target.resolution } : {}),
|
|
205
|
+
},
|
|
206
|
+
entry,
|
|
207
|
+
target.notes,
|
|
208
|
+
deps.cwd,
|
|
209
|
+
),
|
|
199
210
|
};
|
|
200
211
|
}
|
|
201
212
|
|
|
@@ -236,11 +247,16 @@ function addInstructionFiles(
|
|
|
236
247
|
directory: focusPath,
|
|
237
248
|
cwd: deps.cwd,
|
|
238
249
|
fileNames: config.instructionFileNames,
|
|
239
|
-
nativeContextPaths: deps.nativeInstructionPaths,
|
|
250
|
+
nativeContextPaths: new Set([...deps.nativeInstructionPaths, ...deps.fullyReadPaths]),
|
|
240
251
|
surfacedDirectories: deps.surfacedInstructionDirs,
|
|
241
252
|
projectTrusted: deps.projectTrusted,
|
|
242
253
|
});
|
|
243
|
-
const collected = collectInstructionFiles(
|
|
254
|
+
const collected = collectInstructionFiles(
|
|
255
|
+
matches.map((match) => ({
|
|
256
|
+
...match,
|
|
257
|
+
relativePath: toDisplayPath(deps.cwd, match.absolutePath),
|
|
258
|
+
})),
|
|
259
|
+
);
|
|
244
260
|
if (!collected) return result;
|
|
245
261
|
const items: OrientationItem[] = [];
|
|
246
262
|
for (const file of collected.files) {
|
|
@@ -300,7 +316,7 @@ function addTargetSummary(
|
|
|
300
316
|
const name = entry.name ? ` ${entry.name}` : "";
|
|
301
317
|
const summaryNotes = [
|
|
302
318
|
...notes.map((note) => `Note: ${note}`),
|
|
303
|
-
`Resolved target${name}: ${
|
|
319
|
+
`Resolved target${name}: ${toDisplayPath(cwd, entry.file)}:${entry.displayLine}:${entry.displayCharacter} — Target ID: ${entry.targetId}`,
|
|
304
320
|
];
|
|
305
321
|
return { ...result, notes: [...summaryNotes, ...result.notes], target: { ...entry } };
|
|
306
322
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Fingerprint-bound edit evidence for refactor planning. */
|
|
2
|
+
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import type { FileEdit, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
|
|
6
|
+
import { createLogicalLineIndex, type LogicalLineIndex } from "../analysis/refactor/position.ts";
|
|
7
|
+
import { computeFileFingerprint } from "./refactor-plans.ts";
|
|
8
|
+
|
|
9
|
+
type FileFingerprint = { file: string; fingerprint: string };
|
|
10
|
+
|
|
11
|
+
/** Fingerprint each edited file, reusing an earlier source snapshot when provided. */
|
|
12
|
+
export function collectFileFingerprints(
|
|
13
|
+
edits: readonly { file: string }[],
|
|
14
|
+
sourceSnapshot?: FileFingerprint,
|
|
15
|
+
): FileFingerprint[] {
|
|
16
|
+
const files = [...new Set(edits.map((edit) => edit.file))];
|
|
17
|
+
return files.map((file) => ({
|
|
18
|
+
file,
|
|
19
|
+
fingerprint:
|
|
20
|
+
sourceSnapshot?.file === file ? sourceSnapshot.fingerprint : computeFileFingerprint(file),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Drop edits whose replacement exactly equals the text they replace.
|
|
26
|
+
*
|
|
27
|
+
* Text is read only from content whose hash still equals the plan's verified
|
|
28
|
+
* fingerprint, so the comparison uses the snapshot that the plan was validated
|
|
29
|
+
* against. Files left without edits lose their fingerprints and preconditions.
|
|
30
|
+
* Edits whose ranges do not fit the content are kept for normal validation.
|
|
31
|
+
*/
|
|
32
|
+
export function dropIdentityEdits(
|
|
33
|
+
edits: WorkspaceEdit,
|
|
34
|
+
fileFingerprints: readonly FileFingerprint[],
|
|
35
|
+
):
|
|
36
|
+
| { kind: "ok"; edits: WorkspaceEdit; fileFingerprints: FileFingerprint[] }
|
|
37
|
+
| { kind: "unavailable"; reason: string } {
|
|
38
|
+
const contents = new Map<string, { content: string; index: LogicalLineIndex }>();
|
|
39
|
+
for (const { file, fingerprint } of fileFingerprints) {
|
|
40
|
+
let content: string;
|
|
41
|
+
try {
|
|
42
|
+
content = readFileSync(file, "utf-8");
|
|
43
|
+
} catch {
|
|
44
|
+
return { kind: "unavailable", reason: `File ${file} could not be read during planning.` };
|
|
45
|
+
}
|
|
46
|
+
if (createHash("sha256").update(content).digest("hex") !== fingerprint) {
|
|
47
|
+
return {
|
|
48
|
+
kind: "unavailable",
|
|
49
|
+
reason: `File ${file} changed during planning. Request a new plan.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
contents.set(file, { content, index: createLogicalLineIndex(content) });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const kept = edits.edits.filter((edit) => !isIdentityEdit(edit, contents.get(edit.file)));
|
|
56
|
+
const files = new Set(kept.map((edit) => edit.file));
|
|
57
|
+
const preconditions = edits.documentPreconditions?.filter((item) => files.has(item.file));
|
|
58
|
+
return {
|
|
59
|
+
kind: "ok",
|
|
60
|
+
edits: preconditions ? { edits: kept, documentPreconditions: preconditions } : { edits: kept },
|
|
61
|
+
fileFingerprints: fileFingerprints.filter(({ file }) => files.has(file)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isIdentityEdit(
|
|
66
|
+
edit: FileEdit,
|
|
67
|
+
source: { content: string; index: LogicalLineIndex } | undefined,
|
|
68
|
+
): boolean {
|
|
69
|
+
if (!source) return false;
|
|
70
|
+
try {
|
|
71
|
+
const start = source.index.offsetAt(edit.range.start);
|
|
72
|
+
return source.content.slice(start, source.index.offsetAt(edit.range.end)) === edit.newText;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
parseRefactorApplyWorkflowInput,
|
|
25
25
|
parseRefactorPlanWorkflowInput,
|
|
26
26
|
} from "./input/health-refactor.ts";
|
|
27
|
+
import { collectFileFingerprints, dropIdentityEdits } from "./refactor-identity.ts";
|
|
27
28
|
import {
|
|
28
29
|
computeFileFingerprint,
|
|
29
30
|
generatePlanId,
|
|
@@ -81,10 +82,11 @@ export async function runRefactorPlanWorkflow(
|
|
|
81
82
|
control,
|
|
82
83
|
);
|
|
83
84
|
throwIfAborted(control);
|
|
84
|
-
if (target.kind === "
|
|
85
|
+
if (target.kind === "file-outline") {
|
|
85
86
|
return {
|
|
86
87
|
kind: "invalid-input",
|
|
87
|
-
message:
|
|
88
|
+
message:
|
|
89
|
+
"Refactor planning requires one declaration, not a whole file. Pass one handle from the file outline as target.handle.",
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
if (target.kind === "disambiguation" || target.kind === "kind-mismatch") {
|
|
@@ -202,6 +204,14 @@ async function planResolvedRefactor(
|
|
|
202
204
|
deps.cwd,
|
|
203
205
|
);
|
|
204
206
|
if (snapshotError) return { kind: "unavailable", reason: snapshotError };
|
|
207
|
+
const changed = dropIdentityEdits(result.edits, fileFingerprints);
|
|
208
|
+
if (changed.kind === "unavailable") return changed;
|
|
209
|
+
if (changed.edits.edits.length === 0) {
|
|
210
|
+
return {
|
|
211
|
+
kind: "invalid-input",
|
|
212
|
+
message: `The ${parsed.operation} refactor produces no changes; every planned edit matches the current text.`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
205
215
|
|
|
206
216
|
const plan: RefactorPlan = {
|
|
207
217
|
id: generatePlanId(
|
|
@@ -216,10 +226,10 @@ async function planResolvedRefactor(
|
|
|
216
226
|
targetFile: file,
|
|
217
227
|
targetLine: target.displayLine,
|
|
218
228
|
targetCharacter: target.displayCharacter,
|
|
219
|
-
edits:
|
|
229
|
+
edits: changed.edits,
|
|
220
230
|
evidenceSource: sectionRename.evidenceSource,
|
|
221
231
|
authorizedMutationRoots: authority.canonicalRoots,
|
|
222
|
-
fileFingerprints,
|
|
232
|
+
fileFingerprints: changed.fileFingerprints,
|
|
223
233
|
createdAt: Date.now(),
|
|
224
234
|
};
|
|
225
235
|
deps.storePlan(plan);
|
|
@@ -366,18 +376,6 @@ async function planWithProvider(
|
|
|
366
376
|
};
|
|
367
377
|
}
|
|
368
378
|
|
|
369
|
-
function collectFileFingerprints(
|
|
370
|
-
edits: Array<{ file: string }>,
|
|
371
|
-
sourceSnapshot?: { readonly file: string; readonly fingerprint: string },
|
|
372
|
-
): Array<{ file: string; fingerprint: string }> {
|
|
373
|
-
const files = [...new Set(edits.map((edit) => edit.file))];
|
|
374
|
-
return files.map((file) => ({
|
|
375
|
-
file,
|
|
376
|
-
fingerprint:
|
|
377
|
-
sourceSnapshot?.file === file ? sourceSnapshot.fingerprint : computeFileFingerprint(file),
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
|
|
381
379
|
function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
|
|
382
380
|
return Object.freeze({
|
|
383
381
|
...plan,
|
package/src/session/session.ts
CHANGED
|
@@ -17,8 +17,13 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { realpathSync } from "node:fs";
|
|
20
|
+
import * as os from "node:os";
|
|
20
21
|
import * as path from "node:path";
|
|
21
|
-
import type {
|
|
22
|
+
import type {
|
|
23
|
+
ReadToolDetails,
|
|
24
|
+
SessionEntry,
|
|
25
|
+
ToolResultEvent,
|
|
26
|
+
} from "@earendil-works/pi-coding-agent";
|
|
22
27
|
import {
|
|
23
28
|
type AutomaticLspPathPolicy,
|
|
24
29
|
createDefaultAutomaticLspPathPolicy,
|
|
@@ -164,6 +169,9 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
164
169
|
/** Absolute directories whose instruction files were already surfaced by code_orientation. */
|
|
165
170
|
readonly #surfacedInstructionDirs = new Set<string>();
|
|
166
171
|
|
|
172
|
+
/** Absolute files the agent read in full with `read` since the latest compaction. */
|
|
173
|
+
readonly #fullyReadPaths = new Set<string>();
|
|
174
|
+
|
|
167
175
|
/**
|
|
168
176
|
* Optional LSP controller reference — attached by LSP lifecycle module
|
|
169
177
|
* for Capability Warning evaluation and server management.
|
|
@@ -348,6 +356,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
348
356
|
{
|
|
349
357
|
...this.targetWorkflowDeps(),
|
|
350
358
|
nativeInstructionPaths: this.#nativeInstructionPaths,
|
|
359
|
+
fullyReadPaths: this.#fullyReadPaths,
|
|
351
360
|
surfacedInstructionDirs: this.#surfacedInstructionDirs,
|
|
352
361
|
gradleObserver: this.#gradleObserver,
|
|
353
362
|
projectTrusted: this.#projectTrusted,
|
|
@@ -408,15 +417,39 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
408
417
|
|
|
409
418
|
/** Remember instruction/context file paths already loaded by PI natively. */
|
|
410
419
|
captureNativeInstructionPaths(files: Array<{ path: string }>): void {
|
|
411
|
-
for (const file of files)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
+
for (const file of files) this.#nativeInstructionPaths.add(this.#realPath(file.path));
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Record a model-issued `read` that returned a whole file, so code_orientation
|
|
425
|
+
* does not embed it again as an instruction file until the next compaction.
|
|
426
|
+
* Reads issued by another tool (e.g. a codemode script) are ignored: their
|
|
427
|
+
* results reach only the calling tool, not the model, and are not in the
|
|
428
|
+
* transcript used for branch reconstruction.
|
|
429
|
+
*/
|
|
430
|
+
recordToolResult(event: ToolResultEvent): void {
|
|
431
|
+
if (event.toolName !== "read" || event.parentToolCallId !== undefined) return;
|
|
432
|
+
if (isFullRead(event.input, event.isError, event.details))
|
|
433
|
+
this.#markFileReadInFull(event.input.path);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#markFileReadInFull(filePath: string): void {
|
|
437
|
+
this.#fullyReadPaths.add(this.#realPath(filePath));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Resolve like Pi's read tool (`@` prefix, `~`), then to the real path so
|
|
441
|
+
// dedup aligns with the realpath-aware lookup in findInstructionFilesForDirectory.
|
|
442
|
+
#realPath(filePath: string): string {
|
|
443
|
+
const unprefixed = filePath.replace(/^@/, "");
|
|
444
|
+
const expanded =
|
|
445
|
+
unprefixed === "~" || unprefixed.startsWith("~/")
|
|
446
|
+
? path.join(os.homedir(), unprefixed.slice(1))
|
|
447
|
+
: unprefixed;
|
|
448
|
+
const resolved = path.resolve(this.cwd, expanded);
|
|
449
|
+
try {
|
|
450
|
+
return path.resolve(realpathSync(resolved));
|
|
451
|
+
} catch {
|
|
452
|
+
return resolved;
|
|
420
453
|
}
|
|
421
454
|
}
|
|
422
455
|
|
|
@@ -427,20 +460,23 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
427
460
|
}
|
|
428
461
|
}
|
|
429
462
|
|
|
430
|
-
/** Clear instruction-file dedup state after compaction. */
|
|
431
|
-
|
|
463
|
+
/** Clear instruction-file dedup state (surfaced directories, full reads) after compaction. */
|
|
464
|
+
resetInstructionDedup(): void {
|
|
432
465
|
this.#surfacedInstructionDirs.clear();
|
|
466
|
+
this.#fullyReadPaths.clear();
|
|
433
467
|
}
|
|
434
468
|
|
|
435
469
|
/** Reconstruct surfaced instruction directories from branch tool-result details after compaction. */
|
|
436
470
|
reconstructInstructionState(branch: SessionEntry[]): void {
|
|
437
471
|
this.#surfacedInstructionDirs.clear();
|
|
472
|
+
this.#fullyReadPaths.clear();
|
|
438
473
|
const entries = entriesAfterLatestCompaction(branch);
|
|
439
474
|
for (const entry of entries) {
|
|
440
475
|
for (const directory of extractInstructionDirectories(entry)) {
|
|
441
476
|
this.#surfacedInstructionDirs.add(path.resolve(this.cwd, directory));
|
|
442
477
|
}
|
|
443
478
|
}
|
|
479
|
+
for (const filePath of extractFullReadPaths(entries)) this.#markFileReadInFull(filePath);
|
|
444
480
|
}
|
|
445
481
|
|
|
446
482
|
// ── Private session stores ───────────────────────────────────────
|
|
@@ -472,6 +508,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
472
508
|
this.#refactorPlans.clear();
|
|
473
509
|
this.#workflowTargets.clear();
|
|
474
510
|
this.#surfacedInstructionDirs.clear();
|
|
511
|
+
this.#fullyReadPaths.clear();
|
|
475
512
|
this.#nativeInstructionPaths.clear();
|
|
476
513
|
this.#maintenanceState = createLspMaintenanceState();
|
|
477
514
|
this.#lspController = null;
|
|
@@ -505,3 +542,41 @@ function extractInstructionDirectories(entry: SessionEntry): string[] {
|
|
|
505
542
|
.map((file) => file.directory)
|
|
506
543
|
.filter((directory): directory is string => typeof directory === "string");
|
|
507
544
|
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Whether a `read` call returned the whole file: no `offset`/`limit`, no error,
|
|
548
|
+
* and no output truncation.
|
|
549
|
+
*/
|
|
550
|
+
function isFullRead(
|
|
551
|
+
input: Record<string, unknown> | undefined,
|
|
552
|
+
isError: boolean,
|
|
553
|
+
details: unknown,
|
|
554
|
+
): input is { path: string } {
|
|
555
|
+
if (isError || typeof input?.path !== "string") return false;
|
|
556
|
+
if (input.offset !== undefined || input.limit !== undefined) return false;
|
|
557
|
+
return (details as ReadToolDetails | undefined)?.truncation?.truncated !== true;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function extractFullReadPaths(entries: SessionEntry[]): string[] {
|
|
561
|
+
const calls = new Map<string, Record<string, unknown>>();
|
|
562
|
+
const paths: string[] = [];
|
|
563
|
+
for (const entry of entries) {
|
|
564
|
+
if (entry.type !== "message") continue;
|
|
565
|
+
const message = entry.message;
|
|
566
|
+
if (message.role === "assistant") collectReadCalls(message.content, calls);
|
|
567
|
+
if (message.role !== "toolResult" || message.toolName !== "read") continue;
|
|
568
|
+
const input = calls.get(message.toolCallId);
|
|
569
|
+
if (isFullRead(input, message.isError, message.details)) paths.push(input.path);
|
|
570
|
+
}
|
|
571
|
+
return paths;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function collectReadCalls(
|
|
575
|
+
content: ReadonlyArray<{ type: string; id?: string; name?: string; arguments?: unknown }>,
|
|
576
|
+
calls: Map<string, Record<string, unknown>>,
|
|
577
|
+
): void {
|
|
578
|
+
for (const item of content) {
|
|
579
|
+
if (item.type !== "toolCall" || item.name !== "read" || typeof item.id !== "string") continue;
|
|
580
|
+
calls.set(item.id, item.arguments as Record<string, unknown>);
|
|
581
|
+
}
|
|
582
|
+
}
|