@kliebhan/pi-prompt-autocomplete 0.7.0 → 0.8.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/CHANGELOG.md +10 -0
- package/README.md +5 -3
- package/core.ts +50 -0
- package/index.ts +56 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented here. This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
+
## [0.8.0] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `--prompt-autocomplete-thinking <off|minimal|low|medium|high>` (default `off`) sets the thinking each suggestion request asks for, and an RPC draft completion can ask for another level with `thinking`. Results are cached per level.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- A model that thinks before answering got only the answer's output budget, so its thinking often used it up and the request returned no suggestion. Reasoning models now get extra output tokens for it, capped at their output limit, also with `off` unless the model names how to switch thinking off, and higher levels get more time. A response whose thinking still used up the budget before any answer text reports `Thinking used up the output tokens before an answer` instead of an empty result.
|
|
14
|
+
|
|
5
15
|
## [0.7.0] - 2026-11-17
|
|
6
16
|
|
|
7
17
|
### Added
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Inline AI completions for the [Pi coding agent](https://github.com/earendil-works/pi-mono), rendered as unobtrusive ghost text in the prompt editor.
|
|
4
4
|
|
|
5
|
-
[Watch the demo](https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.
|
|
5
|
+
[Watch the demo](https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.8.0/prompt-autocomplete-demo.mp4)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -78,6 +78,7 @@ pi \
|
|
|
78
78
|
--prompt-autocomplete-debounce-ms 250 \
|
|
79
79
|
--prompt-autocomplete-max-chars 240 \
|
|
80
80
|
--prompt-autocomplete-max-alternatives 3 \
|
|
81
|
+
--prompt-autocomplete-thinking off \
|
|
81
82
|
--prompt-autocomplete-max-requests off
|
|
82
83
|
```
|
|
83
84
|
|
|
@@ -90,6 +91,7 @@ pi \
|
|
|
90
91
|
- Suggestions pause while the **main agent** is working by default, and stay paused until `agent_settled` on hosts that emit it. This is separate from streamed autocomplete responses. Use `--prompt-autocomplete-while-streaming` or `/prompt-autocomplete while-streaming on` to change that behavior.
|
|
91
92
|
- `Escape` dismissal lasts while the draft extends the dismissed text: further typing starts no request and does not bring the suggestion back. It ends for good when the draft stops extending it (`Backspace`, submit, clear, history), when the conversation, autocomplete model, `max-chars`, or `max-alternatives` changes, or on the one-shot key (`cycle-next`, `Ctrl+.` by default), accept, or cycling. Dismissing an empty-draft suggestion lasts only while the draft stays empty.
|
|
92
93
|
- `Ctrl+.` with no active suggestion is an explicit one-shot request and may bypass the main-agent-streaming, cooldown, and minimum-length gates. Model, authentication, slash-command, and path safety checks still apply.
|
|
94
|
+
- `--prompt-autocomplete-thinking <off|minimal|low|medium|high>` sets the thinking each request asks for; the default `off` asks for none where the model can switch it off. A reasoning model gets extra output tokens for it (1,024 for `off` and `minimal`, 2,048 for `low`, 4,096 for `medium`, 8,192 for `high`) on top of the answer's budget, capped at its output limit, and more time (8 s plus 7 s for `low`, 22 s for `medium`, 52 s for `high`); with `off`, a model that names how to switch thinking off gets none, and so does a model that cannot think. Thinking adds latency, so `off` with a fast model suits suggestions best. `status` shows the level.
|
|
93
95
|
- Use `--prompt-autocomplete-debug` or `/prompt-autocomplete debug-on` for troubleshooting.
|
|
94
96
|
|
|
95
97
|
Slash-command decisions outrank the CLI flags. `on`, `off`, `min-chars`, and `set` are also saved for later sessions and processes (see [Persistent settings](#persistent-settings)). `stream`, `while-streaming`, and `debug-*` live only in the current extension runtime: Pi replaces that runtime on `/new`, `/resume`, `/fork`, and `/reload`, after which their flags apply again. `status` labels each value with its source, `(flag)`, `(saved)`, or `(session)`. Settings you never toggled keep following their flag. Interactive `set` values outside the documented range are rejected rather than clamped; CLI flags still clamp.
|
|
@@ -157,9 +159,9 @@ pi --mode rpc --no-session --no-tools --prompt-autocomplete-model provider/model
|
|
|
157
159
|
|
|
158
160
|
Send an RPC `prompt` with message `/prompt-autocomplete complete <json>`. The JSON is `{"id":"unique-request-id","draft":"Write","context":{"lastUser":"…","lastAssistant":"…"}}`; `context` and both of its fields are optional. Supply the host thread's latest messages when the sidecar has no session. They use the existing bounded conversation snapshot, not the sidecar's conversation.
|
|
159
161
|
|
|
160
|
-
Optional request fields: `alternatives` (finite number, default `1`, rounded down and clamped to `1..max-alternatives`; configured by `--prompt-autocomplete-max-alternatives`, default `3`) asks for distinct alternatives in one model request. `manual` (boolean, default `false`) bypasses `min-chars`; with an empty draft, alternatives are complete prompts predicted from `context`. Cache entries distinguish alternative counts and manual mode; budget and cancellation rules are unchanged. `fresh` (boolean, default `false`) asks the model again instead of reusing a cached result for the same request, and the new result replaces the cached one.
|
|
162
|
+
Optional request fields: `alternatives` (finite number, default `1`, rounded down and clamped to `1..max-alternatives`; configured by `--prompt-autocomplete-max-alternatives`, default `3`) asks for distinct alternatives in one model request. `manual` (boolean, default `false`) bypasses `min-chars`; with an empty draft, alternatives are complete prompts predicted from `context`. Cache entries distinguish alternative counts and manual mode; budget and cancellation rules are unchanged. `fresh` (boolean, default `false`) asks the model again instead of reusing a cached result for the same request, and the new result replaces the cached one. `thinking` (`off`, `minimal`, `low`, `medium`, or `high`; default from `--prompt-autocomplete-thinking`) sets the thinking for this request; cache entries distinguish levels.
|
|
161
163
|
|
|
162
|
-
Each request receives one fire-and-forget `ctx.ui.setWidget("prompt-autocomplete-completion", [JSON.stringify(result)])`, where `result` is `{"id":"unique-request-id","completion":" the tests","completions":[" the tests"]}`. `completions` contains all distinct normalized alternatives in order, each bounded by `max-chars` and ready to **append**. `completion` always equals `completions[0]` or `null`. Every reply includes `completions`, empty for short automatic drafts, exhausted budgets, unusable output, superseded requests, or errors; errors also carry a short, sanitized `error` string
|
|
164
|
+
Each request receives one fire-and-forget `ctx.ui.setWidget("prompt-autocomplete-completion", [JSON.stringify(result)])`, where `result` is `{"id":"unique-request-id","completion":" the tests","completions":[" the tests"]}`. `completions` contains all distinct normalized alternatives in order, each bounded by `max-chars` and ready to **append**. `completion` always equals `completions[0]` or `null`. Every reply includes `completions`, empty for short automatic drafts, exhausted budgets, unusable output, superseded requests, or errors; errors also carry a short, sanitized `error` string, such as `Thinking used up the output tokens before an answer`. Requests without the new fields still return at most one alternative. Malformed requests with a string `id` receive an error; invalid JSON or missing/non-string ids cannot be correlated and receive no widget.
|
|
163
165
|
|
|
164
166
|
Use a unique id per request. A new request aborts the previous one and immediately replies `null` for its id, even if the provider is slow to stop. Requests share model selection, result cache, request budget, and stats with the existing path. This command does not write editor text or cancel next-prompt requests. It is RPC-only and omitted from argument completions.
|
|
165
167
|
|
package/core.ts
CHANGED
|
@@ -112,6 +112,55 @@ export const MAX_COMPACTION_SUMMARY_CHARS = 1_500;
|
|
|
112
112
|
export const MIN_REQUEST_MAX_TOKENS = 192;
|
|
113
113
|
export const MAX_REQUEST_MAX_TOKENS = 1_024;
|
|
114
114
|
|
|
115
|
+
/** Thinking a suggestion request asks for; `off` asks for none where the model allows it. */
|
|
116
|
+
export const PROMPT_AUTOCOMPLETE_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high"] as const;
|
|
117
|
+
export type PromptAutocompleteThinking = (typeof PROMPT_AUTOCOMPLETE_THINKING_LEVELS)[number];
|
|
118
|
+
export const DEFAULT_PROMPT_AUTOCOMPLETE_THINKING: PromptAutocompleteThinking = "off";
|
|
119
|
+
|
|
120
|
+
/** The thinking level `value` names, case-insensitively, or undefined. */
|
|
121
|
+
export function parsePromptAutocompleteThinking(value: unknown): PromptAutocompleteThinking | undefined {
|
|
122
|
+
if (typeof value !== "string") return undefined;
|
|
123
|
+
const normalized = value.trim().toLowerCase();
|
|
124
|
+
return PROMPT_AUTOCOMPLETE_THINKING_LEVELS.find((level) => level === normalized);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Output tokens a model may spend thinking before its answer, on top of the answer budget.
|
|
128
|
+
const THINKING_HEADROOM_TOKENS: Record<PromptAutocompleteThinking, number> = {
|
|
129
|
+
off: 1_024,
|
|
130
|
+
minimal: 1_024,
|
|
131
|
+
low: 2_048,
|
|
132
|
+
medium: 4_096,
|
|
133
|
+
high: 8_192,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Output tokens to add to the answer budget for thinking. None for a model that does not reason,
|
|
138
|
+
* or whose `thinkingLevelMap.off` names how to switch it off when `off` is asked; any other
|
|
139
|
+
* reasoning model may think anyway and gets room for it, or would use up the budget.
|
|
140
|
+
*/
|
|
141
|
+
export function thinkingHeadroomTokens(
|
|
142
|
+
thinking: PromptAutocompleteThinking,
|
|
143
|
+
model: { reasoning?: boolean; thinkingLevelMap?: Partial<Record<string, string | null>> },
|
|
144
|
+
): number {
|
|
145
|
+
if (!model.reasoning) return 0;
|
|
146
|
+
if (thinking === "off" && typeof model.thinkingLevelMap?.off === "string") return 0;
|
|
147
|
+
return THINKING_HEADROOM_TOKENS[thinking];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Extra time a request may take for the thinking it asks for.
|
|
151
|
+
const THINKING_EXTRA_TIMEOUT_MS: Record<PromptAutocompleteThinking, number> = {
|
|
152
|
+
off: 0,
|
|
153
|
+
minimal: 0,
|
|
154
|
+
low: 7_000,
|
|
155
|
+
medium: 22_000,
|
|
156
|
+
high: 52_000,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/** The response deadline for a request asking for `thinking`, from the deadline without it. */
|
|
160
|
+
export function thinkingTimeoutMs(thinking: PromptAutocompleteThinking, baseMs: number): number {
|
|
161
|
+
return baseMs + THINKING_EXTRA_TIMEOUT_MS[thinking];
|
|
162
|
+
}
|
|
163
|
+
|
|
115
164
|
export interface ModelRef {
|
|
116
165
|
provider: string;
|
|
117
166
|
id: string;
|
|
@@ -122,6 +171,7 @@ export interface PromptAutocompleteCacheIdentity {
|
|
|
122
171
|
modelLabel: string;
|
|
123
172
|
maxAlternatives: number;
|
|
124
173
|
maxSuggestionChars: number;
|
|
174
|
+
thinking: PromptAutocompleteThinking;
|
|
125
175
|
draft: string;
|
|
126
176
|
latestAssistantContext: string;
|
|
127
177
|
latestUserContext: string;
|
package/index.ts
CHANGED
|
@@ -33,6 +33,12 @@ import {
|
|
|
33
33
|
BUDGET_REQUESTS_MIN,
|
|
34
34
|
cancelAllCoalescedRequests,
|
|
35
35
|
computeRequestMaxTokens,
|
|
36
|
+
thinkingHeadroomTokens,
|
|
37
|
+
thinkingTimeoutMs,
|
|
38
|
+
parsePromptAutocompleteThinking,
|
|
39
|
+
type PromptAutocompleteThinking,
|
|
40
|
+
DEFAULT_PROMPT_AUTOCOMPLETE_THINKING,
|
|
41
|
+
PROMPT_AUTOCOMPLETE_THINKING_LEVELS,
|
|
36
42
|
createOwnerRefCounter,
|
|
37
43
|
createPromptAutocompleteUsageStats,
|
|
38
44
|
DEFAULT_BUDGET_REQUESTS_FLAG,
|
|
@@ -196,6 +202,8 @@ interface PromptAutocompleteConfig {
|
|
|
196
202
|
maxSuggestionChars: number;
|
|
197
203
|
maxAlternatives: number;
|
|
198
204
|
modelSelection: PromptAutocompleteModelSelection;
|
|
205
|
+
/** Thinking every request asks for; an RPC completion may ask for another. */
|
|
206
|
+
thinking: PromptAutocompleteThinking;
|
|
199
207
|
/** Effective provider-request ceiling; undefined means off. */
|
|
200
208
|
budgetLimit?: number;
|
|
201
209
|
/** RPC hosts only: send a predicted next prompt through `setEditorText` after each settled turn. */
|
|
@@ -595,6 +603,7 @@ interface SuggestionRequest extends PromptAutocompleteRequestSnapshot {
|
|
|
595
603
|
conversationId: string;
|
|
596
604
|
model: Model<Api>;
|
|
597
605
|
modelLabel: string;
|
|
606
|
+
thinking: PromptAutocompleteThinking;
|
|
598
607
|
cacheKey: string;
|
|
599
608
|
prefixContextKey: string;
|
|
600
609
|
/** Context an Escape dismissal of this request's suggestions is bound to. */
|
|
@@ -633,6 +642,7 @@ async function consumeAssistantStream(
|
|
|
633
642
|
signal: AbortSignal,
|
|
634
643
|
abortProvider: () => void,
|
|
635
644
|
onPartial: (message: AssistantMessage) => void,
|
|
645
|
+
timeoutMs = REQUEST_TIMEOUT_MS,
|
|
636
646
|
): Promise<AssistantMessage> {
|
|
637
647
|
const iterator = stream[Symbol.asyncIterator]();
|
|
638
648
|
let hardTimer: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -647,7 +657,7 @@ async function consumeAssistantStream(
|
|
|
647
657
|
// accidentally ignore their timeout option.
|
|
648
658
|
abortProvider();
|
|
649
659
|
reject(new Error("Provider stream exceeded the local response deadline"));
|
|
650
|
-
},
|
|
660
|
+
}, timeoutMs + STREAM_HARD_TIMEOUT_GRACE_MS);
|
|
651
661
|
});
|
|
652
662
|
const abortDeadline = new Promise<never>((_resolve, reject) => {
|
|
653
663
|
rejectAbortDrain = reject;
|
|
@@ -911,6 +921,8 @@ function parseConfig(pi: ExtensionAPI): PromptAutocompleteConfig {
|
|
|
911
921
|
MAX_ALTERNATIVES_MAX,
|
|
912
922
|
),
|
|
913
923
|
modelSelection: parsePromptAutocompleteModelSelection(pi.getFlag("prompt-autocomplete-model")),
|
|
924
|
+
thinking: parsePromptAutocompleteThinking(pi.getFlag("prompt-autocomplete-thinking"))
|
|
925
|
+
?? DEFAULT_PROMPT_AUTOCOMPLETE_THINKING,
|
|
914
926
|
budgetLimit: parsePromptAutocompleteBudgetFlag(pi.getFlag("prompt-autocomplete-max-requests")),
|
|
915
927
|
nextPrompt: pi.getFlag("prompt-autocomplete-next-prompt") === true,
|
|
916
928
|
};
|
|
@@ -1105,6 +1117,7 @@ function formatStatus(shared: PromptAutocompleteSharedState, interactiveHost = t
|
|
|
1105
1117
|
DEFAULT_MAX_ALTERNATIVES,
|
|
1106
1118
|
).source
|
|
1107
1119
|
})`,
|
|
1120
|
+
`thinking=${shared.config.thinking}(flag)`,
|
|
1108
1121
|
`cache-size=${shared.requestCache.size}`,
|
|
1109
1122
|
`budget=${formatBudget(shared)}`,
|
|
1110
1123
|
`usage=${formatUsageStats(shared.usageStats)}`,
|
|
@@ -2160,8 +2173,15 @@ async function fetchSuggestionUncached(
|
|
|
2160
2173
|
// so credentials are only passed to the compat functions and to seams.
|
|
2161
2174
|
...(viaRegistry ? {} : { apiKey: auth.apiKey, headers: auth.headers }),
|
|
2162
2175
|
signal,
|
|
2163
|
-
|
|
2164
|
-
|
|
2176
|
+
// Never above what the model can emit; providers reject a larger cap.
|
|
2177
|
+
maxTokens: Math.min(
|
|
2178
|
+
computeRequestMaxTokens(request.maxAlternatives, request.maxSuggestionChars)
|
|
2179
|
+
+ thinkingHeadroomTokens(request.thinking, request.model),
|
|
2180
|
+
request.model.maxTokens > 0 ? request.model.maxTokens : Number.POSITIVE_INFINITY,
|
|
2181
|
+
),
|
|
2182
|
+
// Unset asks for no thinking where the model can switch it off.
|
|
2183
|
+
...(request.thinking === "off" ? {} : { reasoning: request.thinking }),
|
|
2184
|
+
timeoutMs: thinkingTimeoutMs(request.thinking, REQUEST_TIMEOUT_MS),
|
|
2165
2185
|
maxRetries: REQUEST_MAX_RETRIES,
|
|
2166
2186
|
maxRetryDelayMs: REQUEST_MAX_RETRY_DELAY_MS,
|
|
2167
2187
|
};
|
|
@@ -2190,7 +2210,7 @@ async function fetchSuggestionUncached(
|
|
|
2190
2210
|
if (lastPublished && !suggestion.startsWith(lastPublished)) return;
|
|
2191
2211
|
lastPublished = suggestion;
|
|
2192
2212
|
publish(suggestion);
|
|
2193
|
-
});
|
|
2213
|
+
}, requestOptions.timeoutMs);
|
|
2194
2214
|
} else {
|
|
2195
2215
|
response = await shared.completeSimple(request.model, context, requestOptions);
|
|
2196
2216
|
}
|
|
@@ -2226,6 +2246,14 @@ async function fetchSuggestionUncached(
|
|
|
2226
2246
|
request.maxSuggestionChars,
|
|
2227
2247
|
request.maxAlternatives,
|
|
2228
2248
|
);
|
|
2249
|
+
// Thinking that used up the output budget leaves no answer; say so instead of suggesting nothing.
|
|
2250
|
+
if (
|
|
2251
|
+
normalized.length === 0 && text.trim().length === 0
|
|
2252
|
+
&& response.stopReason === "length" && contentTypes.includes("thinking")
|
|
2253
|
+
) {
|
|
2254
|
+
stats.failedRequests += 1;
|
|
2255
|
+
throw new ThinkingExhaustedError();
|
|
2256
|
+
}
|
|
2229
2257
|
|
|
2230
2258
|
const debugState =
|
|
2231
2259
|
normalized.length === 0
|
|
@@ -2499,6 +2527,7 @@ function buildSuggestionRequest(
|
|
|
2499
2527
|
activationId: number,
|
|
2500
2528
|
maxAlternatives = shared.config.maxAlternatives,
|
|
2501
2529
|
contextBranch?: unknown[],
|
|
2530
|
+
thinking = shared.config.thinking,
|
|
2502
2531
|
): SuggestionRequest | undefined {
|
|
2503
2532
|
const model = resolveSuggestionModel(shared);
|
|
2504
2533
|
if (!model) return undefined;
|
|
@@ -2518,6 +2547,7 @@ function buildSuggestionRequest(
|
|
|
2518
2547
|
modelLabel,
|
|
2519
2548
|
maxAlternatives: snapshot.maxAlternatives,
|
|
2520
2549
|
maxSuggestionChars: snapshot.maxSuggestionChars,
|
|
2550
|
+
thinking,
|
|
2521
2551
|
latestAssistantContext: snapshot.latestAssistantContext,
|
|
2522
2552
|
latestUserContext: snapshot.latestUserContext,
|
|
2523
2553
|
recentContext: snapshot.recentContext,
|
|
@@ -2530,6 +2560,7 @@ function buildSuggestionRequest(
|
|
|
2530
2560
|
conversationId,
|
|
2531
2561
|
model,
|
|
2532
2562
|
modelLabel,
|
|
2563
|
+
thinking,
|
|
2533
2564
|
cacheKey: buildPromptAutocompleteCacheKey({ ...prefixContextIdentity, draft: snapshot.draft }),
|
|
2534
2565
|
prefixContextKey: buildPromptAutocompletePrefixContextKey(prefixContextIdentity),
|
|
2535
2566
|
dismissalContext: buildDismissalContext(shared, conversationId),
|
|
@@ -2642,6 +2673,14 @@ async function suggestNextPrompt(ctx: ExtensionContext, shared: PromptAutocomple
|
|
|
2642
2673
|
}
|
|
2643
2674
|
}
|
|
2644
2675
|
|
|
2676
|
+
/** A response whose thinking used up the output tokens; its message is safe to show a host. */
|
|
2677
|
+
class ThinkingExhaustedError extends Error {
|
|
2678
|
+
constructor() {
|
|
2679
|
+
super("Thinking used up the output tokens before an answer");
|
|
2680
|
+
this.name = "ThinkingExhaustedError";
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2645
2684
|
/** RPC-only request/reply adapter; provider errors never cross the host boundary. */
|
|
2646
2685
|
async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocompleteSharedState, payload: string): Promise<void> {
|
|
2647
2686
|
if (ctx.mode !== "rpc") {
|
|
@@ -2681,6 +2720,11 @@ async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocomplet
|
|
|
2681
2720
|
reply(null, "Invalid completion request");
|
|
2682
2721
|
return;
|
|
2683
2722
|
}
|
|
2723
|
+
const thinking = "thinking" in value ? parsePromptAutocompleteThinking(value.thinking) : shared.config.thinking;
|
|
2724
|
+
if (thinking === undefined) {
|
|
2725
|
+
reply(null, "Invalid completion request");
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2684
2728
|
const maxAlternatives = Math.max(1, Math.min(shared.config.maxAlternatives, Math.floor(alternatives)));
|
|
2685
2729
|
const context = "context" in value ? value.context : undefined;
|
|
2686
2730
|
const branch: unknown[] = [];
|
|
@@ -2704,7 +2748,7 @@ async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocomplet
|
|
|
2704
2748
|
reply(null);
|
|
2705
2749
|
return;
|
|
2706
2750
|
}
|
|
2707
|
-
const request = buildSuggestionRequest(shared, value.draft, shared.activationId, maxAlternatives, branch);
|
|
2751
|
+
const request = buildSuggestionRequest(shared, value.draft, shared.activationId, maxAlternatives, branch, thinking);
|
|
2708
2752
|
if (!request) {
|
|
2709
2753
|
reply(null, "Completion model unavailable");
|
|
2710
2754
|
return;
|
|
@@ -2718,7 +2762,8 @@ async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocomplet
|
|
|
2718
2762
|
reply(controller.signal.aborted ? null : entry.suggestions);
|
|
2719
2763
|
} catch (error) {
|
|
2720
2764
|
reply(null, controller.signal.aborted || error instanceof PromptAutocompleteBudgetExhaustedError
|
|
2721
|
-
? undefined
|
|
2765
|
+
? undefined
|
|
2766
|
+
: error instanceof ThinkingExhaustedError ? error.message : "Completion request failed");
|
|
2722
2767
|
} finally {
|
|
2723
2768
|
controller.signal.removeEventListener("abort", onAbort);
|
|
2724
2769
|
if (shared.draftCompletionAbort === controller) shared.draftCompletionAbort = undefined;
|
|
@@ -3555,6 +3600,11 @@ export function createPromptAutocompleteExtension(
|
|
|
3555
3600
|
type: "string",
|
|
3556
3601
|
default: DEFAULT_PREFERRED_MODEL,
|
|
3557
3602
|
});
|
|
3603
|
+
pi.registerFlag("prompt-autocomplete-thinking", {
|
|
3604
|
+
description: `Thinking each suggestion request asks for (${PROMPT_AUTOCOMPLETE_THINKING_LEVELS.join("|")})`,
|
|
3605
|
+
type: "string",
|
|
3606
|
+
default: DEFAULT_PROMPT_AUTOCOMPLETE_THINKING,
|
|
3607
|
+
});
|
|
3558
3608
|
pi.registerFlag("prompt-autocomplete-while-streaming", {
|
|
3559
3609
|
description: "Allow prompt autocomplete while the main agent is still working",
|
|
3560
3610
|
type: "boolean",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kliebhan/pi-prompt-autocomplete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Privacy-conscious inline AI prompt completion for the Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"extensions": [
|
|
27
27
|
"./index.ts"
|
|
28
28
|
],
|
|
29
|
-
"video": "https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.
|
|
29
|
+
"video": "https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.8.0/prompt-autocomplete-demo.mp4"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=22.19.0"
|