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,114 +0,0 @@
1
- import { extractText } from "./context-aggregator.js";
2
- const PER_MESSAGE_CAP = 4000;
3
- // A token containing at least one `/` that looks like a path: leading
4
- // whitespace/quote/paren/bracket boundary, then path chars across one or more
5
- // segments.
6
- const SLASHED_PATH = /(?:^|[\s"'`(\[{])([A-Za-z0-9_.\-][A-Za-z0-9_.\-]*(?:\/[A-Za-z0-9_.\-]+)+)/g;
7
- // Backticked single-token contents; we accept them as a path mention if they
8
- // look path-like (slash or dot).
9
- const BACKTICKED = /`([^`\n]{1,200})`/g;
10
- // Bare filename with a known code extension. Conservative list to limit
11
- // false positives during normal English writing.
12
- const FILENAME_EXT = /\b([A-Za-z0-9_\-]+\.(?:ts|tsx|js|jsx|mjs|cjs|md|json|py|go|rs|java|kt|swift|c|h|cc|cpp|hpp|sh|bash|zsh|yml|yaml|toml|ini|css|scss|html|xml|sql|rb|php|lua))\b/g;
13
- const PATHLIKE = /^[A-Za-z0-9_./@\-]+$/;
14
- /**
15
- * Extract path-like mentions from recent conversation messages. Returns a Set
16
- * of distinct tokens — full paths (e.g. `src/foo.ts`) and bare filenames with
17
- * code extensions (e.g. `foo.ts`).
18
- *
19
- * Conservative on purpose: triggers ranking boosts only, so noisy mentions
20
- * just degrade to no-op rather than producing wrong completions.
21
- */
22
- export function extractRecentPaths(messages) {
23
- const out = new Set();
24
- for (const m of messages) {
25
- const text = m.text.length > PER_MESSAGE_CAP ? m.text.slice(0, PER_MESSAGE_CAP) : m.text;
26
- for (const match of text.matchAll(SLASHED_PATH)) {
27
- const tok = match[1];
28
- if (tok)
29
- out.add(tok);
30
- }
31
- for (const match of text.matchAll(BACKTICKED)) {
32
- const raw = match[1]?.trim();
33
- if (raw && raw.length <= 200 && !raw.includes(" ") && PATHLIKE.test(raw) && /[/.]/.test(raw)) {
34
- out.add(raw);
35
- }
36
- }
37
- for (const match of text.matchAll(FILENAME_EXT)) {
38
- const tok = match[1];
39
- if (tok)
40
- out.add(tok);
41
- }
42
- }
43
- return out;
44
- }
45
- /**
46
- * Score boost for a matched path given the recent-mention set.
47
- * - exact full-path hit: +10
48
- * - basename hit: +7
49
- * - otherwise: 0
50
- */
51
- export function recentBoost(matchPath, recent) {
52
- if (!recent || recent.size === 0)
53
- return 0;
54
- if (recent.has(matchPath))
55
- return 10;
56
- const i = matchPath.lastIndexOf("/");
57
- const bn = i < 0 ? matchPath : matchPath.slice(i + 1);
58
- if (recent.has(bn))
59
- return 7;
60
- return 0;
61
- }
62
- /**
63
- * Read role-weighted recent messages tailored for path-mention extraction:
64
- * up to `userMax` most-recent user messages and `assistantMax` most-recent
65
- * assistant messages. Oldest-first.
66
- */
67
- export function getRoleWeightedRecent(ctx, userMax, assistantMax) {
68
- if (userMax <= 0 && assistantMax <= 0)
69
- return [];
70
- let branch;
71
- try {
72
- branch = ctx.sessionManager.getBranch();
73
- }
74
- catch {
75
- return [];
76
- }
77
- if (!branch)
78
- return [];
79
- const out = [];
80
- let userTaken = 0;
81
- let assistantTaken = 0;
82
- for (let i = branch.length - 1; i >= 0; i--) {
83
- if (userTaken >= userMax && assistantTaken >= assistantMax)
84
- break;
85
- const entry = branch[i];
86
- if (!entry || entry.type !== "message")
87
- continue;
88
- const role = roleOf(entry.message);
89
- if (role === "user" && userTaken < userMax) {
90
- const text = extractText(entry.message);
91
- if (text) {
92
- out.push({ role, text });
93
- userTaken++;
94
- }
95
- }
96
- else if (role === "assistant" && assistantTaken < assistantMax) {
97
- const text = extractText(entry.message);
98
- if (text) {
99
- out.push({ role, text });
100
- assistantTaken++;
101
- }
102
- }
103
- }
104
- out.reverse();
105
- return out;
106
- }
107
- function roleOf(msg) {
108
- if (msg && typeof msg === "object" && "role" in msg && typeof msg.role === "string") {
109
- if (msg.role === "user" || msg.role === "assistant")
110
- return msg.role;
111
- }
112
- return undefined;
113
- }
114
- //# sourceMappingURL=recent-paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recent-paths.js","sourceRoot":"","sources":["../src/recent-paths.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAsB,MAAM,yBAAyB,CAAC;AAE1E,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I,KAAK,QAAQ,EAAE,CAAC;QACrF,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IACtE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
@@ -1,84 +0,0 @@
1
- /**
2
- * Accept-regret tracker. PRD §M5a "Regret detection".
3
- *
4
- * After an `accepted` or `accepted-partial` outcome, the editor watches
5
- * for >50% of the inserted characters to be deleted within
6
- * `PI_GHOST_REGRET_WINDOW_MS` (default 3000 ms). When detected, the
7
- * metric record is flagged `acceptRegret=true` with
8
- * `regretDeletedChars=N` before it's logged.
9
- *
10
- * Pure state machine — no timers, no I/O. Caller drives the clock and
11
- * decides when to flush.
12
- *
13
- * Lifecycle:
14
- * 1. `arm(record, snapshot, now)` — stash the staged metric, capture
15
- * the pre-insert text snapshot + insert range. Returns a handle
16
- * the caller stores.
17
- * 2. `observe(handle, currentText, now)` — call on each text change.
18
- * Returns `{flush, regret, deletedChars}` indicating whether the
19
- * record is ready to log.
20
- * 3. `expire(handle, now)` — call when the window deadline fires.
21
- * Returns the final stats so the caller can flush a record that
22
- * never tripped the regret threshold.
23
- */
24
- import type { MetricsRecord } from "./metrics.js";
25
- export declare const DEFAULT_REGRET_WINDOW_MS = 3000;
26
- export declare const REGRET_THRESHOLD = 0.5;
27
- export interface RegretHandle {
28
- record: MetricsRecord;
29
- /** Inserted text, captured at arm time. */
30
- insertedText: string;
31
- /** Anchor: characters BEFORE the insert. Used to locate the slice
32
- * in the current text via a startsWith check. */
33
- textBefore: string;
34
- /** Anchor: characters AFTER the insert. */
35
- textAfter: string;
36
- /** Deadline ms (absolute) past which `expire` should be called. */
37
- deadlineMs: number;
38
- }
39
- export interface RegretSnapshot {
40
- textBefore: string;
41
- insertedText: string;
42
- textAfter: string;
43
- }
44
- export interface ObserveResult {
45
- /** True when the caller should log the record now. */
46
- flush: boolean;
47
- /** True when >50% of inserted text was deleted within the window. */
48
- regret: boolean;
49
- /** Number of inserted chars currently deleted (0..insertedText.length). */
50
- deletedChars: number;
51
- }
52
- /**
53
- * Arm a regret watch. `snapshot` captures the editor state right
54
- * after the insert: the three slices around the insertion point.
55
- * `windowMs` is added to `now` to compute the deadline.
56
- */
57
- export declare function arm(record: MetricsRecord, snapshot: RegretSnapshot, now: number, windowMs?: number): RegretHandle;
58
- /**
59
- * Inspect the current editor text against the handle. Returns whether
60
- * to flush (because regret was detected OR the deadline passed) plus
61
- * the regret stats to attach to the record.
62
- *
63
- * Algorithm: find the inserted range by anchoring on `textBefore` and
64
- * `textAfter`. The middle slice between those two anchors is the
65
- * "currently-remaining inserted text". If anchors moved (e.g. user
66
- * typed in front of the insert), we treat the deletion as "all of
67
- * it" — the regret window is conservative.
68
- */
69
- export declare function observe(handle: RegretHandle, currentText: string, now: number): ObserveResult;
70
- /**
71
- * Hard-flush at deadline. Same as `observe` but always reports
72
- * `flush: true`. Useful when the caller drives the deadline via a
73
- * timer rather than per-keystroke text observation.
74
- */
75
- export declare function expire(handle: RegretHandle, currentText: string): ObserveResult;
76
- /**
77
- * Attach the regret outcome to the staged record. Returns a new
78
- * record with `acceptRegret` + `regretDeletedChars` set (when
79
- * `deletedChars > 0`).
80
- */
81
- export declare function attachToRecord(handle: RegretHandle, outcome: ObserveResult): MetricsRecord;
82
- /** Parse `PI_GHOST_REGRET_WINDOW_MS`. Falls back to default on invalid. */
83
- export declare function parseRegretWindowEnv(raw: string | undefined): number;
84
- //# sourceMappingURL=regret-tracker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regret-tracker.d.ts","sourceRoot":"","sources":["../src/regret-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB;sDACkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC7B,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAClB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,MAAiC,GACzC,YAAY,CAQd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,CAY7F;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAM/E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,aAAa,GACpB,aAAa,CAOf;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKpE"}
@@ -1,145 +0,0 @@
1
- /**
2
- * Accept-regret tracker. PRD §M5a "Regret detection".
3
- *
4
- * After an `accepted` or `accepted-partial` outcome, the editor watches
5
- * for >50% of the inserted characters to be deleted within
6
- * `PI_GHOST_REGRET_WINDOW_MS` (default 3000 ms). When detected, the
7
- * metric record is flagged `acceptRegret=true` with
8
- * `regretDeletedChars=N` before it's logged.
9
- *
10
- * Pure state machine — no timers, no I/O. Caller drives the clock and
11
- * decides when to flush.
12
- *
13
- * Lifecycle:
14
- * 1. `arm(record, snapshot, now)` — stash the staged metric, capture
15
- * the pre-insert text snapshot + insert range. Returns a handle
16
- * the caller stores.
17
- * 2. `observe(handle, currentText, now)` — call on each text change.
18
- * Returns `{flush, regret, deletedChars}` indicating whether the
19
- * record is ready to log.
20
- * 3. `expire(handle, now)` — call when the window deadline fires.
21
- * Returns the final stats so the caller can flush a record that
22
- * never tripped the regret threshold.
23
- */
24
- export const DEFAULT_REGRET_WINDOW_MS = 3000;
25
- export const REGRET_THRESHOLD = 0.5;
26
- /**
27
- * Arm a regret watch. `snapshot` captures the editor state right
28
- * after the insert: the three slices around the insertion point.
29
- * `windowMs` is added to `now` to compute the deadline.
30
- */
31
- export function arm(record, snapshot, now, windowMs = DEFAULT_REGRET_WINDOW_MS) {
32
- return {
33
- record,
34
- insertedText: snapshot.insertedText,
35
- textBefore: snapshot.textBefore,
36
- textAfter: snapshot.textAfter,
37
- deadlineMs: now + windowMs,
38
- };
39
- }
40
- /**
41
- * Inspect the current editor text against the handle. Returns whether
42
- * to flush (because regret was detected OR the deadline passed) plus
43
- * the regret stats to attach to the record.
44
- *
45
- * Algorithm: find the inserted range by anchoring on `textBefore` and
46
- * `textAfter`. The middle slice between those two anchors is the
47
- * "currently-remaining inserted text". If anchors moved (e.g. user
48
- * typed in front of the insert), we treat the deletion as "all of
49
- * it" — the regret window is conservative.
50
- */
51
- export function observe(handle, currentText, now) {
52
- const stats = computeDeletion(handle, currentText);
53
- const deletedChars = stats.deletedChars;
54
- const totalInserted = handle.insertedText.length;
55
- const ratio = totalInserted > 0 ? deletedChars / totalInserted : 0;
56
- const regret = totalInserted > 0 && ratio > REGRET_THRESHOLD;
57
- const deadlineReached = now >= handle.deadlineMs;
58
- return {
59
- flush: regret || deadlineReached,
60
- regret,
61
- deletedChars,
62
- };
63
- }
64
- /**
65
- * Hard-flush at deadline. Same as `observe` but always reports
66
- * `flush: true`. Useful when the caller drives the deadline via a
67
- * timer rather than per-keystroke text observation.
68
- */
69
- export function expire(handle, currentText) {
70
- const stats = computeDeletion(handle, currentText);
71
- const totalInserted = handle.insertedText.length;
72
- const ratio = totalInserted > 0 ? stats.deletedChars / totalInserted : 0;
73
- const regret = totalInserted > 0 && ratio > REGRET_THRESHOLD;
74
- return { flush: true, regret, deletedChars: stats.deletedChars };
75
- }
76
- /**
77
- * Attach the regret outcome to the staged record. Returns a new
78
- * record with `acceptRegret` + `regretDeletedChars` set (when
79
- * `deletedChars > 0`).
80
- */
81
- export function attachToRecord(handle, outcome) {
82
- const out = { ...handle.record };
83
- out.acceptRegret = outcome.regret;
84
- if (outcome.deletedChars > 0) {
85
- out.regretDeletedChars = outcome.deletedChars;
86
- }
87
- return out;
88
- }
89
- /** Parse `PI_GHOST_REGRET_WINDOW_MS`. Falls back to default on invalid. */
90
- export function parseRegretWindowEnv(raw) {
91
- if (raw === undefined)
92
- return DEFAULT_REGRET_WINDOW_MS;
93
- const v = Number(raw);
94
- if (!Number.isFinite(v) || v <= 0)
95
- return DEFAULT_REGRET_WINDOW_MS;
96
- return Math.floor(v);
97
- }
98
- /**
99
- * Compute how many inserted chars are missing from `currentText`. Two
100
- * cases:
101
- * 1. Anchors match: count chars of `insertedText` that disappeared
102
- * from the middle slice.
103
- * 2. Anchors moved (user mutated outside the insert range or
104
- * restructured the line): treat as full deletion. Conservative —
105
- * the user obviously didn't keep the suggestion in place.
106
- *
107
- * The "missing chars" count uses leading-match against the inserted
108
- * text, so partial deletions from the right side are detected
109
- * (typical backspace behavior).
110
- */
111
- function computeDeletion(handle, currentText) {
112
- const { textBefore, insertedText, textAfter } = handle;
113
- if (!currentText.startsWith(textBefore)) {
114
- // Anchor before the insert moved → assume full deletion.
115
- return { deletedChars: insertedText.length };
116
- }
117
- const rest = currentText.slice(textBefore.length);
118
- // `rest` should start with some prefix of `insertedText` followed
119
- // by `textAfter`. Find the boundary by searching for `textAfter`
120
- // from the right side.
121
- const afterIdx = textAfter ? rest.indexOf(textAfter) : rest.length;
122
- if (afterIdx < 0) {
123
- // `textAfter` not found — anchor moved.
124
- return { deletedChars: insertedText.length };
125
- }
126
- const remainingInsert = rest.slice(0, afterIdx);
127
- // Count the leading-match between remainingInsert and insertedText.
128
- // Chars beyond the match are treated as deleted (the user replaced
129
- // them, which still counts as regret).
130
- const keptLen = leadingMatch(remainingInsert, insertedText);
131
- const deletedFromEnd = insertedText.length - keptLen;
132
- // If the user typed past the anchor (remainingInsert > insertedText
133
- // after kept prefix), we count those extra chars as "still kept"
134
- // only if they aren't from the insertion — but we can't distinguish
135
- // retroactive typing from kept insertion. Conservative: kept-only.
136
- return { deletedChars: Math.max(0, deletedFromEnd) };
137
- }
138
- function leadingMatch(a, b) {
139
- const n = Math.min(a.length, b.length);
140
- let i = 0;
141
- while (i < n && a[i] === b[i])
142
- i++;
143
- return i;
144
- }
145
- //# sourceMappingURL=regret-tracker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regret-tracker.js","sourceRoot":"","sources":["../src/regret-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AA8BpC;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAClB,MAAqB,EACrB,QAAwB,EACxB,GAAW,EACX,WAAmB,wBAAwB;IAE3C,OAAO;QACN,MAAM;QACN,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,UAAU,EAAE,GAAG,GAAG,QAAQ;KAC1B,CAAC;AACH,CA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eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IAChD,oEAAoE;IACpE,mEAAmE;IACnE,uCAAuC;IACvC,MAAM,OAAO,GAAG,YAAY,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,GAAG,OAAO,CAAC;IACrD,oEAAoE;IACpE,iEAAiE;IACjE,oEAAoE;IACpE,mEAAmE;IACnE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACzC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAAE,CAAC,EAAE,CAAC;IACnC,OAAO,CAAC,CAAC;AACV,CAAC"}
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * `pi-ghost-replay` — offline replay against a captured eval dataset.
4
- * PRD §M5c.
5
- *
6
- * Reads `.pi/ghost-autocomplete/eval.jsonl` (or path from argv[0]),
7
- * runs each example against a provider built from the active env
8
- * config, and prints a summary. Supports `--json` for machine-readable
9
- * output and `--redact` to suppress raw text in the printed report so
10
- * the output is safe to share.
11
- */
12
- export {};
13
- //# sourceMappingURL=replay-cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replay-cli.d.ts","sourceRoot":"","sources":["../src/replay-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"replay-cli.js","sourceRoot":"","sources":["../src/replay-cli.ts"],"names":[],"mappings":";AACA;;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AC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBxD;AAED,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,aAAa,CA8CtE;AAuBD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
package/dist/replay.js DELETED
@@ -1,225 +0,0 @@
1
- /**
2
- * Replay engine — pure functions. PRD §M5c.
3
- *
4
- * Given an `EvalExample` and a candidate continuation produced by a
5
- * provider variant under test, compute per-example quality metrics. The
6
- * caller drives the actual provider invocation (this module stays I/O-free
7
- * so it's trivially unit-testable and deterministic for fixture providers).
8
- */
9
- import { quantile } from "./bench.js";
10
- /**
11
- * Score one replay. `exactMatch` is the strict equality test;
12
- * `prefixMatchLen` is the longest common leading-character run between
13
- * the actual and the expected continuation; `editDistance` is plain
14
- * Levenshtein. `savedAt{1,3,5}` is the PRD's `chars-saved / max(1, L)`
15
- * over the top-k candidates.
16
- */
17
- export function evaluateExample(result) {
18
- const expected = result.example.expected;
19
- const actual = result.actual ?? "";
20
- const exactMatch = actual === expected;
21
- const prefixMatchLen = leadingMatch(actual, expected);
22
- const editDistance = levenshtein(actual, expected);
23
- const candidates = result.candidates ?? [actual];
24
- return {
25
- exactMatch,
26
- prefixMatchLen,
27
- editDistance,
28
- savedAt1: savedAtK(candidates, expected, 1),
29
- savedAt3: savedAtK(candidates, expected, 3),
30
- savedAt5: savedAtK(candidates, expected, 5),
31
- prefixRecallAt1: prefixRecallAtN(candidates, expected, 1),
32
- prefixRecallAt3: prefixRecallAtN(candidates, expected, 3),
33
- prefixRecallAt5: prefixRecallAtN(candidates, expected, 5),
34
- };
35
- }
36
- /**
37
- * First "identifier-or-punctuation" chunk of `s`. Mirrors the editor's
38
- * `nextWordChunk` behavior without importing from ghost-editor (replay
39
- * stays I/O-free). Skips leading whitespace, then either consumes an
40
- * identifier run (`[A-Za-z0-9_]+`) or one punctuation char.
41
- *
42
- * Returns "" only when `s` has no non-whitespace content. The result
43
- * INCLUDES the leading whitespace so that callers can `startsWith` the
44
- * raw candidate against it without re-trimming.
45
- */
46
- export function firstTokenPrefix(s) {
47
- if (!s)
48
- return "";
49
- let i = 0;
50
- while (i < s.length && /\s/.test(s[i] ?? ""))
51
- i++;
52
- if (i >= s.length)
53
- return "";
54
- const start = i;
55
- const isIdent = /[A-Za-z0-9_]/.test(s[i] ?? "");
56
- if (isIdent) {
57
- while (i < s.length && /[A-Za-z0-9_]/.test(s[i] ?? ""))
58
- i++;
59
- return s.slice(0, i);
60
- }
61
- // Single punctuation char + leading ws.
62
- return s.slice(0, start + 1);
63
- }
64
- /**
65
- * 1 if any of `candidates[0..n)` starts with `firstTokenPrefix(expected)`,
66
- * else 0. PRD §M5b extension — ChaI-TeA's per-token recall metric. The
67
- * binary 0/1 shape (vs. fractional `saved@k`) makes the rate interpretable
68
- * directly as "fraction of expected first-tokens recovered."
69
- */
70
- export function prefixRecallAtN(candidates, expected, n) {
71
- if (n <= 0 || candidates.length === 0 || !expected)
72
- return 0;
73
- const token = firstTokenPrefix(expected);
74
- if (!token)
75
- return 0;
76
- const max = Math.min(n, candidates.length);
77
- for (let i = 0; i < max; i++) {
78
- const c = candidates[i] ?? "";
79
- if (c.startsWith(token))
80
- return 1;
81
- }
82
- return 0;
83
- }
84
- /**
85
- * Number of leading characters where `a` and `b` agree. Used as the
86
- * `prefixMatchLen` quality metric (PRD §M5b).
87
- */
88
- export function leadingMatch(a, b) {
89
- const n = Math.min(a.length, b.length);
90
- let i = 0;
91
- while (i < n && a[i] === b[i])
92
- i++;
93
- return i;
94
- }
95
- /**
96
- * `saved@k = max(0, charsSaved - acceptCost) / max(1, L)` per PRD §M5b,
97
- * where `charsSaved` is the longest leading-match among ranks 1..k and
98
- * `acceptCost = 1 + cycles` (one Right + cycle keystrokes). `k <= 0`
99
- * returns 0; ranks beyond the array are skipped.
100
- */
101
- export function savedAtK(candidates, expected, k) {
102
- if (k <= 0)
103
- return 0;
104
- const L = Math.max(1, expected.length);
105
- let bestSaved = 0;
106
- let bestRank = 0;
107
- const max = Math.min(k, candidates.length);
108
- for (let i = 0; i < max; i++) {
109
- const c = candidates[i] ?? "";
110
- const saved = leadingMatch(c, expected);
111
- if (saved > bestSaved) {
112
- bestSaved = saved;
113
- bestRank = i + 1;
114
- }
115
- }
116
- const acceptCost = bestRank === 0 ? 0 : bestRank; // 1 Right + (rank-1) cycles
117
- return Math.max(0, bestSaved - acceptCost) / L;
118
- }
119
- /**
120
- * Classic Levenshtein distance with single-row DP. O(n*m) time, O(min)
121
- * space. Used by replay to flag near-matches in the bench.
122
- */
123
- export function levenshtein(a, b) {
124
- if (a === b)
125
- return 0;
126
- if (a.length === 0)
127
- return b.length;
128
- if (b.length === 0)
129
- return a.length;
130
- // Swap so `b` is shorter — smaller inner row.
131
- if (a.length < b.length)
132
- [a, b] = [b, a];
133
- let prev = new Array(b.length + 1);
134
- let curr = new Array(b.length + 1);
135
- for (let j = 0; j <= b.length; j++)
136
- prev[j] = j;
137
- for (let i = 1; i <= a.length; i++) {
138
- curr[0] = i;
139
- for (let j = 1; j <= b.length; j++) {
140
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
141
- curr[j] = Math.min(prev[j] + 1, // deletion
142
- curr[j - 1] + 1, // insertion
143
- prev[j - 1] + cost);
144
- }
145
- const tmp = prev;
146
- prev = curr;
147
- curr = tmp;
148
- }
149
- return prev[b.length];
150
- }
151
- /**
152
- * Aggregate per-example metrics + latencies into a single report. Skips
153
- * error results from quality metrics but includes them in `count`/`errors`
154
- * for transparency.
155
- */
156
- export function summarizeReplay(results) {
157
- if (results.length === 0) {
158
- return zeroSummary();
159
- }
160
- const ok = results.filter((r) => !r.error);
161
- const errors = results.length - ok.length;
162
- if (ok.length === 0) {
163
- return { ...zeroSummary(), count: results.length, errors };
164
- }
165
- let exact = 0;
166
- let sumPrefix = 0;
167
- let sumEdit = 0;
168
- let sumS1 = 0;
169
- let sumS3 = 0;
170
- let sumS5 = 0;
171
- let sumPR1 = 0;
172
- let sumPR3 = 0;
173
- let sumPR5 = 0;
174
- for (const r of ok) {
175
- const m = evaluateExample(r);
176
- if (m.exactMatch)
177
- exact++;
178
- sumPrefix += m.prefixMatchLen;
179
- sumEdit += m.editDistance;
180
- sumS1 += m.savedAt1;
181
- sumS3 += m.savedAt3;
182
- sumS5 += m.savedAt5;
183
- sumPR1 += m.prefixRecallAt1;
184
- sumPR3 += m.prefixRecallAt3;
185
- sumPR5 += m.prefixRecallAt5;
186
- }
187
- const latencies = ok.map((r) => r.latencyMs).sort((a, b) => a - b);
188
- return {
189
- count: results.length,
190
- errors,
191
- exactMatchRate: exact / ok.length,
192
- meanPrefixMatchLen: sumPrefix / ok.length,
193
- meanEditDistance: sumEdit / ok.length,
194
- meanSavedAt1: sumS1 / ok.length,
195
- meanSavedAt3: sumS3 / ok.length,
196
- meanSavedAt5: sumS5 / ok.length,
197
- prefixRecallAt1: sumPR1 / ok.length,
198
- prefixRecallAt3: sumPR3 / ok.length,
199
- prefixRecallAt5: sumPR5 / ok.length,
200
- p50LatencyMs: quantile(latencies, 0.5),
201
- p95LatencyMs: quantile(latencies, 0.95),
202
- };
203
- }
204
- function zeroSummary() {
205
- return {
206
- count: 0,
207
- errors: 0,
208
- exactMatchRate: 0,
209
- meanPrefixMatchLen: 0,
210
- meanEditDistance: 0,
211
- meanSavedAt1: 0,
212
- meanSavedAt3: 0,
213
- meanSavedAt5: 0,
214
- prefixRecallAt1: 0,
215
- prefixRecallAt3: 0,
216
- prefixRecallAt5: 0,
217
- p50LatencyMs: 0,
218
- p95LatencyMs: 0,
219
- };
220
- }
221
- // `quantile` re-exported from `bench.ts` so replay + bench reports use
222
- // the same percentile semantics (nearest-rank). Diverging implementations
223
- // would mean the same dataset reports different p95s in the two tools.
224
- export { quantile } from "./bench.js";
225
- //# sourceMappingURL=replay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAoCtC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IACnC,MAAM,UAAU,GAAG,MAAM,KAAK,QAAQ,CAAC;IACvC,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACN,UAAU;QACV,cAAc;QACd,YAAY;QACZ,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC3C,eAAe,EAAE,eAAe,CA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