pi-autosuggestions 0.2.3 → 0.3.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/.github/workflows/release.yml +23 -35
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +29 -0
- package/extensions/autosuggestions.ts +85 -7
- package/package.json +1 -1
- package/.github/workflows/minimal-test.yml +0 -25
|
@@ -1,47 +1,35 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Code Foundry
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches: [main]
|
|
6
6
|
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
release-while-paused:
|
|
9
|
+
description: Run only the release pipeline while the shared CI billing pause remains active.
|
|
10
|
+
required: false
|
|
11
|
+
type: boolean
|
|
12
|
+
default: false
|
|
7
13
|
|
|
8
14
|
permissions:
|
|
15
|
+
actions: write
|
|
9
16
|
contents: write
|
|
17
|
+
issues: write
|
|
10
18
|
pull-requests: write
|
|
11
19
|
id-token: write
|
|
12
20
|
|
|
13
21
|
jobs:
|
|
14
|
-
release
|
|
15
|
-
name: Release
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
publish-npm:
|
|
30
|
-
name: Publish npm
|
|
31
|
-
needs: release-please
|
|
32
|
-
if: needs.release-please.outputs.release_created == 'true'
|
|
33
|
-
runs-on: ubuntu-latest
|
|
34
|
-
steps:
|
|
35
|
-
- name: Checkout release
|
|
36
|
-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
37
|
-
with:
|
|
38
|
-
ref: ${{ needs.release-please.outputs.tag_name }}
|
|
39
|
-
- name: Setup Node
|
|
40
|
-
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
41
|
-
with:
|
|
42
|
-
node-version: 24
|
|
43
|
-
registry-url: https://registry.npmjs.org
|
|
44
|
-
- name: Publish
|
|
45
|
-
run: npm publish --provenance --access public
|
|
46
|
-
env:
|
|
47
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
22
|
+
release:
|
|
23
|
+
name: Release
|
|
24
|
+
if: vars.CI_BILLING_PAUSED != 'true' || (github.event_name == 'workflow_dispatch' && inputs['release-while-paused'] == true)
|
|
25
|
+
uses: 0xPlayerOne/code-foundry/.github/workflows/release.yml@v0.39.4
|
|
26
|
+
with:
|
|
27
|
+
billing-pause-bypass: ${{ github.event_name == 'workflow_dispatch' && inputs['release-while-paused'] == true }}
|
|
28
|
+
runner: ubuntu-slim
|
|
29
|
+
runtime-repository: 0xPlayerOne/code-foundry
|
|
30
|
+
runtime-ref: v0.39.4
|
|
31
|
+
secrets:
|
|
32
|
+
CODE_FOUNDRY_TOKEN: ${{ secrets.CODE_FOUNDRY_TOKEN }}
|
|
33
|
+
RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
|
34
|
+
STAGING_DEPLOY_KEY: ${{ secrets.STAGING_DEPLOY_KEY }}
|
|
35
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{".":"0.
|
|
1
|
+
{".":"0.3.0"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.2.4...pi-autosuggestions-v0.3.0) (2026-09-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* command-name completion from PATH at the bash command position ([9b4eef6](https://github.com/0xPlayerOne/pi-autosuggestions/commit/9b4eef62c780979fc972cb2d304eeefe8fd98db7))
|
|
9
|
+
|
|
10
|
+
## [0.2.4](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.2.3...pi-autosuggestions-v0.2.4) (2026-09-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### CI
|
|
14
|
+
|
|
15
|
+
* route releases through code-foundry ([2747d07](https://github.com/0xPlayerOne/pi-autosuggestions/commit/2747d07ba79a33c77bbca3c0f6fd1228eaeb3298))
|
|
16
|
+
|
|
3
17
|
## [0.2.3](https://github.com/0xPlayerOne/pi-autosuggestions/compare/pi-autosuggestions-v0.2.2...pi-autosuggestions-v0.2.3) (2026-09-04)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -23,6 +23,21 @@ pi install git:github.com/0xPlayerOne/pi-autosuggestions@pi-autosuggestions-v0.2
|
|
|
23
23
|
pi install npm:pi-autosuggestions
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
## Scope
|
|
27
|
+
|
|
28
|
+
| Layer | Where it works |
|
|
29
|
+
|-------|----------------|
|
|
30
|
+
| History ghost suggestions | **Everywhere** — normal prompts and `!`/`!!` bash mode |
|
|
31
|
+
| Path completion + dropdown | **Bash mode only** (`!`/`!!` commands) |
|
|
32
|
+
| Command-name completion | **Bash mode only**, first word after `!` |
|
|
33
|
+
| Beam cursor | **Everywhere** |
|
|
34
|
+
|
|
35
|
+
History is **session-scoped**: the ghost can only suggest prompts you already
|
|
36
|
+
submitted *in the current session* (pi has no persistent shell-history file
|
|
37
|
+
across sessions yet). If you mostly run `!` commands, the ghost will mostly
|
|
38
|
+
appear in bash mode — it isn't restricted there, it just has nothing to
|
|
39
|
+
suggest elsewhere.
|
|
40
|
+
|
|
26
41
|
## Features
|
|
27
42
|
|
|
28
43
|
### zsh-autosuggestions behavior
|
|
@@ -37,6 +52,20 @@ pi install npm:pi-autosuggestions
|
|
|
37
52
|
- **`Esc`** — dismiss the suggestion until your next edit
|
|
38
53
|
- Suggestion hides when the cursor leaves end-of-line, returns when you come back
|
|
39
54
|
|
|
55
|
+
### Command completion (bash mode)
|
|
56
|
+
|
|
57
|
+
The first word after `!` completes against **executables on your `$PATH`** —
|
|
58
|
+
like zsh's command position, no plugins needed:
|
|
59
|
+
|
|
60
|
+
| Input | Result |
|
|
61
|
+
|-------|--------|
|
|
62
|
+
| `!gi` | dropdown — `git`, `gh`, `gimp`, … (marked `command`) |
|
|
63
|
+
| `!whoa` | inline ghost `mi` → `whoami` |
|
|
64
|
+
|
|
65
|
+
File paths that also match are listed after the commands. Per-command
|
|
66
|
+
*subcommand* completion (`git st` → `status`) is zsh's `compdef` system and is
|
|
67
|
+
out of scope — use history or type it.
|
|
68
|
+
|
|
40
69
|
### Path completion (fish/zsh-completion flavored)
|
|
41
70
|
|
|
42
71
|
In bash mode (`!command`), a second strategy completes **filesystem paths**:
|
|
@@ -20,6 +20,9 @@ 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";
|
|
24
|
+
import type { AutocompleteItem } from "@earendil-works/pi-tui";
|
|
25
|
+
|
|
23
26
|
interface EditorInternals {
|
|
24
27
|
state: { lines: string[]; cursorLine: number; cursorCol: number };
|
|
25
28
|
autocompleteProvider?: AutocompleteProvider | null;
|
|
@@ -248,6 +251,52 @@ class BashInlineEditor extends CustomEditor {
|
|
|
248
251
|
* The ghost-vs-dropdown split (one match → ghost, many → dropdown) is
|
|
249
252
|
* decided in updateGhost(), which sees the final suggestion counts.
|
|
250
253
|
*/
|
|
254
|
+
/** Executable names on $PATH, cached for the session (zsh command completion). */
|
|
255
|
+
private pathCommandCache: string[] | null = null;
|
|
256
|
+
|
|
257
|
+
private getPathCommands(): string[] {
|
|
258
|
+
if (this.pathCommandCache) {
|
|
259
|
+
return this.pathCommandCache;
|
|
260
|
+
}
|
|
261
|
+
const names = new Set<string>();
|
|
262
|
+
for (const dir of (process.env.PATH ?? "").split(":")) {
|
|
263
|
+
if (!dir) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
let entries;
|
|
267
|
+
try {
|
|
268
|
+
entries = readdirSync(dir);
|
|
269
|
+
} catch {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
for (const name of entries) {
|
|
273
|
+
if (names.has(name)) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
// eslint-disable-next-line no-bitwise
|
|
278
|
+
if (statSync(`${dir}/${name}`).mode & 0o111) {
|
|
279
|
+
names.add(name);
|
|
280
|
+
}
|
|
281
|
+
} catch {
|
|
282
|
+
// dangling symlink or unreadable entry
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
this.pathCommandCache = [...names].sort();
|
|
287
|
+
return this.pathCommandCache;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** PATH commands starting with the typed command word. */
|
|
291
|
+
private matchingCommands(word: string): string[] {
|
|
292
|
+
if (!word) {
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
return this.getPathCommands()
|
|
296
|
+
.filter((name) => name.startsWith(word))
|
|
297
|
+
.slice(0, 100);
|
|
298
|
+
}
|
|
299
|
+
|
|
251
300
|
private createBashProvider(current: AutocompleteProvider): AutocompleteProvider {
|
|
252
301
|
const self = this;
|
|
253
302
|
return {
|
|
@@ -257,26 +306,54 @@ class BashInlineEditor extends CustomEditor {
|
|
|
257
306
|
}
|
|
258
307
|
const before = (lines[cursorLine] ?? "").slice(0, cursorCol);
|
|
259
308
|
let queryLines = lines;
|
|
309
|
+
let commandItems: AutocompleteItem[] = [];
|
|
310
|
+
let word = "";
|
|
260
311
|
if (self.commandPosition(before)) {
|
|
261
|
-
|
|
262
|
-
|
|
312
|
+
word = before.replace(/^[ \t]*!+/, "");
|
|
313
|
+
const commands = self.matchingCommands(word);
|
|
263
314
|
queryLines = [...lines];
|
|
264
|
-
|
|
315
|
+
if (commands.length > 0) {
|
|
316
|
+
// The typed word is a prefix of real commands: offer them
|
|
317
|
+
// first, plus any matching file paths as fallback.
|
|
318
|
+
commandItems = commands.map((name) => ({
|
|
319
|
+
value: name,
|
|
320
|
+
label: name,
|
|
321
|
+
description: "command",
|
|
322
|
+
}));
|
|
323
|
+
queryLines[cursorLine] = `! ${word}`;
|
|
324
|
+
} else {
|
|
325
|
+
// Neutralize the command word so the provider completes the
|
|
326
|
+
// (empty) argument position: every entry matches.
|
|
327
|
+
queryLines[cursorLine] = before.replace(/![^!\s]*$/, "! ");
|
|
328
|
+
}
|
|
265
329
|
}
|
|
266
|
-
|
|
330
|
+
const suggestions = await current.getSuggestions(queryLines, cursorLine, cursorCol, {
|
|
267
331
|
...options,
|
|
268
332
|
force: true,
|
|
269
333
|
});
|
|
334
|
+
if (commandItems.length === 0) {
|
|
335
|
+
return suggestions;
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
items: [...commandItems, ...(suggestions?.items ?? [])],
|
|
339
|
+
prefix: word,
|
|
340
|
+
};
|
|
270
341
|
},
|
|
271
342
|
|
|
272
343
|
applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
|
|
273
344
|
const before = (lines[cursorLine] ?? "").slice(0, cursorCol);
|
|
274
345
|
if (self.inBashMode() && self.commandPosition(before)) {
|
|
275
|
-
// Completing from the command position: insert the chosen path
|
|
276
|
-
// as the first argument ("!cd" + AppleStuff/ → "!cd AppleStuff/").
|
|
277
346
|
const value = item.value ?? "";
|
|
278
347
|
const line = lines[cursorLine] ?? "";
|
|
279
348
|
const newLines = [...lines];
|
|
349
|
+
if (item.description === "command") {
|
|
350
|
+
// Completing the command word itself ("!gi" + git → "!git").
|
|
351
|
+
const start = cursorCol - prefix.length;
|
|
352
|
+
newLines[cursorLine] = line.slice(0, start) + value + line.slice(cursorCol);
|
|
353
|
+
return { lines: newLines, cursorLine, cursorCol: start + value.length };
|
|
354
|
+
}
|
|
355
|
+
// Completing from the command position: insert the chosen path
|
|
356
|
+
// as the first argument ("!cd" + AppleStuff/ → "!cd AppleStuff/").
|
|
280
357
|
newLines[cursorLine] = `${line.slice(0, cursorCol)} ${value}${line.slice(cursorCol)}`;
|
|
281
358
|
return { lines: newLines, cursorLine, cursorCol: cursorCol + 1 + value.length };
|
|
282
359
|
}
|
|
@@ -336,7 +413,8 @@ class BashInlineEditor extends CustomEditor {
|
|
|
336
413
|
if (!value || !value.toLowerCase().startsWith(token.toLowerCase())) {
|
|
337
414
|
return null;
|
|
338
415
|
}
|
|
339
|
-
const
|
|
416
|
+
const isCommand = suggestions?.items[0]?.description === "command";
|
|
417
|
+
const separator = isCommand ? "" : (this.commandPosition(before) ? " " : "");
|
|
340
418
|
const suggestion = before.slice(0, before.length - token.length) + separator + value;
|
|
341
419
|
if (suggestion.length <= before.length) {
|
|
342
420
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-autosuggestions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
name: Minimal Call Test
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_dispatch:
|
|
5
|
-
|
|
6
|
-
permissions:
|
|
7
|
-
actions: write
|
|
8
|
-
contents: write
|
|
9
|
-
issues: write
|
|
10
|
-
pull-requests: write
|
|
11
|
-
id-token: write
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
release:
|
|
15
|
-
name: Release
|
|
16
|
-
uses: 0xPlayerOne/code-foundry/.github/workflows/release.yml@v0.39.4
|
|
17
|
-
with:
|
|
18
|
-
runner: ubuntu-slim
|
|
19
|
-
runtime-repository: 0xPlayerOne/code-foundry
|
|
20
|
-
runtime-ref: v0.39.4
|
|
21
|
-
secrets:
|
|
22
|
-
CODE_FOUNDRY_TOKEN: ${{ secrets.CODE_FOUNDRY_TOKEN }}
|
|
23
|
-
RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
|
24
|
-
STAGING_DEPLOY_KEY: ${{ secrets.STAGING_DEPLOY_KEY }}
|
|
25
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|