@mrclrchtr/supi-code-intelligence 11.0.1 → 11.2.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 +68 -6
- package/gradle-helper/README.md +48 -0
- package/gradle-helper/build.sh +73 -0
- package/gradle-helper/lib/gradle-tooling-api-9.4.0.jar +0 -0
- package/gradle-helper/lib/slf4j-api-2.0.17.jar +0 -0
- package/gradle-helper/lib/slf4j-simple-2.0.17.jar +0 -0
- package/gradle-helper/lib/supi-gradle-observation.jar +0 -0
- package/gradle-helper/licenses/DEPENDENCIES.md +11 -0
- package/gradle-helper/licenses/LICENSE-gradle-tooling-api.txt +422 -0
- package/gradle-helper/licenses/LICENSE-slf4j.txt +21 -0
- package/gradle-helper/licenses/NOTICE-gradle.txt +21 -0
- package/gradle-helper/src/GradleObservation.java +597 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +43 -6
- 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-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- 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/node_modules/vscode-jsonrpc/README.md +5 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +8 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +44 -5
- 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/manager/manager-project-info.ts +22 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +53 -20
- 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/scanner.ts +27 -15
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
- 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-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
- 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 +19 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
- 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 +19 -2
- package/node_modules/ignore/README.md +36 -10
- package/node_modules/ignore/index.d.ts +3 -2
- package/node_modules/ignore/index.js +57 -53
- package/node_modules/ignore/legacy.js +50 -46
- package/node_modules/ignore/package.json +1 -1
- package/package.json +11 -6
- package/src/analysis/capability/capability-warnings.ts +18 -12
- package/src/analysis/gradle/query.ts +273 -0
- package/src/analysis/gradle/runtime.ts +173 -0
- package/src/analysis/gradle/types.ts +65 -0
- 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 +8 -0
- package/src/analysis/health/signals.ts +2 -0
- package/src/analysis/health/status.ts +82 -0
- package/src/analysis/read-next.ts +1 -4
- package/src/analysis/refactor/apply.ts +19 -10
- package/src/analysis/refactor/mutation-authority.ts +4 -1
- package/src/analysis/search/ast-scan.ts +143 -18
- package/src/analysis/workspace/safe-path.ts +14 -2
- package/src/analysis/workspace/types.ts +2 -0
- package/src/extension.ts +10 -1
- package/src/gradle/consent.ts +279 -0
- package/src/headless.ts +3 -0
- package/src/overview/collect.ts +11 -3
- package/src/session/health-types.ts +7 -0
- package/src/session/health-workflow.ts +8 -43
- package/src/session/orientation/collect.ts +138 -12
- package/src/session/orientation/context-facts.ts +27 -2
- package/src/session/orientation/context-sections.ts +47 -0
- package/src/session/orientation/facts.ts +124 -0
- package/src/session/orientation/gather.ts +98 -11
- package/src/session/orientation/workspace-context.ts +59 -28
- package/src/session/orientation-types.ts +16 -1
- package/src/session/orientation-workflow.ts +5 -2
- package/src/session/refactor-plans.ts +5 -2
- package/src/session/refactor-workflow.ts +4 -3
- package/src/session/session.ts +8 -0
- package/src/tool/code_find/execute.ts +1 -1
- package/src/tool/code_find/guidance.ts +1 -1
- package/src/tool/code_find/markdown.ts +24 -17
- package/src/tool/code_find/result.ts +18 -5
- package/src/tool/code_find/spec.ts +2 -0
- package/src/tool/code_find/structured.ts +161 -0
- package/src/tool/code_graph/result.ts +32 -15
- package/src/tool/code_graph/spec.ts +2 -0
- package/src/tool/code_graph/structured.ts +142 -0
- package/src/tool/code_health/markdown.ts +17 -17
- package/src/tool/code_health/result.ts +15 -2
- package/src/tool/code_health/spec.ts +2 -0
- package/src/tool/code_health/structured-schema.ts +250 -0
- package/src/tool/code_health/structured.ts +256 -0
- package/src/tool/code_inspect/markdown.ts +19 -11
- package/src/tool/code_inspect/result.ts +12 -5
- package/src/tool/code_inspect/spec.ts +2 -0
- package/src/tool/code_inspect/structured.ts +232 -0
- package/src/tool/code_orientation/directory-navigation.ts +66 -0
- package/src/tool/code_orientation/gradle-sections.ts +68 -0
- package/src/tool/code_orientation/markdown.ts +19 -8
- package/src/tool/code_orientation/result.ts +95 -11
- package/src/tool/code_orientation/spec.ts +2 -0
- package/src/tool/code_orientation/structured-schema.ts +607 -0
- package/src/tool/code_orientation/structured-workspace.ts +193 -0
- package/src/tool/code_orientation/structured.ts +195 -0
- package/src/tool/code_orientation/workspace-format.ts +2 -1
- package/src/tool/code_orientation/workspace-observations.ts +81 -0
- package/src/tool/code_orientation/workspace-output.ts +45 -13
- package/src/tool/code_orientation/workspace-projects.ts +180 -75
- package/src/tool/code_orientation/workspace-sections.ts +46 -31
- package/src/tool/code_refactor_apply/execute.ts +1 -1
- package/src/tool/code_refactor_apply/result.ts +13 -5
- 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 +16 -8
- package/src/tool/code_refactor_plan/spec.ts +2 -0
- package/src/tool/code_refactor_plan/structured.ts +128 -0
- package/src/tool/code_resolve/markdown.ts +4 -10
- package/src/tool/code_resolve/result.ts +2 -0
- package/src/tool/code_resolve/spec.ts +2 -0
- package/src/tool/code_resolve/structured.ts +103 -0
- package/src/tool/infra/truncate.ts +12 -4
- package/src/tool/register.ts +10 -6
- package/src/tool/result/display.ts +17 -0
- package/src/tool/result/model-budget.ts +195 -0
- package/src/tool/result/structured.ts +62 -0
- package/src/tool/result/types.ts +10 -2
- package/src/tool/schemas.ts +7 -1
- package/src/tool/specs.ts +2 -0
- package/src/types/execution.ts +5 -1
- package/src/ui/status-command.ts +110 -321
- package/src/ui/status-overlay.ts +564 -420
- package/src/ui/tui/display.ts +10 -4
|
@@ -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
|
}
|
|
@@ -4,9 +4,13 @@ import { loadAutomaticExclusionPatterns } from "@mrclrchtr/supi-core/config";
|
|
|
4
4
|
import ignore from "ignore";
|
|
5
5
|
import { isGitIgnoredDirectory } from "../../analysis/workspace/git.ts";
|
|
6
6
|
import { observeWorkspace } from "../../analysis/workspace/observe.ts";
|
|
7
|
-
import { assertUnlinkedPath } from "../../analysis/workspace/safe-path.ts";
|
|
7
|
+
import { assertUnlinkedPath, WorkspaceSymlinkError } from "../../analysis/workspace/safe-path.ts";
|
|
8
8
|
import type { WorkspaceObservation } from "../../analysis/workspace/types.ts";
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
OrientationResultData,
|
|
11
|
+
OrientationWorkflowInput,
|
|
12
|
+
OrientationWorkflowOutcome,
|
|
13
|
+
} from "../orientation-types.ts";
|
|
10
14
|
import type { WorkflowControl } from "../workflow-control.ts";
|
|
11
15
|
|
|
12
16
|
/** Captured facts for workspace and directory presentation; no provider or live state. */
|
|
@@ -22,35 +26,63 @@ export interface WorkspaceOrientationFacts {
|
|
|
22
26
|
/** Select the new navigation path without changing file or symbol-focused workflows. */
|
|
23
27
|
export async function orientWorkspaceContext(
|
|
24
28
|
request: OrientationWorkflowInput,
|
|
25
|
-
options: {
|
|
29
|
+
options: {
|
|
30
|
+
cwd: string;
|
|
31
|
+
homeDir?: string;
|
|
32
|
+
projectTrusted: boolean;
|
|
33
|
+
gradleObserver?: import("../../analysis/gradle/types.ts").GradleObserver;
|
|
34
|
+
},
|
|
26
35
|
control?: WorkflowControl,
|
|
27
36
|
): Promise<
|
|
28
37
|
| { kind: "completed"; data: OrientationResultData; directory: string | null }
|
|
29
|
-
| { kind: "invalid-input"
|
|
38
|
+
| Extract<OrientationWorkflowOutcome, { kind: "invalid-input" }>
|
|
30
39
|
| null
|
|
31
40
|
> {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
const selected = directoryFocus(request, options.cwd);
|
|
43
|
+
if (!selected) return null;
|
|
44
|
+
let focus = selected.path;
|
|
45
|
+
const exclude = loadAutomaticExclusionPatterns(options.cwd, options);
|
|
46
|
+
if (focus) await assertFocusPath(options.cwd, focus);
|
|
47
|
+
let observation = await initialObservation(options.cwd, focus, exclude, control);
|
|
48
|
+
if (request.focus && "module" in request.focus) {
|
|
49
|
+
const selected = resolveModule(observation, request.focus.module);
|
|
50
|
+
if (selected.kind === "invalid-input") return selected;
|
|
51
|
+
focus = selected.path;
|
|
52
|
+
}
|
|
53
|
+
if (focus) observation = await focusObservation(observation, focus, exclude, control);
|
|
54
|
+
const selectedRoot =
|
|
55
|
+
request.focus && "path" in request.focus ? (focus ?? options.cwd) : options.cwd;
|
|
56
|
+
const gradle = await options.gradleObserver?.observe(selectedRoot, control);
|
|
57
|
+
if (gradle) observation = { ...observation, gradle };
|
|
58
|
+
return {
|
|
59
|
+
kind: "completed",
|
|
60
|
+
directory: focus,
|
|
61
|
+
data: {
|
|
62
|
+
...workspaceOrientationData({
|
|
63
|
+
observation,
|
|
64
|
+
cwd: options.cwd,
|
|
65
|
+
focus,
|
|
66
|
+
maxResults: request.maxResults ?? 10,
|
|
67
|
+
}),
|
|
68
|
+
focusKind: workspaceFocusKind(request),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (!(error instanceof WorkspaceSymlinkError)) throw error;
|
|
73
|
+
return {
|
|
74
|
+
kind: "invalid-input",
|
|
75
|
+
message: error.message,
|
|
76
|
+
symlinkRejection: { requestedPath: error.requestedPath, blockedPath: error.blockedPath },
|
|
77
|
+
};
|
|
42
78
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
focus,
|
|
51
|
-
maxResults: request.maxResults ?? 10,
|
|
52
|
-
}),
|
|
53
|
-
};
|
|
79
|
+
}
|
|
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";
|
|
54
86
|
}
|
|
55
87
|
|
|
56
88
|
async function initialObservation(
|
|
@@ -107,13 +139,12 @@ async function assertFocusPath(cwd: string, focus: string): Promise<void> {
|
|
|
107
139
|
function directoryFocus(
|
|
108
140
|
request: OrientationWorkflowInput,
|
|
109
141
|
cwd: string,
|
|
110
|
-
): { kind: "directory"; path: string | null } |
|
|
142
|
+
): { kind: "directory"; path: string | null } | null {
|
|
111
143
|
if (!request.focus || "module" in request.focus) return { kind: "directory", path: null };
|
|
112
144
|
if ("target" in request.focus) return null;
|
|
113
145
|
const focus = path.resolve(cwd, request.focus.path.replace(/^@/, ""));
|
|
114
146
|
if (!existsSync(focus) || !statSync(focus).isDirectory()) return null;
|
|
115
|
-
if (lstatSync(focus).isSymbolicLink())
|
|
116
|
-
return { kind: "invalid-input", message: "Symbolic-link directory focus is not followed." };
|
|
147
|
+
if (lstatSync(focus).isSymbolicLink()) throw new WorkspaceSymlinkError(focus, focus);
|
|
117
148
|
return { kind: "directory", path: focus };
|
|
118
149
|
}
|
|
119
150
|
|
|
@@ -94,6 +94,10 @@ export interface OrientationSectionData {
|
|
|
94
94
|
readonly confidence: ConfidenceMode;
|
|
95
95
|
readonly provenance: readonly OrientationProvenance[];
|
|
96
96
|
readonly evidenceLists: readonly EvidenceListMetadata[];
|
|
97
|
+
/** Evidence list counted by table rows, including when only empty-result framing remains. */
|
|
98
|
+
readonly tableEvidenceKey?: string;
|
|
99
|
+
/** Named collected facts, independent of presentation atoms. */
|
|
100
|
+
readonly facts?: import("./orientation/facts.ts").OrientationFacts;
|
|
97
101
|
/** Content atoms for this section; the adapter frames them under the title + note. */
|
|
98
102
|
readonly items: readonly OrientationItem[];
|
|
99
103
|
}
|
|
@@ -119,12 +123,15 @@ export interface OrientationResultData {
|
|
|
119
123
|
readonly sections: readonly OrientationSectionData[];
|
|
120
124
|
readonly confidence: ConfidenceMode;
|
|
121
125
|
readonly focusTarget: string | null;
|
|
126
|
+
readonly focusKind?: "workspace" | "directory" | "module" | "file" | "symbol";
|
|
122
127
|
readonly requestedSections: readonly string[];
|
|
123
128
|
readonly renderedSections: readonly string[];
|
|
124
129
|
readonly omittedCount: number;
|
|
125
130
|
readonly nextQueries: readonly string[];
|
|
126
131
|
readonly readNext: readonly ReadNextItem[];
|
|
127
132
|
readonly instructions?: InstructionFilesMetadata;
|
|
133
|
+
/** Collected instruction snippets; separate from mutable session deduplication state. */
|
|
134
|
+
readonly instructionFiles?: readonly import("../analysis/instruction-files.ts").RenderedInstructionFile[];
|
|
128
135
|
/** Captured generic workspace facts; absent for the unchanged file and symbol paths. */
|
|
129
136
|
readonly workspace?: import("./orientation/workspace-context.ts").WorkspaceOrientationFacts;
|
|
130
137
|
readonly target?: Readonly<TargetStoreEntry>;
|
|
@@ -141,5 +148,13 @@ export type OrientationWorkflowOutcome =
|
|
|
141
148
|
readonly requestedKind: TargetSymbolKind;
|
|
142
149
|
readonly candidates: readonly OrientationCandidate[];
|
|
143
150
|
} & TargetCandidateCompleteness)
|
|
144
|
-
| {
|
|
151
|
+
| {
|
|
152
|
+
readonly kind: "invalid-input";
|
|
153
|
+
readonly message: string;
|
|
154
|
+
/** No-follow facts for actionable explicit-focus guidance; never a resolved retry path. */
|
|
155
|
+
readonly symlinkRejection?: {
|
|
156
|
+
readonly requestedPath: string;
|
|
157
|
+
readonly blockedPath: string;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
145
160
|
| { readonly kind: "unavailable"; readonly reason: string };
|
|
@@ -36,6 +36,8 @@ export interface OrientationWorkflowDeps extends TargetWorkflowDeps {
|
|
|
36
36
|
readonly projectTrusted: boolean;
|
|
37
37
|
/** Global config home for hermetic config reads; undefined uses os.homedir(). */
|
|
38
38
|
readonly homeDir?: string;
|
|
39
|
+
/** Separately authorized runtime model collection; absent in profiles that do not own it. */
|
|
40
|
+
readonly gradleObserver?: import("../analysis/gradle/types.ts").GradleObserver;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
/** Resolve the Orientation focus and collect immutable facts for presentation adapters. */
|
|
@@ -93,7 +95,7 @@ export async function runOrientationWorkflow(
|
|
|
93
95
|
{ model, provider, lspRuntime, cwd: deps.cwd, requestControl: control },
|
|
94
96
|
);
|
|
95
97
|
throwIfAborted(control);
|
|
96
|
-
const withInstructions = addInstructionFiles(result, focus.path, deps);
|
|
98
|
+
const withInstructions = addInstructionFiles({ ...result, focusKind: "file" }, focus.path, deps);
|
|
97
99
|
return { kind: "completed", data: withInstructions };
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -193,7 +195,7 @@ async function orientTarget(options: {
|
|
|
193
195
|
throwIfAborted(control);
|
|
194
196
|
return {
|
|
195
197
|
kind: "completed",
|
|
196
|
-
data: addTargetSummary(result, entry, target.notes, deps.cwd),
|
|
198
|
+
data: addTargetSummary({ ...result, focusKind: "symbol" }, entry, target.notes, deps.cwd),
|
|
197
199
|
};
|
|
198
200
|
}
|
|
199
201
|
|
|
@@ -277,6 +279,7 @@ function addInstructionFiles(
|
|
|
277
279
|
sections: [section, ...result.sections],
|
|
278
280
|
renderedSections: ["instructions", ...result.renderedSections],
|
|
279
281
|
instructions: collected.metadata,
|
|
282
|
+
instructionFiles: collected.files,
|
|
280
283
|
};
|
|
281
284
|
}
|
|
282
285
|
|
|
@@ -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
|
}
|
|
@@ -130,7 +130,7 @@ export async function runRefactorApplyWorkflow(
|
|
|
130
130
|
plan.authorizedMutationRoots,
|
|
131
131
|
);
|
|
132
132
|
if (authority.kind === "unavailable") return authority;
|
|
133
|
-
const freshness = isPlanFresh(plan);
|
|
133
|
+
const freshness = isPlanFresh(plan, deps.cwd);
|
|
134
134
|
if (!freshness.fresh) return { kind: "invalid-input", message: freshness.reason };
|
|
135
135
|
const validation = validateEdit(plan.edits);
|
|
136
136
|
if (!validation.safe) return { kind: "invalid-input", message: validation.reason };
|
|
@@ -144,11 +144,11 @@ export async function runRefactorApplyWorkflow(
|
|
|
144
144
|
const expectedFingerprints = new Map(
|
|
145
145
|
plan.fileFingerprints.map(({ file, fingerprint }) => [file, fingerprint]),
|
|
146
146
|
);
|
|
147
|
-
const getOpenDocumentVersion = getDocumentVersionReader(deps);
|
|
148
147
|
const result = await applyWorkspaceEdit(plan.edits, {
|
|
148
|
+
cwd: deps.cwd,
|
|
149
149
|
authorizedMutationRoots: plan.authorizedMutationRoots,
|
|
150
150
|
expectedFingerprints,
|
|
151
|
-
getOpenDocumentVersion,
|
|
151
|
+
getOpenDocumentVersion: getDocumentVersionReader(deps),
|
|
152
152
|
});
|
|
153
153
|
if (result.kind === "error") return { kind: "unavailable", reason: result.reason };
|
|
154
154
|
deps.removePlan(plan.id);
|
|
@@ -199,6 +199,7 @@ async function planResolvedRefactor(
|
|
|
199
199
|
const snapshotError = validateSynchronizedContentFingerprints(
|
|
200
200
|
result.edits.documentPreconditions,
|
|
201
201
|
fileFingerprints,
|
|
202
|
+
deps.cwd,
|
|
202
203
|
);
|
|
203
204
|
if (snapshotError) return { kind: "unavailable", reason: snapshotError };
|
|
204
205
|
|
package/src/session/session.ts
CHANGED
|
@@ -178,6 +178,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
178
178
|
|
|
179
179
|
/** Global config home for hermetic config reads; undefined uses os.homedir(). */
|
|
180
180
|
#homeDir: string | undefined;
|
|
181
|
+
#gradleObserver: import("../analysis/gradle/types.ts").GradleObserver | undefined;
|
|
181
182
|
|
|
182
183
|
/** One automatic exclusion snapshot shared by this session's broad searches. */
|
|
183
184
|
#automaticPathPolicy: AutomaticLspPathPolicy | null = null;
|
|
@@ -332,6 +333,11 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
332
333
|
);
|
|
333
334
|
}
|
|
334
335
|
|
|
336
|
+
/** Attach this profile's separately authorized Gradle observation boundary. */
|
|
337
|
+
setGradleObserver(observer: import("../analysis/gradle/types.ts").GradleObserver): void {
|
|
338
|
+
this.#gradleObserver = observer;
|
|
339
|
+
}
|
|
340
|
+
|
|
335
341
|
/** Orient around the workspace or one exact focus. */
|
|
336
342
|
async orient(
|
|
337
343
|
input: OrientationWorkflowInput,
|
|
@@ -343,6 +349,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
343
349
|
...this.targetWorkflowDeps(),
|
|
344
350
|
nativeInstructionPaths: this.#nativeInstructionPaths,
|
|
345
351
|
surfacedInstructionDirs: this.#surfacedInstructionDirs,
|
|
352
|
+
gradleObserver: this.#gradleObserver,
|
|
346
353
|
projectTrusted: this.#projectTrusted,
|
|
347
354
|
homeDir: this.#homeDir,
|
|
348
355
|
},
|
|
@@ -470,6 +477,7 @@ export class WorkspaceCodeIntelligenceSession {
|
|
|
470
477
|
this.#lspController = null;
|
|
471
478
|
this.#automaticPathPolicy = null;
|
|
472
479
|
this.#projectTrusted = false;
|
|
480
|
+
this.#gradleObserver = undefined;
|
|
473
481
|
}
|
|
474
482
|
}
|
|
475
483
|
|
|
@@ -19,5 +19,5 @@ export async function executeFindTool(
|
|
|
19
19
|
ctx: CodeIntelToolExecCtx,
|
|
20
20
|
): Promise<CodeIntelResult> {
|
|
21
21
|
const outcome = await ctx.session.find(params as FindWorkflowInput, toWorkflowControl(ctx));
|
|
22
|
-
return finishFindResult(outcome, params.scope, params.mode);
|
|
22
|
+
return finishFindResult(outcome, ctx.cwd, params.scope, params.mode);
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const toolDescription =
|
|
2
|
-
"Search workspace symbols in semantic mode, or declaration, import, export, and call names in AST mode. Use
|
|
2
|
+
"Search workspace symbols in semantic mode, or declaration, import, export, and call names in AST mode. Use grep for literal or regular-expression file-content search. The selected mode does not switch to another search method.";
|
|
3
3
|
|
|
4
4
|
export const promptSnippet = "search code structure or workspace symbols";
|
|
5
5
|
|
|
@@ -59,32 +59,39 @@ function renderScanLimitations(limitations: readonly StructuredScanLimitation[])
|
|
|
59
59
|
limitation.pathCount === null
|
|
60
60
|
? "unknown paths"
|
|
61
61
|
: `${limitation.pathCount} path${limitation.pathCount === 1 ? "" : "s"}`;
|
|
62
|
-
|
|
62
|
+
const examples =
|
|
63
|
+
limitation.reason === "unreadable-path" && limitation.examples.length > 0
|
|
64
|
+
? ` (examples: ${limitation.examples.map((file) => `\`${file}\``).join(", ")})`
|
|
65
|
+
: "";
|
|
66
|
+
return `${limitation.reason}: ${count}${examples}`;
|
|
63
67
|
});
|
|
64
68
|
return `_AST Scan incomplete — ${descriptions.join("; ")}. Match total is unknown._`;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
function appendScanAndFailures(lines: string[], result: StructuredPatternResult): void {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
for (const [reason, source] of [
|
|
73
|
+
["configured-exclusion", "`code-intelligence.exclude`"],
|
|
74
|
+
["gitignore", "`.gitignore`"],
|
|
75
|
+
] as const) {
|
|
76
|
+
for (const excluded of result.scan.exclusions.filter(
|
|
77
|
+
(exclusion) => exclusion.reason === reason,
|
|
78
|
+
)) {
|
|
79
|
+
const examples = excluded.examples.length
|
|
80
|
+
? ` Examples: ${excluded.examples.map((file) => `\`${file}\``).join(", ")}.`
|
|
81
|
+
: "";
|
|
82
|
+
lines.push(
|
|
83
|
+
"",
|
|
84
|
+
`_While scanning \`${excluded.scopeRoot}\`, skipped ${excluded.pathCount} path${excluded.pathCount === 1 ? "" : "s"} by ${source}. Other explicit scopes may include these paths.${examples}_`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
|
-
const
|
|
88
|
+
for (const excluded of result.scan.exclusions.filter(
|
|
81
89
|
(exclusion) => exclusion.reason === "unsupported-operation",
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
const count = operationExclusion.pathCount;
|
|
90
|
+
)) {
|
|
91
|
+
const count = excluded.pathCount;
|
|
85
92
|
lines.push(
|
|
86
93
|
"",
|
|
87
|
-
`
|
|
94
|
+
`_While scanning \`${excluded.scopeRoot}\`, skipped ${count} file${count === 1 ? "" : "s"} because ${result.scan.policy.operation} analysis is not supported for their language._`,
|
|
88
95
|
);
|
|
89
96
|
}
|
|
90
97
|
const scanWarning = renderScanLimitations(result.scan.limitations);
|
|
@@ -171,12 +171,14 @@ function findProvenance(
|
|
|
171
171
|
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
172
172
|
import { scopedSymbolFailureMessage, searchErrorResult } from "../result/errors.ts";
|
|
173
173
|
import { renderFindResult } from "./render.ts";
|
|
174
|
+
import { structuredFindResult } from "./structured.ts";
|
|
174
175
|
|
|
175
176
|
type FindOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["find"]>>;
|
|
176
177
|
|
|
177
178
|
/** Assemble the final model-visible code_find result for one workflow outcome. */
|
|
178
179
|
export function finishFindResult(
|
|
179
180
|
outcome: FindOutcome,
|
|
181
|
+
cwd: string,
|
|
180
182
|
scope: readonly string[] | undefined,
|
|
181
183
|
mode?: FindMode,
|
|
182
184
|
): CodeIntelResult {
|
|
@@ -188,16 +190,27 @@ export function finishFindResult(
|
|
|
188
190
|
throw new Error(reason);
|
|
189
191
|
}
|
|
190
192
|
if (outcome.kind === "invalid-input") {
|
|
191
|
-
return
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
return {
|
|
194
|
+
...searchErrorResult(`**Error:** ${outcome.message}`, {
|
|
195
|
+
scope: Array.isArray(scope) ? scope.join(", ") : null,
|
|
196
|
+
nextQueries: ["Fix the search input and retry"],
|
|
197
|
+
message: outcome.message,
|
|
198
|
+
}),
|
|
199
|
+
structuredContent: {
|
|
200
|
+
kind: "invalid-input",
|
|
201
|
+
confidence: "unavailable",
|
|
202
|
+
matches: [],
|
|
203
|
+
evidenceLists: [],
|
|
204
|
+
nextQueries: ["Fix the search input and retry"],
|
|
205
|
+
message: outcome.message,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
196
208
|
}
|
|
197
209
|
|
|
198
210
|
const assembly = assembleFindWorkflowResult(outcome);
|
|
199
211
|
return {
|
|
200
212
|
content: renderFindResult(assembly),
|
|
213
|
+
structuredContent: structuredFindResult(assembly, cwd),
|
|
201
214
|
details: {
|
|
202
215
|
type: "search",
|
|
203
216
|
data: assembly.details,
|
|
@@ -5,6 +5,7 @@ import { FindQueryParam, FindScopeParam, MaxResultsParam } from "../schemas.ts";
|
|
|
5
5
|
import { CODE_FIND_AST_KINDS } from "./ast-kinds.ts";
|
|
6
6
|
import { executeFindTool } from "./execute.ts";
|
|
7
7
|
import { CODE_FIND_MODES } from "./modes.ts";
|
|
8
|
+
import { FindOutputSchema } from "./structured.ts";
|
|
8
9
|
import { renderFindCall, renderFindResult } from "./tui.ts";
|
|
9
10
|
|
|
10
11
|
export const CODE_FIND_TOOL_NAME = "code_find";
|
|
@@ -14,6 +15,7 @@ export const CODE_FIND_TOOL_LABEL = "Code Find";
|
|
|
14
15
|
export const codeFindSpec = {
|
|
15
16
|
name: CODE_FIND_TOOL_NAME,
|
|
16
17
|
label: CODE_FIND_TOOL_LABEL,
|
|
18
|
+
outputSchema: FindOutputSchema,
|
|
17
19
|
parameters: Type.Object(
|
|
18
20
|
{
|
|
19
21
|
query: FindQueryParam,
|