@kliebhan/pi-prompt-autocomplete 0.1.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/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +103 -0
- package/core.ts +1038 -0
- package/index.ts +1412 -0
- package/media/prompt-autocomplete-demo.mp4 +0 -0
- package/package.json +52 -0
- package/system-prompt.template.md +18 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented here. This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-07-10
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Inline ghost-text suggestions in Pi's interactive prompt editor.
|
|
10
|
+
- Full-suggestion and word/chunk acceptance.
|
|
11
|
+
- Multiple ranked alternatives with forward and backward cycling.
|
|
12
|
+
- Active-model and dedicated-model selection.
|
|
13
|
+
- Manual one-shot completion and configurable streaming behavior.
|
|
14
|
+
- Bounded in-memory caching, request coalescing, cancellation, and stale-result protection.
|
|
15
|
+
- Unicode, CJK, emoji, narrow-terminal, multiline, and IME-aware rendering.
|
|
16
|
+
- Debug and lifecycle commands for enabling, disabling, toggling, and inspecting state.
|
|
17
|
+
|
|
18
|
+
### Security and privacy
|
|
19
|
+
|
|
20
|
+
- Autocomplete is opt-in and disabled by default.
|
|
21
|
+
- Automatic empty-draft requests are disabled by default.
|
|
22
|
+
- Provider/context transfer and possible costs are documented.
|
|
23
|
+
- Other custom editors are never overwritten or removed.
|
|
24
|
+
|
|
25
|
+
### Validation
|
|
26
|
+
|
|
27
|
+
- Strict TypeScript checks against Pi 0.80.6.
|
|
28
|
+
- Executable editor, request, lifecycle, packaging, clean-install, and Pi-discovery tests.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @kliebhan/pi-prompt-autocomplete
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
[Watch the demo](https://github.com/KLIEBHAN/pi-extensions/releases/download/pi-prompt-autocomplete-v0.1.0/prompt-autocomplete-demo.mp4)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Review the source before installing: Pi extensions execute with your user permissions.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pi install npm:@kliebhan/pi-prompt-autocomplete
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Try the package for one run without installing it permanently:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pi -e npm:@kliebhan/pi-prompt-autocomplete --prompt-autocomplete
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Prompt Autocomplete is **disabled by default**. Enable it explicitly for a process:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pi --prompt-autocomplete
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or enable it for the current interactive session:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
/prompt-autocomplete on
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
| Action | Key or command |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| Accept the full suggestion | `Tab` |
|
|
38
|
+
| Accept the next word or chunk | `Ctrl+Space` |
|
|
39
|
+
| Next alternative / manual one-shot | `Ctrl+.` |
|
|
40
|
+
| Previous alternative | `Ctrl+,` |
|
|
41
|
+
| Dismiss the suggestion for this draft | `Escape` |
|
|
42
|
+
| Enable, disable, or inspect | `/prompt-autocomplete on\|off\|toggle\|status` |
|
|
43
|
+
|
|
44
|
+
Legacy fallbacks are available for terminals that forward them: `Ctrl+Tab`, `Alt+[`, and `Alt+]`.
|
|
45
|
+
|
|
46
|
+
Built-in slash-command and file/path completion keeps precedence over ghost suggestions.
|
|
47
|
+
|
|
48
|
+
### Configuration
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pi \
|
|
52
|
+
--prompt-autocomplete \
|
|
53
|
+
--prompt-autocomplete-model openai/gpt-5.4-mini \
|
|
54
|
+
--prompt-autocomplete-min-chars 1 \
|
|
55
|
+
--prompt-autocomplete-debounce-ms 250 \
|
|
56
|
+
--prompt-autocomplete-max-chars 240 \
|
|
57
|
+
--prompt-autocomplete-max-alternatives 3
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- The active Pi model is used unless `--prompt-autocomplete-model provider/model` selects a dedicated authenticated model.
|
|
61
|
+
- Automatic suggestions require at least one non-whitespace draft character by default. Set `--prompt-autocomplete-min-chars 0` to opt into empty-draft suggestions.
|
|
62
|
+
- Suggestions pause while the main agent is streaming by default. Use `--prompt-autocomplete-while-streaming` or `/prompt-autocomplete while-streaming on` to change that behavior.
|
|
63
|
+
- `Ctrl+.` with no active suggestion is an explicit one-shot request and may bypass the streaming, cooldown, and minimum-length gates. Model, authentication, slash-command, and path safety checks still apply.
|
|
64
|
+
- Use `--prompt-autocomplete-debug` or `/prompt-autocomplete debug-on` for troubleshooting.
|
|
65
|
+
|
|
66
|
+
## Privacy, providers, and cost
|
|
67
|
+
|
|
68
|
+
Enabling Prompt Autocomplete permits additional model requests. A request can contain:
|
|
69
|
+
|
|
70
|
+
- the current prompt draft or its bounded tail,
|
|
71
|
+
- the latest user and assistant messages,
|
|
72
|
+
- a bounded recent-conversation summary.
|
|
73
|
+
|
|
74
|
+
The active conversation leaf identity is used only in the local in-memory cache key and is not sent to the provider.
|
|
75
|
+
|
|
76
|
+
By default, requests use the active model. A dedicated `--prompt-autocomplete-model` may send this context to a different provider. Requests can incur token charges and consume provider rate limits.
|
|
77
|
+
|
|
78
|
+
Successful results are cached only in memory for up to 60 seconds. The cache is bounded and is cleared on session reset or when the extension is disabled. Provider failures are not cached.
|
|
79
|
+
|
|
80
|
+
The extension makes no autocomplete request while disabled. Automatic empty-draft requests are also disabled by default.
|
|
81
|
+
|
|
82
|
+
## Compatibility and editor ownership
|
|
83
|
+
|
|
84
|
+
- Supported baseline: Pi `0.80.6`, Node.js `22.19.0` or newer.
|
|
85
|
+
- Interactive ghost text requires Pi's TUI mode. RPC, JSON, and print modes do not install a custom editor.
|
|
86
|
+
- Prompt Autocomplete requires exclusive ownership of Pi's custom-editor slot. It refuses to replace another custom editor and never removes a later replacement editor.
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
From the repository root:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npm ci
|
|
94
|
+
npm run test:prompt-autocomplete
|
|
95
|
+
npm run typecheck:prompt-autocomplete
|
|
96
|
+
npm run test:package
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The package smoke test packs this directory, verifies the exact tarball contents, installs it into a clean temporary consumer, and discovers it with the supported Pi version.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[MIT](LICENSE)
|