@pi-unipi/input-shortcuts 0.1.1 → 2.0.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/README.md +29 -66
- package/package.json +1 -1
- package/src/index.ts +2 -3
package/README.md
CHANGED
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
# @pi-unipi/input-shortcuts
|
|
2
2
|
|
|
3
|
-
Keyboard shortcuts for Pi's input box
|
|
3
|
+
Keyboard shortcuts for Pi's input box. Stash and restore text, undo/redo, clipboard operations, thinking level toggle, and tab insertion — all via a vim-style chord overlay triggered by `ALT+S`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Press `ALT+S`, a small overlay appears with key hints. Press a key, the action runs. The overlay closes automatically after 300ms or on `ESC`.
|
|
6
|
+
|
|
7
|
+
## Shortcuts
|
|
6
8
|
|
|
7
9
|
| Chord | Action | Description |
|
|
8
10
|
|-------|--------|-------------|
|
|
9
|
-
| `ALT+S → S` | Stash/Restore | Save input
|
|
10
|
-
| `ALT+S → U` | Undo | Pop from undo buffer
|
|
11
|
+
| `ALT+S → S` | Stash/Restore | Save input to stash register, or restore it |
|
|
12
|
+
| `ALT+S → U` | Undo | Pop from undo buffer |
|
|
11
13
|
| `ALT+S → R` | Redo | Push current text forward, restore previous |
|
|
12
14
|
| `ALT+S → Y` | Copy | Copy input to system clipboard |
|
|
13
15
|
| `ALT+S → D` | Cut | Copy to clipboard, then clear input |
|
|
14
16
|
| `ALT+S → T` | Toggle Thinking | Cycle: off → low → medium → high → xhigh → off |
|
|
15
17
|
| `ALT+S → A → [0-9]` | Append Register | Append from numbered register 0-9 |
|
|
16
18
|
| `ALT+S → A → S` | Append Stash | Append from stash register |
|
|
17
|
-
| `ALT+I` | Tab Insert | Insert literal tab character
|
|
19
|
+
| `ALT+I` | Tab Insert | Insert literal tab character |
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## Commands
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
| Command | Description |
|
|
24
|
+
|---------|-------------|
|
|
25
|
+
| `/unipi:stash-settings` | Open settings TUI for keybinding customization |
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
## Special Triggers
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
Input-shortcuts is a standalone package. It doesn't register with other packages or trigger coexists behavior.
|
|
30
|
+
|
|
31
|
+
Every action shows a brief success or error message in the status bar via `ctx.ui.setStatus()`.
|
|
32
|
+
|
|
33
|
+
## How It Works
|
|
26
34
|
|
|
27
35
|
### Registers
|
|
28
36
|
|
|
29
|
-
- **Stash register**: 1 register for quick save/restore
|
|
30
|
-
- **Numbered registers**: 10 registers (0-9) for
|
|
31
|
-
- **Persistence**:
|
|
37
|
+
- **Stash register**: 1 register for quick save/restore
|
|
38
|
+
- **Numbered registers**: 10 registers (0-9) for stored text snippets
|
|
39
|
+
- **Persistence**: Saved to `.unipi/config/input-shortcuts.json` (per-project, atomic writes)
|
|
32
40
|
|
|
33
41
|
### Undo/Redo
|
|
34
42
|
|
|
35
43
|
- In-memory ring buffer, max 50 snapshots per session
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- Redo buffer cleared on new snapshot
|
|
44
|
+
- 500ms debounce on snapshot creation (prevents noise from rapid typing)
|
|
45
|
+
- 1s throttle on undo (prevents rapid-fire undo)
|
|
46
|
+
- Redo buffer cleared on new snapshot
|
|
39
47
|
- Not persisted across sessions
|
|
40
48
|
|
|
41
49
|
### Clipboard
|
|
@@ -53,15 +61,11 @@ Detected tool is cached after first use. Returns graceful error if no clipboard
|
|
|
53
61
|
|
|
54
62
|
### Thinking Toggle
|
|
55
63
|
|
|
56
|
-
Cycles through Pi's thinking levels
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
off → low → medium → high → xhigh → off
|
|
60
|
-
```
|
|
64
|
+
Cycles through Pi's thinking levels: off → low → medium → high → xhigh → off.
|
|
61
65
|
|
|
62
|
-
##
|
|
66
|
+
## Configurables
|
|
63
67
|
|
|
64
|
-
Run `/unipi:stash-settings` to
|
|
68
|
+
Run `/unipi:stash-settings` to customize keybindings:
|
|
65
69
|
|
|
66
70
|
- **Chord trigger key** — default `alt+s`
|
|
67
71
|
- **Tab insert key** — default `alt+i`
|
|
@@ -70,47 +74,6 @@ Both cycle through available ALT key combinations, excluding known conflicts (`a
|
|
|
70
74
|
|
|
71
75
|
Config persisted to `~/.unipi/config/input-shortcuts-config.json` (global).
|
|
72
76
|
|
|
73
|
-
##
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
input-shortcuts/
|
|
77
|
-
├── index.ts # Re-exports
|
|
78
|
-
├── src/
|
|
79
|
-
│ ├── index.ts # Extension entry — registers shortcuts + command
|
|
80
|
-
│ ├── types.ts # Shared types and constants
|
|
81
|
-
│ ├── registers.ts # RegisterStore — JSON persistence with atomic writes
|
|
82
|
-
│ ├── undo-redo.ts # UndoRedoBuffer — ring buffer with debounce/throttle
|
|
83
|
-
│ ├── clipboard.ts # Cross-platform clipboard detection + read/write
|
|
84
|
-
│ ├── status.ts # Status bar feedback with auto-clear
|
|
85
|
-
│ ├── chord-overlay.ts # ChordOverlay — TUI overlay component (root + register sub-chord)
|
|
86
|
-
│ └── settings-overlay.ts # SettingsOverlay — SettingsList-based config UI
|
|
87
|
-
├── tests/
|
|
88
|
-
│ ├── clipboard.test.ts
|
|
89
|
-
│ ├── registers.test.ts
|
|
90
|
-
│ └── undo-redo.test.ts
|
|
91
|
-
└── package.json
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Key Patterns
|
|
95
|
-
|
|
96
|
-
- **TUI overlay**: Uses `ctx.ui.custom()` from pi-coding-agent (proven pattern from btw, compactor, footer)
|
|
97
|
-
- **SettingsList**: Uses `SettingsList` from pi-tui for the settings overlay
|
|
98
|
-
- **Atomic writes**: All file persistence uses write-to-tmp-then-rename pattern
|
|
99
|
-
- **Status feedback**: Every action shows a brief success/error message in the status bar via `ctx.ui.setStatus()`
|
|
100
|
-
|
|
101
|
-
## Testing
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
npm test --workspace=packages/input-shortcuts
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
19 tests across 3 suites:
|
|
108
|
-
- **clipboard** (4 tests): detection fallback, copy/paste roundtrip, graceful errors
|
|
109
|
-
- **RegisterStore** (8 tests): load/create, read/write stash/registers, corruption handling, atomic writes
|
|
110
|
-
- **UndoRedoBuffer** (7 tests): undo/redo roundtrip, debounce, throttle, max size eviction, clear
|
|
111
|
-
|
|
112
|
-
## Dependencies
|
|
113
|
-
|
|
114
|
-
- `@pi-unipi/core` — shared constants and utilities
|
|
115
|
-
- `@mariozechner/pi-coding-agent` — ExtensionAPI, ExtensionContext
|
|
116
|
-
- `@mariozechner/pi-tui` — Key, Container, Text, SettingsList, Focusable
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -367,8 +367,7 @@ export default function inputShortcutsExtension(pi: ExtensionAPI): void {
|
|
|
367
367
|
|
|
368
368
|
// ─── Info-screen registration ────────────────────────────────────────────
|
|
369
369
|
|
|
370
|
-
const
|
|
371
|
-
const registry = globalObj.__unipi_info_registry;
|
|
370
|
+
const registry = globalThis.__unipi_info_registry;
|
|
372
371
|
if (registry) {
|
|
373
372
|
registry.registerGroup({
|
|
374
373
|
id: "input-shortcuts",
|
|
@@ -402,7 +401,7 @@ export default function inputShortcutsExtension(pi: ExtensionAPI): void {
|
|
|
402
401
|
|
|
403
402
|
// ─── Module ready event ──────────────────────────────────────────────────
|
|
404
403
|
|
|
405
|
-
emitEvent(pi
|
|
404
|
+
emitEvent(pi, UNIPI_EVENTS.MODULE_READY, {
|
|
406
405
|
name: MODULES.INPUT_SHORTCUTS,
|
|
407
406
|
version: "0.1.0",
|
|
408
407
|
commands: [`unipi:${INPUT_SHORTCUTS_COMMANDS.STASH_SETTINGS}`],
|