@mrclrchtr/supi-code-intelligence 2.0.6 → 2.1.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.
Files changed (121) hide show
  1. package/README.md +71 -1
  2. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  3. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  5. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  6. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  8. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  9. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  10. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  11. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  12. package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  13. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  14. package/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  15. package/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  16. package/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  17. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  18. package/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  19. package/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  20. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  21. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  22. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  23. package/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  24. package/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  60. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  61. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +29 -21
  62. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -1
  63. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config-settings.ts +88 -69
  64. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +22 -8
  65. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/prompt-surface.ts +357 -0
  66. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/prompt-surface.ts +4 -0
  67. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-command.ts +1 -1
  68. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +51 -29
  69. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-ui.ts +64 -18
  70. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings.ts +11 -5
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/tool-framework.ts +10 -0
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  73. package/package.json +5 -5
  74. package/src/analysis/evidence.ts +13 -0
  75. package/src/analysis/search/pattern.ts +24 -13
  76. package/src/analysis/search/ripgrep.ts +92 -7
  77. package/src/extension.ts +1 -1
  78. package/src/session/capability-adapter.ts +218 -0
  79. package/src/session/session.ts +39 -1
  80. package/src/session/target-workflow.ts +430 -0
  81. package/src/substrate/lsp/settings.ts +7 -3
  82. package/src/tool/find/execute.ts +23 -10
  83. package/src/tool/find/orchestrate.ts +67 -54
  84. package/src/tool/find/semantic-search.ts +30 -16
  85. package/src/tool/graph/collect-relation.ts +2 -1
  86. package/src/tool/graph/execute.ts +40 -12
  87. package/src/tool/graph/markdown-base.ts +5 -37
  88. package/src/tool/graph/orchestrate.ts +9 -35
  89. package/src/tool/graph/tui.ts +2 -0
  90. package/src/tool/guidance.ts +1 -1
  91. package/src/tool/health/markdown.ts +12 -70
  92. package/src/tool/health/orchestrate.ts +5 -13
  93. package/src/tool/impact/analysis.ts +0 -27
  94. package/src/tool/impact/change-set-impact.ts +3 -2
  95. package/src/tool/impact/execute.ts +27 -0
  96. package/src/tool/impact/file-level-impact.ts +3 -2
  97. package/src/tool/impact/result.ts +2 -21
  98. package/src/tool/impact/single-impact.ts +3 -2
  99. package/src/tool/infra/error-results.ts +18 -196
  100. package/src/tool/infra/pipeline.ts +24 -1
  101. package/src/tool/inspect/markdown.ts +4 -41
  102. package/src/tool/inspect/orchestrate.ts +27 -28
  103. package/src/tool/orientation/orchestrate.ts +5 -8
  104. package/src/tool/orientation/precise-target.ts +65 -69
  105. package/src/tool/refactor-apply/orchestrate.ts +2 -7
  106. package/src/tool/refactor-plan/orchestrate.ts +31 -39
  107. package/src/tool/resolve/markdown.ts +5 -6
  108. package/src/tool/resolve/orchestrate.ts +7 -103
  109. package/src/tool/result/errors.ts +199 -0
  110. package/src/tool/result/find.ts +29 -0
  111. package/src/tool/result/graph.ts +93 -0
  112. package/src/tool/result/health.ts +94 -0
  113. package/src/tool/result/impact.ts +50 -0
  114. package/src/tool/result/inspect.ts +60 -0
  115. package/src/tool/result/orientation.ts +30 -0
  116. package/src/tool/result/refactor.ts +35 -0
  117. package/src/tool/result/resolve.ts +114 -0
  118. package/src/tool/result/types.ts +188 -0
  119. package/src/tool/schemas.ts +22 -1
  120. package/src/types/details.ts +17 -185
  121. package/src/ui/tui/common.ts +45 -1
@@ -5,77 +5,19 @@
5
5
  * readable markdown sections keyed by requested `include` values.
6
6
  */
7
7
 
8
- import type { CoverageWarningReport } from "../../analysis/coverage/coverage-warnings.ts";
9
- import type { GitContext } from "../../analysis/signals/git.ts";
10
8
  import { formatGitContext } from "../../analysis/signals/git.ts";
11
-
12
- export type HealthSection = "diagnostics" | "servers" | "dirty" | "coverage" | "unused";
13
-
14
- export interface HealthServerInfo {
15
- name: string;
16
- root: string;
17
- fileTypes: string[];
18
- status: string;
19
- }
20
-
21
- export interface HealthDiagnosticEntry {
22
- file: string;
23
- errors: number;
24
- warnings: number;
25
- }
26
-
27
- export interface HealthCoverageEntry {
28
- file: string;
29
- pct: number;
30
- }
31
-
32
- export interface HealthCoverageData {
33
- available: boolean;
34
- entries: HealthCoverageEntry[];
35
- }
36
-
37
- export interface HealthUnusedExportEntry {
38
- file: string;
39
- name: string;
40
- }
41
-
42
- export interface HealthUnusedData {
43
- available: boolean;
44
- files: string[];
45
- exports: HealthUnusedExportEntry[];
46
- }
47
-
48
- /** A suggested code action at a specific diagnostic location. */
49
- export interface CodeActionSuggestion {
50
- file: string;
51
- line: number;
52
- title: string;
53
- kind?: string;
54
- }
55
-
56
- export interface HealthData {
57
- includedSections: HealthSection[];
58
- lspAvailable: boolean;
59
- lspStatus: string;
60
- recovered: boolean;
61
- /** Structural (tree-sitter) substrate readiness. Undefined when not evaluated. */
62
- structuralStatus?: string;
63
- diagnostics: HealthDiagnosticEntry[];
64
- servers: HealthServerInfo[];
65
- gitContext: GitContext | null;
66
- scopeFilter: string | null;
67
- level: "summary" | "detailed";
68
- /** Code action suggestions collected from LSP (only populated in detailed mode). */
69
- codeActions: CodeActionSuggestion[] | null;
70
- coverage: HealthCoverageData | null;
71
- unused: HealthUnusedData | null;
72
- /** Coverage warnings for degraded semantic/structural substrate. Undefined when fully healthy. */
73
- degradedCoverage?: CoverageWarningReport;
74
- /** Seconds since diagnostics were last refreshed, or undefined if never refreshed. */
75
- diagnosticAgeSeconds?: number;
76
- }
77
-
78
- export function renderHealthResult(data: HealthData, cwd: string): string {
9
+ import type { HealthData, HealthResultAssembly } from "../result/health.ts";
10
+
11
+ export type {
12
+ CodeActionSuggestion,
13
+ HealthCoverageData,
14
+ HealthData,
15
+ HealthSection,
16
+ HealthUnusedData,
17
+ } from "../result/health.ts";
18
+
19
+ export function renderHealthResult(result: HealthResultAssembly, cwd: string): string {
20
+ const data = result.data;
79
21
  const lines: string[] = ["## Code Health", ""];
80
22
 
81
23
  renderStatusLine(lines, data);
@@ -15,8 +15,8 @@ import {
15
15
  gatherCoverageEvalInput,
16
16
  } from "../../analysis/coverage/coverage-warnings.ts";
17
17
  import { loadPrioritizationSignals } from "../../analysis/signals/project.ts";
18
- import type { CodeIntelResult, HealthDetails } from "../../types/index.ts";
19
- import type { HealthData, HealthSection } from "./markdown.ts";
18
+ import type { CodeIntelResult } from "../../types/index.ts";
19
+ import { assembleHealthResult, type HealthData, type HealthSection } from "../result/health.ts";
20
20
  import { renderHealthResult } from "./markdown.ts";
21
21
  import { collectCodeActions, collectDiagnostics } from "./sections/diagnostics.ts";
22
22
  import {
@@ -138,22 +138,14 @@ export async function executeHealth(
138
138
  diagnosticAgeSeconds,
139
139
  };
140
140
 
141
- const evidenceLists = buildHealthEvidenceLists(gitContext);
142
- const content = renderHealthResult(data, cwd);
141
+ const assembly = assembleHealthResult(data, buildHealthEvidenceLists(gitContext));
142
+ const content = renderHealthResult(assembly, cwd);
143
143
 
144
144
  return {
145
145
  content,
146
146
  details: {
147
147
  type: "health",
148
- data: {
149
- lspAvailable: data.lspAvailable,
150
- lspStatus: data.lspStatus,
151
- recovered: data.recovered,
152
- structuralStatus: data.structuralStatus,
153
- diagnosticFileCount: data.diagnostics.length,
154
- serverCount: data.servers.length,
155
- evidenceLists,
156
- } satisfies HealthDetails,
148
+ data: assembly.details,
157
149
  },
158
150
  };
159
151
  }
@@ -4,7 +4,6 @@
4
4
  import * as path from "node:path";
5
5
  import type { buildArchitectureModel } from "../../analysis/architecture/discovery.ts";
6
6
  import { findModuleForPath, getDependents } from "../../analysis/architecture/model.ts";
7
- import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
8
7
  import type { CodeProvider } from "../../analysis/provider.ts";
9
8
  import type { ReferenceCollection } from "../../analysis/references/semantic-refs.ts";
10
9
  import type { ResolvedTargetData } from "../../analysis/target/types.ts";
@@ -16,7 +15,6 @@ import {
16
15
  type TestAnchorMap,
17
16
  } from "../../analysis/tests/likely-tests.ts";
18
17
  import { buildTestSurfaceDetails } from "../../analysis/tests/test-discovery.ts";
19
- import type { AffectedDetails, ImpactDetails } from "../../types/index.ts";
20
18
  import type { ImpactAnalysis } from "./types.ts";
21
19
 
22
20
  // ── Shared analysis ────────────────────────────────────────────────────
@@ -220,28 +218,3 @@ export function computeOmittedCount(
220
218
  ): number {
221
219
  return externalRefs + Math.max(0, affectedFileCount - (maxResults ?? 8));
222
220
  }
223
-
224
- // biome-ignore lint/complexity/useMaxParams: detail assembly keeps shared counts, queries, and signals explicit for both surfaces
225
- export function buildDetailsData(
226
- analysis: ImpactAnalysis,
227
- directCount: number,
228
- omittedCount: number,
229
- nextQueries: string[],
230
- prioritySignals: AffectedDetails["prioritySignals"],
231
- evidenceLists: EvidenceListMetadata[] = [],
232
- ): AffectedDetails | ImpactDetails {
233
- return {
234
- confidence: analysis.confidence,
235
- directCount,
236
- downstreamCount: analysis.downstreamCount,
237
- riskLevel: analysis.riskLevel,
238
- checkNext: analysis.checkNext,
239
- likelyTests: analysis.likelyTests,
240
- likelyTestCommands: analysis.likelyTestCommands,
241
- omittedCount,
242
- evidenceLists,
243
- nextQueries,
244
- prioritySignals,
245
- tests: analysis.tests,
246
- };
247
- }
@@ -10,7 +10,8 @@ import type { ResolvedTargetData } from "../../analysis/target/types.ts";
10
10
  import type { ChangeSetFileEntry } from "../../analysis/tests/likely-tests.ts";
11
11
  import { normalizeChangeSet } from "../../analysis/tests/likely-tests.ts";
12
12
  import type { CodeIntelResult } from "../../types/index.ts";
13
- import { analyzeChangeSet, buildDetailsData, type ChangeSetSemanticImpact } from "./analysis.ts";
13
+ import { assembleImpactDetails } from "../result/impact.ts";
14
+ import { analyzeChangeSet, type ChangeSetSemanticImpact } from "./analysis.ts";
14
15
  import { renderChangeSetImpact } from "./markdown.ts";
15
16
  import { unavailableImpactResult } from "./result.ts";
16
17
  import type { ImpactAnalysis, ImpactInput } from "./types.ts";
@@ -59,7 +60,7 @@ export async function executeChangeSetImpact(
59
60
  prioritySignals,
60
61
  }) + evidenceNote;
61
62
 
62
- const detailsData = buildDetailsData(
63
+ const detailsData = assembleImpactDetails(
63
64
  analysis,
64
65
  changeSetFiles.length,
65
66
  0,
@@ -30,6 +30,7 @@ export interface CodeImpactToolParams {
30
30
  }
31
31
 
32
32
  /** Execute the public code_impact tool. */
33
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: target workflow + pipeline orchestration stays together for clarity
33
34
  export async function executeImpactTool(
34
35
  params: CodeImpactToolParams,
35
36
  ctx: CodeIntelToolExecCtx,
@@ -38,6 +39,32 @@ export async function executeImpactTool(
38
39
 
39
40
  const hasChangeSetInputs = (params.changeSetFiles?.length ?? 0) > 0 || Boolean(params.change);
40
41
 
42
+ // ── Deep seam: resolve targetId through the session target workflow ──
43
+ // Replaces expandTargetId pipeline stage for targetId expansion.
44
+ if (!hasChangeSetInputs && params.targetId) {
45
+ const outcome = await ctx.session.resolveTarget(
46
+ { targetId: params.targetId },
47
+ { fileLevelAllowed: false, nameAnchorRequired: false, waitForSemantic: false },
48
+ );
49
+
50
+ if (outcome.kind === "resolved") {
51
+ params.file = outcome.entry.file;
52
+ params.line = outcome.entry.displayLine;
53
+ params.character = outcome.entry.displayCharacter;
54
+ params.symbol = outcome.entry.name ?? undefined;
55
+ } else if (outcome.kind !== "no-target") {
56
+ const msg =
57
+ outcome.kind === "invalid-input"
58
+ ? outcome.message
59
+ : outcome.kind === "unavailable"
60
+ ? outcome.reason
61
+ : "Target resolution failed. Verify the targetId is valid.";
62
+ return impactErrorResult(msg, {
63
+ nextQueries: ["Use `code_resolve` to resolve a target first"],
64
+ });
65
+ }
66
+ }
67
+
41
68
  return runPipe(
42
69
  params,
43
70
  ctx,
@@ -8,7 +8,8 @@ import { summarizePrioritySignalsForFiles } from "../../analysis/signals/project
8
8
  import type { ResolvedTargetGroupData } from "../../analysis/target/types.ts";
9
9
  import { buildTestAnchorMap } from "../../analysis/tests/likely-tests.ts";
10
10
  import type { CodeIntelResult } from "../../types/index.ts";
11
- import { analyzeReferenceImpact, buildDetailsData, computeOmittedCount } from "./analysis.ts";
11
+ import { assembleImpactDetails } from "../result/impact.ts";
12
+ import { analyzeReferenceImpact, computeOmittedCount } from "./analysis.ts";
12
13
  import { renderImpactFileLevel } from "./markdown.ts";
13
14
  import type { ImpactInput } from "./types.ts";
14
15
 
@@ -60,7 +61,7 @@ export async function executeFileLevelImpact(
60
61
  cwd,
61
62
  });
62
63
 
63
- const detailsData = buildDetailsData(
64
+ const detailsData = assembleImpactDetails(
64
65
  analysis,
65
66
  aggregated.refs.length,
66
67
  computeOmittedCount(analysis.externalRefs, analysis.affectedFiles.size, input.maxResults),
@@ -1,21 +1,2 @@
1
- import type { CodeIntelResult } from "../../types/index.ts";
2
-
3
- export function unavailableImpactResult(content: string, nextQueries: string[]): CodeIntelResult {
4
- return {
5
- content,
6
- details: {
7
- type: "impact",
8
- data: {
9
- confidence: "unavailable",
10
- directCount: 0,
11
- downstreamCount: 0,
12
- riskLevel: "low" as const,
13
- checkNext: [],
14
- likelyTests: [],
15
- likelyTestCommands: [],
16
- omittedCount: 0,
17
- nextQueries,
18
- },
19
- },
20
- };
21
- }
1
+ /** Compatibility export for impact result assembly. */
2
+ export { unavailableImpactResult } from "../result/impact.ts";
@@ -10,7 +10,8 @@ import { summarizePrioritySignalsForFiles } from "../../analysis/signals/project
10
10
  import type { ResolvedTargetData } from "../../analysis/target/types.ts";
11
11
  import { buildTestAnchorMap } from "../../analysis/tests/likely-tests.ts";
12
12
  import type { CodeIntelResult } from "../../types/index.ts";
13
- import { analyzeReferenceImpact, buildDetailsData, computeOmittedCount } from "./analysis.ts";
13
+ import { assembleImpactDetails } from "../result/impact.ts";
14
+ import { analyzeReferenceImpact, computeOmittedCount } from "./analysis.ts";
14
15
  import { renderImpactSingle } from "./markdown.ts";
15
16
  import type { ImpactInput } from "./types.ts";
16
17
 
@@ -58,7 +59,7 @@ export async function executeSingleImpact(
58
59
  items: refs.refs,
59
60
  maxResults,
60
61
  }).metadata;
61
- const detailsData = buildDetailsData(
62
+ const detailsData = assembleImpactDetails(
62
63
  analysis,
63
64
  refs.refs.length,
64
65
  computeOmittedCount(analysis.externalRefs, analysis.affectedFiles.size, input.maxResults),
@@ -1,199 +1,21 @@
1
1
  /**
2
- * Unified error-result factories for code-intelligence tool executors.
2
+ * Compatibility export for code-intelligence error result assembly.
3
3
  *
4
- * Every factory returns a complete {@link CodeIntelResult} (content + typed
5
- * details) so executors never need to inline the `{ content, details }`
6
- * wrapper. The old `unavailableXxxDetails()` functions are kept as thin
7
- * wrappers — prefer the combined `xxxErrorResult()` factories in new code.
4
+ * Returned tool errors are assembled behind `src/tool/result/` with the rest
5
+ * of public tool evidence. New tool code should import from
6
+ * `../result/errors.ts` directly.
8
7
  */
9
-
10
- import type {
11
- CodeIntelResult,
12
- ContextDetails,
13
- HealthDetails,
14
- ImpactDetails,
15
- InspectDetails,
16
- ResolveDetails,
17
- SearchDetails,
18
- } from "../../types/index.ts";
19
-
20
- // ── Combined error-result factories (preferred) ──────────────────────
21
-
22
- /** Full error result for search-family tools (code_find, code_graph, code_find, code_refactor_plan). */
23
- export function searchErrorResult(
24
- content: string,
25
- opts?: { scope?: string | null; nextQueries?: string[] },
26
- ): CodeIntelResult {
27
- return {
28
- content,
29
- details: {
30
- type: "search" as const,
31
- data: {
32
- confidence: "unavailable" as const,
33
- scope: opts?.scope ?? null,
34
- candidateCount: 0,
35
- omittedCount: 0,
36
- nextQueries: opts?.nextQueries ?? [],
37
- },
38
- },
39
- };
40
- }
41
-
42
- /** Full error result for code_orientation (context-type details). */
43
- export function contextErrorResult(
44
- content: string,
45
- opts?: { nextQueries?: string[] },
46
- ): CodeIntelResult {
47
- return {
48
- content,
49
- details: {
50
- type: "context" as const,
51
- data: {
52
- confidence: "unavailable" as const,
53
- task: null,
54
- focusTarget: null,
55
- requestedSections: [],
56
- renderedSections: [],
57
- omittedCount: 0,
58
- nextQueries: opts?.nextQueries ?? [],
59
- },
60
- },
61
- };
62
- }
63
-
64
- /** Full error result for code_resolve. */
65
- export function resolveErrorResult(
66
- content: string,
67
- opts?: { nextQueries?: string[] },
68
- ): CodeIntelResult {
69
- return {
70
- content,
71
- details: {
72
- type: "resolve" as const,
73
- data: {
74
- confidence: "unavailable" as const,
75
- targetCount: 0,
76
- omittedCount: 0,
77
- targets: [],
78
- nextQueries: opts?.nextQueries ?? [],
79
- },
80
- },
81
- };
82
- }
83
-
84
- /** Full error result for code_inspect. */
85
- export function inspectErrorResult(
86
- content: string,
87
- opts?: { focusTarget?: string; nextQueries?: string[] },
88
- ): CodeIntelResult {
89
- return {
90
- content,
91
- details: {
92
- type: "inspect" as const,
93
- data: {
94
- confidence: "unavailable" as const,
95
- focusTarget: opts?.focusTarget ?? "",
96
- unavailableSections: [],
97
- nextQueries: opts?.nextQueries ?? [],
98
- },
99
- },
100
- };
101
- }
102
-
103
- /** Full error result for code_impact. */
104
- export function impactErrorResult(
105
- content: string,
106
- opts?: { nextQueries?: string[] },
107
- ): CodeIntelResult {
108
- const data: ImpactDetails = {
109
- confidence: "unavailable",
110
- directCount: 0,
111
- downstreamCount: 0,
112
- riskLevel: "low",
113
- checkNext: [],
114
- likelyTests: [],
115
- likelyTestCommands: [],
116
- omittedCount: 0,
117
- nextQueries: opts?.nextQueries ?? [],
118
- };
119
- return { content, details: { type: "impact" as const, data } };
120
- }
121
-
122
- /** Full error result for code_health. */
123
- export function healthErrorResult(content: string, reason?: string): CodeIntelResult {
124
- return {
125
- content,
126
- details: {
127
- type: "health" as const,
128
- data: {
129
- lspAvailable: false,
130
- lspStatus: reason ?? content,
131
- recovered: false,
132
- diagnosticFileCount: 0,
133
- serverCount: 0,
134
- },
135
- },
136
- };
137
- }
138
-
139
- // ── Details-only helpers (thin wrappers — prefer combined factories above) ─
140
-
141
- export function unavailableSearchDetails(
142
- scope: string | null,
143
- nextQueries: string[],
144
- ): { type: "search"; data: SearchDetails } {
145
- return searchErrorResult("", { scope, nextQueries }).details as {
146
- type: "search";
147
- data: SearchDetails;
148
- };
149
- }
150
-
151
- export function unavailableContextDetails(nextQueries: string[]): {
152
- type: "context";
153
- data: ContextDetails;
154
- } {
155
- return contextErrorResult("", { nextQueries }).details as {
156
- type: "context";
157
- data: ContextDetails;
158
- };
159
- }
160
-
161
- export function unavailableResolveDetails(nextQueries: string[]): {
162
- type: "resolve";
163
- data: ResolveDetails;
164
- } {
165
- return resolveErrorResult("", { nextQueries }).details as {
166
- type: "resolve";
167
- data: ResolveDetails;
168
- };
169
- }
170
-
171
- export function unavailableInspectDetails(
172
- focusTarget: string,
173
- nextQueries: string[],
174
- ): { type: "inspect"; data: InspectDetails } {
175
- return inspectErrorResult("", { focusTarget, nextQueries }).details as {
176
- type: "inspect";
177
- data: InspectDetails;
178
- };
179
- }
180
-
181
- export function unavailableImpactDetails(nextQueries: string[]): {
182
- type: "impact";
183
- data: ImpactDetails;
184
- } {
185
- return impactErrorResult("", { nextQueries }).details as {
186
- type: "impact";
187
- data: ImpactDetails;
188
- };
189
- }
190
-
191
- export function unavailableHealthDetails(reason: string): {
192
- type: "health";
193
- data: HealthDetails;
194
- } {
195
- return healthErrorResult("", reason).details as {
196
- type: "health";
197
- data: HealthDetails;
198
- };
199
- }
8
+ export {
9
+ contextErrorResult,
10
+ healthErrorResult,
11
+ impactErrorResult,
12
+ inspectErrorResult,
13
+ resolveErrorResult,
14
+ searchErrorResult,
15
+ unavailableContextDetails,
16
+ unavailableHealthDetails,
17
+ unavailableImpactDetails,
18
+ unavailableInspectDetails,
19
+ unavailableResolveDetails,
20
+ unavailableSearchDetails,
21
+ } from "../result/errors.ts";
@@ -23,7 +23,7 @@
23
23
 
24
24
  import { match } from "ts-pattern";
25
25
  import { ensureSemanticReadiness } from "../../analysis/readiness.ts";
26
- import { resolveScope } from "../../analysis/search/ripgrep.ts";
26
+ import { resolveScope, resolveScopeSet } from "../../analysis/search/ripgrep.ts";
27
27
  import { routeFor } from "../../analysis/target/planner.ts";
28
28
  import type {
29
29
  CodeIntelligenceToolName,
@@ -150,6 +150,15 @@ export interface HasScopeParam {
150
150
  scope?: string;
151
151
  }
152
152
 
153
+ /** Minimum parameter shape needed by `resolveScopeSetParam`. */
154
+ export interface HasScopeSetParam {
155
+ scope?: string | string[];
156
+ /** Set by resolveScopeSetParam — absolute search roots for code_find. */
157
+ _resolvedScopePaths?: string[];
158
+ /** Set by resolveScopeSetParam — display label for requested search roots. */
159
+ _resolvedScopeDisplay?: string | null;
160
+ }
161
+
153
162
  /**
154
163
  * Resolve the `scope` parameter to an absolute path.
155
164
  *
@@ -175,6 +184,20 @@ export function resolveScopeParam<P extends HasScopeParam>(
175
184
  };
176
185
  }
177
186
 
187
+ /** Resolve code_find's one-or-many `scope` input to absolute search roots. */
188
+ export function resolveScopeSetParam<P extends HasScopeSetParam>(
189
+ onError: (reason: string) => CodeIntelResult,
190
+ ): PipeStage<P> {
191
+ return (params, ctx) => {
192
+ const result = resolveScopeSet(params.scope, ctx.cwd);
193
+ if (result.kind === "error") return { kind: "error", result: onError(result.reason) };
194
+
195
+ params._resolvedScopePaths = [...result.paths];
196
+ params._resolvedScopeDisplay = result.display;
197
+ return { kind: "continue" };
198
+ };
199
+ }
200
+
178
201
  /**
179
202
  * Apply cross-field validation rules after TypeBox schema validation.
180
203
  *
@@ -1,46 +1,9 @@
1
- import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
- import {
3
- type EvidenceListMetadata,
4
- renderEvidenceListMetadataDisclosure,
5
- } from "../../analysis/evidence.ts";
6
-
7
- export interface InspectRenderInput {
8
- relPath: string;
9
- line: number;
10
- character: number;
11
- confidence: ConfidenceMode;
12
- node: {
13
- type: string;
14
- text: string;
15
- startLine: number;
16
- startCharacter: number;
17
- ancestry?: Array<
18
- | string
19
- | {
20
- type: string;
21
- startLine: number;
22
- startCharacter: number;
23
- endLine?: number;
24
- endCharacter?: number;
25
- }
26
- >;
27
- } | null;
28
- enclosingSymbol: {
29
- name: string;
30
- kind: string;
31
- startLine: number;
32
- endLine: number;
33
- } | null;
34
- hover: string | null;
35
- definitions: Array<{ file: string; line: number; character: number }>;
36
- diagnostics: Array<{ line: number; severity: number | string; message: string }>;
37
- codeActions: Array<{ title: string; kind?: string }>;
38
- codeActionEvidence?: EvidenceListMetadata;
39
- unavailableSections: string[];
40
- }
1
+ import { renderEvidenceListMetadataDisclosure } from "../../analysis/evidence.ts";
2
+ import type { InspectResultAssembly } from "../result/inspect.ts";
41
3
 
42
4
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: inspect rendering keeps section ordering and unavailable-state handling explicit
43
- export function renderInspectResult(input: InspectRenderInput): string {
5
+ export function renderInspectResult(assembly: InspectResultAssembly): string {
6
+ const input = assembly.data;
44
7
  const lines: string[] = [];
45
8
  lines.push(`# Inspect: ${input.relPath}:${input.line}:${input.character}`);
46
9
  lines.push("");
@@ -4,6 +4,7 @@ import { createEvidenceList } from "../../analysis/evidence.ts";
4
4
  import { normalizePath } from "../../analysis/search/ripgrep.ts";
5
5
  import { gatherNearbyDiagnostics, gatherTreeSitterContext } from "../../ui/markdown/gather.ts";
6
6
  import type { InspectDeps, InspectInput, InspectUseCaseResult } from "../../ui/markdown/types.ts";
7
+ import { assembleInspectResult } from "../result/inspect.ts";
7
8
  import { renderInspectResult } from "./markdown.ts";
8
9
 
9
10
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: inspect orchestration keeps data gathering and unavailable-section derivation in one place
@@ -89,37 +90,35 @@ export async function executeInspect(
89
90
  });
90
91
 
91
92
  const nextQueries = buildNextQueries(relPath, input.line, input.character, confidence);
92
- const content = renderInspectResult({
93
- relPath,
94
- line: input.line,
95
- character: input.character,
96
- confidence,
97
- node: context.nodeInfo,
98
- enclosingSymbol: enclosing
99
- ? {
100
- name: enclosing.name,
101
- kind: enclosing.kind,
102
- startLine: enclosing.startLine,
103
- endLine: enclosing.endLine,
104
- }
105
- : null,
106
- hover: context.hover?.contents ?? null,
107
- definitions,
108
- diagnostics,
109
- codeActions: codeActions.items,
110
- codeActionEvidence: codeActions.metadata,
111
- unavailableSections: dedupe(unavailableSections),
112
- });
113
-
114
- return {
115
- content,
116
- details: {
93
+ const assembly = assembleInspectResult(
94
+ {
95
+ relPath,
96
+ line: input.line,
97
+ character: input.character,
117
98
  confidence,
118
- focusTarget: `${relPath}:${input.line}:${input.character}`,
99
+ node: context.nodeInfo,
100
+ enclosingSymbol: enclosing
101
+ ? {
102
+ name: enclosing.name,
103
+ kind: enclosing.kind,
104
+ startLine: enclosing.startLine,
105
+ endLine: enclosing.endLine,
106
+ }
107
+ : null,
108
+ hover: context.hover?.contents ?? null,
109
+ definitions,
110
+ diagnostics,
111
+ codeActions: codeActions.items,
112
+ codeActionEvidence: codeActions.metadata,
119
113
  unavailableSections: dedupe(unavailableSections),
120
- evidenceLists: [codeActions.metadata],
121
- nextQueries,
122
114
  },
115
+ nextQueries,
116
+ );
117
+ const content = renderInspectResult(assembly);
118
+
119
+ return {
120
+ content,
121
+ details: assembly.details,
123
122
  };
124
123
  }
125
124