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,199 +0,0 @@
1
- /**
2
- * Stateful wrapper around `profile.ts` for the editor. Holds the in-memory
3
- * `ProfileIndex`, serializes writes, triggers periodic compaction, and
4
- * exposes a synchronous lookup surface for the editor's hot path.
5
- *
6
- * Lifecycle:
7
- * 1. `create(cwd)` — loads + indexes the JSONL once. Returns a disabled
8
- * store if `PI_GHOST_PROFILE=off`. Errors during load yield an empty
9
- * index (best-effort).
10
- * 2. `captureCommit(text)` / `captureAccept(prefix, completion, weight)`
11
- * — append to disk (async, fire-and-forget) and merge into the
12
- * in-memory index so the next lookup sees them immediately.
13
- * 3. Every `COMPACT_CHECK_EVERY` writes the store runs `compactIfNeeded`
14
- * in the background. Compaction reloads the index after rewrite.
15
- *
16
- * `disabled` is a public boolean so callers can short-circuit lookups
17
- * without an extra function call on the keystroke path.
18
- */
19
- import { appendRecords, bestSlashMatch, buildIndex, compactIfNeeded, DEFAULT_DECAY_DAYS, emptyIndex, loadRecords, parseDecayDaysEnv, prefixHash, profileBias, profilePathBoost, recordsFromCommit, recordFromAccept, } from "./profile.js";
20
- // `loadRecords` referenced only inside the `create` static; `buildIndex`
21
- // likewise. Both retained in imports. Keep this import block fixed so
22
- // future additions don't bring in unused symbols silently.
23
- const COMPACT_CHECK_EVERY = 100;
24
- export class ProfileStore {
25
- cwd;
26
- disabled;
27
- index = emptyIndex();
28
- writeQueue = Promise.resolve();
29
- writesSinceCompact = 0;
30
- decayDays;
31
- constructor(cwd, opts) {
32
- this.cwd = cwd;
33
- this.disabled = opts.disabled;
34
- this.decayDays = opts.decayDays;
35
- }
36
- /**
37
- * Build a store and load the JSONL into memory. Caller awaits before
38
- * exposing the store to the editor so the index is hot on first
39
- * keystroke. Disabled stores short-circuit load entirely.
40
- */
41
- static async create(cwd, env = process.env) {
42
- const disabled = env.PI_GHOST_PROFILE === "off";
43
- const decayDays = parseDecayDaysEnv(env.PI_GHOST_PROFILE_DECAY_DAYS);
44
- const store = new ProfileStore(cwd, { disabled, decayDays });
45
- if (!disabled) {
46
- try {
47
- const records = await loadRecords(cwd);
48
- store.index = buildIndex(records, { decayDays });
49
- }
50
- catch {
51
- // best-effort
52
- }
53
- }
54
- return store;
55
- }
56
- getIndex() {
57
- return this.index;
58
- }
59
- get decayDaysSetting() {
60
- return this.decayDays;
61
- }
62
- /**
63
- * Capture user-committed text. Extracts paths + slash + trigrams, drops
64
- * sensitive messages entirely. Returns the count of records emitted —
65
- * useful for tests/diagnostics.
66
- */
67
- captureCommit(text, ts = Date.now()) {
68
- if (this.disabled)
69
- return 0;
70
- const recs = recordsFromCommit(text, ts);
71
- if (recs.length === 0)
72
- return 0;
73
- this.mergeAndPersist(recs);
74
- return recs.length;
75
- }
76
- /**
77
- * Capture an accept (full or partial). `weight` defaults to 3 to match
78
- * PRD §M2 trie weights. Returns true when a record was emitted.
79
- */
80
- captureAccept(prefix, completion, weight = 3, ts = Date.now()) {
81
- if (this.disabled)
82
- return false;
83
- const rec = recordFromAccept(prefix, completion, weight, ts);
84
- if (!rec)
85
- return false;
86
- this.mergeAndPersist([rec]);
87
- return true;
88
- }
89
- /** Public lookup surfaces — thin wrappers around `profile.ts`. */
90
- bestSlashMatch(prefix) {
91
- if (this.disabled)
92
- return null;
93
- return bestSlashMatch(this.index, prefix);
94
- }
95
- profileBias(text) {
96
- if (this.disabled)
97
- return 0;
98
- return profileBias(this.index, text);
99
- }
100
- profilePathBoost(path) {
101
- if (this.disabled)
102
- return 0;
103
- return profilePathBoost(this.index, path);
104
- }
105
- /**
106
- * Provisional fallback (PRD §M3.5b) — look up an exact-prefix accept
107
- * record. Returns the completion tokens + summed weight, or null when
108
- * the prefix has never been the exact key of a captured accept.
109
- * `prefix` is hashed in-process; the raw string never leaves memory.
110
- */
111
- lookupAcceptByPrefix(prefix) {
112
- if (this.disabled || !prefix)
113
- return null;
114
- const hit = this.index.acceptByPrefix.get(prefixHash(prefix));
115
- return hit ? { completionTokens: hit.completionTokens, weight: hit.weight } : null;
116
- }
117
- /** Flush any pending writes — call before process exit. */
118
- async flush() {
119
- await this.writeQueue;
120
- }
121
- /**
122
- * Append records both in-memory and to disk. In-memory merge happens
123
- * synchronously so the very next lookup sees the new weight; the disk
124
- * write is queued through `writeQueue` to serialize concurrent commits.
125
- */
126
- mergeAndPersist(recs) {
127
- // Merge into in-memory index. Rebuilding from scratch is wasteful
128
- // for one record; instead apply the same buildIndex rules inline.
129
- this.applyToIndex(recs);
130
- this.writesSinceCompact += recs.length;
131
- const shouldCompact = this.writesSinceCompact >= COMPACT_CHECK_EVERY;
132
- if (shouldCompact)
133
- this.writesSinceCompact = 0;
134
- this.writeQueue = this.writeQueue
135
- .then(() => appendRecords(this.cwd, recs))
136
- .then(async () => {
137
- if (!shouldCompact)
138
- return;
139
- // Background compaction rewrites the file. The in-memory
140
- // index is NOT reloaded afterward: between the loadRecords
141
- // step inside `compactIfNeeded` and our reload, additional
142
- // `applyToIndex` calls would have mutated `this.index` —
143
- // reloading would lose them. The in-memory index is the
144
- // authoritative session view; compaction's purpose is
145
- // disk-size reduction. Next session start re-reads the
146
- // compacted file via `ProfileStore.create`.
147
- await compactIfNeeded(this.cwd, { decayDays: this.decayDays });
148
- })
149
- .catch(() => {
150
- /* logging must never break completions */
151
- });
152
- }
153
- /**
154
- * Inline equivalent of `buildIndex` for a small record batch. The
155
- * fresh-record path skips decay since we just wrote `ts`. Keeping this
156
- * separate from `profile.buildIndex` avoids reindexing the whole store
157
- * on every keystroke.
158
- */
159
- applyToIndex(recs) {
160
- for (const r of recs) {
161
- const w = r.weight;
162
- switch (r.kind) {
163
- case "ngram":
164
- if (r.tokens && r.tokens.length > 0) {
165
- const key = r.tokens.join(" ");
166
- this.index.ngram.set(key, (this.index.ngram.get(key) ?? 0) + w);
167
- }
168
- break;
169
- case "path":
170
- if (r.value)
171
- this.index.path.set(r.value, (this.index.path.get(r.value) ?? 0) + w);
172
- break;
173
- case "slash":
174
- if (r.value)
175
- this.index.slash.set(r.value, (this.index.slash.get(r.value) ?? 0) + w);
176
- break;
177
- case "accept":
178
- if (r.prefixHash && r.completionTokens) {
179
- const existing = this.index.acceptByPrefix.get(r.prefixHash);
180
- if (existing) {
181
- existing.weight += w;
182
- existing.completionTokens = r.completionTokens;
183
- }
184
- else {
185
- this.index.acceptByPrefix.set(r.prefixHash, {
186
- completionTokens: r.completionTokens,
187
- weight: w,
188
- });
189
- }
190
- this.index.totalAcceptRecords += 1;
191
- }
192
- break;
193
- }
194
- }
195
- }
196
- }
197
- /** Exported for tests — surface compactor knob without re-exporting `profile.ts`. */
198
- export { DEFAULT_DECAY_DAYS };
199
- //# sourceMappingURL=profile-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile-store.js","sourceRoot":"","sources":["../src/profile-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACN,aAAa,EACb,cAAc,EACd,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GAGhB,MAAM,cAAc,CAAC;AAEtB,yEAAyE;AACzE,sEAAsE;AACtE,2DAA2D;AAE3D,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC,MAAM,OAAO,YAAY;IAQN;IAPT,QAAQ,CAAU;IACnB,KAAK,GAAiB,UAAU,EAAE,CAAC;IACnC,UAAU,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9C,kBAAkB,GAAG,CAAC,CAAC;IACvB,SAAS,CAAS;IAE1B,YACkB,GAAW,EAC5B,IAA8C;QAD7B,QAAG,GAAH,GAAG,CAAQ;QAG5B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,MAAyB,OAAO,CAAC,GAAG;QACpE,MAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,KAAK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,GAAG,SAAS,GAAG,MAAM,CAKjE"}
package/dist/profile.js DELETED
@@ -1,434 +0,0 @@
1
- /**
2
- * User profile — long-lived, cross-session frequency store. PRD §M4.
3
- *
4
- * Storage: `.pi/ghost-autocomplete/profile.jsonl` (append-only). One JSON
5
- * record per line, written via the in-process writer.
6
- *
7
- * The profile feeds three local-only signals:
8
- * - ngram trigrams → reranker `profileBias` (PRD §M3c hook)
9
- * - path frequency → bounded boost to deterministic path/fuzzy ranking
10
- * - slash-command frequency → editor fast-path for `/cmd…` prefixes
11
- *
12
- * Privacy: raw full prefixes and full completions are NEVER persisted. We
13
- * store sanitized n-grams (≤4), absolute paths, slash commands, and SHA-256
14
- * hashes of prefix keys (`prefixHash`) for exact-prefix lookup without
15
- * writing prompt text. The sanitizer is shared with `trie-sanitize.ts` so
16
- * the entropy + key-prefix rules drop the same tokens.
17
- *
18
- * The on-disk format is intentionally append-only + line-delimited so a
19
- * crash mid-write never corrupts the existing index; partial trailing lines
20
- * are skipped on load. Rotation compacts when the file exceeds 2 MB.
21
- */
22
- import { createHash } from "node:crypto";
23
- import { appendFile, mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
24
- import { dirname, join } from "node:path";
25
- import { containsSensitive } from "./trie-sanitize.js";
26
- export const PROFILE_REL = ".pi/ghost-autocomplete/profile.jsonl";
27
- export const DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
28
- export const DEFAULT_DECAY_DAYS = 90;
29
- export const DROP_BELOW_WEIGHT = 0.1;
30
- export const MAX_NGRAM_N = 4;
31
- export const TRIGRAM_N = 3;
32
- const PATH_RE = /(?:^|[\s"'`(])((?:[\w.-]+\/)+[\w.-]+\.[a-zA-Z]{1,6})\b/g;
33
- const SLASH_RE = /(?:^|\s)(\/[a-z][a-z0-9_-]{0,30})\b/g;
34
- const TOKEN_RE = /\b[\w][\w-]*\b/g;
35
- export function emptyIndex() {
36
- return {
37
- ngram: new Map(),
38
- path: new Map(),
39
- slash: new Map(),
40
- acceptByPrefix: new Map(),
41
- totalAcceptRecords: 0,
42
- };
43
- }
44
- /**
45
- * Tokenize a string into the same word-token form the profile stores. Drops
46
- * the empty string, deduplicates whitespace, and lowercases nothing — code
47
- * identifiers are case-sensitive.
48
- */
49
- export function tokenize(text) {
50
- if (!text)
51
- return [];
52
- const out = [];
53
- for (const m of text.matchAll(TOKEN_RE)) {
54
- if (m[0])
55
- out.push(m[0]);
56
- }
57
- return out;
58
- }
59
- /**
60
- * Generate n-grams of size `n` from `tokens`. Returns empty when there are
61
- * fewer than `n` tokens.
62
- */
63
- export function ngrams(tokens, n) {
64
- if (n <= 0 || tokens.length < n)
65
- return [];
66
- const out = [];
67
- for (let i = 0; i + n <= tokens.length; i++) {
68
- out.push(tokens.slice(i, i + n));
69
- }
70
- return out;
71
- }
72
- /**
73
- * SHA-256 hex of a prefix string. The hash is the disk-storable surrogate
74
- * for the prefix — same prefix always maps to the same key, but the raw
75
- * prefix never leaves the process.
76
- */
77
- export function prefixHash(prefix) {
78
- return `sha256:${createHash("sha256").update(prefix).digest("hex")}`;
79
- }
80
- /**
81
- * Extract candidate paths from free text. Same shape used by `recent-paths.ts`
82
- * but kept independent so changes to recent-paths semantics don't drift
83
- * the profile schema. Matches `foo/bar.ts`, `src/a/b.tsx`, etc.
84
- */
85
- export function extractPaths(text) {
86
- if (!text)
87
- return [];
88
- const out = [];
89
- PATH_RE.lastIndex = 0;
90
- for (const m of text.matchAll(PATH_RE)) {
91
- if (m[1])
92
- out.push(m[1]);
93
- }
94
- return out;
95
- }
96
- /**
97
- * Extract `/slash-command` tokens from free text. Limited to a-z prefix
98
- * plus alphanumerics/hyphen/underscore to avoid false matches on URLs
99
- * (`https://…`) or expressions (`x/y`).
100
- */
101
- export function extractSlash(text) {
102
- if (!text)
103
- return [];
104
- const out = [];
105
- SLASH_RE.lastIndex = 0;
106
- for (const m of text.matchAll(SLASH_RE)) {
107
- if (m[1])
108
- out.push(m[1]);
109
- }
110
- return out;
111
- }
112
- /**
113
- * Build profile records from a committed user message. Capture path +
114
- * slash + trigram ngrams. Sanitize check runs FIRST: messages with
115
- * sensitive content are dropped entirely (consistent with session trie).
116
- */
117
- export function recordsFromCommit(text, ts = Date.now()) {
118
- if (!text)
119
- return [];
120
- if (containsSensitive(text))
121
- return [];
122
- const out = [];
123
- for (const p of extractPaths(text)) {
124
- out.push({ ts, kind: "path", value: p, weight: 1 });
125
- }
126
- for (const s of extractSlash(text)) {
127
- out.push({ ts, kind: "slash", value: s, weight: 1 });
128
- }
129
- const toks = tokenize(text);
130
- for (const g of ngrams(toks, TRIGRAM_N)) {
131
- out.push({ ts, kind: "ngram", n: TRIGRAM_N, tokens: g, weight: 1 });
132
- }
133
- return out;
134
- }
135
- /**
136
- * Build an `accept` record for a full or partial acceptance. `prefix` is
137
- * hashed; `completion` is tokenized. The raw prefix never appears in the
138
- * returned record. Drops the whole record if either side fails sanitize.
139
- */
140
- export function recordFromAccept(prefix, completion, weight = 3, ts = Date.now()) {
141
- if (!prefix || !completion)
142
- return null;
143
- if (containsSensitive(prefix) || containsSensitive(completion))
144
- return null;
145
- const prefixTailTokens = tokenize(prefix).slice(-MAX_NGRAM_N);
146
- const completionTokens = tokenize(completion).slice(0, 8);
147
- if (completionTokens.length === 0)
148
- return null;
149
- return {
150
- ts,
151
- kind: "accept",
152
- weight,
153
- prefixHash: prefixHash(prefix),
154
- prefixTailTokens,
155
- completionTokens,
156
- };
157
- }
158
- /**
159
- * Append one or more records to the JSONL file. Returns silently on write
160
- * failure — profile logging must never break ghost completion.
161
- */
162
- export async function appendRecords(cwd, recs) {
163
- if (recs.length === 0)
164
- return;
165
- const path = join(cwd, PROFILE_REL);
166
- try {
167
- await mkdir(dirname(path), { recursive: true });
168
- const body = recs.map((r) => JSON.stringify(r)).join("\n") + "\n";
169
- await appendFile(path, body, "utf8");
170
- }
171
- catch {
172
- // best-effort
173
- }
174
- }
175
- /**
176
- * Parse the JSONL file into an array of records. Silently skips malformed
177
- * lines (partial trailing write) and records missing required fields.
178
- * Returns an empty array when the file does not exist.
179
- */
180
- export async function loadRecords(cwd) {
181
- const path = join(cwd, PROFILE_REL);
182
- let body;
183
- try {
184
- body = await readFile(path, "utf8");
185
- }
186
- catch {
187
- return [];
188
- }
189
- return parseRecords(body);
190
- }
191
- export function parseRecords(body) {
192
- const out = [];
193
- for (const line of body.split("\n")) {
194
- if (!line)
195
- continue;
196
- try {
197
- const r = JSON.parse(line);
198
- if (typeof r.ts !== "number")
199
- continue;
200
- if (typeof r.weight !== "number")
201
- continue;
202
- if (r.kind !== "ngram" && r.kind !== "path" && r.kind !== "slash" && r.kind !== "accept")
203
- continue;
204
- out.push(r);
205
- }
206
- catch {
207
- // partial trailing write — ignore
208
- }
209
- }
210
- return out;
211
- }
212
- /**
213
- * Build the in-memory aggregated index from a record list. Decays records
214
- * older than `decayDays` by halving their weight; drops weights below
215
- * `DROP_BELOW_WEIGHT` (0.1). `now` defaults to `Date.now()`; expose for
216
- * deterministic tests.
217
- */
218
- export function buildIndex(records, opts = {}) {
219
- const now = opts.now ?? Date.now();
220
- const decayDays = opts.decayDays ?? DEFAULT_DECAY_DAYS;
221
- const decayCutoff = now - decayDays * 24 * 60 * 60 * 1000;
222
- const idx = emptyIndex();
223
- for (const r of records) {
224
- let w = r.weight;
225
- if (r.ts < decayCutoff)
226
- w *= 0.5;
227
- if (w < DROP_BELOW_WEIGHT)
228
- continue;
229
- switch (r.kind) {
230
- case "ngram":
231
- if (r.tokens && r.tokens.length > 0) {
232
- const key = r.tokens.join(" ");
233
- idx.ngram.set(key, (idx.ngram.get(key) ?? 0) + w);
234
- }
235
- break;
236
- case "path":
237
- if (r.value)
238
- idx.path.set(r.value, (idx.path.get(r.value) ?? 0) + w);
239
- break;
240
- case "slash":
241
- if (r.value)
242
- idx.slash.set(r.value, (idx.slash.get(r.value) ?? 0) + w);
243
- break;
244
- case "accept":
245
- if (r.prefixHash && r.completionTokens && r.completionTokens.length > 0) {
246
- const existing = idx.acceptByPrefix.get(r.prefixHash);
247
- if (existing) {
248
- existing.weight += w;
249
- // Newer completion tokens win if more frequent; keep the
250
- // most-recent tokens as the surrogate (last-write-wins is
251
- // fine here — accept records carry the actual user choice).
252
- existing.completionTokens = r.completionTokens;
253
- }
254
- else {
255
- idx.acceptByPrefix.set(r.prefixHash, {
256
- completionTokens: r.completionTokens,
257
- weight: w,
258
- });
259
- }
260
- idx.totalAcceptRecords += 1;
261
- }
262
- break;
263
- }
264
- }
265
- return idx;
266
- }
267
- /**
268
- * Look up the weight of a trigram (already tokenized + joined). Returns 0
269
- * when missing. Callers should also tokenize the candidate text the same
270
- * way the writer did.
271
- */
272
- export function ngramWeight(idx, tokens) {
273
- if (tokens.length === 0)
274
- return 0;
275
- let total = 0;
276
- for (const g of ngrams(tokens, TRIGRAM_N)) {
277
- total += idx.ngram.get(g.join(" ")) ?? 0;
278
- }
279
- return total;
280
- }
281
- /**
282
- * Profile-bias score for a candidate completion. PRD §M4
283
- * "Ranking-from-prior": `α·log(1 + ngramWeight) + β·pathWeight + γ·slashWeight`.
284
- * Returns 0 when the index is empty or the candidate has no signal —
285
- * neutral input to the reranker.
286
- */
287
- export function profileBias(idx, text, weights = {}) {
288
- if (idx.totalAcceptRecords === 0 && idx.ngram.size === 0 && idx.path.size === 0 && idx.slash.size === 0) {
289
- return 0;
290
- }
291
- const alpha = weights.alpha ?? 0.3;
292
- const beta = weights.beta ?? 0.5;
293
- const gamma = weights.gamma ?? 0.5;
294
- const toks = tokenize(text);
295
- const ng = ngramWeight(idx, toks);
296
- let pathW = 0;
297
- for (const p of extractPaths(text))
298
- pathW += idx.path.get(p) ?? 0;
299
- let slashW = 0;
300
- for (const s of extractSlash(text))
301
- slashW += idx.slash.get(s) ?? 0;
302
- return alpha * Math.log(1 + ng) + beta * pathW + gamma * slashW;
303
- }
304
- /**
305
- * Bounded boost for deterministic path matches. Capped so persistent
306
- * frequency cannot beat a fresh exact-prefix path-prefix match (PRD §M4
307
- * "Deterministic path/fuzzy ranking"). The cap is a constant 0.2 — tune
308
- * once we have replay data.
309
- */
310
- export const MAX_PATH_BOOST = 0.2;
311
- export function profilePathBoost(idx, path) {
312
- const w = idx.path.get(path) ?? 0;
313
- if (w === 0)
314
- return 0;
315
- // Log + clamp so a path with 1000 accepts isn't 1000× a path with 1.
316
- const raw = Math.log(1 + w) / 10;
317
- return Math.min(MAX_PATH_BOOST, raw);
318
- }
319
- /**
320
- * Slash-command frequency score. Used by the editor's slash fast-path:
321
- * given a `/cmd-prefix`, return the best-matching full command by weight.
322
- * Returns null when nothing in the index extends `prefix`.
323
- */
324
- export function bestSlashMatch(idx, prefix) {
325
- if (!prefix.startsWith("/"))
326
- return null;
327
- let best = null;
328
- for (const [cmd, w] of idx.slash) {
329
- if (!cmd.startsWith(prefix))
330
- continue;
331
- if (cmd === prefix)
332
- continue;
333
- if (!best || w > best.weight)
334
- best = { cmd, weight: w };
335
- }
336
- return best;
337
- }
338
- /**
339
- * Rotate + compact when the file exceeds `maxBytes`. Strategy: load all
340
- * records, decay them, sum weights per (kind, key), drop sub-threshold
341
- * entries, write the compacted file back. Returns true when a rotation
342
- * happened. Best-effort — swallows errors.
343
- */
344
- export async function compactIfNeeded(cwd, opts = {}) {
345
- const maxBytes = opts.maxBytes ?? DEFAULT_MAX_BYTES;
346
- const path = join(cwd, PROFILE_REL);
347
- let size;
348
- try {
349
- const s = await stat(path);
350
- size = s.size;
351
- }
352
- catch {
353
- return false;
354
- }
355
- if (size < maxBytes)
356
- return false;
357
- const records = await loadRecords(cwd);
358
- const compacted = compactRecords(records, {
359
- decayDays: opts.decayDays ?? DEFAULT_DECAY_DAYS,
360
- now: opts.now ?? Date.now(),
361
- });
362
- try {
363
- // Move the original aside first so a crash mid-write keeps the old
364
- // data recoverable as `profile.jsonl.1`.
365
- await rename(path, `${path}.1`);
366
- const body = compacted.map((r) => JSON.stringify(r)).join("\n") + "\n";
367
- await writeFile(path, body, "utf8");
368
- return true;
369
- }
370
- catch {
371
- return false;
372
- }
373
- }
374
- /**
375
- * Compact a record list in memory: decay aged weights, sum per (kind,key),
376
- * drop sub-threshold. Pure function — exposed for unit tests.
377
- */
378
- export function compactRecords(records, opts = {}) {
379
- const now = opts.now ?? Date.now();
380
- const decayDays = opts.decayDays ?? DEFAULT_DECAY_DAYS;
381
- const decayCutoff = now - decayDays * 24 * 60 * 60 * 1000;
382
- // Map<groupKey, { rec template, summedWeight, latestTs }>
383
- const groups = new Map();
384
- for (const r of records) {
385
- let w = r.weight;
386
- if (r.ts < decayCutoff)
387
- w *= 0.5;
388
- if (w < DROP_BELOW_WEIGHT)
389
- continue;
390
- const key = groupKey(r);
391
- if (!key)
392
- continue;
393
- const existing = groups.get(key);
394
- if (existing) {
395
- existing.weight += w;
396
- if (r.ts > existing.ts)
397
- existing.ts = r.ts;
398
- // For `accept`, keep the latest completion tokens.
399
- if (r.kind === "accept" && r.completionTokens) {
400
- existing.template.completionTokens = r.completionTokens;
401
- }
402
- }
403
- else {
404
- groups.set(key, { template: { ...r }, weight: w, ts: r.ts });
405
- }
406
- }
407
- return [...groups.values()].map(({ template, weight, ts }) => ({
408
- ...template,
409
- weight,
410
- ts,
411
- }));
412
- }
413
- function groupKey(r) {
414
- switch (r.kind) {
415
- case "ngram":
416
- return r.tokens ? `ngram:${r.tokens.join(" ")}` : null;
417
- case "path":
418
- return r.value ? `path:${r.value}` : null;
419
- case "slash":
420
- return r.value ? `slash:${r.value}` : null;
421
- case "accept":
422
- return r.prefixHash ? `accept:${r.prefixHash}` : null;
423
- }
424
- }
425
- /** Parse `PI_GHOST_PROFILE_DECAY_DAYS`. Falls back to default when invalid. */
426
- export function parseDecayDaysEnv(raw) {
427
- if (raw === undefined)
428
- return DEFAULT_DECAY_DAYS;
429
- const v = Number(raw);
430
- if (!Number.isFinite(v) || v <= 0)
431
- return DEFAULT_DECAY_DAYS;
432
- return Math.floor(v);
433
- }
434
- //# sourceMappingURL=profile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.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