pi-ghost-autocomplete 0.3.2 → 0.4.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 (168) hide show
  1. package/LICENSE +561 -0
  2. package/README.md +464 -331
  3. package/dist/bench-cli.js +1 -123
  4. package/dist/bench.d.ts +7 -3
  5. package/dist/bench.js +1 -522
  6. package/dist/config.d.ts +4 -1
  7. package/dist/context-aggregator.d.ts +4 -1
  8. package/dist/cycle-manager.d.ts +2 -21
  9. package/dist/entropy-stop.d.ts +4 -1
  10. package/dist/eval-dataset.d.ts +2 -13
  11. package/dist/fuzzy-matcher.d.ts +4 -1
  12. package/dist/ghost-editor.d.ts +11 -2
  13. package/dist/index.d.ts +4 -1
  14. package/dist/index.js +1 -289
  15. package/dist/intent.d.ts +179 -0
  16. package/dist/metrics.d.ts +4 -1
  17. package/dist/path-index.d.ts +4 -1
  18. package/dist/path-matcher.d.ts +4 -1
  19. package/dist/profile-store.d.ts +4 -1
  20. package/dist/profile.d.ts +2 -20
  21. package/dist/providers/cloud-provider.d.ts +4 -1
  22. package/dist/providers/local-provider.d.ts +4 -1
  23. package/dist/providers/openai-compat-provider.d.ts +24 -1
  24. package/dist/providers/race.d.ts +4 -1
  25. package/dist/providers/types.d.ts +13 -1
  26. package/dist/recent-paths.d.ts +4 -1
  27. package/dist/replay-cli.js +1 -166
  28. package/dist/replay.d.ts +2 -7
  29. package/package.json +90 -80
  30. package/dist/bench-cli.d.ts +0 -3
  31. package/dist/bench-cli.d.ts.map +0 -1
  32. package/dist/bench-cli.js.map +0 -1
  33. package/dist/bench.d.ts.map +0 -1
  34. package/dist/bench.js.map +0 -1
  35. package/dist/cache.d.ts +0 -124
  36. package/dist/cache.d.ts.map +0 -1
  37. package/dist/cache.js +0 -173
  38. package/dist/cache.js.map +0 -1
  39. package/dist/candidate-rerank.d.ts +0 -57
  40. package/dist/candidate-rerank.d.ts.map +0 -1
  41. package/dist/candidate-rerank.js +0 -78
  42. package/dist/candidate-rerank.js.map +0 -1
  43. package/dist/config.d.ts.map +0 -1
  44. package/dist/config.js +0 -317
  45. package/dist/config.js.map +0 -1
  46. package/dist/context-aggregator.d.ts.map +0 -1
  47. package/dist/context-aggregator.js +0 -87
  48. package/dist/context-aggregator.js.map +0 -1
  49. package/dist/context-selector.d.ts +0 -128
  50. package/dist/context-selector.d.ts.map +0 -1
  51. package/dist/context-selector.js +0 -300
  52. package/dist/context-selector.js.map +0 -1
  53. package/dist/cycle-manager.d.ts.map +0 -1
  54. package/dist/cycle-manager.js +0 -168
  55. package/dist/cycle-manager.js.map +0 -1
  56. package/dist/edit-history-ring.d.ts +0 -148
  57. package/dist/edit-history-ring.d.ts.map +0 -1
  58. package/dist/edit-history-ring.js +0 -262
  59. package/dist/edit-history-ring.js.map +0 -1
  60. package/dist/entropy-stop.d.ts.map +0 -1
  61. package/dist/entropy-stop.js +0 -141
  62. package/dist/entropy-stop.js.map +0 -1
  63. package/dist/eval-dataset.d.ts.map +0 -1
  64. package/dist/eval-dataset.js +0 -127
  65. package/dist/eval-dataset.js.map +0 -1
  66. package/dist/fast-path-engine.d.ts +0 -286
  67. package/dist/fast-path-engine.d.ts.map +0 -1
  68. package/dist/fast-path-engine.js +0 -341
  69. package/dist/fast-path-engine.js.map +0 -1
  70. package/dist/fuzzy-matcher.d.ts.map +0 -1
  71. package/dist/fuzzy-matcher.js +0 -162
  72. package/dist/fuzzy-matcher.js.map +0 -1
  73. package/dist/ghost-editor.d.ts.map +0 -1
  74. package/dist/ghost-editor.js +0 -1491
  75. package/dist/ghost-editor.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/keystroke-timer.d.ts +0 -59
  79. package/dist/keystroke-timer.d.ts.map +0 -1
  80. package/dist/keystroke-timer.js +0 -94
  81. package/dist/keystroke-timer.js.map +0 -1
  82. package/dist/metrics-builder.d.ts +0 -71
  83. package/dist/metrics-builder.d.ts.map +0 -1
  84. package/dist/metrics-builder.js +0 -71
  85. package/dist/metrics-builder.js.map +0 -1
  86. package/dist/metrics.d.ts.map +0 -1
  87. package/dist/metrics.js +0 -212
  88. package/dist/metrics.js.map +0 -1
  89. package/dist/path-index.d.ts.map +0 -1
  90. package/dist/path-index.js +0 -148
  91. package/dist/path-index.js.map +0 -1
  92. package/dist/path-matcher.d.ts.map +0 -1
  93. package/dist/path-matcher.js +0 -88
  94. package/dist/path-matcher.js.map +0 -1
  95. package/dist/profile-store.d.ts.map +0 -1
  96. package/dist/profile-store.js +0 -199
  97. package/dist/profile-store.js.map +0 -1
  98. package/dist/profile.d.ts.map +0 -1
  99. package/dist/profile.js +0 -434
  100. package/dist/profile.js.map +0 -1
  101. package/dist/providers/cloud-provider.d.ts.map +0 -1
  102. package/dist/providers/cloud-provider.js +0 -109
  103. package/dist/providers/cloud-provider.js.map +0 -1
  104. package/dist/providers/local-provider.d.ts.map +0 -1
  105. package/dist/providers/local-provider.js +0 -48
  106. package/dist/providers/local-provider.js.map +0 -1
  107. package/dist/providers/openai-compat-provider.d.ts.map +0 -1
  108. package/dist/providers/openai-compat-provider.js +0 -215
  109. package/dist/providers/openai-compat-provider.js.map +0 -1
  110. package/dist/providers/openai-completions-runner.d.ts +0 -52
  111. package/dist/providers/openai-completions-runner.d.ts.map +0 -1
  112. package/dist/providers/openai-completions-runner.js +0 -141
  113. package/dist/providers/openai-completions-runner.js.map +0 -1
  114. package/dist/providers/race.d.ts.map +0 -1
  115. package/dist/providers/race.js +0 -441
  116. package/dist/providers/race.js.map +0 -1
  117. package/dist/providers/truncate.d.ts +0 -7
  118. package/dist/providers/truncate.d.ts.map +0 -1
  119. package/dist/providers/truncate.js +0 -57
  120. package/dist/providers/truncate.js.map +0 -1
  121. package/dist/providers/types.d.ts.map +0 -1
  122. package/dist/providers/types.js +0 -60
  123. package/dist/providers/types.js.map +0 -1
  124. package/dist/provisional-manager.d.ts +0 -93
  125. package/dist/provisional-manager.d.ts.map +0 -1
  126. package/dist/provisional-manager.js +0 -98
  127. package/dist/provisional-manager.js.map +0 -1
  128. package/dist/provisional.d.ts +0 -150
  129. package/dist/provisional.d.ts.map +0 -1
  130. package/dist/provisional.js +0 -238
  131. package/dist/provisional.js.map +0 -1
  132. package/dist/recent-paths.d.ts.map +0 -1
  133. package/dist/recent-paths.js +0 -114
  134. package/dist/recent-paths.js.map +0 -1
  135. package/dist/regret-tracker.d.ts +0 -84
  136. package/dist/regret-tracker.d.ts.map +0 -1
  137. package/dist/regret-tracker.js +0 -145
  138. package/dist/regret-tracker.js.map +0 -1
  139. package/dist/replay-cli.d.ts +0 -13
  140. package/dist/replay-cli.d.ts.map +0 -1
  141. package/dist/replay-cli.js.map +0 -1
  142. package/dist/replay.d.ts.map +0 -1
  143. package/dist/replay.js +0 -225
  144. package/dist/replay.js.map +0 -1
  145. package/dist/reranker.d.ts +0 -181
  146. package/dist/reranker.d.ts.map +0 -1
  147. package/dist/reranker.js +0 -324
  148. package/dist/reranker.js.map +0 -1
  149. package/dist/session-trie.d.ts +0 -103
  150. package/dist/session-trie.d.ts.map +0 -1
  151. package/dist/session-trie.js +0 -280
  152. package/dist/session-trie.js.map +0 -1
  153. package/dist/speculative.d.ts +0 -74
  154. package/dist/speculative.d.ts.map +0 -1
  155. package/dist/speculative.js +0 -107
  156. package/dist/speculative.js.map +0 -1
  157. package/dist/tool-summarize.d.ts +0 -40
  158. package/dist/tool-summarize.d.ts.map +0 -1
  159. package/dist/tool-summarize.js +0 -245
  160. package/dist/tool-summarize.js.map +0 -1
  161. package/dist/trie-sanitize.d.ts +0 -22
  162. package/dist/trie-sanitize.d.ts.map +0 -1
  163. package/dist/trie-sanitize.js +0 -142
  164. package/dist/trie-sanitize.js.map +0 -1
  165. package/dist/versions.d.ts +0 -23
  166. package/dist/versions.d.ts.map +0 -1
  167. package/dist/versions.js +0 -31
  168. package/dist/versions.js.map +0 -1
@@ -1,300 +0,0 @@
1
- /**
2
- * Relevance-pruned context selection. See PRD §M6b.
3
- *
4
- * Replaces the "last N messages" recency window with a scan-then-select
5
- * design motivated by ChaI-TeA (RESEARCH §2): models can exploit distant
6
- * conversation history; a pure recency window blinds the selector to
7
- * high-IDF distant turns.
8
- *
9
- * Pipeline:
10
- * 1. Scan up to `maxScan` candidates from the branch (newest first).
11
- * 2. Tokenize each candidate's text (lower-case, drop stopwords).
12
- * 3. Score each candidate as `0.7 * recencyWeight + 0.3 * bm25Score`,
13
- * both normalized to [0, 1].
14
- * 4. Sort by score, take top `maxSelected`, enforce `maxChars` budget by
15
- * truncating the lowest-recency tail.
16
- *
17
- * Pure module: no I/O, no editor state.
18
- */
19
- export const DEFAULT_MAX_SCAN = 200;
20
- export const DEFAULT_MAX_SELECTED = 8;
21
- export const DEFAULT_MAX_CHARS = 4000;
22
- export const DEFAULT_BM25_WEIGHT = 0.3;
23
- /**
24
- * Enhancement #1: weight on the edit-history token-overlap locality
25
- * signal. Default 0 (opt-in). When > 0, the score formula becomes:
26
- * `score = (1 - bm25Weight - editLocalityWeight) * recency
27
- * + bm25Weight * bm25
28
- * + editLocalityWeight * editLocality`
29
- * where `editLocality` is 1 if the candidate text shares any token with
30
- * `editTokens`, else 0. `bm25Weight + editLocalityWeight` is clamped to
31
- * 1; recency coefficient gets whatever remains.
32
- */
33
- export const DEFAULT_EDIT_LOCALITY_WEIGHT = 0;
34
- export const RECENCY_HALF_LIFE = 4;
35
- const BM25_K1 = 1.5;
36
- const BM25_B = 0.75;
37
- /**
38
- * Small fixed English stopword list. No language detection — when ghost
39
- * autocomplete moves to non-English prompts, this set may need expansion
40
- * or a per-language switch. Until then, the cost of leaving these in is
41
- * higher than the cost of an English-only set.
42
- */
43
- export const STOPWORDS = new Set([
44
- "the",
45
- "a",
46
- "an",
47
- "of",
48
- "and",
49
- "or",
50
- "to",
51
- "in",
52
- "on",
53
- "for",
54
- "is",
55
- "are",
56
- "this",
57
- "that",
58
- ]);
59
- /**
60
- * Tokenize text into lower-case alphanumeric words, dropping stopwords and
61
- * single-character noise. Kept intentionally simple — proper tokenization
62
- * (subword, punctuation handling, code identifiers) would over-fit the
63
- * v0.5 prompt corpus.
64
- *
65
- * Caveat: camelCase identifiers do NOT split. `getRecentMessages` becomes a
66
- * single token `getrecentmessages`. File paths and snake_case split on the
67
- * separator characters and tokenize as expected.
68
- */
69
- export function tokenize(text) {
70
- const out = [];
71
- for (const m of text.toLowerCase().matchAll(/[a-z0-9]+/g)) {
72
- const t = m[0];
73
- if (t.length < 2)
74
- continue;
75
- if (STOPWORDS.has(t))
76
- continue;
77
- out.push(t);
78
- }
79
- return out;
80
- }
81
- /**
82
- * Compute document frequencies over a candidate pool. Used as the corpus
83
- * for BM25's IDF term.
84
- */
85
- export function computeDocFreqs(candidates) {
86
- const docFreqs = new Map();
87
- const docLens = [];
88
- let totalLen = 0;
89
- for (const c of candidates) {
90
- const tokens = tokenize(c.text);
91
- docLens.push(tokens.length);
92
- totalLen += tokens.length;
93
- const seen = new Set();
94
- for (const t of tokens) {
95
- if (seen.has(t))
96
- continue;
97
- seen.add(t);
98
- docFreqs.set(t, (docFreqs.get(t) ?? 0) + 1);
99
- }
100
- }
101
- const avgDocLen = candidates.length > 0 ? totalLen / candidates.length : 0;
102
- return { docFreqs, avgDocLen, docLens };
103
- }
104
- /**
105
- * BM25 score for `queryTokens` against a document. Uses an IDF floor
106
- * `log(1 + 1/N)` so terms appearing in every candidate still contribute a
107
- * small positive score instead of zero — PRD §M6b "BM25-on-small-corpus
108
- * caveat".
109
- */
110
- export function bm25Score(queryTokens, docTokens, docFreqs, N, avgDocLen) {
111
- if (queryTokens.length === 0 || docTokens.length === 0 || N === 0)
112
- return 0;
113
- const docLen = docTokens.length;
114
- const idfFloor = Math.log(1 + 1 / Math.max(1, N));
115
- // Term-frequency in the document.
116
- const tf = new Map();
117
- for (const t of docTokens)
118
- tf.set(t, (tf.get(t) ?? 0) + 1);
119
- let score = 0;
120
- const seenInQuery = new Set();
121
- for (const q of queryTokens) {
122
- if (seenInQuery.has(q))
123
- continue;
124
- seenInQuery.add(q);
125
- const f = tf.get(q);
126
- if (!f)
127
- continue;
128
- const df = docFreqs.get(q) ?? 0;
129
- // Standard Okapi IDF; clamp at the floor so universal terms still count.
130
- const idfRaw = Math.log((N - df + 0.5) / (df + 0.5) + 1);
131
- const idf = Math.max(idfFloor, idfRaw);
132
- const lenNorm = 1 - BM25_B + BM25_B * (docLen / Math.max(1, avgDocLen));
133
- const tfNorm = (f * (BM25_K1 + 1)) / (f + BM25_K1 * lenNorm);
134
- score += idf * tfNorm;
135
- }
136
- return score;
137
- }
138
- /**
139
- * Exponential recency weight: 1.0 at the newest position, decays e-fold
140
- * every `RECENCY_HALF_LIFE` positions. `distance` is positions from the
141
- * newest end of the candidate pool (0 = newest).
142
- */
143
- export function recencyWeight(distance) {
144
- return Math.exp(-distance / RECENCY_HALF_LIFE);
145
- }
146
- function minMaxNormalize(xs) {
147
- if (xs.length === 0)
148
- return [];
149
- let min = Infinity;
150
- let max = -Infinity;
151
- for (const x of xs) {
152
- if (x < min)
153
- min = x;
154
- if (x > max)
155
- max = x;
156
- }
157
- const spread = max - min;
158
- if (spread < 1e-9)
159
- return xs.map(() => 0.5);
160
- return xs.map((x) => (x - min) / spread);
161
- }
162
- /**
163
- * Select the most relevant subset of `candidates` for the current prefix.
164
- * `candidates` should be newest-first (index 0 = newest). Returns selected
165
- * entries in their original branch order (oldest-first of those selected)
166
- * for natural prompt rendering.
167
- */
168
- export function selectContext(candidates, prefix, opts = {}) {
169
- const maxScan = Math.max(0, opts.maxScan ?? DEFAULT_MAX_SCAN);
170
- const maxSelected = Math.max(0, opts.maxSelected ?? DEFAULT_MAX_SELECTED);
171
- const maxChars = Math.max(0, opts.maxChars ?? DEFAULT_MAX_CHARS);
172
- const bm25WeightRaw = Math.min(1, Math.max(0, opts.bm25Weight ?? DEFAULT_BM25_WEIGHT));
173
- const editLocalityWeightRaw = Math.min(1, Math.max(0, opts.editLocalityWeight ?? DEFAULT_EDIT_LOCALITY_WEIGHT));
174
- // Clamp the sum at 1 so recency coefficient never goes negative. If the
175
- // caller asks for bm25=0.7 + editLocality=0.5, scale both proportionally.
176
- const sum = bm25WeightRaw + editLocalityWeightRaw;
177
- const scale = sum > 1 ? 1 / sum : 1;
178
- const bm25Weight = bm25WeightRaw * scale;
179
- const editLocalityWeight = editLocalityWeightRaw * scale;
180
- const recencyWeightCoef = 1 - bm25Weight - editLocalityWeight;
181
- // Normalize editTokens to lowercase to align with the selector's tokenize.
182
- // Edit-history tokens preserve identifier case (code identifiers are
183
- // case-sensitive); context-selector lowercases (prose tokens). Compare
184
- // post-normalization so the two spaces meet.
185
- const editTokens = opts.editTokens
186
- ? new Set(Array.from(opts.editTokens, (t) => t.toLowerCase()))
187
- : undefined;
188
- const editLocalityActive = editLocalityWeight > 0 && editTokens && editTokens.size > 0;
189
- const scanned = candidates.slice(0, maxScan);
190
- if (scanned.length === 0 || maxSelected === 0) {
191
- return { candidates: [], scannedCount: 0, selectedCount: 0, totalChars: 0 };
192
- }
193
- const queryTokens = tokenize(prefix);
194
- const { docFreqs, avgDocLen } = computeDocFreqs(scanned);
195
- // Per-candidate raw scores.
196
- const recencyRaw = scanned.map((_, i) => recencyWeight(i));
197
- const docTokens = scanned.map((c) => tokenize(c.text));
198
- const bm25Raw = docTokens.map((toks) => bm25Score(queryTokens, toks, docFreqs, scanned.length, avgDocLen));
199
- const editLocalityRaw = editLocalityActive
200
- ? docTokens.map((toks) => (toks.some((t) => editTokens.has(t)) ? 1 : 0))
201
- : scanned.map(() => 0);
202
- const recencyNorm = minMaxNormalize(recencyRaw);
203
- const bm25Norm = minMaxNormalize(bm25Raw);
204
- // editLocality is already in {0, 1} — skip normalization.
205
- const combined = scanned.map((c, i) => ({
206
- candidate: c,
207
- score: recencyWeightCoef * recencyNorm[i] +
208
- bm25Weight * bm25Norm[i] +
209
- editLocalityWeight * editLocalityRaw[i],
210
- // Carry the newest-first index for ordering selected entries back into
211
- // chronological order at the end.
212
- index: i,
213
- }));
214
- // Top-N by score; ties broken by recency (lower index = newer).
215
- combined.sort((a, b) => {
216
- const ds = b.score - a.score;
217
- if (Math.abs(ds) > 1e-9)
218
- return ds;
219
- return a.index - b.index;
220
- });
221
- const topN = combined.slice(0, maxSelected);
222
- // Char-budget enforcement (PRD §M6b: "drop lowest-recency tail").
223
- // Sort newest-first then greedily fill — once the budget would be
224
- // exceeded, stop. This gives priority to newer entries, which matches
225
- // PRD's "drop lowest-recency tail" intent.
226
- //
227
- // Edge case: the very first (newest) entry's `len` may exceed `maxChars`
228
- // on its own. We still keep it (the alternative is no context at all),
229
- // even though `totalChars` then exceeds the budget. This is a documented
230
- // best-effort policy — a future revision could truncate such entries
231
- // mid-text, but that risks splitting mid-token.
232
- topN.sort((a, b) => a.index - b.index);
233
- let totalChars = 0;
234
- const kept = [];
235
- for (const c of topN) {
236
- const len = c.candidate.text.length;
237
- if (totalChars + len > maxChars && kept.length > 0) {
238
- break;
239
- }
240
- totalChars += len;
241
- kept.push(c);
242
- }
243
- // Render oldest-first for natural prompt rendering (newest at the end).
244
- kept.sort((a, b) => b.index - a.index);
245
- return {
246
- candidates: kept.map((k) => k.candidate),
247
- scannedCount: scanned.length,
248
- selectedCount: kept.length,
249
- totalChars,
250
- };
251
- }
252
- /**
253
- * Parse `PI_GHOST_CONTEXT_BM25_WEIGHT`. Returns fallback on bad input or
254
- * outside [0, 1].
255
- */
256
- export function parseBm25WeightEnv(raw) {
257
- if (raw === undefined)
258
- return DEFAULT_BM25_WEIGHT;
259
- const v = Number(raw);
260
- if (!Number.isFinite(v) || v < 0 || v > 1)
261
- return DEFAULT_BM25_WEIGHT;
262
- return v;
263
- }
264
- /**
265
- * Parse `PI_GHOST_CONTEXT_EDIT_LOCALITY_WEIGHT`. Returns 0 (no-op) on bad
266
- * input or outside [0, 1]. Enhancement #1.
267
- */
268
- export function parseEditLocalityWeightEnv(raw) {
269
- if (raw === undefined)
270
- return DEFAULT_EDIT_LOCALITY_WEIGHT;
271
- const v = Number(raw);
272
- if (!Number.isFinite(v) || v < 0 || v > 1)
273
- return DEFAULT_EDIT_LOCALITY_WEIGHT;
274
- return v;
275
- }
276
- function numEnv(name, fallback, min = 0, max = Number.POSITIVE_INFINITY) {
277
- const raw = process.env[name];
278
- if (!raw)
279
- return fallback;
280
- const v = Number(raw);
281
- if (!Number.isFinite(v) || v < min || v > max)
282
- return fallback;
283
- return Math.floor(v);
284
- }
285
- /**
286
- * Build a `ContextSelectorOpts` from the documented env knobs (PRD §M6d).
287
- * Returns a defaulted opts object. `editTokens` is omitted — the caller
288
- * must inject the live edit-history token set on each call (env can only
289
- * configure the weight, not the dynamic data).
290
- */
291
- export function readContextEnv() {
292
- return {
293
- maxScan: numEnv("PI_GHOST_CONTEXT_MAX_SCAN", DEFAULT_MAX_SCAN, 0),
294
- maxSelected: numEnv("PI_GHOST_CONTEXT_MAX_SELECTED", DEFAULT_MAX_SELECTED, 0),
295
- maxChars: numEnv("PI_GHOST_CONTEXT_MAX_CHARS", DEFAULT_MAX_CHARS, 0),
296
- bm25Weight: parseBm25WeightEnv(process.env.PI_GHOST_CONTEXT_BM25_WEIGHT),
297
- editLocalityWeight: parseEditLocalityWeightEnv(process.env.PI_GHOST_CONTEXT_EDIT_LOCALITY_WEIGHT),
298
- };
299
- }
300
- //# sourceMappingURL=context-selector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-selector.js","sourceRoot":"","sources":["../src/context-selector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,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AED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO;IAc3B;;;;;;;;;;;;OAYG;IACH,uBAAuB,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;IAgBtE;;OAEG;IACH,QAAQ,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;CAQ5E"}
@@ -1,168 +0,0 @@
1
- /**
2
- * CycleManager — owns multi-candidate state and word-level partial-accept
3
- * gestures for the GREAT Ghost autocomplete.
4
- *
5
- * PRD §M3e (Alt+]/Alt+[ cycling with clamp-at-edges, no wrap) +
6
- * PRD §M3f (Ctrl+Right word-by-word acceptance in append mode).
7
- *
8
- * Design notes:
9
- *
10
- * - Candidate list is stored read-only (frozen) so that future refactors
11
- * don't accidentally mutate ranked text. Per-candidate consumption from
12
- * word-level accepts is tracked separately in `consumed[idx]`.
13
- * - `current` returns `string | null` — `null` distinguishes "no candidates
14
- * installed" from "current candidate is empty after full consumption".
15
- * - `acceptPartialWordAppend()` is named to make the append-mode invariant
16
- * impossible to forget at call sites. Replace-mode ghosts (fuzzy/path)
17
- * accept atomically; word-by-word doesn't apply.
18
- * - No hidden auto-reset: caller is responsible for `reset()` after the
19
- * final-chunk accept so the lifecycle is explicit.
20
- *
21
- * Extracted as part of refactor #57 so `GhostEditor` stays thin.
22
- */
23
- function emptyState() {
24
- return {
25
- originals: Object.freeze([]),
26
- consumed: [],
27
- candidateIdx: 0,
28
- cycledCount: 0,
29
- partialAccepts: 0,
30
- };
31
- }
32
- /**
33
- * Pure helper: compute the next index for Alt+]/Alt[+ cycle.
34
- * Returns null when the move would go past an edge (no wrap, per PRD).
35
- */
36
- export function cycleCandidateIdx(currentIdx, len, dir) {
37
- if (len <= 1)
38
- return null;
39
- const next = currentIdx + dir;
40
- if (next < 0 || next >= len)
41
- return null;
42
- return next;
43
- }
44
- /**
45
- * Extract the next lexical "word" chunk from the start of a ghost string.
46
- * Skips leading whitespace, then either consumes an identifier run (`\w+`)
47
- * OR a single non-word non-space char so code like `foo("bar")` accepts as
48
- * `foo`, `(`, `"`, `bar`, `"`, `)` rather than gulping the whole
49
- * expression. Used by Ctrl+Right partial accept.
50
- *
51
- * Returns the empty string when the ghost is empty or contains only
52
- * whitespace — caller treats that as a no-op.
53
- */
54
- export function nextWordChunk(ghost) {
55
- if (!ghost)
56
- return "";
57
- const m = /^\s*(\w+|[^\s\w])/.exec(ghost);
58
- return m ? m[0] : "";
59
- }
60
- /**
61
- * CycleManager — small mutable facade over CycleState.
62
- * All mutation goes through the manager so editor code stays declarative.
63
- */
64
- export class CycleManager {
65
- state = emptyState();
66
- reset() {
67
- this.state = emptyState();
68
- }
69
- /**
70
- * Install a fresh ranked candidate list for a newly shown ghost.
71
- * Always resets indices, cycledCount, partialAccepts, and consumed
72
- * offsets. The stored list is frozen — partial-accepts shrink the
73
- * per-candidate `consumed` offset, never the underlying text.
74
- */
75
- setCandidates(texts) {
76
- const originals = Object.freeze(texts.length > 0 ? [...texts] : []);
77
- this.state = {
78
- originals,
79
- consumed: new Array(originals.length).fill(0),
80
- candidateIdx: 0,
81
- cycledCount: 0,
82
- partialAccepts: 0,
83
- };
84
- }
85
- /**
86
- * Read-only view of the ranked candidate list as installed. Stable across
87
- * partial accepts (consumption is tracked separately via `current`).
88
- */
89
- get candidates() {
90
- return this.state.originals;
91
- }
92
- /**
93
- * Currently displayed ghost text — the un-consumed remainder of the
94
- * candidate at `candidateIdx`. Returns `null` when no candidates are
95
- * installed; returns `""` when the current candidate has been fully
96
- * consumed by partial accepts (caller must then `reset()`).
97
- */
98
- get current() {
99
- const o = this.state.originals[this.state.candidateIdx];
100
- if (o === undefined)
101
- return null;
102
- return o.slice(this.state.consumed[this.state.candidateIdx] ?? 0);
103
- }
104
- get cycledCount() {
105
- return this.state.cycledCount;
106
- }
107
- get partialAccepts() {
108
- return this.state.partialAccepts;
109
- }
110
- get candidateIdx() {
111
- return this.state.candidateIdx;
112
- }
113
- /**
114
- * Attempt a cycle in the given direction. Returns true if the ghost text
115
- * actually changed (i.e., a legal non-edge move occurred). Each
116
- * candidate retains its own `consumed` offset across cycles so the user
117
- * can partial-accept on A, cycle to B, cycle back to A and resume.
118
- */
119
- cycle(dir) {
120
- const nextIdx = cycleCandidateIdx(this.state.candidateIdx, this.state.originals.length, dir);
121
- if (nextIdx === null) {
122
- return false;
123
- }
124
- this.state.candidateIdx = nextIdx;
125
- this.state.cycledCount++;
126
- return true;
127
- }
128
- /**
129
- * Perform a word-level partial accept on the currently displayed
130
- * candidate. APPEND MODE ONLY — callers must check
131
- * `!ghostReplaceFrom && cursorAtEnd()` before invoking. Naming
132
- * deliberately includes `Append` so the invariant is impossible to
133
- * forget at the call site.
134
- *
135
- * Returns the chunk that should be inserted now, plus the remaining
136
- * ghost suffix (or `null` if this was the final chunk). When `remaining`
137
- * is `null` the caller is responsible for finalizing and calling
138
- * `reset()` — the manager does NOT auto-reset so lifecycle stays
139
- * explicit.
140
- */
141
- acceptPartialWordAppend() {
142
- const cur = this.current;
143
- if (cur === null || cur.length === 0) {
144
- return { chunk: "", remaining: null };
145
- }
146
- const chunk = nextWordChunk(cur);
147
- if (!chunk) {
148
- return { chunk: "", remaining: null };
149
- }
150
- const idx = this.state.candidateIdx;
151
- this.state.consumed[idx] = (this.state.consumed[idx] ?? 0) + chunk.length;
152
- this.state.partialAccepts++;
153
- const tail = cur.slice(chunk.length);
154
- return { chunk, remaining: tail.length === 0 ? null : tail };
155
- }
156
- /**
157
- * Snapshot for diagnostics / metrics (no raw candidate text leaked).
158
- */
159
- snapshot() {
160
- return {
161
- count: this.state.originals.length,
162
- idx: this.state.candidateIdx,
163
- cycled: this.state.cycledCount,
164
- partials: this.state.partialAccepts,
165
- };
166
- }
167
- }
168
- //# sour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ACnC,CAAC;IACH,CAAC;CACD"}
@@ -1,148 +0,0 @@
1
- /**
2
- * Edit-history ring + aggregated index. Enhancement #1
3
- * (Next-Edit-Prediction motivated). See `docs/edit-history-signals-spec.md`.
4
- *
5
- * Records the most recent K edits (default 32) made in-session, then
6
- * exposes:
7
- * - a `snapshot()` of newest-first events with age filtering, and
8
- * - an `index()` of decayed token frequencies + per-URI line proximity.
9
- *
10
- * The reranker reads `index()` to compute `editProximityBoost`; the M6
11
- * context selector reads it (opt-in) for a token-overlap locality bit.
12
- *
13
- * Privacy: events are pre-sanitized at capture (`containsSensitive` on
14
- * the raw added/removed text — caller is responsible for invoking it
15
- * before calling `record`). Only tokens + scalars + URIs survive. No
16
- * raw text is ever stored on the ring. The ring lives in-process only —
17
- * no persistence in v0.5.
18
- */
19
- export declare const TOKEN_CAP_PER_EVENT = 16;
20
- export declare const DEFAULT_CAPACITY = 32;
21
- export declare const DEFAULT_MAX_AGE_MS: number;
22
- export declare const DEFAULT_HALF_LIFE_MS: number;
23
- export interface EditEvent {
24
- ts: number;
25
- uri: string;
26
- rangeStartLine: number;
27
- addedTokens: string[];
28
- removedTokens: string[];
29
- netCharDelta: number;
30
- }
31
- export interface EditHistoryIndex {
32
- addedFreq: Map<string, number>;
33
- removedFreq: Map<string, number>;
34
- recentUris: Set<string>;
35
- lastEditLineByUri: Map<string, number>;
36
- totalEvents: number;
37
- }
38
- export interface EditHistoryOpts {
39
- capacity?: number;
40
- maxAgeMs?: number;
41
- halfLifeMs?: number;
42
- }
43
- /**
44
- * Tokenize text using the same regex as `profile.ts` (`\b[\w][\w-]*\b`).
45
- * Code identifiers are case-sensitive — we do NOT lowercase. Result is
46
- * capped at `TOKEN_CAP_PER_EVENT` to bound memory per event.
47
- */
48
- export declare function tokenize(text: string): string[];
49
- /**
50
- * Exponential time-decay weight: 1.0 at `ageMs=0`, halves every
51
- * `halfLifeMs`. Pure helper for tests + index().
52
- */
53
- export declare function timeDecayWeight(ageMs: number, halfLifeMs?: number): number;
54
- export declare class EditHistoryRing {
55
- private readonly events;
56
- readonly capacity: number;
57
- readonly maxAgeMs: number;
58
- readonly halfLifeMs: number;
59
- constructor(opts?: EditHistoryOpts);
60
- /**
61
- * Append an event. `ts` defaults to `Date.now()`. Caller is responsible
62
- * for sanitization — the ring does not re-validate. Overflow drops the
63
- * oldest event.
64
- */
65
- record(ev: Omit<EditEvent, "ts"> & {
66
- ts?: number;
67
- }): void;
68
- /**
69
- * Newest-first list of events not older than `maxAgeMs`. Returns a
70
- * copy — safe for the caller to retain.
71
- *
72
- * Scans without early-break: we cannot assume `record()` was called in
73
- * ts-monotonic order (a backfill or test clock could insert older
74
- * events after newer ones). At capacity=32 the scan cost is trivial.
75
- */
76
- snapshot(now?: number): EditEvent[];
77
- /**
78
- * Aggregated index of recent edit signals, with exponential time-decay
79
- * applied to token frequencies. URIs touched within `maxAgeMs` are
80
- * collected; the *most recent* edit line per URI is kept (used by the
81
- * reranker for line-proximity scoring).
82
- */
83
- index(now?: number): EditHistoryIndex;
84
- clear(): void;
85
- get size(): number;
86
- }
87
- /** Default per-entry size cap. 1 MB — large enough for any realistic
88
- * source file, small enough that 16 × 1MB = 16MB worst-case is bounded. */
89
- export declare const DEFAULT_PRE_EDIT_MAX_BYTES: number;
90
- /**
91
- * Per-document pre-edit text cache. Holds the most recent `capacity`
92
- * document texts so we can derive the *removed* slice of an edit before
93
- * the on-disk text mutates. LRU-bounded to avoid pinning every project
94
- * file in RAM. v0.5 stores transiently in process only — never persisted.
95
- *
96
- * Per-entry size is capped at `maxBytesPerEntry` (default 1 MB). Texts
97
- * exceeding the cap are stored as empty string — the next edit on that
98
- * document will derive empty `removedTokens`, which is the same
99
- * degradation as a fresh LRU miss. This bounds worst-case memory at
100
- * `capacity * maxBytesPerEntry` regardless of project file sizes.
101
- */
102
- export declare class PreEditTextCache {
103
- private readonly map;
104
- readonly capacity: number;
105
- readonly maxBytesPerEntry: number;
106
- constructor(capacity?: number, maxBytesPerEntry?: number);
107
- /** Returns the snapshot for `uri` (or `""` if absent) without touching LRU order. */
108
- peek(uri: string): string;
109
- /**
110
- * Update the snapshot. Move-to-front semantics; oldest is evicted when
111
- * capacity is exceeded. Texts exceeding `maxBytesPerEntry` are stored
112
- * as empty string (the next edit on this URI gets no `removedTokens`,
113
- * matching the LRU-miss degradation path).
114
- *
115
- * Byte length uses UTF-16 code units (`text.length`), not UTF-8 bytes —
116
- * the cap is approximate but stable across machines.
117
- */
118
- update(uri: string, text: string): void;
119
- clear(): void;
120
- get size(): number;
121
- }
122
- /**
123
- * Spec §5.1 — compute the raw `editProximityScore` for a candidate. Pure
124
- * function. Returns 0 when the ring is empty (zero events). Output is
125
- * un-normalized: the reranker's min-max normalization re-maps the value
126
- * across the candidate set so absolute scale doesn't matter — only the
127
- * relative ordering does. The same un-normalized value is reported on
128
- * the `MetricRecord` for observability.
129
- *
130
- * `currentUri` / `currentLine` describe the user's cursor at predict
131
- * time. The prompt-buffer editor uses a static `"prompt"` URI sentinel
132
- * and the current cursor line.
133
- */
134
- export declare function editProximityScore(text: string, index: EditHistoryIndex, currentUri: string, currentLine: number): number;
135
- /**
136
- * Pure character-diff helper. Returns the minimal `{ added, removed }`
137
- * slice between two strings by stripping the common prefix + suffix.
138
- * Caller is responsible for `containsSensitive` checks before tokenizing
139
- * the result. Returns empty strings for both sides when texts are equal.
140
- */
141
- export declare function diffStrings(prev: string, next: string): {
142
- added: string;
143
- removed: string;
144
- };
145
- export declare function readEditHistoryEnv(env?: Record<string, string | undefined>): Required<EditHistoryOpts> & {
146
- enabled: boolean;
147
- };
148
- //# sourceMappingURL=edit-history-ring.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit-history-ring.d.ts","sourceRoot":"","sources":["../src/edit-history-ring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,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