openlore 2.0.5 → 2.0.7

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.
@@ -8,14 +8,36 @@
8
8
  * The call graph is deliberately excluded — rebuilding it requires full
9
9
  * tree-sitter analysis of all call sites and is too expensive for a watch loop.
10
10
  * It stays current via the post-commit hook (openlore analyze --force --embed).
11
+ *
12
+ * Spec 13.1 (watch-mode performance): freshness is O(change), not O(repo).
13
+ * • Per-file events COALESCE into one batched flush (single debounce timer +
14
+ * hard max-batch ceiling), so a burst / branch-switch runs the pipeline once,
15
+ * not once per file.
16
+ * • The patched llm-context is handed to the MCP read cache in place
17
+ * (primeContextCache), so the next tool call is a cache HIT — no 2.1 MB
18
+ * cold re-parse — even after the disk write.
19
+ * • Vector updates are row-level (VectorIndex.updateFiles), not a full-corpus
20
+ * read+overwrite, and run on a separate lower-priority lane so signature
21
+ * freshness never blocks on embedding.
22
+ * • VCS-flood / bulk batches are detected and collapsed to a single refresh.
23
+ * • stderr emits one summary line per batch by default (per-file detail behind
24
+ * OPENLORE_WATCH_DEBUG).
11
25
  */
12
26
  export interface McpWatcherOptions {
13
27
  /** Absolute path to the project root being watched */
14
28
  rootPath: string;
15
29
  /** Absolute path to .openlore/analysis/ — where llm-context.json lives */
16
30
  outputPath?: string;
17
- /** Milliseconds to debounce file-change events (default: 400) */
31
+ /** Milliseconds to debounce file-change events (default: WATCH_DEBOUNCE_MS) */
18
32
  debounceMs?: number;
33
+ /** Hard flush ceiling under a continuous change stream (default: WATCH_MAX_BATCH_MS) */
34
+ maxBatchMs?: number;
35
+ /** Batch size that trips VCS-flood handling (default: WATCH_BULK_THRESHOLD) */
36
+ bulkThreshold?: number;
37
+ /** Run the live vector update; false = signatures-only (default: true) */
38
+ embed?: boolean;
39
+ /** Above this many watched source files, auto-degrade to signatures-only */
40
+ embedFileCeiling?: number;
19
41
  /** Extra glob patterns to ignore in addition to defaults */
20
42
  ignore?: string[];
21
43
  }
@@ -31,20 +53,82 @@ export declare function isIgnoredRelPath(relPath: string): boolean;
31
53
  export declare class McpWatcher {
32
54
  private readonly rootPath;
33
55
  private readonly outputPath;
56
+ private readonly contextPath;
34
57
  private readonly debounceMs;
58
+ private readonly maxBatchMs;
59
+ private readonly bulkThreshold;
60
+ private readonly embedFileCeiling;
35
61
  private readonly extraIgnore;
62
+ private readonly debug;
36
63
  private fsWatcher?;
37
- private timers;
64
+ private gitWatcher?;
65
+ private pending;
66
+ private debounceTimer?;
67
+ private maxBatchTimer?;
38
68
  private running;
69
+ private vcsBulkFlag;
70
+ private embed;
71
+ private embedDegraded;
72
+ private embedFiles;
73
+ private embedNodes;
74
+ private embedTimer?;
75
+ private embedRunning;
76
+ private lastEmbedContext?;
39
77
  constructor(options: McpWatcherOptions);
40
78
  start(): Promise<void>;
41
79
  stop(): Promise<void>;
42
- private scheduleChange;
43
80
  /**
44
- * Re-index a single changed file.
45
- * Exposed for unit testing without needing a real file watcher.
81
+ * Add a changed path to the pending set and (re)arm a single debounce timer,
82
+ * plus a one-shot hard ceiling so a continuous stream still flushes.
83
+ */
84
+ private enqueue;
85
+ /** A .git ref changed — settle, then flush whatever changed as one bulk batch. */
86
+ private onVcsEvent;
87
+ /**
88
+ * Drain the pending set into a single batch. Single-flight: if a flush is
89
+ * already running, leave the new paths in `pending` and reschedule once it
90
+ * finishes — never interleave two flushes.
91
+ */
92
+ private flush;
93
+ /**
94
+ * Re-index a single changed file. Exposed for unit testing without needing a
95
+ * real file watcher; flushes synchronously so callers observe the update on
96
+ * disk immediately. Internally this is just a batch of one.
46
97
  */
47
98
  handleChange(absPath: string): Promise<void>;
48
- private reEmbed;
99
+ /**
100
+ * Process a coalesced batch of changed files as ONE pipeline pass:
101
+ * • per-file incremental edge update (content-hash skip), all under one open
102
+ * EdgeStore;
103
+ * • ONE signature patch + ONE llm-context persist + ONE read-cache handoff;
104
+ * • ONE vector update (inline when syncFlush, else on the embed lane).
105
+ */
106
+ private handleBatch;
107
+ /**
108
+ * True when this watcher writes to the canonical `<root>/.openlore/analysis`
109
+ * layout that the MCP read handlers cache against. Only then is the shared
110
+ * in-memory read cache (primeContextCache) the right channel to prime; a custom
111
+ * `outputPath` (tests / non-standard installs) writes only to disk.
112
+ */
113
+ private get usesStandardLayout();
114
+ /**
115
+ * Load the context the watcher is about to patch. This ALWAYS reads fresh from
116
+ * disk — never through the shared read cache — because the cache is a read-path
117
+ * (tool-call) optimization, and patching a possibly-stale cached object could
118
+ * silently drop signatures written by a concurrent `analyze` between events.
119
+ * The writer reads ground truth; persistContext then primes the read cache with
120
+ * the result so the next tool call is still a hit (Step 2a, G1).
121
+ */
122
+ private loadContext;
123
+ private persistContext;
124
+ private scheduleEmbed;
125
+ private runEmbedLane;
126
+ /**
127
+ * Row-level vector update for the changed files only (Step 3). Falls back to a
128
+ * silent no-op when no embedding service and no index are available.
129
+ */
130
+ private updateVectors;
131
+ /** Bounded count of watched source files; stops early once `cap` is exceeded. */
132
+ private countSourceFiles;
49
133
  }
50
134
  //# sourceMappingURL=mcp-watcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-watcher.d.ts","sourceRoot":"","sources":["../../../src/core/services/mcp-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuBH,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAuCD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUzD;AAID,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,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