@mrclrchtr/supi-code-intelligence 11.2.0 → 11.3.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 +19 -0
- package/README.md +16 -6
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
- 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 +39 -2
- 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/capability/types.ts +3 -1
- 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-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/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/diagnostics/evidence.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +254 -56
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
- 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/capability/types.ts +3 -1
- 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-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 +5 -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 +5 -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/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/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 +39 -11
- package/src/analysis/target/types.ts +6 -1
- package/src/extension.ts +17 -11
- package/src/session/graph/collect.ts +1 -10
- package/src/session/graph-types.ts +2 -0
- package/src/session/graph-workflow.ts +1 -0
- 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-types.ts +3 -0
- package/src/session/orientation-workflow.ts +18 -5
- package/src/session/refactor-identity.ts +76 -0
- package/src/session/refactor-workflow.ts +11 -14
- package/src/session/target-store.ts +3 -18
- package/src/session/target-workflow.ts +33 -16
- 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 +133 -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/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-sections.ts +3 -2
- 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/markdown.ts +6 -30
- package/src/tool/code_resolve/result.ts +24 -11
- package/src/tool/code_resolve/structured.ts +7 -9
- package/src/tool/result/refactor.ts +8 -5
- package/src/tool/result/structured.ts +8 -5
- package/src/tool/result/types.ts +18 -14
- 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
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { type ReadNextItem, readNextRange } from "../../analysis/read-next.ts";
|
|
2
|
-
import
|
|
1
|
+
import { type ReadNextItem, readNextRange, readNextTopSites } from "../../analysis/read-next.ts";
|
|
2
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
3
|
+
import type { AssembledGraphSection } from "./section.ts";
|
|
3
4
|
|
|
4
5
|
/** Prefer the known enclosing scope, then alternate relation sites before the display cap. */
|
|
5
|
-
export function graphReadNext(
|
|
6
|
+
export function graphReadNext(
|
|
7
|
+
sections: readonly AssembledGraphSection[],
|
|
8
|
+
cwd: string,
|
|
9
|
+
): ReadNextItem[] {
|
|
6
10
|
const calls = sections.find((section) => section.kind === "ok" && section.rel === "callees");
|
|
7
11
|
const scopeReads =
|
|
8
12
|
calls?.kind === "ok"
|
|
@@ -10,12 +14,11 @@ export function graphReadNext(sections: readonly GraphSection[]): ReadNextItem[]
|
|
|
10
14
|
: [];
|
|
11
15
|
const queues = sections.flatMap((section) => {
|
|
12
16
|
if (section.kind !== "ok" || section.rel === "callees") return [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
];
|
|
17
|
+
if (section.rel !== "references") return [section.readNext];
|
|
18
|
+
// Collection supplies the target range; reference sites come only from selected evidence.
|
|
19
|
+
const target = section.readNext[0];
|
|
20
|
+
const sites = referenceReadNext(section, cwd, scopeReads[0]?.file ?? target?.file);
|
|
21
|
+
return [scopeReads.length > 0 || !target ? sites : [target, ...sites]];
|
|
19
22
|
});
|
|
20
23
|
const candidates = [...scopeReads];
|
|
21
24
|
const maxLength = Math.max(0, ...queues.map((queue) => queue.length));
|
|
@@ -30,6 +33,32 @@ export function graphReadNext(sections: readonly GraphSection[]): ReadNextItem[]
|
|
|
30
33
|
.map((item) => readNextRange(item));
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
/** Prefer new files, then the target file, before filling remaining slots with repeated files. */
|
|
37
|
+
function referenceReadNext(
|
|
38
|
+
section: Extract<AssembledGraphSection, { kind: "ok"; rel: "references" }>,
|
|
39
|
+
cwd: string,
|
|
40
|
+
targetFile: string | undefined,
|
|
41
|
+
): ReadNextItem[] {
|
|
42
|
+
const sites = section.evidence.items.map((site) => ({
|
|
43
|
+
file: toDisplayPath(cwd, site.file),
|
|
44
|
+
line: site.line,
|
|
45
|
+
}));
|
|
46
|
+
const firstByFile = new Map<string, (typeof sites)[number]>();
|
|
47
|
+
for (const site of sites) {
|
|
48
|
+
if (!firstByFile.has(site.file)) firstByFile.set(site.file, site);
|
|
49
|
+
}
|
|
50
|
+
const distinct = [...firstByFile.values()];
|
|
51
|
+
return readNextTopSites(
|
|
52
|
+
[
|
|
53
|
+
...distinct.filter((site) => site.file !== targetFile),
|
|
54
|
+
...distinct.filter((site) => site.file === targetFile),
|
|
55
|
+
...sites.filter((site) => firstByFile.get(site.file) !== site),
|
|
56
|
+
],
|
|
57
|
+
2,
|
|
58
|
+
"reference",
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
33
62
|
/** Merge connected ranges before bounding them, including ranges that bridge two earlier reads. */
|
|
34
63
|
function mergeRanges(items: readonly ReadNextItem[]): ReadNextItem[] {
|
|
35
64
|
const result: ReadNextItem[] = [];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReferenceEntry } from "../../analysis/relations/types.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Select one site per file per round from normalized, file/source-ordered references.
|
|
5
|
+
* Preserve that order for display; callers retain completeness from the full collected list.
|
|
6
|
+
*/
|
|
7
|
+
export function selectReferenceLocations(
|
|
8
|
+
references: readonly ReferenceEntry[],
|
|
9
|
+
limit: number,
|
|
10
|
+
): ReferenceEntry[] {
|
|
11
|
+
if (references.length <= limit) return [...references];
|
|
12
|
+
const byFile = new Map<string, number[]>();
|
|
13
|
+
for (const [index, reference] of references.entries()) {
|
|
14
|
+
const indices = byFile.get(reference.file) ?? [];
|
|
15
|
+
indices.push(index);
|
|
16
|
+
byFile.set(reference.file, indices);
|
|
17
|
+
}
|
|
18
|
+
const selected = new Set<number>();
|
|
19
|
+
let activeFiles = [...byFile.values()];
|
|
20
|
+
for (let round = 0; selected.size < limit && activeFiles.length > 0; round++) {
|
|
21
|
+
const remaining: number[][] = [];
|
|
22
|
+
for (const indices of activeFiles) {
|
|
23
|
+
if (selected.size === limit) break;
|
|
24
|
+
selected.add(indices[round]);
|
|
25
|
+
if (indices.length > round + 1) remaining.push(indices);
|
|
26
|
+
}
|
|
27
|
+
activeFiles = remaining;
|
|
28
|
+
}
|
|
29
|
+
return references.filter((_, index) => selected.has(index));
|
|
30
|
+
}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
-
import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
|
|
3
|
-
import {
|
|
4
|
-
createEvidenceList,
|
|
5
|
-
createPartialEvidenceList,
|
|
6
|
-
type EvidenceList,
|
|
7
|
-
} from "../../analysis/evidence.ts";
|
|
8
|
-
import type { RelationLocationPartialReason } from "../../analysis/relations/provider-locations.ts";
|
|
9
|
-
import type {
|
|
10
|
-
CallEntry,
|
|
11
|
-
ImplementationEntry,
|
|
12
|
-
ReferenceEntry,
|
|
13
|
-
} from "../../analysis/relations/types.ts";
|
|
2
|
+
import type { EvidenceList, EvidenceListMetadata } from "../../analysis/evidence.ts";
|
|
14
3
|
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
15
4
|
import type { GraphSection } from "../../session/graph-types.ts";
|
|
16
5
|
import {
|
|
@@ -26,27 +15,16 @@ import type { GraphDetails, GraphFileGroup, GraphSectionDetails } from "./detail
|
|
|
26
15
|
import { graphDisplaySection } from "./display.ts";
|
|
27
16
|
import { formatGraphEvidence } from "./format.ts";
|
|
28
17
|
import { graphReadNext } from "./read-next.ts";
|
|
18
|
+
import { type AssembledGraphSection, assembleGraphSection } from "./section.ts";
|
|
29
19
|
import { structuredGraphCandidates, structuredGraphResult } from "./structured.ts";
|
|
30
20
|
|
|
31
21
|
export type { GraphRelationKind, GraphSection } from "../../session/graph-types.ts";
|
|
32
22
|
|
|
33
|
-
type UnavailableGraphSection = Extract<GraphSection, { kind: "unavailable" }>;
|
|
34
|
-
type ReferenceGraphSection = Extract<GraphSection, { kind: "ok"; rel: "references" }>;
|
|
35
|
-
type CalleeGraphSection = Extract<GraphSection, { kind: "ok"; rel: "callees" }>;
|
|
36
|
-
type ImplementationGraphSection = Extract<GraphSection, { kind: "ok"; rel: "implements" }>;
|
|
37
|
-
|
|
38
|
-
/** A relation section after canonical evidence bounding. */
|
|
39
|
-
export type AssembledGraphSection =
|
|
40
|
-
| UnavailableGraphSection
|
|
41
|
-
| (ReferenceGraphSection & { readonly evidence: EvidenceList<ReferenceEntry> })
|
|
42
|
-
| (CalleeGraphSection & { readonly evidence: EvidenceList<CallEntry> })
|
|
43
|
-
| (ImplementationGraphSection & {
|
|
44
|
-
readonly evidence: EvidenceList<ImplementationEntry>;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
23
|
/** Presentation-neutral assembled graph result. */
|
|
48
24
|
export interface GraphResultAssembly {
|
|
49
25
|
displayName: string;
|
|
26
|
+
/** Target-resolution notes shown before relation sections. */
|
|
27
|
+
notes: readonly string[];
|
|
50
28
|
sections: readonly AssembledGraphSection[];
|
|
51
29
|
resolvedDisplayFile: string;
|
|
52
30
|
cwd: string;
|
|
@@ -62,8 +40,11 @@ export function assembleGraphResult(input: {
|
|
|
62
40
|
resolvedDisplayFile: string;
|
|
63
41
|
maxResults: number;
|
|
64
42
|
cwd: string;
|
|
43
|
+
notes?: readonly string[];
|
|
65
44
|
}): GraphResultAssembly {
|
|
66
|
-
const sections = input.sections.map((section) =>
|
|
45
|
+
const sections = input.sections.map((section) =>
|
|
46
|
+
assembleGraphSection(section, input.maxResults, input.cwd),
|
|
47
|
+
);
|
|
67
48
|
const evidenceLists = sections.flatMap((section) =>
|
|
68
49
|
section.kind === "ok" ? [section.evidence.metadata] : [],
|
|
69
50
|
);
|
|
@@ -85,7 +66,7 @@ export function assembleGraphResult(input: {
|
|
|
85
66
|
})),
|
|
86
67
|
evidenceLists,
|
|
87
68
|
nextQueries: [],
|
|
88
|
-
readNext: graphReadNext(sections),
|
|
69
|
+
readNext: graphReadNext(sections, input.cwd),
|
|
89
70
|
candidateCount,
|
|
90
71
|
confidence,
|
|
91
72
|
provenance,
|
|
@@ -96,6 +77,7 @@ export function assembleGraphResult(input: {
|
|
|
96
77
|
|
|
97
78
|
return {
|
|
98
79
|
displayName: input.displayName,
|
|
80
|
+
notes: input.notes ?? [],
|
|
99
81
|
sections,
|
|
100
82
|
resolvedDisplayFile: input.resolvedDisplayFile,
|
|
101
83
|
cwd: input.cwd,
|
|
@@ -130,103 +112,19 @@ function graphSectionDetails(
|
|
|
130
112
|
? { ...calls.enclosingScope, file: toDisplayPath(cwd, calls.enclosingScope.file) }
|
|
131
113
|
: null,
|
|
132
114
|
depth: calls?.depth ?? null,
|
|
133
|
-
recovery: calls?.recovery
|
|
115
|
+
recovery: calls?.recovery
|
|
116
|
+
? { ...calls.recovery, file: toDisplayPath(cwd, calls.recovery.file) }
|
|
117
|
+
: null,
|
|
134
118
|
fileGroups,
|
|
135
119
|
};
|
|
136
120
|
}
|
|
137
121
|
|
|
138
|
-
function assembleGraphSection(section: GraphSection, maxResults: number): AssembledGraphSection {
|
|
139
|
-
if (section.kind === "unavailable") return section;
|
|
140
|
-
switch (section.rel) {
|
|
141
|
-
case "references":
|
|
142
|
-
return {
|
|
143
|
-
...section,
|
|
144
|
-
evidence: createRelationEvidenceList({
|
|
145
|
-
key: "references.locations",
|
|
146
|
-
items: [...section.data.references],
|
|
147
|
-
maxResults,
|
|
148
|
-
invalidLocationCount: section.data.invalidLocationCount,
|
|
149
|
-
partialReason: section.data.partialReason,
|
|
150
|
-
}),
|
|
151
|
-
};
|
|
152
|
-
case "callees": {
|
|
153
|
-
const evidence = section.data.recovery
|
|
154
|
-
? createPartialEvidenceList({
|
|
155
|
-
key: "callees.calls",
|
|
156
|
-
items: [...section.data.calls],
|
|
157
|
-
maxResults,
|
|
158
|
-
partialReason: "provider-limited",
|
|
159
|
-
})
|
|
160
|
-
: createEvidenceList({
|
|
161
|
-
key: "callees.calls",
|
|
162
|
-
items: [...section.data.calls],
|
|
163
|
-
maxResults,
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
...section,
|
|
167
|
-
evidence: section.data.recovery
|
|
168
|
-
? {
|
|
169
|
-
...evidence,
|
|
170
|
-
metadata: {
|
|
171
|
-
...evidence.metadata,
|
|
172
|
-
partialMessage: recoveryMessage(section.data.recovery),
|
|
173
|
-
},
|
|
174
|
-
}
|
|
175
|
-
: evidence,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
case "implements":
|
|
179
|
-
return {
|
|
180
|
-
...section,
|
|
181
|
-
evidence: createRelationEvidenceList({
|
|
182
|
-
key: "implements.locations",
|
|
183
|
-
items: [...section.data.implementations],
|
|
184
|
-
maxResults,
|
|
185
|
-
invalidLocationCount: section.data.invalidLocationCount,
|
|
186
|
-
partialReason: section.data.partialReason,
|
|
187
|
-
}),
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function createRelationEvidenceList<T>(params: {
|
|
193
|
-
key: string;
|
|
194
|
-
items: T[];
|
|
195
|
-
maxResults: number;
|
|
196
|
-
invalidLocationCount: number;
|
|
197
|
-
partialReason: RelationLocationPartialReason | null;
|
|
198
|
-
}): EvidenceList<T> {
|
|
199
|
-
const evidence =
|
|
200
|
-
params.partialReason === "provider-limited"
|
|
201
|
-
? createPartialEvidenceList({ ...params, partialReason: params.partialReason })
|
|
202
|
-
: createEvidenceList(params);
|
|
203
|
-
if (params.partialReason === null) return evidence;
|
|
204
|
-
return {
|
|
205
|
-
...evidence,
|
|
206
|
-
metadata: {
|
|
207
|
-
...evidence.metadata,
|
|
208
|
-
partialReason: params.partialReason,
|
|
209
|
-
invalidLocationCount: params.invalidLocationCount,
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function recoveryMessage(recovery: NonNullable<CalleeGraphSection["data"]["recovery"]>): string {
|
|
215
|
-
const locations = recovery.errorRanges.map(
|
|
216
|
-
(range) => `L${range.start.line + 1}:${range.start.character + 1}`,
|
|
217
|
-
);
|
|
218
|
-
const suffix = locations.length > 0 ? ` Error locations: ${locations.join(", ")}.` : "";
|
|
219
|
-
return `${recovery.file}: ${recovery.reason}${suffix}`;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
122
|
function evidenceTotal(evidence: EvidenceList<unknown>): number {
|
|
223
123
|
return evidence.metadata.totalCount ?? evidence.metadata.shownCount;
|
|
224
124
|
}
|
|
225
125
|
|
|
226
126
|
function evidenceStatus(evidence: EvidenceList<unknown>): "complete" | "partial" {
|
|
227
|
-
return evidence.metadata.partialReason !== null
|
|
228
|
-
? "partial"
|
|
229
|
-
: "complete";
|
|
127
|
+
return evidence.metadata.partialReason !== null ? "partial" : "complete";
|
|
230
128
|
}
|
|
231
129
|
|
|
232
130
|
function sectionConfidence(section: AssembledGraphSection): ConfidenceMode {
|
|
@@ -279,7 +177,7 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
|
|
|
279
177
|
};
|
|
280
178
|
}
|
|
281
179
|
if (outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch") {
|
|
282
|
-
return finishGraphCandidates(outcome);
|
|
180
|
+
return finishGraphCandidates(outcome, cwd);
|
|
283
181
|
}
|
|
284
182
|
|
|
285
183
|
const assembly = assembleGraphResult({
|
|
@@ -288,6 +186,7 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
|
|
|
288
186
|
resolvedDisplayFile: outcome.resolvedDisplayFile,
|
|
289
187
|
maxResults: outcome.maxResults,
|
|
290
188
|
cwd,
|
|
189
|
+
notes: outcome.notes,
|
|
291
190
|
});
|
|
292
191
|
const displayTruncated = hasHiddenDisplayEvidence(assembly);
|
|
293
192
|
return {
|
|
@@ -304,8 +203,16 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
|
|
|
304
203
|
}
|
|
305
204
|
|
|
306
205
|
function finishGraphCandidates(
|
|
307
|
-
|
|
206
|
+
input: Extract<GraphOutcome, { kind: "disambiguation" | "kind-mismatch" }>,
|
|
207
|
+
cwd: string,
|
|
308
208
|
): CodeIntelResult {
|
|
209
|
+
const outcome = {
|
|
210
|
+
...input,
|
|
211
|
+
candidates: input.candidates.map((candidate) => ({
|
|
212
|
+
...candidate,
|
|
213
|
+
file: toDisplayPath(cwd, candidate.file),
|
|
214
|
+
})),
|
|
215
|
+
};
|
|
309
216
|
const lines = [
|
|
310
217
|
outcome.kind === "kind-mismatch"
|
|
311
218
|
? `**No target matched provider kind \`${outcome.requestedKind}\`. Near matches:**`
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEvidenceList,
|
|
3
|
+
createPartialEvidenceList,
|
|
4
|
+
type EvidenceList,
|
|
5
|
+
} from "../../analysis/evidence.ts";
|
|
6
|
+
import type { RelationLocationPartialReason } from "../../analysis/relations/provider-locations.ts";
|
|
7
|
+
import type {
|
|
8
|
+
CallEntry,
|
|
9
|
+
ImplementationEntry,
|
|
10
|
+
ReferenceEntry,
|
|
11
|
+
} from "../../analysis/relations/types.ts";
|
|
12
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
13
|
+
import type { GraphSection } from "../../session/graph-types.ts";
|
|
14
|
+
import { selectReferenceLocations } from "./reference-selection.ts";
|
|
15
|
+
|
|
16
|
+
type UnavailableGraphSection = Extract<GraphSection, { kind: "unavailable" }>;
|
|
17
|
+
type ReferenceGraphSection = Extract<GraphSection, { kind: "ok"; rel: "references" }>;
|
|
18
|
+
type CalleeGraphSection = Extract<GraphSection, { kind: "ok"; rel: "callees" }>;
|
|
19
|
+
type ImplementationGraphSection = Extract<GraphSection, { kind: "ok"; rel: "implements" }>;
|
|
20
|
+
|
|
21
|
+
/** A relation section after canonical evidence bounding. */
|
|
22
|
+
export type AssembledGraphSection =
|
|
23
|
+
| UnavailableGraphSection
|
|
24
|
+
| (ReferenceGraphSection & {
|
|
25
|
+
readonly evidence: EvidenceList<ReferenceEntry>;
|
|
26
|
+
readonly selectionNote: string | null;
|
|
27
|
+
})
|
|
28
|
+
| (CalleeGraphSection & { readonly evidence: EvidenceList<CallEntry> })
|
|
29
|
+
| (ImplementationGraphSection & {
|
|
30
|
+
readonly evidence: EvidenceList<ImplementationEntry>;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** Bound one relation section's evidence once, before any presentation consumes it. */
|
|
34
|
+
export function assembleGraphSection(
|
|
35
|
+
section: GraphSection,
|
|
36
|
+
maxResults: number,
|
|
37
|
+
cwd: string,
|
|
38
|
+
): AssembledGraphSection {
|
|
39
|
+
if (section.kind === "unavailable") return section;
|
|
40
|
+
switch (section.rel) {
|
|
41
|
+
case "references": {
|
|
42
|
+
const evidence = createRelationEvidenceList({
|
|
43
|
+
key: "references.locations",
|
|
44
|
+
items: [...section.data.references],
|
|
45
|
+
maxResults,
|
|
46
|
+
invalidLocationCount: section.data.invalidLocationCount,
|
|
47
|
+
partialReason: section.data.partialReason,
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
...section,
|
|
51
|
+
evidence: {
|
|
52
|
+
...evidence,
|
|
53
|
+
items: selectReferenceLocations(section.data.references, evidence.metadata.shownCount),
|
|
54
|
+
},
|
|
55
|
+
selectionNote:
|
|
56
|
+
(evidence.metadata.omittedCount ?? 0) > 0 &&
|
|
57
|
+
section.data.references.some((site) => site.file !== section.data.references[0]?.file)
|
|
58
|
+
? "Selection: one site per file per round."
|
|
59
|
+
: null,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
case "callees": {
|
|
63
|
+
const evidence = section.data.recovery
|
|
64
|
+
? createPartialEvidenceList({
|
|
65
|
+
key: "callees.calls",
|
|
66
|
+
items: [...section.data.calls],
|
|
67
|
+
maxResults,
|
|
68
|
+
partialReason: "provider-limited",
|
|
69
|
+
})
|
|
70
|
+
: createEvidenceList({
|
|
71
|
+
key: "callees.calls",
|
|
72
|
+
items: [...section.data.calls],
|
|
73
|
+
maxResults,
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
...section,
|
|
77
|
+
evidence: section.data.recovery
|
|
78
|
+
? {
|
|
79
|
+
...evidence,
|
|
80
|
+
metadata: {
|
|
81
|
+
...evidence.metadata,
|
|
82
|
+
partialMessage: recoveryMessage(section.data.recovery, cwd),
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: evidence,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
case "implements":
|
|
89
|
+
return {
|
|
90
|
+
...section,
|
|
91
|
+
evidence: createRelationEvidenceList({
|
|
92
|
+
key: "implements.locations",
|
|
93
|
+
items: [...section.data.implementations],
|
|
94
|
+
maxResults,
|
|
95
|
+
invalidLocationCount: section.data.invalidLocationCount,
|
|
96
|
+
partialReason: section.data.partialReason,
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function createRelationEvidenceList<T>(params: {
|
|
103
|
+
key: string;
|
|
104
|
+
items: T[];
|
|
105
|
+
maxResults: number;
|
|
106
|
+
invalidLocationCount: number;
|
|
107
|
+
partialReason: RelationLocationPartialReason | null;
|
|
108
|
+
}): EvidenceList<T> {
|
|
109
|
+
const evidence =
|
|
110
|
+
params.partialReason === "provider-limited"
|
|
111
|
+
? createPartialEvidenceList({ ...params, partialReason: params.partialReason })
|
|
112
|
+
: createEvidenceList(params);
|
|
113
|
+
if (params.partialReason === null) return evidence;
|
|
114
|
+
return {
|
|
115
|
+
...evidence,
|
|
116
|
+
metadata: {
|
|
117
|
+
...evidence.metadata,
|
|
118
|
+
partialReason: params.partialReason,
|
|
119
|
+
invalidLocationCount: params.invalidLocationCount,
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function recoveryMessage(
|
|
125
|
+
recovery: NonNullable<CalleeGraphSection["data"]["recovery"]>,
|
|
126
|
+
cwd: string,
|
|
127
|
+
): string {
|
|
128
|
+
const locations = recovery.errorRanges.map(
|
|
129
|
+
(range) => `L${range.start.line + 1}:${range.start.character + 1}`,
|
|
130
|
+
);
|
|
131
|
+
const suffix = locations.length > 0 ? ` Error locations: ${locations.join(", ")}.` : "";
|
|
132
|
+
return `${toDisplayPath(cwd, recovery.file)}: ${recovery.reason}${suffix}`;
|
|
133
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
1
|
import { Type } from "typebox";
|
|
3
2
|
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
4
3
|
import { GraphTargetParam, MaxResultsParam } from "../schemas.ts";
|
|
@@ -18,7 +17,7 @@ export const codeGraphSpec = {
|
|
|
18
17
|
{
|
|
19
18
|
target: GraphTargetParam,
|
|
20
19
|
relations: Type.Optional(
|
|
21
|
-
Type.Array(
|
|
20
|
+
Type.Array(Type.Enum(["all", "references", "callees", "implements"], { type: "string" }), {
|
|
22
21
|
description:
|
|
23
22
|
'Requested relations; defaults to ["references"]. "all" must be the only item.',
|
|
24
23
|
minItems: 1,
|
|
@@ -27,7 +26,8 @@ export const codeGraphSpec = {
|
|
|
27
26
|
),
|
|
28
27
|
maxResults: Type.Optional(MaxResultsParam),
|
|
29
28
|
calleeDepth: Type.Optional(
|
|
30
|
-
|
|
29
|
+
Type.Enum(["direct", "deep"], {
|
|
30
|
+
type: "string",
|
|
31
31
|
description: "direct excludes nested scopes; deep includes them.",
|
|
32
32
|
}),
|
|
33
33
|
),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
1
|
import { type Static, Type } from "typebox";
|
|
3
2
|
import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
|
|
4
3
|
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
@@ -14,14 +13,20 @@ import type { GraphResultAssembly } from "./result.ts";
|
|
|
14
13
|
/** Codemode relation evidence; callees describe written expressions, not resolved identities. */
|
|
15
14
|
export const GraphOutputSchema = Type.Object(
|
|
16
15
|
{
|
|
17
|
-
kind:
|
|
16
|
+
kind: Type.Enum(["completed", "invalid-input", "disambiguation", "kind-mismatch"], {
|
|
17
|
+
type: "string",
|
|
18
|
+
}),
|
|
18
19
|
target: Type.Optional(Type.Object({ name: Type.String(), file: Type.String() })),
|
|
19
20
|
sections: Type.Array(
|
|
20
21
|
Type.Object(
|
|
21
22
|
{
|
|
22
|
-
relation:
|
|
23
|
-
source:
|
|
24
|
-
status:
|
|
23
|
+
relation: Type.Enum(["references", "callees", "implements"], { type: "string" }),
|
|
24
|
+
source: Type.Enum(["semantic", "structural"], { type: "string" }),
|
|
25
|
+
status: Type.Enum(["complete", "partial", "unavailable"], {
|
|
26
|
+
type: "string",
|
|
27
|
+
description:
|
|
28
|
+
"Completeness of collected relation evidence; display caps are reported separately in evidence counts.",
|
|
29
|
+
}),
|
|
25
30
|
message: Type.Union([Type.String(), Type.Null()]),
|
|
26
31
|
items: Type.Array(
|
|
27
32
|
Type.Object(
|
|
@@ -36,7 +41,7 @@ export const GraphOutputSchema = Type.Object(
|
|
|
36
41
|
),
|
|
37
42
|
evidence: Type.Optional(EvidenceListSchema),
|
|
38
43
|
externalCount: Type.Integer(),
|
|
39
|
-
depth: Type.Union([
|
|
44
|
+
depth: Type.Union([Type.Enum(["direct", "deep"], { type: "string" }), Type.Null()]),
|
|
40
45
|
enclosingScope: Type.Union([
|
|
41
46
|
Type.Object({
|
|
42
47
|
name: Type.String(),
|
|
@@ -62,6 +67,11 @@ export const GraphOutputSchema = Type.Object(
|
|
|
62
67
|
evidenceLists: Type.Array(EvidenceListSchema),
|
|
63
68
|
readNext: Type.Array(ReadNextSchema),
|
|
64
69
|
message: Type.Optional(Type.String()),
|
|
70
|
+
notes: Type.Optional(
|
|
71
|
+
Type.Array(Type.String(), {
|
|
72
|
+
description: "Target-resolution notes, such as excluded paths beside a unique match.",
|
|
73
|
+
}),
|
|
74
|
+
),
|
|
65
75
|
requestedKind: Type.Optional(Type.String()),
|
|
66
76
|
nextQueries: Type.Array(Type.String()),
|
|
67
77
|
},
|
|
@@ -109,6 +119,7 @@ export function structuredGraphResult(
|
|
|
109
119
|
}),
|
|
110
120
|
evidenceLists: assembly.assembled.evidenceLists.map((evidence) => ({ ...evidence })),
|
|
111
121
|
readNext: assembly.details.readNext.map((item) => ({ ...item })),
|
|
122
|
+
...(assembly.notes.length > 0 ? { notes: [...assembly.notes] } : {}),
|
|
112
123
|
nextQueries: [],
|
|
113
124
|
};
|
|
114
125
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { DiagnosticEvidenceSummary } from "@mrclrchtr/supi-lsp/api";
|
|
2
|
+
import { formatProjectServerRoot } from "../../analysis/health/server-status.ts";
|
|
3
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
4
|
+
import type {
|
|
5
|
+
HealthData,
|
|
6
|
+
HealthDiagnosticScope,
|
|
7
|
+
HealthRefreshAttempt,
|
|
8
|
+
} from "../../session/health-types.ts";
|
|
9
|
+
|
|
10
|
+
/** Clone source navigation and recovery labels for display; retain observed ownership identities and stored session facts. */
|
|
11
|
+
export function displayHealthPaths(input: HealthData, cwd: string): HealthData {
|
|
12
|
+
const display = (file: string) => toDisplayPath(cwd, file);
|
|
13
|
+
const scope = (value: HealthDiagnosticScope): HealthDiagnosticScope =>
|
|
14
|
+
value.kind === "file"
|
|
15
|
+
? { ...value, path: display(value.path) }
|
|
16
|
+
: { ...value, filter: value.filter === null ? null : display(value.filter) };
|
|
17
|
+
const evidence = (value: DiagnosticEvidenceSummary): DiagnosticEvidenceSummary => ({
|
|
18
|
+
...value,
|
|
19
|
+
documents: value.documents.map((document) => ({ ...document, file: display(document.file) })),
|
|
20
|
+
});
|
|
21
|
+
const attempt = (value: HealthRefreshAttempt): HealthRefreshAttempt => ({
|
|
22
|
+
...value,
|
|
23
|
+
requestedDiagnosticScope: scope(value.requestedDiagnosticScope),
|
|
24
|
+
...(value.processCrashRecovery
|
|
25
|
+
? {
|
|
26
|
+
processCrashRecovery: {
|
|
27
|
+
...value.processCrashRecovery,
|
|
28
|
+
entries: value.processCrashRecovery.entries.map((entry) => ({
|
|
29
|
+
...entry,
|
|
30
|
+
root: formatProjectServerRoot(cwd, entry.root),
|
|
31
|
+
})),
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
: {}),
|
|
35
|
+
...(value.startupRetry
|
|
36
|
+
? {
|
|
37
|
+
startupRetry: {
|
|
38
|
+
...value.startupRetry,
|
|
39
|
+
entries: value.startupRetry.entries.map((entry) => ({
|
|
40
|
+
...entry,
|
|
41
|
+
root: formatProjectServerRoot(cwd, entry.root),
|
|
42
|
+
})),
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
: {}),
|
|
46
|
+
...("diagnosticEvidence" in value && value.diagnosticEvidence
|
|
47
|
+
? { diagnosticEvidence: evidence(value.diagnosticEvidence) }
|
|
48
|
+
: {}),
|
|
49
|
+
...(value.sourceTracking
|
|
50
|
+
? {
|
|
51
|
+
sourceTracking: {
|
|
52
|
+
...value.sourceTracking,
|
|
53
|
+
discovered: value.sourceTracking.discovered.map(display),
|
|
54
|
+
tracked: value.sourceTracking.tracked.map(display),
|
|
55
|
+
skipped: value.sourceTracking.skipped.map(display),
|
|
56
|
+
unavailable: value.sourceTracking.unavailable.map(display),
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
});
|
|
61
|
+
const { diagnostics, refresh } = input;
|
|
62
|
+
return {
|
|
63
|
+
...input,
|
|
64
|
+
diagnostics:
|
|
65
|
+
diagnostics.kind === "not-requested"
|
|
66
|
+
? diagnostics
|
|
67
|
+
: {
|
|
68
|
+
...diagnostics,
|
|
69
|
+
scope: scope(diagnostics.scope),
|
|
70
|
+
entries: diagnostics.entries.map((entry) => ({ ...entry, file: display(entry.file) })),
|
|
71
|
+
evidence: evidence(diagnostics.evidence),
|
|
72
|
+
...(diagnostics.scopeStatus
|
|
73
|
+
? {
|
|
74
|
+
scopeStatus: {
|
|
75
|
+
...diagnostics.scopeStatus,
|
|
76
|
+
configPath:
|
|
77
|
+
diagnostics.scopeStatus.configPath === null
|
|
78
|
+
? null
|
|
79
|
+
: display(diagnostics.scopeStatus.configPath),
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
83
|
+
},
|
|
84
|
+
refresh:
|
|
85
|
+
refresh.kind === "not-requested" || refresh.kind === "not-attempted"
|
|
86
|
+
? {
|
|
87
|
+
...refresh,
|
|
88
|
+
lastAttempt: refresh.lastAttempt === null ? null : attempt(refresh.lastAttempt),
|
|
89
|
+
}
|
|
90
|
+
: attempt(refresh),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
1
2
|
import type { HealthDiagnosticObservation } from "../../session/health-types.ts";
|
|
2
3
|
|
|
3
4
|
/** Render the tsconfig coverage result for a single-file health request. */
|
|
@@ -37,7 +38,7 @@ function formatConfigPath(configPath: string | null, cwd: string): string {
|
|
|
37
38
|
return `\`${makeRelative(cwd, configPath)}\``;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
/** Format a
|
|
41
|
+
/** Format a diagnostic source with the shared workspace/external path policy. */
|
|
41
42
|
export function makeRelative(cwd: string, file: string): string {
|
|
42
|
-
return
|
|
43
|
+
return toDisplayPath(cwd, file);
|
|
43
44
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "../result/assembly.ts";
|
|
16
16
|
import { createToolDisplaySection, truncateDisplayText } from "../result/display.ts";
|
|
17
17
|
import type { HealthDetails, HealthSectionDetails, ToolDisplaySection } from "../result/types.ts";
|
|
18
|
+
import { displayHealthPaths } from "./display-paths.ts";
|
|
18
19
|
|
|
19
20
|
export type {
|
|
20
21
|
HealthData,
|
|
@@ -44,7 +45,8 @@ const SECTION_TITLES: Record<HealthSection, string> = {
|
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
/** Assemble public code_health evidence and details before presentation adapters render it. */
|
|
47
|
-
export function assembleHealthResult(
|
|
48
|
+
export function assembleHealthResult(input: HealthData, cwd?: string): HealthResultAssembly {
|
|
49
|
+
const data = cwd === undefined ? input : displayHealthPaths(input, cwd);
|
|
48
50
|
const projections = data.includedSections.map((section) => projectSection(section, data));
|
|
49
51
|
const sections = projections.map((projection) => projection.section);
|
|
50
52
|
const sectionDetails = projections.map((projection) => projection.details);
|
|
@@ -282,7 +284,7 @@ export function finishHealthResult(outcome: HealthOutcome, cwd: string): CodeInt
|
|
|
282
284
|
const assembly = assembleHealthResult(outcome.data, cwd);
|
|
283
285
|
return {
|
|
284
286
|
content: renderHealthResult(assembly, cwd),
|
|
285
|
-
structuredContent: structuredHealthResult(
|
|
287
|
+
structuredContent: structuredHealthResult(assembly.data),
|
|
286
288
|
details: {
|
|
287
289
|
type: "health",
|
|
288
290
|
data: assembly.details,
|