pi-autosuggestions 0.3.3 → 0.5.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +29 -0
- package/extensions/autosuggestions.ts +286 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{".":"0.
|
|
1
|
+
{".":"0.5.0"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.0](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.4.0...pi-autosuggestions-v0.5.0) (2026-09-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* dynamic completions and expanded command tables ([4e99186](https://github.com/0xPlayerOne/pi-autosuggestions/commit/4e991868049694c1f973bc8ab2069af433c8bf4c))
|
|
9
|
+
|
|
10
|
+
## [0.4.0](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.3...pi-autosuggestions-v0.4.0) (2026-09-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* subcommand completion for common bash commands ([3b17e1c](https://github.com/0xPlayerOne/pi-autosuggestions/commit/3b17e1cc5c6ee0ef92b5f2f564a9f8a7ce896411))
|
|
16
|
+
|
|
3
17
|
## [0.3.3](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.3.2...pi-autosuggestions-v0.3.3) (2026-09-04)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -52,6 +52,35 @@ 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`, `go`, `uv`, `pip`, `poetry`, `terraform`, `helm`,
|
|
68
|
+
`wrangler`, `vercel`, `mise`, `asdf`, `systemctl`, `apt`, `pacman`.
|
|
69
|
+
Deeper arguments (flags, file args) still complete from history or the
|
|
70
|
+
filesystem.
|
|
71
|
+
|
|
72
|
+
### Dynamic completions (bash mode)
|
|
73
|
+
|
|
74
|
+
Some completions are **live** — the extension reads your project instead of a
|
|
75
|
+
static table (results cached for 10s):
|
|
76
|
+
|
|
77
|
+
| Input | Source |
|
|
78
|
+
|-------|--------|
|
|
79
|
+
| `!git checkout f` / `!git switch` / `!git merge` / `!git rebase` | branch names from `git branch` |
|
|
80
|
+
| `!npm run d` / `!pnpm run` / `!bun d` (implicit for yarn/pnpm/bun) | `scripts` from the nearest `package.json` |
|
|
81
|
+
| `!make d` | targets parsed from the nearest `Makefile` |
|
|
82
|
+
| `!docker compose u` | compose subcommands |
|
|
83
|
+
|
|
55
84
|
### Command completion (bash mode)
|
|
56
85
|
|
|
57
86
|
The first word after `!` completes against **executables on your `$PATH`** —
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
} from "@earendil-works/pi-tui";
|
|
21
21
|
|
|
22
22
|
/** Runtime access to Editor internals that are private in the type declarations. */
|
|
23
|
-
import { readdirSync, statSync } from "node:fs";
|
|
23
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
24
|
+
import { dirname } from "node:path";
|
|
24
25
|
import type { AutocompleteItem } from "@earendil-works/pi-tui";
|
|
25
26
|
|
|
26
27
|
interface EditorInternals {
|
|
@@ -34,11 +35,148 @@ interface EditorInternals {
|
|
|
34
35
|
|
|
35
36
|
const DIM = "\x1b[2m";
|
|
36
37
|
const RESET = "\x1b[0m";
|
|
38
|
+
/** Set at extension load; used for dynamic completion exec calls. */
|
|
39
|
+
let execApi: ExtensionAPI | undefined;
|
|
37
40
|
/** Beam cursor: thin vertical bar, bold so it stands out. One cell wide. */
|
|
38
41
|
const BEAM = "\x1b[1m▏\x1b[0m";
|
|
39
42
|
/** Matches the reverse-video block the base renderer emits for the cursor. */
|
|
40
43
|
const REVERSE_CURSOR = /\x1b\[7m([\s\S]*?)\x1b\[0m/;
|
|
41
44
|
|
|
45
|
+
/** First-argument (subcommand) completions for common commands. */
|
|
46
|
+
const SUBCOMMANDS: Record<string, string[]> = {
|
|
47
|
+
git: [
|
|
48
|
+
"add", "am", "apply", "archive", "bisect", "blame", "branch", "bundle", "checkout",
|
|
49
|
+
"cherry-pick", "clean", "clone", "commit", "config", "describe", "diff", "fetch",
|
|
50
|
+
"fsck", "gc", "init", "log", "merge", "mv", "pull", "push", "rebase", "reflog",
|
|
51
|
+
"remote", "repack", "reset", "restore", "revert", "rm", "shortlog", "show",
|
|
52
|
+
"stash", "status", "submodule", "switch", "tag", "worktree",
|
|
53
|
+
],
|
|
54
|
+
npm: [
|
|
55
|
+
"audit", "bin", "bugs", "cache", "ci", "completion", "config", "dedupe", "deprecate",
|
|
56
|
+
"diff", "dist-tag", "docs", "doctor", "edit", "exec", "explain", "explore", "find-dupes",
|
|
57
|
+
"fund", "help", "hook", "init", "install", "link", "login", "logout", "ls", "npm-autoinit",
|
|
58
|
+
"org", "outdated", "owner", "pack", "ping", "pkg", "prefix", "profile", "prune",
|
|
59
|
+
"publish", "query", "rebuild", "repo", "restart", "root", "run-script", "search",
|
|
60
|
+
"set", "shrinkwrap", "star", "stars", "start", "stop", "team", "test", "token",
|
|
61
|
+
"uninstall", "unpublish", "unstar", "update", "version", "view", "whoami",
|
|
62
|
+
],
|
|
63
|
+
pnpm: [
|
|
64
|
+
"add", "audit", "bin", "config", "create", "dlx", "exec", "import", "init", "install",
|
|
65
|
+
"link", "list", "outdated", "pack", "patch", "prune", "publish", "rebuild", "remove",
|
|
66
|
+
"rename", "run", "store", "test", "unlink", "update", "why",
|
|
67
|
+
],
|
|
68
|
+
yarn: [
|
|
69
|
+
"add", "audit", "bin", "cache", "config", "create", "dedupe", "dlx", "exec", "global",
|
|
70
|
+
"info", "init", "install", "link", "list", "outdated", "owner", "pack", "publish",
|
|
71
|
+
"remove", "run", "self", "unlink", "upgrade", "up", "version", "why", "workspace", "workspaces",
|
|
72
|
+
],
|
|
73
|
+
bun: [
|
|
74
|
+
"add", "build", "create", "init", "install", "link", "outdated", "pm", "publish",
|
|
75
|
+
"remove", "run", "test", "unlink", "update", "upgrade", "x",
|
|
76
|
+
],
|
|
77
|
+
docker: [
|
|
78
|
+
"attach", "build", "commit", "container", "cp", "create", "diff", "events", "exec",
|
|
79
|
+
"export", "history", "image", "images", "import", "info", "inspect", "kill", "load",
|
|
80
|
+
"login", "logout", "logs", "network", "pause", "port", "ps", "pull", "push", "rename",
|
|
81
|
+
"restart", "rm", "rmi", "run", "save", "search", "start", "stats", "stop", "system",
|
|
82
|
+
"tag", "top", "unpause", "update", "version", "volume", "wait",
|
|
83
|
+
],
|
|
84
|
+
kubectl: [
|
|
85
|
+
"annotate", "api-resources", "api-versions", "apply", "attach", "auth", "autoscale",
|
|
86
|
+
"cluster-info", "completion", "config", "cordon", "cp", "create", "delete", "describe",
|
|
87
|
+
"diff", "drain", "edit", "exec", "explain", "expose", "get", "label", "logs", "options",
|
|
88
|
+
"patch", "port-forward", "proxy", "replace", "rollout", "run", "scale", "set", "taint",
|
|
89
|
+
"top", "uncordon", "version", "wait",
|
|
90
|
+
],
|
|
91
|
+
cargo: [
|
|
92
|
+
"add", "bench", "build", "check", "clean", "doc", "fetch", "fix", "fmt", "init",
|
|
93
|
+
"install", "locate-project", "login", "logout", "metadata", "new", "owner", "package",
|
|
94
|
+
"publish", "read-manifest", "remove", "report", "run", "rustc", "rustdoc", "search",
|
|
95
|
+
"test", "tree", "uninstall", "update", "vendor", "verify-project", "version", "yank",
|
|
96
|
+
],
|
|
97
|
+
brew: [
|
|
98
|
+
"audit", "bundle", "cleanup", "commands", "config", "deps", "desc", "doctor", "edit",
|
|
99
|
+
"fetch", "formula", "home", "info", "install", "leaves", "link", "list", "log",
|
|
100
|
+
"missing", "options", "outdated", "pin", "postinstall", "readall", "reinstall",
|
|
101
|
+
"search", "services", "style", "tap", "uninstall", "unlink", "unpin", "untap",
|
|
102
|
+
"update", "upgrade", "uses",
|
|
103
|
+
],
|
|
104
|
+
gh: [
|
|
105
|
+
"alias", "api", "auth", "browse", "cache", "codespace", "completion", "config",
|
|
106
|
+
"extension", "gist", "gpg-key", "issue", "label", "org", "pr", "project", "release",
|
|
107
|
+
"repo", "run", "search", "secret", "ssh-key", "status", "variable", "workflow",
|
|
108
|
+
],
|
|
109
|
+
go: [
|
|
110
|
+
"bug", "build", "clean", "doc", "env", "fix", "fmt", "generate", "get", "help",
|
|
111
|
+
"install", "list", "mod", "run", "test", "tool", "version", "vet", "work",
|
|
112
|
+
],
|
|
113
|
+
uv: [
|
|
114
|
+
"add", "build", "cache", "export", "help", "init", "lock", "pip", "publish", "python",
|
|
115
|
+
"remove", "run", "self", "sync", "tool", "tree", "venv", "version",
|
|
116
|
+
],
|
|
117
|
+
pip: [
|
|
118
|
+
"cache", "check", "config", "debug", "download", "freeze", "hash", "index", "inspect",
|
|
119
|
+
"install", "list", "show", "uninstall", "wheel",
|
|
120
|
+
],
|
|
121
|
+
poetry: [
|
|
122
|
+
"add", "build", "cache", "check", "config", "env", "export", "init", "install",
|
|
123
|
+
"list", "lock", "new", "publish", "remove", "run", "search", "self", "shell",
|
|
124
|
+
"show", "source", "update", "version",
|
|
125
|
+
],
|
|
126
|
+
terraform: [
|
|
127
|
+
"apply", "console", "destroy", "fmt", "get", "graph", "import", "init", "output",
|
|
128
|
+
"plan", "providers", "refresh", "show", "state", "taint", "test", "untaint",
|
|
129
|
+
"validate", "version", "workspace",
|
|
130
|
+
],
|
|
131
|
+
helm: [
|
|
132
|
+
"completion", "create", "dependency", "env", "get", "help", "history", "install",
|
|
133
|
+
"lint", "list", "package", "plugin", "pull", "push", "registry", "repo", "rollback",
|
|
134
|
+
"search", "show", "status", "template", "test", "uninstall", "upgrade", "verify",
|
|
135
|
+
],
|
|
136
|
+
wrangler: [
|
|
137
|
+
"ai", "d1", "delete", "deploy", "dev", "dispatch", "init", "kv", "login", "logout",
|
|
138
|
+
"logs", "r2", "rollback", "secret", "subdomain", "tail", "triggers", "types",
|
|
139
|
+
"versions", "whoami",
|
|
140
|
+
],
|
|
141
|
+
vercel: [
|
|
142
|
+
"alias", "build", "deploy", "dev", "dns", "domains", "env", "init", "inspect",
|
|
143
|
+
"link", "login", "logout", "logs", "ls", "projects", "pull", "remove", "switch",
|
|
144
|
+
"teams", "telemetry", "whoami",
|
|
145
|
+
],
|
|
146
|
+
mise: [
|
|
147
|
+
"activate", "current", "deactivate", "doctor", "exec", "global", "install", "link",
|
|
148
|
+
"list", "local", "ls", "outdated", "prune", "reshim", "run", "settings", "tasks",
|
|
149
|
+
"uninstall", "upgrade", "use", "which",
|
|
150
|
+
],
|
|
151
|
+
asdf: [
|
|
152
|
+
"current", "exec", "global", "info", "install", "latest", "list", "list-all",
|
|
153
|
+
"local", "plugin", "reshim", "shell", "uninstall", "update", "version", "where",
|
|
154
|
+
"which",
|
|
155
|
+
],
|
|
156
|
+
systemctl: [
|
|
157
|
+
"cat", "disable", "enable", "is-active", "is-enabled", "isolate", "kill", "list",
|
|
158
|
+
"list-dependencies", "list-timers", "list-units", "mask", "reload", "reload-or-restart",
|
|
159
|
+
"restart", "set-default", "show", "start", "status", "stop", "unmask",
|
|
160
|
+
],
|
|
161
|
+
apt: [
|
|
162
|
+
"autoclean", "autopurge", "autoremove", "build-dep", "cache", "check", "clean",
|
|
163
|
+
"download", "edit-sources", "full-upgrade", "help", "install", "list", "purge",
|
|
164
|
+
"reinstall", "remove", "satisfy", "search", "show", "source", "update", "upgrade",
|
|
165
|
+
],
|
|
166
|
+
pacman: [
|
|
167
|
+
"-Q", "-R", "-S", "-T", "-U", "-F", "clean", "deps", "files", "help", "query",
|
|
168
|
+
"remove", "sync", "test", "upgrade", "version",
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const COMPOSE_SUBCOMMANDS = [
|
|
173
|
+
"build", "config", "create", "down", "events", "exec", "images", "kill", "logs", "ls",
|
|
174
|
+
"pause", "port", "ps", "pull", "push", "restart", "rm", "run", "start", "stop", "top",
|
|
175
|
+
"unpause", "up", "version", "wait", "watch",
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
// (SUBCOMMANDS gains more tables below — see SUBCOMMANDS_EXTRA merge point.)
|
|
179
|
+
|
|
42
180
|
const BLINK_INTERVAL_MS = 500;
|
|
43
181
|
/** Cursor stays solid for this long after each keystroke, then resumes blinking. */
|
|
44
182
|
const SOLID_AFTER_INPUT_MS = 450;
|
|
@@ -311,6 +449,117 @@ class BashInlineEditor extends CustomEditor {
|
|
|
311
449
|
.slice(0, 100);
|
|
312
450
|
}
|
|
313
451
|
|
|
452
|
+
private dynCache = new Map<string, { at: number; data: string[] }>();
|
|
453
|
+
|
|
454
|
+
private cached(key: string, ttl: number, fetch: () => Promise<string[]>): Promise<string[]> {
|
|
455
|
+
const hit = this.dynCache.get(key);
|
|
456
|
+
if (hit && Date.now() - hit.at < ttl) {
|
|
457
|
+
return hit.data;
|
|
458
|
+
}
|
|
459
|
+
return fetch()
|
|
460
|
+
.then((data) => {
|
|
461
|
+
this.dynCache.set(key, { at: Date.now(), data });
|
|
462
|
+
return data;
|
|
463
|
+
})
|
|
464
|
+
.catch(() => []);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
private async runCommand(cmd: string, args: string[], timeout = 4000): Promise<string[]> {
|
|
468
|
+
if (!execApi) {
|
|
469
|
+
return [];
|
|
470
|
+
}
|
|
471
|
+
const result = await execApi.exec(cmd, args, { cwd: process.cwd(), timeout });
|
|
472
|
+
if (result.code !== 0) {
|
|
473
|
+
return [];
|
|
474
|
+
}
|
|
475
|
+
return result.stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
private findUp(name: string): string | null {
|
|
479
|
+
let dir = process.cwd();
|
|
480
|
+
for (;;) {
|
|
481
|
+
const candidate = `${dir}/${name}`;
|
|
482
|
+
if (existsSync(candidate)) {
|
|
483
|
+
return candidate;
|
|
484
|
+
}
|
|
485
|
+
const parent = dirname(dir);
|
|
486
|
+
if (parent === dir) {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
dir = parent;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
private gitBranches(): Promise<string[]> {
|
|
494
|
+
return this.cached("git:branches", 10_000, async () =>
|
|
495
|
+
(await this.runCommand("git", ["branch", "--list"]))
|
|
496
|
+
.map((l) => l.replace(/^\*?\s*/, ""))
|
|
497
|
+
.filter((l) => l && !l.includes(" ")));
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
private npmScripts(): Promise<string[]> {
|
|
501
|
+
return this.cached("npm:scripts", 10_000, async () => {
|
|
502
|
+
const pkg = this.findUp("package.json");
|
|
503
|
+
if (!pkg) {
|
|
504
|
+
return [];
|
|
505
|
+
}
|
|
506
|
+
const parsed: { scripts?: Record<string, string> } = JSON.parse(readFileSync(pkg, "utf8"));
|
|
507
|
+
return Object.keys(parsed.scripts ?? {});
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
private makeTargets(): Promise<string[]> {
|
|
512
|
+
return this.cached("make:targets", 10_000, async () => {
|
|
513
|
+
const file = this.findUp("Makefile") ?? this.findUp("makefile");
|
|
514
|
+
if (!file) {
|
|
515
|
+
return [];
|
|
516
|
+
}
|
|
517
|
+
const targets = new Set<string>();
|
|
518
|
+
for (const line of readFileSync(file, "utf8").split("\n")) {
|
|
519
|
+
const m = /^([a-zA-Z0-9][^\s=$#]*(?:\s+[a-zA-Z0-9][^\s=$#]*)?):(?!=)/.exec(line);
|
|
520
|
+
if (m) {
|
|
521
|
+
for (const t of m[1]!.trim().split(/\s+/)) {
|
|
522
|
+
targets.add(t);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return [...targets];
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** Live sources: git branches, package scripts, make targets, compose. */
|
|
531
|
+
private async dynamicCompletions(
|
|
532
|
+
cmd: string,
|
|
533
|
+
args: string[],
|
|
534
|
+
token: string,
|
|
535
|
+
): Promise<{ items: string[]; description: string } | null> {
|
|
536
|
+
let items: string[] | null = null;
|
|
537
|
+
let description = "";
|
|
538
|
+
if (cmd === "git" && args.length === 1 && ["checkout", "switch", "merge", "rebase"].includes(args[0]!)) {
|
|
539
|
+
items = (await this.gitBranches()).filter((b) => b.startsWith(token));
|
|
540
|
+
description = "branch";
|
|
541
|
+
} else if (cmd === "git" && args[0] === "branch" && args.length === 1) {
|
|
542
|
+
items = (await this.gitBranches()).filter((b) => b.startsWith(token));
|
|
543
|
+
description = "branch";
|
|
544
|
+
} else if (
|
|
545
|
+
["npm", "pnpm", "yarn", "bun"].includes(cmd) &&
|
|
546
|
+
((args[0] === "run" && args.length === 1) || (cmd !== "npm" && args.length === 0))
|
|
547
|
+
) {
|
|
548
|
+
items = (await this.npmScripts()).filter((sc) => sc.startsWith(token));
|
|
549
|
+
description = "script";
|
|
550
|
+
} else if ((cmd === "make" || cmd === "gmake") && args.length === 0) {
|
|
551
|
+
items = (await this.makeTargets()).filter((t) => t.startsWith(token));
|
|
552
|
+
description = "make target";
|
|
553
|
+
} else if (cmd === "docker" && args[0] === "compose" && args.length === 1) {
|
|
554
|
+
items = COMPOSE_SUBCOMMANDS.filter((sc) => sc.startsWith(token));
|
|
555
|
+
description = "compose subcommand";
|
|
556
|
+
}
|
|
557
|
+
if (!items || items.length === 0) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
return { items: items.slice(0, 50), description };
|
|
561
|
+
}
|
|
562
|
+
|
|
314
563
|
private createBashProvider(current: AutocompleteProvider): AutocompleteProvider {
|
|
315
564
|
const self = this;
|
|
316
565
|
return {
|
|
@@ -319,6 +568,41 @@ class BashInlineEditor extends CustomEditor {
|
|
|
319
568
|
return current.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
320
569
|
}
|
|
321
570
|
const before = (lines[cursorLine] ?? "").slice(0, cursorCol);
|
|
571
|
+
// First-argument completion for known commands:
|
|
572
|
+
// "!git s" → status/stash/show… (replaces path completion).
|
|
573
|
+
const arg = /^[\t ]*!+(\S+)[ \t]+(\S*)$/.exec(before);
|
|
574
|
+
if (arg) {
|
|
575
|
+
const cmd = arg[1]!;
|
|
576
|
+
const token = arg[2] ?? "";
|
|
577
|
+
const subs = SUBCOMMANDS[cmd];
|
|
578
|
+
const staticMatches = (subs ?? []).filter((sc) => sc.startsWith(token)).slice(0, 50);
|
|
579
|
+
const dynamic = await self.dynamicCompletions(cmd, [], token);
|
|
580
|
+
const dynamicItems = dynamic?.items.filter((d) => !staticMatches.includes(d)) ?? [];
|
|
581
|
+
if (staticMatches.length > 0 || dynamicItems.length > 0) {
|
|
582
|
+
return {
|
|
583
|
+
items: [
|
|
584
|
+
...staticMatches.map((sc) => ({ value: sc, label: sc, description: `${cmd} subcommand` })),
|
|
585
|
+
...dynamicItems.map((sc) => ({ value: sc, label: sc, description: dynamic!.description })),
|
|
586
|
+
],
|
|
587
|
+
prefix: token,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
// Nothing matched: fall through to paths.
|
|
591
|
+
}
|
|
592
|
+
// Second-argument dynamic completion (branches, scripts, compose…).
|
|
593
|
+
const words = before.replace(/^[\t ]*!+/, "").split(/[ \t]+/);
|
|
594
|
+
if (words.length >= 2) {
|
|
595
|
+
const cmd = words[0]!;
|
|
596
|
+
const token = words[words.length - 1]!;
|
|
597
|
+
const args = words.slice(1, -1).filter(Boolean);
|
|
598
|
+
const dyn = await self.dynamicCompletions(cmd, args, token);
|
|
599
|
+
if (dyn && dyn.items.length > 0) {
|
|
600
|
+
return {
|
|
601
|
+
items: dyn.items.map((sc) => ({ value: sc, label: sc, description: dyn.description })),
|
|
602
|
+
prefix: token,
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
}
|
|
322
606
|
let queryLines = lines;
|
|
323
607
|
let commandItems: AutocompleteItem[] = [];
|
|
324
608
|
let word = "";
|
|
@@ -536,6 +820,7 @@ class BashInlineEditor extends CustomEditor {
|
|
|
536
820
|
}
|
|
537
821
|
|
|
538
822
|
export default function (pi: ExtensionAPI): void {
|
|
823
|
+
execApi = pi;
|
|
539
824
|
pi.on("session_start", (_event, ctx) => {
|
|
540
825
|
ctx.ui.setEditorComponent((tui, theme, keybindings) => new BashInlineEditor(tui, theme, keybindings));
|
|
541
826
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-autosuggestions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|