@kliebhan/pi-prompt-autocomplete 0.6.0 → 0.7.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 CHANGED
@@ -2,6 +2,12 @@
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.7.0] - 2026-11-17
6
+
7
+ ### Added
8
+
9
+ - RPC draft completion accepts `fresh` to ask the model again instead of reusing a cached result for the same request; the new result replaces the cached one.
10
+
5
11
  ## [0.6.0] - 2026-11-17
6
12
 
7
13
  ### 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.6.0/prompt-autocomplete-demo.mp4)
5
+ [Watch the demo](https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.7.0/prompt-autocomplete-demo.mp4)
6
6
 
7
7
  ## Install
8
8
 
@@ -157,7 +157,7 @@ pi --mode rpc --no-session --no-tools --prompt-autocomplete-model provider/model
157
157
 
158
158
  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
159
 
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.
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.
161
161
 
162
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. 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
163
 
package/index.ts CHANGED
@@ -2673,7 +2673,11 @@ async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocomplet
2673
2673
  }
2674
2674
  const alternatives = "alternatives" in value ? value.alternatives : 1;
2675
2675
  const manual = "manual" in value ? value.manual : false;
2676
- if (typeof alternatives !== "number" || !Number.isFinite(alternatives) || typeof manual !== "boolean") {
2676
+ const fresh = "fresh" in value ? value.fresh : false;
2677
+ if (
2678
+ typeof alternatives !== "number" || !Number.isFinite(alternatives)
2679
+ || typeof manual !== "boolean" || typeof fresh !== "boolean"
2680
+ ) {
2677
2681
  reply(null, "Invalid completion request");
2678
2682
  return;
2679
2683
  }
@@ -2707,7 +2711,8 @@ async function completeRpcDraft(ctx: ExtensionContext, shared: PromptAutocomplet
2707
2711
  }
2708
2712
  // Count and context are already in the key; keep manual results separate too.
2709
2713
  request.cacheKey = JSON.stringify([request.cacheKey, manual]);
2710
- let entry = getCachedRequest(shared, request.cacheKey);
2714
+ // `fresh` asks the model again instead of reusing a cached result for the same request.
2715
+ let entry = fresh ? undefined : getCachedRequest(shared, request.cacheKey);
2711
2716
  if (entry) shared.usageStats.cacheHits += 1;
2712
2717
  else entry = await fetchSuggestionUncached(shared, { ...request, useStreaming: false }, controller.signal, () => undefined);
2713
2718
  reply(controller.signal.aborted ? null : entry.suggestions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kliebhan/pi-prompt-autocomplete",
3
- "version": "0.6.0",
3
+ "version": "0.7.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.6.0/prompt-autocomplete-demo.mp4"
29
+ "video": "https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.7.0/prompt-autocomplete-demo.mp4"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=22.19.0"