@mrclrchtr/supi-code-intelligence 8.0.1 → 9.0.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/README.md +3 -2
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +10 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +9 -4
- package/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
- package/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +1 -0
- 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/types.ts +10 -1
- 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/debug-registry.ts +9 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +6 -9
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +202 -106
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +164 -88
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +14 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +6 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +12 -3
- 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/types.ts +10 -1
- 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/debug-registry.ts +9 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session-capabilities.ts +55 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session-capability-profiles.ts +240 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +22 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/debug/web-tree-sitter.wasm.map +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/web-tree-sitter/web-tree-sitter.wasm.map +7 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/kotlin/tree-sitter-kotlin.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/latex/tree-sitter-latex.wasm.json +17 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +5 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +6 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +45 -34
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-process.ts +122 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +55 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-latex.ts +288 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-polyglot.ts +8 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +18 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +11 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/process-host.mjs +92 -0
- package/package.json +5 -5
- package/src/analysis/refactor/latex-section-rename.ts +343 -0
- package/src/analysis/target/anchored-structural.ts +148 -0
- package/src/analysis/target/anchored.ts +15 -124
- package/src/analysis/target/file-refinement.ts +51 -0
- package/src/analysis/target/file.ts +49 -47
- package/src/analysis/target/identity.ts +147 -29
- package/src/analysis/target/latex-label-container.ts +137 -0
- package/src/analysis/target/latex-section-anchor.ts +116 -0
- package/src/analysis/target/latex-target-anchor.ts +17 -0
- package/src/overview/overview-data.ts +1 -0
- package/src/session/inspect/collect.ts +3 -1
- package/src/session/refactor-plans.ts +3 -1
- package/src/session/refactor-workflow.ts +127 -49
- package/src/tool/code_inspect/markdown.ts +1 -1
- package/src/tool/result/refactor.ts +24 -6
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CodeRequestControl, StructuralProvider } from "@mrclrchtr/supi-code-runtime/api";
|
|
2
|
+
import { resolveLatexLabelTargetAtAnchor } from "./latex-label-container.ts";
|
|
3
|
+
import { resolveLatexSectionTargetAtAnchor } from "./latex-section-anchor.ts";
|
|
4
|
+
import type { ResolvedTargetData } from "./types.ts";
|
|
5
|
+
|
|
6
|
+
/** Resolve a LaTeX label or section title at one source coordinate. */
|
|
7
|
+
export async function resolveLatexTargetAtAnchor(input: {
|
|
8
|
+
readonly file: string;
|
|
9
|
+
readonly line: number;
|
|
10
|
+
readonly character: number;
|
|
11
|
+
readonly outline?: StructuralProvider["outline"];
|
|
12
|
+
readonly control?: CodeRequestControl;
|
|
13
|
+
}): Promise<ResolvedTargetData | null> {
|
|
14
|
+
const label = await resolveLatexLabelTargetAtAnchor(input);
|
|
15
|
+
if (label) return label;
|
|
16
|
+
return resolveLatexSectionTargetAtAnchor(input);
|
|
17
|
+
}
|
|
@@ -302,8 +302,10 @@ function comparePosition(
|
|
|
302
302
|
return leftLine - rightLine || leftCharacter - rightCharacter;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
function lspUnavailableReason(state:
|
|
305
|
+
function lspUnavailableReason(state: WorkspaceLspRuntimeState): string {
|
|
306
306
|
switch (state.kind) {
|
|
307
|
+
case "ready":
|
|
308
|
+
throw new Error("Cannot report an unavailable reason for a ready LSP runtime.");
|
|
307
309
|
case "unavailable":
|
|
308
310
|
return state.reason;
|
|
309
311
|
case "pending":
|
|
@@ -19,7 +19,9 @@ export interface RefactorPlan {
|
|
|
19
19
|
targetLine: number;
|
|
20
20
|
targetCharacter: number;
|
|
21
21
|
edits: WorkspaceEdit;
|
|
22
|
-
/**
|
|
22
|
+
/** Evidence source used to compose this plan. */
|
|
23
|
+
evidenceSource?: "semantic" | "structural";
|
|
24
|
+
/** Canonical roots that authorize the plan's files. */
|
|
23
25
|
authorizedMutationRoots: string[];
|
|
24
26
|
fileFingerprints: Array<{ file: string; fingerprint: string }>;
|
|
25
27
|
createdAt: number;
|
|
@@ -9,6 +9,10 @@ import type {
|
|
|
9
9
|
import { toLspPosition } from "@mrclrchtr/supi-lsp/api";
|
|
10
10
|
import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
|
|
11
11
|
import { applyWorkspaceEdit } from "../analysis/refactor/apply.ts";
|
|
12
|
+
import {
|
|
13
|
+
isLatexSectionTarget,
|
|
14
|
+
refineLatexSectionRenameResult,
|
|
15
|
+
} from "../analysis/refactor/latex-section-rename.ts";
|
|
12
16
|
import {
|
|
13
17
|
establishMutationAuthority,
|
|
14
18
|
revalidateMutationAuthority,
|
|
@@ -35,6 +39,7 @@ import {
|
|
|
35
39
|
type RefactorPlanWorkflowInput,
|
|
36
40
|
type RefactorPlanWorkflowOutcome,
|
|
37
41
|
} from "./refactor-types.ts";
|
|
42
|
+
import type { TargetStoreEntry } from "./target-store.ts";
|
|
38
43
|
import { resolveTargetWorkflow, type TargetWorkflowDeps } from "./target-workflow.ts";
|
|
39
44
|
import { reportProgress, throwIfAborted, type WorkflowControl } from "./workflow-control.ts";
|
|
40
45
|
|
|
@@ -99,54 +104,7 @@ export async function runRefactorPlanWorkflow(
|
|
|
99
104
|
}
|
|
100
105
|
if (readiness.kind === "unavailable") return readiness;
|
|
101
106
|
throwIfAborted(control);
|
|
102
|
-
|
|
103
|
-
const file = normalizePath(target.entry.file, deps.cwd);
|
|
104
|
-
const result = await planWithProvider(
|
|
105
|
-
deps.capability.getSemanticProvider(deps.cwd),
|
|
106
|
-
{
|
|
107
|
-
operation: parsed.operation,
|
|
108
|
-
file,
|
|
109
|
-
position: toLspPosition(target.entry.displayLine, target.entry.displayCharacter),
|
|
110
|
-
range: parsed.range ? toLspRange(parsed.range) : undefined,
|
|
111
|
-
newName: parsed.newName,
|
|
112
|
-
},
|
|
113
|
-
control,
|
|
114
|
-
);
|
|
115
|
-
if (result.kind === "unavailable") return result;
|
|
116
|
-
if (result.kind === "ambiguous") {
|
|
117
|
-
return { kind: "ambiguous", candidates: result.candidates };
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const validation = validateEdit(result.edits);
|
|
121
|
-
if (!validation.safe) {
|
|
122
|
-
return { kind: "invalid-input", message: `Refactor safety check failed: ${validation.reason}` };
|
|
123
|
-
}
|
|
124
|
-
const authority = establishMutationAuthority(
|
|
125
|
-
result.edits.edits.map((edit) => edit.file),
|
|
126
|
-
result.authorizedMutationRoots,
|
|
127
|
-
);
|
|
128
|
-
if (authority.kind === "unavailable") return authority;
|
|
129
|
-
|
|
130
|
-
const plan: RefactorPlan = {
|
|
131
|
-
id: generatePlanId(
|
|
132
|
-
parsed.operation,
|
|
133
|
-
file,
|
|
134
|
-
target.entry.displayLine,
|
|
135
|
-
target.entry.displayCharacter,
|
|
136
|
-
parsed.newName,
|
|
137
|
-
),
|
|
138
|
-
operation: parsed.operation,
|
|
139
|
-
newName: parsed.newName,
|
|
140
|
-
targetFile: file,
|
|
141
|
-
targetLine: target.entry.displayLine,
|
|
142
|
-
targetCharacter: target.entry.displayCharacter,
|
|
143
|
-
edits: result.edits,
|
|
144
|
-
authorizedMutationRoots: authority.canonicalRoots,
|
|
145
|
-
fileFingerprints: collectFileFingerprints(result.edits.edits),
|
|
146
|
-
createdAt: Date.now(),
|
|
147
|
-
};
|
|
148
|
-
deps.storePlan(plan);
|
|
149
|
-
return { kind: "completed", plan: immutablePlan(plan) };
|
|
107
|
+
return planResolvedRefactor(parsed, target.entry, deps, control);
|
|
150
108
|
}
|
|
151
109
|
|
|
152
110
|
/** Revalidate and apply one stored plan through the per-file mutation queue. */
|
|
@@ -196,6 +154,121 @@ export async function runRefactorApplyWorkflow(
|
|
|
196
154
|
return { kind: "completed", plan: immutablePlan(plan), result };
|
|
197
155
|
}
|
|
198
156
|
|
|
157
|
+
type ParsedRefactorOperation = Extract<ReturnType<typeof parseOperation>, { kind: "ok" }>;
|
|
158
|
+
type RefinedRefactorResult = Awaited<ReturnType<typeof refineLatexSectionRenameResult>>;
|
|
159
|
+
|
|
160
|
+
async function planResolvedRefactor(
|
|
161
|
+
parsed: ParsedRefactorOperation,
|
|
162
|
+
target: Readonly<TargetStoreEntry>,
|
|
163
|
+
deps: RefactorWorkflowDeps,
|
|
164
|
+
control?: WorkflowControl,
|
|
165
|
+
): Promise<RefactorPlanWorkflowOutcome> {
|
|
166
|
+
const file = normalizePath(target.file, deps.cwd);
|
|
167
|
+
const sectionRename = await planWithLatexSafety({ parsed, target, file, deps, control });
|
|
168
|
+
const result = sectionRename.result;
|
|
169
|
+
if (result.kind === "unavailable") return result;
|
|
170
|
+
if (result.kind === "ambiguous") {
|
|
171
|
+
return { kind: "ambiguous", candidates: result.candidates };
|
|
172
|
+
}
|
|
173
|
+
if (
|
|
174
|
+
sectionRename.sourceFingerprint &&
|
|
175
|
+
computeFileFingerprint(file) !== sectionRename.sourceFingerprint
|
|
176
|
+
) {
|
|
177
|
+
return {
|
|
178
|
+
kind: "unavailable",
|
|
179
|
+
reason: "The LaTeX source changed before the title rename plan was stored.",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const validation = validateEdit(result.edits);
|
|
184
|
+
if (!validation.safe) {
|
|
185
|
+
return { kind: "invalid-input", message: `Refactor safety check failed: ${validation.reason}` };
|
|
186
|
+
}
|
|
187
|
+
const authority = establishMutationAuthority(
|
|
188
|
+
result.edits.edits.map((edit) => edit.file),
|
|
189
|
+
result.authorizedMutationRoots,
|
|
190
|
+
);
|
|
191
|
+
if (authority.kind === "unavailable") return authority;
|
|
192
|
+
|
|
193
|
+
const plan: RefactorPlan = {
|
|
194
|
+
id: generatePlanId(
|
|
195
|
+
parsed.operation,
|
|
196
|
+
file,
|
|
197
|
+
target.displayLine,
|
|
198
|
+
target.displayCharacter,
|
|
199
|
+
parsed.newName,
|
|
200
|
+
),
|
|
201
|
+
operation: parsed.operation,
|
|
202
|
+
newName: parsed.newName,
|
|
203
|
+
targetFile: file,
|
|
204
|
+
targetLine: target.displayLine,
|
|
205
|
+
targetCharacter: target.displayCharacter,
|
|
206
|
+
edits: result.edits,
|
|
207
|
+
evidenceSource: sectionRename.evidenceSource,
|
|
208
|
+
authorizedMutationRoots: authority.canonicalRoots,
|
|
209
|
+
fileFingerprints: collectFileFingerprints(
|
|
210
|
+
result.edits.edits,
|
|
211
|
+
sectionRename.sourceFingerprint
|
|
212
|
+
? { file, fingerprint: sectionRename.sourceFingerprint }
|
|
213
|
+
: undefined,
|
|
214
|
+
),
|
|
215
|
+
createdAt: Date.now(),
|
|
216
|
+
};
|
|
217
|
+
deps.storePlan(plan);
|
|
218
|
+
return { kind: "completed", plan: immutablePlan(plan) };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async function planWithLatexSafety(input: {
|
|
222
|
+
readonly parsed: ParsedRefactorOperation;
|
|
223
|
+
readonly target: Readonly<TargetStoreEntry>;
|
|
224
|
+
readonly file: string;
|
|
225
|
+
readonly deps: RefactorWorkflowDeps;
|
|
226
|
+
readonly control?: WorkflowControl;
|
|
227
|
+
}): Promise<RefinedRefactorResult> {
|
|
228
|
+
const { parsed, target, file, deps, control } = input;
|
|
229
|
+
const isLatexRename = parsed.operation === "rename_symbol" && isLatexSectionTarget(target);
|
|
230
|
+
if (isLatexRename && computeFileFingerprint(file) !== target.fileFingerprint) {
|
|
231
|
+
return {
|
|
232
|
+
result: {
|
|
233
|
+
kind: "unavailable",
|
|
234
|
+
reason: "The LaTeX source changed after the target was resolved. Re-resolve the target.",
|
|
235
|
+
},
|
|
236
|
+
evidenceSource: "semantic",
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const result = await planWithProvider(
|
|
241
|
+
deps.capability.getSemanticProvider(deps.cwd),
|
|
242
|
+
{
|
|
243
|
+
operation: parsed.operation,
|
|
244
|
+
file,
|
|
245
|
+
position: toLspPosition(target.displayLine, target.displayCharacter),
|
|
246
|
+
range: parsed.range ? toLspRange(parsed.range) : undefined,
|
|
247
|
+
newName: parsed.newName,
|
|
248
|
+
},
|
|
249
|
+
control,
|
|
250
|
+
);
|
|
251
|
+
if (isLatexRename && computeFileFingerprint(file) !== target.fileFingerprint) {
|
|
252
|
+
return {
|
|
253
|
+
result: {
|
|
254
|
+
kind: "unavailable",
|
|
255
|
+
reason: "The LaTeX source changed while the rename provider was working.",
|
|
256
|
+
},
|
|
257
|
+
evidenceSource: "semantic",
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return refineLatexSectionRenameResult({
|
|
261
|
+
operation: parsed.operation,
|
|
262
|
+
result,
|
|
263
|
+
target,
|
|
264
|
+
file,
|
|
265
|
+
newName: parsed.newName,
|
|
266
|
+
structural: deps.capability.getStructuralProvider(deps.cwd),
|
|
267
|
+
documentVersionReader: getDocumentVersionReader(deps),
|
|
268
|
+
control,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
199
272
|
function getDocumentVersionReader(
|
|
200
273
|
deps: RefactorWorkflowDeps,
|
|
201
274
|
): ((file: string) => number | null) | undefined {
|
|
@@ -287,9 +360,14 @@ async function planWithProvider(
|
|
|
287
360
|
|
|
288
361
|
function collectFileFingerprints(
|
|
289
362
|
edits: Array<{ file: string }>,
|
|
363
|
+
sourceSnapshot?: { readonly file: string; readonly fingerprint: string },
|
|
290
364
|
): Array<{ file: string; fingerprint: string }> {
|
|
291
365
|
const files = [...new Set(edits.map((edit) => edit.file))];
|
|
292
|
-
return files.map((file) => ({
|
|
366
|
+
return files.map((file) => ({
|
|
367
|
+
file,
|
|
368
|
+
fingerprint:
|
|
369
|
+
sourceSnapshot?.file === file ? sourceSnapshot.fingerprint : computeFileFingerprint(file),
|
|
370
|
+
}));
|
|
293
371
|
}
|
|
294
372
|
|
|
295
373
|
function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
|
|
@@ -38,7 +38,7 @@ function renderNode(
|
|
|
38
38
|
lines.push(
|
|
39
39
|
`- Type: \`${node.type}\` at ${input.relPath}:${node.startLine}:${node.startCharacter}–${node.endLine}:${node.endCharacter}`,
|
|
40
40
|
);
|
|
41
|
-
if (node.text) lines.push("```
|
|
41
|
+
if (node.text) lines.push("```text", node.text, "```");
|
|
42
42
|
if (node.ancestry.length > 0) {
|
|
43
43
|
lines.push("", "### Ancestry");
|
|
44
44
|
for (const ancestor of node.ancestry) {
|
|
@@ -46,7 +46,13 @@ export function assembleRefactorPlanDetails(
|
|
|
46
46
|
items: [...plan.edits.edits],
|
|
47
47
|
maxResults,
|
|
48
48
|
});
|
|
49
|
-
const
|
|
49
|
+
const evidenceSource = plan.evidenceSource ?? "semantic";
|
|
50
|
+
const provenance = [
|
|
51
|
+
{
|
|
52
|
+
source: evidenceSource,
|
|
53
|
+
capability: evidenceSource === "semantic" ? "LSP refactor" : "Tree-sitter exact LaTeX title",
|
|
54
|
+
},
|
|
55
|
+
];
|
|
50
56
|
const assembled = assembleToolResult({
|
|
51
57
|
data: { plan, cwd, edits },
|
|
52
58
|
sections: [
|
|
@@ -55,14 +61,14 @@ export function assembleRefactorPlanDetails(
|
|
|
55
61
|
title: "Proposed edits",
|
|
56
62
|
status: "complete",
|
|
57
63
|
items: edits.items,
|
|
58
|
-
confidence:
|
|
64
|
+
confidence: evidenceSource,
|
|
59
65
|
provenance,
|
|
60
66
|
},
|
|
61
67
|
],
|
|
62
68
|
evidenceLists: [edits.metadata],
|
|
63
69
|
nextQueries: [`Use code_refactor_apply with planId: "${plan.id}" to apply this refactor`],
|
|
64
70
|
candidateCount: edits.metadata.totalCount ?? edits.metadata.shownCount,
|
|
65
|
-
confidence:
|
|
71
|
+
confidence: evidenceSource,
|
|
66
72
|
provenance,
|
|
67
73
|
});
|
|
68
74
|
|
|
@@ -96,7 +102,19 @@ export function assembleRefactorApplyDetails(
|
|
|
96
102
|
plan: Readonly<RefactorPlan>,
|
|
97
103
|
): RefactorApplyResultAssembly {
|
|
98
104
|
const candidateCount = applyResult.kind === "applied" ? applyResult.totalEdits : 0;
|
|
99
|
-
const
|
|
105
|
+
const evidenceSource = plan.evidenceSource ?? "semantic";
|
|
106
|
+
const provenance =
|
|
107
|
+
applyResult.kind === "applied"
|
|
108
|
+
? [
|
|
109
|
+
{
|
|
110
|
+
source: evidenceSource,
|
|
111
|
+
capability:
|
|
112
|
+
evidenceSource === "semantic" ? "LSP refactor" : "Tree-sitter exact LaTeX title",
|
|
113
|
+
},
|
|
114
|
+
{ source: "runtime" as const, capability: "file-mutation-queue" },
|
|
115
|
+
]
|
|
116
|
+
: [{ source: "runtime" as const, capability: "file-mutation-queue" }];
|
|
117
|
+
const confidence = applyResult.kind === "applied" ? evidenceSource : "unavailable";
|
|
100
118
|
const assembled = assembleToolResult({
|
|
101
119
|
data: { plan, result: applyResult },
|
|
102
120
|
sections: [
|
|
@@ -105,13 +123,13 @@ export function assembleRefactorApplyDetails(
|
|
|
105
123
|
title: "Applied edits",
|
|
106
124
|
status: applyResult.kind === "applied" ? "complete" : "unavailable",
|
|
107
125
|
items: applyResult.kind === "applied" ? [applyResult] : [],
|
|
108
|
-
confidence
|
|
126
|
+
confidence,
|
|
109
127
|
provenance,
|
|
110
128
|
},
|
|
111
129
|
],
|
|
112
130
|
nextQueries: [],
|
|
113
131
|
candidateCount,
|
|
114
|
-
confidence
|
|
132
|
+
confidence,
|
|
115
133
|
provenance,
|
|
116
134
|
});
|
|
117
135
|
|