pi-autosuggestions 0.3.2 → 0.4.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.
@@ -1 +1 @@
1
- {".":"0.3.2"}
1
+ {".":"0.4.0"}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.3...pi-autosuggestions-v0.4.0) (2026-09-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * subcommand completion for common bash commands ([3b17e1c](https://github.com/0xPlayerOne/pi-autosuggestions/commit/3b17e1cc5c6ee0ef92b5f2f564a9f8a7ce896411))
9
+
10
+ ## [0.3.3](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.2...pi-autosuggestions-v0.3.3) (2026-09-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * force white blinking bar cursor in terminals with themed cursors ([20a3a24](https://github.com/0xPlayerOne/pi-autosuggestions/commit/20a3a2499cad2ec3a83e1c8d1edd0c96b6d6a2ee))
16
+
3
17
  ## [0.3.2](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.1...pi-autosuggestions-v0.3.2) (2026-09-04)
4
18
 
5
19
 
package/README.md CHANGED
@@ -52,6 +52,21 @@ suggest elsewhere.
52
52
  - **`Esc`** — dismiss the suggestion until your next edit
53
53
  - Suggestion hides when the cursor leaves end-of-line, returns when you come back
54
54
 
55
+ ### Subcommand completion (bash mode)
56
+
57
+ For well-known commands the **first argument** completes from a built-in
58
+ subcommand table instead of the filesystem:
59
+
60
+ | Input | Result |
61
+ |-------|--------|
62
+ | `!git s` | dropdown — `show`, `stash`, `status`, … (marked `git subcommand`) |
63
+ | `!git statu` | inline ghost `s` → `status` |
64
+ | `!git zz` | no subcommand match → falls back to path completion |
65
+
66
+ Covered commands: `git`, `npm`, `pnpm`, `yarn`, `bun`, `docker`, `kubectl`,
67
+ `cargo`, `brew`, `gh`. Deeper arguments (branch names, flags, file args)
68
+ still complete from history or the filesystem.
69
+
55
70
  ### Command completion (bash mode)
56
71
 
57
72
  The first word after `!` completes against **executables on your `$PATH`** —
@@ -90,8 +105,11 @@ The editor's fake block cursor is replaced by your terminal's **native blinking
90
105
  bar cursor** — the same behavior as Apple Terminal's bar style: it overlays the
91
106
  cell edge without ever covering the character, blinks on its own, and pauses
92
107
  blinking while you type. On ghost rows the bar rides the suggestion's first
93
- character. The extension requests the blinking-bar shape via `DECSCUSR`
94
- (`CSI 5 q`); terminals without that escape use their profile's cursor shape.
108
+ character. The extension forces the cursor **white** (OSC 12) and requests the
109
+ blinking-bar shape (DECSCUSR `CSI 5 q`) so it doesn't inherit the terminal
110
+ theme's cursor color; both are restored to your terminal's defaults when pi
111
+ exits. If blinking stays off (e.g. Warp), check the terminal's own cursor-blink
112
+ setting (Warp: Settings → Appearance → Cursor → Blinking).
95
113
  A software beam cursor is kept as a fallback if the hardware cursor is
96
114
  unavailable.
97
115
 
@@ -39,6 +39,72 @@ const BEAM = "\x1b[1m▏\x1b[0m";
39
39
  /** Matches the reverse-video block the base renderer emits for the cursor. */
40
40
  const REVERSE_CURSOR = /\x1b\[7m([\s\S]*?)\x1b\[0m/;
41
41
 
42
+ /** First-argument (subcommand) completions for common commands. */
43
+ const SUBCOMMANDS: Record<string, string[]> = {
44
+ git: [
45
+ "add", "am", "apply", "archive", "bisect", "blame", "branch", "bundle", "checkout",
46
+ "cherry-pick", "clean", "clone", "commit", "config", "describe", "diff", "fetch",
47
+ "fsck", "gc", "init", "log", "merge", "mv", "pull", "push", "rebase", "reflog",
48
+ "remote", "repack", "reset", "restore", "revert", "rm", "shortlog", "show",
49
+ "stash", "status", "submodule", "switch", "tag", "worktree",
50
+ ],
51
+ npm: [
52
+ "audit", "bin", "bugs", "cache", "ci", "completion", "config", "dedupe", "deprecate",
53
+ "diff", "dist-tag", "docs", "doctor", "edit", "exec", "explain", "explore", "find-dupes",
54
+ "fund", "help", "hook", "init", "install", "link", "login", "logout", "ls", "npm-autoinit",
55
+ "org", "outdated", "owner", "pack", "ping", "pkg", "prefix", "profile", "prune",
56
+ "publish", "query", "rebuild", "repo", "restart", "root", "run-script", "search",
57
+ "set", "shrinkwrap", "star", "stars", "start", "stop", "team", "test", "token",
58
+ "uninstall", "unpublish", "unstar", "update", "version", "view", "whoami",
59
+ ],
60
+ pnpm: [
61
+ "add", "audit", "bin", "config", "create", "dlx", "exec", "import", "init", "install",
62
+ "link", "list", "outdated", "pack", "patch", "prune", "publish", "rebuild", "remove",
63
+ "rename", "run", "store", "test", "unlink", "update", "why",
64
+ ],
65
+ yarn: [
66
+ "add", "audit", "bin", "cache", "config", "create", "dedupe", "dlx", "exec", "global",
67
+ "info", "init", "install", "link", "list", "outdated", "owner", "pack", "publish",
68
+ "remove", "run", "self", "unlink", "upgrade", "up", "version", "why", "workspace", "workspaces",
69
+ ],
70
+ bun: [
71
+ "add", "build", "create", "init", "install", "link", "outdated", "pm", "publish",
72
+ "remove", "run", "test", "unlink", "update", "upgrade", "x",
73
+ ],
74
+ docker: [
75
+ "attach", "build", "commit", "container", "cp", "create", "diff", "events", "exec",
76
+ "export", "history", "image", "images", "import", "info", "inspect", "kill", "load",
77
+ "login", "logout", "logs", "network", "pause", "port", "ps", "pull", "push", "rename",
78
+ "restart", "rm", "rmi", "run", "save", "search", "start", "stats", "stop", "system",
79
+ "tag", "top", "unpause", "update", "version", "volume", "wait",
80
+ ],
81
+ kubectl: [
82
+ "annotate", "api-resources", "api-versions", "apply", "attach", "auth", "autoscale",
83
+ "cluster-info", "completion", "config", "cordon", "cp", "create", "delete", "describe",
84
+ "diff", "drain", "edit", "exec", "explain", "expose", "get", "label", "logs", "options",
85
+ "patch", "port-forward", "proxy", "replace", "rollout", "run", "scale", "set", "taint",
86
+ "top", "uncordon", "version", "wait",
87
+ ],
88
+ cargo: [
89
+ "add", "bench", "build", "check", "clean", "doc", "fetch", "fix", "fmt", "init",
90
+ "install", "locate-project", "login", "logout", "metadata", "new", "owner", "package",
91
+ "publish", "read-manifest", "remove", "report", "run", "rustc", "rustdoc", "search",
92
+ "test", "tree", "uninstall", "update", "vendor", "verify-project", "version", "yank",
93
+ ],
94
+ brew: [
95
+ "audit", "bundle", "cleanup", "commands", "config", "deps", "desc", "doctor", "edit",
96
+ "fetch", "formula", "home", "info", "install", "leaves", "link", "list", "log",
97
+ "missing", "options", "outdated", "pin", "postinstall", "readall", "reinstall",
98
+ "search", "services", "style", "tap", "uninstall", "unlink", "unpin", "untap",
99
+ "update", "upgrade", "uses",
100
+ ],
101
+ gh: [
102
+ "alias", "api", "auth", "browse", "cache", "codespace", "completion", "config",
103
+ "extension", "gist", "gpg-key", "issue", "label", "org", "pr", "project", "release",
104
+ "repo", "run", "search", "secret", "ssh-key", "status", "variable", "workflow",
105
+ ],
106
+ };
107
+
42
108
  const BLINK_INTERVAL_MS = 500;
43
109
  /** Cursor stays solid for this long after each keystroke, then resumes blinking. */
44
110
  const SOLID_AFTER_INPUT_MS = 450;
@@ -61,9 +127,12 @@ class BashInlineEditor extends CustomEditor {
61
127
  super(tui, theme, keybindings);
62
128
  // Native terminal cursor = the Apple-Terminal-style blinking bar: it
63
129
  // draws over the glyph's cell edge without covering the character.
64
- // DECSCUSR 5 q requests a blinking bar where the terminal supports
65
- // it; otherwise the terminal profile's cursor shape is used as-is.
130
+ // - DECSCUSR 5 q: blinking bar shape (Warp honors this).
131
+ // - OSC 12: force the cursor color white — terminals like Warp paint
132
+ // the native cursor with the theme's color (often blue), which we
133
+ // don't control from the theme.
66
134
  tui.setShowHardwareCursor(true);
135
+ tui.terminal.write("\x1b]12;#ffffff\x1b\\");
67
136
  tui.terminal.write("\x1b[5 q");
68
137
  // Wrap onChange so programmatic text changes (paste, undo, history,
69
138
  // setText) also refresh the inline suggestion.
@@ -316,6 +385,30 @@ class BashInlineEditor extends CustomEditor {
316
385
  return current.getSuggestions(lines, cursorLine, cursorCol, options);
317
386
  }
318
387
  const before = (lines[cursorLine] ?? "").slice(0, cursorCol);
388
+ // First-argument completion for known commands:
389
+ // "!git s" → status/stash/show… (replaces path completion).
390
+ const arg = /^[\t ]*!+(\S+)[ \t]+(\S*)$/.exec(before);
391
+ if (arg) {
392
+ const cmd = arg[1]!;
393
+ const token = arg[2] ?? "";
394
+ const subs = SUBCOMMANDS[cmd];
395
+ if (subs) {
396
+ const matches = subs
397
+ .filter((sc) => sc.startsWith(token))
398
+ .slice(0, 50);
399
+ if (matches.length > 0) {
400
+ return {
401
+ items: matches.map((sc) => ({
402
+ value: sc,
403
+ label: sc,
404
+ description: `${cmd} subcommand`,
405
+ })),
406
+ prefix: token,
407
+ };
408
+ }
409
+ // No subcommand matches the prefix: fall through to paths.
410
+ }
411
+ }
319
412
  let queryLines = lines;
320
413
  let commandItems: AutocompleteItem[] = [];
321
414
  let word = "";
@@ -536,4 +629,13 @@ export default function (pi: ExtensionAPI): void {
536
629
  pi.on("session_start", (_event, ctx) => {
537
630
  ctx.ui.setEditorComponent((tui, theme, keybindings) => new BashInlineEditor(tui, theme, keybindings));
538
631
  });
632
+ // Restore the terminal's own cursor color and shape when pi exits so the
633
+ // shell afterwards isn't left with our forced white bar.
634
+ process.on("exit", () => {
635
+ try {
636
+ process.stdout.write("\x1b]104;12\x1b\\\x1b[0 q");
637
+ } catch {
638
+ // terminal gone — nothing to restore
639
+ }
640
+ });
539
641
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-autosuggestions",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "zsh-autosuggestions-style ghost completions for the pi coding agent — history-based inline suggestions, path completion in bash mode, blinking beam cursor",
5
5
  "keywords": [
6
6
  "pi-package",