@kliebhan/pi-prompt-autocomplete 0.2.2 → 0.2.3

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.2.3] - 2026-08-06
6
+
7
+ ### Fixed
8
+
9
+ - Inline suggestions now render on hosts that keep an editor background surface alive. The renderer located the fake cursor by Pi's exact `\x1b[7m \x1b[0m` byte sequence, but forks such as prime-agent close the inverse-video cursor with `\x1b[27m` so the background survives the cursor cell. The lookup missed, so suggestions were generated and counted as showing yet never drawn. The cursor lookup now accepts both reset variants and rebuilds the line with the host's own reset.
10
+
5
11
  ## [0.2.2] - 2026-08-06
6
12
 
7
13
  ### Security
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.2.2/prompt-autocomplete-demo.mp4)
5
+ [Watch the demo](https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.2.3/prompt-autocomplete-demo.mp4)
6
6
 
7
7
  ## Install
8
8
 
package/index.ts CHANGED
@@ -59,7 +59,13 @@ import {
59
59
  const GHOST_TEXT_STYLE = "\x1b[2m";
60
60
  const GHOST_INDICATOR_STYLE = "\x1b[90m";
61
61
  const RESET = "\x1b[0m";
62
- const CURSOR_TOKEN = "\x1b[7m \x1b[0m";
62
+ // Hosts draw the end-of-line fake cursor as an inverse-video space. Pi closes
63
+ // it with a full SGR reset (\x1b[0m); forks that keep an editor background
64
+ // surface alive, such as prime-agent, close it with \x1b[27m so the background
65
+ // survives the cursor cell. Accept both, otherwise the suggestion lookup never
66
+ // finds the cursor and inline suggestions silently never render.
67
+ const CURSOR_INVERSE_SPACE = "\x1b[7m ";
68
+ const CURSOR_TOKEN_PATTERN = /\x1b\[7m \x1b\[(0|27)m/;
63
69
  const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
64
70
  const SPINNER_INTERVAL_MS = 80;
65
71
  const SPINNER_LABEL = "Generating suggestion";
@@ -718,15 +724,26 @@ class PromptAutocompleteEditor extends CustomEditor {
718
724
  return lines;
719
725
  }
720
726
 
721
- const cursorLineIndex = lines.findIndex((line) => line.includes(CURSOR_TOKEN));
722
- if (cursorLineIndex === -1) return lines;
727
+ let cursorLineIndex = -1;
728
+ let cursorMatch: RegExpMatchArray | undefined;
729
+ for (let index = 0; index < lines.length; index++) {
730
+ if (!lines[index]!.includes(CURSOR_INVERSE_SPACE)) continue;
731
+ const match = lines[index]!.match(CURSOR_TOKEN_PATTERN);
732
+ if (match?.index !== undefined) {
733
+ cursorLineIndex = index;
734
+ cursorMatch = match;
735
+ break;
736
+ }
737
+ }
738
+ if (cursorLineIndex === -1 || !cursorMatch || cursorMatch.index === undefined) return lines;
723
739
 
724
740
  const cursorLine = lines[cursorLineIndex]!;
725
- const cursorIndex = cursorLine.indexOf(CURSOR_TOKEN);
726
- if (cursorIndex === -1) return lines;
741
+ const cursorIndex = cursorMatch.index;
742
+ const cursorToken = cursorMatch[0];
743
+ const cursorReset = cursorMatch[1] === "27" ? "\x1b[27m" : "\x1b[0m";
727
744
 
728
745
  const before = cursorLine.slice(0, cursorIndex);
729
- const after = cursorLine.slice(cursorIndex + CURSOR_TOKEN.length);
746
+ const after = cursorLine.slice(cursorIndex + cursorToken.length);
730
747
  const availableWidth = visibleWidth(after);
731
748
  if (availableWidth <= 0) return lines;
732
749
 
@@ -735,7 +752,7 @@ class PromptAutocompleteEditor extends CustomEditor {
735
752
  const firstPreviewChar = previewChars[0] ?? "";
736
753
  const absorbLeadingWhitespaceIntoCursor = /^[ \t]$/.test(firstPreviewChar);
737
754
 
738
- const cursorCell = absorbLeadingWhitespaceIntoCursor ? `\x1b[7m${firstPreviewChar}\x1b[0m` : CURSOR_TOKEN;
755
+ const cursorCell = absorbLeadingWhitespaceIntoCursor ? `\x1b[7m${firstPreviewChar}${cursorReset}` : cursorToken;
739
756
  const renderedPreviewText = absorbLeadingWhitespaceIntoCursor ? previewChars.slice(1).join("") : previewText;
740
757
 
741
758
  const indicator = this.suggestions.length > 1 ? ` ‹${this.suggestionIndex + 1}/${this.suggestions.length}›` : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kliebhan/pi-prompt-autocomplete",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
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.2.2/prompt-autocomplete-demo.mp4"
29
+ "video": "https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.2.3/prompt-autocomplete-demo.mp4"
30
30
  },
31
31
  "engines": {
32
32
  "node": ">=22.19.0"