@mrclrchtr/supi-code-intelligence 11.2.0 → 11.4.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 (145) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +19 -9
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  7. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  8. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  9. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  11. package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/README.md +40 -3
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
  26. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  27. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
  28. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
  29. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +151 -44
  32. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
  34. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
  36. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +318 -58
  37. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
  39. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +68 -6
  40. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  48. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +9 -1
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +9 -1
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
  58. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
  59. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
  60. package/package.json +6 -5
  61. package/src/analysis/health/server-status.ts +6 -2
  62. package/src/analysis/helpers.ts +0 -7
  63. package/src/analysis/relations/implementations.ts +5 -0
  64. package/src/analysis/relations/references.ts +5 -0
  65. package/src/analysis/search/exclusions.ts +47 -0
  66. package/src/analysis/search/paths.ts +32 -9
  67. package/src/analysis/target/anchored-structural.ts +3 -8
  68. package/src/analysis/target/anchored.ts +4 -20
  69. package/src/analysis/target/file-merge.ts +162 -0
  70. package/src/analysis/target/file-outline-omissions.ts +146 -0
  71. package/src/analysis/target/file-refinement.ts +7 -7
  72. package/src/analysis/target/file.ts +44 -156
  73. package/src/analysis/target/identity.ts +1 -1
  74. package/src/analysis/target/latex-label-container.ts +6 -6
  75. package/src/analysis/target/latex-section-anchor.ts +6 -6
  76. package/src/analysis/target/resolution.ts +18 -0
  77. package/src/analysis/target/symbol.ts +44 -12
  78. package/src/analysis/target/types.ts +38 -7
  79. package/src/api.ts +1 -1
  80. package/src/app/app.ts +9 -3
  81. package/src/extension.ts +17 -11
  82. package/src/session/graph/collect.ts +3 -10
  83. package/src/session/graph-types.ts +5 -1
  84. package/src/session/graph-workflow.ts +6 -4
  85. package/src/session/inspect/collect.ts +8 -2
  86. package/src/session/inspect/file-point.ts +2 -3
  87. package/src/session/inspect-workflow.ts +1 -1
  88. package/src/session/orientation/collect.ts +54 -16
  89. package/src/session/orientation/context-sections.ts +2 -3
  90. package/src/session/orientation/facts.ts +9 -1
  91. package/src/session/orientation/workspace-context.ts +3 -0
  92. package/src/session/orientation-types.ts +3 -0
  93. package/src/session/orientation-workflow.ts +24 -8
  94. package/src/session/refactor-identity.ts +76 -0
  95. package/src/session/refactor-workflow.ts +14 -16
  96. package/src/session/session.ts +87 -12
  97. package/src/session/target-store.ts +3 -18
  98. package/src/session/target-workflow.ts +56 -37
  99. package/src/substrate/lsp/recovery.ts +5 -5
  100. package/src/tool/code_find/render.ts +8 -4
  101. package/src/tool/code_find/result.ts +78 -6
  102. package/src/tool/code_find/spec.ts +4 -3
  103. package/src/tool/code_find/structured.ts +25 -9
  104. package/src/tool/code_graph/details.ts +1 -0
  105. package/src/tool/code_graph/display.ts +1 -1
  106. package/src/tool/code_graph/guidance.ts +1 -1
  107. package/src/tool/code_graph/markdown.ts +11 -6
  108. package/src/tool/code_graph/read-next.ts +38 -9
  109. package/src/tool/code_graph/reference-selection.ts +30 -0
  110. package/src/tool/code_graph/result.ts +25 -118
  111. package/src/tool/code_graph/section.ts +137 -0
  112. package/src/tool/code_graph/spec.ts +3 -3
  113. package/src/tool/code_graph/structured.ts +17 -6
  114. package/src/tool/code_health/display-paths.ts +92 -0
  115. package/src/tool/code_health/file-scope-markdown.ts +3 -2
  116. package/src/tool/code_health/result.ts +4 -2
  117. package/src/tool/code_health/spec.ts +3 -3
  118. package/src/tool/code_health/structured-schema.ts +44 -44
  119. package/src/tool/code_inspect/spec.ts +5 -1
  120. package/src/tool/code_inspect/structured.ts +1 -2
  121. package/src/tool/code_orientation/directory-navigation.ts +20 -31
  122. package/src/tool/code_orientation/execute.ts +1 -1
  123. package/src/tool/code_orientation/result.ts +22 -5
  124. package/src/tool/code_orientation/structured-schema.ts +46 -36
  125. package/src/tool/code_orientation/structured-workspace.ts +2 -1
  126. package/src/tool/code_orientation/structured.ts +6 -12
  127. package/src/tool/code_orientation/workspace-format.ts +2 -5
  128. package/src/tool/code_orientation/workspace-output.ts +40 -13
  129. package/src/tool/code_orientation/workspace-sections.ts +48 -4
  130. package/src/tool/code_refactor_apply/result.ts +1 -1
  131. package/src/tool/code_refactor_plan/result.ts +2 -1
  132. package/src/tool/code_refactor_plan/structured.ts +2 -3
  133. package/src/tool/code_resolve/guidance.ts +1 -1
  134. package/src/tool/code_resolve/markdown.ts +127 -64
  135. package/src/tool/code_resolve/result.ts +41 -25
  136. package/src/tool/code_resolve/structured.ts +49 -18
  137. package/src/tool/result/model-budget.ts +2 -2
  138. package/src/tool/result/refactor.ts +8 -5
  139. package/src/tool/result/structured.ts +8 -5
  140. package/src/tool/result/types.ts +31 -24
  141. package/src/tool/schemas.ts +5 -5
  142. package/src/ui/status-command.ts +37 -1
  143. package/src/ui/status-overlay.ts +70 -51
  144. package/src/ui/status-presentation.ts +108 -0
  145. package/src/ui/tui/common.ts +10 -10
@@ -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
- * This is the canonical post-registration target type — all tool layers
35
- * (executors, renderers, details) use it directly. Computed fields like
36
- * relative paths are derived at the rendering boundary.
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
 
@@ -10,18 +10,19 @@ import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
10
10
  import { withSemanticRequestControl, withStructuralRequestControl } from "../analysis/provider.ts";
11
11
  import { normalizePath, resolveScope } from "../analysis/search/paths.ts";
12
12
  import { resolveAnchoredSymbolTarget } from "../analysis/target/anchored.ts";
13
- import { resolveFileTargetGroup, validateFileTargetDiscovery } from "../analysis/target/file.ts";
13
+ import { resolveFileOutline, validateFileTargetDiscovery } from "../analysis/target/file.ts";
14
14
  import {
15
15
  canonicalDeclarationKind,
16
16
  refineTargetOutcomeIdentity,
17
17
  } from "../analysis/target/identity.ts";
18
18
  import { resolveSymbolTarget } from "../analysis/target/symbol.ts";
19
19
  import type {
20
+ FileOutlineData,
20
21
  ResolvedTargetData,
21
- ResolvedTargetGroupData,
22
22
  TargetCandidateCompleteness,
23
23
  TargetOutcome,
24
24
  } from "../analysis/target/types.ts";
25
+ import type { AnchoredResolutionMetadata } from "../types/index.ts";
25
26
  import type { CapabilityAdapter } from "./capability-adapter.ts";
26
27
  import { parseTargetInput } from "./input/common.ts";
27
28
  import { resolveWorkspaceSemanticDemand } from "./semantic-demand.ts";
@@ -49,17 +50,24 @@ export interface TargetWorkflowPolicy {
49
50
 
50
51
  /** Typed Target workflow outcome. */
51
52
  export type TargetWorkflowOutcome =
52
- | { kind: "resolved"; entry: Readonly<TargetStoreEntry>; notes: readonly string[] }
53
53
  | {
54
- kind: "target-group";
54
+ kind: "resolved";
55
+ entry: Readonly<TargetStoreEntry>;
56
+ /** Immutable observation of this anchored request, never stored with the target. */
57
+ readonly resolution?: AnchoredResolutionMetadata;
58
+ notes: readonly string[];
59
+ }
60
+ | {
61
+ kind: "file-outline";
55
62
  file: string;
56
63
  confidence: ResolvedTargetData["confidence"];
57
- discoveryProvenance: ResolvedTargetGroupData["discoveryProvenance"];
64
+ discoveryProvenance: FileOutlineData["discoveryProvenance"];
58
65
  targets: ReadonlyArray<Readonly<TargetStoreEntry>>;
59
66
  totalCount: number;
60
67
  omittedCount: number;
61
- unknownNestingCount: number;
62
- partial?: ResolvedTargetGroupData["partial"];
68
+ unknownLevelCount: number;
69
+ partial?: FileOutlineData["partial"];
70
+ notListed: FileOutlineData["notListed"];
63
71
  }
64
72
  | ({
65
73
  kind: "disambiguation";
@@ -259,7 +267,7 @@ async function resolveFileOnlyWorkflow(
259
267
  return { kind: "unavailable", reason: readiness.reason };
260
268
  }
261
269
 
262
- const result = await resolveFileTargetGroup(
270
+ const result = await resolveFileOutline(
263
271
  file,
264
272
  deps.cwd,
265
273
  {
@@ -277,7 +285,7 @@ async function resolveFileOnlyWorkflow(
277
285
  return { kind: "unavailable", reason: result.message };
278
286
  }
279
287
 
280
- return registerTargetGroup(result.group, deps, maxResults);
288
+ return registerFileOutline(result.outline, deps, maxResults);
281
289
  }
282
290
 
283
291
  function toWorkflowOutcome(
@@ -301,15 +309,17 @@ function toWorkflowOutcome(
301
309
  };
302
310
  }
303
311
  const registered = registerFromTargetData(outcome.target, deps);
312
+ const resolution = immutableResolution(outcome.target.resolution);
304
313
  return {
305
314
  kind: "resolved",
306
315
  entry: immutableEntry(registered.entry),
307
- notes: buildResolutionNotes(outcome.target),
316
+ ...(resolution ? { resolution } : {}),
317
+ notes: [...buildResolutionNotes(resolution), ...(outcome.notes ?? [])],
308
318
  };
309
319
  }
310
320
 
311
- if (outcome.kind === "group") {
312
- return registerTargetGroup(outcome.group, deps, policy.maxResults ?? 10);
321
+ if (outcome.kind === "file-outline") {
322
+ return registerFileOutline(outcome.outline, deps, policy.maxResults ?? 10);
313
323
  }
314
324
 
315
325
  const candidates = registerTargetCandidates(outcome.candidates, deps.registerTarget);
@@ -333,40 +343,44 @@ function toWorkflowOutcome(
333
343
  };
334
344
  }
335
345
 
336
- function registerTargetGroup(
337
- group: ResolvedTargetGroupData,
346
+ function registerFileOutline(
347
+ outline: FileOutlineData,
338
348
  deps: TargetWorkflowDeps,
339
349
  maxResults: number,
340
350
  ): TargetWorkflowOutcome {
341
- const totalCount = group.targets.length;
342
- const visibleTargets = group.targets.slice(0, Math.max(0, maxResults));
343
- const fingerprint = computeFileFingerprint(group.file);
351
+ const totalCount = outline.targets.length;
352
+ const visibleTargets = outline.targets.slice(0, Math.max(0, maxResults));
353
+ const fingerprint = computeFileFingerprint(outline.file);
344
354
  const fileFingerprint = fingerprint.kind === "ok" ? fingerprint.fingerprint : "unfingerprinted";
345
355
  const targets = visibleTargets.map((target) =>
346
356
  immutableEntry(registerFromTargetData(target, deps, fileFingerprint).entry),
347
357
  );
348
358
  return Object.freeze({
349
- kind: "target-group",
350
- file: group.file,
351
- confidence: group.confidence,
352
- discoveryProvenance: Object.freeze([...group.discoveryProvenance]),
359
+ kind: "file-outline",
360
+ file: outline.file,
361
+ confidence: outline.confidence,
362
+ discoveryProvenance: Object.freeze([...outline.discoveryProvenance]),
353
363
  targets: Object.freeze(targets),
354
364
  totalCount,
355
365
  omittedCount: totalCount - targets.length,
356
- unknownNestingCount: group.unknownNestingCount,
357
- ...(group.partial ? { partial: group.partial } : {}),
366
+ unknownLevelCount: outline.unknownLevelCount,
367
+ ...(outline.partial ? { partial: outline.partial } : {}),
368
+ notListed: outline.notListed,
358
369
  });
359
370
  }
360
371
 
361
- function buildResolutionNotes(target: ResolvedTargetData): readonly string[] {
372
+ function buildResolutionNotes(
373
+ resolution: AnchoredResolutionMetadata | undefined,
374
+ ): readonly string[] {
362
375
  const notes: string[] = [];
363
- if (target.resolution?.snapped) {
376
+ if (resolution?.snapped) {
377
+ const requested = `${resolution.requested.line}:${resolution.requested.character}`;
378
+ const resolved = `${resolution.resolved.line}:${resolution.resolved.character}`;
364
379
  notes.push(
365
- `Resolved from a declaration header and snapped to the identifier (${target.resolution.source}).`,
380
+ `Requested coordinate snapped from ${requested} to name anchor ${resolved} (evidence: ${resolution.source}).`,
366
381
  );
367
- }
368
- if (target.resolution?.source === "structural-identifier") {
369
- notes.push("Resolved from provider-backed structural identifier evidence.");
382
+ } else if (resolution && resolution.source !== "semantic") {
383
+ notes.push(`Resolved from ${resolution.source} evidence.`);
370
384
  }
371
385
  return Object.freeze(notes);
372
386
  }
@@ -394,7 +408,6 @@ function registerFromTargetData(
394
408
  provenance: target.provenance,
395
409
  anchorKind: target.anchorKind,
396
410
  container: target.container,
397
- resolution: target.resolution,
398
411
  fileFingerprint,
399
412
  });
400
413
  }
@@ -407,12 +420,18 @@ function immutableEntry(entry: TargetStoreEntry): Readonly<TargetStoreEntry> {
407
420
  declarationPosition: entry.declarationPosition
408
421
  ? Object.freeze({ ...entry.declarationPosition })
409
422
  : entry.declarationPosition,
410
- resolution: entry.resolution
411
- ? Object.freeze({
412
- ...entry.resolution,
413
- requested: Object.freeze({ ...entry.resolution.requested }),
414
- resolved: Object.freeze({ ...entry.resolution.resolved }),
415
- })
416
- : undefined,
417
423
  });
418
424
  }
425
+
426
+ /** Keep the current request observation independent of provider and target-store state. */
427
+ function immutableResolution(
428
+ resolution: AnchoredResolutionMetadata | undefined,
429
+ ): AnchoredResolutionMetadata | undefined {
430
+ return resolution
431
+ ? Object.freeze({
432
+ ...resolution,
433
+ requested: Object.freeze({ ...resolution.requested }),
434
+ resolved: Object.freeze({ ...resolution.resolved }),
435
+ })
436
+ : undefined;
437
+ }
@@ -62,16 +62,16 @@ function getFilePathFromToolResult(event: ToolResultEvent): string | null {
62
62
  return pathValue;
63
63
  }
64
64
 
65
- /** Extract changed file paths emitted by a successful code_refactor_apply result. */
65
+ /** Extract original document identities, never display paths, from a successful Apply. */
66
66
  function getRefactorApplyPaths(event: ToolResultEvent): string[] {
67
67
  const details = (event as { details?: unknown }).details as
68
- | { data?: { changedFiles?: unknown } }
68
+ | { data?: { recoveryFiles?: unknown } }
69
69
  | undefined;
70
- const changedFiles = details?.data?.changedFiles;
71
- if (!Array.isArray(changedFiles)) return [];
70
+ const recoveryFiles = details?.data?.recoveryFiles;
71
+ if (!Array.isArray(recoveryFiles)) return [];
72
72
  return [
73
73
  ...new Set(
74
- changedFiles.filter((file): file is string => typeof file === "string" && file.length > 0),
74
+ recoveryFiles.filter((file): file is string => typeof file === "string" && file.length > 0),
75
75
  ),
76
76
  ];
77
77
  }
@@ -4,6 +4,10 @@ import {
4
4
  type EvidenceListMetadata,
5
5
  renderEvidenceListMetadataDisclosure,
6
6
  } from "../../analysis/evidence.ts";
7
+ import {
8
+ type AutomaticPathExclusionDisplay,
9
+ describeExcludedPath,
10
+ } from "../../analysis/search/exclusions.ts";
7
11
  import { renderStructuredEmptyState, renderStructuredMatches } from "./markdown.ts";
8
12
  import type { FindResultAssembly } from "./result.ts";
9
13
 
@@ -52,19 +56,19 @@ function renderSemantic(assembly: FindResultAssembly, evidence: EvidenceListMeta
52
56
  const disclosure = renderEvidenceListMetadataDisclosure(evidence);
53
57
  if (disclosure) lines.push(disclosure);
54
58
  const exclusionDisclosure = renderAutomaticPathExclusionDisclosure(
55
- outcome.data.partialMetadata?.automaticPathExclusion,
59
+ assembly.details.automaticPathExclusion,
56
60
  );
57
61
  if (exclusionDisclosure) lines.push(exclusionDisclosure);
58
62
  return lines.join("\n");
59
63
  }
60
64
 
61
65
  function renderAutomaticPathExclusionDisclosure(
62
- exclusion: { readonly excludedCount: number; readonly examples: readonly string[] } | undefined,
66
+ exclusion: AutomaticPathExclusionDisplay | undefined,
63
67
  ): string | null {
64
68
  if (!exclusion || exclusion.excludedCount <= 0) return null;
65
69
  const noun = `workspace-symbol result${exclusion.excludedCount === 1 ? "" : "s"}`;
66
70
  const examples = exclusion.examples.length
67
- ? ` Examples: ${exclusion.examples.map((file) => `\`${file}\``).join(", ")}.`
71
+ ? ` Excluded path examples: ${exclusion.examples.map(describeExcludedPath).join(", ")}.`
68
72
  : "";
69
73
  return `_Automatic path policy excluded ${exclusion.excludedCount} ${noun}.${examples}_`;
70
74
  }
@@ -82,7 +86,7 @@ function renderEmptySemantic(assembly: FindResultAssembly, evidence: EvidenceLis
82
86
  const disclosure = renderEvidenceListMetadataDisclosure(evidence);
83
87
  if (disclosure) lines.push("", disclosure);
84
88
  const exclusionDisclosure = renderAutomaticPathExclusionDisclosure(
85
- outcome.data.partialMetadata?.automaticPathExclusion,
89
+ assembly.details.automaticPathExclusion,
86
90
  );
87
91
  if (exclusionDisclosure) lines.push("", exclusionDisclosure);
88
92
  lines.push("", "Document-level semantic symbols can differ from the workspace index.");
@@ -4,6 +4,12 @@ import {
4
4
  createPartialEvidenceList,
5
5
  type EvidenceListMetadata,
6
6
  } from "../../analysis/evidence.ts";
7
+ import {
8
+ describeExcludedPath,
9
+ describePartialQuery,
10
+ displayAutomaticPathExclusion,
11
+ } from "../../analysis/search/exclusions.ts";
12
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
7
13
  import type { FindMode, FindWorkflowOutcome } from "../../session/find-types.ts";
8
14
  import {
9
15
  assembledNextQueries,
@@ -24,8 +30,14 @@ export interface FindResultAssembly {
24
30
 
25
31
  /** Assemble one completed code-aware search outcome before presentation. */
26
32
  export function assembleFindWorkflowResult(
27
- outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>,
33
+ input: Extract<FindWorkflowOutcome, { kind: "completed" }>,
34
+ cwd: string,
28
35
  ): FindResultAssembly {
36
+ const outcome = withDisplayPaths(input, cwd);
37
+ const exclusion =
38
+ outcome.data.kind === "semantic"
39
+ ? displayAutomaticPathExclusion(outcome.data.partialMetadata?.automaticPathExclusion, cwd)
40
+ : undefined;
29
41
  const evidence = createFindEvidence(outcome);
30
42
  const confidence: ConfidenceMode = outcome.data.kind === "semantic" ? "semantic" : "structural";
31
43
  const nextQueries = findNextQueries(outcome);
@@ -61,6 +73,19 @@ export function assembleFindWorkflowResult(
61
73
  }),
62
74
  ];
63
75
 
76
+ if (exclusion?.examples.length) {
77
+ displaySections.push(
78
+ createToolDisplaySection({
79
+ key: "find.excludedPaths",
80
+ title: "Excluded path examples",
81
+ items: exclusion.examples,
82
+ totalCount: exclusion.examples.length,
83
+ omittedCount: 0,
84
+ format: describeExcludedPath,
85
+ }),
86
+ );
87
+ }
88
+
64
89
  return {
65
90
  outcome,
66
91
  assembled,
@@ -79,9 +104,52 @@ export function assembleFindWorkflowResult(
79
104
  structuralFailures: [...outcome.data.result.failures],
80
105
  }
81
106
  : {}),
82
- ...(outcome.data.kind === "semantic" && outcome.data.partialMetadata?.automaticPathExclusion
83
- ? { automaticPathExclusion: outcome.data.partialMetadata.automaticPathExclusion }
84
- : {}),
107
+ ...(exclusion ? { automaticPathExclusion: exclusion } : {}),
108
+ },
109
+ };
110
+ }
111
+
112
+ /** Clone source-path projections for all output adapters without changing workflow facts. */
113
+ function withDisplayPaths(
114
+ outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>,
115
+ cwd: string,
116
+ ): Extract<FindWorkflowOutcome, { kind: "completed" }> {
117
+ const display = (file: string) => toDisplayPath(cwd, file);
118
+ const { data } = outcome;
119
+ if (data.kind === "semantic") {
120
+ return {
121
+ ...outcome,
122
+ data: {
123
+ ...data,
124
+ symbols: data.symbols.map((symbol) => ({ ...symbol, file: display(symbol.file) })),
125
+ partialReason: data.partialReason
126
+ ? describePartialQuery(data.partialReason, data.partialMetadata, cwd)
127
+ : null,
128
+ },
129
+ };
130
+ }
131
+ const { result } = data;
132
+ return {
133
+ ...outcome,
134
+ data: {
135
+ ...data,
136
+ result: {
137
+ ...result,
138
+ matches: result.matches.map((match) => ({ ...match, file: display(match.file) })),
139
+ failures: result.failures.map((failure) => ({ ...failure, file: display(failure.file) })),
140
+ scan: {
141
+ ...result.scan,
142
+ roots: result.scan.roots.map(display),
143
+ exclusions: result.scan.exclusions.map((entry) => ({
144
+ ...entry,
145
+ examples: entry.examples.map(display),
146
+ })),
147
+ limitations: result.scan.limitations.map((entry) => ({
148
+ ...entry,
149
+ examples: entry.examples.map(display),
150
+ })),
151
+ },
152
+ },
85
153
  },
86
154
  };
87
155
  }
@@ -105,7 +173,11 @@ function createFindEvidence(outcome: Extract<FindWorkflowOutcome, { kind: "compl
105
173
  items: [...outcome.data.symbols],
106
174
  maxResults: outcome.maxResults,
107
175
  };
108
- const evidence = outcome.data.partialReason
176
+ // Exclusion-only results counted every in-policy row; the separate
177
+ // exclusion disclosure still reports the dropped paths.
178
+ const providerLimited =
179
+ outcome.data.partialReason !== null && outcome.data.partialMetadata?.exclusionOnly !== true;
180
+ const evidence = providerLimited
109
181
  ? createPartialEvidenceList({ ...params, partialReason: "provider-limited" })
110
182
  : createEvidenceList(params);
111
183
  return { total: outcome.data.symbols.length, metadata: evidence.metadata };
@@ -207,7 +279,7 @@ export function finishFindResult(
207
279
  };
208
280
  }
209
281
 
210
- const assembly = assembleFindWorkflowResult(outcome);
282
+ const assembly = assembleFindWorkflowResult(outcome, cwd);
211
283
  return {
212
284
  content: renderFindResult(assembly),
213
285
  structuredContent: structuredFindResult(assembly, cwd),
@@ -1,4 +1,3 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
1
  import { Type } from "typebox";
3
2
  import type { CodeIntelToolExecCtx } from "../../types/index.ts";
4
3
  import { FindQueryParam, FindScopeParam, MaxResultsParam } from "../schemas.ts";
@@ -20,12 +19,14 @@ export const codeFindSpec = {
20
19
  {
21
20
  query: FindQueryParam,
22
21
  scope: Type.Optional(FindScopeParam),
23
- mode: StringEnum(CODE_FIND_MODES, {
22
+ mode: Type.Enum(CODE_FIND_MODES, {
23
+ type: "string",
24
24
  description:
25
25
  "Required code-aware search mode. AST mode requires `kind`; semantic mode rejects `kind`.",
26
26
  }),
27
27
  kind: Type.Optional(
28
- StringEnum(CODE_FIND_AST_KINDS, {
28
+ Type.Enum(CODE_FIND_AST_KINDS, {
29
+ type: "string",
29
30
  description: 'AST structure kind; required only for mode:"ast".',
30
31
  }),
31
32
  ),
@@ -1,4 +1,3 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
1
  import { type Static, Type } from "typebox";
3
2
  import { toDisplayPath } from "../../analysis/search/paths.ts";
4
3
  import { ConfidenceSchema, EvidenceListSchema, RecoveryRangeSchema } from "../result/structured.ts";
@@ -13,8 +12,8 @@ const ScanPathSummary = Type.Object({
13
12
  /** Codemode search evidence, including scan-universe limits independently of match counts. */
14
13
  export const FindOutputSchema = Type.Object(
15
14
  {
16
- kind: StringEnum(["completed", "invalid-input"]),
17
- mode: Type.Optional(StringEnum(["semantic", "ast"])),
15
+ kind: Type.Enum(["completed", "invalid-input"], { type: "string" }),
16
+ mode: Type.Optional(Type.Enum(["semantic", "ast"], { type: "string" })),
18
17
  confidence: ConfidenceSchema,
19
18
  matches: Type.Array(
20
19
  Type.Object(
@@ -26,7 +25,7 @@ export const FindOutputSchema = Type.Object(
26
25
  character: Type.Integer(),
27
26
  endLine: Type.Optional(Type.Integer()),
28
27
  endCharacter: Type.Optional(Type.Integer()),
29
- anchorKind: Type.Optional(StringEnum(["name", "declaration"])),
28
+ anchorKind: Type.Optional(Type.Enum(["name", "declaration"], { type: "string" })),
30
29
  container: Type.Optional(Type.Union([Type.String(), Type.Null()])),
31
30
  },
32
31
  { additionalProperties: false },
@@ -35,9 +34,25 @@ export const FindOutputSchema = Type.Object(
35
34
  evidenceLists: Type.Array(EvidenceListSchema),
36
35
  nextQueries: Type.Array(Type.String()),
37
36
  message: Type.Optional(Type.String()),
38
- partialReason: Type.Optional(Type.Union([Type.String(), Type.Null()])),
37
+ partialReason: Type.Optional(
38
+ Type.Union([Type.String(), Type.Null()], {
39
+ description:
40
+ "Why semantic results may be incomplete; null when complete. Policy exclusions alone are reported in automaticPathExclusion, not here.",
41
+ }),
42
+ ),
39
43
  automaticPathExclusion: Type.Optional(
40
- Type.Object({ excludedCount: Type.Integer(), examples: Type.Array(Type.String()) }),
44
+ Type.Object({
45
+ excludedCount: Type.Integer(),
46
+ examples: Type.Array(
47
+ Type.Object({
48
+ observedPath: Type.String({
49
+ description:
50
+ "Original path observed by the exclusion policy, not a canonical navigation path.",
51
+ }),
52
+ canonicalPath: Type.String({ description: "Canonical source navigation path." }),
53
+ }),
54
+ ),
55
+ }),
41
56
  ),
42
57
  scan: Type.Optional(
43
58
  Type.Object({
@@ -93,7 +108,7 @@ export function structuredFindResult(
93
108
  nextQueries: assembly.details.nextQueries,
94
109
  };
95
110
  if (data.kind === "semantic") {
96
- const exclusion = data.partialMetadata?.automaticPathExclusion;
111
+ const exclusion = assembly.details.automaticPathExclusion;
97
112
  return {
98
113
  ...base,
99
114
  matches: data.symbols.slice(0, shown).map((symbol) => {
@@ -108,12 +123,13 @@ export function structuredFindResult(
108
123
  container: symbol.container ?? null,
109
124
  };
110
125
  }),
111
- partialReason: data.partialReason,
126
+ // Exclusion-only evidence is complete; automaticPathExclusion carries it.
127
+ partialReason: data.partialMetadata?.exclusionOnly === true ? null : data.partialReason,
112
128
  ...(exclusion
113
129
  ? {
114
130
  automaticPathExclusion: {
115
131
  excludedCount: exclusion.excludedCount,
116
- examples: [...exclusion.examples],
132
+ examples: exclusion.examples.map((example) => ({ ...example })),
117
133
  },
118
134
  }
119
135
  : {}),
@@ -14,6 +14,7 @@ export interface GraphFileGroup {
14
14
  export interface GraphSectionDetails {
15
15
  rel: GraphRelationKind;
16
16
  source: "semantic" | "structural";
17
+ /** Collection completeness; display caps are disclosed by the evidence-list counts. */
17
18
  status: "complete" | "partial" | "unavailable";
18
19
  message: string | null;
19
20
  externalCount: number;
@@ -4,7 +4,7 @@ import { createToolDisplaySection } from "../result/display.ts";
4
4
  import type { ToolDisplaySection } from "../result/types.ts";
5
5
  import type { GraphFileGroup } from "./details.ts";
6
6
  import { compactGraphLabel } from "./format.ts";
7
- import type { AssembledGraphSection } from "./result.ts";
7
+ import type { AssembledGraphSection } from "./section.ts";
8
8
 
9
9
  /** Bound sites before grouping them. Each file group partitions the display rows. */
10
10
  export function graphDisplaySection(
@@ -1,5 +1,5 @@
1
1
  export const toolDescription =
2
- "Find semantic references and implementations, or non-symbol-aware structural calls written inside a target's enclosing scope.";
2
+ "Find semantic references and implementations, or non-symbol-aware structural calls written inside a target's enclosing scope. To find relationships for a known symbol or source position, pass it directly as the target.";
3
3
 
4
4
  export const promptSnippet = "trace code relationships";
5
5
 
@@ -10,7 +10,8 @@ import {
10
10
  formatGraphRange,
11
11
  graphCodeSpan,
12
12
  } from "./format.ts";
13
- import type { AssembledGraphSection, GraphResultAssembly } from "./result.ts";
13
+ import type { GraphResultAssembly } from "./result.ts";
14
+ import type { AssembledGraphSection } from "./section.ts";
14
15
 
15
16
  /** Render one target and one summary per requested relation. */
16
17
  export function renderGraphResult(assembly: GraphResultAssembly): string {
@@ -18,6 +19,7 @@ export function renderGraphResult(assembly: GraphResultAssembly): string {
18
19
  `Target: ${graphCodeSpan(assembly.displayName)} — ${graphCodeSpan(assembly.resolvedDisplayFile)}`,
19
20
  "",
20
21
  ];
22
+ for (const note of assembly.notes) lines.push(`_Note: ${note}_`, "");
21
23
  for (const section of assembly.sections) lines.push(...renderSection(section, assembly), "");
22
24
  lines.push(...renderReadNextSection(assembledReadNext(assembly.assembled)));
23
25
  return lines.join("\n");
@@ -28,12 +30,15 @@ function renderSection(section: AssembledGraphSection, assembly: GraphResultAsse
28
30
  const depth = section.kind === "ok" && section.rel === "callees" ? `, ${section.data.depth}` : "";
29
31
  const lines = [`## ${section.rel} (${source}${depth})`];
30
32
  if (section.kind === "unavailable") return [...lines, `Unavailable — ${section.message}`];
33
+ const summary = formatGraphEvidence(
34
+ section.evidence.metadata,
35
+ section.rel === "callees" ? "call sites" : "locations",
36
+ section.rel === "callees" ? 0 : section.data.externalCount,
37
+ );
31
38
  lines.push(
32
- formatGraphEvidence(
33
- section.evidence.metadata,
34
- section.rel === "callees" ? "call sites" : "locations",
35
- section.rel === "callees" ? 0 : section.data.externalCount,
36
- ),
39
+ section.rel === "references" && section.selectionNote
40
+ ? `${summary} — ${section.selectionNote}`
41
+ : summary,
37
42
  "",
38
43
  );
39
44
  if (section.rel !== "callees") return [...lines, ...formatLocations(section, assembly.cwd)];