@mrclrchtr/supi-code-intelligence 7.4.0 → 8.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 (74) hide show
  1. package/README.md +6 -6
  2. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  5. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
  7. package/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  8. package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  9. package/node_modules/@mrclrchtr/supi-lsp/README.md +29 -6
  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/api.ts +1 -1
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  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/config/config.ts +110 -0
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  17. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  18. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +25 -3
  19. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +2 -1
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -2
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +39 -6
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +82 -12
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +28 -5
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +606 -30
  25. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +9 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +69 -8
  27. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +196 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +15 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +9 -1
  30. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +31 -2
  32. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +72 -2
  33. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +9 -43
  34. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +102 -50
  35. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +49 -3
  36. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +78 -18
  37. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +46 -2
  38. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
  39. package/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +30 -4
  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/api.ts +1 -1
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  48. package/package.json +5 -5
  49. package/src/analysis/capability/capability-warnings.ts +64 -25
  50. package/src/analysis/health/server-status.ts +23 -1
  51. package/src/analysis/health/signals.ts +1 -0
  52. package/src/analysis/search/ast-scan.ts +42 -8
  53. package/src/analysis/search/pattern.ts +4 -0
  54. package/src/config.ts +64 -34
  55. package/src/extension.ts +29 -10
  56. package/src/headless.ts +1 -0
  57. package/src/session/find-types.ts +2 -1
  58. package/src/session/find-workflow.ts +5 -0
  59. package/src/session/health-types.ts +3 -0
  60. package/src/session/health-workflow.ts +10 -1
  61. package/src/session/session.ts +34 -2
  62. package/src/substrate/lsp/lifecycle.ts +2 -0
  63. package/src/substrate/lsp/recovery.ts +3 -3
  64. package/src/substrate/lsp/settings.ts +191 -108
  65. package/src/substrate/workspace-provider-host.ts +50 -12
  66. package/src/tool/code_find/markdown.ts +12 -0
  67. package/src/tool/code_find/render.ts +20 -0
  68. package/src/tool/code_find/result.ts +3 -0
  69. package/src/tool/code_health/markdown.ts +3 -0
  70. package/src/tool/code_health/result.ts +3 -1
  71. package/src/tool/result/types.ts +3 -1
  72. package/src/ui/status-command.ts +54 -6
  73. package/src/ui/status-overlay.ts +5 -0
  74. package/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +0 -22
@@ -1,9 +1,22 @@
1
1
  // Public API surface for the LSP session-scoped service.
2
2
 
3
3
  export { isMissingFileError } from "./client/client-file-state.ts";
4
- export { type LoadConfigOptions, loadConfig } from "./config/config.ts";
5
- export type { LspSettings } from "./config/lsp-settings.ts";
6
- export { loadLspSettings } from "./config/lsp-settings.ts";
4
+ export {
5
+ getExplicitlyDisabledLanguages,
6
+ type LoadConfigOptions,
7
+ loadConfig,
8
+ } from "./config/config.ts";
9
+ export {
10
+ codeActionKindsForOperation,
11
+ getServerOperationSupport,
12
+ isCodeActionKindInRange,
13
+ REFACTOR_CODE_ACTION_KINDS,
14
+ supportsCodeActionResolve,
15
+ supportsCodeActions,
16
+ supportsPrepareRename,
17
+ supportsRename,
18
+ supportsRequestedCodeActionKinds,
19
+ } from "./config/operation-support.ts";
7
20
  export {
8
21
  clearTsconfigCache,
9
22
  type FileScopeDecision,
@@ -21,6 +34,8 @@ export type {
21
34
  DocumentSymbol,
22
35
  FileEvent,
23
36
  Hover,
37
+ JsonObject,
38
+ JsonValue,
24
39
  Location,
25
40
  LocationLink,
26
41
  LspConfig,
@@ -29,6 +44,10 @@ export type {
29
44
  ProjectServerInfo,
30
45
  ProjectServerStatusReason,
31
46
  Range,
47
+ ServerAdvertisement,
48
+ ServerOperationName,
49
+ ServerOperationSupport,
50
+ ServerOperationSupportMap,
32
51
  SymbolInformation,
33
52
  WorkspaceEdit,
34
53
  WorkspaceSymbol,
@@ -52,6 +71,7 @@ export {
52
71
  export { raceReadinessValue, raceRequestControl } from "./session/readiness.ts";
53
72
  export type {
54
73
  LspControllerState,
74
+ LspRuntimeControllerOptions,
55
75
  LspRuntimeTransition,
56
76
  LspRuntimeTransitionKind,
57
77
  LspRuntimeTransitionListener,
@@ -77,6 +97,7 @@ export type {
77
97
  StartupRetryNextAction,
78
98
  StartupRetryOutcome,
79
99
  StartupRetryReport,
100
+ WorkspaceCodeActionRequestOptions,
80
101
  WorkspaceDiagnosticReport,
81
102
  WorkspaceDiagnosticSnapshot,
82
103
  WorkspaceDiagnosticSummaryEntry,
@@ -98,6 +119,7 @@ export { MAX_BULK_TRACK_FILES } from "./session/workspace-lsp-runtime.ts";
98
119
  export {
99
120
  AUTOMATIC_LSP_EXCLUDED_DIRECTORIES,
100
121
  type AutomaticLspPathPolicy,
122
+ type AutomaticLspPathPolicyOptions,
101
123
  createAutomaticLspPathPolicy,
102
124
  createDefaultAutomaticLspPathPolicy,
103
125
  } from "./workspace-path-policy.ts";
@@ -1,4 +1,5 @@
1
1
  import type { DiagnosticRequestAdapter } from "./client-diagnostic-request.ts";
2
+ import type { NormalizedDocumentSync } from "./client-document-sync.ts";
2
3
 
3
4
  /** Transport and capability operations required by diagnostic state. */
4
5
  export interface ClientDiagnosticsHost {
@@ -9,6 +10,6 @@ export interface ClientDiagnosticsHost {
9
10
  isOperational(): boolean;
10
11
  /** Native pull and server-specific request evidence share this priority adapter. */
11
12
  diagnosticRequestAdapter: DiagnosticRequestAdapter;
12
- usesIncrementalDocumentSync(): boolean;
13
+ documentSync(): NormalizedDocumentSync;
13
14
  sendNotification(method: string, params: unknown): void;
14
15
  }
@@ -289,7 +289,9 @@ interface ClientDiagnosticRefreshOptions {
289
289
  /** Invalidate route evidence before applying a disk content change. */
290
290
  readonly noteInputContentChange: () => number;
291
291
  /** Keep the shared semantic barrier's verified disk observation current. */
292
- readonly observeDiskContent: (uri: string, content: string) => void;
292
+ readonly observeDiskContent: (uri: string, content: string) => boolean;
293
+ /** Send one save for an externally observed disk change. */
294
+ readonly noteExternalDiskChange: (uri: string, content: string) => void;
293
295
  readonly clearFile: (uri: string) => void;
294
296
  readonly invalidateEvidence: (uri: string) => void;
295
297
  readonly markUnversionedSyncMoment: (uri: string) => void;
@@ -343,9 +345,10 @@ function prepareRefreshDocuments(
343
345
  nextVersion: (uri) => nextDocumentVersion(options.versionHistory, uri),
344
346
  nextSynchronizationId: options.nextSynchronizationId,
345
347
  evidenceRevision,
348
+ documentSync: options.host.documentSync(),
346
349
  noteInputContentChange: options.noteInputContentChange,
347
350
  observeDiskContent: options.observeDiskContent,
348
- incrementalSync: options.host.usesIncrementalDocumentSync(),
351
+ noteExternalDiskChange: options.noteExternalDiskChange,
349
352
  sendNotification: (method, params) => options.host.sendNotification(method, params),
350
353
  uriToFile,
351
354
  preloadedContent: classification.preloadedContent,
@@ -1,4 +1,5 @@
1
1
  // biome-ignore-all lint/style/noExcessiveLinesPerFile: one client's document sync, diagnostics, refresh, and sync-file flow stay in one cohesive class.
2
+ import { readFileSync } from "node:fs";
2
3
  import * as path from "node:path";
3
4
  import {
4
5
  type CodeQueryResult,
@@ -116,6 +117,8 @@ export class ClientDiagnostics {
116
117
  isOperational: () => this.host.isOperational(),
117
118
  getOpenDocuments: () => this.#getSemanticInputDocuments(),
118
119
  applyDocumentUpdates: (updates) => this.#applySemanticInputUpdates(updates),
120
+ noteExternalDiskChange: (filePath, content) =>
121
+ this.#noteExternalDiskChange(filePath, content),
119
122
  closeMissingDocument: (filePath) => this.didClose(filePath),
120
123
  markUnreadableDocument: (filePath) => this.markFailedFile(filePath),
121
124
  });
@@ -200,7 +203,7 @@ export class ClientDiagnostics {
200
203
  nextVersion: () => nextDocumentVersion(this.#versionHistory, uri),
201
204
  nextSynchronizationId: () => ++this.#nextSynchronizationId,
202
205
  evidenceRevision: this.#evidenceRevision,
203
- incrementalSync: this.host.usesIncrementalDocumentSync(),
206
+ documentSync: this.host.documentSync(),
204
207
  waiters: this.#waiters,
205
208
  sendNotification: (method, params) => this.host.sendNotification(method, params),
206
209
  markUnversionedSyncMoment: () => this.#unversionedPushSyncMoments.set(uri, Date.now()),
@@ -213,10 +216,6 @@ export class ClientDiagnostics {
213
216
  this.#inputBarrier.initializeDocumentContent(uri, content);
214
217
  }
215
218
 
216
- #observeDiskContent(uri: string, content: string): void {
217
- this.#inputBarrier.observeDiskContent(uri, content);
218
- }
219
-
220
219
  #forgetDocumentContent(uri: string): void {
221
220
  this.#inputBarrier.forgetDocumentContent(uri);
222
221
  }
@@ -333,6 +332,38 @@ export class ClientDiagnostics {
333
332
  this.#synchronizeTrackedDocument(uri, filePath, content, doc);
334
333
  }
335
334
 
335
+ /** Send a save after a disk change that the input barrier observed. */
336
+ #noteExternalDiskChange(filePath: string, content: string): void {
337
+ if (!this.host.isOperational()) return;
338
+ const documentSync = this.host.documentSync();
339
+ if (!documentSync.save) return;
340
+ this.host.sendNotification("textDocument/didSave", {
341
+ textDocument: { uri: fileToUri(filePath) },
342
+ ...(documentSync.includeText ? { text: content } : {}),
343
+ });
344
+ }
345
+
346
+ /** Synchronize and notify one tracked document after an observed disk write. */
347
+ noteWorkspaceWrite(filePath: string): void {
348
+ if (!this.host.isOperational()) return;
349
+
350
+ const uri = fileToUri(filePath);
351
+ const document = this.#openDocs.get(uri);
352
+ if (!document) return;
353
+
354
+ let content: string;
355
+ try {
356
+ content = readFileSync(filePath, "utf-8");
357
+ } catch {
358
+ return;
359
+ }
360
+ const diskChanged = this.#inputBarrier.observeDiskContent(uri, content);
361
+ if (document.contentFingerprint !== fingerprintDocumentContent(content)) {
362
+ this.didChange(filePath, content);
363
+ }
364
+ if (diskChanged) this.#noteExternalDiskChange(filePath, content);
365
+ }
366
+
336
367
  didClose(filePath: string): void {
337
368
  const uri = fileToUri(filePath);
338
369
  const wasOpen = this.#openDocs.has(uri);
@@ -527,7 +558,9 @@ export class ClientDiagnostics {
527
558
  isRelatedUriTracked: (uri) => this.#openDocs.has(uri) || this.#versionHistory.has(uri),
528
559
  nextSynchronizationId: () => ++this.#nextSynchronizationId,
529
560
  noteInputContentChange: () => this.#noteInputContentChange(),
530
- observeDiskContent: (uri, content) => this.#observeDiskContent(uri, content),
561
+ observeDiskContent: (uri, content) => this.#inputBarrier.observeDiskContent(uri, content),
562
+ noteExternalDiskChange: (uri, content) =>
563
+ this.#noteExternalDiskChange(uriToFile(uri), content),
531
564
  invalidateEvidence: (uri) => {
532
565
  this.#advanceInputRevision(false, true, "failure");
533
566
  this.#cancelDiagnosticRequest(uri);
@@ -1,5 +1,8 @@
1
1
  import { readFileSync } from "node:fs";
2
- import type { VersionedTextDocumentIdentifier } from "../config/types.ts";
2
+ import {
3
+ TextDocumentSyncKind,
4
+ type VersionedTextDocumentIdentifier,
5
+ } from "vscode-languageserver-protocol";
3
6
  import type { DiagnosticSynchronization } from "./client-diagnostic-evidence.ts";
4
7
  import type { DiagnosticWaitRegistry } from "./client-diagnostic-waiters.ts";
5
8
  import { fingerprintDocumentContent, type OpenDocumentState } from "./client-document-state.ts";
@@ -7,6 +10,59 @@ import { getDiagnosticFileState } from "./client-file-state.ts";
7
10
 
8
11
  type NotificationSender = (method: string, params: unknown) => void;
9
12
 
13
+ /** Normalized document lifecycle options negotiated with one LSP server. */
14
+ export interface NormalizedDocumentSync {
15
+ readonly openClose: boolean;
16
+ readonly change: TextDocumentSyncKind;
17
+ readonly save: boolean;
18
+ readonly includeText: boolean;
19
+ }
20
+
21
+ const NO_DOCUMENT_SYNC: NormalizedDocumentSync = Object.freeze({
22
+ openClose: false,
23
+ change: TextDocumentSyncKind.None,
24
+ save: false,
25
+ includeText: false,
26
+ });
27
+
28
+ /**
29
+ * Normalize structured and legacy numeric server synchronization options.
30
+ * Legacy non-none values use the historical full lifecycle defaults.
31
+ */
32
+ export function normalizeDocumentSync(value: unknown): NormalizedDocumentSync {
33
+ if (value === TextDocumentSyncKind.None) return NO_DOCUMENT_SYNC;
34
+ if (value === TextDocumentSyncKind.Full || value === TextDocumentSyncKind.Incremental) {
35
+ return Object.freeze({
36
+ openClose: true,
37
+ change: value,
38
+ save: true,
39
+ includeText: false,
40
+ });
41
+ }
42
+ if (!isRecord(value)) return NO_DOCUMENT_SYNC;
43
+
44
+ const change = isTextDocumentSyncKind(value.change) ? value.change : TextDocumentSyncKind.None;
45
+ const save = value.save === true || isRecord(value.save);
46
+ return Object.freeze({
47
+ openClose: value.openClose === true,
48
+ change,
49
+ save,
50
+ includeText: isRecord(value.save) && value.save.includeText === true,
51
+ });
52
+ }
53
+
54
+ function isTextDocumentSyncKind(value: unknown): value is TextDocumentSyncKind {
55
+ return (
56
+ value === TextDocumentSyncKind.None ||
57
+ value === TextDocumentSyncKind.Full ||
58
+ value === TextDocumentSyncKind.Incremental
59
+ );
60
+ }
61
+
62
+ function isRecord(value: unknown): value is Record<string, unknown> {
63
+ return typeof value === "object" && value !== null && !Array.isArray(value);
64
+ }
65
+
10
66
  interface SynchronizeDocumentOptions {
11
67
  uri: string;
12
68
  content: string;
@@ -14,7 +70,7 @@ interface SynchronizeDocumentOptions {
14
70
  version: number;
15
71
  synchronizationId: number;
16
72
  evidenceRevision: number;
17
- incrementalSync: boolean;
73
+ documentSync: NormalizedDocumentSync;
18
74
  waiters: DiagnosticWaitRegistry;
19
75
  sendNotification: NotificationSender;
20
76
  }
@@ -31,9 +87,9 @@ function endPosition(content: string): { line: number; character: number } {
31
87
  function contentChanges(
32
88
  previousContent: string,
33
89
  content: string,
34
- incrementalSync: boolean,
90
+ change: TextDocumentSyncKind,
35
91
  ): unknown[] {
36
- if (incrementalSync) {
92
+ if (change === TextDocumentSyncKind.Incremental) {
37
93
  return [
38
94
  {
39
95
  range: {
@@ -64,10 +120,11 @@ export function synchronizeDocument(options: SynchronizeDocumentOptions): void {
64
120
  const changes = contentChanges(
65
121
  options.document.content,
66
122
  options.content,
67
- options.incrementalSync,
123
+ options.documentSync.change,
68
124
  );
69
125
  options.document.content = options.content;
70
126
  options.document.contentFingerprint = fingerprintDocumentContent(options.content);
127
+ if (options.documentSync.change === TextDocumentSyncKind.None) return;
71
128
  options.sendNotification("textDocument/didChange", {
72
129
  textDocument: {
73
130
  uri: options.uri,
@@ -98,7 +155,7 @@ export function synchronizeTrackedDocument(options: {
98
155
  nextVersion(): number;
99
156
  nextSynchronizationId(): number;
100
157
  evidenceRevision: number;
101
- incrementalSync: boolean;
158
+ documentSync: NormalizedDocumentSync;
102
159
  waiters: DiagnosticWaitRegistry;
103
160
  sendNotification: NotificationSender;
104
161
  markUnversionedSyncMoment?(): void;
@@ -117,7 +174,7 @@ export function synchronizeTrackedDocument(options: {
117
174
  version: options.nextVersion(),
118
175
  synchronizationId: options.nextSynchronizationId(),
119
176
  evidenceRevision: options.evidenceRevision,
120
- incrementalSync: options.incrementalSync,
177
+ documentSync: options.documentSync,
121
178
  waiters: options.waiters,
122
179
  sendNotification: options.sendNotification,
123
180
  });
@@ -130,11 +187,13 @@ interface ResynchronizeDocumentsOptions {
130
187
  nextVersion(uri: string): number;
131
188
  nextSynchronizationId(): number;
132
189
  evidenceRevision: number;
190
+ documentSync: NormalizedDocumentSync;
133
191
  /** Invalidate route evidence before the first changed document is applied. */
134
192
  noteInputContentChange(): number;
135
- /** Record the verified disk content in the shared semantic barrier. */
136
- observeDiskContent(uri: string, content: string): void;
137
- incrementalSync: boolean;
193
+ /** Record the verified disk content and report whether its baseline changed. */
194
+ observeDiskContent(uri: string, content: string): boolean;
195
+ /** Send one save for an externally observed disk change. */
196
+ noteExternalDiskChange(uri: string, content: string): void;
138
197
  sendNotification: NotificationSender;
139
198
  uriToFile(uri: string): string;
140
199
  /** Disk content already read by classification; avoids a second read. */
@@ -157,6 +216,17 @@ export interface ResynchronizeDocumentsResult {
157
216
  failedFiles: string[];
158
217
  }
159
218
 
219
+ /** Send one save when a refresh observes a new disk fingerprint. */
220
+ function noteObservedDiskChange(
221
+ options: ResynchronizeDocumentsOptions,
222
+ uri: string,
223
+ content: string,
224
+ ): void {
225
+ if (options.observeDiskContent(uri, content)) {
226
+ options.noteExternalDiskChange(uri, content);
227
+ }
228
+ }
229
+
160
230
  /** Re-read and synchronize every existing open document. */
161
231
  export function resynchronizeOpenDocuments(
162
232
  options: ResynchronizeDocumentsOptions,
@@ -185,7 +255,7 @@ export function resynchronizeOpenDocuments(
185
255
  version: options.nextVersion(uri),
186
256
  synchronizationId: options.nextSynchronizationId(),
187
257
  evidenceRevision: synchronizationRevision,
188
- incrementalSync: options.incrementalSync,
258
+ documentSync: options.documentSync,
189
259
  waiters: options.waiters,
190
260
  sendNotification: options.sendNotification,
191
261
  });
@@ -200,7 +270,7 @@ export function resynchronizeOpenDocuments(
200
270
  waiters: options.waiters,
201
271
  });
202
272
  }
203
- options.observeDiskContent(uri, content);
273
+ noteObservedDiskChange(options, uri, content);
204
274
  options.clearFailedFile(uri);
205
275
  synchronizedUris.add(uri);
206
276
  if (contentChanged) resynchronizedUris.add(uri);
@@ -36,6 +36,8 @@ export interface SemanticInputBarrierHost {
36
36
  isOperational(): boolean;
37
37
  getOpenDocuments(): readonly SemanticInputDocument[];
38
38
  applyDocumentUpdates(updates: readonly SemanticInputUpdate[]): void;
39
+ /** Report disk changes that were observed during synchronization. */
40
+ noteExternalDiskChange?(filePath: string, content: string): void;
39
41
  closeMissingDocument(filePath: string): void;
40
42
  markUnreadableDocument(filePath: string): void;
41
43
  }
@@ -60,6 +62,7 @@ interface OpenDocumentRead {
60
62
 
61
63
  interface SynchronizationPlan {
62
64
  readonly updates: SemanticInputUpdate[];
65
+ readonly externalDiskChanges: Array<{ readonly filePath: string; readonly content: string }>;
63
66
  readonly observedDiskFingerprints: Map<string, string | undefined>;
64
67
  }
65
68
 
@@ -202,9 +205,13 @@ export class SemanticInputBarrier {
202
205
  this.#observedDiskFingerprints.set(uri, fingerprintDocumentContent(content));
203
206
  }
204
207
 
205
- /** Record content read from disk after a synchronization or refresh pass. */
206
- observeDiskContent(uri: string, content: string): void {
207
- this.#observedDiskFingerprints.set(uri, fingerprintDocumentContent(content));
208
+ /** Record content read from disk and report a changed known baseline. */
209
+ observeDiskContent(uri: string, content: string): boolean {
210
+ const fingerprint = fingerprintDocumentContent(content);
211
+ const previous = this.#observedDiskFingerprints.get(uri);
212
+ const changed = this.#observedDiskFingerprints.has(uri) && previous !== fingerprint;
213
+ this.#observedDiskFingerprints.set(uri, fingerprint);
214
+ return changed;
208
215
  }
209
216
 
210
217
  /** Forget a document's last observed disk content. */
@@ -322,19 +329,25 @@ export class SemanticInputBarrier {
322
329
  reads: readonly OpenDocumentRead[],
323
330
  ): SynchronizationPlan {
324
331
  const updates: SemanticInputUpdate[] = [];
332
+ const externalDiskChanges: Array<{ readonly filePath: string; readonly content: string }> = [];
325
333
  const observedDiskFingerprints = new Map<string, string | undefined>();
326
334
  for (const read of reads) {
327
335
  const planned = this.#planDocumentRead(pending, read);
328
336
  observedDiskFingerprints.set(read.document.uri, planned.observedDiskFingerprint);
329
337
  if (planned.update) updates.push(planned.update);
338
+ if (planned.externalDiskChange) externalDiskChanges.push(planned.externalDiskChange);
330
339
  }
331
- return { updates, observedDiskFingerprints };
340
+ return { updates, externalDiskChanges, observedDiskFingerprints };
332
341
  }
333
342
 
334
343
  #planDocumentRead(
335
344
  pending: PendingSynchronization,
336
345
  read: OpenDocumentRead,
337
- ): { observedDiskFingerprint: string | undefined; update?: SemanticInputUpdate } {
346
+ ): {
347
+ observedDiskFingerprint: string | undefined;
348
+ update?: SemanticInputUpdate;
349
+ externalDiskChange?: { readonly filePath: string; readonly content: string };
350
+ } {
338
351
  const override = pending.contentOverrides.get(read.document.uri);
339
352
  if (read.result.kind === "error") {
340
353
  return this.#planReadError(read.document, read.result.error, override);
@@ -343,6 +356,12 @@ export class SemanticInputBarrier {
343
356
  const diskFingerprint = fingerprintDocumentContent(read.result.content);
344
357
  const hasObservedDiskContent = this.#observedDiskFingerprints.has(read.document.uri);
345
358
  const previousDiskFingerprint = this.#observedDiskFingerprints.get(read.document.uri);
359
+ const externalDiskChange =
360
+ override === undefined &&
361
+ hasObservedDiskContent &&
362
+ previousDiskFingerprint !== diskFingerprint
363
+ ? { filePath: read.document.filePath, content: read.result.content }
364
+ : undefined;
346
365
  // An explicit override controls server content; the disk fingerprint remains the next observation.
347
366
  const content =
348
367
  override ??
@@ -352,6 +371,7 @@ export class SemanticInputBarrier {
352
371
  const contentFingerprint = fingerprintDocumentContent(content);
353
372
  return {
354
373
  observedDiskFingerprint: diskFingerprint,
374
+ ...(externalDiskChange ? { externalDiskChange } : {}),
355
375
  ...(read.document.contentFingerprint !== contentFingerprint
356
376
  ? { update: { document: read.document, content } }
357
377
  : {}),
@@ -385,6 +405,9 @@ export class SemanticInputBarrier {
385
405
  this.#advanceRevision("content");
386
406
  }
387
407
  this.#rememberObservedDiskFingerprints(plan.observedDiskFingerprints);
408
+ for (const change of plan.externalDiskChanges) {
409
+ this.#host.noteExternalDiskChange?.(change.filePath, change.content);
410
+ }
388
411
  }
389
412
 
390
413
  #advanceRevision(changeKind: SemanticInputChangeKind): void {