pi-ghost-autocomplete 0.3.1 → 0.3.2
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.
- package/README.md +101 -6
- package/dist/bench-cli.js +81 -5
- package/dist/bench-cli.js.map +1 -1
- package/dist/bench.d.ts +130 -2
- package/dist/bench.d.ts.map +1 -1
- package/dist/bench.js +285 -4
- package/dist/bench.js.map +1 -1
- package/dist/cache.d.ts +124 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +173 -0
- package/dist/cache.js.map +1 -0
- package/dist/candidate-rerank.d.ts +57 -0
- package/dist/candidate-rerank.d.ts.map +1 -0
- package/dist/candidate-rerank.js +78 -0
- package/dist/candidate-rerank.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +148 -18
- package/dist/config.js.map +1 -1
- package/dist/context-aggregator.d.ts +14 -5
- package/dist/context-aggregator.d.ts.map +1 -1
- package/dist/context-aggregator.js +38 -9
- package/dist/context-aggregator.js.map +1 -1
- package/dist/context-selector.d.ts +128 -0
- package/dist/context-selector.d.ts.map +1 -0
- package/dist/context-selector.js +300 -0
- package/dist/context-selector.js.map +1 -0
- package/dist/cycle-manager.d.ts +102 -0
- package/dist/cycle-manager.d.ts.map +1 -0
- package/dist/cycle-manager.js +168 -0
- package/dist/cycle-manager.js.map +1 -0
- package/dist/edit-history-ring.d.ts +148 -0
- package/dist/edit-history-ring.d.ts.map +1 -0
- package/dist/edit-history-ring.js +262 -0
- package/dist/edit-history-ring.js.map +1 -0
- package/dist/entropy-stop.d.ts +102 -0
- package/dist/entropy-stop.d.ts.map +1 -0
- package/dist/entropy-stop.js +141 -0
- package/dist/entropy-stop.js.map +1 -0
- package/dist/eval-dataset.d.ts +66 -0
- package/dist/eval-dataset.d.ts.map +1 -0
- package/dist/eval-dataset.js +127 -0
- package/dist/eval-dataset.js.map +1 -0
- package/dist/fast-path-engine.d.ts +286 -0
- package/dist/fast-path-engine.d.ts.map +1 -0
- package/dist/fast-path-engine.js +341 -0
- package/dist/fast-path-engine.js.map +1 -0
- package/dist/fuzzy-matcher.d.ts +8 -0
- package/dist/fuzzy-matcher.d.ts.map +1 -1
- package/dist/fuzzy-matcher.js +5 -3
- package/dist/fuzzy-matcher.js.map +1 -1
- package/dist/ghost-editor.d.ts +321 -4
- package/dist/ghost-editor.d.ts.map +1 -1
- package/dist/ghost-editor.js +1190 -144
- package/dist/ghost-editor.js.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -2
- package/dist/index.js.map +1 -1
- package/dist/keystroke-timer.d.ts +59 -0
- package/dist/keystroke-timer.d.ts.map +1 -0
- package/dist/keystroke-timer.js +94 -0
- package/dist/keystroke-timer.js.map +1 -0
- package/dist/metrics-builder.d.ts +71 -0
- package/dist/metrics-builder.d.ts.map +1 -0
- package/dist/metrics-builder.js +71 -0
- package/dist/metrics-builder.js.map +1 -0
- package/dist/metrics.d.ts +99 -2
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +131 -17
- package/dist/metrics.js.map +1 -1
- package/dist/path-matcher.d.ts +9 -0
- package/dist/path-matcher.d.ts.map +1 -1
- package/dist/path-matcher.js +5 -2
- package/dist/path-matcher.js.map +1 -1
- package/dist/profile-store.d.ts +82 -0
- package/dist/profile-store.d.ts.map +1 -0
- package/dist/profile-store.js +199 -0
- package/dist/profile-store.js.map +1 -0
- package/dist/profile.d.ts +185 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +434 -0
- package/dist/profile.js.map +1 -0
- package/dist/providers/cloud-provider.d.ts +10 -1
- package/dist/providers/cloud-provider.d.ts.map +1 -1
- package/dist/providers/cloud-provider.js +71 -14
- package/dist/providers/cloud-provider.js.map +1 -1
- package/dist/providers/local-provider.d.ts +8 -1
- package/dist/providers/local-provider.d.ts.map +1 -1
- package/dist/providers/local-provider.js +15 -3
- package/dist/providers/local-provider.js.map +1 -1
- package/dist/providers/openai-compat-provider.d.ts +11 -1
- package/dist/providers/openai-compat-provider.d.ts.map +1 -1
- package/dist/providers/openai-compat-provider.js +93 -6
- package/dist/providers/openai-compat-provider.js.map +1 -1
- package/dist/providers/openai-completions-runner.d.ts +25 -1
- package/dist/providers/openai-completions-runner.d.ts.map +1 -1
- package/dist/providers/openai-completions-runner.js +109 -14
- package/dist/providers/openai-completions-runner.js.map +1 -1
- package/dist/providers/race.d.ts +58 -1
- package/dist/providers/race.d.ts.map +1 -1
- package/dist/providers/race.js +317 -4
- package/dist/providers/race.js.map +1 -1
- package/dist/providers/truncate.d.ts.map +1 -1
- package/dist/providers/truncate.js +20 -2
- package/dist/providers/truncate.js.map +1 -1
- package/dist/providers/types.d.ts +96 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/providers/types.js +59 -1
- package/dist/providers/types.js.map +1 -1
- package/dist/provisional-manager.d.ts +93 -0
- package/dist/provisional-manager.d.ts.map +1 -0
- package/dist/provisional-manager.js +98 -0
- package/dist/provisional-manager.js.map +1 -0
- package/dist/provisional.d.ts +150 -0
- package/dist/provisional.d.ts.map +1 -0
- package/dist/provisional.js +238 -0
- package/dist/provisional.js.map +1 -0
- package/dist/regret-tracker.d.ts +84 -0
- package/dist/regret-tracker.d.ts.map +1 -0
- package/dist/regret-tracker.js +145 -0
- package/dist/regret-tracker.js.map +1 -0
- package/dist/replay-cli.d.ts +13 -0
- package/dist/replay-cli.d.ts.map +1 -0
- package/dist/replay-cli.js +167 -0
- package/dist/replay-cli.js.map +1 -0
- package/dist/replay.d.ts +107 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +225 -0
- package/dist/replay.js.map +1 -0
- package/dist/reranker.d.ts +181 -0
- package/dist/reranker.d.ts.map +1 -0
- package/dist/reranker.js +324 -0
- package/dist/reranker.js.map +1 -0
- package/dist/session-trie.d.ts +103 -0
- package/dist/session-trie.d.ts.map +1 -0
- package/dist/session-trie.js +280 -0
- package/dist/session-trie.js.map +1 -0
- package/dist/speculative.d.ts +74 -0
- package/dist/speculative.d.ts.map +1 -0
- package/dist/speculative.js +107 -0
- package/dist/speculative.js.map +1 -0
- package/dist/tool-summarize.d.ts +40 -0
- package/dist/tool-summarize.d.ts.map +1 -0
- package/dist/tool-summarize.js +245 -0
- package/dist/tool-summarize.js.map +1 -0
- package/dist/trie-sanitize.d.ts +22 -0
- package/dist/trie-sanitize.d.ts.map +1 -0
- package/dist/trie-sanitize.js +142 -0
- package/dist/trie-sanitize.js.map +1 -0
- package/dist/versions.d.ts +23 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +31 -0
- package/dist/versions.js.map +1 -0
- package/package.json +3 -2
package/dist/ghost-editor.d.ts
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
import { CustomEditor, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { KeybindingsManager } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { type EditorTheme, type TUI } from "@earendil-works/pi-tui";
|
|
4
|
-
import type { GhostConfig } from "./config.js";
|
|
4
|
+
import type { GhostConfig, ProviderConfig } from "./config.js";
|
|
5
|
+
import { type RecentMessage } from "./context-aggregator.js";
|
|
5
6
|
import type { MetricsLogger } from "./metrics.js";
|
|
6
7
|
import type { PathIndex } from "./path-index.js";
|
|
7
|
-
import type {
|
|
8
|
+
import type { ProfileStore } from "./profile-store.js";
|
|
9
|
+
export { cycleCandidateIdx, nextWordChunk } from "./cycle-manager.js";
|
|
10
|
+
import { type GhostProvider } from "./providers/types.js";
|
|
11
|
+
/**
|
|
12
|
+
* #5 helper — classify a stale event as divergent or typed-through given
|
|
13
|
+
* the ghost state at render time and the post-change text. Returns true
|
|
14
|
+
* when the user typed characters that are NOT a prefix of the suggested
|
|
15
|
+
* ghost. Pure / exported for testability — the editor wraps this in
|
|
16
|
+
* `recordDivergentTyped` to track the consecutive run.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTypedPastDivergent(ghost: string, ghostForText: string, textAfterChange: string): boolean;
|
|
19
|
+
/** Parse `PI_GHOST_SHORT_HOVER_MS`. Falls back to the default on invalid
|
|
20
|
+
* or non-positive input. Exposed for tests; called once per dismiss. */
|
|
21
|
+
export declare function parseShortHoverEnv(raw: string | undefined): number;
|
|
8
22
|
export declare class GhostEditor extends CustomEditor {
|
|
9
23
|
private provider;
|
|
10
24
|
private readonly config;
|
|
11
25
|
private readonly extCtx;
|
|
12
26
|
private readonly metrics;
|
|
13
27
|
private readonly onError;
|
|
14
|
-
private
|
|
28
|
+
private profile;
|
|
15
29
|
private ghostText;
|
|
16
30
|
private ghostForText;
|
|
31
|
+
private readonly keystrokeTimer;
|
|
32
|
+
/**
|
|
33
|
+
* Tracks consecutive divergent stales on the same line for the #5
|
|
34
|
+
* typed-past negative signal. Reset by any accept or a non-divergent
|
|
35
|
+
* (i.e., user-typed-through) stale. Carries the original `(prefix,
|
|
36
|
+
* ghost)` so a single penalty at threshold can be applied against the
|
|
37
|
+
* pair that was actually being typed-past.
|
|
38
|
+
*/
|
|
39
|
+
private divergentRun;
|
|
17
40
|
private ghostReplaceFrom;
|
|
18
41
|
private debounceTimer;
|
|
19
42
|
private inflight;
|
|
@@ -22,25 +45,319 @@ export declare class GhostEditor extends CustomEditor {
|
|
|
22
45
|
private shownMetric;
|
|
23
46
|
private recentPaths;
|
|
24
47
|
private recentPathsAt;
|
|
25
|
-
|
|
48
|
+
private readonly fastPath;
|
|
49
|
+
private readonly providerFingerprint;
|
|
50
|
+
private readonly versionFingerprint;
|
|
51
|
+
/** Tracks the prefix shown alongside the current ghost so commit-time
|
|
52
|
+
* reconciliation can decide accepted vs divergent. */
|
|
53
|
+
private lastAcceptedGhost;
|
|
54
|
+
/** PRD §M3e/f — CycleManager owns the ranked candidate list, cycling (Alt+]/Alt+[),
|
|
55
|
+
* word-level partial accepts (Ctrl+Right), and related accounting. */
|
|
56
|
+
private readonly cycleMgr;
|
|
57
|
+
/** PRD §M5a — regret detection after accept. Pending while the
|
|
58
|
+
* window is open; flushed on regret or deadline. */
|
|
59
|
+
private pendingRegret;
|
|
60
|
+
private regretTimer;
|
|
61
|
+
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager, extCtx: ExtensionContext, config: GhostConfig, provider: GhostProvider | null, metrics?: MetricsLogger | null, pathIndex?: PathIndex | null, onError?: ((err: Error) => void) | null, profile?: ProfileStore | null);
|
|
26
62
|
setPathIndex(index: PathIndex | null): void;
|
|
63
|
+
setProfile(profile: ProfileStore | null): void;
|
|
64
|
+
/**
|
|
65
|
+
* PRD §M3g — diagnostic snapshot for the `/ghost` command. Pure read,
|
|
66
|
+
* no side effects. Numbers are point-in-time; the editor doesn't keep
|
|
67
|
+
* a running window. `cooldownMs` is reported when the active provider
|
|
68
|
+
* is a `RaceProvider`; otherwise omitted.
|
|
69
|
+
*/
|
|
70
|
+
getDiagnostics(): GhostDiagnostics;
|
|
71
|
+
/**
|
|
72
|
+
* Build the edit-history section of `/ghost` diag. Snapshot is taken at
|
|
73
|
+
* call time; `topAdded` / `topRemoved` expose token *lists only* (no
|
|
74
|
+
* raw text — privacy contract from spec §6.5).
|
|
75
|
+
*/
|
|
76
|
+
private buildEditHistoryDiag;
|
|
27
77
|
setProvider(provider: GhostProvider | null): void;
|
|
28
78
|
dispose(): void;
|
|
29
79
|
handleInput(data: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Right Arrow → full ghost accept (append-mode appends, replace-mode
|
|
82
|
+
* replaces the typed token). Seeds the trie + profile with the accepted
|
|
83
|
+
* (prefix, ghost) pair for append-mode only — replace-mode ghosts are
|
|
84
|
+
* structurally incompatible with the trie's append model.
|
|
85
|
+
*/
|
|
86
|
+
private handleFullAccept;
|
|
87
|
+
/**
|
|
88
|
+
* PRD §M3f — Ctrl+Right consumes the next word of the ghost.
|
|
89
|
+
* Append-mode only; replace-mode ghosts (fuzzy/path) accept atomically
|
|
90
|
+
* via Right. Returns true iff the keystroke was claimed (chunk inserted
|
|
91
|
+
* or final-chunk path taken). A no-op move (empty chunk) falls through.
|
|
92
|
+
*/
|
|
93
|
+
private handlePartialWordAccept;
|
|
94
|
+
/**
|
|
95
|
+
* PRD §M3e — Alt+]/Alt+[ cycle through ranked candidates. Append-mode
|
|
96
|
+
* only and only when more than one candidate exists. Clamp at edges
|
|
97
|
+
* (no wrap). An edge press is a silent no-op: ghost is preserved
|
|
98
|
+
* (see `maybeDismissGhost`) and cycledCount is NOT incremented since
|
|
99
|
+
* the user didn't actually cycle.
|
|
100
|
+
*/
|
|
101
|
+
private handleCycle;
|
|
102
|
+
/**
|
|
103
|
+
* Keys we explicitly own preserve the ghost; everything else dismisses.
|
|
104
|
+
* Alt+]/Alt+[ always preserve (match VS Code: alt+] on a single
|
|
105
|
+
* candidate is a silent no-op, ghost stays). Ctrl+Right preserves
|
|
106
|
+
* ONLY in append-mode — for replace-mode (fuzzy/path) ghosts,
|
|
107
|
+
* Ctrl+Right is normal cursor word-right nav, so the ghost should
|
|
108
|
+
* dismiss before the parent editor moves the cursor.
|
|
109
|
+
*/
|
|
110
|
+
private maybeDismissGhost;
|
|
111
|
+
/**
|
|
112
|
+
* Observe post-`super.handleInput` text change: feed the keystroke timer
|
|
113
|
+
* (single-char insertions only), check pending regret, and dispatch
|
|
114
|
+
* to `handleTextChange` for the next prediction cycle.
|
|
115
|
+
*/
|
|
116
|
+
private observePostInputTextChange;
|
|
117
|
+
/**
|
|
118
|
+
* Enhancement #1 — capture an edit event into the FastPathEngine's
|
|
119
|
+
* `EditHistoryRing`. Diffs `prev` vs `next` to derive the minimal
|
|
120
|
+
* `{added, removed}` slice, sanitizes both sides (event dropped on a
|
|
121
|
+
* sensitive hit), tokenizes, and records.
|
|
122
|
+
*
|
|
123
|
+
* No-op when `PI_GHOST_EDIT_HISTORY=0` (master switch read at engine
|
|
124
|
+
* construction). Single-buffer URI sentinel `"prompt"` — the editor
|
|
125
|
+
* owns one document.
|
|
126
|
+
*/
|
|
127
|
+
private recordEditEvent;
|
|
128
|
+
/**
|
|
129
|
+
* Build the editProximity scorer bound to the current cursor + a
|
|
130
|
+
* fresh `EditHistoryIndex` snapshot. Returns `null` when edit-history
|
|
131
|
+
* is disabled OR the ring is empty (no signal to surface). Captured
|
|
132
|
+
* per-prediction-cycle so the scorer is consistent across all
|
|
133
|
+
* candidates in a single rerank.
|
|
134
|
+
*/
|
|
135
|
+
private buildEditProximityScorer;
|
|
30
136
|
render(width: number): string[];
|
|
31
137
|
private cursorAtEnd;
|
|
32
138
|
private shouldShowGhost;
|
|
33
139
|
private clearGhost;
|
|
34
140
|
private cancelInflight;
|
|
141
|
+
/**
|
|
142
|
+
* #5 — track consecutive divergent stales on the same prefix family.
|
|
143
|
+
* A non-divergent (i.e., typed-through) stale resets the run because
|
|
144
|
+
* the user was on-track with the suggestion. At threshold we apply a
|
|
145
|
+
* trie penalty against the original `(prefix, ghost)` and stamp the
|
|
146
|
+
* current `shownMetric` so the resulting stale record carries the
|
|
147
|
+
* `typedPastDivergent` flag. Only one penalty per run — the run resets
|
|
148
|
+
* so a long string of divergent typing doesn't double-charge.
|
|
149
|
+
*/
|
|
150
|
+
private recordDivergentTyped;
|
|
35
151
|
private handleTextChange;
|
|
152
|
+
/**
|
|
153
|
+
* Extension host hook: notify the editor that a user prompt has been
|
|
154
|
+
* committed (Enter pressed, message submitted). Seeds the session trie
|
|
155
|
+
* with prefix→remainder shingles from the committed text and reconciles
|
|
156
|
+
* any in-flight accepted ghost against the actual commit (for divergent
|
|
157
|
+
* dismiss accounting in a future iteration).
|
|
158
|
+
*
|
|
159
|
+
* Sanitization happens inside the trie. The hook is safe to call with raw
|
|
160
|
+
* user text — secrets are filtered before insertion.
|
|
161
|
+
*/
|
|
162
|
+
onPromptCommitted(text: string): void;
|
|
163
|
+
/**
|
|
164
|
+
* Single-line prefix at the cursor, used as the trie key. Stripping
|
|
165
|
+
* earlier lines keeps trie entries small and keeps "prefix" semantics
|
|
166
|
+
* consistent across single-line commits vs multi-line edits.
|
|
167
|
+
*/
|
|
168
|
+
private lastSingleLinePrefix;
|
|
169
|
+
/**
|
|
170
|
+
* Assemble the recent-message context for a prediction. Combines:
|
|
171
|
+
* - M6a: opt-in tool entries via `getRecentMessages({ includeTools })`
|
|
172
|
+
* - M6c: type-aware summarization + cap on tool count
|
|
173
|
+
* - M6b: relevance-pruned selection by BM25 + recency
|
|
174
|
+
*
|
|
175
|
+
* Returns oldest-first messages suitable for provider rendering. Sized
|
|
176
|
+
* by the M6d env knobs; falls back to `config.provider.maxRecentMessages`
|
|
177
|
+
* when context scanning is effectively disabled.
|
|
178
|
+
*/
|
|
179
|
+
private buildSelectedContext;
|
|
180
|
+
private textBeforeCursor;
|
|
181
|
+
private applyServedGhost;
|
|
182
|
+
/**
|
|
183
|
+
* Shared ghost-state mutation used by every "show this ghost now" path
|
|
184
|
+
* (served, deterministic). Sets the 7 ghost-related fields atomically.
|
|
185
|
+
* `replaceFrom` is null for append-mode ghosts; non-null for fuzzy/path
|
|
186
|
+
* replace-mode. Does NOT touch `shownMetric` — callers build that with
|
|
187
|
+
* source-specific fields.
|
|
188
|
+
*/
|
|
189
|
+
private setShownGhost;
|
|
190
|
+
/**
|
|
191
|
+
* PRD §M4 — slash-command fast-path. Runs before the minChars gate and
|
|
192
|
+
* before the provider check: profile-local lookup, no LLM, useful even
|
|
193
|
+
* at 1-char prefixes (`/`). Returns true when a slash-completion was
|
|
194
|
+
* served. Profile must exist; line must start with `/`.
|
|
195
|
+
*/
|
|
196
|
+
private trySlashFastPath;
|
|
36
197
|
private tryDeterministic;
|
|
37
198
|
private getRecentPaths;
|
|
38
199
|
private applyDeterministic;
|
|
39
200
|
private replaceTokenAtCursor;
|
|
201
|
+
/**
|
|
202
|
+
* PRD §M3.5b — arm a provisional ghost. Engine owns the timer + env
|
|
203
|
+
* gate + picker construction (uses its own trie/lastGhosts plus the
|
|
204
|
+
* supplied profile). Editor supplies the request-scoped `canRender`
|
|
205
|
+
* predicate and the `onShow` UI mutator — both close over `ctrl` +
|
|
206
|
+
* `textAtSchedule` so they stay consistent with the in-flight request.
|
|
207
|
+
*/
|
|
208
|
+
private armProvisional;
|
|
40
209
|
private requestPrediction;
|
|
210
|
+
/**
|
|
211
|
+
* Refresh context + fingerprints + build the provider request bag at
|
|
212
|
+
* fire-time. Session messages may have arrived during the debounce
|
|
213
|
+
* window; the cache key we persist must match what the provider actually
|
|
214
|
+
* sees, otherwise a later identical keystroke would miss its own cached
|
|
215
|
+
* result. Pure context construction — no LLM call.
|
|
216
|
+
*/
|
|
217
|
+
private buildPredictionContext;
|
|
218
|
+
/**
|
|
219
|
+
* Post-provider-call disposition: stamp TTFT, run the post-flight gate,
|
|
220
|
+
* sanitize empty results, rerank, apply confidence gate, reconcile with
|
|
221
|
+
* any displayed provisional, and commit. Each early-return emits the
|
|
222
|
+
* appropriate metric; the happy path lands in `commitDisplayedGhost`.
|
|
223
|
+
*
|
|
224
|
+
* Extracted from `requestPrediction` as part of refactor #57 phase 1 so
|
|
225
|
+
* the orchestrator stays a thin sequence (build → await → finalize).
|
|
226
|
+
*/
|
|
227
|
+
private finalizeProviderResult;
|
|
228
|
+
/**
|
|
229
|
+
* Centralized post-provider-call disposition. Returns `null` when the
|
|
230
|
+
* result is good to render; otherwise the abort reason the caller should
|
|
231
|
+
* report via `emitMetric`. Clears `this.inflight` only on the happy path
|
|
232
|
+
* (matches the prior in-line behavior at the first non-aborted check) so
|
|
233
|
+
* an `aborted` return leaves `inflight` for the catch / next request to
|
|
234
|
+
* deal with.
|
|
235
|
+
*/
|
|
236
|
+
private postFlightCheck;
|
|
237
|
+
/**
|
|
238
|
+
* PRD §M3.5a — invoke the provider in either streaming or multi-candidate
|
|
239
|
+
* mode and (when streaming) drive incremental UI paint via `onChunk`.
|
|
240
|
+
* Stamps TTFT on the first stream chunk and returns it for the caller to
|
|
241
|
+
* attach to the pending metric.
|
|
242
|
+
*
|
|
243
|
+
* - Streaming path: provider exposes `predictStream` AND lacks
|
|
244
|
+
* `predictMulti`. Used by Mercury FIM streaming + LocalProvider.
|
|
245
|
+
* - Multi path: everything else (openai-compat FIM, race with sync
|
|
246
|
+
* members). `onChunk` is ignored.
|
|
247
|
+
*
|
|
248
|
+
* Extracted from `requestPrediction` as part of refactor #57 so the
|
|
249
|
+
* orchestrator stays focused on rerank / reconcile / commit.
|
|
250
|
+
*/
|
|
251
|
+
private runPredictionPath;
|
|
252
|
+
/**
|
|
253
|
+
* Commit a successfully-reconciled LLM ghost to all on-screen + fast-path
|
|
254
|
+
* structures: ranked candidate list, ghost text, cache, speculative ring,
|
|
255
|
+
* and the pending metric record. Extracted from `requestPrediction` as
|
|
256
|
+
* part of refactor #57 to keep the orchestrator readable.
|
|
257
|
+
*
|
|
258
|
+
* Cache + speculative ring store the *reranked* top — a subsequent cache
|
|
259
|
+
* hit must reproduce what the user actually saw, not the provider's
|
|
260
|
+
* pre-rerank order.
|
|
261
|
+
*/
|
|
262
|
+
private commitDisplayedGhost;
|
|
41
263
|
private emitMetric;
|
|
42
264
|
private finalizeShown;
|
|
265
|
+
/**
|
|
266
|
+
* Detach + clear the pending-regret watch (handle + timer) atomically
|
|
267
|
+
* and return the captured handle. Callers decide how to resolve the
|
|
268
|
+
* outcome (`observeRegret`, `expireRegret`, or a forced no-regret on
|
|
269
|
+
* Enter-commit) and log the resulting record.
|
|
270
|
+
*
|
|
271
|
+
* Returns null when no watch was armed — callers can short-circuit.
|
|
272
|
+
*/
|
|
273
|
+
private takePendingRegret;
|
|
274
|
+
private resolvePendingRegret;
|
|
275
|
+
/**
|
|
276
|
+
* Flush any pending regret-watched record. Called by the timer, by a
|
|
277
|
+
* later accept that supersedes the prior window, or by dispose.
|
|
278
|
+
* Detects regret against the *current* editor text via `expireRegret`
|
|
279
|
+
* so the final record reflects whatever the user did in the window.
|
|
280
|
+
*/
|
|
281
|
+
private flushRegret;
|
|
43
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Render a recent-messages array into a single string for eval capture
|
|
285
|
+
* (PRD §M5c). Format mirrors the provider context shape — `role: text`
|
|
286
|
+
* joined by newlines — so a CLI replay can feed it back to the same
|
|
287
|
+
* provider. Tool entries get a `tool ${name}:` label.
|
|
288
|
+
*/
|
|
289
|
+
export declare function renderContextForEval(recent: RecentMessage[]): string;
|
|
290
|
+
export interface GhostDiagnostics {
|
|
291
|
+
provider: string | null;
|
|
292
|
+
providerFingerprint: string;
|
|
293
|
+
versionFingerprint: string;
|
|
294
|
+
/** PRD §M3g — capability flags detected from the active provider. */
|
|
295
|
+
capabilities: {
|
|
296
|
+
streaming: boolean;
|
|
297
|
+
multiCandidate: boolean;
|
|
298
|
+
preflight: boolean;
|
|
299
|
+
/** PRD §M7 — provider populates per-token `-logprob` on stream events. */
|
|
300
|
+
logprobs: boolean;
|
|
301
|
+
};
|
|
302
|
+
cache: {
|
|
303
|
+
size: number;
|
|
304
|
+
hits: number;
|
|
305
|
+
misses: number;
|
|
306
|
+
hitRate: number;
|
|
307
|
+
};
|
|
308
|
+
trie: {
|
|
309
|
+
prefixes: number;
|
|
310
|
+
candidates: number;
|
|
311
|
+
insertsSinceDecay: number;
|
|
312
|
+
};
|
|
313
|
+
profile: {
|
|
314
|
+
enabled: boolean;
|
|
315
|
+
ngrams: number;
|
|
316
|
+
paths: number;
|
|
317
|
+
slash: number;
|
|
318
|
+
accepts: number;
|
|
319
|
+
decayDays: number;
|
|
320
|
+
};
|
|
321
|
+
race: {
|
|
322
|
+
cooldown: {
|
|
323
|
+
active: boolean;
|
|
324
|
+
remainingMs: number;
|
|
325
|
+
};
|
|
326
|
+
members: Array<{
|
|
327
|
+
name: string;
|
|
328
|
+
slowCount: number;
|
|
329
|
+
wins: number;
|
|
330
|
+
skipRemaining: number;
|
|
331
|
+
}>;
|
|
332
|
+
} | null;
|
|
333
|
+
ghostShown: boolean;
|
|
334
|
+
/** PRD §M5a — regret window state. `null` when no accept is being
|
|
335
|
+
* watched; otherwise the remaining ms until the window closes. */
|
|
336
|
+
pendingRegret: {
|
|
337
|
+
remainingMs: number;
|
|
338
|
+
insertedLen: number;
|
|
339
|
+
} | null;
|
|
340
|
+
/**
|
|
341
|
+
* Enhancement #1 — edit-history snapshot for `/ghost` diag. `enabled`
|
|
342
|
+
* mirrors `PI_GHOST_EDIT_HISTORY`; the remaining fields are populated
|
|
343
|
+
* even when disabled (they'll just report zeros).
|
|
344
|
+
*/
|
|
345
|
+
editHistory: {
|
|
346
|
+
enabled: boolean;
|
|
347
|
+
events: number;
|
|
348
|
+
capacity: number;
|
|
349
|
+
uris: number;
|
|
350
|
+
topAdded: string[];
|
|
351
|
+
topRemoved: string[];
|
|
352
|
+
oldestAgeMs: number | null;
|
|
353
|
+
halfLifeMs: number;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Build a stable provider fingerprint from the config. For race configs, fold
|
|
358
|
+
* each member into the `extras` map so member rotation invalidates cache.
|
|
359
|
+
*/
|
|
360
|
+
export declare function providerFingerprintFromConfig(cfg: ProviderConfig): string;
|
|
44
361
|
/**
|
|
45
362
|
* Pure helper: replace the slice `[from.col, end-of-line]` on `from.line` of
|
|
46
363
|
* `text` with `replacement`. Exported for testability.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ghost-editor.d.ts","sourceRoot":"","sources":["../src/ghost-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAiB,KAAK,WAAW,EAA+B,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"ghost-editor.d.ts","sourceRoot":"","sources":["../src/ghost-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,C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