@mrclrchtr/supi-code-intelligence 11.3.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 +11 -0
- package/README.md +3 -3
- 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/declaration-level.ts +34 -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-lsp/README.md +1 -1
- 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/declaration-level.ts +34 -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/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/config/tsconfig-scope.ts +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +64 -2
- 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 +49 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -1
- 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/declaration-level.ts +34 -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/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/package.json +5 -5
- 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/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/symbol.ts +5 -1
- package/src/analysis/target/types.ts +32 -6
- package/src/api.ts +1 -1
- package/src/app/app.ts +9 -3
- package/src/session/graph/collect.ts +2 -0
- package/src/session/graph-types.ts +3 -1
- package/src/session/graph-workflow.ts +5 -4
- package/src/session/orientation/workspace-context.ts +3 -0
- package/src/session/orientation-workflow.ts +6 -3
- package/src/session/refactor-workflow.ts +3 -2
- package/src/session/session.ts +87 -12
- package/src/session/target-workflow.ts +23 -21
- package/src/tool/code_graph/section.ts +4 -0
- package/src/tool/code_orientation/directory-navigation.ts +20 -31
- package/src/tool/code_orientation/workspace-output.ts +40 -13
- package/src/tool/code_orientation/workspace-sections.ts +45 -2
- package/src/tool/code_resolve/guidance.ts +1 -1
- package/src/tool/code_resolve/markdown.ts +121 -34
- package/src/tool/code_resolve/result.ts +18 -15
- package/src/tool/code_resolve/structured.ts +43 -10
- package/src/tool/result/model-budget.ts +2 -2
- package/src/tool/result/types.ts +13 -10
- package/src/ui/tui/common.ts +10 -10
|
@@ -19,6 +19,7 @@ export function workspaceSections(
|
|
|
19
19
|
data: OrientationResultData,
|
|
20
20
|
limit: number,
|
|
21
21
|
descriptions: boolean,
|
|
22
|
+
fileLimit = limit,
|
|
22
23
|
): OrientationResultData {
|
|
23
24
|
const facts = data.workspace;
|
|
24
25
|
if (!facts) return data;
|
|
@@ -54,7 +55,7 @@ export function workspaceSections(
|
|
|
54
55
|
"Declared descriptions are omitted to preserve names and paths. They remain in the captured result.",
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
|
-
const sections = inventorySections(entries, facts, limit);
|
|
58
|
+
const sections = inventorySections(entries, facts, limit, fileLimit);
|
|
58
59
|
sections.push(...projectSections(facts, limit, descriptions));
|
|
59
60
|
sections.push(...gradleSections(observation.gradle, limit));
|
|
60
61
|
const issues = [
|
|
@@ -192,6 +193,7 @@ function inventorySections(
|
|
|
192
193
|
entries: readonly InventoryEntry[],
|
|
193
194
|
facts: WorkspaceOrientationFacts,
|
|
194
195
|
limit: number,
|
|
196
|
+
fileLimit: number,
|
|
195
197
|
): OrientationSectionData[] {
|
|
196
198
|
const { directories, directFiles, extensions } = collectWorkspaceInventory(entries);
|
|
197
199
|
const sections = [
|
|
@@ -205,7 +207,8 @@ function inventorySections(
|
|
|
205
207
|
detail: "included paths",
|
|
206
208
|
}),
|
|
207
209
|
];
|
|
208
|
-
if (
|
|
210
|
+
if (facts.focus && !facts.overview) sections.push(directFileList(directFiles, fileLimit));
|
|
211
|
+
else if (directFiles.length > 0 || !facts.overview)
|
|
209
212
|
sections.push(
|
|
210
213
|
tableSection("workspace.files", "Direct files", {
|
|
211
214
|
headers: ["Path", "Kind"],
|
|
@@ -228,6 +231,46 @@ function inventorySections(
|
|
|
228
231
|
return sections;
|
|
229
232
|
}
|
|
230
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Directory focus lists direct files as one compact line instead of a per-row table. Its own
|
|
236
|
+
* `fileLimit` lets presentation show all siblings and shrink them first under the text budget.
|
|
237
|
+
*/
|
|
238
|
+
function directFileList(
|
|
239
|
+
directFiles: readonly InventoryEntry[],
|
|
240
|
+
fileLimit: number,
|
|
241
|
+
): OrientationSectionData {
|
|
242
|
+
const names = directFiles
|
|
243
|
+
.slice(0, fileLimit)
|
|
244
|
+
.map((entry) =>
|
|
245
|
+
entry.kind === "symlink" ? `${code(entry.path)} (symlink)` : code(entry.path),
|
|
246
|
+
);
|
|
247
|
+
return {
|
|
248
|
+
key: "workspace.files",
|
|
249
|
+
title: "Direct files",
|
|
250
|
+
status: "complete",
|
|
251
|
+
reason: null,
|
|
252
|
+
confidence: "unavailable",
|
|
253
|
+
provenance: [{ source: "filesystem", detail: "included paths" }],
|
|
254
|
+
evidenceLists: [
|
|
255
|
+
{
|
|
256
|
+
key: "workspace.files",
|
|
257
|
+
totalCount: directFiles.length,
|
|
258
|
+
shownCount: names.length,
|
|
259
|
+
omittedCount: directFiles.length - names.length,
|
|
260
|
+
partialReason: null,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
items: [
|
|
264
|
+
{
|
|
265
|
+
kind: "paragraph",
|
|
266
|
+
text: directFiles.length
|
|
267
|
+
? names.join(", ") || "No entries shown."
|
|
268
|
+
: "No collected entries.",
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
231
274
|
export function display(cwd: string, target: string): string {
|
|
232
275
|
return toDisplayPath(cwd, target);
|
|
233
276
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const toolDescription =
|
|
2
|
-
"Resolve a real symbol anchor or semantic query to target handles for later code tools, or list a file's declarations as a
|
|
2
|
+
"Resolve a real symbol anchor or semantic query to target handles for later code tools, or list a file's declarations as a file outline. This tool does not search file text.";
|
|
3
3
|
|
|
4
4
|
export const promptSnippet = "resolve symbols or file declarations";
|
|
5
5
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { renderEvidenceListMetadataDisclosure } from "../../analysis/evidence.ts";
|
|
4
4
|
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
5
|
+
import type { TargetProviderProvenance } from "../../session/target-store.ts";
|
|
5
6
|
import type { TargetWorkflowOutcome } from "../../session/target-workflow.ts";
|
|
6
7
|
import { formatPartialCandidateDisclosure } from "../result/candidate-row.ts";
|
|
7
8
|
import type { ResolveDetails } from "../result/types.ts";
|
|
@@ -13,8 +14,8 @@ export function renderResolveResult(assembly: ResolveResultAssembly): string {
|
|
|
13
14
|
switch (outcome.kind) {
|
|
14
15
|
case "resolved":
|
|
15
16
|
return renderResolved(outcome, cwd);
|
|
16
|
-
case "
|
|
17
|
-
return
|
|
17
|
+
case "file-outline":
|
|
18
|
+
return renderFileOutline(assembly.details);
|
|
18
19
|
case "disambiguation":
|
|
19
20
|
return renderDisambiguation(assembly.details);
|
|
20
21
|
case "kind-mismatch":
|
|
@@ -47,60 +48,146 @@ function renderResolved(
|
|
|
47
48
|
return lines.join("\n");
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`- Group confidence: \`${details.confidence}\``,
|
|
56
|
-
`- Discovery provenance: \`${discovery}\``,
|
|
57
|
-
];
|
|
58
|
-
appendUnknownHierarchyDisclosure(lines, details.groupUnknownNestingCount ?? 0);
|
|
59
|
-
appendGroupRecoveryDisclosure(lines, details);
|
|
51
|
+
function renderFileOutline(details: ResolveDetails): string {
|
|
52
|
+
const lines = [`# File outline of \`${details.outlineFile ?? "file"}\``, ""];
|
|
53
|
+
lines.push(`- Sources: ${outlineSources(details.outlineDiscoveryProvenance ?? [])}`);
|
|
54
|
+
appendUnknownLevelDisclosure(lines, details.outlineUnknownLevelCount ?? 0);
|
|
55
|
+
appendOutlineRecoveryDisclosure(lines, details);
|
|
60
56
|
lines.push("");
|
|
61
|
-
|
|
57
|
+
appendFileOutlineItems(lines, details);
|
|
62
58
|
appendDisclosure(lines, details);
|
|
59
|
+
appendNotListed(lines, details);
|
|
63
60
|
return lines.join("\n");
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
const SOURCE_NAMES: Record<TargetProviderProvenance, string> = {
|
|
64
|
+
semantic: "language server",
|
|
65
|
+
structural: "syntax parser",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function outlineSources(provenance: readonly TargetProviderProvenance[]): string {
|
|
69
|
+
return provenance.length
|
|
70
|
+
? provenance.map((source) => SOURCE_NAMES[source]).join(" and ")
|
|
71
|
+
: "none";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function appendFileOutlineItems(lines: string[], details: ResolveDetails): void {
|
|
67
75
|
if (details.targets.length === 0) {
|
|
68
76
|
lines.push(
|
|
69
|
-
details.
|
|
77
|
+
details.outlinePartialReason
|
|
70
78
|
? "No declarations were collected before structural recovery limited discovery."
|
|
71
79
|
: "No declarations were reported for this file.",
|
|
72
80
|
);
|
|
73
81
|
return;
|
|
74
82
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
const count = details.targetCount;
|
|
84
|
+
lines.push(
|
|
85
|
+
`${count} declaration${count === 1 ? "" : "s"}: top-level declarations in source order, members indented below their container. Pass a handle as target.handle to code_graph, code_inspect, or code_refactor_plan.`,
|
|
86
|
+
"",
|
|
87
|
+
);
|
|
88
|
+
appendGroupedRows(lines, details.targets);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type OutlineRowTarget = ResolveDetails["targets"][number];
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Render each visible member directly below its visible container, so the
|
|
95
|
+
* container name is not repeated per row. Members whose container is not a
|
|
96
|
+
* uniquely named visible row keep an explicit `in` suffix.
|
|
97
|
+
*/
|
|
98
|
+
function appendGroupedRows(lines: string[], targets: readonly OutlineRowTarget[]): void {
|
|
99
|
+
const containerCounts = new Map<string, number>();
|
|
100
|
+
for (const target of targets) {
|
|
101
|
+
if (target.name) containerCounts.set(target.name, (containerCounts.get(target.name) ?? 0) + 1);
|
|
102
|
+
}
|
|
103
|
+
const children = new Map<string, OutlineRowTarget[]>();
|
|
104
|
+
const roots: OutlineRowTarget[] = [];
|
|
105
|
+
for (const target of targets) {
|
|
106
|
+
const container = target.container;
|
|
107
|
+
if (container && container !== target.name && containerCounts.get(container) === 1) {
|
|
108
|
+
children.set(container, [...(children.get(container) ?? []), target]);
|
|
109
|
+
} else {
|
|
110
|
+
roots.push(target);
|
|
111
|
+
}
|
|
83
112
|
}
|
|
113
|
+
const emit = (target: OutlineRowTarget, depth: number): void => {
|
|
114
|
+
lines.push(outlineRow(target, depth));
|
|
115
|
+
const own = target.name ? children.get(target.name) : undefined;
|
|
116
|
+
if (!own) return;
|
|
117
|
+
children.delete(target.name ?? "");
|
|
118
|
+
for (const child of own) emit(child, depth + 1);
|
|
119
|
+
};
|
|
120
|
+
for (const root of roots) emit(root, 0);
|
|
121
|
+
// Containers that are themselves grouped under a hidden row fall back to suffixes.
|
|
122
|
+
for (const orphans of children.values()) for (const orphan of orphans) emit(orphan, 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** One compact row; evidence notes appear only when they differ from the usual case. */
|
|
126
|
+
function outlineRow(target: OutlineRowTarget, depth: number): string {
|
|
127
|
+
const displayKind = outlineKind(target.nativeKind ?? target.kind);
|
|
128
|
+
const kind = displayKind ? `${displayKind} ` : "";
|
|
129
|
+
const container = depth === 0 && target.container ? ` in \`${target.container}\`` : "";
|
|
130
|
+
const indent = " ".repeat(depth);
|
|
131
|
+
const suffix = target.provenance.includes("semantic") ? "" : " (syntax parser only)";
|
|
132
|
+
const name = (target.name ?? "anonymous").replace(/\s+/g, " ");
|
|
133
|
+
return `${indent}- \`${target.targetId}\` ${kind}\`${name}\`${container} — L${target.displayLine}:${target.displayCharacter}${suffix}`;
|
|
84
134
|
}
|
|
85
135
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
136
|
+
/** Lower-case words for both providers' kinds, e.g. `EnumMember` -> `enum member`. */
|
|
137
|
+
function outlineKind(kind: string | null | undefined): string {
|
|
138
|
+
return (kind ?? "").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function appendNotListed(lines: string[], details: ResolveDetails): void {
|
|
142
|
+
const notListed = details.outlineNotListed;
|
|
143
|
+
if (!notListed) return;
|
|
144
|
+
const span = (value: { startLine: number; endLine: number }) =>
|
|
145
|
+
value.startLine === value.endLine
|
|
146
|
+
? `L${value.startLine}`
|
|
147
|
+
: `L${value.startLine}–L${value.endLine}`;
|
|
148
|
+
const rows = [
|
|
149
|
+
...(notListed.importedNames
|
|
150
|
+
? [
|
|
151
|
+
`- ${plural(notListed.importedNames.count, "imported name")} (${span(notListed.importedNames)}). Read those lines, or resolve a name with code_resolve target.symbol.`,
|
|
152
|
+
]
|
|
153
|
+
: []),
|
|
154
|
+
...(notListed.reExportStatements
|
|
155
|
+
? [
|
|
156
|
+
`- ${plural(notListed.reExportStatements.count, "`export … from` statement")} (${span(notListed.reExportStatements)}); they forward names declared in other modules.`,
|
|
157
|
+
]
|
|
158
|
+
: []),
|
|
159
|
+
...(notListed.exportListNames
|
|
160
|
+
? [
|
|
161
|
+
`- ${plural(notListed.exportListNames.count, "name")} in export lists (${span(notListed.exportListNames)}). Read those lines, or find them with code_find mode "ast", kind "export", a name fragment as query, and scope set to this file.`,
|
|
162
|
+
]
|
|
163
|
+
: []),
|
|
164
|
+
...(notListed.localDeclarations > 0
|
|
165
|
+
? [
|
|
166
|
+
`- ${plural(notListed.localDeclarations, "declaration")} inside function, method, or constructor bodies. Resolve one with code_resolve target.symbol and scope set to this file.`,
|
|
167
|
+
]
|
|
168
|
+
: []),
|
|
169
|
+
];
|
|
170
|
+
if (rows.length) lines.push("", "Not listed:", ...rows);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function plural(count: number, noun: string): string {
|
|
174
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function appendOutlineRecoveryDisclosure(lines: string[], details: ResolveDetails): void {
|
|
178
|
+
if (!details.outlinePartialReason) return;
|
|
179
|
+
const locations = (details.outlineErrorRanges ?? []).map(
|
|
89
180
|
(range) => `L${range.start.line + 1}:${range.start.character + 1}`,
|
|
90
181
|
);
|
|
91
182
|
const errors = locations.length ? ` Error locations: ${locations.join(", ")}.` : "";
|
|
92
|
-
lines.push(`- Partial discovery: ${details.
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function declarationCountHeading(count: number): string {
|
|
96
|
-
return `**${count} declaration${count === 1 ? "" : "s"} discovered**`;
|
|
183
|
+
lines.push(`- Partial discovery: ${details.outlinePartialReason}${errors}`);
|
|
97
184
|
}
|
|
98
185
|
|
|
99
|
-
function
|
|
186
|
+
function appendUnknownLevelDisclosure(lines: string[], count: number): void {
|
|
100
187
|
if (count <= 0) return;
|
|
101
|
-
const
|
|
188
|
+
const declarations = count === 1 ? "declaration has" : "declarations have";
|
|
102
189
|
lines.push(
|
|
103
|
-
`-
|
|
190
|
+
`- Position unknown: ${count} ${declarations} no enclosing declaration reported by the language server, so ${count === 1 ? "it is" : "they are"} listed after the top-level declarations.`,
|
|
104
191
|
);
|
|
105
192
|
}
|
|
106
193
|
|
|
@@ -85,8 +85,8 @@ function projectResolveOutcome(outcome: TargetWorkflowOutcome, cwd: string): Res
|
|
|
85
85
|
switch (outcome.kind) {
|
|
86
86
|
case "resolved":
|
|
87
87
|
return projectResolved(outcome, cwd);
|
|
88
|
-
case "
|
|
89
|
-
return
|
|
88
|
+
case "file-outline":
|
|
89
|
+
return projectFileOutline(outcome, cwd);
|
|
90
90
|
case "disambiguation":
|
|
91
91
|
case "kind-mismatch":
|
|
92
92
|
return projectCandidateOutcome(outcome, cwd);
|
|
@@ -121,8 +121,8 @@ function projectResolved(
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function
|
|
125
|
-
outcome: Extract<TargetWorkflowOutcome, { kind: "
|
|
124
|
+
function projectFileOutline(
|
|
125
|
+
outcome: Extract<TargetWorkflowOutcome, { kind: "file-outline" }>,
|
|
126
126
|
cwd: string,
|
|
127
127
|
): ResolveProjection {
|
|
128
128
|
const evidence = {
|
|
@@ -138,19 +138,20 @@ function projectTargetGroup(
|
|
|
138
138
|
},
|
|
139
139
|
};
|
|
140
140
|
return {
|
|
141
|
-
key: "resolve.
|
|
142
|
-
title: "
|
|
141
|
+
key: "resolve.file-outline",
|
|
142
|
+
title: "File outline",
|
|
143
143
|
status: outcome.partial ? "partial" : "complete",
|
|
144
144
|
items: evidence.items,
|
|
145
145
|
confidence: outcome.confidence,
|
|
146
146
|
evidence: evidence.metadata,
|
|
147
147
|
details: {
|
|
148
|
-
resultKind: "
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
resultKind: "file-outline",
|
|
149
|
+
outlineFile: toDisplayPath(cwd, outcome.file),
|
|
150
|
+
outlineDiscoveryProvenance: [...outcome.discoveryProvenance],
|
|
151
|
+
outlineUnknownLevelCount: outcome.unknownLevelCount,
|
|
152
|
+
outlinePartialReason: outcome.partial?.reason ?? null,
|
|
153
|
+
outlineErrorRanges: outcome.partial?.errorRanges,
|
|
154
|
+
outlineNotListed: outcome.notListed,
|
|
154
155
|
confidence: outcome.confidence,
|
|
155
156
|
targetCount: outcome.totalCount,
|
|
156
157
|
omittedCount: evidence.metadata.omittedCount,
|
|
@@ -158,7 +159,9 @@ function projectTargetGroup(
|
|
|
158
159
|
targets: evidence.items.map((target) => toTargetDetails(target, cwd)),
|
|
159
160
|
nextQueries:
|
|
160
161
|
outcome.totalCount > 0
|
|
161
|
-
? [
|
|
162
|
+
? [
|
|
163
|
+
"Pass one declaration handle from the file outline as target.handle to code_graph, code_inspect, or code_refactor_plan",
|
|
164
|
+
]
|
|
162
165
|
: ["Use code_inspect for point facts or code_find for explicit source evidence"],
|
|
163
166
|
},
|
|
164
167
|
};
|
|
@@ -298,7 +301,7 @@ function resolveProvenance(outcome: TargetWorkflowOutcome): ResultProvenance[] {
|
|
|
298
301
|
const sources = new Set<"semantic" | "structural">();
|
|
299
302
|
if (outcome.kind === "resolved") {
|
|
300
303
|
for (const source of outcome.entry.provenance) sources.add(source);
|
|
301
|
-
} else if (outcome.kind === "
|
|
304
|
+
} else if (outcome.kind === "file-outline") {
|
|
302
305
|
for (const source of outcome.discoveryProvenance) sources.add(source);
|
|
303
306
|
} else if (outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch") {
|
|
304
307
|
sources.add("semantic");
|
|
@@ -343,7 +346,7 @@ export function finishResolveResult(
|
|
|
343
346
|
type: "resolve",
|
|
344
347
|
data: assembly.details,
|
|
345
348
|
status:
|
|
346
|
-
outcome.kind === "resolved" || outcome.kind === "
|
|
349
|
+
outcome.kind === "resolved" || outcome.kind === "file-outline"
|
|
347
350
|
? "completed"
|
|
348
351
|
: outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch"
|
|
349
352
|
? "disambiguation"
|
|
@@ -8,11 +8,16 @@ import {
|
|
|
8
8
|
} from "../result/structured.ts";
|
|
9
9
|
import type { ResolveDetails } from "../result/types.ts";
|
|
10
10
|
|
|
11
|
+
const NameSpanSchema = Type.Object(
|
|
12
|
+
{ count: Type.Integer(), startLine: Type.Integer(), endLine: Type.Integer() },
|
|
13
|
+
{ additionalProperties: false },
|
|
14
|
+
);
|
|
15
|
+
|
|
11
16
|
/** Codemode contract for resolution, including candidate selection and invalid input. */
|
|
12
17
|
export const ResolveOutputSchema = Type.Object(
|
|
13
18
|
{
|
|
14
19
|
kind: Type.Enum(
|
|
15
|
-
["resolved", "
|
|
20
|
+
["resolved", "file-outline", "disambiguation", "kind-mismatch", "invalid-input"],
|
|
16
21
|
{ type: "string" },
|
|
17
22
|
),
|
|
18
23
|
confidence: ConfidenceSchema,
|
|
@@ -23,7 +28,18 @@ export const ResolveOutputSchema = Type.Object(
|
|
|
23
28
|
message: Type.Optional(Type.String()),
|
|
24
29
|
file: Type.Optional(Type.String()),
|
|
25
30
|
requestedKind: Type.Optional(Type.String()),
|
|
26
|
-
|
|
31
|
+
unknownLevelCount: Type.Optional(Type.Integer()),
|
|
32
|
+
notListed: Type.Optional(
|
|
33
|
+
Type.Object(
|
|
34
|
+
{
|
|
35
|
+
importedNames: Type.Union([NameSpanSchema, Type.Null()]),
|
|
36
|
+
exportListNames: Type.Union([NameSpanSchema, Type.Null()]),
|
|
37
|
+
reExportStatements: Type.Union([NameSpanSchema, Type.Null()]),
|
|
38
|
+
localDeclarations: Type.Integer(),
|
|
39
|
+
},
|
|
40
|
+
{ additionalProperties: false },
|
|
41
|
+
),
|
|
42
|
+
),
|
|
27
43
|
discoveryProvenance: Type.Optional(
|
|
28
44
|
Type.Array(Type.Enum(["semantic", "structural"], { type: "string" })),
|
|
29
45
|
),
|
|
@@ -80,22 +96,39 @@ export function structuredResolveResult(
|
|
|
80
96
|
nextQueries: data.nextQueries,
|
|
81
97
|
notes: outcome.kind === "resolved" ? [...outcome.notes] : [],
|
|
82
98
|
...(data.message === undefined ? {} : { message: data.message }),
|
|
83
|
-
...(data.
|
|
99
|
+
...(data.outlineFile === undefined ? {} : { file: data.outlineFile }),
|
|
84
100
|
...(data.requestedKind === undefined ? {} : { requestedKind: data.requestedKind }),
|
|
85
|
-
...(data.
|
|
101
|
+
...(data.outlineNotListed === undefined
|
|
102
|
+
? {}
|
|
103
|
+
: { notListed: structuredNotListed(data.outlineNotListed) }),
|
|
104
|
+
...(data.outlineUnknownLevelCount === undefined
|
|
86
105
|
? {}
|
|
87
|
-
: {
|
|
88
|
-
...(data.
|
|
106
|
+
: { unknownLevelCount: data.outlineUnknownLevelCount }),
|
|
107
|
+
...(data.outlineDiscoveryProvenance === undefined
|
|
89
108
|
? {}
|
|
90
|
-
: { discoveryProvenance: [...data.
|
|
91
|
-
...(data.
|
|
92
|
-
|
|
109
|
+
: { discoveryProvenance: [...data.outlineDiscoveryProvenance] }),
|
|
110
|
+
...(data.outlinePartialReason === undefined
|
|
111
|
+
? {}
|
|
112
|
+
: { partialReason: data.outlinePartialReason }),
|
|
113
|
+
...(data.outlineErrorRanges === undefined
|
|
93
114
|
? {}
|
|
94
115
|
: {
|
|
95
|
-
errorRanges: data.
|
|
116
|
+
errorRanges: data.outlineErrorRanges.map((range) => ({
|
|
96
117
|
start: { ...range.start },
|
|
97
118
|
end: { ...range.end },
|
|
98
119
|
})),
|
|
99
120
|
}),
|
|
100
121
|
};
|
|
101
122
|
}
|
|
123
|
+
|
|
124
|
+
/** Copy outline omission counts into the codemode contract. */
|
|
125
|
+
function structuredNotListed(notListed: NonNullable<ResolveDetails["outlineNotListed"]>) {
|
|
126
|
+
const span = (value: { count: number; startLine: number; endLine: number } | null) =>
|
|
127
|
+
value ? { ...value } : null;
|
|
128
|
+
return {
|
|
129
|
+
importedNames: span(notListed.importedNames),
|
|
130
|
+
exportListNames: span(notListed.exportListNames),
|
|
131
|
+
reExportStatements: span(notListed.reExportStatements),
|
|
132
|
+
localDeclarations: notListed.localDeclarations,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -113,8 +113,8 @@ function sectionFacts(details: Details): string[] {
|
|
|
113
113
|
case "resolve":
|
|
114
114
|
return [
|
|
115
115
|
`${details.data.resultKind}: ${details.data.targetCount} targets; ${details.data.omittedCount} cap omissions.`,
|
|
116
|
-
...(details.data.
|
|
117
|
-
? [`Partial discovery: ${details.data.
|
|
116
|
+
...(details.data.outlinePartialReason
|
|
117
|
+
? [`Partial discovery: ${details.data.outlinePartialReason}`]
|
|
118
118
|
: []),
|
|
119
119
|
...details.data.targets
|
|
120
120
|
.slice(0, 3)
|
package/src/tool/result/types.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
StructuredMatch,
|
|
10
10
|
StructuredScanSummary,
|
|
11
11
|
} from "../../analysis/search/pattern.ts";
|
|
12
|
+
import type { FileOutlineNotListed } from "../../analysis/target/types.ts";
|
|
12
13
|
import type {
|
|
13
14
|
HealthDiagnosticObservation,
|
|
14
15
|
HealthRefreshState,
|
|
@@ -123,20 +124,22 @@ export type { DisambiguationCandidateData as DisambiguationCandidate } from "../
|
|
|
123
124
|
export interface ResolveDetails {
|
|
124
125
|
resultKind:
|
|
125
126
|
| "resolved"
|
|
126
|
-
| "
|
|
127
|
+
| "file-outline"
|
|
127
128
|
| "disambiguation"
|
|
128
129
|
| "kind-mismatch"
|
|
129
130
|
| "invalid-input"
|
|
130
131
|
| "unavailable";
|
|
131
|
-
/** Workspace-relative source file
|
|
132
|
-
|
|
133
|
-
/** Providers that successfully enumerated
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
/** Provider recovery that makes this
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
/** Workspace-relative source file of a File outline. */
|
|
133
|
+
outlineFile?: string;
|
|
134
|
+
/** Providers that successfully enumerated the File outline's file. */
|
|
135
|
+
outlineDiscoveryProvenance?: readonly TargetProviderProvenance[];
|
|
136
|
+
/** Outline declarations whose provider reported no enclosing declaration. */
|
|
137
|
+
outlineUnknownLevelCount?: number;
|
|
138
|
+
/** Provider recovery that makes this File outline incomplete. */
|
|
139
|
+
outlinePartialReason?: string | null;
|
|
140
|
+
outlineErrorRanges?: readonly SourceRange[];
|
|
141
|
+
/** Discovered declarations left out of the File outline, with exact counts. */
|
|
142
|
+
outlineNotListed?: FileOutlineNotListed;
|
|
140
143
|
/** Strict provider kind that produced a near-match result. */
|
|
141
144
|
requestedKind?: TargetSymbolKind;
|
|
142
145
|
confidence: ConfidenceMode;
|
package/src/ui/tui/common.ts
CHANGED
|
@@ -310,13 +310,13 @@ export function buildSimpleCompact(data: Record<string, unknown> | undefined, th
|
|
|
310
310
|
const confidence = typeof data.confidence === "string" ? data.confidence : "";
|
|
311
311
|
const dot = theme.fg("dim", "·");
|
|
312
312
|
const segments = badges.map((badge) => theme.fg("success", theme.bold(badge)));
|
|
313
|
-
const
|
|
313
|
+
const unknownLevelCount = data.outlineUnknownLevelCount;
|
|
314
314
|
if (
|
|
315
|
-
typeof
|
|
316
|
-
Number.isInteger(
|
|
317
|
-
|
|
315
|
+
typeof unknownLevelCount === "number" &&
|
|
316
|
+
Number.isInteger(unknownLevelCount) &&
|
|
317
|
+
unknownLevelCount > 0
|
|
318
318
|
) {
|
|
319
|
-
segments.push(theme.fg("warning", `${
|
|
319
|
+
segments.push(theme.fg("warning", `${unknownLevelCount} position unknown`));
|
|
320
320
|
}
|
|
321
321
|
if (confidence) {
|
|
322
322
|
segments.push(`${theme.fg("dim", "confidence")} ${theme.fg("muted", confidence)}`);
|
|
@@ -349,13 +349,13 @@ function structuredDetailLines(data: Record<string, unknown>): string[] {
|
|
|
349
349
|
|
|
350
350
|
lines.push(...inspectSectionStatusLines(data.sections));
|
|
351
351
|
|
|
352
|
-
const
|
|
352
|
+
const unknownLevelCount = data.outlineUnknownLevelCount;
|
|
353
353
|
if (
|
|
354
|
-
typeof
|
|
355
|
-
Number.isInteger(
|
|
356
|
-
|
|
354
|
+
typeof unknownLevelCount === "number" &&
|
|
355
|
+
Number.isInteger(unknownLevelCount) &&
|
|
356
|
+
unknownLevelCount > 0
|
|
357
357
|
) {
|
|
358
|
-
lines.push(`
|
|
358
|
+
lines.push(`position unknown: ${unknownLevelCount}`);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
const checkNext = data.checkNext;
|