@mrclrchtr/supi-code-intelligence 11.1.0 → 11.3.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 (199) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +41 -6
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  6. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  8. package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +81 -7
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  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/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  61. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  62. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  63. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  64. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  67. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  68. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  69. package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
  70. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +11 -4
  71. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +77 -6
  72. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-input-admission.ts +149 -0
  73. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-typescript-project.ts +40 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +174 -49
  75. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  76. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  77. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  78. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  79. package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +2 -2
  80. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  81. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +157 -23
  82. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +306 -75
  83. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  84. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  85. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +19 -2
  86. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +1 -0
  87. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  88. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +5 -1
  89. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +2 -2
  90. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  91. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +3 -1
  92. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +9 -0
  93. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  94. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
  95. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
  96. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  97. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  98. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  99. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  100. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  101. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +40 -25
  102. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +2 -0
  103. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/call-context.ts +44 -0
  104. package/package.json +6 -5
  105. package/src/analysis/capability/capability-warnings.ts +18 -12
  106. package/src/analysis/health/check.ts +115 -0
  107. package/src/analysis/health/diagnostics.ts +3 -0
  108. package/src/analysis/health/file-scope.ts +2 -3
  109. package/src/analysis/health/semantic-state.ts +38 -0
  110. package/src/analysis/health/server-status.ts +14 -2
  111. package/src/analysis/health/signals.ts +2 -0
  112. package/src/analysis/health/status.ts +82 -0
  113. package/src/analysis/refactor/apply.ts +17 -8
  114. package/src/analysis/search/exclusions.ts +47 -0
  115. package/src/analysis/search/paths.ts +32 -9
  116. package/src/analysis/target/anchored-structural.ts +3 -8
  117. package/src/analysis/target/anchored.ts +4 -20
  118. package/src/analysis/target/identity.ts +1 -1
  119. package/src/analysis/target/latex-label-container.ts +6 -6
  120. package/src/analysis/target/latex-section-anchor.ts +6 -6
  121. package/src/analysis/target/resolution.ts +18 -0
  122. package/src/analysis/target/symbol.ts +39 -11
  123. package/src/analysis/target/types.ts +6 -1
  124. package/src/extension.ts +17 -11
  125. package/src/session/graph/collect.ts +1 -10
  126. package/src/session/graph-types.ts +2 -0
  127. package/src/session/graph-workflow.ts +1 -0
  128. package/src/session/health-types.ts +7 -0
  129. package/src/session/health-workflow.ts +8 -43
  130. package/src/session/inspect/collect.ts +8 -2
  131. package/src/session/inspect/file-point.ts +2 -3
  132. package/src/session/inspect-workflow.ts +1 -1
  133. package/src/session/orientation/collect.ts +184 -20
  134. package/src/session/orientation/context-facts.ts +27 -2
  135. package/src/session/orientation/context-sections.ts +49 -3
  136. package/src/session/orientation/facts.ts +132 -0
  137. package/src/session/orientation/gather.ts +98 -11
  138. package/src/session/orientation/workspace-context.ts +16 -6
  139. package/src/session/orientation-types.ts +8 -0
  140. package/src/session/orientation-workflow.ts +20 -6
  141. package/src/session/refactor-identity.ts +76 -0
  142. package/src/session/refactor-plans.ts +5 -2
  143. package/src/session/refactor-workflow.ts +15 -17
  144. package/src/session/target-store.ts +3 -18
  145. package/src/session/target-workflow.ts +33 -16
  146. package/src/substrate/lsp/recovery.ts +5 -5
  147. package/src/tool/code_find/guidance.ts +1 -1
  148. package/src/tool/code_find/render.ts +8 -4
  149. package/src/tool/code_find/result.ts +78 -6
  150. package/src/tool/code_find/spec.ts +4 -3
  151. package/src/tool/code_find/structured.ts +25 -9
  152. package/src/tool/code_graph/details.ts +1 -0
  153. package/src/tool/code_graph/display.ts +1 -1
  154. package/src/tool/code_graph/guidance.ts +1 -1
  155. package/src/tool/code_graph/markdown.ts +11 -6
  156. package/src/tool/code_graph/read-next.ts +38 -9
  157. package/src/tool/code_graph/reference-selection.ts +30 -0
  158. package/src/tool/code_graph/result.ts +25 -118
  159. package/src/tool/code_graph/section.ts +133 -0
  160. package/src/tool/code_graph/spec.ts +3 -3
  161. package/src/tool/code_graph/structured.ts +17 -6
  162. package/src/tool/code_health/display-paths.ts +92 -0
  163. package/src/tool/code_health/file-scope-markdown.ts +3 -2
  164. package/src/tool/code_health/markdown.ts +12 -2
  165. package/src/tool/code_health/result.ts +18 -3
  166. package/src/tool/code_health/spec.ts +5 -3
  167. package/src/tool/code_health/structured-schema.ts +250 -0
  168. package/src/tool/code_health/structured.ts +256 -0
  169. package/src/tool/code_inspect/result.ts +11 -5
  170. package/src/tool/code_inspect/spec.ts +7 -1
  171. package/src/tool/code_inspect/structured.ts +231 -0
  172. package/src/tool/code_orientation/execute.ts +1 -1
  173. package/src/tool/code_orientation/result.ts +31 -8
  174. package/src/tool/code_orientation/spec.ts +2 -0
  175. package/src/tool/code_orientation/structured-schema.ts +617 -0
  176. package/src/tool/code_orientation/structured-workspace.ts +194 -0
  177. package/src/tool/code_orientation/structured.ts +189 -0
  178. package/src/tool/code_orientation/workspace-format.ts +2 -5
  179. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  180. package/src/tool/code_orientation/workspace-output.ts +5 -0
  181. package/src/tool/code_orientation/workspace-projects.ts +16 -31
  182. package/src/tool/code_orientation/workspace-sections.ts +46 -32
  183. package/src/tool/code_refactor_apply/execute.ts +1 -1
  184. package/src/tool/code_refactor_apply/result.ts +14 -6
  185. package/src/tool/code_refactor_apply/spec.ts +2 -0
  186. package/src/tool/code_refactor_apply/structured.ts +49 -0
  187. package/src/tool/code_refactor_plan/result.ts +18 -9
  188. package/src/tool/code_refactor_plan/spec.ts +2 -0
  189. package/src/tool/code_refactor_plan/structured.ts +127 -0
  190. package/src/tool/code_resolve/markdown.ts +6 -30
  191. package/src/tool/code_resolve/result.ts +24 -11
  192. package/src/tool/code_resolve/structured.ts +7 -9
  193. package/src/tool/result/refactor.ts +8 -5
  194. package/src/tool/result/structured.ts +8 -5
  195. package/src/tool/result/types.ts +18 -14
  196. package/src/tool/schemas.ts +12 -6
  197. package/src/ui/status-command.ts +147 -322
  198. package/src/ui/status-overlay.ts +584 -421
  199. package/src/ui/status-presentation.ts +108 -0
@@ -1,31 +1,16 @@
1
- // Code Intelligence status command — toggleable center dialog with persistent
2
- // status bar, custom footer, and below-editor widget for LSP + structural awareness.
3
-
4
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
5
- import { truncateToWidth } from "@earendil-works/pi-tui";
6
2
  import { getDefaultWorkspaceRuntime } from "@mrclrchtr/supi-code-runtime/api";
7
- import {
8
- type AutomaticLspPathPolicy,
9
- getWorkspaceLspRuntime,
10
- type WorkspaceLspRuntimeState,
11
- } from "@mrclrchtr/supi-lsp/api";
12
- import {
13
- type CapabilityWarningMissingServerSource,
14
- evaluateCapabilityWarnings,
15
- gatherCapabilityWarningInput,
16
- } from "../analysis/capability/capability-warnings.ts";
17
- import { countProjectServerRouteStatuses } from "../analysis/health/server-status.ts";
18
- import { type CiStatusData, createCiStatusDialog } from "./status-overlay.ts";
19
-
20
- const STATUS_KEY = "code-intelligence";
21
- const WIDGET_KEY = "code-intelligence";
22
-
23
- interface InspectorState {
24
- handle: unknown;
25
- close: (() => void) | null;
26
- }
27
-
28
- /** Owned LSP facts used by the status warning collector. */
3
+ import { type AutomaticLspPathPolicy, getWorkspaceLspRuntime } from "@mrclrchtr/supi-lsp/api";
4
+ import type { CapabilityWarningMissingServerSource } from "../analysis/capability/capability-warnings.ts";
5
+ import { checkWorkspaceDiagnostics } from "../analysis/health/check.ts";
6
+ import { observeWorkspaceStatus } from "../analysis/health/status.ts";
7
+ import type { WorkspaceCodeIntelligenceSession } from "../session/session.ts";
8
+ import { throwIfAborted } from "../session/workflow-control.ts";
9
+ import { DEFAULT_WORKFLOW_DEADLINE_MS } from "../tool/infra/workflow-control.ts";
10
+ import { type CiStatusDialog, createCiStatusDialog } from "./status-overlay.ts";
11
+ import { CiHealthRefreshError, presentHealthRefresh } from "./status-presentation.ts";
12
+
13
+ /** Owned LSP facts used by the passive status warning collector. */
29
14
  export interface CiStatusWarningSource {
30
15
  get(cwd: string): {
31
16
  lspController: CapabilityWarningMissingServerSource | null;
@@ -33,317 +18,157 @@ export interface CiStatusWarningSource {
33
18
  };
34
19
  }
35
20
 
36
- /** Register the interactive /supi-ci-status overlay command. */
21
+ async function collectStatusData(
22
+ pi: ExtensionAPI,
23
+ ctx: ExtensionContext,
24
+ homeDir?: string,
25
+ warningSource?: CiStatusWarningSource,
26
+ ) {
27
+ const workspace = getDefaultWorkspaceRuntime().getWorkspace(ctx.cwd);
28
+ const facts = warningSource?.get(ctx.cwd);
29
+ return {
30
+ ...(await observeWorkspaceStatus({
31
+ cwd: ctx.cwd,
32
+ lspState: getWorkspaceLspRuntime(ctx.cwd),
33
+ semanticState: workspace.semantic.state,
34
+ structuralState: workspace.structural.state,
35
+ projectTrusted: ctx.isProjectTrusted(),
36
+ homeDir,
37
+ lspController: facts?.lspController,
38
+ automaticPathPolicy: facts?.automaticPathPolicy,
39
+ })),
40
+ activeTools: pi.getActiveTools().filter((tool) => tool.startsWith("code_")),
41
+ };
42
+ }
43
+
44
+ function readDiagnosticDetails(cwd: string) {
45
+ const lsp = getWorkspaceLspRuntime(cwd);
46
+ if (lsp.kind !== "ready") throw new Error("LSP diagnostics are unavailable");
47
+ return lsp.runtime.getOutstandingDiagnostics(2);
48
+ }
49
+
50
+ interface StatusInteraction {
51
+ cancelled: boolean;
52
+ close?: () => void;
53
+ dialog?: CiStatusDialog;
54
+ }
55
+
56
+ /** Register the terminal inspector. Persistent footer contributions have a separate owner. */
37
57
  export function registerCiStatusCommand(
38
58
  pi: ExtensionAPI,
39
59
  homeDir?: string,
40
60
  warningSource?: CiStatusWarningSource,
61
+ getSession?: (ctx: ExtensionContext) => Pick<WorkspaceCodeIntelligenceSession, "health">,
41
62
  ): void {
42
- const inspector: InspectorState = { handle: null, close: null };
63
+ let interaction: StatusInteraction | undefined;
64
+ const close = () => {
65
+ if (!interaction) return;
66
+ interaction.cancelled = true;
67
+ interaction.dialog?.dispose();
68
+ interaction.close?.();
69
+ };
70
+ pi.on("session_shutdown", close);
71
+ pi.on("session_start", close);
72
+
43
73
  pi.registerCommand("supi-ci-status", {
44
- description: "Toggle code intelligence status — LSP and structural analysis state",
45
- handler: async (_args: string, ctx: ExtensionContext) => {
46
- if (inspector.close) {
47
- inspector.close();
74
+ description:
75
+ "Toggle diagnostic evidence inspector with explicit check and health refresh actions",
76
+ handler: async (_args, ctx) => {
77
+ if (ctx.mode !== "tui") {
78
+ ctx.ui.notify(
79
+ "The status inspector requires a terminal UI. Use code_health instead.",
80
+ "warning",
81
+ );
48
82
  return;
49
83
  }
50
-
51
- const dataRef = {
52
- current: await gatherCiStatusData({
53
- cwd: ctx.cwd,
54
- pi,
55
- projectTrusted: ctx.isProjectTrusted(),
56
- homeDir,
57
- warningSource,
58
- }),
84
+ if (interaction) {
85
+ close();
86
+ return;
87
+ }
88
+ const current: StatusInteraction = { cancelled: false };
89
+ interaction = current;
90
+ const observe = () => collectStatusData(pi, ctx, homeDir, warningSource);
91
+ let checkOffset = 0;
92
+ const check = async (signal: AbortSignal) => {
93
+ const lsp = getWorkspaceLspRuntime(ctx.cwd);
94
+ if (lsp.kind !== "ready")
95
+ throw new Error(`LSP runtime is ${lsp.kind}; diagnostics cannot be checked.`);
96
+ pi.events.emit("supi:working:start", { source: "supi-code-intelligence" });
97
+ try {
98
+ const diagnosticCheck = await checkWorkspaceDiagnostics({
99
+ runtime: lsp.runtime,
100
+ cwd: ctx.cwd,
101
+ offset: checkOffset,
102
+ control: { signal, deadline: Date.now() + 30_000 },
103
+ });
104
+ throwIfAborted({ signal });
105
+ const snapshot = await observe();
106
+ checkOffset = diagnosticCheck.nextOffset;
107
+ return { ...snapshot, diagnosticCheck };
108
+ } finally {
109
+ pi.events.emit("supi:working:end", { source: "supi-code-intelligence" });
110
+ }
59
111
  };
60
- updateStatusAndWidget(ctx, dataRef.current);
61
-
62
- // Custom footer while overlay is open — reads latest data via ref
63
- ctx.ui.setFooter((_tui, _theme) => ({
64
- render(width: number): string[] {
65
- return [truncateFooterLine(renderFooterLine(ctx, dataRef.current), width)];
66
- },
67
- invalidate(): void {},
68
- }));
69
-
70
- void ctx.ui
71
- .custom<void>(
72
- (tui, theme, _kb, done) => {
73
- inspector.close = () => done(undefined);
74
- return createCiStatusDialog(dataRef.current, {
75
- theme: theme as unknown as import("./status-overlay.ts").CiDialogTheme,
76
- done: () => done(undefined),
112
+ const refreshHealth = async (signal: AbortSignal) => {
113
+ const startedAt = Date.now();
114
+ const control = { signal, deadline: startedAt + DEFAULT_WORKFLOW_DEADLINE_MS };
115
+ let stage = "health workflow";
116
+ let healthRefresh: readonly string[] | undefined;
117
+ pi.events.emit("supi:working:start", { source: "supi-code-intelligence" });
118
+ try {
119
+ if (!getSession) throw new Error("Session health workflow is unavailable");
120
+ const outcome = await getSession(ctx).health(
121
+ { refresh: true, include: ["diagnostics", "servers"] },
122
+ control,
123
+ );
124
+ throwIfAborted(control);
125
+ healthRefresh = presentHealthRefresh(outcome, Date.now() - startedAt, ctx.cwd);
126
+ stage = "passive snapshot";
127
+ const snapshot = await observe();
128
+ throwIfAborted(control);
129
+ return { ...snapshot, healthRefresh };
130
+ } catch (error) {
131
+ throw new CiHealthRefreshError(stage, {
132
+ cause: error,
133
+ elapsedMs: Date.now() - startedAt,
134
+ healthRefresh,
135
+ });
136
+ } finally {
137
+ pi.events.emit("supi:working:end", { source: "supi-code-intelligence" });
138
+ }
139
+ };
140
+ try {
141
+ const data = await observe();
142
+ if (current.cancelled) return;
143
+ await ctx.ui.custom<void>(
144
+ (tui, theme, keybindings, done) => {
145
+ current.close = () => done(undefined);
146
+ const dialog = createCiStatusDialog(data, {
77
147
  tui,
78
- fetchDetailedDiagnostics: async (maxSeverity) => {
79
- const lspState = getWorkspaceLspRuntime(ctx.cwd);
80
- if (lspState.kind !== "ready") return [];
81
- return lspState.runtime.getOutstandingDiagnostics(maxSeverity).entries;
82
- },
83
- onRefresh: async () => {
84
- const fresh = await gatherCiStatusData({
85
- cwd: ctx.cwd,
86
- pi,
87
- projectTrusted: ctx.isProjectTrusted(),
88
- homeDir,
89
- warningSource,
90
- });
91
- dataRef.current = fresh;
92
- updateStatusAndWidget(ctx, fresh);
93
- return fresh;
94
- },
148
+ theme,
149
+ keybindings,
150
+ done: current.close,
151
+ onRefresh: observe,
152
+ onCheck: check,
153
+ onHealth: refreshHealth,
154
+ fetchDetailedDiagnostics: () => readDiagnosticDetails(ctx.cwd),
95
155
  });
156
+ current.dialog = dialog;
157
+ if (current.cancelled) current.close();
158
+ return dialog;
96
159
  },
97
160
  {
98
161
  overlay: true,
99
- overlayOptions: {
100
- anchor: "center",
101
- width: "66%",
102
- minWidth: 60,
103
- maxHeight: "85%",
104
- visible: (termWidth: number) => termWidth >= 60,
105
- },
106
- onHandle: (handle) => {
107
- inspector.handle = handle;
108
- },
162
+ overlayOptions: { anchor: "center", width: "85%", maxHeight: "85%" },
109
163
  },
110
- )
111
- .finally(() => {
112
- inspector.handle = null;
113
- inspector.close = null;
114
- clearStatusAndWidget(ctx);
115
- ctx.ui.setFooter(undefined);
116
- });
164
+ );
165
+ } catch (error) {
166
+ if (!current.cancelled)
167
+ ctx.ui.notify(`Unable to open code intelligence status: ${String(error)}`, "error");
168
+ } finally {
169
+ current.dialog?.dispose();
170
+ if (interaction === current) interaction = undefined;
171
+ }
117
172
  },
118
173
  });
119
174
  }
120
-
121
- /** Inputs for one status dialog snapshot. */
122
- interface GatherCiStatusOptions {
123
- cwd: string;
124
- pi: ExtensionAPI;
125
- projectTrusted: boolean;
126
- homeDir?: string;
127
- warningSource?: CiStatusWarningSource;
128
- }
129
-
130
- /** Gather a snapshot of LSP and structural state for the dialog. */
131
- async function gatherCiStatusData(options: GatherCiStatusOptions): Promise<CiStatusData> {
132
- const { cwd, pi, projectTrusted, homeDir, warningSource } = options;
133
- const workspace = getDefaultWorkspaceRuntime().getWorkspace(cwd);
134
- const lspState = getWorkspaceLspRuntime(cwd);
135
- const serverInventoryAvailable = lspState.kind === "ready" || lspState.kind === "disabled";
136
- const servers = lspState.kind === "ready" ? lspState.runtime.getProjectServers() : [];
137
- const semanticAvailable = servers.some(
138
- (server) => server.status === "running" && server.ready === true,
139
- );
140
- const diagnosticSnapshot =
141
- lspState.kind === "ready" && semanticAvailable
142
- ? lspState.runtime.getOutstandingDiagnosticSummary(1)
143
- : { entries: [], current: false };
144
- const diagnostics = diagnosticSnapshot.entries;
145
- const semanticState = deriveSemanticCapabilityState(workspace, lspState, semanticAvailable);
146
-
147
- // Sort: errors desc, warnings desc, info desc, hints desc
148
- diagnostics.sort((a, b) => {
149
- if (b.errors !== a.errors) return b.errors - a.errors;
150
- if (b.warnings !== a.warnings) return b.warnings - a.warnings;
151
- if (b.information !== a.information) return b.information - a.information;
152
- return b.hints - a.hints;
153
- });
154
-
155
- const structState = workspace.structural.state;
156
- const structKind = structState.kind;
157
- const structReason = structState.kind === "unavailable" ? structState.reason : undefined;
158
-
159
- const activeTools = pi.getActiveTools().filter((t) => t.startsWith("code_"));
160
-
161
- // Evaluate current Capability Warnings from available data.
162
- const warningFacts = warningSource?.get(cwd);
163
- const capabilityWarnings = evaluateCapabilityWarnings(
164
- gatherCapabilityWarningInput(cwd, warningFacts?.lspController ?? null, {
165
- projectTrusted,
166
- homeDir,
167
- automaticPathPolicy: warningFacts?.automaticPathPolicy ?? undefined,
168
- }),
169
- );
170
-
171
- return {
172
- workspaceRoot: cwd,
173
- servers,
174
- diagnostics,
175
- serverInventoryAvailable,
176
- semanticAvailable,
177
- diagnosticSnapshotCurrent: diagnosticSnapshot.current,
178
- capabilities: {
179
- semantic: semanticState,
180
- structural: {
181
- kind: structKind,
182
- reason: structReason,
183
- providerAvailable: structState.kind === "ready",
184
- },
185
- refactorAvailable: workspace.semantic.refactorAvailable,
186
- },
187
- activeTools,
188
- capabilityWarnings: capabilityWarnings.hasWarnings ? capabilityWarnings : undefined,
189
- };
190
- }
191
-
192
- function deriveSemanticCapabilityState(
193
- workspace: {
194
- semantic: {
195
- state: { kind: string };
196
- provider: unknown | null;
197
- };
198
- },
199
- lspState: WorkspaceLspRuntimeState,
200
- semanticAvailable: boolean,
201
- ): CiStatusData["capabilities"]["semantic"] {
202
- if (lspState.kind === "ready") {
203
- return semanticAvailable
204
- ? {
205
- kind: "ready",
206
- providerAvailable: workspace.semantic.provider !== null,
207
- }
208
- : {
209
- kind: "pending",
210
- reason: "No active, ready project servers",
211
- providerAvailable: workspace.semantic.provider !== null,
212
- };
213
- }
214
- if (workspace.semantic.state.kind === "pending" || lspState.kind === "pending") {
215
- return {
216
- kind: "pending",
217
- providerAvailable: workspace.semantic.provider !== null,
218
- };
219
- }
220
- if (lspState.kind === "inactive") {
221
- return { kind: "inactive", providerAvailable: workspace.semantic.provider !== null };
222
- }
223
- if (lspState.kind === "disabled") {
224
- return {
225
- kind: "disabled",
226
- reason: "LSP is disabled in settings",
227
- providerAvailable: workspace.semantic.provider !== null,
228
- };
229
- }
230
- return {
231
- kind: workspace.semantic.state.kind,
232
- reason: "reason" in lspState ? lspState.reason : "No LSP service",
233
- providerAvailable: workspace.semantic.provider !== null,
234
- };
235
- }
236
-
237
- /** Render the custom footer line. */
238
- function renderFooterLine(ctx: ExtensionContext, data: CiStatusData): string {
239
- const t = ctx.ui.theme;
240
- const parts: string[] = [];
241
- const running = data.servers.filter((s) => s.status === "running").length;
242
- if (running > 0) {
243
- parts.push(
244
- t.fg("accent", "λ ci") + t.fg("dim", ` ${running} server${running === 1 ? "" : "s"}`),
245
- );
246
- }
247
- const totalErrors = data.diagnostics.reduce((sum, d) => sum + d.errors, 0);
248
- if (totalErrors > 0) {
249
- parts.push(t.fg("error", `${totalErrors} error${totalErrors === 1 ? "" : "s"}`));
250
- }
251
- const totalWarnings = data.diagnostics.reduce((sum, d) => sum + d.warnings, 0);
252
- if (totalWarnings > 0) {
253
- parts.push(t.fg("warning", `${totalWarnings} warning${totalWarnings === 1 ? "" : "s"}`));
254
- }
255
- addProjectServerRouteCounts(parts, data, t);
256
- const structKind = data.capabilities.structural.kind;
257
- if (structKind === "ready") parts.push(t.fg("success", "✓ ts"));
258
- if (parts.length === 0) return t.fg("dim", "CI — no data available");
259
- return parts.join(t.fg("dim", " "));
260
- }
261
-
262
- function addProjectServerRouteCounts(
263
- parts: string[],
264
- data: CiStatusData,
265
- theme: ExtensionContext["ui"]["theme"],
266
- ): void {
267
- const counts = countProjectServerRouteStatuses(data.servers);
268
- if (counts.recovering > 0) {
269
- parts.push(
270
- theme.fg(
271
- "warning",
272
- `${counts.recovering} route${counts.recovering === 1 ? "" : "s"} recovering`,
273
- ),
274
- );
275
- }
276
- if (counts.error > 0) {
277
- parts.push(theme.fg("error", `${counts.error} route error${counts.error === 1 ? "" : "s"}`));
278
- }
279
- if (counts.unavailable > 0) {
280
- parts.push(
281
- theme.fg(
282
- "warning",
283
- `${counts.unavailable} route${counts.unavailable === 1 ? "" : "s"} unavailable`,
284
- ),
285
- );
286
- }
287
- }
288
-
289
- function truncateFooterLine(line: string, width: number): string {
290
- return truncateToWidth(line, width, "…");
291
- }
292
-
293
- /** Update the persistent status bar and below-editor widget. */
294
- function updateStatusAndWidget(ctx: ExtensionContext, data: CiStatusData): void {
295
- const t = ctx.ui.theme;
296
-
297
- // Status bar: concise one-liner
298
- const parts: string[] = [t.fg("accent", "λ ci")];
299
- const runningServers = data.servers.filter((s) => s.status === "running").length;
300
- if (runningServers > 0) {
301
- parts.push(t.fg("dim", `${runningServers} server${runningServers === 1 ? "" : "s"}`));
302
- }
303
- const totalErrors = data.diagnostics.reduce((sum, d) => sum + d.errors, 0);
304
- if (totalErrors > 0) {
305
- parts.push(t.fg("error", `${totalErrors} error${totalErrors === 1 ? "" : "s"}`));
306
- }
307
- const totalWarnings = data.diagnostics.reduce((sum, d) => sum + d.warnings, 0);
308
- if (totalWarnings > 0) {
309
- parts.push(t.fg("warning", `${totalWarnings} warning${totalWarnings === 1 ? "" : "s"}`));
310
- }
311
- addProjectServerRouteCounts(parts, data, t);
312
- const structKind = data.capabilities.structural.kind;
313
- if (structKind === "ready") parts.push(t.fg("success", "✓ ts"));
314
-
315
- const statusText = parts.length > 1 ? parts.join(t.fg("dim", " · ")) : undefined;
316
- ctx.ui.setStatus(STATUS_KEY, statusText);
317
-
318
- // Widget (below editor) — top problem files
319
- if (data.diagnostics.length > 0) {
320
- const top = data.diagnostics.slice(0, 2);
321
- const fileLines = top.map((d) => {
322
- const counts: string[] = [];
323
- if (d.errors > 0) {
324
- counts.push(t.fg("error", `${d.errors} error${d.errors === 1 ? "" : "s"}`));
325
- }
326
- if (d.warnings > 0) {
327
- counts.push(t.fg("warning", `${d.warnings} warning${d.warnings === 1 ? "" : "s"}`));
328
- }
329
- return ` ${d.file} (${counts.join(", ")})`;
330
- });
331
- const more = data.diagnostics.length - top.length;
332
- const moreSuffix = more > 0 ? t.fg("dim", ` +${more} more`) : "";
333
- ctx.ui.setWidget(
334
- WIDGET_KEY,
335
- [
336
- t.fg("accent", `λ CI — ${data.diagnostics.length} files with issues`) + moreSuffix,
337
- ...fileLines,
338
- ],
339
- { placement: "belowEditor" },
340
- );
341
- } else {
342
- ctx.ui.setWidget(WIDGET_KEY, undefined);
343
- }
344
- }
345
-
346
- function clearStatusAndWidget(ctx: ExtensionContext): void {
347
- ctx.ui.setStatus(STATUS_KEY, undefined);
348
- ctx.ui.setWidget(WIDGET_KEY, undefined);
349
- }