pi-ghost-autocomplete 0.9.1 → 0.10.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.
- package/README.md +17 -2
- package/dist/bench-cli.js +1 -1
- package/dist/bench.js +1 -1
- package/dist/fuzzy-matcher.d.ts +3 -0
- package/dist/ghost-editor.d.ts +39 -160
- package/dist/ghost-utils.d.ts +131 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1 -1
- package/dist/providers/openai-compat-provider.d.ts +5 -1
- package/dist/providers/race.d.ts +11 -0
- package/dist/providers/router.d.ts +5 -0
- package/dist/recent-paths.d.ts +31 -0
- package/dist/replay-cli.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-License-Identifier: SSPL-1.0
|
|
3
|
+
* SPDX-FileCopyrightText: 2025 Alessandro Pungitore <alessandro.pungitore.ch>
|
|
4
|
+
*/
|
|
5
|
+
import type { AcceptKeyId, ProviderConfig } from "./config.js";
|
|
6
|
+
import type { RecentMessage } from "./context-aggregator.js";
|
|
7
|
+
/** Parse `PI_GHOST_SHORT_HOVER_MS`. Falls back to the default on invalid
|
|
8
|
+
* or non-positive input. Exposed for tests; called once per dismiss. */
|
|
9
|
+
export declare function parseShortHoverEnv(raw: string | undefined): number;
|
|
10
|
+
/**
|
|
11
|
+
* #5 — was the user's typed tail divergent from the ghost? `false` when the
|
|
12
|
+
* ghost is empty, when nothing was typed, or when the typed tail is a prefix
|
|
13
|
+
* of the ghost (accept-in-progress). Drives `recordDivergentTyped`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isTypedPastDivergent(ghost: string, ghostForText: string, textAfterChange: string): boolean;
|
|
16
|
+
/** Gap-fix P1.3 — one-shot discoverability suffix on the first painted ghost. */
|
|
17
|
+
export declare const ACCEPT_HINT_SUFFIX = " [\u2192 accept]";
|
|
18
|
+
/**
|
|
19
|
+
* Build the visible ghost string (markers + optional accept hint).
|
|
20
|
+
* Pure helper so render logic is unit-testable without a TUI.
|
|
21
|
+
*/
|
|
22
|
+
export declare function formatGhostDisplay(input: {
|
|
23
|
+
ghost: string;
|
|
24
|
+
replaceMode: boolean;
|
|
25
|
+
provisional: boolean;
|
|
26
|
+
showAcceptHint: boolean;
|
|
27
|
+
}): string;
|
|
28
|
+
/**
|
|
29
|
+
* Gap-fix P2.2 — which keys trigger a full accept (before popup/cursor guards).
|
|
30
|
+
* Pure so unit tests cover the key matrix without a live editor.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isFullAcceptKey(data: string, acceptKeys: readonly AcceptKeyId[]): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Build a stable provider fingerprint from the config. For race configs, fold
|
|
35
|
+
* each member into the `extras` map so member rotation invalidates cache.
|
|
36
|
+
*/
|
|
37
|
+
export declare function providerFingerprintFromConfig(cfg: ProviderConfig): string;
|
|
38
|
+
/**
|
|
39
|
+
* Render a recent-messages array into a single string for eval capture
|
|
40
|
+
* (PRD §M5c). Format mirrors the provider context shape — `role: text`
|
|
41
|
+
* joined by newlines — so a CLI replay can feed it back to the same
|
|
42
|
+
* provider. Tool entries get a `tool ${name}:` label.
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderContextForEval(recent: RecentMessage[]): string;
|
|
45
|
+
/**
|
|
46
|
+
* Pure helper: replace the slice `[from.col, end-of-line]` on `from.line` of
|
|
47
|
+
* `text` with `replacement`. Exported for testability.
|
|
48
|
+
*
|
|
49
|
+
* Caller must guarantee the cursor sits at end of `from.line` and that the
|
|
50
|
+
* replacement is intended to land there; this helper does not validate.
|
|
51
|
+
*/
|
|
52
|
+
export declare function computeReplacement(text: string, from: {
|
|
53
|
+
line: number;
|
|
54
|
+
col: number;
|
|
55
|
+
}, replacement: string): string;
|
|
56
|
+
/**
|
|
57
|
+
* Visible column width of a possibly-ANSI-colored string.
|
|
58
|
+
* Uses string-width which handles wide chars, combining marks, and emoji.
|
|
59
|
+
*/
|
|
60
|
+
export declare function visualWidth(s: string): number;
|
|
61
|
+
/**
|
|
62
|
+
* Clip a string to fit in `maxCols` terminal columns, grapheme-aware.
|
|
63
|
+
* Returns the empty string if `maxCols <= 0` or no characters fit.
|
|
64
|
+
*/
|
|
65
|
+
export declare function clipToWidth(s: string, maxCols: number): string;
|
|
66
|
+
export interface GhostDiagnostics {
|
|
67
|
+
provider: string | null;
|
|
68
|
+
providerFingerprint: string;
|
|
69
|
+
versionFingerprint: string;
|
|
70
|
+
/** PRD §M3g — capability flags detected from the active provider. */
|
|
71
|
+
capabilities: {
|
|
72
|
+
streaming: boolean;
|
|
73
|
+
multiCandidate: boolean;
|
|
74
|
+
preflight: boolean;
|
|
75
|
+
/** PRD §M7 — provider populates per-token `-logprob` on stream events. */
|
|
76
|
+
logprobs: boolean;
|
|
77
|
+
};
|
|
78
|
+
cache: {
|
|
79
|
+
size: number;
|
|
80
|
+
hits: number;
|
|
81
|
+
misses: number;
|
|
82
|
+
hitRate: number;
|
|
83
|
+
};
|
|
84
|
+
trie: {
|
|
85
|
+
prefixes: number;
|
|
86
|
+
candidates: number;
|
|
87
|
+
insertsSinceDecay: number;
|
|
88
|
+
};
|
|
89
|
+
profile: {
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
ngrams: number;
|
|
92
|
+
paths: number;
|
|
93
|
+
slash: number;
|
|
94
|
+
accepts: number;
|
|
95
|
+
decayDays: number;
|
|
96
|
+
};
|
|
97
|
+
race: {
|
|
98
|
+
cooldown: {
|
|
99
|
+
active: boolean;
|
|
100
|
+
remainingMs: number;
|
|
101
|
+
};
|
|
102
|
+
members: Array<{
|
|
103
|
+
name: string;
|
|
104
|
+
slowCount: number;
|
|
105
|
+
wins: number;
|
|
106
|
+
skipRemaining: number;
|
|
107
|
+
}>;
|
|
108
|
+
} | null;
|
|
109
|
+
ghostShown: boolean;
|
|
110
|
+
/** PRD §M5a — regret window state. `null` when no accept is being
|
|
111
|
+
* watched; otherwise the remaining ms until the window closes. */
|
|
112
|
+
pendingRegret: {
|
|
113
|
+
remainingMs: number;
|
|
114
|
+
insertedLen: number;
|
|
115
|
+
} | null;
|
|
116
|
+
/**
|
|
117
|
+
* Enhancement #1 — edit-history snapshot for `/ghost` diag. `enabled`
|
|
118
|
+
* mirrors `PI_GHOST_EDIT_HISTORY`; the remaining fields are populated
|
|
119
|
+
* even when disabled (they'll just report zeros).
|
|
120
|
+
*/
|
|
121
|
+
editHistory: {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
events: number;
|
|
124
|
+
capacity: number;
|
|
125
|
+
uris: number;
|
|
126
|
+
topAdded: string[];
|
|
127
|
+
topRemoved: string[];
|
|
128
|
+
oldestAgeMs: number | null;
|
|
129
|
+
halfLifeMs: number;
|
|
130
|
+
};
|
|
131
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import { type GhostConfig } from "./config.js";
|
|
7
|
-
import type { GhostDiagnostics } from "./ghost-
|
|
7
|
+
import type { GhostDiagnostics } from "./ghost-utils.js";
|
|
8
8
|
declare const ghost: ExtensionFactory;
|
|
9
9
|
/**
|
|
10
10
|
* PRD §M3g — render the diagnostic snapshot from `GhostEditor.getDiagnostics`
|
|
@@ -32,8 +32,10 @@ export { RouterProvider, routeToChat, routeToChatByRegister } from "./providers/
|
|
|
32
32
|
export type { PreflightResult } from "./providers/openai-compat-provider.js";
|
|
33
33
|
export { RaceProvider, firstNonNull } from "./providers/race.js";
|
|
34
34
|
export type { RaceConfig, RaceTrace } from "./providers/race.js";
|
|
35
|
-
export { GhostEditor
|
|
36
|
-
export type {
|
|
35
|
+
export { GhostEditor } from "./ghost-editor.js";
|
|
36
|
+
export type { GhostLifecycleEvent, GhostLifecycleListener } from "./ghost-editor.js";
|
|
37
|
+
export { computeReplacement, isFullAcceptKey } from "./ghost-utils.js";
|
|
38
|
+
export type { GhostDiagnostics } from "./ghost-utils.js";
|
|
37
39
|
export type { GhostConfig, AcceptKeyId, ProviderConfig, CloudProviderConfig, LocalProviderConfig, OpenAICompatProviderConfig, OpenAICompatChatProviderConfig, RaceProviderConfig, RouterProviderConfig, } from "./config.js";
|
|
38
40
|
export { parseAcceptKeys, DEFAULT_ACCEPT_KEYS } from "./config.js";
|
|
39
41
|
export { BUILTIN_SLASH_COMMANDS, mergeKnownCommands, seedCommandTrie, COLD_START_TRIE_WEIGHT, } from "./cold-start.js";
|