@mrclrchtr/supi-code-intelligence 11.3.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 (66) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +3 -3
  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/declaration-level.ts +34 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  7. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-lsp/README.md +1 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  19. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +64 -2
  22. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
  24. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +49 -4
  25. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -1
  26. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  27. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +2 -1
  28. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  29. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -5
  30. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  31. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  32. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  33. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  34. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  35. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  36. package/package.json +5 -5
  37. package/src/analysis/helpers.ts +0 -7
  38. package/src/analysis/relations/implementations.ts +5 -0
  39. package/src/analysis/relations/references.ts +5 -0
  40. package/src/analysis/target/file-merge.ts +162 -0
  41. package/src/analysis/target/file-outline-omissions.ts +146 -0
  42. package/src/analysis/target/file-refinement.ts +7 -7
  43. package/src/analysis/target/file.ts +44 -156
  44. package/src/analysis/target/symbol.ts +5 -1
  45. package/src/analysis/target/types.ts +32 -6
  46. package/src/api.ts +1 -1
  47. package/src/app/app.ts +9 -3
  48. package/src/session/graph/collect.ts +2 -0
  49. package/src/session/graph-types.ts +3 -1
  50. package/src/session/graph-workflow.ts +5 -4
  51. package/src/session/orientation/workspace-context.ts +3 -0
  52. package/src/session/orientation-workflow.ts +6 -3
  53. package/src/session/refactor-workflow.ts +3 -2
  54. package/src/session/session.ts +87 -12
  55. package/src/session/target-workflow.ts +23 -21
  56. package/src/tool/code_graph/section.ts +4 -0
  57. package/src/tool/code_orientation/directory-navigation.ts +20 -31
  58. package/src/tool/code_orientation/workspace-output.ts +40 -13
  59. package/src/tool/code_orientation/workspace-sections.ts +45 -2
  60. package/src/tool/code_resolve/guidance.ts +1 -1
  61. package/src/tool/code_resolve/markdown.ts +121 -34
  62. package/src/tool/code_resolve/result.ts +18 -15
  63. package/src/tool/code_resolve/structured.ts +43 -10
  64. package/src/tool/result/model-budget.ts +2 -2
  65. package/src/tool/result/types.ts +13 -10
  66. package/src/ui/tui/common.ts +10 -10
@@ -101,21 +101,47 @@ export interface ResolvedTargetData {
101
101
  resolution?: import("../../types/index.ts").AnchoredResolutionMetadata;
102
102
  }
103
103
 
104
+ /** Names left out of a File outline that sit on a contiguous span of lines. */
105
+ export interface FileOutlineNameSpan {
106
+ readonly count: number;
107
+ /** 1-based first and last line holding such a name. */
108
+ readonly startLine: number;
109
+ readonly endLine: number;
110
+ }
111
+
112
+ /**
113
+ * Declarations discovered in a file but left out of its File outline, counted
114
+ * so an agent can request them explicitly.
115
+ */
116
+ export interface FileOutlineNotListed {
117
+ /** Names bound by import statements; the file does not declare them. */
118
+ readonly importedNames: FileOutlineNameSpan | null;
119
+ /** Names inside `export { … }` lists, including re-exports `export { … } from`. */
120
+ readonly exportListNames: FileOutlineNameSpan | null;
121
+ /** `export … from` statements; they only forward names declared in other modules. */
122
+ readonly reExportStatements: FileOutlineNameSpan | null;
123
+ /** Declarations inside function, method, or constructor bodies. */
124
+ readonly localDeclarations: number;
125
+ }
126
+
104
127
  /**
105
- * A file-derived Target group with zero or more evidence-backed declarations.
128
+ * The File outline of one file: its top-level declarations and members,
129
+ * without imported names, export-list names, and local declarations.
106
130
  */
107
- export interface ResolvedTargetGroupData {
131
+ export interface FileOutlineData {
108
132
  file: string;
109
133
  displayName: string;
110
134
  targets: ResolvedTargetData[];
111
135
  /** Providers that successfully enumerated the selected file. */
112
136
  discoveryProvenance: readonly TargetProviderProvenance[];
113
- /** Conservative confidence across the complete group, before display capping. */
137
+ /** Conservative confidence across the complete outline, before display capping. */
114
138
  confidence: "semantic" | "structural" | "heuristic" | "unavailable";
115
- /** Complete-group declarations whose provider observations could not establish hierarchy. */
116
- unknownNestingCount: number;
139
+ /** Declarations in the complete outline whose provider reported no enclosing declaration. */
140
+ unknownLevelCount: number;
117
141
  /** Partial provider collection; targets remain usable and exact absence is not claimed. */
118
142
  partial?: { reason: string; errorRanges: readonly SourceRange[] };
143
+ /** Discovered declarations left out of `targets`, with exact counts. */
144
+ notListed: FileOutlineNotListed;
119
145
  }
120
146
 
121
147
  /**
@@ -166,7 +192,7 @@ export type TargetOutcome =
166
192
  /** Request-scoped evidence notes, such as policy exclusions beside a unique match. */
167
193
  notes?: readonly string[];
168
194
  }
169
- | { kind: "group"; group: ResolvedTargetGroupData }
195
+ | { kind: "file-outline"; outline: FileOutlineData }
170
196
  | ({
171
197
  kind: "disambiguation";
172
198
  candidates: DisambiguationCandidateData[];
package/src/api.ts CHANGED
@@ -40,8 +40,8 @@ export type {
40
40
  export type { CodeProvider, CodeProviderState } from "./analysis/provider.ts";
41
41
  // Target resolution types.
42
42
  export type {
43
+ FileOutlineData,
43
44
  ResolvedTargetData,
44
- ResolvedTargetGroupData,
45
45
  TargetOutcome,
46
46
  TargetProviderProvenance,
47
47
  } from "./analysis/target/types.ts";
package/src/app/app.ts CHANGED
@@ -72,8 +72,10 @@ export function createSessionCache(): {
72
72
  * Create the code-intelligence app and wire it to pi lifecycle events.
73
73
  *
74
74
  * Registers:
75
- * - `session_start` — creates a session for the new cwd, checks branch
76
- * for existing overview
75
+ * - `session_start` / `session_tree` — create or restore the session for the
76
+ * cwd from the active branch (overview and instruction dedup state)
77
+ * - `tool_result` — records full `read` results for instruction dedup
78
+ * - `session_compact` — resets instruction dedup state
77
79
  * - `session_shutdown` — releases all sessions and clears per-session stores
78
80
  */
79
81
  export function createCodeIntelligenceApp(pi: ExtensionAPI): CodeIntelligenceApp {
@@ -91,8 +93,12 @@ export function createCodeIntelligenceApp(pi: ExtensionAPI): CodeIntelligenceApp
91
93
  restoreBranchOverviewState(session, ctx.sessionManager.getBranch());
92
94
  });
93
95
 
96
+ pi.on("tool_result", (event, ctx) => {
97
+ sessions.get(ctx.cwd)?.recordToolResult(event);
98
+ });
99
+
94
100
  pi.on("session_compact", (_event, ctx) => {
95
- sessions.get(ctx.cwd)?.resetSurfacedInstructionDirs();
101
+ sessions.get(ctx.cwd)?.resetInstructionDedup();
96
102
  });
97
103
 
98
104
  pi.on("session_shutdown", () => {
@@ -88,6 +88,7 @@ async function collectReferences(options: CollectRelationOptions): Promise<Graph
88
88
  externalCount: result.externalCount,
89
89
  invalidLocationCount: result.invalidLocationCount,
90
90
  partialReason: result.partialReason,
91
+ partialMessage: result.partialMessage,
91
92
  confidence: "semantic",
92
93
  },
93
94
  readNext: [
@@ -189,6 +190,7 @@ async function collectImplementationsRelation(
189
190
  externalCount: result.externalCount,
190
191
  invalidLocationCount: result.invalidLocationCount,
191
192
  partialReason: result.partialReason,
193
+ partialMessage: result.partialMessage,
192
194
  },
193
195
  readNext: result.implementations
194
196
  .slice(0, Math.min(options.maxResults, 2))
@@ -32,6 +32,7 @@ export type GraphSection =
32
32
  readonly externalCount: number;
33
33
  readonly invalidLocationCount: number;
34
34
  readonly partialReason: RelationLocationPartialReason | null;
35
+ readonly partialMessage: string | null;
35
36
  readonly confidence: "semantic";
36
37
  };
37
38
  readonly readNext: readonly ReadNextItem[];
@@ -59,6 +60,7 @@ export type GraphSection =
59
60
  readonly externalCount: number;
60
61
  readonly invalidLocationCount: number;
61
62
  readonly partialReason: RelationLocationPartialReason | null;
63
+ readonly partialMessage: string | null;
62
64
  };
63
65
  readonly readNext: readonly ReadNextItem[];
64
66
  }
@@ -82,4 +84,4 @@ export interface CompletedGraphWorkflow {
82
84
  /** Graph workflow outcome, preserving target disambiguation and failure states. */
83
85
  export type GraphWorkflowOutcome =
84
86
  | CompletedGraphWorkflow
85
- | Exclude<TargetWorkflowOutcome, { kind: "resolved" } | { kind: "target-group" }>;
87
+ | Exclude<TargetWorkflowOutcome, { kind: "resolved" } | { kind: "file-outline" }>;
@@ -57,10 +57,11 @@ export async function runGraphWorkflow(
57
57
  control,
58
58
  );
59
59
  throwIfAborted(control);
60
- if (targetOutcome.kind === "target-group") {
60
+ if (targetOutcome.kind === "file-outline") {
61
61
  return {
62
62
  kind: "invalid-input",
63
- message: "Graph analysis requires one member handle from a Target group.",
63
+ message:
64
+ "Graph analysis requires one declaration, not a whole file. Pass one handle from the file outline as target.handle.",
64
65
  };
65
66
  }
66
67
  if (targetOutcome.kind !== "resolved") return targetOutcome;
@@ -155,6 +156,6 @@ async function getSemanticReadinessError(options: {
155
156
  /** Narrow helper retained for session method typing. */
156
157
  export function isTargetFailure(
157
158
  outcome: TargetWorkflowOutcome,
158
- ): outcome is Exclude<TargetWorkflowOutcome, { kind: "resolved" } | { kind: "target-group" }> {
159
- return outcome.kind !== "resolved" && outcome.kind !== "target-group";
159
+ ): outcome is Exclude<TargetWorkflowOutcome, { kind: "resolved" } | { kind: "file-outline" }> {
160
+ return outcome.kind !== "resolved" && outcome.kind !== "file-outline";
160
161
  }
@@ -20,6 +20,8 @@ export interface WorkspaceOrientationFacts {
20
20
  /** Absolute explicit focus, or null for the session working directory. */
21
21
  readonly focus: string | null;
22
22
  readonly maxResults: number;
23
+ /** True when the caller set `maxResults`; directory file lists then honor it exactly. */
24
+ readonly maxResultsExplicit?: boolean;
23
25
  readonly overview?: boolean;
24
26
  }
25
27
 
@@ -64,6 +66,7 @@ export async function orientWorkspaceContext(
64
66
  cwd: options.cwd,
65
67
  focus,
66
68
  maxResults: request.maxResults ?? 10,
69
+ maxResultsExplicit: request.maxResults !== undefined,
67
70
  }),
68
71
  focusKind: workspaceFocusKind(request),
69
72
  },
@@ -30,6 +30,8 @@ import { reportProgress, throwIfAborted, type WorkflowControl } from "./workflow
30
30
  export interface OrientationWorkflowDeps extends TargetWorkflowDeps {
31
31
  readonly capability: CapabilityAdapter;
32
32
  readonly nativeInstructionPaths: Set<string>;
33
+ /** Absolute files read in full since the latest compaction; not embedded again. */
34
+ readonly fullyReadPaths: Set<string>;
33
35
  readonly surfacedInstructionDirs: Set<string>;
34
36
  /** Whether the project is trusted — controls instruction-file discovery. */
35
37
  readonly projectTrusted: boolean;
@@ -122,10 +124,11 @@ async function orientTarget(options: {
122
124
  control,
123
125
  );
124
126
  throwIfAborted(control);
125
- if (target.kind === "target-group") {
127
+ if (target.kind === "file-outline") {
126
128
  return {
127
129
  kind: "invalid-input",
128
- message: "Precise Orientation requires one member handle from a Target group.",
130
+ message:
131
+ "Orientation on a target requires one declaration, not a whole file. Pass one handle from the file outline as target.handle, or use focus.path for the file.",
129
132
  };
130
133
  }
131
134
  if (target.kind === "disambiguation" || target.kind === "kind-mismatch") {
@@ -244,7 +247,7 @@ function addInstructionFiles(
244
247
  directory: focusPath,
245
248
  cwd: deps.cwd,
246
249
  fileNames: config.instructionFileNames,
247
- nativeContextPaths: deps.nativeInstructionPaths,
250
+ nativeContextPaths: new Set([...deps.nativeInstructionPaths, ...deps.fullyReadPaths]),
248
251
  surfacedDirectories: deps.surfacedInstructionDirs,
249
252
  projectTrusted: deps.projectTrusted,
250
253
  });
@@ -82,10 +82,11 @@ export async function runRefactorPlanWorkflow(
82
82
  control,
83
83
  );
84
84
  throwIfAborted(control);
85
- if (target.kind === "target-group") {
85
+ if (target.kind === "file-outline") {
86
86
  return {
87
87
  kind: "invalid-input",
88
- message: "Refactor planning requires one member handle from a Target group.",
88
+ message:
89
+ "Refactor planning requires one declaration, not a whole file. Pass one handle from the file outline as target.handle.",
89
90
  };
90
91
  }
91
92
  if (target.kind === "disambiguation" || target.kind === "kind-mismatch") {
@@ -17,8 +17,13 @@
17
17
  */
18
18
 
19
19
  import { realpathSync } from "node:fs";
20
+ import * as os from "node:os";
20
21
  import * as path from "node:path";
21
- import type { SessionEntry } from "@earendil-works/pi-coding-agent";
22
+ import type {
23
+ ReadToolDetails,
24
+ SessionEntry,
25
+ ToolResultEvent,
26
+ } from "@earendil-works/pi-coding-agent";
22
27
  import {
23
28
  type AutomaticLspPathPolicy,
24
29
  createDefaultAutomaticLspPathPolicy,
@@ -164,6 +169,9 @@ export class WorkspaceCodeIntelligenceSession {
164
169
  /** Absolute directories whose instruction files were already surfaced by code_orientation. */
165
170
  readonly #surfacedInstructionDirs = new Set<string>();
166
171
 
172
+ /** Absolute files the agent read in full with `read` since the latest compaction. */
173
+ readonly #fullyReadPaths = new Set<string>();
174
+
167
175
  /**
168
176
  * Optional LSP controller reference — attached by LSP lifecycle module
169
177
  * for Capability Warning evaluation and server management.
@@ -348,6 +356,7 @@ export class WorkspaceCodeIntelligenceSession {
348
356
  {
349
357
  ...this.targetWorkflowDeps(),
350
358
  nativeInstructionPaths: this.#nativeInstructionPaths,
359
+ fullyReadPaths: this.#fullyReadPaths,
351
360
  surfacedInstructionDirs: this.#surfacedInstructionDirs,
352
361
  gradleObserver: this.#gradleObserver,
353
362
  projectTrusted: this.#projectTrusted,
@@ -408,15 +417,39 @@ export class WorkspaceCodeIntelligenceSession {
408
417
 
409
418
  /** Remember instruction/context file paths already loaded by PI natively. */
410
419
  captureNativeInstructionPaths(files: Array<{ path: string }>): void {
411
- for (const file of files) {
412
- const resolved = path.resolve(this.cwd, file.path);
413
- // Resolve to real path so dedup aligns with the realpath-aware
414
- // instruction-file lookup in findInstructionFilesForDirectory.
415
- try {
416
- this.#nativeInstructionPaths.add(path.resolve(realpathSync(resolved)));
417
- } catch {
418
- this.#nativeInstructionPaths.add(resolved);
419
- }
420
+ for (const file of files) this.#nativeInstructionPaths.add(this.#realPath(file.path));
421
+ }
422
+
423
+ /**
424
+ * Record a model-issued `read` that returned a whole file, so code_orientation
425
+ * does not embed it again as an instruction file until the next compaction.
426
+ * Reads issued by another tool (e.g. a codemode script) are ignored: their
427
+ * results reach only the calling tool, not the model, and are not in the
428
+ * transcript used for branch reconstruction.
429
+ */
430
+ recordToolResult(event: ToolResultEvent): void {
431
+ if (event.toolName !== "read" || event.parentToolCallId !== undefined) return;
432
+ if (isFullRead(event.input, event.isError, event.details))
433
+ this.#markFileReadInFull(event.input.path);
434
+ }
435
+
436
+ #markFileReadInFull(filePath: string): void {
437
+ this.#fullyReadPaths.add(this.#realPath(filePath));
438
+ }
439
+
440
+ // Resolve like Pi's read tool (`@` prefix, `~`), then to the real path so
441
+ // dedup aligns with the realpath-aware lookup in findInstructionFilesForDirectory.
442
+ #realPath(filePath: string): string {
443
+ const unprefixed = filePath.replace(/^@/, "");
444
+ const expanded =
445
+ unprefixed === "~" || unprefixed.startsWith("~/")
446
+ ? path.join(os.homedir(), unprefixed.slice(1))
447
+ : unprefixed;
448
+ const resolved = path.resolve(this.cwd, expanded);
449
+ try {
450
+ return path.resolve(realpathSync(resolved));
451
+ } catch {
452
+ return resolved;
420
453
  }
421
454
  }
422
455
 
@@ -427,20 +460,23 @@ export class WorkspaceCodeIntelligenceSession {
427
460
  }
428
461
  }
429
462
 
430
- /** Clear instruction-file dedup state after compaction. */
431
- resetSurfacedInstructionDirs(): void {
463
+ /** Clear instruction-file dedup state (surfaced directories, full reads) after compaction. */
464
+ resetInstructionDedup(): void {
432
465
  this.#surfacedInstructionDirs.clear();
466
+ this.#fullyReadPaths.clear();
433
467
  }
434
468
 
435
469
  /** Reconstruct surfaced instruction directories from branch tool-result details after compaction. */
436
470
  reconstructInstructionState(branch: SessionEntry[]): void {
437
471
  this.#surfacedInstructionDirs.clear();
472
+ this.#fullyReadPaths.clear();
438
473
  const entries = entriesAfterLatestCompaction(branch);
439
474
  for (const entry of entries) {
440
475
  for (const directory of extractInstructionDirectories(entry)) {
441
476
  this.#surfacedInstructionDirs.add(path.resolve(this.cwd, directory));
442
477
  }
443
478
  }
479
+ for (const filePath of extractFullReadPaths(entries)) this.#markFileReadInFull(filePath);
444
480
  }
445
481
 
446
482
  // ── Private session stores ───────────────────────────────────────
@@ -472,6 +508,7 @@ export class WorkspaceCodeIntelligenceSession {
472
508
  this.#refactorPlans.clear();
473
509
  this.#workflowTargets.clear();
474
510
  this.#surfacedInstructionDirs.clear();
511
+ this.#fullyReadPaths.clear();
475
512
  this.#nativeInstructionPaths.clear();
476
513
  this.#maintenanceState = createLspMaintenanceState();
477
514
  this.#lspController = null;
@@ -505,3 +542,41 @@ function extractInstructionDirectories(entry: SessionEntry): string[] {
505
542
  .map((file) => file.directory)
506
543
  .filter((directory): directory is string => typeof directory === "string");
507
544
  }
545
+
546
+ /**
547
+ * Whether a `read` call returned the whole file: no `offset`/`limit`, no error,
548
+ * and no output truncation.
549
+ */
550
+ function isFullRead(
551
+ input: Record<string, unknown> | undefined,
552
+ isError: boolean,
553
+ details: unknown,
554
+ ): input is { path: string } {
555
+ if (isError || typeof input?.path !== "string") return false;
556
+ if (input.offset !== undefined || input.limit !== undefined) return false;
557
+ return (details as ReadToolDetails | undefined)?.truncation?.truncated !== true;
558
+ }
559
+
560
+ function extractFullReadPaths(entries: SessionEntry[]): string[] {
561
+ const calls = new Map<string, Record<string, unknown>>();
562
+ const paths: string[] = [];
563
+ for (const entry of entries) {
564
+ if (entry.type !== "message") continue;
565
+ const message = entry.message;
566
+ if (message.role === "assistant") collectReadCalls(message.content, calls);
567
+ if (message.role !== "toolResult" || message.toolName !== "read") continue;
568
+ const input = calls.get(message.toolCallId);
569
+ if (isFullRead(input, message.isError, message.details)) paths.push(input.path);
570
+ }
571
+ return paths;
572
+ }
573
+
574
+ function collectReadCalls(
575
+ content: ReadonlyArray<{ type: string; id?: string; name?: string; arguments?: unknown }>,
576
+ calls: Map<string, Record<string, unknown>>,
577
+ ): void {
578
+ for (const item of content) {
579
+ if (item.type !== "toolCall" || item.name !== "read" || typeof item.id !== "string") continue;
580
+ calls.set(item.id, item.arguments as Record<string, unknown>);
581
+ }
582
+ }
@@ -10,15 +10,15 @@ 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";
@@ -58,15 +58,16 @@ export type TargetWorkflowOutcome =
58
58
  notes: readonly string[];
59
59
  }
60
60
  | {
61
- kind: "target-group";
61
+ kind: "file-outline";
62
62
  file: string;
63
63
  confidence: ResolvedTargetData["confidence"];
64
- discoveryProvenance: ResolvedTargetGroupData["discoveryProvenance"];
64
+ discoveryProvenance: FileOutlineData["discoveryProvenance"];
65
65
  targets: ReadonlyArray<Readonly<TargetStoreEntry>>;
66
66
  totalCount: number;
67
67
  omittedCount: number;
68
- unknownNestingCount: number;
69
- partial?: ResolvedTargetGroupData["partial"];
68
+ unknownLevelCount: number;
69
+ partial?: FileOutlineData["partial"];
70
+ notListed: FileOutlineData["notListed"];
70
71
  }
71
72
  | ({
72
73
  kind: "disambiguation";
@@ -266,7 +267,7 @@ async function resolveFileOnlyWorkflow(
266
267
  return { kind: "unavailable", reason: readiness.reason };
267
268
  }
268
269
 
269
- const result = await resolveFileTargetGroup(
270
+ const result = await resolveFileOutline(
270
271
  file,
271
272
  deps.cwd,
272
273
  {
@@ -284,7 +285,7 @@ async function resolveFileOnlyWorkflow(
284
285
  return { kind: "unavailable", reason: result.message };
285
286
  }
286
287
 
287
- return registerTargetGroup(result.group, deps, maxResults);
288
+ return registerFileOutline(result.outline, deps, maxResults);
288
289
  }
289
290
 
290
291
  function toWorkflowOutcome(
@@ -317,8 +318,8 @@ function toWorkflowOutcome(
317
318
  };
318
319
  }
319
320
 
320
- if (outcome.kind === "group") {
321
- return registerTargetGroup(outcome.group, deps, policy.maxResults ?? 10);
321
+ if (outcome.kind === "file-outline") {
322
+ return registerFileOutline(outcome.outline, deps, policy.maxResults ?? 10);
322
323
  }
323
324
 
324
325
  const candidates = registerTargetCandidates(outcome.candidates, deps.registerTarget);
@@ -342,28 +343,29 @@ function toWorkflowOutcome(
342
343
  };
343
344
  }
344
345
 
345
- function registerTargetGroup(
346
- group: ResolvedTargetGroupData,
346
+ function registerFileOutline(
347
+ outline: FileOutlineData,
347
348
  deps: TargetWorkflowDeps,
348
349
  maxResults: number,
349
350
  ): TargetWorkflowOutcome {
350
- const totalCount = group.targets.length;
351
- const visibleTargets = group.targets.slice(0, Math.max(0, maxResults));
352
- 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);
353
354
  const fileFingerprint = fingerprint.kind === "ok" ? fingerprint.fingerprint : "unfingerprinted";
354
355
  const targets = visibleTargets.map((target) =>
355
356
  immutableEntry(registerFromTargetData(target, deps, fileFingerprint).entry),
356
357
  );
357
358
  return Object.freeze({
358
- kind: "target-group",
359
- file: group.file,
360
- confidence: group.confidence,
361
- discoveryProvenance: Object.freeze([...group.discoveryProvenance]),
359
+ kind: "file-outline",
360
+ file: outline.file,
361
+ confidence: outline.confidence,
362
+ discoveryProvenance: Object.freeze([...outline.discoveryProvenance]),
362
363
  targets: Object.freeze(targets),
363
364
  totalCount,
364
365
  omittedCount: totalCount - targets.length,
365
- unknownNestingCount: group.unknownNestingCount,
366
- ...(group.partial ? { partial: group.partial } : {}),
366
+ unknownLevelCount: outline.unknownLevelCount,
367
+ ...(outline.partial ? { partial: outline.partial } : {}),
368
+ notListed: outline.notListed,
367
369
  });
368
370
  }
369
371
 
@@ -45,6 +45,7 @@ export function assembleGraphSection(
45
45
  maxResults,
46
46
  invalidLocationCount: section.data.invalidLocationCount,
47
47
  partialReason: section.data.partialReason,
48
+ partialMessage: section.data.partialMessage,
48
49
  });
49
50
  return {
50
51
  ...section,
@@ -94,6 +95,7 @@ export function assembleGraphSection(
94
95
  maxResults,
95
96
  invalidLocationCount: section.data.invalidLocationCount,
96
97
  partialReason: section.data.partialReason,
98
+ partialMessage: section.data.partialMessage,
97
99
  }),
98
100
  };
99
101
  }
@@ -105,6 +107,7 @@ function createRelationEvidenceList<T>(params: {
105
107
  maxResults: number;
106
108
  invalidLocationCount: number;
107
109
  partialReason: RelationLocationPartialReason | null;
110
+ partialMessage: string | null;
108
111
  }): EvidenceList<T> {
109
112
  const evidence =
110
113
  params.partialReason === "provider-limited"
@@ -117,6 +120,7 @@ function createRelationEvidenceList<T>(params: {
117
120
  ...evidence.metadata,
118
121
  partialReason: params.partialReason,
119
122
  invalidLocationCount: params.invalidLocationCount,
123
+ ...(params.partialMessage ? { partialMessage: params.partialMessage } : {}),
120
124
  },
121
125
  };
122
126
  }
@@ -10,12 +10,16 @@ const INLINE_SECTIONS = new Set([
10
10
  "workspace.issues",
11
11
  ]);
12
12
 
13
- /** Keep the immediate directory map and all collection problems inline; defer ancillary facts. */
13
+ /**
14
+ * Keep the immediate directory map, manifest-declared entry paths, and all collection problems
15
+ * inline; defer ancillary facts to the captured result and name them in one note.
16
+ */
14
17
  export function selectDirectoryNavigation(data: OrientationResultData): OrientationResultData {
15
18
  if (!data.workspace?.focus || data.workspace.overview) return data;
16
19
  const workspaceRoot = data.workspace.focus === data.workspace.observation.root;
17
20
  const inline = (section: OrientationSectionData): boolean =>
18
21
  INLINE_SECTIONS.has(section.key) ||
22
+ section.key.endsWith(".paths") ||
19
23
  section.key.startsWith("gradle.") ||
20
24
  (workspaceRoot &&
21
25
  (section.key === "workspace.projects" || section.key === "workspace.memberships")) ||
@@ -28,39 +32,24 @@ export function selectDirectoryNavigation(data: OrientationResultData): Orientat
28
32
  sum + section.evidenceLists.reduce((count, list) => count + (list.totalCount ?? 0), 0),
29
33
  0,
30
34
  );
31
- if (total > 0) {
32
- sections.push({
33
- key: "workspace.captured",
34
- title: "Captured navigation",
35
- status: "complete",
36
- reason: null,
37
- confidence: "unavailable",
38
- provenance: [],
39
- evidenceLists: [
40
- {
41
- key: "workspace.captured",
42
- totalCount: total,
43
- shownCount: 0,
44
- omittedCount: total,
45
- partialReason: null,
46
- },
47
- ],
48
- items: [
49
- {
50
- kind: "paragraph",
51
- text: `Ancillary sections are in the captured details: ${deferred.map((section) => section.title).join("; ")}.`,
52
- },
53
- ],
54
- });
55
- }
35
+ const notes =
36
+ total > 0
37
+ ? [
38
+ ...data.notes,
39
+ `Deferred to captured details: ${deferred.map((section) => section.title).join("; ")}.`,
40
+ ]
41
+ : data.notes;
56
42
  return {
57
43
  ...data,
44
+ notes,
58
45
  sections,
59
46
  renderedSections: sections.map((section) => section.key),
60
- omittedCount: sections.reduce(
61
- (sum, section) =>
62
- sum + section.evidenceLists.reduce((count, list) => count + (list.omittedCount ?? 0), 0),
63
- 0,
64
- ),
47
+ omittedCount:
48
+ total +
49
+ sections.reduce(
50
+ (sum, section) =>
51
+ sum + section.evidenceLists.reduce((count, list) => count + (list.omittedCount ?? 0), 0),
52
+ 0,
53
+ ),
65
54
  };
66
55
  }
@@ -40,21 +40,9 @@ export function prepareWorkspaceOutput(input: OrientationResultData): {
40
40
  true,
41
41
  );
42
42
  const fullContent = renderOrientationData(full);
43
- let limit = workspace.overview
44
- ? Math.max(10, workspace.observation.projects.length)
45
- : workspace.maxResults;
46
- let descriptions = true;
47
- let data = selectDirectoryNavigation(workspaceSections(input, limit, descriptions));
48
- if (navigationText(data).length > budget.warning * 4) {
49
- descriptions = false;
50
- data = selectDirectoryNavigation(workspaceSections(input, limit, descriptions));
51
- }
52
43
  // Reserve room for the snapshot path and omission notice before reducing rows.
53
44
  const reserved = 1024;
54
- while (exceedsNavigationBudget(data, budget.cap * 4 - reserved) && limit > 0) {
55
- limit = Math.floor(limit / 2);
56
- data = selectDirectoryNavigation(workspaceSections(input, limit, descriptions));
57
- }
45
+ let { data, descriptions } = selectWithinBudget(input, workspace, budget, reserved);
58
46
  const overflow = exceedsNavigationBudget(data, budget.cap * 4 - reserved);
59
47
  if (overflow) {
60
48
  data = {
@@ -111,6 +99,45 @@ export function prepareWorkspaceOutput(input: OrientationResultData): {
111
99
  };
112
100
  }
113
101
 
102
+ /**
103
+ * Shrink one observation's presentation until it fits: drop descriptions, then the uncapped
104
+ * directory file list, then halve every list cap.
105
+ */
106
+ function selectWithinBudget(
107
+ input: OrientationResultData,
108
+ workspace: WorkspaceOrientationFacts,
109
+ budget: { warning: number; cap: number },
110
+ reserved: number,
111
+ ): { data: OrientationResultData; descriptions: boolean } {
112
+ let limit = workspace.overview
113
+ ? Math.max(10, workspace.observation.projects.length)
114
+ : workspace.maxResults;
115
+ // Without an explicit cap, directory focus shows every direct file until the budget forces the default.
116
+ let fileLimit =
117
+ workspace.focus && !workspace.overview && !workspace.maxResultsExplicit
118
+ ? Number.MAX_SAFE_INTEGER
119
+ : limit;
120
+ let descriptions = true;
121
+ const select = () =>
122
+ selectDirectoryNavigation(workspaceSections(input, limit, descriptions, fileLimit));
123
+ let data = select();
124
+ if (navigationText(data).length > budget.warning * 4) {
125
+ descriptions = false;
126
+ data = select();
127
+ }
128
+ const cap = budget.cap * 4 - reserved;
129
+ if (exceedsNavigationBudget(data, cap) && fileLimit > limit) {
130
+ fileLimit = limit;
131
+ data = select();
132
+ }
133
+ while (exceedsNavigationBudget(data, cap) && limit > 0) {
134
+ limit = Math.floor(limit / 2);
135
+ fileLimit = limit;
136
+ data = select();
137
+ }
138
+ return { data, descriptions };
139
+ }
140
+
114
141
  /** Overview links recover omitted navigation; explicit Orientation also retains raw facts. */
115
142
  function needsCapturedResult(
116
143
  workspace: WorkspaceOrientationFacts,