@mrclrchtr/supi-code-intelligence 11.1.0 → 11.2.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 (123) hide show
  1. package/README.md +29 -4
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-lsp/README.md +42 -5
  5. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  7. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/LICENSE +15 -0
  8. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/README.md +680 -0
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/bin/semver.js +195 -0
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/comparator.js +143 -0
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/index.js +7 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +577 -0
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/semver.js +350 -0
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/clean.js +8 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/cmp.js +54 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/coerce.js +62 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-build.js +9 -0
  18. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare-loose.js +5 -0
  19. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/compare.js +7 -0
  20. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/diff.js +60 -0
  21. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/eq.js +5 -0
  22. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gt.js +5 -0
  23. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/gte.js +5 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/inc.js +21 -0
  25. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lt.js +5 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/lte.js +5 -0
  27. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/major.js +5 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/minor.js +5 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/neq.js +5 -0
  30. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/parse.js +18 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/patch.js +5 -0
  32. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/prerelease.js +8 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rcompare.js +5 -0
  34. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/rsort.js +5 -0
  35. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/satisfies.js +12 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/sort.js +5 -0
  37. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/truncate.js +48 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/functions/valid.js +8 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/index.js +93 -0
  40. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +37 -0
  41. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/debug.js +11 -0
  42. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/identifiers.js +29 -0
  43. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/lrucache.js +42 -0
  44. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/parse-options.js +17 -0
  45. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/re.js +223 -0
  46. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +78 -0
  47. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/preload.js +4 -0
  48. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/range.bnf +17 -0
  49. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/gtr.js +6 -0
  50. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/intersects.js +9 -0
  51. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/ltr.js +6 -0
  52. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/max-satisfying.js +27 -0
  53. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-satisfying.js +26 -0
  54. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/min-version.js +63 -0
  55. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/outside.js +82 -0
  56. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/simplify.js +49 -0
  57. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/subset.js +249 -0
  58. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/to-comparators.js +10 -0
  59. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/ranges/valid.js +13 -0
  60. package/node_modules/@mrclrchtr/supi-lsp/package.json +5 -3
  61. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +23 -5
  62. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +53 -2
  63. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +19 -4
  64. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +22 -0
  65. package/node_modules/@mrclrchtr/supi-lsp/src/config/typescript-launch.ts +276 -0
  66. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +22 -10
  67. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +52 -19
  68. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +4 -3
  69. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +2 -2
  70. package/node_modules/@mrclrchtr/supi-lsp/src/session/scanner.ts +27 -15
  71. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  72. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  73. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  74. package/package.json +5 -5
  75. package/src/analysis/capability/capability-warnings.ts +18 -12
  76. package/src/analysis/health/check.ts +115 -0
  77. package/src/analysis/health/diagnostics.ts +3 -0
  78. package/src/analysis/health/file-scope.ts +2 -3
  79. package/src/analysis/health/semantic-state.ts +38 -0
  80. package/src/analysis/health/server-status.ts +8 -0
  81. package/src/analysis/health/signals.ts +2 -0
  82. package/src/analysis/health/status.ts +82 -0
  83. package/src/analysis/refactor/apply.ts +17 -8
  84. package/src/session/health-types.ts +7 -0
  85. package/src/session/health-workflow.ts +8 -43
  86. package/src/session/orientation/collect.ts +138 -12
  87. package/src/session/orientation/context-facts.ts +27 -2
  88. package/src/session/orientation/context-sections.ts +47 -0
  89. package/src/session/orientation/facts.ts +124 -0
  90. package/src/session/orientation/gather.ts +98 -11
  91. package/src/session/orientation/workspace-context.ts +16 -6
  92. package/src/session/orientation-types.ts +5 -0
  93. package/src/session/orientation-workflow.ts +3 -2
  94. package/src/session/refactor-plans.ts +5 -2
  95. package/src/session/refactor-workflow.ts +4 -3
  96. package/src/tool/code_find/guidance.ts +1 -1
  97. package/src/tool/code_health/markdown.ts +12 -2
  98. package/src/tool/code_health/result.ts +15 -2
  99. package/src/tool/code_health/spec.ts +2 -0
  100. package/src/tool/code_health/structured-schema.ts +250 -0
  101. package/src/tool/code_health/structured.ts +256 -0
  102. package/src/tool/code_inspect/result.ts +11 -5
  103. package/src/tool/code_inspect/spec.ts +2 -0
  104. package/src/tool/code_inspect/structured.ts +232 -0
  105. package/src/tool/code_orientation/result.ts +10 -4
  106. package/src/tool/code_orientation/spec.ts +2 -0
  107. package/src/tool/code_orientation/structured-schema.ts +607 -0
  108. package/src/tool/code_orientation/structured-workspace.ts +193 -0
  109. package/src/tool/code_orientation/structured.ts +195 -0
  110. package/src/tool/code_orientation/workspace-observations.ts +81 -0
  111. package/src/tool/code_orientation/workspace-output.ts +5 -0
  112. package/src/tool/code_orientation/workspace-projects.ts +16 -31
  113. package/src/tool/code_orientation/workspace-sections.ts +43 -30
  114. package/src/tool/code_refactor_apply/execute.ts +1 -1
  115. package/src/tool/code_refactor_apply/result.ts +13 -5
  116. package/src/tool/code_refactor_apply/spec.ts +2 -0
  117. package/src/tool/code_refactor_apply/structured.ts +49 -0
  118. package/src/tool/code_refactor_plan/result.ts +16 -8
  119. package/src/tool/code_refactor_plan/spec.ts +2 -0
  120. package/src/tool/code_refactor_plan/structured.ts +128 -0
  121. package/src/tool/schemas.ts +7 -1
  122. package/src/ui/status-command.ts +110 -321
  123. package/src/ui/status-overlay.ts +564 -420
@@ -7,6 +7,7 @@ import type {
7
7
  MissingServer,
8
8
  ServerConfig,
9
9
  } from "../config/types.ts";
10
+ import { inspectTypeScriptLaunch } from "../config/typescript-launch.ts";
10
11
  import type { LspManager } from "../manager/manager.ts";
11
12
  import { commandExists } from "../utils.ts";
12
13
  import {
@@ -32,20 +33,16 @@ export function scanProjectCapabilities(
32
33
 
33
34
  return Object.entries(config.servers)
34
35
  .flatMap(([serverName, server]) => {
35
- if (!commandExists(server.command)) return [];
36
36
  const allRoots = new Set(markerMatches.get(serverName) ?? []);
37
37
  if (extensionBasedServers.has(serverName)) {
38
38
  allRoots.add(cwd);
39
39
  }
40
40
  const roots = dedupeTopmostRoots(Array.from(allRoots));
41
- return roots.map(
42
- (root) =>
43
- ({
44
- name: serverName,
45
- root,
46
- fileTypes: [...server.fileTypes],
47
- }) satisfies DetectedProjectServer,
48
- );
41
+ return roots.flatMap((root) => {
42
+ const { command, ...selection } = inspectTypeScriptLaunch(serverName, server, root);
43
+ if (!selection.failureMessage && !commandExists(command)) return [];
44
+ return [{ name: serverName, root, fileTypes: [...server.fileTypes], ...selection }];
45
+ });
49
46
  })
50
47
  .sort((a, b) => a.root.localeCompare(b.root) || a.name.localeCompare(b.name));
51
48
  }
@@ -79,8 +76,6 @@ function inspectDirectory(
79
76
  ctx: HintContext,
80
77
  ): void {
81
78
  for (const [serverName, server] of Object.entries(servers)) {
82
- if (!commandExists(server.command)) continue;
83
-
84
79
  if (server.rootMarkers.length === 0) {
85
80
  if (hasMatchingFile(directory, entryNames, server.fileTypes)) {
86
81
  ctx.extensionBasedServers.add(serverName);
@@ -122,7 +117,7 @@ export async function startDetectedServers(
122
117
 
123
118
  /**
124
119
  * Scan the project for languages whose source files exist but whose LSP server
125
- * binary is not installed on PATH. Walks the project directory tree collecting
120
+ * executable or selected compiler is unavailable. Walks the project tree collecting
126
121
  * file extensions, then checks each configured server.
127
122
  */
128
123
  export function scanMissingServers(
@@ -142,14 +137,31 @@ export function scanMissingServers(
142
137
  });
143
138
 
144
139
  const missing: MissingServer[] = [];
140
+ const { markerMatches } = collectServerHints(config, cwd, maxDepth, policy);
145
141
 
146
142
  for (const [name, server] of Object.entries(config.servers)) {
147
- if (commandExists(server.command)) continue;
148
-
149
143
  const matching = server.fileTypes.filter((ft) => foundExtensions.has(ft));
150
144
  if (matching.length === 0) continue;
151
145
 
152
- missing.push({ name, command: server.command, foundExtensions: matching });
146
+ const roots = dedupeTopmostRoots(Array.from(markerMatches.get(name) ?? []));
147
+ for (const root of roots.length ? roots : [cwd]) {
148
+ const selection = inspectTypeScriptLaunch(name, server, root);
149
+ const command = selection.command;
150
+ if (selection.failureMessage) {
151
+ missing.push({
152
+ name,
153
+ command,
154
+ foundExtensions: matching,
155
+ root,
156
+ failureMessage: selection.failureMessage,
157
+ });
158
+ continue;
159
+ }
160
+ if (!commandExists(command)) {
161
+ missing.push({ name, command, foundExtensions: matching });
162
+ break;
163
+ }
164
+ }
153
165
  }
154
166
 
155
167
  return missing;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-runtime",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "Shared workspace context and capability contracts for code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-tree-sitter",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "Structural AST analysis for SuPi code intelligence",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "jiti": "^2.7.0",
38
38
  "web-tree-sitter": "^0.27.0",
39
- "@mrclrchtr/supi-code-runtime": "11.1.0",
40
- "@mrclrchtr/supi-core": "11.1.0"
39
+ "@mrclrchtr/supi-code-runtime": "11.2.0",
40
+ "@mrclrchtr/supi-core": "11.2.0"
41
41
  },
42
42
  "bundledDependencies": [
43
43
  "@mrclrchtr/supi-code-runtime",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-code-intelligence",
3
- "version": "11.1.0",
3
+ "version": "11.2.0",
4
4
  "description": "LSP and AST navigation, search, diagnostics, and refactoring",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,10 +42,10 @@
42
42
  "ignore": "^7.0.12",
43
43
  "smol-toml": "^1.9.1",
44
44
  "yaml": "^2.9.0",
45
- "@mrclrchtr/supi-code-runtime": "11.1.0",
46
- "@mrclrchtr/supi-lsp": "11.1.0",
47
- "@mrclrchtr/supi-core": "11.1.0",
48
- "@mrclrchtr/supi-tree-sitter": "11.1.0"
45
+ "@mrclrchtr/supi-code-runtime": "11.2.0",
46
+ "@mrclrchtr/supi-core": "11.2.0",
47
+ "@mrclrchtr/supi-lsp": "11.2.0",
48
+ "@mrclrchtr/supi-tree-sitter": "11.2.0"
49
49
  },
50
50
  "bundledDependencies": [
51
51
  "@mrclrchtr/supi-code-runtime",
@@ -29,9 +29,18 @@ export interface CapabilityWarningReport {
29
29
  warnings: CapabilityWarning[];
30
30
  }
31
31
 
32
+ /** Narrow launch-failure evidence accepted from a controller, before extension normalization. */
33
+ interface MissingServerEvidence {
34
+ name: string;
35
+ command: string;
36
+ foundExtensions?: string[];
37
+ failureMessage?: string;
38
+ }
39
+ type NormalizedMissingServerEvidence = MissingServerEvidence & { foundExtensions: string[] };
40
+
32
41
  /** Minimal LSP-controller surface needed to discover missing servers. */
33
42
  export interface CapabilityWarningMissingServerSource {
34
- getMissingServers(): Array<{ name: string; command: string; foundExtensions?: string[] }>;
43
+ getMissingServers(): MissingServerEvidence[];
35
44
  /** Explicit disablement captured with the active LSP configuration snapshot. */
36
45
  getExplicitlyDisabledLanguages?(): readonly string[];
37
46
  /** Configuration validation failure that prevented automatic startup. */
@@ -41,7 +50,7 @@ export interface CapabilityWarningMissingServerSource {
41
50
  /** Current runtime/config facts needed to evaluate Capability Warnings. */
42
51
  export interface CapabilityWarningInput {
43
52
  explicitlyDisabledLanguages: string[];
44
- missingServers: Array<{ name: string; command: string; foundExtensions: string[] }>;
53
+ missingServers: NormalizedMissingServerEvidence[];
45
54
  structuralState: { kind: string; reason?: string };
46
55
  /** Configuration could not be validated for automatic capability work. */
47
56
  configurationError?: string;
@@ -68,9 +77,11 @@ export function evaluateCapabilityWarnings(input: CapabilityWarningInput): Capab
68
77
 
69
78
  for (const server of input.missingServers) {
70
79
  warnings.push({
71
- type: "missing-server",
80
+ type: server.failureMessage ? "configuration-error" : "missing-server",
72
81
  language: server.name,
73
- message: `Cannot start "${server.name}" server — "${server.command}" not found on PATH`,
82
+ message:
83
+ server.failureMessage ??
84
+ `Cannot start "${server.name}" server — "${server.command}" not found on PATH`,
74
85
  detail:
75
86
  server.foundExtensions.length > 0
76
87
  ? `Affected file types: ${server.foundExtensions.join(", ")}`
@@ -157,11 +168,7 @@ export function gatherCapabilityWarningInput(
157
168
  const projectTrusted = options.projectTrusted !== false;
158
169
  const structuralState = getDefaultWorkspaceRuntime().getWorkspace(cwd).structural.state;
159
170
  let explicitlyDisabledLanguages: string[] = [];
160
- let missingServers: Array<{
161
- name: string;
162
- command: string;
163
- foundExtensions: string[];
164
- }> = [];
171
+ let missingServers: NormalizedMissingServerEvidence[] = [];
165
172
  let configurationError: string | undefined;
166
173
 
167
174
  try {
@@ -197,12 +204,11 @@ export function gatherCapabilityWarningInput(
197
204
  };
198
205
  }
199
206
 
200
- function normalizeMissingServers(
201
- raw: Array<{ name: string; command: string; foundExtensions?: string[] }>,
202
- ): Array<{ name: string; command: string; foundExtensions: string[] }> {
207
+ function normalizeMissingServers(raw: MissingServerEvidence[]): NormalizedMissingServerEvidence[] {
203
208
  return raw.map((entry) => ({
204
209
  name: entry.name,
205
210
  command: entry.command,
206
211
  foundExtensions: entry.foundExtensions ?? [],
212
+ ...(entry.failureMessage ? { failureMessage: entry.failureMessage } : {}),
207
213
  }));
208
214
  }
@@ -0,0 +1,115 @@
1
+ import {
2
+ type CodeRequestControl,
3
+ isCodeRequestInterruption,
4
+ throwIfCodeRequestInterrupted,
5
+ } from "@mrclrchtr/supi-code-runtime/api";
6
+ import type {
7
+ BulkTrackFileOutcome,
8
+ DiagnosticEvidenceDocument,
9
+ WorkspaceLspRuntime,
10
+ } from "@mrclrchtr/supi-lsp/api";
11
+ import { collectScopedFileDiagnostics } from "./file-scope.ts";
12
+
13
+ /** Maximum eligible source files selected by one explicit inspector check. */
14
+ export const DIAGNOSTIC_CHECK_BATCH_SIZE = 32;
15
+
16
+ /** One selected source file, including candidates that could not be checked. */
17
+ export interface DiagnosticCheckFile {
18
+ readonly file: string;
19
+ readonly status: DiagnosticEvidenceDocument["status"] | "skipped" | "unavailable";
20
+ readonly reason?: string;
21
+ }
22
+
23
+ /** Bounded check coverage, separate from the runtime's tracked-file snapshot. */
24
+ export interface WorkspaceDiagnosticCheckReport {
25
+ readonly kind: "completed" | "partial";
26
+ readonly files: readonly DiagnosticCheckFile[];
27
+ /** Null when source discovery did not establish a complete inventory. */
28
+ readonly total: number | null;
29
+ readonly startOffset: number;
30
+ /** Continuation within the sorted inventory; zero starts another pass. */
31
+ readonly nextOffset: number;
32
+ readonly remaining: number | null;
33
+ readonly reason?: string;
34
+ }
35
+
36
+ /** Discover policy-eligible sources and request diagnostics for one bounded batch. */
37
+ export async function checkWorkspaceDiagnostics(options: {
38
+ readonly runtime: WorkspaceLspRuntime;
39
+ readonly cwd: string;
40
+ readonly offset: number;
41
+ readonly control: CodeRequestControl;
42
+ }): Promise<WorkspaceDiagnosticCheckReport> {
43
+ const { runtime, cwd, control } = options;
44
+ let total: number | null = null;
45
+ let startOffset = options.offset;
46
+ const files: DiagnosticCheckFile[] = [];
47
+ const report = (
48
+ kind: WorkspaceDiagnosticCheckReport["kind"],
49
+ reason?: string,
50
+ ): WorkspaceDiagnosticCheckReport => {
51
+ const end = startOffset + files.length;
52
+ return {
53
+ kind,
54
+ files,
55
+ total,
56
+ startOffset,
57
+ nextOffset: total !== null && end >= total ? 0 : end,
58
+ remaining: total === null ? null : Math.max(0, total - end),
59
+ ...(reason ? { reason } : {}),
60
+ };
61
+ };
62
+ try {
63
+ throwIfCodeRequestInterrupted(control);
64
+ const inventory = await runtime.scanWorkspaceSources(control);
65
+ throwIfCodeRequestInterrupted(control);
66
+ if (inventory.status !== "complete") {
67
+ return report(
68
+ "partial",
69
+ `Source discovery incomplete: ${inventory.reason} (${inventory.observedFileCount} files observed).`,
70
+ );
71
+ }
72
+ total = inventory.files.length;
73
+ startOffset = options.offset >= 0 && options.offset < total ? options.offset : 0;
74
+ const selected = inventory.files.slice(startOffset, startOffset + DIAGNOSTIC_CHECK_BATCH_SIZE);
75
+ const batch = await runtime.bulkTrackFiles(selected, control);
76
+ for (const outcome of batch.outcomes) {
77
+ throwIfCodeRequestInterrupted(control);
78
+ files.push(await checkFile(outcome, runtime, cwd, control));
79
+ }
80
+ throwIfCodeRequestInterrupted(control);
81
+ return report("completed");
82
+ } catch (error) {
83
+ if (control.signal?.aborted || !isCodeRequestInterruption(error, control)) throw error;
84
+ return report(
85
+ "partial",
86
+ "Check time limit reached; remaining files were not checked. Run Check again to continue.",
87
+ );
88
+ }
89
+ }
90
+
91
+ async function checkFile(
92
+ outcome: BulkTrackFileOutcome,
93
+ runtime: WorkspaceLspRuntime,
94
+ cwd: string,
95
+ control: CodeRequestControl,
96
+ ): Promise<DiagnosticCheckFile> {
97
+ if (outcome.kind === "skipped" || outcome.kind === "unavailable") {
98
+ return { file: outcome.file, status: outcome.kind, reason: outcome.reason };
99
+ }
100
+ const result = await collectScopedFileDiagnostics({
101
+ service: runtime,
102
+ scope: { kind: "file", path: outcome.file },
103
+ cwd,
104
+ requestControl: control,
105
+ });
106
+ if (result.kind === "not-requested")
107
+ throw new Error("Diagnostic check did not request diagnostics.");
108
+ return {
109
+ file: outcome.file,
110
+ status: result.evidence.documents[0]?.status ?? "failed",
111
+ ...(result.kind === "partial" || result.kind === "unavailable"
112
+ ? { reason: result.reason }
113
+ : {}),
114
+ };
115
+ }
@@ -310,6 +310,9 @@ function evidenceIsComplete(
310
310
  }
311
311
 
312
312
  function diagnosticEvidenceReason(evidence: DiagnosticEvidenceSummary): string {
313
+ if (evidence.requested === 0) {
314
+ return "No document-level diagnostic evidence was collected for this scope. An empty result does not establish that the scope is clean. Request diagnostics for an exact file.";
315
+ }
313
316
  let reason = `Diagnostic evidence is partial: ${evidence.requested} requested, ${evidence.confirmed} confirmed, ${evidence.unconfirmed} unconfirmed, ${evidence.failed} failed, ${evidence.removed} removed.`;
314
317
  if (evidence.unconfirmed > 0) {
315
318
  reason += " Unconfirmed documents have no request-based confirmation.";
@@ -26,6 +26,7 @@ import type {
26
26
  HealthDiagnosticObservation,
27
27
  HealthDiagnosticScope,
28
28
  } from "../../session/health-types.ts";
29
+ import { HEALTH_DIAGNOSTIC_MESSAGE_LIMIT } from "../../session/health-types.ts";
29
30
 
30
31
  /** Collect a live per-file diagnostic pull with an applicable config scope decision. */
31
32
  export async function collectScopedFileDiagnostics(options: {
@@ -114,8 +115,6 @@ export function toFileDiagnosticEntries(
114
115
 
115
116
  // ── Message extraction ────────────────────────────────────────────────
116
117
 
117
- const MAX_MESSAGES_PER_FILE = 3;
118
-
119
118
  function extractMessages(
120
119
  diagnostics: ReadonlyArray<Pick<Diagnostic, "severity" | "message" | "source" | "range">>,
121
120
  ): HealthDiagnosticMessage[] {
@@ -125,7 +124,7 @@ function extractMessages(
125
124
  (a, b) => (a.severity ?? 1) - (b.severity ?? 1) || a.range.start.line - b.range.start.line,
126
125
  );
127
126
 
128
- return errorsAndWarnings.slice(0, MAX_MESSAGES_PER_FILE).map((d) => ({
127
+ return errorsAndWarnings.slice(0, HEALTH_DIAGNOSTIC_MESSAGE_LIMIT).map((d) => ({
129
128
  line: d.range.start.line + 1,
130
129
  severity: (d.severity ?? 1) === 1 ? ("error" as const) : ("warning" as const),
131
130
  message: typeof d.message === "string" ? d.message : d.message.value,
@@ -0,0 +1,38 @@
1
+ import type { CapabilityState } from "@mrclrchtr/supi-code-runtime/api";
2
+ import type { ProjectServerInfo, WorkspaceLspRuntimeState } from "@mrclrchtr/supi-lsp/api";
3
+ import type { SemanticHealthState } from "../../session/health-types.ts";
4
+
5
+ /** Derive passive workspace readiness; a runtime owner alone is not a ready server. */
6
+ export function deriveWorkspaceSemanticHealthState(
7
+ lspState: WorkspaceLspRuntimeState,
8
+ capabilityState: CapabilityState,
9
+ servers: readonly Pick<ProjectServerInfo, "status" | "ready">[],
10
+ ): SemanticHealthState {
11
+ if (
12
+ lspState.kind === "ready" &&
13
+ servers.some((server) => server.status === "running" && server.ready)
14
+ ) {
15
+ return { kind: "ready" };
16
+ }
17
+ switch (lspState.kind) {
18
+ case "pending":
19
+ return { kind: "pending", reason: "LSP is starting" };
20
+ case "inactive":
21
+ return { kind: "inactive", reason: "Inactive on the current session branch" };
22
+ case "disabled":
23
+ return { kind: "disabled", reason: "Disabled by configuration" };
24
+ case "unavailable":
25
+ return { kind: "unavailable", reason: lspState.reason };
26
+ case "ready":
27
+ switch (capabilityState.kind) {
28
+ case "inactive":
29
+ return { kind: "inactive", reason: "Inactive on the current session branch" };
30
+ case "disabled":
31
+ return { kind: "disabled", reason: "Disabled by configuration" };
32
+ case "unavailable":
33
+ return { kind: "unavailable", reason: capabilityState.reason };
34
+ default:
35
+ return { kind: "pending", reason: "No active, ready project servers" };
36
+ }
37
+ }
38
+ }
@@ -67,6 +67,14 @@ export function formatProjectServerStatusReason(
67
67
  }
68
68
  }
69
69
 
70
+ /** Render the selected compiler without confusing a wrapper version with its implementation. */
71
+ export function formatProjectServerCompiler(
72
+ selection: ProjectServerInfo["typescript"],
73
+ ): string | null {
74
+ if (!selection) return null;
75
+ return `${selection.backend}: TypeScript ${selection.compilerVersion ?? "(unknown version)"} via ${selection.packageName}${selection.wrapperVersion ? ` (wrapper ${selection.wrapperVersion})` : ""}`;
76
+ }
77
+
70
78
  /** Render operation support without hiding server limits or SuPi limits. */
71
79
  export function formatProjectServerOperationSupport(
72
80
  support: ServerOperationSupportMap | undefined,
@@ -16,6 +16,8 @@ export function collectServers(
16
16
  fileTypes: server.fileTypes,
17
17
  status: server.status,
18
18
  ...(server.statusReason ? { statusReason: server.statusReason } : {}),
19
+ ...(server.typescript ? { typescript: server.typescript } : {}),
20
+ ...(server.failureMessage ? { failureMessage: server.failureMessage } : {}),
19
21
  ready: server.ready,
20
22
  ...(server.operationSupport ? { operationSupport: server.operationSupport } : {}),
21
23
  }));
@@ -0,0 +1,82 @@
1
+ import type { CapabilityState } from "@mrclrchtr/supi-code-runtime/api";
2
+ import type {
3
+ AutomaticLspPathPolicy,
4
+ ProjectServerInfo,
5
+ WorkspaceLspRuntimeState,
6
+ } from "@mrclrchtr/supi-lsp/api";
7
+ import type {
8
+ HealthDiagnosticObservation,
9
+ SemanticHealthState,
10
+ } from "../../session/health-types.ts";
11
+ import {
12
+ type CapabilityWarningMissingServerSource,
13
+ type CapabilityWarningReport,
14
+ evaluateCapabilityWarnings,
15
+ gatherCapabilityWarningInput,
16
+ } from "../capability/capability-warnings.ts";
17
+ import { collectDiagnostics } from "./diagnostics.ts";
18
+ import { deriveWorkspaceSemanticHealthState } from "./semantic-state.ts";
19
+
20
+ /** Passive status facts. No maintenance, recovery, or document tracking is performed. */
21
+ export interface WorkspaceStatusSnapshot {
22
+ readonly workspaceRoot: string;
23
+ readonly servers: readonly ProjectServerInfo[];
24
+ readonly serverInventoryAvailable: boolean;
25
+ readonly diagnostics: HealthDiagnosticObservation;
26
+ readonly capabilities: {
27
+ readonly semantic: SemanticHealthState;
28
+ readonly structural: CapabilityState;
29
+ };
30
+ readonly capabilityWarnings?: CapabilityWarningReport;
31
+ }
32
+
33
+ /** Runtime facts and trusted configuration needed for one passive observation. */
34
+ export interface WorkspaceStatusOptions {
35
+ readonly cwd: string;
36
+ readonly lspState: WorkspaceLspRuntimeState;
37
+ readonly semanticState: CapabilityState;
38
+ readonly structuralState: CapabilityState;
39
+ readonly projectTrusted: boolean;
40
+ readonly homeDir?: string;
41
+ readonly lspController?: CapabilityWarningMissingServerSource | null;
42
+ readonly automaticPathPolicy?: AutomaticLspPathPolicy | null;
43
+ }
44
+
45
+ /** Use the same readiness and diagnostic evidence policy as code_health, without refreshing it. */
46
+ export async function observeWorkspaceStatus(
47
+ options: WorkspaceStatusOptions,
48
+ ): Promise<WorkspaceStatusSnapshot> {
49
+ const { cwd, lspState } = options;
50
+ const runtime = lspState.kind === "ready" ? lspState.runtime : null;
51
+ const servers = runtime?.getProjectServers() ?? [];
52
+ const semantic = deriveWorkspaceSemanticHealthState(lspState, options.semanticState, servers);
53
+ const diagnostics = await collectDiagnostics({
54
+ service: semantic.kind === "ready" ? runtime : null,
55
+ evidenceService:
56
+ lspState.kind === "ready" || lspState.kind === "inactive" ? lspState.runtime : null,
57
+ included: ["diagnostics"],
58
+ scope: { kind: "tracked-files", filter: null },
59
+ cwd,
60
+ unavailableReason: semantic.kind === "ready" ? "Diagnostics unavailable" : semantic.reason,
61
+ });
62
+ const warnings = evaluateCapabilityWarnings(
63
+ gatherCapabilityWarningInput(cwd, options.lspController ?? null, {
64
+ projectTrusted: options.projectTrusted,
65
+ homeDir: options.homeDir,
66
+ automaticPathPolicy: options.automaticPathPolicy ?? undefined,
67
+ }),
68
+ );
69
+ return {
70
+ workspaceRoot: cwd,
71
+ servers,
72
+ serverInventoryAvailable: lspState.kind === "ready" || lspState.kind === "disabled",
73
+ diagnostics: {
74
+ ...diagnostics,
75
+ entries: [...diagnostics.entries].sort(
76
+ (a, b) => b.errors - a.errors || b.warnings - a.warnings || a.file.localeCompare(b.file),
77
+ ),
78
+ },
79
+ capabilities: { semantic, structural: options.structuralState },
80
+ capabilityWarnings: warnings.hasWarnings ? warnings : undefined,
81
+ };
82
+ }
@@ -16,6 +16,7 @@ import { readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:
16
16
  import { basename, dirname, join } from "node:path";
17
17
  import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
18
18
  import type { FileEdit, WorkspaceEdit } from "@mrclrchtr/supi-code-runtime/api";
19
+ import { toDisplayPath } from "../search/paths.ts";
19
20
  import { revalidateMutationAuthority } from "./mutation-authority.ts";
20
21
  import { compareCodePositions, createLogicalLineIndex } from "./position.ts";
21
22
  import { validateEditAgainstFiles } from "./safety.ts";
@@ -25,6 +26,8 @@ export type ApplyResult =
25
26
  | { kind: "error"; reason: string };
26
27
 
27
28
  export interface ApplyOptions {
29
+ /** Workspace root for relative error paths; omitted roots retain absolute paths. */
30
+ cwd?: string;
28
31
  /** Canonical roots authorized by the semantic provider that made the plan. */
29
32
  authorizedMutationRoots: readonly string[];
30
33
  /** Expected SHA-256 fingerprints per file, validated after queue acquisition. */
@@ -65,7 +68,7 @@ export async function applyWorkspaceEdit(
65
68
  }
66
69
 
67
70
  if (options.expectedFingerprints) {
68
- const freshness = validateFingerprints(files, options.expectedFingerprints);
71
+ const freshness = validateFingerprints(files, options.expectedFingerprints, options.cwd);
69
72
  if (!freshness.ok) return { kind: "error", reason: freshness.reason };
70
73
  }
71
74
 
@@ -73,6 +76,7 @@ export async function applyWorkspaceEdit(
73
76
  edit,
74
77
  options.getOpenDocumentVersion,
75
78
  options.expectedFingerprints,
79
+ options.cwd,
76
80
  );
77
81
  if (!documentState.ok) return { kind: "error", reason: documentState.reason };
78
82
 
@@ -97,6 +101,7 @@ function validateDocumentPreconditions(
97
101
  edit: WorkspaceEdit,
98
102
  getOpenDocumentVersion: ApplyOptions["getOpenDocumentVersion"],
99
103
  expectedFingerprints: ApplyOptions["expectedFingerprints"],
104
+ cwd: ApplyOptions["cwd"],
100
105
  ): { ok: true } | { ok: false; reason: string } {
101
106
  const preconditions = edit.documentPreconditions ?? [];
102
107
  if (preconditions.length === 0) return { ok: true };
@@ -112,6 +117,7 @@ function validateDocumentPreconditions(
112
117
  precondition,
113
118
  getOpenDocumentVersion,
114
119
  expectedFingerprints,
120
+ cwd,
115
121
  );
116
122
  if (reason) return { ok: false, reason };
117
123
  }
@@ -122,21 +128,23 @@ function validateDocumentPrecondition(
122
128
  precondition: NonNullable<WorkspaceEdit["documentPreconditions"]>[number],
123
129
  getOpenDocumentVersion: NonNullable<ApplyOptions["getOpenDocumentVersion"]>,
124
130
  expectedFingerprints: ApplyOptions["expectedFingerprints"],
131
+ cwd: ApplyOptions["cwd"],
125
132
  ): string | null {
133
+ const file = cwd ? toDisplayPath(cwd, precondition.file) : precondition.file;
126
134
  const currentVersion = getOpenDocumentVersion(precondition.file);
127
135
  if (precondition.kind === "disk-content") {
128
136
  return currentVersion === null
129
137
  ? null
130
- : `File ${precondition.file} is now open and no longer uses disk content as its master.`;
138
+ : `File ${file} is now open and no longer uses disk content as its master.`;
131
139
  }
132
140
  if (currentVersion !== precondition.version) {
133
- return `File ${precondition.file} open document version has changed since the plan was generated.`;
141
+ return `File ${file} open document version has changed since the plan was generated.`;
134
142
  }
135
143
  if (
136
144
  precondition.kind === "open-document-content" &&
137
145
  expectedFingerprints?.get(precondition.file) !== precondition.fingerprint
138
146
  ) {
139
- return `File ${precondition.file} synchronized content fingerprint does not match the stored plan.`;
147
+ return `File ${file} synchronized content fingerprint does not match the stored plan.`;
140
148
  }
141
149
  return null;
142
150
  }
@@ -144,6 +152,7 @@ function validateDocumentPrecondition(
144
152
  function validateFingerprints(
145
153
  files: string[],
146
154
  expected: ReadonlyMap<string, string>,
155
+ cwd: ApplyOptions["cwd"],
147
156
  ): { ok: true } | { ok: false; reason: string } {
148
157
  for (const file of files) {
149
158
  const expectedFingerprint = expected.get(file);
@@ -152,9 +161,9 @@ function validateFingerprints(
152
161
  try {
153
162
  actual = sha256File(file);
154
163
  } catch {
155
- return stalePlanError(file);
164
+ return stalePlanError(file, cwd);
156
165
  }
157
- if (actual !== expectedFingerprint) return stalePlanError(file);
166
+ if (actual !== expectedFingerprint) return stalePlanError(file, cwd);
158
167
  }
159
168
  return { ok: true };
160
169
  }
@@ -163,10 +172,10 @@ function sha256File(file: string): string {
163
172
  return createHash("sha256").update(readFileSync(file, "utf-8")).digest("hex");
164
173
  }
165
174
 
166
- function stalePlanError(file: string): { ok: false; reason: string } {
175
+ function stalePlanError(file: string, cwd: ApplyOptions["cwd"]): { ok: false; reason: string } {
167
176
  return {
168
177
  ok: false,
169
- reason: `File ${file} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
178
+ reason: `File ${cwd ? toDisplayPath(cwd, file) : file} has changed since the plan was generated. Regenerate with code_refactor_plan.`,
170
179
  };
171
180
  }
172
181
 
@@ -10,6 +10,9 @@ import type {
10
10
  import type { CapabilityWarningReport } from "../analysis/capability/capability-warnings.ts";
11
11
  import type { SourceTrackingReport } from "../substrate/lsp/source-tracking.ts";
12
12
 
13
+ /** Maximum detailed error and warning messages retained for each diagnostic file. */
14
+ export const HEALTH_DIAGNOSTIC_MESSAGE_LIMIT = 3;
15
+
13
16
  export type HealthSection = "diagnostics" | "servers";
14
17
 
15
18
  /** Final semantic-diagnostics readiness after routing and requested recovery. */
@@ -33,6 +36,10 @@ export interface HealthServerInfo {
33
36
  readonly fileTypes: readonly string[];
34
37
  readonly status: ProjectServerInfo["status"];
35
38
  readonly statusReason?: ProjectServerStatusReason;
39
+ /** Compiler selection used by this route generation, if automatically resolved. */
40
+ readonly typescript?: ProjectServerInfo["typescript"];
41
+ /** Actionable launch failure, distinct from process recovery status. */
42
+ readonly failureMessage?: string;
36
43
  readonly ready: boolean;
37
44
  /** Negotiated operation support and SuPi planning limitations. */
38
45
  readonly operationSupport?: ServerOperationSupportMap;