@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
|
@@ -22,15 +22,26 @@ export type ContextGatherProvider = Pick<
|
|
|
22
22
|
Partial<Pick<SemanticProvider, "hover" | "definition">>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Best-effort substrate evidence at one target position.
|
|
26
|
-
*
|
|
25
|
+
* Best-effort substrate evidence at one target position. Consult each operation's
|
|
26
|
+
* status to distinguish a completed empty value from unavailable or withheld evidence.
|
|
27
27
|
*/
|
|
28
|
+
/** Availability of one independently attempted context observation. */
|
|
29
|
+
type CollectedStatus =
|
|
30
|
+
| { readonly status: "complete"; readonly reason: null }
|
|
31
|
+
| { readonly status: "partial" | "unavailable"; readonly reason: string };
|
|
32
|
+
|
|
33
|
+
export type ContextObservationStatus =
|
|
34
|
+
| CollectedStatus
|
|
35
|
+
| { readonly status: "withheld"; readonly reason: string };
|
|
36
|
+
|
|
28
37
|
export interface SubstrateContext {
|
|
29
38
|
nodeInfo: {
|
|
30
39
|
type: string;
|
|
31
40
|
text: string;
|
|
32
41
|
startLine: number;
|
|
33
42
|
startCharacter: number;
|
|
43
|
+
endLine: number;
|
|
44
|
+
endCharacter: number;
|
|
34
45
|
ancestry: Array<{
|
|
35
46
|
type: string;
|
|
36
47
|
startLine: number;
|
|
@@ -42,10 +53,19 @@ export interface SubstrateContext {
|
|
|
42
53
|
outline: Array<{ name: string; kind: string; startLine: number; endLine: number }>;
|
|
43
54
|
imports: Array<{ moduleSpecifier: string }>;
|
|
44
55
|
exports: Array<{ name: string; kind: string }>;
|
|
45
|
-
/** Best-effort LSP hover
|
|
56
|
+
/** Best-effort LSP hover data; consult operations.hover for empty versus unavailable. */
|
|
46
57
|
hover: { contents: string; range?: SourceRange } | null;
|
|
47
|
-
/** Best-effort LSP definition
|
|
58
|
+
/** Best-effort LSP definition data; empty arrays are successful observations. */
|
|
48
59
|
definition: Array<{ uri: string; range: SourceRange }> | null;
|
|
60
|
+
/** Availability of each independent observation, including withheld position-strict queries. */
|
|
61
|
+
operations: {
|
|
62
|
+
nodeAt: ContextObservationStatus;
|
|
63
|
+
hover: ContextObservationStatus;
|
|
64
|
+
definition: ContextObservationStatus;
|
|
65
|
+
outline: CollectedStatus;
|
|
66
|
+
imports: CollectedStatus;
|
|
67
|
+
exports: CollectedStatus;
|
|
68
|
+
};
|
|
49
69
|
/** Structural recovery from independently queried source operations. */
|
|
50
70
|
recovery: Array<{
|
|
51
71
|
operation: "nodeAt" | "outline" | "imports" | "exports";
|
|
@@ -63,9 +83,10 @@ export interface SubstrateContext {
|
|
|
63
83
|
* (tree-sitter `nodeAt`, hover-at) run only when `positionStrict` is true —
|
|
64
84
|
* callers holding a declaration-anchor target must pass false (ADR 0003).
|
|
65
85
|
* File-level evidence (outline, imports, exports) and position-tolerant
|
|
66
|
-
* definition lookups run regardless. Failures
|
|
86
|
+
* definition lookups run regardless. Failures retain unavailable status and reason.
|
|
67
87
|
*/
|
|
68
88
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: best-effort substrate gathering with independent try/catch blocks kept together for readability
|
|
89
|
+
// biome-ignore lint/complexity/noExcessiveLinesPerFunction: keep the existing shared best-effort failure boundary and query order intact
|
|
69
90
|
// biome-ignore lint/complexity/useMaxParams: one internal gather call site carries the full position context
|
|
70
91
|
export async function gatherSubstrateContext(
|
|
71
92
|
provider: ContextGatherProvider | null,
|
|
@@ -82,12 +103,34 @@ export async function gatherSubstrateContext(
|
|
|
82
103
|
let hover: SubstrateContext["hover"] = null;
|
|
83
104
|
let definition: SubstrateContext["definition"] = null;
|
|
84
105
|
const recovery: SubstrateContext["recovery"] = [];
|
|
106
|
+
const withheld = {
|
|
107
|
+
status: "withheld" as const,
|
|
108
|
+
reason:
|
|
109
|
+
"Position-strict evidence requires a name anchor; this target has a declaration anchor.",
|
|
110
|
+
};
|
|
111
|
+
const operations: SubstrateContext["operations"] = {
|
|
112
|
+
nodeAt: positionStrict ? { status: "unavailable", reason: "Not collected." } : withheld,
|
|
113
|
+
hover: positionStrict ? { status: "unavailable", reason: "Not collected." } : withheld,
|
|
114
|
+
definition: { status: "unavailable", reason: "Not collected." },
|
|
115
|
+
outline: { status: "unavailable", reason: "Not collected." },
|
|
116
|
+
imports: { status: "unavailable", reason: "Not collected." },
|
|
117
|
+
exports: { status: "unavailable", reason: "Not collected." },
|
|
118
|
+
};
|
|
119
|
+
let currentOperation: keyof SubstrateContext["operations"] | null = null;
|
|
85
120
|
|
|
86
|
-
if (!provider)
|
|
121
|
+
if (!provider) {
|
|
122
|
+
for (const key of Object.keys(operations) as Array<keyof SubstrateContext["operations"]>) {
|
|
123
|
+
if (operations[key].status !== "withheld")
|
|
124
|
+
operations[key] = { status: "unavailable", reason: "Provider unavailable." };
|
|
125
|
+
}
|
|
126
|
+
return { nodeInfo, outline, imports, exports, hover, definition: null, recovery, operations };
|
|
127
|
+
}
|
|
87
128
|
|
|
88
129
|
try {
|
|
89
130
|
if (positionStrict) {
|
|
131
|
+
currentOperation = "nodeAt";
|
|
90
132
|
const nodeResult = await provider.nodeAt(relPath, line, character, requestControl);
|
|
133
|
+
operations.nodeAt = structuralStatus(nodeResult);
|
|
91
134
|
if (nodeResult.kind === "partial") {
|
|
92
135
|
recovery.push({
|
|
93
136
|
operation: "nodeAt",
|
|
@@ -102,12 +145,17 @@ export async function gatherSubstrateContext(
|
|
|
102
145
|
text: nodeResult.data.text,
|
|
103
146
|
startLine: nodeResult.data.startLine,
|
|
104
147
|
startCharacter: nodeResult.data.startCharacter,
|
|
148
|
+
endLine: nodeResult.data.endLine,
|
|
149
|
+
endCharacter: nodeResult.data.endCharacter,
|
|
105
150
|
ancestry: nodeResult.data.ancestry ?? [],
|
|
106
151
|
};
|
|
107
152
|
}
|
|
153
|
+
currentOperation = null;
|
|
108
154
|
}
|
|
109
155
|
|
|
156
|
+
currentOperation = "outline";
|
|
110
157
|
const outlineResult = await provider.outline(relPath, requestControl);
|
|
158
|
+
operations.outline = structuralStatus(outlineResult);
|
|
111
159
|
if (outlineResult.kind === "partial") {
|
|
112
160
|
recovery.push({
|
|
113
161
|
operation: "outline",
|
|
@@ -125,7 +173,9 @@ export async function gatherSubstrateContext(
|
|
|
125
173
|
}));
|
|
126
174
|
}
|
|
127
175
|
|
|
176
|
+
currentOperation = "imports";
|
|
128
177
|
const importsResult = await provider.imports(relPath, requestControl);
|
|
178
|
+
operations.imports = structuralStatus(importsResult);
|
|
129
179
|
if (importsResult.kind === "partial") {
|
|
130
180
|
recovery.push({
|
|
131
181
|
operation: "imports",
|
|
@@ -138,7 +188,9 @@ export async function gatherSubstrateContext(
|
|
|
138
188
|
imports = importsResult.data;
|
|
139
189
|
}
|
|
140
190
|
|
|
191
|
+
currentOperation = "exports";
|
|
141
192
|
const exportsResult = await provider.exports(relPath, requestControl);
|
|
193
|
+
operations.exports = structuralStatus(exportsResult);
|
|
142
194
|
if (exportsResult.kind === "partial") {
|
|
143
195
|
recovery.push({
|
|
144
196
|
operation: "exports",
|
|
@@ -153,6 +205,7 @@ export async function gatherSubstrateContext(
|
|
|
153
205
|
kind: item.kind,
|
|
154
206
|
}));
|
|
155
207
|
}
|
|
208
|
+
currentOperation = null;
|
|
156
209
|
|
|
157
210
|
// Best-effort hover — LSP expects 0-based coordinates; hover-at is position-strict.
|
|
158
211
|
if (positionStrict && provider.hover) {
|
|
@@ -161,11 +214,14 @@ export async function gatherSubstrateContext(
|
|
|
161
214
|
line: line - 1,
|
|
162
215
|
character: character - 1,
|
|
163
216
|
});
|
|
217
|
+
operations.hover = semanticStatus(hoverResult);
|
|
164
218
|
if (hoverResult.kind !== "unavailable" && hoverResult.data) hover = hoverResult.data;
|
|
165
219
|
} catch (error) {
|
|
166
220
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
167
|
-
|
|
221
|
+
operations.hover = { status: "unavailable", reason: String(error) };
|
|
168
222
|
}
|
|
223
|
+
} else if (positionStrict) {
|
|
224
|
+
operations.hover = { status: "unavailable", reason: "Hover provider unavailable." };
|
|
169
225
|
}
|
|
170
226
|
|
|
171
227
|
// Best-effort definition — LSP expects 0-based coordinates; definitions are position-tolerant.
|
|
@@ -175,7 +231,8 @@ export async function gatherSubstrateContext(
|
|
|
175
231
|
line: line - 1,
|
|
176
232
|
character: character - 1,
|
|
177
233
|
});
|
|
178
|
-
|
|
234
|
+
operations.definition = semanticStatus(defResult);
|
|
235
|
+
if (defResult.kind !== "unavailable") {
|
|
179
236
|
definition = defResult.data.map((loc) => ({
|
|
180
237
|
uri: loc.uri,
|
|
181
238
|
range: loc.range,
|
|
@@ -183,13 +240,43 @@ export async function gatherSubstrateContext(
|
|
|
183
240
|
}
|
|
184
241
|
} catch (error) {
|
|
185
242
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
186
|
-
|
|
243
|
+
operations.definition = { status: "unavailable", reason: String(error) };
|
|
187
244
|
}
|
|
245
|
+
} else {
|
|
246
|
+
operations.definition = { status: "unavailable", reason: "Definition provider unavailable." };
|
|
188
247
|
}
|
|
189
248
|
} catch (error) {
|
|
190
249
|
if (isCodeRequestInterruption(error, requestControl)) throw error;
|
|
191
|
-
|
|
250
|
+
if (currentOperation) {
|
|
251
|
+
operations[currentOperation] = { status: "unavailable", reason: String(error) };
|
|
252
|
+
for (const key of ["hover", "definition"] as const) {
|
|
253
|
+
if (operations[key].reason === "Not collected.") {
|
|
254
|
+
operations[key] = {
|
|
255
|
+
status: "unavailable",
|
|
256
|
+
reason: `Not collected after ${currentOperation} failed.`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
192
261
|
}
|
|
193
262
|
|
|
194
|
-
return { nodeInfo, outline, imports, exports, hover, definition, recovery };
|
|
263
|
+
return { nodeInfo, outline, imports, exports, hover, definition, recovery, operations };
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function semanticStatus(result: { kind: string; reason?: string }): CollectedStatus {
|
|
267
|
+
if (result.kind === "completed") return { status: "complete", reason: null };
|
|
268
|
+
if (result.kind === "partial")
|
|
269
|
+
return { status: "partial", reason: result.reason ?? "Partial evidence." };
|
|
270
|
+
return { status: "unavailable", reason: result.reason ?? "Semantic provider unavailable." };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function structuralStatus(result: {
|
|
274
|
+
kind: string;
|
|
275
|
+
reason?: string;
|
|
276
|
+
message?: string;
|
|
277
|
+
}): SubstrateContext["operations"]["outline"] {
|
|
278
|
+
if (result.kind === "success") return { status: "complete", reason: null };
|
|
279
|
+
if (result.kind === "partial")
|
|
280
|
+
return { status: "partial", reason: result.reason ?? "Partial evidence." };
|
|
281
|
+
return { status: "unavailable", reason: result.message ?? "Structural provider unavailable." };
|
|
195
282
|
}
|
|
@@ -58,12 +58,15 @@ export async function orientWorkspaceContext(
|
|
|
58
58
|
return {
|
|
59
59
|
kind: "completed",
|
|
60
60
|
directory: focus,
|
|
61
|
-
data:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
data: {
|
|
62
|
+
...workspaceOrientationData({
|
|
63
|
+
observation,
|
|
64
|
+
cwd: options.cwd,
|
|
65
|
+
focus,
|
|
66
|
+
maxResults: request.maxResults ?? 10,
|
|
67
|
+
}),
|
|
68
|
+
focusKind: workspaceFocusKind(request),
|
|
69
|
+
},
|
|
67
70
|
};
|
|
68
71
|
} catch (error) {
|
|
69
72
|
if (!(error instanceof WorkspaceSymlinkError)) throw error;
|
|
@@ -75,6 +78,13 @@ export async function orientWorkspaceContext(
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
function workspaceFocusKind(
|
|
82
|
+
request: OrientationWorkflowInput,
|
|
83
|
+
): "workspace" | "module" | "directory" {
|
|
84
|
+
if (!request.focus) return "workspace";
|
|
85
|
+
return "module" in request.focus ? "module" : "directory";
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
async function initialObservation(
|
|
79
89
|
cwd: string,
|
|
80
90
|
focus: string | null,
|
|
@@ -10,6 +10,7 @@ import type { InstructionFilesMetadata } from "../analysis/instruction-files.ts"
|
|
|
10
10
|
import type { CodeProvider } from "../analysis/provider.ts";
|
|
11
11
|
import type { ReadNextItem } from "../analysis/read-next.ts";
|
|
12
12
|
import type { TargetCandidateCompleteness } from "../analysis/target/types.ts";
|
|
13
|
+
import type { AnchoredResolutionMetadata } from "../types/index.ts";
|
|
13
14
|
import type { OrientationTargetInput, TargetSymbolKind } from "./target-input.ts";
|
|
14
15
|
import type { AnchorKind, TargetStoreEntry } from "./target-store.ts";
|
|
15
16
|
|
|
@@ -96,6 +97,8 @@ export interface OrientationSectionData {
|
|
|
96
97
|
readonly evidenceLists: readonly EvidenceListMetadata[];
|
|
97
98
|
/** Evidence list counted by table rows, including when only empty-result framing remains. */
|
|
98
99
|
readonly tableEvidenceKey?: string;
|
|
100
|
+
/** Named collected facts, independent of presentation atoms. */
|
|
101
|
+
readonly facts?: import("./orientation/facts.ts").OrientationFacts;
|
|
99
102
|
/** Content atoms for this section; the adapter frames them under the title + note. */
|
|
100
103
|
readonly items: readonly OrientationItem[];
|
|
101
104
|
}
|
|
@@ -121,15 +124,20 @@ export interface OrientationResultData {
|
|
|
121
124
|
readonly sections: readonly OrientationSectionData[];
|
|
122
125
|
readonly confidence: ConfidenceMode;
|
|
123
126
|
readonly focusTarget: string | null;
|
|
127
|
+
readonly focusKind?: "workspace" | "directory" | "module" | "file" | "symbol";
|
|
124
128
|
readonly requestedSections: readonly string[];
|
|
125
129
|
readonly renderedSections: readonly string[];
|
|
126
130
|
readonly omittedCount: number;
|
|
127
131
|
readonly nextQueries: readonly string[];
|
|
128
132
|
readonly readNext: readonly ReadNextItem[];
|
|
129
133
|
readonly instructions?: InstructionFilesMetadata;
|
|
134
|
+
/** Collected instruction snippets; separate from mutable session deduplication state. */
|
|
135
|
+
readonly instructionFiles?: readonly import("../analysis/instruction-files.ts").RenderedInstructionFile[];
|
|
130
136
|
/** Captured generic workspace facts; absent for the unchanged file and symbol paths. */
|
|
131
137
|
readonly workspace?: import("./orientation/workspace-context.ts").WorkspaceOrientationFacts;
|
|
132
138
|
readonly target?: Readonly<TargetStoreEntry>;
|
|
139
|
+
/** Current anchored focus observation, separate from reusable target facts. */
|
|
140
|
+
readonly resolution?: AnchoredResolutionMetadata;
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
export type OrientationWorkflowOutcome =
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** Session-owned Orientation workflow. */
|
|
2
2
|
|
|
3
3
|
import { existsSync, statSync } from "node:fs";
|
|
4
|
-
import { relative } from "node:path";
|
|
5
4
|
import { buildArchitectureModel } from "../analysis/architecture/discovery.ts";
|
|
6
5
|
import type { ArchitectureModel } from "../analysis/architecture/model.ts";
|
|
7
6
|
import {
|
|
@@ -10,7 +9,7 @@ import {
|
|
|
10
9
|
} from "../analysis/instruction-files.ts";
|
|
11
10
|
import { createStructuralCodeProvider, withSemanticRequestControl } from "../analysis/provider.ts";
|
|
12
11
|
import { SEMANTIC_READINESS_TIMEOUT_REASON } from "../analysis/readiness.ts";
|
|
13
|
-
import { normalizePath } from "../analysis/search/paths.ts";
|
|
12
|
+
import { normalizePath, toDisplayPath } from "../analysis/search/paths.ts";
|
|
14
13
|
import { loadCodeIntelligenceConfig } from "../config.ts";
|
|
15
14
|
import type { CapabilityAdapter } from "./capability-adapter.ts";
|
|
16
15
|
import { parseOrientationWorkflowInput } from "./input/workflows.ts";
|
|
@@ -95,7 +94,7 @@ export async function runOrientationWorkflow(
|
|
|
95
94
|
{ model, provider, lspRuntime, cwd: deps.cwd, requestControl: control },
|
|
96
95
|
);
|
|
97
96
|
throwIfAborted(control);
|
|
98
|
-
const withInstructions = addInstructionFiles(result, focus.path, deps);
|
|
97
|
+
const withInstructions = addInstructionFiles({ ...result, focusKind: "file" }, focus.path, deps);
|
|
99
98
|
return { kind: "completed", data: withInstructions };
|
|
100
99
|
}
|
|
101
100
|
|
|
@@ -195,7 +194,16 @@ async function orientTarget(options: {
|
|
|
195
194
|
throwIfAborted(control);
|
|
196
195
|
return {
|
|
197
196
|
kind: "completed",
|
|
198
|
-
data: addTargetSummary(
|
|
197
|
+
data: addTargetSummary(
|
|
198
|
+
{
|
|
199
|
+
...result,
|
|
200
|
+
focusKind: "symbol",
|
|
201
|
+
...(target.resolution ? { resolution: target.resolution } : {}),
|
|
202
|
+
},
|
|
203
|
+
entry,
|
|
204
|
+
target.notes,
|
|
205
|
+
deps.cwd,
|
|
206
|
+
),
|
|
199
207
|
};
|
|
200
208
|
}
|
|
201
209
|
|
|
@@ -240,7 +248,12 @@ function addInstructionFiles(
|
|
|
240
248
|
surfacedDirectories: deps.surfacedInstructionDirs,
|
|
241
249
|
projectTrusted: deps.projectTrusted,
|
|
242
250
|
});
|
|
243
|
-
const collected = collectInstructionFiles(
|
|
251
|
+
const collected = collectInstructionFiles(
|
|
252
|
+
matches.map((match) => ({
|
|
253
|
+
...match,
|
|
254
|
+
relativePath: toDisplayPath(deps.cwd, match.absolutePath),
|
|
255
|
+
})),
|
|
256
|
+
);
|
|
244
257
|
if (!collected) return result;
|
|
245
258
|
const items: OrientationItem[] = [];
|
|
246
259
|
for (const file of collected.files) {
|
|
@@ -279,6 +292,7 @@ function addInstructionFiles(
|
|
|
279
292
|
sections: [section, ...result.sections],
|
|
280
293
|
renderedSections: ["instructions", ...result.renderedSections],
|
|
281
294
|
instructions: collected.metadata,
|
|
295
|
+
instructionFiles: collected.files,
|
|
282
296
|
};
|
|
283
297
|
}
|
|
284
298
|
|
|
@@ -299,7 +313,7 @@ function addTargetSummary(
|
|
|
299
313
|
const name = entry.name ? ` ${entry.name}` : "";
|
|
300
314
|
const summaryNotes = [
|
|
301
315
|
...notes.map((note) => `Note: ${note}`),
|
|
302
|
-
`Resolved target${name}: ${
|
|
316
|
+
`Resolved target${name}: ${toDisplayPath(cwd, entry.file)}:${entry.displayLine}:${entry.displayCharacter} — Target ID: ${entry.targetId}`,
|
|
303
317
|
];
|
|
304
318
|
return { ...result, notes: [...summaryNotes, ...result.notes], target: { ...entry } };
|
|
305
319
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Fingerprint-bound edit evidence for refactor planning. */
|
|
2
|
+
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import type { FileEdit, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
|
|
6
|
+
import { createLogicalLineIndex, type LogicalLineIndex } from "../analysis/refactor/position.ts";
|
|
7
|
+
import { computeFileFingerprint } from "./refactor-plans.ts";
|
|
8
|
+
|
|
9
|
+
type FileFingerprint = { file: string; fingerprint: string };
|
|
10
|
+
|
|
11
|
+
/** Fingerprint each edited file, reusing an earlier source snapshot when provided. */
|
|
12
|
+
export function collectFileFingerprints(
|
|
13
|
+
edits: readonly { file: string }[],
|
|
14
|
+
sourceSnapshot?: FileFingerprint,
|
|
15
|
+
): FileFingerprint[] {
|
|
16
|
+
const files = [...new Set(edits.map((edit) => edit.file))];
|
|
17
|
+
return files.map((file) => ({
|
|
18
|
+
file,
|
|
19
|
+
fingerprint:
|
|
20
|
+
sourceSnapshot?.file === file ? sourceSnapshot.fingerprint : computeFileFingerprint(file),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Drop edits whose replacement exactly equals the text they replace.
|
|
26
|
+
*
|
|
27
|
+
* Text is read only from content whose hash still equals the plan's verified
|
|
28
|
+
* fingerprint, so the comparison uses the snapshot that the plan was validated
|
|
29
|
+
* against. Files left without edits lose their fingerprints and preconditions.
|
|
30
|
+
* Edits whose ranges do not fit the content are kept for normal validation.
|
|
31
|
+
*/
|
|
32
|
+
export function dropIdentityEdits(
|
|
33
|
+
edits: WorkspaceEdit,
|
|
34
|
+
fileFingerprints: readonly FileFingerprint[],
|
|
35
|
+
):
|
|
36
|
+
| { kind: "ok"; edits: WorkspaceEdit; fileFingerprints: FileFingerprint[] }
|
|
37
|
+
| { kind: "unavailable"; reason: string } {
|
|
38
|
+
const contents = new Map<string, { content: string; index: LogicalLineIndex }>();
|
|
39
|
+
for (const { file, fingerprint } of fileFingerprints) {
|
|
40
|
+
let content: string;
|
|
41
|
+
try {
|
|
42
|
+
content = readFileSync(file, "utf-8");
|
|
43
|
+
} catch {
|
|
44
|
+
return { kind: "unavailable", reason: `File ${file} could not be read during planning.` };
|
|
45
|
+
}
|
|
46
|
+
if (createHash("sha256").update(content).digest("hex") !== fingerprint) {
|
|
47
|
+
return {
|
|
48
|
+
kind: "unavailable",
|
|
49
|
+
reason: `File ${file} changed during planning. Request a new plan.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
contents.set(file, { content, index: createLogicalLineIndex(content) });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const kept = edits.edits.filter((edit) => !isIdentityEdit(edit, contents.get(edit.file)));
|
|
56
|
+
const files = new Set(kept.map((edit) => edit.file));
|
|
57
|
+
const preconditions = edits.documentPreconditions?.filter((item) => files.has(item.file));
|
|
58
|
+
return {
|
|
59
|
+
kind: "ok",
|
|
60
|
+
edits: preconditions ? { edits: kept, documentPreconditions: preconditions } : { edits: kept },
|
|
61
|
+
fileFingerprints: fileFingerprints.filter(({ file }) => files.has(file)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isIdentityEdit(
|
|
66
|
+
edit: FileEdit,
|
|
67
|
+
source: { content: string; index: LogicalLineIndex } | undefined,
|
|
68
|
+
): boolean {
|
|
69
|
+
if (!source) return false;
|
|
70
|
+
try {
|
|
71
|
+
const start = source.index.offsetAt(edit.range.start);
|
|
72
|
+
return source.content.slice(start, source.index.offsetAt(edit.range.end)) === edit.newText;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import { readFileSync } from "node:fs";
|
|
11
11
|
import type { RefactorOperation, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
|
|
12
|
+
import { toDisplayPath } from "../analysis/search/paths.ts";
|
|
12
13
|
|
|
13
14
|
export interface RefactorPlan {
|
|
14
15
|
id: string;
|
|
@@ -41,6 +42,7 @@ export function computeFileFingerprint(file: string): string {
|
|
|
41
42
|
export function validateSynchronizedContentFingerprints(
|
|
42
43
|
preconditions: WorkspaceEdit["documentPreconditions"],
|
|
43
44
|
fileFingerprints: readonly { file: string; fingerprint: string }[],
|
|
45
|
+
cwd: string,
|
|
44
46
|
): string | null {
|
|
45
47
|
const fingerprints = new Map(
|
|
46
48
|
fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
|
|
@@ -48,7 +50,7 @@ export function validateSynchronizedContentFingerprints(
|
|
|
48
50
|
for (const precondition of preconditions ?? []) {
|
|
49
51
|
if (precondition.kind !== "open-document-content") continue;
|
|
50
52
|
if (fingerprints.get(precondition.file) !== precondition.fingerprint) {
|
|
51
|
-
return `File ${precondition.file} changed after the semantic input snapshot. Request a new rename plan.`;
|
|
53
|
+
return `File ${toDisplayPath(cwd, precondition.file)} changed after the semantic input snapshot. Request a new rename plan.`;
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
return null;
|
|
@@ -89,13 +91,14 @@ export function removePlan(store: Map<string, RefactorPlan>, id: string): void {
|
|
|
89
91
|
/** Check if a plan is still fresh (all file fingerprints match). */
|
|
90
92
|
export function isPlanFresh(
|
|
91
93
|
plan: RefactorPlan,
|
|
94
|
+
cwd: string,
|
|
92
95
|
): { fresh: true } | { fresh: false; reason: string } {
|
|
93
96
|
for (const fp of plan.fileFingerprints) {
|
|
94
97
|
const current = computeFileFingerprint(fp.file);
|
|
95
98
|
if (current !== fp.fingerprint) {
|
|
96
99
|
return {
|
|
97
100
|
fresh: false,
|
|
98
|
-
reason: `File ${fp.file} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
|
|
101
|
+
reason: `File ${toDisplayPath(cwd, fp.file)} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
parseRefactorApplyWorkflowInput,
|
|
25
25
|
parseRefactorPlanWorkflowInput,
|
|
26
26
|
} from "./input/health-refactor.ts";
|
|
27
|
+
import { collectFileFingerprints, dropIdentityEdits } from "./refactor-identity.ts";
|
|
27
28
|
import {
|
|
28
29
|
computeFileFingerprint,
|
|
29
30
|
generatePlanId,
|
|
@@ -130,7 +131,7 @@ export async function runRefactorApplyWorkflow(
|
|
|
130
131
|
plan.authorizedMutationRoots,
|
|
131
132
|
);
|
|
132
133
|
if (authority.kind === "unavailable") return authority;
|
|
133
|
-
const freshness = isPlanFresh(plan);
|
|
134
|
+
const freshness = isPlanFresh(plan, deps.cwd);
|
|
134
135
|
if (!freshness.fresh) return { kind: "invalid-input", message: freshness.reason };
|
|
135
136
|
const validation = validateEdit(plan.edits);
|
|
136
137
|
if (!validation.safe) return { kind: "invalid-input", message: validation.reason };
|
|
@@ -144,11 +145,11 @@ export async function runRefactorApplyWorkflow(
|
|
|
144
145
|
const expectedFingerprints = new Map(
|
|
145
146
|
plan.fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
|
|
146
147
|
);
|
|
147
|
-
const getOpenDocumentVersion = getDocumentVersionReader(deps);
|
|
148
148
|
const result = await applyWorkspaceEdit(plan.edits, {
|
|
149
|
+
cwd: deps.cwd,
|
|
149
150
|
authorizedMutationRoots: plan.authorizedMutationRoots,
|
|
150
151
|
expectedFingerprints,
|
|
151
|
-
getOpenDocumentVersion,
|
|
152
|
+
getOpenDocumentVersion: getDocumentVersionReader(deps),
|
|
152
153
|
});
|
|
153
154
|
if (result.kind === "error") return { kind: "unavailable", reason: result.reason };
|
|
154
155
|
deps.removePlan(plan.id);
|
|
@@ -199,8 +200,17 @@ async function planResolvedRefactor(
|
|
|
199
200
|
const snapshotError = validateSynchronizedContentFingerprints(
|
|
200
201
|
result.edits.documentPreconditions,
|
|
201
202
|
fileFingerprints,
|
|
203
|
+
deps.cwd,
|
|
202
204
|
);
|
|
203
205
|
if (snapshotError) return { kind: "unavailable", reason: snapshotError };
|
|
206
|
+
const changed = dropIdentityEdits(result.edits, fileFingerprints);
|
|
207
|
+
if (changed.kind === "unavailable") return changed;
|
|
208
|
+
if (changed.edits.edits.length === 0) {
|
|
209
|
+
return {
|
|
210
|
+
kind: "invalid-input",
|
|
211
|
+
message: `The ${parsed.operation} refactor produces no changes; every planned edit matches the current text.`,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
204
214
|
|
|
205
215
|
const plan: RefactorPlan = {
|
|
206
216
|
id: generatePlanId(
|
|
@@ -215,10 +225,10 @@ async function planResolvedRefactor(
|
|
|
215
225
|
targetFile: file,
|
|
216
226
|
targetLine: target.displayLine,
|
|
217
227
|
targetCharacter: target.displayCharacter,
|
|
218
|
-
edits:
|
|
228
|
+
edits: changed.edits,
|
|
219
229
|
evidenceSource: sectionRename.evidenceSource,
|
|
220
230
|
authorizedMutationRoots: authority.canonicalRoots,
|
|
221
|
-
fileFingerprints,
|
|
231
|
+
fileFingerprints: changed.fileFingerprints,
|
|
222
232
|
createdAt: Date.now(),
|
|
223
233
|
};
|
|
224
234
|
deps.storePlan(plan);
|
|
@@ -365,18 +375,6 @@ async function planWithProvider(
|
|
|
365
375
|
};
|
|
366
376
|
}
|
|
367
377
|
|
|
368
|
-
function collectFileFingerprints(
|
|
369
|
-
edits: Array<{ file: string }>,
|
|
370
|
-
sourceSnapshot?: { readonly file: string; readonly fingerprint: string },
|
|
371
|
-
): Array<{ file: string; fingerprint: string }> {
|
|
372
|
-
const files = [...new Set(edits.map((edit) => edit.file))];
|
|
373
|
-
return files.map((file) => ({
|
|
374
|
-
file,
|
|
375
|
-
fingerprint:
|
|
376
|
-
sourceSnapshot?.file === file ? sourceSnapshot.fingerprint : computeFileFingerprint(file),
|
|
377
|
-
}));
|
|
378
|
-
}
|
|
379
|
-
|
|
380
378
|
function immutablePlan(plan: RefactorPlan): Readonly<RefactorPlan> {
|
|
381
379
|
return Object.freeze({
|
|
382
380
|
...plan,
|
|
@@ -31,9 +31,9 @@ export type TargetProviderProvenance = "semantic" | "structural";
|
|
|
31
31
|
/**
|
|
32
32
|
* A stored resolved target entry with handles and metadata.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Contains stable target facts only; request-local resolution metadata belongs
|
|
35
|
+
* to the Target workflow outcome. Computed fields like relative paths are
|
|
36
|
+
* derived at the rendering boundary.
|
|
37
37
|
*/
|
|
38
38
|
export interface TargetStoreEntry {
|
|
39
39
|
targetId: string;
|
|
@@ -60,12 +60,6 @@ export interface TargetStoreEntry {
|
|
|
60
60
|
fileFingerprint: string;
|
|
61
61
|
/** Named symbolic container, or null when no container name was reported. */
|
|
62
62
|
container: string | null;
|
|
63
|
-
/**
|
|
64
|
-
* Resolution provenance — present when the target was resolved from
|
|
65
|
-
* anchored coordinates. Carries requested/resolved coordinates, whether
|
|
66
|
-
* the anchor was snapped, and the provider-backed evidence source.
|
|
67
|
-
*/
|
|
68
|
-
resolution?: import("../types/index.ts").AnchoredResolutionMetadata;
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
/** Input shape for registering a resolved target. */
|
|
@@ -95,12 +89,6 @@ export interface TargetRegistrationInput {
|
|
|
95
89
|
anchorKind: AnchorKind;
|
|
96
90
|
/** Named symbolic container used to disambiguate same-file identity collisions, or null when unreported (ADR 0003). */
|
|
97
91
|
container: string | null;
|
|
98
|
-
/**
|
|
99
|
-
* Resolution provenance — present when the target was resolved from
|
|
100
|
-
* anchored coordinates. Carries requested/resolved coordinates, whether
|
|
101
|
-
* the anchor was snapped, and the provider-backed evidence source.
|
|
102
|
-
*/
|
|
103
|
-
resolution?: import("../types/index.ts").AnchoredResolutionMetadata;
|
|
104
92
|
/** Reuse one verified fingerprint across a bounded registration batch. */
|
|
105
93
|
fileFingerprint?: string;
|
|
106
94
|
}
|
|
@@ -261,7 +249,6 @@ export function registerWorkflowTarget(
|
|
|
261
249
|
anchorKind: input.anchorKind,
|
|
262
250
|
fileFingerprint: fingerprint,
|
|
263
251
|
container: input.container,
|
|
264
|
-
resolution: input.resolution,
|
|
265
252
|
};
|
|
266
253
|
|
|
267
254
|
const existing = store.get(targetId);
|
|
@@ -293,7 +280,6 @@ function mergeTargetRefinement(
|
|
|
293
280
|
displayCharacter: anchorSource.displayCharacter,
|
|
294
281
|
kind: displayKind,
|
|
295
282
|
anchorKind: anchorSource.anchorKind,
|
|
296
|
-
resolution: anchorSource.resolution,
|
|
297
283
|
confidence: strongestEvidenceSource.confidence,
|
|
298
284
|
provenance: mergeProvenance(existing.provenance, incoming.provenance),
|
|
299
285
|
};
|
|
@@ -305,7 +291,6 @@ function selectAnchorSource(
|
|
|
305
291
|
): TargetStoreEntry {
|
|
306
292
|
if (existing.anchorKind === "declaration" && incoming.anchorKind === "name") return incoming;
|
|
307
293
|
if (existing.anchorKind === "name" && incoming.anchorKind === "declaration") return existing;
|
|
308
|
-
if (!existing.resolution && incoming.resolution) return incoming;
|
|
309
294
|
return existing;
|
|
310
295
|
}
|
|
311
296
|
|