@mrclrchtr/supi-code-intelligence 11.1.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 +41 -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 +81 -7
- 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/node_modules/semver/LICENSE +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -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 +174 -49
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +306 -75
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
- 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/scanner.ts +27 -15
- 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/capability/capability-warnings.ts +18 -12
- package/src/analysis/health/check.ts +115 -0
- package/src/analysis/health/diagnostics.ts +3 -0
- package/src/analysis/health/file-scope.ts +2 -3
- package/src/analysis/health/semantic-state.ts +38 -0
- package/src/analysis/health/server-status.ts +14 -2
- package/src/analysis/health/signals.ts +2 -0
- package/src/analysis/health/status.ts +82 -0
- package/src/analysis/refactor/apply.ts +17 -8
- 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/health-types.ts +7 -0
- package/src/session/health-workflow.ts +8 -43
- 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 +184 -20
- package/src/session/orientation/context-facts.ts +27 -2
- package/src/session/orientation/context-sections.ts +49 -3
- package/src/session/orientation/facts.ts +132 -0
- package/src/session/orientation/gather.ts +98 -11
- package/src/session/orientation/workspace-context.ts +16 -6
- package/src/session/orientation-types.ts +8 -0
- package/src/session/orientation-workflow.ts +20 -6
- package/src/session/refactor-identity.ts +76 -0
- package/src/session/refactor-plans.ts +5 -2
- package/src/session/refactor-workflow.ts +15 -17
- 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/guidance.ts +1 -1
- 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/markdown.ts +12 -2
- package/src/tool/code_health/result.ts +18 -3
- package/src/tool/code_health/spec.ts +5 -3
- package/src/tool/code_health/structured-schema.ts +250 -0
- package/src/tool/code_health/structured.ts +256 -0
- package/src/tool/code_inspect/result.ts +11 -5
- package/src/tool/code_inspect/spec.ts +7 -1
- package/src/tool/code_inspect/structured.ts +231 -0
- package/src/tool/code_orientation/execute.ts +1 -1
- package/src/tool/code_orientation/result.ts +31 -8
- package/src/tool/code_orientation/spec.ts +2 -0
- package/src/tool/code_orientation/structured-schema.ts +617 -0
- package/src/tool/code_orientation/structured-workspace.ts +194 -0
- package/src/tool/code_orientation/structured.ts +189 -0
- package/src/tool/code_orientation/workspace-format.ts +2 -5
- package/src/tool/code_orientation/workspace-observations.ts +81 -0
- package/src/tool/code_orientation/workspace-output.ts +5 -0
- package/src/tool/code_orientation/workspace-projects.ts +16 -31
- package/src/tool/code_orientation/workspace-sections.ts +46 -32
- package/src/tool/code_refactor_apply/execute.ts +1 -1
- package/src/tool/code_refactor_apply/result.ts +14 -6
- package/src/tool/code_refactor_apply/spec.ts +2 -0
- package/src/tool/code_refactor_apply/structured.ts +49 -0
- package/src/tool/code_refactor_plan/result.ts +18 -9
- package/src/tool/code_refactor_plan/spec.ts +2 -0
- package/src/tool/code_refactor_plan/structured.ts +127 -0
- 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 +12 -6
- package/src/ui/status-command.ts +147 -322
- package/src/ui/status-overlay.ts +584 -421
- package/src/ui/status-presentation.ts +108 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
2
3
|
import type { InventoryEntry, WorkspaceObservation } from "../../analysis/workspace/types.ts";
|
|
3
4
|
import {
|
|
4
5
|
type WorkspaceOrientationFacts,
|
|
@@ -10,9 +11,10 @@ import type {
|
|
|
10
11
|
} from "../../session/orientation-types.ts";
|
|
11
12
|
import { gradleSections } from "./gradle-sections.ts";
|
|
12
13
|
import { code, plain, sourcePath, tableSection } from "./workspace-format.ts";
|
|
14
|
+
import { workspaceCollectionStatus } from "./workspace-observations.ts";
|
|
13
15
|
import { projectSections } from "./workspace-projects.ts";
|
|
14
16
|
|
|
15
|
-
/**
|
|
17
|
+
/** Project one captured observation without collecting new workspace facts. */
|
|
16
18
|
export function workspaceSections(
|
|
17
19
|
data: OrientationResultData,
|
|
18
20
|
limit: number,
|
|
@@ -104,37 +106,25 @@ function collectionStatus(
|
|
|
104
106
|
observation: WorkspaceObservation,
|
|
105
107
|
): OrientationSectionData {
|
|
106
108
|
if (section.key === "workspace.issues" || section.key.startsWith("gradle.")) return section;
|
|
107
|
-
const
|
|
108
|
-
const inventoryPartial =
|
|
109
|
-
collection.stopReason !== "complete" ||
|
|
110
|
-
collection.errors.some((error) => error.stage === "inventory");
|
|
109
|
+
const state = workspaceCollectionStatus(observation.collection);
|
|
111
110
|
const partial = section.provenance.some((source) => source.source === "filesystem")
|
|
112
|
-
? inventoryPartial
|
|
113
|
-
:
|
|
111
|
+
? state.inventoryPartial
|
|
112
|
+
: state.metadataPartial;
|
|
114
113
|
if (!partial) return section;
|
|
115
|
-
const reason =
|
|
116
|
-
collection.stopReason === "entry-limit"
|
|
117
|
-
? "safety-limit"
|
|
118
|
-
: collection.stopReason === "deadline"
|
|
119
|
-
? "timeout"
|
|
120
|
-
: inventoryPartial
|
|
121
|
-
? "filesystem-error"
|
|
122
|
-
: "configuration-error";
|
|
123
114
|
return {
|
|
124
115
|
...section,
|
|
125
116
|
status: "partial",
|
|
126
|
-
reason:
|
|
127
|
-
? "Inventory collection is incomplete"
|
|
128
|
-
: "Metadata collection is incomplete",
|
|
117
|
+
reason: state.reason,
|
|
129
118
|
evidenceLists: section.evidenceLists.map((list) => ({
|
|
130
119
|
...list,
|
|
131
120
|
totalCount: null,
|
|
132
|
-
partialReason:
|
|
121
|
+
partialReason: state.partialReason,
|
|
133
122
|
})),
|
|
134
123
|
};
|
|
135
124
|
}
|
|
136
125
|
|
|
137
|
-
|
|
126
|
+
/** Nearest project declarations containing the focus, established by parsed metadata. */
|
|
127
|
+
export function containingProjects(facts: WorkspaceOrientationFacts, root: string) {
|
|
138
128
|
const candidates = facts.observation.projects.filter((project) =>
|
|
139
129
|
within(path.resolve(facts.observation.root, project.directory), root),
|
|
140
130
|
);
|
|
@@ -166,11 +156,17 @@ function inventoryNote(
|
|
|
166
156
|
return `Inventory: ${files} regular file${files === 1 ? "" : "s"} and ${links} symbolic links. Includes ${policy}; link targets are not followed.${exclusions} Collection ${collection.status}${collection.stopReason !== "complete" ? ` (${collection.stopReason}; more entries may exist)` : ""}.`;
|
|
167
157
|
}
|
|
168
158
|
|
|
169
|
-
|
|
159
|
+
/** Named inventory observations before presentation and per-list selection. */
|
|
160
|
+
export interface WorkspaceInventoryFacts {
|
|
161
|
+
readonly directories: readonly { path: string; entryCount: number }[];
|
|
162
|
+
readonly directFiles: readonly InventoryEntry[];
|
|
163
|
+
readonly extensions: readonly { extension: string; fileCount: number }[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Derive direct children and extension counts from the already captured inventory. */
|
|
167
|
+
export function collectWorkspaceInventory(
|
|
170
168
|
entries: readonly InventoryEntry[],
|
|
171
|
-
|
|
172
|
-
limit: number,
|
|
173
|
-
): OrientationSectionData[] {
|
|
169
|
+
): WorkspaceInventoryFacts {
|
|
174
170
|
const directories = new Map<string, number>();
|
|
175
171
|
const extensions = new Map<string, number>();
|
|
176
172
|
for (const entry of entries) {
|
|
@@ -181,13 +177,30 @@ function inventorySections(
|
|
|
181
177
|
extensions.set(extension, (extensions.get(extension) ?? 0) + 1);
|
|
182
178
|
}
|
|
183
179
|
}
|
|
184
|
-
|
|
180
|
+
return {
|
|
181
|
+
directories: [...directories]
|
|
182
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
183
|
+
.map(([name, count]) => ({ path: `${name}/`, entryCount: count })),
|
|
184
|
+
directFiles: entries.filter((entry) => !entry.path.includes("/")),
|
|
185
|
+
extensions: [...extensions]
|
|
186
|
+
.sort(([a, an], [b, bn]) => bn - an || a.localeCompare(b))
|
|
187
|
+
.map(([extension, count]) => ({ extension, fileCount: count })),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function inventorySections(
|
|
192
|
+
entries: readonly InventoryEntry[],
|
|
193
|
+
facts: WorkspaceOrientationFacts,
|
|
194
|
+
limit: number,
|
|
195
|
+
): OrientationSectionData[] {
|
|
196
|
+
const { directories, directFiles, extensions } = collectWorkspaceInventory(entries);
|
|
185
197
|
const sections = [
|
|
186
198
|
tableSection("workspace.directories", "Direct directories", {
|
|
187
199
|
headers: ["Path", "Entries at all depths"],
|
|
188
|
-
rows: [
|
|
189
|
-
|
|
190
|
-
|
|
200
|
+
rows: directories.map(({ path: directory, entryCount }) => [
|
|
201
|
+
code(directory),
|
|
202
|
+
String(entryCount),
|
|
203
|
+
]),
|
|
191
204
|
limit,
|
|
192
205
|
detail: "included paths",
|
|
193
206
|
}),
|
|
@@ -204,9 +217,10 @@ function inventorySections(
|
|
|
204
217
|
sections.push(
|
|
205
218
|
tableSection("workspace.extensions", "File extensions (filenames, not language support)", {
|
|
206
219
|
headers: ["Extension", "Regular files"],
|
|
207
|
-
rows: [
|
|
208
|
-
|
|
209
|
-
|
|
220
|
+
rows: extensions.map(({ extension, fileCount }) => [
|
|
221
|
+
extension ? code(extension) : "No extension",
|
|
222
|
+
String(fileCount),
|
|
223
|
+
]),
|
|
210
224
|
limit: facts.overview ? Math.min(5, limit) : limit,
|
|
211
225
|
detail: "included regular files",
|
|
212
226
|
}),
|
|
@@ -215,5 +229,5 @@ function inventorySections(
|
|
|
215
229
|
}
|
|
216
230
|
|
|
217
231
|
export function display(cwd: string, target: string): string {
|
|
218
|
-
return
|
|
232
|
+
return toDisplayPath(cwd, target);
|
|
219
233
|
}
|
|
@@ -13,5 +13,5 @@ export async function executeRefactorApplyTool(
|
|
|
13
13
|
ctx: CodeIntelToolExecCtx,
|
|
14
14
|
): Promise<CodeIntelResult> {
|
|
15
15
|
const outcome = await ctx.session.applyRefactor(params, toWorkflowControl(ctx));
|
|
16
|
-
return finishRefactorApplyResult(outcome);
|
|
16
|
+
return finishRefactorApplyResult(outcome, ctx.cwd);
|
|
17
17
|
}
|
|
@@ -4,22 +4,30 @@ import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts
|
|
|
4
4
|
import { renderRefactorApplyResult } from "../refactor-markdown.ts";
|
|
5
5
|
import { searchErrorResult } from "../result/errors.ts";
|
|
6
6
|
import { assembleRefactorApplyDetails } from "../result/refactor.ts";
|
|
7
|
+
import { structuredRefactorApply } from "./structured.ts";
|
|
7
8
|
|
|
8
9
|
type RefactorApplyOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["applyRefactor"]>>;
|
|
9
10
|
|
|
10
11
|
/** Assemble the final model-visible code_refactor_apply result for one workflow outcome. */
|
|
11
|
-
export function finishRefactorApplyResult(
|
|
12
|
+
export function finishRefactorApplyResult(
|
|
13
|
+
outcome: RefactorApplyOutcome,
|
|
14
|
+
cwd: string,
|
|
15
|
+
): CodeIntelResult {
|
|
12
16
|
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
13
17
|
if (outcome.kind === "invalid-input") {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
return {
|
|
19
|
+
...searchErrorResult(`**Error:** ${outcome.message}`, {
|
|
20
|
+
nextQueries: ["Generate a fresh plan with code_refactor_plan"],
|
|
21
|
+
message: outcome.message,
|
|
22
|
+
}),
|
|
23
|
+
structuredContent: structuredRefactorApply(outcome, cwd),
|
|
24
|
+
};
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
const assembly = assembleRefactorApplyDetails(outcome.result, outcome.plan);
|
|
27
|
+
const assembly = assembleRefactorApplyDetails(outcome.result, outcome.plan, cwd);
|
|
21
28
|
return {
|
|
22
29
|
content: renderRefactorApplyResult(assembly),
|
|
30
|
+
structuredContent: structuredRefactorApply(outcome, cwd),
|
|
23
31
|
details: {
|
|
24
32
|
type: "search",
|
|
25
33
|
data: assembly.details,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
3
3
|
import { executeRefactorApplyTool } from "./execute.ts";
|
|
4
|
+
import { RefactorApplyOutputSchema } from "./structured.ts";
|
|
4
5
|
import { renderRefactorApplyCall, renderRefactorApplyResult } from "./tui.ts";
|
|
5
6
|
|
|
6
7
|
export const CODE_REFACTOR_APPLY_TOOL_NAME = "code_refactor_apply";
|
|
@@ -19,6 +20,7 @@ export const codeRefactorApplySpec = {
|
|
|
19
20
|
},
|
|
20
21
|
{ additionalProperties: false },
|
|
21
22
|
),
|
|
23
|
+
outputSchema: RefactorApplyOutputSchema,
|
|
22
24
|
run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
|
|
23
25
|
executeRefactorApplyTool(params as Parameters<typeof executeRefactorApplyTool>[0], ctx),
|
|
24
26
|
renderCall: renderRefactorApplyCall,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
3
|
+
import type { RefactorApplyWorkflowOutcome } from "../../session/refactor-types.ts";
|
|
4
|
+
|
|
5
|
+
/** Native application outcome, separate from recovery's absolute changed-file paths. */
|
|
6
|
+
export const RefactorApplyOutputSchema = Type.Union([
|
|
7
|
+
Type.Object(
|
|
8
|
+
{
|
|
9
|
+
kind: Type.Literal("applied"),
|
|
10
|
+
planId: Type.String(),
|
|
11
|
+
files: Type.Array(
|
|
12
|
+
Type.Object(
|
|
13
|
+
{ file: Type.String(), editCount: Type.Integer({ minimum: 0 }) },
|
|
14
|
+
{ additionalProperties: false },
|
|
15
|
+
),
|
|
16
|
+
),
|
|
17
|
+
fileCount: Type.Integer({ minimum: 0 }),
|
|
18
|
+
editCount: Type.Integer({ minimum: 0 }),
|
|
19
|
+
},
|
|
20
|
+
{ additionalProperties: false },
|
|
21
|
+
),
|
|
22
|
+
Type.Object(
|
|
23
|
+
{ kind: Type.Literal("invalid-input"), message: Type.String(), nextAction: Type.String() },
|
|
24
|
+
{ additionalProperties: false },
|
|
25
|
+
),
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
/** Project applied file counts without exposing the stored plan. */
|
|
29
|
+
export function structuredRefactorApply(
|
|
30
|
+
outcome: Exclude<RefactorApplyWorkflowOutcome, { kind: "unavailable" }>,
|
|
31
|
+
cwd: string,
|
|
32
|
+
): Static<typeof RefactorApplyOutputSchema> {
|
|
33
|
+
if (outcome.kind === "invalid-input")
|
|
34
|
+
return {
|
|
35
|
+
kind: outcome.kind,
|
|
36
|
+
message: outcome.message,
|
|
37
|
+
nextAction: "Generate a fresh plan with code_refactor_plan",
|
|
38
|
+
};
|
|
39
|
+
const counts = new Map<string, number>();
|
|
40
|
+
for (const edit of outcome.plan.edits.edits)
|
|
41
|
+
counts.set(edit.file, (counts.get(edit.file) ?? 0) + 1);
|
|
42
|
+
return {
|
|
43
|
+
kind: "applied",
|
|
44
|
+
planId: outcome.plan.id,
|
|
45
|
+
files: [...counts].map(([file, editCount]) => ({ file: toDisplayPath(cwd, file), editCount })),
|
|
46
|
+
fileCount: outcome.result.filesChanged,
|
|
47
|
+
editCount: outcome.result.totalEdits,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** Result assembly for code_refactor_plan. */
|
|
2
2
|
|
|
3
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
3
4
|
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
4
5
|
import { renderRefactorPlanResult } from "../refactor-markdown.ts";
|
|
5
6
|
import { searchErrorResult } from "../result/errors.ts";
|
|
6
7
|
import { assembleRefactorPlanDetails } from "../result/refactor.ts";
|
|
8
|
+
import { structuredRefactorPlan } from "./structured.ts";
|
|
7
9
|
|
|
8
10
|
type RefactorPlanOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["planRefactor"]>>;
|
|
9
11
|
|
|
@@ -14,27 +16,34 @@ export function finishRefactorPlanResult(
|
|
|
14
16
|
): CodeIntelResult {
|
|
15
17
|
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
16
18
|
if (outcome.kind === "invalid-input") {
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return {
|
|
20
|
+
...searchErrorResult(`**Error:** ${outcome.message}`, {
|
|
21
|
+
nextQueries: ["Fix the target or operation and retry"],
|
|
22
|
+
message: outcome.message,
|
|
23
|
+
}),
|
|
24
|
+
structuredContent: structuredRefactorPlan(outcome, cwd),
|
|
25
|
+
};
|
|
21
26
|
}
|
|
22
27
|
if (outcome.kind === "ambiguous") {
|
|
23
28
|
const candidates = outcome.candidates
|
|
24
29
|
.map(
|
|
25
30
|
(candidate, index) =>
|
|
26
|
-
`${index + 1}. ${candidate.description} (${candidate.file}:${candidate.line})`,
|
|
31
|
+
`${index + 1}. ${candidate.description} (${candidate.file === undefined ? candidate.file : toDisplayPath(cwd, candidate.file)}:${candidate.line})`,
|
|
27
32
|
)
|
|
28
33
|
.join("\n");
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
return {
|
|
35
|
+
...searchErrorResult(`**Refactor ambiguous:**\n${candidates}`, {
|
|
36
|
+
nextQueries: ["Use a precise target handle or anchor"],
|
|
37
|
+
message: "The refactor target is ambiguous.",
|
|
38
|
+
}),
|
|
39
|
+
structuredContent: structuredRefactorPlan(outcome, cwd),
|
|
40
|
+
};
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
const assembly = assembleRefactorPlanDetails(outcome.plan, cwd);
|
|
36
44
|
return {
|
|
37
45
|
content: renderRefactorPlanResult(assembly),
|
|
46
|
+
structuredContent: structuredRefactorPlan(outcome, cwd),
|
|
38
47
|
details: {
|
|
39
48
|
type: "search",
|
|
40
49
|
data: assembly.details,
|
|
@@ -2,6 +2,7 @@ import { Type } from "typebox";
|
|
|
2
2
|
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
3
3
|
import { RefactorOperationParam, RefactorTargetParam } from "../schemas.ts";
|
|
4
4
|
import { executeRefactorPlanTool } from "./execute.ts";
|
|
5
|
+
import { RefactorPlanOutputSchema } from "./structured.ts";
|
|
5
6
|
import { renderRefactorPlanCall, renderRefactorPlanResult } from "./tui.ts";
|
|
6
7
|
|
|
7
8
|
export const CODE_REFACTOR_PLAN_TOOL_NAME = "code_refactor_plan";
|
|
@@ -18,6 +19,7 @@ export const codeRefactorPlanSpec = {
|
|
|
18
19
|
},
|
|
19
20
|
{ additionalProperties: false },
|
|
20
21
|
),
|
|
22
|
+
outputSchema: RefactorPlanOutputSchema,
|
|
21
23
|
run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
|
|
22
24
|
executeRefactorPlanTool(params as Parameters<typeof executeRefactorPlanTool>[0], ctx),
|
|
23
25
|
renderCall: renderRefactorPlanCall,
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
3
|
+
import {
|
|
4
|
+
PUBLIC_REFACTOR_OPERATION_NAMES,
|
|
5
|
+
type RefactorPlanWorkflowOutcome,
|
|
6
|
+
} from "../../session/refactor-types.ts";
|
|
7
|
+
|
|
8
|
+
const Position = Type.Object(
|
|
9
|
+
{ line: Type.Integer({ minimum: 0 }), character: Type.Integer({ minimum: 0 }) },
|
|
10
|
+
{ additionalProperties: false },
|
|
11
|
+
);
|
|
12
|
+
const Edit = Type.Object(
|
|
13
|
+
{
|
|
14
|
+
file: Type.String(),
|
|
15
|
+
range: Type.Object(
|
|
16
|
+
{ start: Position, end: Position },
|
|
17
|
+
{
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
description: "Zero-based UTF-16 positions; end is exclusive.",
|
|
20
|
+
},
|
|
21
|
+
),
|
|
22
|
+
newText: Type.String(),
|
|
23
|
+
},
|
|
24
|
+
{ additionalProperties: false },
|
|
25
|
+
);
|
|
26
|
+
const Candidate = Type.Object(
|
|
27
|
+
{
|
|
28
|
+
description: Type.String(),
|
|
29
|
+
file: Type.Optional(Type.String()),
|
|
30
|
+
line: Type.Optional(Type.Integer()),
|
|
31
|
+
character: Type.Optional(Type.Integer()),
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
description:
|
|
36
|
+
"Provider-reported candidate location, when available; one-based line and UTF-16 character.",
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/** Native plan data, including all edits rather than the bounded text preview. */
|
|
41
|
+
export const RefactorPlanOutputSchema = Type.Union([
|
|
42
|
+
Type.Object(
|
|
43
|
+
{
|
|
44
|
+
kind: Type.Literal("completed"),
|
|
45
|
+
planId: Type.String(),
|
|
46
|
+
operation: Type.Enum([...PUBLIC_REFACTOR_OPERATION_NAMES], { type: "string" }),
|
|
47
|
+
target: Type.Object(
|
|
48
|
+
{ file: Type.String(), line: Type.Integer(), character: Type.Integer() },
|
|
49
|
+
{ additionalProperties: false, description: "One-based line and UTF-16 character." },
|
|
50
|
+
),
|
|
51
|
+
newName: Type.Optional(Type.String()),
|
|
52
|
+
destination: Type.Optional(Type.String()),
|
|
53
|
+
edits: Type.Array(Edit),
|
|
54
|
+
fileCount: Type.Integer({ minimum: 0 }),
|
|
55
|
+
editCount: Type.Integer({ minimum: 0 }),
|
|
56
|
+
provenance: Type.Enum(["semantic", "structural"], { type: "string" }),
|
|
57
|
+
nextAction: Type.Object(
|
|
58
|
+
{ tool: Type.Literal("code_refactor_apply"), planId: Type.String() },
|
|
59
|
+
{ additionalProperties: false },
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{ additionalProperties: false },
|
|
63
|
+
),
|
|
64
|
+
Type.Object(
|
|
65
|
+
{
|
|
66
|
+
kind: Type.Literal("ambiguous"),
|
|
67
|
+
candidates: Type.Array(Candidate),
|
|
68
|
+
nextAction: Type.String(),
|
|
69
|
+
},
|
|
70
|
+
{ additionalProperties: false },
|
|
71
|
+
),
|
|
72
|
+
Type.Object(
|
|
73
|
+
{ kind: Type.Literal("invalid-input"), message: Type.String(), nextAction: Type.String() },
|
|
74
|
+
{ additionalProperties: false },
|
|
75
|
+
),
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
/** Project public facts without plan authority, fingerprints, or document preconditions. */
|
|
79
|
+
export function structuredRefactorPlan(
|
|
80
|
+
outcome: Exclude<RefactorPlanWorkflowOutcome, { kind: "unavailable" }>,
|
|
81
|
+
cwd: string,
|
|
82
|
+
): Static<typeof RefactorPlanOutputSchema> {
|
|
83
|
+
if (outcome.kind === "invalid-input")
|
|
84
|
+
return {
|
|
85
|
+
kind: outcome.kind,
|
|
86
|
+
message: outcome.message,
|
|
87
|
+
nextAction: "Fix the target or operation and retry",
|
|
88
|
+
};
|
|
89
|
+
if (outcome.kind === "ambiguous")
|
|
90
|
+
return {
|
|
91
|
+
kind: outcome.kind,
|
|
92
|
+
candidates: outcome.candidates.map((candidate) => ({
|
|
93
|
+
description: candidate.description,
|
|
94
|
+
...(candidate.file === undefined ? {} : { file: toDisplayPath(cwd, candidate.file) }),
|
|
95
|
+
...(candidate.line === undefined ? {} : { line: candidate.line }),
|
|
96
|
+
...(candidate.character === undefined ? {} : { character: candidate.character }),
|
|
97
|
+
})),
|
|
98
|
+
nextAction: "Use a precise target handle or anchor",
|
|
99
|
+
};
|
|
100
|
+
const plan = outcome.plan;
|
|
101
|
+
const operation = PUBLIC_REFACTOR_OPERATION_NAMES.find((name) => name === plan.operation);
|
|
102
|
+
if (operation === undefined) throw new Error(`Unsupported refactor operation: ${plan.operation}`);
|
|
103
|
+
return {
|
|
104
|
+
kind: "completed",
|
|
105
|
+
planId: plan.id,
|
|
106
|
+
operation,
|
|
107
|
+
target: {
|
|
108
|
+
file: toDisplayPath(cwd, plan.targetFile),
|
|
109
|
+
line: plan.targetLine,
|
|
110
|
+
character: plan.targetCharacter,
|
|
111
|
+
},
|
|
112
|
+
...(plan.newName === undefined ? {} : { newName: plan.newName }),
|
|
113
|
+
...(plan.destination === undefined ? {} : { destination: plan.destination }),
|
|
114
|
+
edits: plan.edits.edits.map((edit) => ({
|
|
115
|
+
file: toDisplayPath(cwd, edit.file),
|
|
116
|
+
range: {
|
|
117
|
+
start: { line: edit.range.start.line, character: edit.range.start.character },
|
|
118
|
+
end: { line: edit.range.end.line, character: edit.range.end.character },
|
|
119
|
+
},
|
|
120
|
+
newText: edit.newText,
|
|
121
|
+
})),
|
|
122
|
+
fileCount: new Set(plan.edits.edits.map((edit) => edit.file)).size,
|
|
123
|
+
editCount: plan.edits.edits.length,
|
|
124
|
+
provenance: plan.evidenceSource ?? "semantic",
|
|
125
|
+
nextAction: { tool: "code_refactor_apply", planId: plan.id },
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Markdown adapter for assembled code_resolve outcomes. */
|
|
2
2
|
|
|
3
|
-
import { relative } from "node:path";
|
|
4
3
|
import { renderEvidenceListMetadataDisclosure } from "../../analysis/evidence.ts";
|
|
5
|
-
import
|
|
4
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
5
|
+
import type { TargetWorkflowOutcome } from "../../session/target-workflow.ts";
|
|
6
6
|
import { formatPartialCandidateDisclosure } from "../result/candidate-row.ts";
|
|
7
7
|
import type { ResolveDetails } from "../result/types.ts";
|
|
8
8
|
import type { ResolveResultAssembly } from "./result.ts";
|
|
@@ -12,7 +12,7 @@ export function renderResolveResult(assembly: ResolveResultAssembly): string {
|
|
|
12
12
|
const { outcome, cwd } = assembly;
|
|
13
13
|
switch (outcome.kind) {
|
|
14
14
|
case "resolved":
|
|
15
|
-
return renderResolved(outcome
|
|
15
|
+
return renderResolved(outcome, cwd);
|
|
16
16
|
case "target-group":
|
|
17
17
|
return renderTargetGroup(assembly.details);
|
|
18
18
|
case "disambiguation":
|
|
@@ -27,11 +27,11 @@ export function renderResolveResult(assembly: ResolveResultAssembly): string {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function renderResolved(
|
|
30
|
-
|
|
31
|
-
notes: readonly string[],
|
|
30
|
+
outcome: Extract<TargetWorkflowOutcome, { kind: "resolved" }>,
|
|
32
31
|
cwd: string,
|
|
33
32
|
): string {
|
|
34
|
-
const
|
|
33
|
+
const { entry: target, notes } = outcome;
|
|
34
|
+
const relFile = toDisplayPath(cwd, target.file);
|
|
35
35
|
const displayKind = target.nativeKind ?? target.kind;
|
|
36
36
|
const kind = displayKind ? ` \`${displayKind}\`` : "";
|
|
37
37
|
const name = target.name ? ` **${target.name}**${kind}` : "";
|
|
@@ -41,22 +41,12 @@ function renderResolved(
|
|
|
41
41
|
`confidence: ${target.confidence}; provenance: ${target.provenance.join("+")}`,
|
|
42
42
|
];
|
|
43
43
|
|
|
44
|
-
const resolutionNote = renderAnchoredResolutionNote(target);
|
|
45
|
-
if (resolutionNote) lines.push("", resolutionNote);
|
|
46
44
|
for (const note of notes) {
|
|
47
|
-
if (resolutionNote && isResolutionMetadataNote(note)) continue;
|
|
48
45
|
lines.push("", `_Note: ${note}_`);
|
|
49
46
|
}
|
|
50
47
|
return lines.join("\n");
|
|
51
48
|
}
|
|
52
49
|
|
|
53
|
-
function isResolutionMetadataNote(note: string): boolean {
|
|
54
|
-
return (
|
|
55
|
-
note.startsWith("Resolved from a declaration header and snapped to the identifier") ||
|
|
56
|
-
note === "Resolved from provider-backed structural identifier evidence."
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
50
|
function renderTargetGroup(details: ResolveDetails): string {
|
|
61
51
|
const discovery = details.groupDiscoveryProvenance?.join("+") || "unavailable";
|
|
62
52
|
const lines = [
|
|
@@ -114,20 +104,6 @@ function appendUnknownHierarchyDisclosure(lines: string[], count: number): void
|
|
|
114
104
|
);
|
|
115
105
|
}
|
|
116
106
|
|
|
117
|
-
function renderAnchoredResolutionNote(target: Readonly<TargetStoreEntry>): string | null {
|
|
118
|
-
const resolution = target.resolution;
|
|
119
|
-
if (!resolution) return null;
|
|
120
|
-
const degraded = resolution.source !== "semantic";
|
|
121
|
-
if (!resolution.snapped && !degraded) return null;
|
|
122
|
-
|
|
123
|
-
const requested = `${resolution.requested.line}:${resolution.requested.character}`;
|
|
124
|
-
const resolved = `${resolution.resolved.line}:${resolution.resolved.character}`;
|
|
125
|
-
if (resolution.snapped) {
|
|
126
|
-
return `_Note: snapped from requested coordinate ${requested} to name anchor ${resolved} (evidence: ${resolution.source})._`;
|
|
127
|
-
}
|
|
128
|
-
return `_Note: resolved from ${resolution.source} evidence; use code_inspect for point-level facts._`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
107
|
function renderDisambiguation(details: ResolveDetails): string {
|
|
132
108
|
const lines = [
|
|
133
109
|
"# Multiple matches found",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { relative } from "node:path";
|
|
2
1
|
import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
|
|
3
2
|
import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
|
|
4
3
|
import { createEvidenceList } from "../../analysis/evidence.ts";
|
|
4
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
5
5
|
import type { ResolveTargetInput } from "../../session/target-input.ts";
|
|
6
6
|
import type { TargetStoreEntry } from "../../session/target-store.ts";
|
|
7
7
|
import type { TargetWorkflowOutcome } from "../../session/target-workflow.ts";
|
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
import { formatCandidateRow } from "../result/candidate-row.ts";
|
|
15
15
|
import { createToolDisplaySection } from "../result/display.ts";
|
|
16
16
|
import { scopedSymbolFailureMessage } from "../result/errors.ts";
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
AnchoredResolutionMetadata,
|
|
19
|
+
ResolveDetails,
|
|
20
|
+
ToolDisplaySection,
|
|
21
|
+
} from "../result/types.ts";
|
|
18
22
|
|
|
19
23
|
/** Presentation-neutral assembled code_resolve result. */
|
|
20
24
|
export interface ResolveResultAssembly {
|
|
@@ -80,19 +84,23 @@ export function assembleResolveResult(
|
|
|
80
84
|
function projectResolveOutcome(outcome: TargetWorkflowOutcome, cwd: string): ResolveProjection {
|
|
81
85
|
switch (outcome.kind) {
|
|
82
86
|
case "resolved":
|
|
83
|
-
return projectResolved(outcome
|
|
87
|
+
return projectResolved(outcome, cwd);
|
|
84
88
|
case "target-group":
|
|
85
89
|
return projectTargetGroup(outcome, cwd);
|
|
86
90
|
case "disambiguation":
|
|
87
91
|
case "kind-mismatch":
|
|
88
|
-
return projectCandidateOutcome(outcome);
|
|
92
|
+
return projectCandidateOutcome(outcome, cwd);
|
|
89
93
|
case "invalid-input":
|
|
90
94
|
case "unavailable":
|
|
91
95
|
return projectFailure(outcome);
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
function projectResolved(
|
|
99
|
+
function projectResolved(
|
|
100
|
+
outcome: Extract<TargetWorkflowOutcome, { kind: "resolved" }>,
|
|
101
|
+
cwd: string,
|
|
102
|
+
): ResolveProjection {
|
|
103
|
+
const { entry: target, resolution } = outcome;
|
|
96
104
|
const evidence = createEvidenceList({ key: "resolve.targets", items: [target] }).metadata;
|
|
97
105
|
return {
|
|
98
106
|
key: "resolve.targets",
|
|
@@ -107,7 +115,7 @@ function projectResolved(target: Readonly<TargetStoreEntry>, cwd: string): Resol
|
|
|
107
115
|
targetCount: 1,
|
|
108
116
|
omittedCount: 0,
|
|
109
117
|
evidenceLists: [evidence],
|
|
110
|
-
targets: [toTargetDetails(target, cwd)],
|
|
118
|
+
targets: [toTargetDetails(target, cwd, resolution)],
|
|
111
119
|
nextQueries: [],
|
|
112
120
|
},
|
|
113
121
|
};
|
|
@@ -138,7 +146,7 @@ function projectTargetGroup(
|
|
|
138
146
|
evidence: evidence.metadata,
|
|
139
147
|
details: {
|
|
140
148
|
resultKind: "target-group",
|
|
141
|
-
groupFile:
|
|
149
|
+
groupFile: toDisplayPath(cwd, outcome.file),
|
|
142
150
|
groupDiscoveryProvenance: [...outcome.discoveryProvenance],
|
|
143
151
|
groupUnknownNestingCount: outcome.unknownNestingCount,
|
|
144
152
|
groupPartialReason: outcome.partial?.reason ?? null,
|
|
@@ -158,6 +166,7 @@ function projectTargetGroup(
|
|
|
158
166
|
|
|
159
167
|
function projectCandidateOutcome(
|
|
160
168
|
outcome: Extract<TargetWorkflowOutcome, { kind: "disambiguation" | "kind-mismatch" }>,
|
|
169
|
+
cwd: string,
|
|
161
170
|
): ResolveProjection {
|
|
162
171
|
const evidence: EvidenceListMetadata = {
|
|
163
172
|
key: "resolve.candidates",
|
|
@@ -189,7 +198,7 @@ function projectCandidateOutcome(
|
|
|
189
198
|
name: candidate.name,
|
|
190
199
|
kind: candidate.kind,
|
|
191
200
|
container: candidate.container,
|
|
192
|
-
file: candidate.file,
|
|
201
|
+
file: toDisplayPath(cwd, candidate.file),
|
|
193
202
|
line: candidate.line,
|
|
194
203
|
character: candidate.character,
|
|
195
204
|
rank: candidate.rank,
|
|
@@ -228,11 +237,15 @@ function projectFailure(
|
|
|
228
237
|
};
|
|
229
238
|
}
|
|
230
239
|
|
|
231
|
-
function toTargetDetails(
|
|
240
|
+
function toTargetDetails(
|
|
241
|
+
target: Readonly<TargetStoreEntry>,
|
|
242
|
+
cwd: string,
|
|
243
|
+
resolution?: AnchoredResolutionMetadata,
|
|
244
|
+
) {
|
|
232
245
|
return {
|
|
233
246
|
targetId: target.targetId,
|
|
234
247
|
spanId: target.spanId,
|
|
235
|
-
file:
|
|
248
|
+
file: toDisplayPath(cwd, target.file),
|
|
236
249
|
displayLine: target.displayLine,
|
|
237
250
|
displayCharacter: target.displayCharacter,
|
|
238
251
|
name: target.name,
|
|
@@ -242,7 +255,7 @@ function toTargetDetails(target: Readonly<TargetStoreEntry>, cwd: string) {
|
|
|
242
255
|
anchorKind: target.anchorKind,
|
|
243
256
|
confidence: target.confidence,
|
|
244
257
|
provenance: [...target.provenance],
|
|
245
|
-
resolution:
|
|
258
|
+
...(resolution ? { resolution } : {}),
|
|
246
259
|
};
|
|
247
260
|
}
|
|
248
261
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
1
|
import { type Static, Type } from "typebox";
|
|
3
2
|
import type { TargetWorkflowOutcome } from "../../session/target-workflow.ts";
|
|
4
3
|
import {
|
|
@@ -12,13 +11,10 @@ import type { ResolveDetails } from "../result/types.ts";
|
|
|
12
11
|
/** Codemode contract for resolution, including candidate selection and invalid input. */
|
|
13
12
|
export const ResolveOutputSchema = Type.Object(
|
|
14
13
|
{
|
|
15
|
-
kind:
|
|
16
|
-
"resolved",
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"kind-mismatch",
|
|
20
|
-
"invalid-input",
|
|
21
|
-
]),
|
|
14
|
+
kind: Type.Enum(
|
|
15
|
+
["resolved", "target-group", "disambiguation", "kind-mismatch", "invalid-input"],
|
|
16
|
+
{ type: "string" },
|
|
17
|
+
),
|
|
22
18
|
confidence: ConfidenceSchema,
|
|
23
19
|
targets: Type.Array(NavigationTargetSchema),
|
|
24
20
|
evidenceLists: Type.Array(EvidenceListSchema),
|
|
@@ -28,7 +24,9 @@ export const ResolveOutputSchema = Type.Object(
|
|
|
28
24
|
file: Type.Optional(Type.String()),
|
|
29
25
|
requestedKind: Type.Optional(Type.String()),
|
|
30
26
|
unknownNestingCount: Type.Optional(Type.Integer()),
|
|
31
|
-
discoveryProvenance: Type.Optional(
|
|
27
|
+
discoveryProvenance: Type.Optional(
|
|
28
|
+
Type.Array(Type.Enum(["semantic", "structural"], { type: "string" })),
|
|
29
|
+
),
|
|
32
30
|
partialReason: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
33
31
|
errorRanges: Type.Optional(Type.Array(RecoveryRangeSchema)),
|
|
34
32
|
},
|