pi-autosuggestions 0.3.3 → 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.3"}
1
+ {".":"0.4.0"}
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## [0.3.3](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.2...pi-autosuggestions-v0.3.3) (2026-09-04)
4
11
 
5
12
 
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`** —
@@ -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;
@@ -319,6 +385,30 @@ class BashInlineEditor extends CustomEditor {
319
385
  return current.getSuggestions(lines, cursorLine, cursorCol, options);
320
386
  }
321
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
+ }
322
412
  let queryLines = lines;
323
413
  let commandItems: AutocompleteItem[] = [];
324
414
  let word = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-autosuggestions",
3
- "version": "0.3.3",
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",