@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
@@ -1,8 +1,12 @@
1
- import { type ReadNextItem, readNextRange } from "../../analysis/read-next.ts";
2
- import type { GraphSection } from "../../session/graph-types.ts";
1
+ import { type ReadNextItem, readNextRange, readNextTopSites } from "../../analysis/read-next.ts";
2
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
3
+ import type { AssembledGraphSection } from "./section.ts";
3
4
 
4
5
  /** Prefer the known enclosing scope, then alternate relation sites before the display cap. */
5
- export function graphReadNext(sections: readonly GraphSection[]): ReadNextItem[] {
6
+ export function graphReadNext(
7
+ sections: readonly AssembledGraphSection[],
8
+ cwd: string,
9
+ ): ReadNextItem[] {
6
10
  const calls = sections.find((section) => section.kind === "ok" && section.rel === "callees");
7
11
  const scopeReads =
8
12
  calls?.kind === "ok"
@@ -10,12 +14,11 @@ export function graphReadNext(sections: readonly GraphSection[]): ReadNextItem[]
10
14
  : [];
11
15
  const queues = sections.flatMap((section) => {
12
16
  if (section.kind !== "ok" || section.rel === "callees") return [];
13
- // Reference collection puts the approximate target range first. The known scope replaces it.
14
- return [
15
- section.rel === "references" && scopeReads.length > 0
16
- ? section.readNext.slice(1)
17
- : section.readNext,
18
- ];
17
+ if (section.rel !== "references") return [section.readNext];
18
+ // Collection supplies the target range; reference sites come only from selected evidence.
19
+ const target = section.readNext[0];
20
+ const sites = referenceReadNext(section, cwd, scopeReads[0]?.file ?? target?.file);
21
+ return [scopeReads.length > 0 || !target ? sites : [target, ...sites]];
19
22
  });
20
23
  const candidates = [...scopeReads];
21
24
  const maxLength = Math.max(0, ...queues.map((queue) => queue.length));
@@ -30,6 +33,32 @@ export function graphReadNext(sections: readonly GraphSection[]): ReadNextItem[]
30
33
  .map((item) => readNextRange(item));
31
34
  }
32
35
 
36
+ /** Prefer new files, then the target file, before filling remaining slots with repeated files. */
37
+ function referenceReadNext(
38
+ section: Extract<AssembledGraphSection, { kind: "ok"; rel: "references" }>,
39
+ cwd: string,
40
+ targetFile: string | undefined,
41
+ ): ReadNextItem[] {
42
+ const sites = section.evidence.items.map((site) => ({
43
+ file: toDisplayPath(cwd, site.file),
44
+ line: site.line,
45
+ }));
46
+ const firstByFile = new Map<string, (typeof sites)[number]>();
47
+ for (const site of sites) {
48
+ if (!firstByFile.has(site.file)) firstByFile.set(site.file, site);
49
+ }
50
+ const distinct = [...firstByFile.values()];
51
+ return readNextTopSites(
52
+ [
53
+ ...distinct.filter((site) => site.file !== targetFile),
54
+ ...distinct.filter((site) => site.file === targetFile),
55
+ ...sites.filter((site) => firstByFile.get(site.file) !== site),
56
+ ],
57
+ 2,
58
+ "reference",
59
+ );
60
+ }
61
+
33
62
  /** Merge connected ranges before bounding them, including ranges that bridge two earlier reads. */
34
63
  function mergeRanges(items: readonly ReadNextItem[]): ReadNextItem[] {
35
64
  const result: ReadNextItem[] = [];
@@ -0,0 +1,30 @@
1
+ import type { ReferenceEntry } from "../../analysis/relations/types.ts";
2
+
3
+ /**
4
+ * Select one site per file per round from normalized, file/source-ordered references.
5
+ * Preserve that order for display; callers retain completeness from the full collected list.
6
+ */
7
+ export function selectReferenceLocations(
8
+ references: readonly ReferenceEntry[],
9
+ limit: number,
10
+ ): ReferenceEntry[] {
11
+ if (references.length <= limit) return [...references];
12
+ const byFile = new Map<string, number[]>();
13
+ for (const [index, reference] of references.entries()) {
14
+ const indices = byFile.get(reference.file) ?? [];
15
+ indices.push(index);
16
+ byFile.set(reference.file, indices);
17
+ }
18
+ const selected = new Set<number>();
19
+ let activeFiles = [...byFile.values()];
20
+ for (let round = 0; selected.size < limit && activeFiles.length > 0; round++) {
21
+ const remaining: number[][] = [];
22
+ for (const indices of activeFiles) {
23
+ if (selected.size === limit) break;
24
+ selected.add(indices[round]);
25
+ if (indices.length > round + 1) remaining.push(indices);
26
+ }
27
+ activeFiles = remaining;
28
+ }
29
+ return references.filter((_, index) => selected.has(index));
30
+ }
@@ -1,16 +1,5 @@
1
1
  import type { ConfidenceMode } from "@mrclrchtr/supi-code-runtime/api";
2
- import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
3
- import {
4
- createEvidenceList,
5
- createPartialEvidenceList,
6
- type EvidenceList,
7
- } from "../../analysis/evidence.ts";
8
- import type { RelationLocationPartialReason } from "../../analysis/relations/provider-locations.ts";
9
- import type {
10
- CallEntry,
11
- ImplementationEntry,
12
- ReferenceEntry,
13
- } from "../../analysis/relations/types.ts";
2
+ import type { EvidenceList, EvidenceListMetadata } from "../../analysis/evidence.ts";
14
3
  import { toDisplayPath } from "../../analysis/search/paths.ts";
15
4
  import type { GraphSection } from "../../session/graph-types.ts";
16
5
  import {
@@ -26,27 +15,16 @@ import type { GraphDetails, GraphFileGroup, GraphSectionDetails } from "./detail
26
15
  import { graphDisplaySection } from "./display.ts";
27
16
  import { formatGraphEvidence } from "./format.ts";
28
17
  import { graphReadNext } from "./read-next.ts";
18
+ import { type AssembledGraphSection, assembleGraphSection } from "./section.ts";
29
19
  import { structuredGraphCandidates, structuredGraphResult } from "./structured.ts";
30
20
 
31
21
  export type { GraphRelationKind, GraphSection } from "../../session/graph-types.ts";
32
22
 
33
- type UnavailableGraphSection = Extract<GraphSection, { kind: "unavailable" }>;
34
- type ReferenceGraphSection = Extract<GraphSection, { kind: "ok"; rel: "references" }>;
35
- type CalleeGraphSection = Extract<GraphSection, { kind: "ok"; rel: "callees" }>;
36
- type ImplementationGraphSection = Extract<GraphSection, { kind: "ok"; rel: "implements" }>;
37
-
38
- /** A relation section after canonical evidence bounding. */
39
- export type AssembledGraphSection =
40
- | UnavailableGraphSection
41
- | (ReferenceGraphSection & { readonly evidence: EvidenceList<ReferenceEntry> })
42
- | (CalleeGraphSection & { readonly evidence: EvidenceList<CallEntry> })
43
- | (ImplementationGraphSection & {
44
- readonly evidence: EvidenceList<ImplementationEntry>;
45
- });
46
-
47
23
  /** Presentation-neutral assembled graph result. */
48
24
  export interface GraphResultAssembly {
49
25
  displayName: string;
26
+ /** Target-resolution notes shown before relation sections. */
27
+ notes: readonly string[];
50
28
  sections: readonly AssembledGraphSection[];
51
29
  resolvedDisplayFile: string;
52
30
  cwd: string;
@@ -62,8 +40,11 @@ export function assembleGraphResult(input: {
62
40
  resolvedDisplayFile: string;
63
41
  maxResults: number;
64
42
  cwd: string;
43
+ notes?: readonly string[];
65
44
  }): GraphResultAssembly {
66
- const sections = input.sections.map((section) => assembleGraphSection(section, input.maxResults));
45
+ const sections = input.sections.map((section) =>
46
+ assembleGraphSection(section, input.maxResults, input.cwd),
47
+ );
67
48
  const evidenceLists = sections.flatMap((section) =>
68
49
  section.kind === "ok" ? [section.evidence.metadata] : [],
69
50
  );
@@ -85,7 +66,7 @@ export function assembleGraphResult(input: {
85
66
  })),
86
67
  evidenceLists,
87
68
  nextQueries: [],
88
- readNext: graphReadNext(sections),
69
+ readNext: graphReadNext(sections, input.cwd),
89
70
  candidateCount,
90
71
  confidence,
91
72
  provenance,
@@ -96,6 +77,7 @@ export function assembleGraphResult(input: {
96
77
 
97
78
  return {
98
79
  displayName: input.displayName,
80
+ notes: input.notes ?? [],
99
81
  sections,
100
82
  resolvedDisplayFile: input.resolvedDisplayFile,
101
83
  cwd: input.cwd,
@@ -130,103 +112,19 @@ function graphSectionDetails(
130
112
  ? { ...calls.enclosingScope, file: toDisplayPath(cwd, calls.enclosingScope.file) }
131
113
  : null,
132
114
  depth: calls?.depth ?? null,
133
- recovery: calls?.recovery ?? null,
115
+ recovery: calls?.recovery
116
+ ? { ...calls.recovery, file: toDisplayPath(cwd, calls.recovery.file) }
117
+ : null,
134
118
  fileGroups,
135
119
  };
136
120
  }
137
121
 
138
- function assembleGraphSection(section: GraphSection, maxResults: number): AssembledGraphSection {
139
- if (section.kind === "unavailable") return section;
140
- switch (section.rel) {
141
- case "references":
142
- return {
143
- ...section,
144
- evidence: createRelationEvidenceList({
145
- key: "references.locations",
146
- items: [...section.data.references],
147
- maxResults,
148
- invalidLocationCount: section.data.invalidLocationCount,
149
- partialReason: section.data.partialReason,
150
- }),
151
- };
152
- case "callees": {
153
- const evidence = section.data.recovery
154
- ? createPartialEvidenceList({
155
- key: "callees.calls",
156
- items: [...section.data.calls],
157
- maxResults,
158
- partialReason: "provider-limited",
159
- })
160
- : createEvidenceList({
161
- key: "callees.calls",
162
- items: [...section.data.calls],
163
- maxResults,
164
- });
165
- return {
166
- ...section,
167
- evidence: section.data.recovery
168
- ? {
169
- ...evidence,
170
- metadata: {
171
- ...evidence.metadata,
172
- partialMessage: recoveryMessage(section.data.recovery),
173
- },
174
- }
175
- : evidence,
176
- };
177
- }
178
- case "implements":
179
- return {
180
- ...section,
181
- evidence: createRelationEvidenceList({
182
- key: "implements.locations",
183
- items: [...section.data.implementations],
184
- maxResults,
185
- invalidLocationCount: section.data.invalidLocationCount,
186
- partialReason: section.data.partialReason,
187
- }),
188
- };
189
- }
190
- }
191
-
192
- function createRelationEvidenceList<T>(params: {
193
- key: string;
194
- items: T[];
195
- maxResults: number;
196
- invalidLocationCount: number;
197
- partialReason: RelationLocationPartialReason | null;
198
- }): EvidenceList<T> {
199
- const evidence =
200
- params.partialReason === "provider-limited"
201
- ? createPartialEvidenceList({ ...params, partialReason: params.partialReason })
202
- : createEvidenceList(params);
203
- if (params.partialReason === null) return evidence;
204
- return {
205
- ...evidence,
206
- metadata: {
207
- ...evidence.metadata,
208
- partialReason: params.partialReason,
209
- invalidLocationCount: params.invalidLocationCount,
210
- },
211
- };
212
- }
213
-
214
- function recoveryMessage(recovery: NonNullable<CalleeGraphSection["data"]["recovery"]>): string {
215
- const locations = recovery.errorRanges.map(
216
- (range) => `L${range.start.line + 1}:${range.start.character + 1}`,
217
- );
218
- const suffix = locations.length > 0 ? ` Error locations: ${locations.join(", ")}.` : "";
219
- return `${recovery.file}: ${recovery.reason}${suffix}`;
220
- }
221
-
222
122
  function evidenceTotal(evidence: EvidenceList<unknown>): number {
223
123
  return evidence.metadata.totalCount ?? evidence.metadata.shownCount;
224
124
  }
225
125
 
226
126
  function evidenceStatus(evidence: EvidenceList<unknown>): "complete" | "partial" {
227
- return evidence.metadata.partialReason !== null || (evidence.metadata.omittedCount ?? 0) > 0
228
- ? "partial"
229
- : "complete";
127
+ return evidence.metadata.partialReason !== null ? "partial" : "complete";
230
128
  }
231
129
 
232
130
  function sectionConfidence(section: AssembledGraphSection): ConfidenceMode {
@@ -279,7 +177,7 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
279
177
  };
280
178
  }
281
179
  if (outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch") {
282
- return finishGraphCandidates(outcome);
180
+ return finishGraphCandidates(outcome, cwd);
283
181
  }
284
182
 
285
183
  const assembly = assembleGraphResult({
@@ -288,6 +186,7 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
288
186
  resolvedDisplayFile: outcome.resolvedDisplayFile,
289
187
  maxResults: outcome.maxResults,
290
188
  cwd,
189
+ notes: outcome.notes,
291
190
  });
292
191
  const displayTruncated = hasHiddenDisplayEvidence(assembly);
293
192
  return {
@@ -304,8 +203,16 @@ export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntel
304
203
  }
305
204
 
306
205
  function finishGraphCandidates(
307
- outcome: Extract<GraphOutcome, { kind: "disambiguation" | "kind-mismatch" }>,
206
+ input: Extract<GraphOutcome, { kind: "disambiguation" | "kind-mismatch" }>,
207
+ cwd: string,
308
208
  ): CodeIntelResult {
209
+ const outcome = {
210
+ ...input,
211
+ candidates: input.candidates.map((candidate) => ({
212
+ ...candidate,
213
+ file: toDisplayPath(cwd, candidate.file),
214
+ })),
215
+ };
309
216
  const lines = [
310
217
  outcome.kind === "kind-mismatch"
311
218
  ? `**No target matched provider kind \`${outcome.requestedKind}\`. Near matches:**`
@@ -0,0 +1,137 @@
1
+ import {
2
+ createEvidenceList,
3
+ createPartialEvidenceList,
4
+ type EvidenceList,
5
+ } from "../../analysis/evidence.ts";
6
+ import type { RelationLocationPartialReason } from "../../analysis/relations/provider-locations.ts";
7
+ import type {
8
+ CallEntry,
9
+ ImplementationEntry,
10
+ ReferenceEntry,
11
+ } from "../../analysis/relations/types.ts";
12
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
13
+ import type { GraphSection } from "../../session/graph-types.ts";
14
+ import { selectReferenceLocations } from "./reference-selection.ts";
15
+
16
+ type UnavailableGraphSection = Extract<GraphSection, { kind: "unavailable" }>;
17
+ type ReferenceGraphSection = Extract<GraphSection, { kind: "ok"; rel: "references" }>;
18
+ type CalleeGraphSection = Extract<GraphSection, { kind: "ok"; rel: "callees" }>;
19
+ type ImplementationGraphSection = Extract<GraphSection, { kind: "ok"; rel: "implements" }>;
20
+
21
+ /** A relation section after canonical evidence bounding. */
22
+ export type AssembledGraphSection =
23
+ | UnavailableGraphSection
24
+ | (ReferenceGraphSection & {
25
+ readonly evidence: EvidenceList<ReferenceEntry>;
26
+ readonly selectionNote: string | null;
27
+ })
28
+ | (CalleeGraphSection & { readonly evidence: EvidenceList<CallEntry> })
29
+ | (ImplementationGraphSection & {
30
+ readonly evidence: EvidenceList<ImplementationEntry>;
31
+ });
32
+
33
+ /** Bound one relation section's evidence once, before any presentation consumes it. */
34
+ export function assembleGraphSection(
35
+ section: GraphSection,
36
+ maxResults: number,
37
+ cwd: string,
38
+ ): AssembledGraphSection {
39
+ if (section.kind === "unavailable") return section;
40
+ switch (section.rel) {
41
+ case "references": {
42
+ const evidence = createRelationEvidenceList({
43
+ key: "references.locations",
44
+ items: [...section.data.references],
45
+ maxResults,
46
+ invalidLocationCount: section.data.invalidLocationCount,
47
+ partialReason: section.data.partialReason,
48
+ partialMessage: section.data.partialMessage,
49
+ });
50
+ return {
51
+ ...section,
52
+ evidence: {
53
+ ...evidence,
54
+ items: selectReferenceLocations(section.data.references, evidence.metadata.shownCount),
55
+ },
56
+ selectionNote:
57
+ (evidence.metadata.omittedCount ?? 0) > 0 &&
58
+ section.data.references.some((site) => site.file !== section.data.references[0]?.file)
59
+ ? "Selection: one site per file per round."
60
+ : null,
61
+ };
62
+ }
63
+ case "callees": {
64
+ const evidence = section.data.recovery
65
+ ? createPartialEvidenceList({
66
+ key: "callees.calls",
67
+ items: [...section.data.calls],
68
+ maxResults,
69
+ partialReason: "provider-limited",
70
+ })
71
+ : createEvidenceList({
72
+ key: "callees.calls",
73
+ items: [...section.data.calls],
74
+ maxResults,
75
+ });
76
+ return {
77
+ ...section,
78
+ evidence: section.data.recovery
79
+ ? {
80
+ ...evidence,
81
+ metadata: {
82
+ ...evidence.metadata,
83
+ partialMessage: recoveryMessage(section.data.recovery, cwd),
84
+ },
85
+ }
86
+ : evidence,
87
+ };
88
+ }
89
+ case "implements":
90
+ return {
91
+ ...section,
92
+ evidence: createRelationEvidenceList({
93
+ key: "implements.locations",
94
+ items: [...section.data.implementations],
95
+ maxResults,
96
+ invalidLocationCount: section.data.invalidLocationCount,
97
+ partialReason: section.data.partialReason,
98
+ partialMessage: section.data.partialMessage,
99
+ }),
100
+ };
101
+ }
102
+ }
103
+
104
+ function createRelationEvidenceList<T>(params: {
105
+ key: string;
106
+ items: T[];
107
+ maxResults: number;
108
+ invalidLocationCount: number;
109
+ partialReason: RelationLocationPartialReason | null;
110
+ partialMessage: string | null;
111
+ }): EvidenceList<T> {
112
+ const evidence =
113
+ params.partialReason === "provider-limited"
114
+ ? createPartialEvidenceList({ ...params, partialReason: params.partialReason })
115
+ : createEvidenceList(params);
116
+ if (params.partialReason === null) return evidence;
117
+ return {
118
+ ...evidence,
119
+ metadata: {
120
+ ...evidence.metadata,
121
+ partialReason: params.partialReason,
122
+ invalidLocationCount: params.invalidLocationCount,
123
+ ...(params.partialMessage ? { partialMessage: params.partialMessage } : {}),
124
+ },
125
+ };
126
+ }
127
+
128
+ function recoveryMessage(
129
+ recovery: NonNullable<CalleeGraphSection["data"]["recovery"]>,
130
+ cwd: string,
131
+ ): string {
132
+ const locations = recovery.errorRanges.map(
133
+ (range) => `L${range.start.line + 1}:${range.start.character + 1}`,
134
+ );
135
+ const suffix = locations.length > 0 ? ` Error locations: ${locations.join(", ")}.` : "";
136
+ return `${toDisplayPath(cwd, recovery.file)}: ${recovery.reason}${suffix}`;
137
+ }
@@ -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 { GraphTargetParam, MaxResultsParam } from "../schemas.ts";
@@ -18,7 +17,7 @@ export const codeGraphSpec = {
18
17
  {
19
18
  target: GraphTargetParam,
20
19
  relations: Type.Optional(
21
- Type.Array(StringEnum(["all", "references", "callees", "implements"]), {
20
+ Type.Array(Type.Enum(["all", "references", "callees", "implements"], { type: "string" }), {
22
21
  description:
23
22
  'Requested relations; defaults to ["references"]. "all" must be the only item.',
24
23
  minItems: 1,
@@ -27,7 +26,8 @@ export const codeGraphSpec = {
27
26
  ),
28
27
  maxResults: Type.Optional(MaxResultsParam),
29
28
  calleeDepth: Type.Optional(
30
- StringEnum(["direct", "deep"], {
29
+ Type.Enum(["direct", "deep"], {
30
+ type: "string",
31
31
  description: "direct excludes nested scopes; deep includes them.",
32
32
  }),
33
33
  ),
@@ -1,4 +1,3 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
1
  import { type Static, Type } from "typebox";
3
2
  import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
4
3
  import { toDisplayPath } from "../../analysis/search/paths.ts";
@@ -14,14 +13,20 @@ import type { GraphResultAssembly } from "./result.ts";
14
13
  /** Codemode relation evidence; callees describe written expressions, not resolved identities. */
15
14
  export const GraphOutputSchema = Type.Object(
16
15
  {
17
- kind: StringEnum(["completed", "invalid-input", "disambiguation", "kind-mismatch"]),
16
+ kind: Type.Enum(["completed", "invalid-input", "disambiguation", "kind-mismatch"], {
17
+ type: "string",
18
+ }),
18
19
  target: Type.Optional(Type.Object({ name: Type.String(), file: Type.String() })),
19
20
  sections: Type.Array(
20
21
  Type.Object(
21
22
  {
22
- relation: StringEnum(["references", "callees", "implements"]),
23
- source: StringEnum(["semantic", "structural"]),
24
- status: StringEnum(["complete", "partial", "unavailable"]),
23
+ relation: Type.Enum(["references", "callees", "implements"], { type: "string" }),
24
+ source: Type.Enum(["semantic", "structural"], { type: "string" }),
25
+ status: Type.Enum(["complete", "partial", "unavailable"], {
26
+ type: "string",
27
+ description:
28
+ "Completeness of collected relation evidence; display caps are reported separately in evidence counts.",
29
+ }),
25
30
  message: Type.Union([Type.String(), Type.Null()]),
26
31
  items: Type.Array(
27
32
  Type.Object(
@@ -36,7 +41,7 @@ export const GraphOutputSchema = Type.Object(
36
41
  ),
37
42
  evidence: Type.Optional(EvidenceListSchema),
38
43
  externalCount: Type.Integer(),
39
- depth: Type.Union([StringEnum(["direct", "deep"]), Type.Null()]),
44
+ depth: Type.Union([Type.Enum(["direct", "deep"], { type: "string" }), Type.Null()]),
40
45
  enclosingScope: Type.Union([
41
46
  Type.Object({
42
47
  name: Type.String(),
@@ -62,6 +67,11 @@ export const GraphOutputSchema = Type.Object(
62
67
  evidenceLists: Type.Array(EvidenceListSchema),
63
68
  readNext: Type.Array(ReadNextSchema),
64
69
  message: Type.Optional(Type.String()),
70
+ notes: Type.Optional(
71
+ Type.Array(Type.String(), {
72
+ description: "Target-resolution notes, such as excluded paths beside a unique match.",
73
+ }),
74
+ ),
65
75
  requestedKind: Type.Optional(Type.String()),
66
76
  nextQueries: Type.Array(Type.String()),
67
77
  },
@@ -109,6 +119,7 @@ export function structuredGraphResult(
109
119
  }),
110
120
  evidenceLists: assembly.assembled.evidenceLists.map((evidence) => ({ ...evidence })),
111
121
  readNext: assembly.details.readNext.map((item) => ({ ...item })),
122
+ ...(assembly.notes.length > 0 ? { notes: [...assembly.notes] } : {}),
112
123
  nextQueries: [],
113
124
  };
114
125
  }
@@ -0,0 +1,92 @@
1
+ import type { DiagnosticEvidenceSummary } from "@mrclrchtr/supi-lsp/api";
2
+ import { formatProjectServerRoot } from "../../analysis/health/server-status.ts";
3
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
4
+ import type {
5
+ HealthData,
6
+ HealthDiagnosticScope,
7
+ HealthRefreshAttempt,
8
+ } from "../../session/health-types.ts";
9
+
10
+ /** Clone source navigation and recovery labels for display; retain observed ownership identities and stored session facts. */
11
+ export function displayHealthPaths(input: HealthData, cwd: string): HealthData {
12
+ const display = (file: string) => toDisplayPath(cwd, file);
13
+ const scope = (value: HealthDiagnosticScope): HealthDiagnosticScope =>
14
+ value.kind === "file"
15
+ ? { ...value, path: display(value.path) }
16
+ : { ...value, filter: value.filter === null ? null : display(value.filter) };
17
+ const evidence = (value: DiagnosticEvidenceSummary): DiagnosticEvidenceSummary => ({
18
+ ...value,
19
+ documents: value.documents.map((document) => ({ ...document, file: display(document.file) })),
20
+ });
21
+ const attempt = (value: HealthRefreshAttempt): HealthRefreshAttempt => ({
22
+ ...value,
23
+ requestedDiagnosticScope: scope(value.requestedDiagnosticScope),
24
+ ...(value.processCrashRecovery
25
+ ? {
26
+ processCrashRecovery: {
27
+ ...value.processCrashRecovery,
28
+ entries: value.processCrashRecovery.entries.map((entry) => ({
29
+ ...entry,
30
+ root: formatProjectServerRoot(cwd, entry.root),
31
+ })),
32
+ },
33
+ }
34
+ : {}),
35
+ ...(value.startupRetry
36
+ ? {
37
+ startupRetry: {
38
+ ...value.startupRetry,
39
+ entries: value.startupRetry.entries.map((entry) => ({
40
+ ...entry,
41
+ root: formatProjectServerRoot(cwd, entry.root),
42
+ })),
43
+ },
44
+ }
45
+ : {}),
46
+ ...("diagnosticEvidence" in value && value.diagnosticEvidence
47
+ ? { diagnosticEvidence: evidence(value.diagnosticEvidence) }
48
+ : {}),
49
+ ...(value.sourceTracking
50
+ ? {
51
+ sourceTracking: {
52
+ ...value.sourceTracking,
53
+ discovered: value.sourceTracking.discovered.map(display),
54
+ tracked: value.sourceTracking.tracked.map(display),
55
+ skipped: value.sourceTracking.skipped.map(display),
56
+ unavailable: value.sourceTracking.unavailable.map(display),
57
+ },
58
+ }
59
+ : {}),
60
+ });
61
+ const { diagnostics, refresh } = input;
62
+ return {
63
+ ...input,
64
+ diagnostics:
65
+ diagnostics.kind === "not-requested"
66
+ ? diagnostics
67
+ : {
68
+ ...diagnostics,
69
+ scope: scope(diagnostics.scope),
70
+ entries: diagnostics.entries.map((entry) => ({ ...entry, file: display(entry.file) })),
71
+ evidence: evidence(diagnostics.evidence),
72
+ ...(diagnostics.scopeStatus
73
+ ? {
74
+ scopeStatus: {
75
+ ...diagnostics.scopeStatus,
76
+ configPath:
77
+ diagnostics.scopeStatus.configPath === null
78
+ ? null
79
+ : display(diagnostics.scopeStatus.configPath),
80
+ },
81
+ }
82
+ : {}),
83
+ },
84
+ refresh:
85
+ refresh.kind === "not-requested" || refresh.kind === "not-attempted"
86
+ ? {
87
+ ...refresh,
88
+ lastAttempt: refresh.lastAttempt === null ? null : attempt(refresh.lastAttempt),
89
+ }
90
+ : attempt(refresh),
91
+ };
92
+ }
@@ -1,3 +1,4 @@
1
+ import { toDisplayPath } from "../../analysis/search/paths.ts";
1
2
  import type { HealthDiagnosticObservation } from "../../session/health-types.ts";
2
3
 
3
4
  /** Render the tsconfig coverage result for a single-file health request. */
@@ -37,7 +38,7 @@ function formatConfigPath(configPath: string | null, cwd: string): string {
37
38
  return `\`${makeRelative(cwd, configPath)}\``;
38
39
  }
39
40
 
40
- /** Format a workspace path without exposing an absolute root. */
41
+ /** Format a diagnostic source with the shared workspace/external path policy. */
41
42
  export function makeRelative(cwd: string, file: string): string {
42
- return file.startsWith(cwd) ? file.slice(cwd.length + 1) : file;
43
+ return toDisplayPath(cwd, file);
43
44
  }
@@ -15,6 +15,7 @@ import {
15
15
  } from "../result/assembly.ts";
16
16
  import { createToolDisplaySection, truncateDisplayText } from "../result/display.ts";
17
17
  import type { HealthDetails, HealthSectionDetails, ToolDisplaySection } from "../result/types.ts";
18
+ import { displayHealthPaths } from "./display-paths.ts";
18
19
 
19
20
  export type {
20
21
  HealthData,
@@ -44,7 +45,8 @@ const SECTION_TITLES: Record<HealthSection, string> = {
44
45
  };
45
46
 
46
47
  /** Assemble public code_health evidence and details before presentation adapters render it. */
47
- export function assembleHealthResult(data: HealthData, cwd?: string): HealthResultAssembly {
48
+ export function assembleHealthResult(input: HealthData, cwd?: string): HealthResultAssembly {
49
+ const data = cwd === undefined ? input : displayHealthPaths(input, cwd);
48
50
  const projections = data.includedSections.map((section) => projectSection(section, data));
49
51
  const sections = projections.map((projection) => projection.section);
50
52
  const sectionDetails = projections.map((projection) => projection.details);
@@ -282,7 +284,7 @@ export function finishHealthResult(outcome: HealthOutcome, cwd: string): CodeInt
282
284
  const assembly = assembleHealthResult(outcome.data, cwd);
283
285
  return {
284
286
  content: renderHealthResult(assembly, cwd),
285
- structuredContent: structuredHealthResult(outcome.data),
287
+ structuredContent: structuredHealthResult(assembly.data),
286
288
  details: {
287
289
  type: "health",
288
290
  data: assembly.details,