@mrclrchtr/supi-code-intelligence 13.0.0 → 14.0.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 (78) hide show
  1. package/CHANGELOG.md +18 -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/query-result.ts +10 -0
  5. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
  7. package/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
  9. package/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  10. package/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
  11. package/node_modules/@mrclrchtr/supi-lsp/README.md +6 -2
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
  20. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +3 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +14 -1
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-typescript.ts +8 -1
  25. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +4 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +7 -1
  27. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +1 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +24 -8
  29. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +5 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +3 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +64 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +3 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +27 -2
  34. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +16 -112
  35. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +521 -83
  36. package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-collection.ts +163 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/src/manager/workspace-symbol-row-limit.ts +72 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +11 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +36 -7
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +10 -0
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +59 -13
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/footer-registry.ts +41 -9
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +2 -0
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/side-run.ts +46 -0
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/spill.ts +2 -2
  48. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm +0 -0
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/sql/tree-sitter-sql.wasm.json +2 -2
  51. package/package.json +5 -5
  52. package/src/analysis/health/server-status.ts +32 -9
  53. package/src/analysis/health/signals.ts +1 -0
  54. package/src/analysis/instruction-files.ts +11 -7
  55. package/src/analysis/search/exclusions.ts +18 -4
  56. package/src/analysis/target/file-outline-omissions.ts +17 -2
  57. package/src/analysis/target/symbol-selection.ts +100 -0
  58. package/src/analysis/target/symbol.ts +48 -8
  59. package/src/analysis/target/types.ts +8 -1
  60. package/src/app/app.ts +37 -21
  61. package/src/extension.ts +1 -2
  62. package/src/headless.ts +4 -2
  63. package/src/session/health-types.ts +2 -0
  64. package/src/session/orientation-types.ts +5 -0
  65. package/src/session/orientation-workflow.ts +13 -3
  66. package/src/session/target-workflow.ts +18 -12
  67. package/src/tool/code_find/render.ts +10 -11
  68. package/src/tool/code_find/result.ts +6 -1
  69. package/src/tool/code_graph/structured.ts +3 -0
  70. package/src/tool/code_health/markdown.ts +3 -1
  71. package/src/tool/code_health/structured-schema.ts +1 -0
  72. package/src/tool/code_health/structured.ts +2 -0
  73. package/src/tool/code_orientation/markdown.ts +6 -1
  74. package/src/tool/code_resolve/result.ts +2 -1
  75. package/src/tool/code_resolve/structured.ts +6 -1
  76. package/src/tool/result/candidate-selection.ts +17 -1
  77. package/src/ui/footer.ts +147 -42
  78. package/src/ui/status-overlay.ts +13 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [14.0.0]
4
+
5
+ - The LSP footer moved to the right side of the footer path line and is shorter: `λ 3✓ 1⟳ ◫43` instead of `λ lsp • 3 ✓ • 1 ⟳ • 43 open files`. Route counts are colored by severity (`✓` success, `⟳` accent, `↻` and `⊘` warning, `✗` error). The file count covers files synchronized to a language server, not files open in an editor; it uses `◫`, the Nerd Font file-with-eye outline (U+F0DCB), or `f` depending on the footer `icons` setting, and ASCII mode writes `lsp 3ok`. When LSP startup fails, the footer shows `λ ✗ config` for a configuration error and `λ ✗ unavailable` otherwise, instead of disappearing. Pi's built-in footer and other custom footers now show the LSP status too, on their extension status line. The footer renders the last published runtime state instead of re-querying every route on each render, and a route whose server command is missing or fails to start shows up without waiting for another state change.
6
+ - Symbol queries on TypeScript workspaces with several projects no longer return a short candidate list as complete. The language server searches only projects it has loaded, and the first query stopped after loading one. A query for `toolDescription` could list 13 of 26 declarations, and a name declared in two projects could be selected automatically from the one that was loaded. Every project root (up to 96) is now loaded before a symbol result is reported complete; roots past that limit are reported as a coverage limit ([#615](https://github.com/mrclrchtr/supi/issues/615)). Loading starts in the background when the TypeScript server is ready and takes a few seconds once per session. A symbol query that arrives earlier waits for it. While it runs, the LSP footer counts the TypeScript route under `⟳` instead of `✓`, and `code_health` and the `/supi-ci-status` inspector show it as `loading projects`; structured `code_health` servers carry `loadingProjects: true`. The opened files (one per project root) count as tracked files in `code_health` from then on, also in sessions that never run a symbol query ([#618](https://github.com/mrclrchtr/supi/issues/618)).
7
+ - `code_graph` references on a native TypeScript workspace no longer miss a test project whose first file in directory order is one the project excludes, such as `__tests__/fixtures/server.mjs`. Project warm-up opened only that file, which does not keep the project loaded, so references to `limitWorkspaceSymbolWarmRoots` came back provider-limited with `packages/supi-lsp/__tests__/tsconfig.json` is not loaded, and symbol queries could miss names declared only in that project. Warm-up now opens the project's next file and records the skipped one as a `workspace-symbol.warm-probe` debug event with outcome `excluded`. A project that includes the queried file but has no file of its own, such as a `__tests__/tsconfig.json` without tests, is no longer reported as not loaded: there was no file to open, so the advice could not be followed ([#616](https://github.com/mrclrchtr/supi/issues/616)).
8
+ - Several `code_*` calls in one parallel block no longer fail with `No routed LSP client could complete …` when together they open more than 32 new files, for example long candidate lists. Up to 1,024 first opens may now wait per language server. If that limit is reached, the result names the cause (`LSP could not open <file> for references: LSP input admission queue is full.`) instead of reporting a missing route.
9
+ - Two new LSP debug events are kept in the session file: `document.open-failed` (warning) names the server, file, and reason when a language server could not open a file, and `workspace-symbol.warm-pass` (info) summarizes one project warm-up pass with root counts and duration. Before, a failed open left no trace, and the per-file warm-up probes were `debug` events that high-volume request timings pushed out of the buffer.
10
+ - LSP batch operations no longer record one `request.timing` debug event per completed request. A diagnostic refresh over every open document and a project warm-up pass now report their completed requests on their own event (`diagnostics.timing` `refresh-open`, `workspace-symbol.warm-pass`) as `requests`, keyed by method with `count`, `totalMs`, and `maxMs`. Before, one refresh over 46 open documents recorded 46 near-identical timings and filled most of the 100-event debug buffer. Failed, timed-out, and cancelled requests are still recorded individually ([#619](https://github.com/mrclrchtr/supi/issues/619)).
11
+ - A project warm-up pass records far fewer debug events. It publishes one `runtime.transition` for all files it opened instead of one per file, and records a `workspace-symbol.warm-probe` event only for a file that did not load its project (`open-failed`, `probe-unavailable`, `inferred`); loaded projects are counted in `workspace-symbol.warm-pass`. Before, one pass over 46 projects recorded about 90 such events. The LSP footer therefore updates its open-file count less often during the pass ([#619](https://github.com/mrclrchtr/supi/issues/619)).
12
+ - A TypeScript symbol result at the native server's limit of 256 rows is reported as provider-limited instead of complete, so a target is not selected automatically from a truncated list. The limit is not applied to typescript-language-server (tsserver), which returns every match. The native server sorts exact names first and cuts afterwards, so a cut answer whose last row has another name still holds every declaration of the queried name. Such a result selects the only declaration of that name, with a note that partial-name matches may be missing: `code_resolve` for `git` scoped to `packages/supi-extras/src` resolves `footer-git-status.ts:102` instead of listing six candidates. Otherwise, when the query already has a scope, the note points to an anchor target (file, line, character) instead of suggesting a scope. If no row of a cut answer lies in the scope, the `code_resolve` failure no longer appends the readiness next steps, whose `target.file` advice led back to the same query ([#617](https://github.com/mrclrchtr/supi/issues/617), [#622](https://github.com/mrclrchtr/supi/issues/622)).
13
+ - A candidate list that is incomplete (for example provider-limited) ends with `Choose one candidate handle.` instead of also suggesting to narrow with `scope` or `symbolKind`. The list's own note names the step that applies, and the generic advice could contradict it ([#617](https://github.com/mrclrchtr/supi/issues/617)).
14
+ - A semantic `code_find` result that may be incomplete now states why: `more may exist — provider-limited; <reason>`, the same wording `code_resolve` uses. Before, it showed only `provider-limited`. The separate line about results excluded by the automatic path policy is omitted in that case, because the reason already contains it.
15
+ - Several reasons for an incomplete symbol result are no longer joined as `.;`. A reason that ends a sentence is followed by a space.
16
+ - Directory `code_orientation` in managed child sessions (Agent Runs and Reviewer Sessions) no longer repeats an instruction file the session already has: one loaded into its system prompt, or one it read in full with `read`. After a compaction the files are delivered again. The parent session already behaved this way ([#612](https://github.com/mrclrchtr/supi/issues/612)).
17
+ - Directory `code_orientation` names the instruction files it does not repeat: `Instruction files already supplied in this session, not repeated: …`. Before, the missing `## Instructions` section could not be told apart from a discovery failure. The workspace-root file is not listed, because nearly every session already has it.
18
+ - The note about results excluded by the automatic path policy is shorter: it names at most two example paths, and a path is written once unless the observed and canonical forms differ. Structured output still lists every collected example.
19
+ - Symbol targets in `code_resolve`, `code_graph`, and `code_orientation` select the only case-sensitive exact-name match instead of listing partial-name matches as candidates. A query for `registerSettings` no longer returns `# Multiple targets match` because `registerLspSettings` also exists; the result carries a note naming the matches that were not selected. An exact-name match that only imports or re-exports the name, such as the `alias` symbol TypeScript 6 and earlier report for `export { foo } from "./foo"`, no longer counts as a second declaration. Several declarations of one name still list candidates, now without the partial-name matches, which a note names instead. Incomplete provider results list every match.
20
+
3
21
  ## [13.0.0]
4
22
 
5
23
  - **Breaking:** every `code_*` evidence list in structured details now carries `completeness`: `complete`, `capped`, `partial`, or `unbounded`. Scripts can read it directly instead of inferring completeness from a null `totalCount`. `code_orientation` source lists and context definitions replace `collectedCount`/`omittedCount` with one `evidence` list. Expanded TUI sections report rows hidden by the 20-row view separately (for example `25 of 30; 5 omitted; 5 rows hidden in view`), instead of adding them to the evidence omission count. Structured TUI chrome from sessions saved before this change falls back to the markdown output on resume.
package/README.md CHANGED
@@ -76,7 +76,7 @@ code_health({ scope: "packages/api/src/index.ts", refresh: true })
76
76
 
77
77
  Important tool rules:
78
78
 
79
- - **Resolve:** new target handles require semantic readiness. A comment or whitespace point is not a symbol; use `code_inspect` there. Handles are session-local and become stale when file contents change. Resolve the symbol again rather than reuse a stale handle. Symbol queries put case-sensitive exact-name matches first, before the display cap. Provider order stays unchanged within exact-name and other matches. An incomplete provider result never selects a target automatically.
79
+ - **Resolve:** new target handles require semantic readiness. A comment or whitespace point is not a symbol; use `code_inspect` there. Handles are session-local and become stale when file contents change. Resolve the symbol again rather than reuse a stale handle. A symbol query selects the only case-sensitive exact-name match, even beside partial-name matches such as `fooBar` for `foo`, and names those in a note. Exact-name matches inside an import statement or export list are bindings, not declarations, and do not count. With several declarations of one name it lists only those as candidates and names the other matches in a note. An incomplete provider result lists every match, exact names first, before the display cap. Provider order stays unchanged within exact-name and other matches. An incomplete provider result never selects a target automatically.
80
80
  - **Graph:** relations are `references` (default), `callees`, and `implements`. Use `["all"]` for all three. Callee depth is `direct` by default; `deep` includes nested scopes, not transitive calls. Callees match source shape, not symbol identity. Counts include each distinct call site; repeated expressions share one agent-output row with all shown line/column coordinates. Each relation reports its counts and limits once. Relation status describes evidence collection, not display size: a fully collected relation remains `complete` when `maxResults` hides sites; `shownCount`, `totalCount`, and `omittedCount` disclose that cap. Actual evidence gaps remain `partial`, and unavailable capabilities remain `unavailable`. Capped references select one site per file per round in stable file/source order, then display the selected sites grouped by file; `maxResults` still counts individual references, not files. This distributes the available slots without ranking semantic importance or promising that every file is represented. Provider-limited results have unknown totals; invalid locations are disclosed separately. Callee previews shorten receiver argument lists from syntax without changing grouping by the full expression. Matching previews get local expression numbers so distinct source expressions remain clear. Unavailable references and implementations keep the provider reason. If no provider exists, the result names that gap. Unavailable callees keep the provider reason and a source-inspection next step. Ambiguous targets ask for candidate selection, not input correction. Candidate limits retain exact totals, or unknown totals when the provider returns partial data. Agent output and both transcript views disclose omissions. Only shown candidates receive target handles. The human transcript shows the resolved target and per-relation evidence types and status. The expanded view groups up to 20 sites per relation by file, without a duplicate Markdown body. If this display limit hides returned sites, the transcript links to a temporary file with all returned evidence. This file does not include evidence beyond `maxResults`, and its path does not add text to an otherwise complete agent result. Reference read-next suggestions use selected sites and prefer different files not already covered by the target recommendation. Merged read ranges use neutral guidance.
81
81
  - **Find:** AST mode requires `kind`: `definition`, `import`, `export`, `call`, `type`, `interface`, `class`, `method`, or `enum`. Semantic mode does not accept `kind`. A supplied `scope` is a non-empty array.
82
82
  - **Health:** `include` accepts `diagnostics` and `servers` (both by default); `level` is `summary` (default) or `detailed`. Server inventory and route counts remain workspace-wide, even with a diagnostic scope. A diagnostic snapshot does not prove that the whole workspace is clean. Tsconfig and jsconfig coverage applies only to TypeScript and JavaScript-family files; other-language files have no `Tsconfig` label.
@@ -267,7 +267,7 @@ Press `h` (or F6) to **Refresh health**: run the existing workspace-scoped sessi
267
267
 
268
268
  Press `r` to reload the passive snapshot, `a` to collapse details, and Escape to close. Opening, rendering, expanding details, and reloading do not enroll files, start or retry routes, or request fresh diagnostics. Only one reload, check, or health action runs at a time; scrolling and details remain usable while the spinner runs. Closing aborts the caller's wait and prevents subsequent snapshot collection or late UI updates; shared LSP work may still settle independently. Scrolling, Tab, confirmation, and cancel actions honor Pi's configured keybindings. Configured actions take priority over `c`/F5 and `h`/F6; the inspector advertises an available shortcut for each action, or marks it unbound. The viewport adjusts to terminal size, with controls kept visible.
269
269
 
270
- The inspector does not replace the footer or add editor widgets. The extension's separate LSP footer contribution remains active. Outside the interactive terminal, use `code_health`.
270
+ The inspector does not replace the footer or add editor widgets. The extension's separate LSP footer contribution remains active: `λ 2✓ 1⟳ ◫17` on the right side of the footer path line counts ready routes (`✓`), routes still in progress (`⟳`), and files synchronized to a language server (`◫`; a Nerd Font file icon or `f`, depending on the footer `icons` setting). Recovering (`↻`), failed (`✗`), and unavailable (`⊘`) routes appear in warning or error colors, and a failed LSP startup shows `λ ✗ config` or `λ ✗ unavailable`. Without the SuPi footer, Pi's extension status line shows the same text. A route is in progress while its server starts or indexes, and while the TypeScript project warm-up after startup loads its projects; during the warm-up the route answers queries, and only symbol queries wait. The inspector and `code_health` name that state `loading projects`. Outside the interactive terminal, use `code_health`.
271
271
 
272
272
  The package registers **Code Intelligence** and **LSP** settings. If `@mrclrchtr/supi-settings` is installed, use `/supi-settings` to edit them. A standalone Code Intelligence install does not include that settings UI.
273
273
 
@@ -344,7 +344,7 @@ Tool results and the hidden overview enter Pi's model context and can be saved i
344
344
 
345
345
  The package-root export also re-exports types; prefer `/api`. See [the type exports](src/api.ts) for the complete list.
346
346
 
347
- The headless factory registers only `code_resolve`, `code_inspect`, `code_orientation`, `code_graph`, `code_find`, and `code_health` for managed child sessions. It adds no refactor tools, settings, commands, UI, or overview. It is a tool profile, not a filesystem sandbox.
347
+ The headless factory registers only `code_resolve`, `code_inspect`, `code_orientation`, `code_graph`, `code_find`, and `code_health` for managed child sessions. It adds no refactor tools, settings, commands, UI, or overview. Directory orientation skips instruction files the child session already has, by the same rules as the full extension. It is a tool profile, not a filesystem sandbox.
348
348
 
349
349
  ## See it in action
350
350
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,16 @@ export interface CodeQueryPartialMetadata {
14
14
  * answer.
15
15
  */
16
16
  readonly exclusionOnly?: boolean;
17
+ /** A provider cut its answer at a row limit; a narrower scope cannot avoid it. */
18
+ readonly rowLimit?: {
19
+ /**
20
+ * True when every declaration whose name equals the query is still in the
21
+ * result, though partial-name matches may be missing: the provider sorted
22
+ * exact names first. Set only when no provider failed and no coverage gap
23
+ * was observed, so exact-name selection stays sound.
24
+ */
25
+ readonly exactNamesComplete: boolean;
26
+ };
17
27
  }
18
28
 
19
29
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -16,7 +16,10 @@ export interface DebugRegistryConfig {
16
16
  agentAccess: DebugAgentAccess;
17
17
  /** Whether Agent Run retrospective capture is explicitly enabled. */
18
18
  agentRunRetrospectivesEnabled: boolean;
19
- /** Maximum number of session-local events to keep in memory. */
19
+ /**
20
+ * Maximum number of session-local events to keep in memory. `debug` events
21
+ * are evicted first; higher levels keep at most half of the buffer.
22
+ */
20
23
  maxEvents: number;
21
24
  /**
22
25
  * Minimum level forwarded to persistence sinks. Lower-level events stay in the
@@ -146,12 +149,51 @@ function normalizeMaxEvents(value: number): number {
146
149
  return Math.floor(value);
147
150
  }
148
151
 
152
+ function isSummary(event: DebugEvent): boolean {
153
+ return event.level !== "debug";
154
+ }
155
+
156
+ function groupKey(event: DebugEvent): string {
157
+ return `${event.source}\u0000${event.category}`;
158
+ }
159
+
160
+ /**
161
+ * Return the index of the oldest event in the largest source/category group of
162
+ * one tier, so a high-volume category evicts its own events before rare ones.
163
+ */
164
+ function evictionIndex(events: readonly DebugEvent[], summaryTier: boolean): number {
165
+ const counts = new Map<string, number>();
166
+ let largest = 0;
167
+ for (const event of events) {
168
+ if (isSummary(event) !== summaryTier) continue;
169
+ const key = groupKey(event);
170
+ const count = (counts.get(key) ?? 0) + 1;
171
+ counts.set(key, count);
172
+ largest = Math.max(largest, count);
173
+ }
174
+ return events.findIndex(
175
+ (event) => isSummary(event) === summaryTier && counts.get(groupKey(event)) === largest,
176
+ );
177
+ }
178
+
179
+ /**
180
+ * Evict down to `maxEvents`. A `debug` event goes first, so high-volume
181
+ * timings cannot push out a summary recorded moments earlier. Higher-level
182
+ * events keep at most half the buffer; past that one of them goes instead, so
183
+ * recent `debug` events stay visible too. Within the chosen tier, the oldest
184
+ * event of the largest source/category group goes, so one flooding category
185
+ * such as `request.timing` cannot push out every other category.
186
+ */
149
187
  function trimToMaxEvents(state: DebugRegistryState): void {
150
188
  const maxEvents = normalizeMaxEvents(state.config.maxEvents);
151
- if (state.events.length <= maxEvents) {
152
- return;
189
+ const summaryShare = Math.floor(maxEvents / 2);
190
+ let summaries = state.events.filter(isSummary).length;
191
+ while (state.events.length > maxEvents) {
192
+ const evictSummary = summaries > summaryShare;
193
+ const index = evictionIndex(state.events, evictSummary);
194
+ if (evictSummary) summaries--;
195
+ state.events.splice(Math.max(index, 0), 1);
153
196
  }
154
- state.events.splice(0, state.events.length - maxEvents);
155
197
  }
156
198
 
157
199
  /** Return whether a debug level is recognized by the registry. */
@@ -226,18 +268,22 @@ export function isDebugRegistryEnabled(): boolean {
226
268
  }
227
269
 
228
270
  /**
229
- * Return whether a retrospective can be captured: Debug and its explicit opt-in
271
+ * Return whether an event at `level` would reach the session file now: Debug
230
272
  * must be enabled, at least one persistence sink must be registered, and the
231
- * persistence threshold must admit `info` events.
273
+ * persistence threshold must admit the level.
232
274
  */
233
- export function canRecordAgentRunRetrospective(): boolean {
275
+ export function canPersistDebugEvent(level: DebugLevel = "info"): boolean {
234
276
  const state = getState();
235
- return (
236
- state.config.enabled &&
237
- state.config.agentRunRetrospectivesEnabled &&
238
- state.persistenceSinks.size > 0 &&
239
- shouldPersist(state, "info")
240
- );
277
+ return state.config.enabled && state.persistenceSinks.size > 0 && shouldPersist(state, level);
278
+ }
279
+
280
+ /**
281
+ * Return whether a retrospective can be captured: an `info` event must be
282
+ * persistable (see {@link canPersistDebugEvent}) and the explicit Agent Run
283
+ * retrospective opt-in must be enabled.
284
+ */
285
+ export function canRecordAgentRunRetrospective(): boolean {
286
+ return getState().config.agentRunRetrospectivesEnabled && canPersistDebugEvent("info");
241
287
  }
242
288
 
243
289
  /** Best-effort redaction helper for data exposed through sanitized debug views. */
@@ -1,9 +1,8 @@
1
1
  // Shared footer contribution registry for SuPi extensions.
2
2
  //
3
- // Extensions register pre-styled text chunks with a placement hint
4
- // ("stats" for the metrics line, "status" for the extension status line).
5
- // The custom footer in supi-extras reads these contributions and renders them
6
- // alongside the built-in metrics. Extensions can use PI's status API as a
3
+ // Extensions register text chunks with a placement hint. The custom footer in
4
+ // supi-extras reads these contributions and renders them alongside the
5
+ // built-in metrics. Extensions can use PI's status API with the same key as a
7
6
  // fallback when the custom footer is not installed.
8
7
 
9
8
  import { createRegistry } from "./registry-utils.ts";
@@ -11,8 +10,33 @@ import { createRegistry } from "./registry-utils.ts";
11
10
  /** Event emitted when a dynamic footer contribution needs a new render. */
12
11
  export const FOOTER_INVALIDATE_EVENT = "supi:footer:invalidate";
13
12
 
14
- /** Where the contribution should appear in the footer. */
15
- export type FooterPlacement = "stats" | "stats-end" | "status";
13
+ /**
14
+ * Where the contribution should appear in the footer.
15
+ *
16
+ * - `path-end`: right side of the workspace line (path and Git), for workspace state
17
+ * - `stats`: inside the cache section of the session line
18
+ * - `stats-end`: own sections after context usage on the session line
19
+ * - `model-start`: right side of the session line, before the model name
20
+ * - `status`: extension status line below the footer
21
+ */
22
+ export type FooterPlacement = "path-end" | "stats" | "stats-end" | "model-start" | "status";
23
+
24
+ /** Icon set selected by the footer `icons` setting. */
25
+ export type FooterGlyphMode = "nerd" | "unicode" | "ascii";
26
+
27
+ /**
28
+ * Theme color names accepted by {@link FooterRenderContext.style}.
29
+ * Matches the Pi `ThemeColor` names SuPi contributions use.
30
+ */
31
+ export type FooterColor = "accent" | "dim" | "muted" | "text" | "success" | "warning" | "error";
32
+
33
+ /** Render inputs supplied by the custom footer. */
34
+ export interface FooterRenderContext {
35
+ /** Apply a theme color. */
36
+ style: (color: FooterColor, text: string) => string;
37
+ /** Resolved icon mode; contributions choose matching glyphs. */
38
+ glyphMode: FooterGlyphMode;
39
+ }
16
40
 
17
41
  /** A single footer contribution registered by an extension. */
18
42
  export interface FooterContribution {
@@ -21,15 +45,18 @@ export interface FooterContribution {
21
45
  * A same-key Pi status is treated as this contribution's built-in-footer fallback.
22
46
  */
23
47
  key: string;
24
- /** Which footer line this belongs on. */
48
+ /** Which footer area this belongs to. */
25
49
  placement: FooterPlacement;
26
50
  /**
27
51
  * Sort order within the placement (lower values render further left). Default: 100.
28
52
  * Priority 0 is reserved for the turn cache-hit part so it stays adjacent to CH.
29
53
  */
30
54
  priority?: number;
31
- /** Return the pre-styled text for this contribution. Called on every render. */
32
- render: () => string;
55
+ /**
56
+ * Return the text for this contribution; empty hides it. Called on every render.
57
+ * Callers without a footer context (for example tests) may omit `ctx`.
58
+ */
59
+ render: (ctx?: FooterRenderContext) => string;
33
60
  }
34
61
 
35
62
  const registry = createRegistry<FooterContribution>("footer-contributions");
@@ -57,6 +84,11 @@ export const footerContributions = {
57
84
  .sort(sortByPriority);
58
85
  },
59
86
 
87
+ /** Get every registered contribution regardless of placement. */
88
+ getAll(): FooterContribution[] {
89
+ return registry.getAll();
90
+ },
91
+
60
92
  /** Remove all contributions (primarily for tests). */
61
93
  clear(): void {
62
94
  registry.clear();
@@ -57,3 +57,5 @@ export {
57
57
  getActiveBranchEntries,
58
58
  } from "./session-utils.ts";
59
59
  export { BSD_SED_HINT, BSD_SED_HINT_MARKER, registerShellHints } from "./shell-hints.ts";
60
+ export type { SideRunEvent } from "./side-run.ts";
61
+ export { runSideRun, SIDE_RUN_END_EVENT, SIDE_RUN_START_EVENT } from "./side-run.ts";
@@ -0,0 +1,46 @@
1
+ // Side-run signal shared over `pi.events`.
2
+ //
3
+ // A side run is agent work whose result the session will not continue from,
4
+ // such as a run on a branch that is abandoned afterwards. Listeners use the
5
+ // signal to skip work tied to the run's result, for example prompt suggestions.
6
+
7
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
8
+
9
+ /** Event emitted on `pi.events` when a side run starts. Payload: {@link SideRunEvent}. */
10
+ export const SIDE_RUN_START_EVENT = "supi:side-run:start";
11
+
12
+ /** Event emitted on `pi.events` when a side run ends. Payload: {@link SideRunEvent}. */
13
+ export const SIDE_RUN_END_EVENT = "supi:side-run:end";
14
+
15
+ /** Payload of {@link SIDE_RUN_START_EVENT} and {@link SIDE_RUN_END_EVENT}. */
16
+ export interface SideRunEvent {
17
+ /** Emitting package, such as `supi-debug`. */
18
+ readonly source: string;
19
+ }
20
+
21
+ /**
22
+ * Run `run` as a side run: emit {@link SIDE_RUN_START_EVENT} before it and
23
+ * {@link SIDE_RUN_END_EVENT} after it, also when it throws.
24
+ *
25
+ * After a session replacement or reload the captured `pi` is stale and its
26
+ * `events.emit` throws. That end signal is dropped instead of masking the
27
+ * run's result; listeners reset their side-run state on `session_start` and
28
+ * `session_shutdown`.
29
+ */
30
+ export async function runSideRun<T>(
31
+ pi: Pick<ExtensionAPI, "events">,
32
+ source: string,
33
+ run: () => Promise<T>,
34
+ ): Promise<T> {
35
+ const payload: SideRunEvent = { source };
36
+ pi.events.emit(SIDE_RUN_START_EVENT, payload);
37
+ try {
38
+ return await run();
39
+ } finally {
40
+ try {
41
+ pi.events.emit(SIDE_RUN_END_EVENT, payload);
42
+ } catch {
43
+ // Stale extension instance after session replacement; see JSDoc.
44
+ }
45
+ }
46
+ }
@@ -15,8 +15,8 @@ export interface SpillFileOptions {
15
15
  owner: string;
16
16
  /** Descriptive file name, e.g. `"snapshot.md"`. The content hash is inserted before the extension. */
17
17
  name: string;
18
- /** Full content to persist. */
19
- content: string;
18
+ /** Full content to persist: text (written as UTF-8) or raw bytes. */
19
+ content: string | Uint8Array;
20
20
  }
21
21
 
22
22
  const SEGMENT = /^[a-z0-9][a-z0-9-]*$/;
@@ -64,6 +64,8 @@ A configured route is not a ready server. Features depend on the active server,
64
64
 
65
65
  The [operation-support model](src/config/operation-support.ts) separates server advertisement from SuPi planning limits. A server can advertise an action that SuPi cannot safely turn into a plan.
66
66
 
67
+ A TypeScript server answers `workspace/symbol` from loaded projects only. One pass per TypeScript route opens one source file per project root (up to 96 roots). It starts in the background once the route is ready after startup; shutdown and a route restart abort it. While it runs, the route's `ProjectServerInfo` carries `loadingProjects: true` and `ready` is unchanged; a lifecycle transition is published when the pass starts and when it ends. The opened files stay tracked documents, so diagnostic refreshes include them even in a session that never runs a symbol query. A query that arrives during the pass waits for it, and a query that finds no recorded pass runs one for its scope before it collects. Later queries reuse the pass until the route restarts or a project config changes. A project config change during a pass leaves it unrecorded, and a query that ran that pass is partial. Roots past the limit and a native-server answer at its 256-row limit make the result partial; tsserver has no row limit. A cut answer that provably holds every declaration of the queried name (the server sorts exact names first) carries `metadata.rowLimit.exactNamesComplete: true`, so exact-name target selection stays possible; every row-limited result carries `metadata.rowLimit`. Other servers are warmed only until one row answers the request.
68
+
67
69
  Workspace-symbol scopes select contributing routes and bound query completeness; returned data can still contain out-of-scope rows, which consumers must filter. An automatic-policy exclusion does not make a scoped query partial when both its observed path and physical identity are proven outside every requested scope. In-scope exclusions, aliases that may overlap, unresolved paths, and contributing route failures remain partial. Unscoped queries retain all exclusion evidence. Partial metadata sets `exclusionOnly` when policy exclusions are the only gap, with no route failure or inferred-project coverage gap. Explicitly selected excluded files and directories remain inspectable; when a scoped query returns no row inside any scope, warm-up may open files inside those selected scopes so a server that only indexes opened documents can report them. Automatic path rules and target-uniqueness checks are unchanged.
68
70
 
69
71
  ### Reference-server acceptance
@@ -203,7 +205,7 @@ Refresh and file collection share synchronization, evidence-revision, deadline,
203
205
 
204
206
  Caller cancellation or deadline stops only that caller's wait. Explicit diagnostic requests use an owned transport lifetime: supersession drops queued jobs and stops future adapter phases but does not cancel an active protocol request. The route stays occupied until actual settlement or connection disposal. The owner timeout attempts protocol cancellation but does not prove that the backend stopped. The owner bound is at least 30 seconds (or a larger collection budget). A result from an obsolete document generation is discarded. Ordinary semantic requests still pass caller cancellation to the protocol transport.
205
207
 
206
- First document enrollment is admitted between semantic query and refactor-planning attempts on the same current client. Each attempt covers input synchronization, its RPCs, and final acceptance; reads can still run concurrently. A refactor attempt retains admission through `prepareRename`/`rename` or `codeAction`/`resolve` and verified snapshot capture, but releases it before retries and the rename workflow's own cross-file enrollment. FIFO admission prevents later reads from overtaking a waiting first open. At most 32 operations may wait; excess demand fails rather than growing an unbounded queue. Waiting preserves the caller's original signal and absolute deadline, and interrupted operations are removed before they can open a document. Disk content is read after admission. First opens for semantic or refactor demand also discard the caller's original parameters after a known input change; ordinary tracking can still adopt fresh content. Tracked-document updates, closes, workspace changes, and lifecycle invalidation do not wait: they still invalidate active evidence and discard queued request parameters. Closing a file cancels its queued opens, and stopping a client discards its queued work. Admission does not span retries, project warm-up, or whole tool/refactor workflows. Diagnostic transport ownership and confirmation remain separate and unchanged.
208
+ First document enrollment is admitted between semantic query and refactor-planning attempts on the same current client. Each attempt covers input synchronization, its RPCs, and final acceptance; reads can still run concurrently. A refactor attempt retains admission through `prepareRename`/`rename` or `codeAction`/`resolve` and verified snapshot capture, but releases it before retries and the rename workflow's own cross-file enrollment. FIFO admission prevents later reads from overtaking a waiting first open. At most 1,024 operations may wait; excess demand fails rather than growing an unbounded queue, and the query result names that cause. First opens dispatch one at a time, so the bound limits waiting memory, not server load. Waiting preserves the caller's original signal and absolute deadline, and interrupted operations are removed before they can open a document. Disk content is read after admission. First opens for semantic or refactor demand also discard the caller's original parameters after a known input change; ordinary tracking can still adopt fresh content. Tracked-document updates, closes, workspace changes, and lifecycle invalidation do not wait: they still invalidate active evidence and discard queued request parameters. Closing a file cancels its queued opens, and stopping a client discards its queued work. Admission does not span retries, project warm-up, or whole tool/refactor workflows. Diagnostic transport ownership and confirmation remain separate and unchanged.
207
209
 
208
210
  If another request first opens a document during an active semantic or diagnostic request, the client can synchronize and repeat the request once. The retry retains the caller's original signal and deadline. Content, workspace, close, and lifecycle changes still reject stale results. A diagnostic retry collects new request evidence; it does not promote an old cache. This retry is not route recovery. A second enrollment during the retry still rejects the result. Semantic failure reasons state whether the retry failed or was exhausted. The bounded `request.retry` debug event records the retry reason and outcome with the public call's opaque operation ID, when supplied. A completed RPC alone does not establish accepted semantic evidence.
209
211
 
@@ -377,7 +379,9 @@ Retained and persisted LSP debug events may identify local workspaces, servers,
377
379
  - `method` — exact LSP method, e.g. `textDocument/hover`
378
380
  - `root` — server root, absolute where present
379
381
 
380
- `runtime.transition` events carry `cwd` and a bounded `servers` array (name, status, ready, and an optional process-crash status reason; at most 16 entries) alongside the aggregate counts. `readiness.*` events carry `cwd`, `server`, and `root`; their messages and data never embed raw progress-token values. `request.timing` events carry the exact `method`, `server`, and `cwd`, plus the JSON-RPC error code: the server-reported code for failed requests, and the defined constant `-32095` (`LSP_REQUEST_TIMEOUT_ERROR_CODE`) for local timeouts; cancellations carry no code. `diagnostics.timing` events carry `cwd`, `server`, and a workspace-relative `file` for `sync-file` operations; `refresh-open` stays aggregate. Their `collection` value identifies the source, such as `pull`, `typescript`, `mixed`, or `push`. `diagnostics.publication` keeps bounded publication counts for observation; a count or late publication does not promote confirmation. `runtime.recovery` events carry `cwd`, bounded server and route-root identity, an outcome, and elapsed time for process-crash recovery. Diagnostic recovery events keep their existing bounded attempted/restarted server names. `capability.transition` events fire only on semantic ready↔pending transitions and carry `cwd` and the ready state — never for initialize, registration, or unregistration traffic. Code-intelligence events (`code-operation.*`, `workflow.timing`, `ast-scan.timing`) carry `cwd` only.
382
+ `runtime.transition` events carry `cwd` and a bounded `servers` array (name, status, ready, and an optional process-crash status reason; at most 16 entries) alongside the aggregate counts. `readiness.*` events carry `cwd`, `server`, and `root`; their messages and data never embed raw progress-token values. `request.timing` events carry the exact `method`, `server`, and `cwd`, plus the JSON-RPC error code: the server-reported code for failed requests, and the defined constant `-32095` (`LSP_REQUEST_TIMEOUT_ERROR_CODE`) for local timeouts; cancellations carry no code. Batch operations do not record one `request.timing` event per completed request: a `refresh-open` diagnostic pass and an all-roots workspace-symbol warm-up pass report their completed requests as `requests` on their own event, keyed by method with `count`, `totalMs`, and `maxMs`. Their failed, timed-out, and cancelled requests still record individual `request.timing` events. `diagnostics.timing` events carry `cwd`, `server`, and a workspace-relative `file` for `sync-file` operations; `refresh-open` stays aggregate. Their `collection` value identifies the source, such as `pull`, `typescript`, `mixed`, or `push`. `diagnostics.publication` keeps bounded publication counts for observation; a count or late publication does not promote confirmation. `runtime.recovery` events carry `cwd`, bounded server and route-root identity, an outcome, and elapsed time for process-crash recovery. Diagnostic recovery events keep their existing bounded attempted/restarted server names. `capability.transition` events fire only on semantic ready↔pending transitions and carry `cwd` and the ready state — never for initialize, registration, or unregistration traffic. Code-intelligence events (`code-operation.*`, `workflow.timing`, `ast-scan.timing`) carry `cwd` only.
383
+
384
+ `document.open-failed` is a `warning` recorded when a routed client could not open a file, with `server`, a workspace-relative `file`, and the bounded `reason` (for example a full input admission queue); the caller only receives an unavailable result. `workspace-symbol.warm-pass` is an `info` summary of one all-roots warm-up pass: `server`, `roots`, `loadedRoots`, `inferredProbes`, `failedProbes`, `limited`, `elapsedMs`, and `requests`. Per-file `workspace-symbol.warm-probe` events stay at `debug` level and are not persisted; an all-roots pass records them only for probes that did not load a root (`open-failed`, `probe-unavailable`, `inferred`, `excluded`). `excluded` is a native TypeScript probe of a file its nearest project config excludes; the summary counts it under `inferredProbes`. The pass publishes one `tracked-files` `runtime.transition` for all files it opened, not one per file.
381
385
 
382
386
  `ProjectServerInfo.statusReason` is present only for process-crash recovery states: `process-crashed`, `process-crash-recovery-pending`, or `process-crash-recovery-exhausted`. An LSP route is one configured server and workspace root. A route stays in `error` status for all three states.
383
387
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,16 @@ export interface CodeQueryPartialMetadata {
14
14
  * answer.
15
15
  */
16
16
  readonly exclusionOnly?: boolean;
17
+ /** A provider cut its answer at a row limit; a narrower scope cannot avoid it. */
18
+ readonly rowLimit?: {
19
+ /**
20
+ * True when every declaration whose name equals the query is still in the
21
+ * result, though partial-name matches may be missing: the provider sorted
22
+ * exact names first. Set only when no provider failed and no coverage gap
23
+ * was observed, so exact-name selection stays sound.
24
+ */
25
+ readonly exactNamesComplete: boolean;
26
+ };
17
27
  }
18
28
 
19
29
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -16,7 +16,10 @@ export interface DebugRegistryConfig {
16
16
  agentAccess: DebugAgentAccess;
17
17
  /** Whether Agent Run retrospective capture is explicitly enabled. */
18
18
  agentRunRetrospectivesEnabled: boolean;
19
- /** Maximum number of session-local events to keep in memory. */
19
+ /**
20
+ * Maximum number of session-local events to keep in memory. `debug` events
21
+ * are evicted first; higher levels keep at most half of the buffer.
22
+ */
20
23
  maxEvents: number;
21
24
  /**
22
25
  * Minimum level forwarded to persistence sinks. Lower-level events stay in the
@@ -146,12 +149,51 @@ function normalizeMaxEvents(value: number): number {
146
149
  return Math.floor(value);
147
150
  }
148
151
 
152
+ function isSummary(event: DebugEvent): boolean {
153
+ return event.level !== "debug";
154
+ }
155
+
156
+ function groupKey(event: DebugEvent): string {
157
+ return `${event.source}\u0000${event.category}`;
158
+ }
159
+
160
+ /**
161
+ * Return the index of the oldest event in the largest source/category group of
162
+ * one tier, so a high-volume category evicts its own events before rare ones.
163
+ */
164
+ function evictionIndex(events: readonly DebugEvent[], summaryTier: boolean): number {
165
+ const counts = new Map<string, number>();
166
+ let largest = 0;
167
+ for (const event of events) {
168
+ if (isSummary(event) !== summaryTier) continue;
169
+ const key = groupKey(event);
170
+ const count = (counts.get(key) ?? 0) + 1;
171
+ counts.set(key, count);
172
+ largest = Math.max(largest, count);
173
+ }
174
+ return events.findIndex(
175
+ (event) => isSummary(event) === summaryTier && counts.get(groupKey(event)) === largest,
176
+ );
177
+ }
178
+
179
+ /**
180
+ * Evict down to `maxEvents`. A `debug` event goes first, so high-volume
181
+ * timings cannot push out a summary recorded moments earlier. Higher-level
182
+ * events keep at most half the buffer; past that one of them goes instead, so
183
+ * recent `debug` events stay visible too. Within the chosen tier, the oldest
184
+ * event of the largest source/category group goes, so one flooding category
185
+ * such as `request.timing` cannot push out every other category.
186
+ */
149
187
  function trimToMaxEvents(state: DebugRegistryState): void {
150
188
  const maxEvents = normalizeMaxEvents(state.config.maxEvents);
151
- if (state.events.length <= maxEvents) {
152
- return;
189
+ const summaryShare = Math.floor(maxEvents / 2);
190
+ let summaries = state.events.filter(isSummary).length;
191
+ while (state.events.length > maxEvents) {
192
+ const evictSummary = summaries > summaryShare;
193
+ const index = evictionIndex(state.events, evictSummary);
194
+ if (evictSummary) summaries--;
195
+ state.events.splice(Math.max(index, 0), 1);
153
196
  }
154
- state.events.splice(0, state.events.length - maxEvents);
155
197
  }
156
198
 
157
199
  /** Return whether a debug level is recognized by the registry. */
@@ -226,18 +268,22 @@ export function isDebugRegistryEnabled(): boolean {
226
268
  }
227
269
 
228
270
  /**
229
- * Return whether a retrospective can be captured: Debug and its explicit opt-in
271
+ * Return whether an event at `level` would reach the session file now: Debug
230
272
  * must be enabled, at least one persistence sink must be registered, and the
231
- * persistence threshold must admit `info` events.
273
+ * persistence threshold must admit the level.
232
274
  */
233
- export function canRecordAgentRunRetrospective(): boolean {
275
+ export function canPersistDebugEvent(level: DebugLevel = "info"): boolean {
234
276
  const state = getState();
235
- return (
236
- state.config.enabled &&
237
- state.config.agentRunRetrospectivesEnabled &&
238
- state.persistenceSinks.size > 0 &&
239
- shouldPersist(state, "info")
240
- );
277
+ return state.config.enabled && state.persistenceSinks.size > 0 && shouldPersist(state, level);
278
+ }
279
+
280
+ /**
281
+ * Return whether a retrospective can be captured: an `info` event must be
282
+ * persistable (see {@link canPersistDebugEvent}) and the explicit Agent Run
283
+ * retrospective opt-in must be enabled.
284
+ */
285
+ export function canRecordAgentRunRetrospective(): boolean {
286
+ return getState().config.agentRunRetrospectivesEnabled && canPersistDebugEvent("info");
241
287
  }
242
288
 
243
289
  /** Best-effort redaction helper for data exposed through sanitized debug views. */
@@ -1,9 +1,8 @@
1
1
  // Shared footer contribution registry for SuPi extensions.
2
2
  //
3
- // Extensions register pre-styled text chunks with a placement hint
4
- // ("stats" for the metrics line, "status" for the extension status line).
5
- // The custom footer in supi-extras reads these contributions and renders them
6
- // alongside the built-in metrics. Extensions can use PI's status API as a
3
+ // Extensions register text chunks with a placement hint. The custom footer in
4
+ // supi-extras reads these contributions and renders them alongside the
5
+ // built-in metrics. Extensions can use PI's status API with the same key as a
7
6
  // fallback when the custom footer is not installed.
8
7
 
9
8
  import { createRegistry } from "./registry-utils.ts";
@@ -11,8 +10,33 @@ import { createRegistry } from "./registry-utils.ts";
11
10
  /** Event emitted when a dynamic footer contribution needs a new render. */
12
11
  export const FOOTER_INVALIDATE_EVENT = "supi:footer:invalidate";
13
12
 
14
- /** Where the contribution should appear in the footer. */
15
- export type FooterPlacement = "stats" | "stats-end" | "status";
13
+ /**
14
+ * Where the contribution should appear in the footer.
15
+ *
16
+ * - `path-end`: right side of the workspace line (path and Git), for workspace state
17
+ * - `stats`: inside the cache section of the session line
18
+ * - `stats-end`: own sections after context usage on the session line
19
+ * - `model-start`: right side of the session line, before the model name
20
+ * - `status`: extension status line below the footer
21
+ */
22
+ export type FooterPlacement = "path-end" | "stats" | "stats-end" | "model-start" | "status";
23
+
24
+ /** Icon set selected by the footer `icons` setting. */
25
+ export type FooterGlyphMode = "nerd" | "unicode" | "ascii";
26
+
27
+ /**
28
+ * Theme color names accepted by {@link FooterRenderContext.style}.
29
+ * Matches the Pi `ThemeColor` names SuPi contributions use.
30
+ */
31
+ export type FooterColor = "accent" | "dim" | "muted" | "text" | "success" | "warning" | "error";
32
+
33
+ /** Render inputs supplied by the custom footer. */
34
+ export interface FooterRenderContext {
35
+ /** Apply a theme color. */
36
+ style: (color: FooterColor, text: string) => string;
37
+ /** Resolved icon mode; contributions choose matching glyphs. */
38
+ glyphMode: FooterGlyphMode;
39
+ }
16
40
 
17
41
  /** A single footer contribution registered by an extension. */
18
42
  export interface FooterContribution {
@@ -21,15 +45,18 @@ export interface FooterContribution {
21
45
  * A same-key Pi status is treated as this contribution's built-in-footer fallback.
22
46
  */
23
47
  key: string;
24
- /** Which footer line this belongs on. */
48
+ /** Which footer area this belongs to. */
25
49
  placement: FooterPlacement;
26
50
  /**
27
51
  * Sort order within the placement (lower values render further left). Default: 100.
28
52
  * Priority 0 is reserved for the turn cache-hit part so it stays adjacent to CH.
29
53
  */
30
54
  priority?: number;
31
- /** Return the pre-styled text for this contribution. Called on every render. */
32
- render: () => string;
55
+ /**
56
+ * Return the text for this contribution; empty hides it. Called on every render.
57
+ * Callers without a footer context (for example tests) may omit `ctx`.
58
+ */
59
+ render: (ctx?: FooterRenderContext) => string;
33
60
  }
34
61
 
35
62
  const registry = createRegistry<FooterContribution>("footer-contributions");
@@ -57,6 +84,11 @@ export const footerContributions = {
57
84
  .sort(sortByPriority);
58
85
  },
59
86
 
87
+ /** Get every registered contribution regardless of placement. */
88
+ getAll(): FooterContribution[] {
89
+ return registry.getAll();
90
+ },
91
+
60
92
  /** Remove all contributions (primarily for tests). */
61
93
  clear(): void {
62
94
  registry.clear();
@@ -57,3 +57,5 @@ export {
57
57
  getActiveBranchEntries,
58
58
  } from "./session-utils.ts";
59
59
  export { BSD_SED_HINT, BSD_SED_HINT_MARKER, registerShellHints } from "./shell-hints.ts";
60
+ export type { SideRunEvent } from "./side-run.ts";
61
+ export { runSideRun, SIDE_RUN_END_EVENT, SIDE_RUN_START_EVENT } from "./side-run.ts";