@earendil-works/pi-coding-agent 0.87.0 → 0.87.1

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +25 -711
  3. package/dist/bundle/chunks/{anthropic-messages-MYU5ZMRF.js → anthropic-messages-J5WXPPPC.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-GV2E3GBU.js → chunk-65HAU2C5.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-4DKZACXI.js → chunk-OJP47DM6.js} +13 -13
  6. package/dist/bundle/chunks/github-copilot.js +1 -1
  7. package/dist/bundle/chunks/{openai-completions-XHML6MTL.js → openai-completions-OBX42CLD.js} +1 -1
  8. package/dist/bundle/chunks/{virtual-modules-BNWPZYDH.js → virtual-modules-VHMJYYWQ.js} +1 -1
  9. package/dist/bundle/cli-runtime.js +1 -1
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/rpc-entry.js +1 -1
  12. package/dist/cli/args.d.ts.map +1 -1
  13. package/dist/cli/args.js +14 -4
  14. package/dist/cli/args.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +9 -9
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/model-resolver.d.ts.map +1 -1
  19. package/dist/core/model-resolver.js +1 -1
  20. package/dist/core/model-resolver.js.map +1 -1
  21. package/docs/cli-integration.md +106 -0
  22. package/docs/cli.md +268 -0
  23. package/docs/compaction.md +22 -22
  24. package/docs/configuration.md +45 -0
  25. package/docs/containerization.md +109 -82
  26. package/docs/custom-provider.md +132 -784
  27. package/docs/docs.json +139 -99
  28. package/docs/environment-variables.md +3 -5
  29. package/docs/extensions.md +134 -3020
  30. package/docs/how-pi-works.md +49 -0
  31. package/docs/images/interactive-mode.png +0 -0
  32. package/docs/index.md +24 -69
  33. package/docs/json.md +193 -65
  34. package/docs/keybindings.md +57 -102
  35. package/docs/llama-cpp.md +3 -3
  36. package/docs/message-types.md +261 -0
  37. package/docs/models.md +55 -565
  38. package/docs/packages.md +66 -167
  39. package/docs/prompt-templates.md +31 -68
  40. package/docs/providers.md +102 -240
  41. package/docs/quickstart.md +61 -106
  42. package/docs/rpc-commands.md +854 -0
  43. package/docs/rpc-extension-ui.md +200 -0
  44. package/docs/rpc.md +129 -1556
  45. package/docs/sdk.md +76 -1171
  46. package/docs/security.md +70 -32
  47. package/docs/session-format.md +10 -214
  48. package/docs/sessions.md +35 -141
  49. package/docs/settings.md +109 -387
  50. package/docs/shell-aliases.md +85 -5
  51. package/docs/skills.md +51 -190
  52. package/docs/slash-commands.md +60 -0
  53. package/docs/terminal-setup.md +105 -78
  54. package/docs/termux.md +74 -83
  55. package/docs/themes.md +68 -280
  56. package/docs/tmux.md +31 -39
  57. package/docs/tui.md +69 -923
  58. package/docs/usage.md +54 -272
  59. package/docs/windows.md +43 -17
  60. package/examples/README.md +13 -2
  61. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  62. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  63. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  64. package/examples/extensions/gondolin/package-lock.json +2 -2
  65. package/examples/extensions/gondolin/package.json +1 -1
  66. package/examples/extensions/sandbox/package-lock.json +2 -2
  67. package/examples/extensions/sandbox/package.json +1 -1
  68. package/examples/extensions/with-deps/package-lock.json +2 -2
  69. package/examples/extensions/with-deps/package.json +1 -1
  70. package/examples/rpc-client.ts +35 -0
  71. package/examples/rpc-extension-ui.ts +25 -5
  72. package/examples/sdk/README.md +1 -1
  73. package/npm-shrinkwrap.json +20 -20
  74. package/package.json +8 -8
  75. package/docs/development.md +0 -90
@@ -1,73 +1,74 @@
1
- # Terminal Setup
1
+ # Configure your terminal
2
2
 
3
- Pi uses the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) for reliable modifier key detection. Most modern terminals support this protocol, but some require configuration.
3
+ Most modern terminals work with Pi without additional setup. Use this page when modified keys, scrolling, links, images, colors, or input-method editor (IME) positioning do not behave as expected.
4
4
 
5
- ## Capability Overrides
5
+ Pi uses extended-key protocols so terminals can distinguish combinations such as `Shift+Enter` and `Alt+Enter` from plain `Enter`. Terminal proxies, multiplexers, and built-in IDE terminals can change or discard that information.
6
6
 
7
- Pi auto-detects OSC 8 hyperlinks, inline image protocols, and truecolor. If detection fails behind a terminal proxy or multiplexer, use these advanced overrides:
7
+ ## Troubleshooting
8
8
 
9
- | Capability | Environment variable | JSON setting |
10
- |------------|----------------------|--------------|
11
- | OSC 8 hyperlinks | `PI_HYPERLINKS=1\|0\|auto` | `terminal.hyperlinks: true\|false\|"auto"` |
12
- | Inline images | `PI_IMAGE_PROTOCOL=kitty\|iterm2\|none\|auto` | `terminal.images: "kitty"\|"iterm2"\|false\|"auto"` |
13
- | Truecolor | `PI_TRUE_COLOR=1\|0\|auto` | `terminal.trueColor: true\|false\|"auto"` |
9
+ | Symptom | Start here |
10
+ |---|---|
11
+ | `Shift+Enter` submits instead of inserting a line | Your terminal's section below; for tmux, see [Run Pi in tmux](tmux.md) |
12
+ | `Alt+Enter` does not queue a follow-up | [WezTerm](#wezterm), [Alacritty](#alacritty), or [Windows Terminal](#windows-terminal) |
13
+ | Fullscreen scrolling is unusually slow | [iTerm2](#iterm2) |
14
+ | Links work but show no hover preview | [Ghostty](#ghostty) |
15
+ | Inline images or colors are not detected | [Override detected capabilities](#override-detected-capabilities) |
16
+ | An IME candidate window appears in the wrong place | [WezTerm](#wezterm) or [IntelliJ IDEA](#intellij-idea-integrated-terminal) |
17
+ | Modified keys fail only inside tmux | [Run Pi in tmux](tmux.md) |
14
18
 
15
- Settings take precedence over environment variables; unset or `auto` preserves detection. Only force capabilities supported by the complete terminal path, since unsupported escape sequences can corrupt rendering.
19
+ Use `/hotkeys` to inspect Pi's active shortcuts. See [Keybindings](keybindings.md) to change them.
16
20
 
17
21
  ## Kitty
18
22
 
19
- Works out of the box.
23
+ Kitty supports the required keyboard protocol without additional configuration.
20
24
 
21
25
  ## iTerm2
22
26
 
23
- ### Regular TUI mode
24
-
25
- Works out of the box.
27
+ Regular terminal mode works without additional configuration.
26
28
 
27
- ### Fullscreen TUI mode
29
+ ### Fix slow fullscreen scrolling
28
30
 
29
- Pi owns the viewport, so iTerm2 sends mouse-wheel reports instead of scrolling its native scrollback. With iTerm2's default fast-trackpad behavior, those reports can lose most of an accelerated wheel delta, making fullscreen scrolling much slower than regular scrolling.
31
+ In fullscreen mode, Pi owns the viewport, so iTerm2 sends mouse-wheel reports instead of scrolling native terminal history. Fast trackpad gestures can then move only about one line at a time.
30
32
 
31
- If fast mouse-wheel gestures move only about one line at a time in fullscreen mode:
33
+ To change this behavior:
32
34
 
33
- 1. Open **iTerm2 → Settings → Advanced**.
34
- 2. Search for **Trackpad scrolls fast?** and set it to **No**.
35
+ 1. Open **iTerm2 > Settings > Advanced**.
36
+ 2. Search for **Trackpad scrolls fast?**.
37
+ 3. Set it to **No**.
35
38
 
36
- This is an iTerm2-wide workaround and may also change native trackpad scrolling. The underlying behavior is tracked in [iTerm2 issue 9619](https://gitlab.com/gnachman/iterm2/-/work_items/9619).
39
+ This is an iTerm2-wide setting and can also change native trackpad scrolling. The underlying behavior is tracked in [iTerm2 issue 9619](https://gitlab.com/gnachman/iterm2/-/work_items/9619).
37
40
 
38
41
  ## Apple Terminal
39
42
 
40
- Pi enables enhanced key reporting when available. If Terminal.app still sends plain Return for `Shift+Enter`, pi uses a local macOS modifier fallback to treat that Return as `Shift+Enter`.
43
+ Pi enables enhanced key reporting when available. If Terminal.app still sends plain Return for `Shift+Enter`, Pi uses a local macOS modifier fallback and treats it as `Shift+Enter`.
41
44
 
42
- This fallback only works when pi runs on the same Mac as Terminal.app. It cannot detect the local keyboard over remote SSH.
45
+ The fallback works only when Pi runs on the same Mac as Terminal.app. It cannot inspect the local modifier state when Pi runs on another machine over SSH.
43
46
 
44
47
  ## Ghostty
45
48
 
46
- Add to your Ghostty config (`~/Library/Application Support/com.mitchellh.ghostty/config` on macOS, `~/.config/ghostty/config` on Linux):
49
+ Add this mapping to Ghostty's configuration if `Alt+Backspace` does not work:
47
50
 
48
- ```
51
+ ```text
49
52
  keybind = alt+backspace=text:\x1b\x7f
50
53
  ```
51
54
 
52
- Older Claude Code versions may have added this Ghostty mapping:
55
+ The configuration file is `~/Library/Application Support/com.mitchellh.ghostty/config` on macOS and `~/.config/ghostty/config` on Linux.
53
56
 
54
- ```
57
+ Older Claude Code configurations may contain:
58
+
59
+ ```text
55
60
  keybind = shift+enter=text:\n
56
61
  ```
57
62
 
58
- That mapping sends a raw linefeed byte. Inside pi, that is indistinguishable from `Ctrl+J`, so tmux and pi no longer see a real `shift+enter` key event.
59
-
60
- If Claude Code 2.x or newer is the only reason you added that mapping, you can remove it, unless you want to use Claude Code in tmux, where it still requires that Ghostty mapping.
61
-
62
- Pi binds `Ctrl+J` as a default newline alias, so `Shift+Enter` keeps working in tmux via that remap without extra pi configuration.
63
+ This sends a raw linefeed, which Pi cannot distinguish from `Ctrl+J`. Remove the mapping if an older Claude Code installation is the only reason you added it. Pi already binds `Ctrl+J` as a newline alternative, so the mapping may appear to work while still preventing Pi and tmux from receiving a real `Shift+Enter` event.
63
64
 
64
- ### Fullscreen TUI mode
65
+ ### Open links in fullscreen mode
65
66
 
66
- In fullscreen mode, links remain clickable, but Ghostty does not show its hover underline or lower-left URL preview while pi captures mouse input. Hold `Shift+Command` on macOS or `Shift+Ctrl` on Linux to use Ghostty's native link handling.
67
+ Links remain clickable in fullscreen mode, but Ghostty does not show its normal hover underline or URL preview while Pi captures mouse input. Hold `Shift+Command` on macOS or `Shift+Ctrl` on Linux to use Ghostty's native link handling.
67
68
 
68
69
  ## WezTerm
69
70
 
70
- WezTerm usually works out of the box for `Shift+Enter` via xterm modifyOtherKeys. To use the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
71
+ WezTerm normally reports `Shift+Enter` through xterm extended keys. To enable the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
71
72
 
72
73
  ```lua
73
74
  local wezterm = require 'wezterm'
@@ -76,7 +77,19 @@ config.enable_kitty_keyboard = true
76
77
  return config
77
78
  ```
78
79
 
79
- On macOS, WezTerm binds `Option+Enter` to fullscreen by default. To use `Option+Enter` for pi follow-up queueing, add this key override:
80
+ ### Forward Alt+Enter on macOS
81
+
82
+ WezTerm binds `Option+Enter` to fullscreen by default on macOS. To use it for Pi's follow-up queue, add this entry to your `config.keys` table:
83
+
84
+ ```lua
85
+ {
86
+ key = 'Enter',
87
+ mods = 'ALT',
88
+ action = wezterm.action.SendString('\x1b[13;3u'),
89
+ }
90
+ ```
91
+
92
+ A complete minimal configuration is:
80
93
 
81
94
  ```lua
82
95
  local wezterm = require 'wezterm'
@@ -91,13 +104,20 @@ config.keys = {
91
104
  return config
92
105
  ```
93
106
 
94
- If you already have a `config.keys` table, add the entry to it.
107
+ ### Position an IME candidate window in WSL
95
108
 
96
- On WSL, WezTerm may require a visible hardware cursor for IME candidate window positioning. If CJK IME candidates do not follow the text cursor, set `PI_HARDWARE_CURSOR=1` before running pi or set `showHardwareCursor` to `true` in settings.
109
+ If CJK IME candidates do not follow Pi's text cursor in WSL, show the hardware cursor:
110
+
111
+ ```bash
112
+ export PI_HARDWARE_CURSOR=1
113
+ pi
114
+ ```
115
+
116
+ You can instead set `showHardwareCursor` to `true` in Pi settings.
97
117
 
98
118
  ## Alacritty
99
119
 
100
- Alacritty usually works out of the box for `Shift+Enter`. On macOS, `Option+Enter` may arrive as plain `Enter`. To use `Option+Enter` for pi follow-up queueing, add to `~/.config/alacritty/alacritty.toml`:
120
+ Alacritty normally reports `Shift+Enter`. On macOS, `Option+Enter` can arrive as plain `Enter`. Add this to `~/.config/alacritty/alacritty.toml` to forward it to Pi:
101
121
 
102
122
  ```toml
103
123
  [[keyboard.bindings]]
@@ -106,20 +126,13 @@ mods = "Alt"
106
126
  chars = "\u001b[13;3u"
107
127
  ```
108
128
 
109
- Restart Alacritty after changing the config.
110
-
111
- ## VS Code (Integrated Terminal)
129
+ Restart Alacritty after changing the file.
112
130
 
113
- VS Code 1.109.5 and newer enable Kitty keyboard protocol in the integrated terminal by default, so `Shift+Enter` should work out of the box.
131
+ ## VS Code integrated terminal
114
132
 
115
- VS Code versions older than 1.109.5 need an explicit terminal keybinding for `Shift+Enter`.
133
+ VS Code 1.109.5 and newer enable the Kitty keyboard protocol in the integrated terminal by default.
116
134
 
117
- `keybindings.json` locations:
118
- - macOS: `~/Library/Application Support/Code/User/keybindings.json`
119
- - Linux: `~/.config/Code/User/keybindings.json`
120
- - Windows: `%APPDATA%\\Code\\User\\keybindings.json`
121
-
122
- Add to `keybindings.json`:
135
+ For an older version, add a `Shift+Enter` terminal binding to `keybindings.json`:
123
136
 
124
137
  ```json
125
138
  {
@@ -130,9 +143,15 @@ Add to `keybindings.json`:
130
143
  }
131
144
  ```
132
145
 
133
- ## Zed (Integrated Terminal)
146
+ The user `keybindings.json` file is normally located at:
147
+
148
+ - macOS: `~/Library/Application Support/Code/User/keybindings.json`
149
+ - Linux: `~/.config/Code/User/keybindings.json`
150
+ - Windows: `%APPDATA%\\Code\\User\\keybindings.json`
134
151
 
135
- Add these key bindings to your Zed `keymap.json`:
152
+ ## Zed integrated terminal
153
+
154
+ Add these bindings to Zed's `keymap.json`:
136
155
 
137
156
  ```json
138
157
  {
@@ -147,46 +166,54 @@ Add these key bindings to your Zed `keymap.json`:
147
166
 
148
167
  ## Windows Terminal
149
168
 
150
- Pi uses Windows-style keybindings when running natively on Windows or in WSL:
169
+ Windows Terminal uses Pi's Windows and WSL shortcut defaults. See [Keybindings](keybindings.md) for the complete list.
151
170
 
152
- - `Alt+V` pastes an image or clipboard text.
153
- - `Ctrl+F` searches the transcript in fullscreen mode, and `Ctrl+Up`/`Ctrl+Down` jump between marked messages.
154
- - `Alt+P` cycles to the previous model.
155
- - `Ctrl+Z` undoes editing on native Windows; WSL uses `Alt+Z` so `Ctrl+Z` can suspend pi.
156
- - `Ctrl+Q` queues a follow-up message and `Alt+Q` restores queued messages.
171
+ ### Forward Shift+Enter
157
172
 
158
- Add to `settings.json` (Ctrl+Shift+, or Settings → Open JSON file) to forward `Shift+Enter` for inserting a new line:
173
+ Open Windows Terminal's `settings.json` with `Ctrl+Shift+,` or **Settings > Open JSON file**. Add this object to its `actions` array:
159
174
 
160
175
  ```json
161
176
  {
162
- "actions": [
163
- {
164
- "command": { "action": "sendInput", "input": "\u001b[13;2u" },
165
- "keys": "shift+enter"
166
- }
167
- ]
177
+ "command": { "action": "sendInput", "input": "\u001b[13;2u" },
178
+ "keys": "shift+enter"
168
179
  }
169
180
  ```
170
181
 
171
- Windows Terminal binds `Alt+Enter` to fullscreen by default. To use it instead of pi's `Ctrl+Q` default for follow-up queueing, configure Windows Terminal to send the key and bind `app.message.followUp` to `alt+enter` in pi.
182
+ Fully close and reopen Windows Terminal, then verify that `Shift+Enter` inserts a new line in Pi.
183
+
184
+ ### Use Alt+Enter for follow-ups
172
185
 
173
- If you already have an `actions` array, add the object to it. Fully close and reopen Windows Terminal after changing its settings.
186
+ Windows Terminal binds `Alt+Enter` to fullscreen by default. Pi therefore uses `Ctrl+Q` for follow-ups on Windows and WSL.
174
187
 
175
- ## xfce4-terminal, terminator
188
+ To use `Alt+Enter` instead, configure Windows Terminal to forward the key and bind `app.message.followUp` to `alt+enter` in Pi's `keybindings.json`. See [Keybindings](keybindings.md#assign-keybindings).
176
189
 
177
- These terminals have limited escape sequence support. Modified Enter keys like `Ctrl+Enter` and `Shift+Enter` cannot be distinguished from plain `Enter`, preventing custom keybindings such as `submit: ["ctrl+enter"]` from working.
190
+ ## xfce4-terminal and Terminator
178
191
 
179
- For the best experience, use a terminal that supports the Kitty keyboard protocol:
180
- - [Kitty](https://sw.kovidgoyal.net/kitty/)
181
- - [Ghostty](https://ghostty.org/)
182
- - [WezTerm](https://wezfurlong.org/wezterm/)
183
- - [iTerm2](https://iterm2.com/)
184
- - [Alacritty](https://github.com/alacritty/alacritty) (requires compilation with Kitty protocol support)
192
+ These terminals cannot reliably distinguish modified Enter keys from plain `Enter`. Custom bindings such as `Ctrl+Enter` or `Shift+Enter` therefore may not work.
185
193
 
186
- ## IntelliJ IDEA (Integrated Terminal)
194
+ Use a terminal with modern extended-key support when you need those shortcuts, such as Kitty, Ghostty, WezTerm, iTerm2, Windows Terminal, or a compatible Alacritty build.
187
195
 
188
- The built-in terminal has limited escape sequence support. Shift+Enter cannot be distinguished from Enter in IntelliJ's terminal.
196
+ ## IntelliJ IDEA integrated terminal
197
+
198
+ IntelliJ IDEA's built-in terminal cannot reliably distinguish `Shift+Enter` from plain `Enter`. Use `Ctrl+J` for a newline or run Pi in a terminal with modern extended-key support.
199
+
200
+ If an IME candidate window does not follow the text cursor, show the hardware cursor:
201
+
202
+ ```bash
203
+ export PI_HARDWARE_CURSOR=1
204
+ pi
205
+ ```
206
+
207
+ ## Override detected capabilities
208
+
209
+ Pi automatically detects OSC 8 hyperlinks, inline image protocols, and truecolor support. A terminal proxy or multiplexer can make that detection inaccurate.
210
+
211
+ | Capability | Environment variable | Setting |
212
+ |---|---|---|
213
+ | Hyperlinks | `PI_HYPERLINKS=1\|0\|auto` | `terminal.hyperlinks: true\|false\|"auto"` |
214
+ | Inline images | `PI_IMAGE_PROTOCOL=kitty\|iterm2\|none\|auto` | `terminal.images: "kitty"\|"iterm2"\|false\|"auto"` |
215
+ | Truecolor | `PI_TRUE_COLOR=1\|0\|auto` | `terminal.trueColor: true\|false\|"auto"` |
189
216
 
190
- If you want the hardware cursor visible, set `PI_HARDWARE_CURSOR=1` before running pi (disabled by default for compatibility).
217
+ Settings take precedence over environment variables. An unset value or `auto` preserves automatic detection.
191
218
 
192
- Consider using a dedicated terminal emulator for the best experience.
219
+ Only force a capability supported by the complete terminal path. Unsupported escape sequences can corrupt rendering. See [Environment Variables](environment-variables.md#pi-process-configuration) and [Settings](settings.md) for the canonical value definitions.
package/docs/termux.md CHANGED
@@ -1,126 +1,117 @@
1
- # Termux (Android) Setup
1
+ # Run Pi on Android with Termux
2
2
 
3
- Pi runs on Android via [Termux](https://termux.dev/), a terminal emulator and Linux environment for Android.
3
+ Pi runs on Android through [Termux](https://termux.dev/), a terminal emulator and Linux environment. Text input, file tools, and shell commands are supported. Pi can copy and paste text through the Android clipboard with Termux:API. Clipboard image paste is not supported.
4
4
 
5
- ## Prerequisites
5
+ ## Before you begin
6
6
 
7
- 1. Install [Termux](https://github.com/termux/termux-app#installation) from GitHub or F-Droid (not Google Play, that version is deprecated)
8
- 2. Install [Termux:API](https://github.com/termux/termux-api#installation) from GitHub or F-Droid for clipboard and other device integrations
7
+ Install Termux from [GitHub or F-Droid](https://github.com/termux/termux-app#installation). Do not use the deprecated Google Play build.
9
8
 
10
- ## Installation
9
+ [Termux:API](https://github.com/termux/termux-api#installation) is optional. Install it only when you want Pi to copy or paste Android clipboard text, or when shell commands need Android device APIs.
11
10
 
12
- ```bash
13
- # Update packages
14
- pkg update && pkg upgrade
11
+ ## Install Pi
15
12
 
16
- # Install dependencies
17
- pkg install nodejs termux-api git
13
+ 1. Update Termux packages:
18
14
 
19
- # Install pi
20
- npm install -g --ignore-scripts @earendil-works/pi-coding-agent
15
+ ```bash
16
+ pkg update && pkg upgrade
17
+ ```
21
18
 
22
- # Create config directory
23
- mkdir -p ~/.pi/agent
19
+ 2. Install Node.js and Git:
24
20
 
25
- # Run pi
26
- pi
27
- ```
21
+ ```bash
22
+ pkg install nodejs git
23
+ ```
28
24
 
29
- ## Clipboard Support
25
+ 3. Install Pi:
30
26
 
31
- Clipboard operations use `termux-clipboard-set` and `termux-clipboard-get` when running in Termux. The Termux:API app must be installed for these to work.
27
+ ```bash
28
+ npm install -g --ignore-scripts @earendil-works/pi-coding-agent
29
+ ```
32
30
 
33
- Image clipboard is not supported on Termux (the `ctrl+v` image paste feature will not work).
31
+ 4. Verify the installation:
34
32
 
35
- ## Example AGENTS.md for Termux
33
+ ```bash
34
+ pi --version
35
+ ```
36
36
 
37
- Create `~/.pi/agent/AGENTS.md` to help the agent understand the Termux environment:
37
+ 5. Open the folder you want to work in and start Pi:
38
38
 
39
- ````markdown
40
- # Agent Environment: Termux on Android
39
+ ```bash
40
+ cd /path/to/working-folder
41
+ pi
42
+ ```
41
43
 
42
- ## Location
43
- - **OS**: Android (Termux terminal emulator)
44
- - **Home**: `/data/data/com.termux/files/home`
45
- - **Prefix**: `/data/data/com.termux/files/usr`
46
- - **Shared storage**: `/storage/emulated/0` (Downloads, Documents, etc.)
44
+ Continue with the main [Quickstart](quickstart.md#3-choose-a-model) to connect a model and run your first task.
47
45
 
48
- ## Opening URLs
49
- ```bash
50
- termux-open-url "https://example.com"
51
- ```
46
+ ## Access Android shared storage
52
47
 
53
- ## Opening Files
54
- ```bash
55
- termux-open file.pdf # Opens with default app
56
- termux-open --chooser image.jpg # Choose app
57
- ```
48
+ Termux cannot access shared Android storage until you grant permission. Run this once:
58
49
 
59
- ## Clipboard
60
50
  ```bash
61
- termux-clipboard-set "text" # Copy
62
- termux-clipboard-get # Paste
51
+ termux-setup-storage
63
52
  ```
64
53
 
65
- ## Notifications
66
- ```bash
67
- termux-notification -t "Title" -c "Content"
68
- ```
54
+ After approval, Android shared storage is available under `/storage/emulated/0` and through the links Termux creates under `~/storage/`.
69
55
 
70
- ## Device Info
71
- ```bash
72
- termux-battery-status # Battery info
73
- termux-wifi-connectioninfo # WiFi info
74
- termux-telephony-deviceinfo # Device info
75
- ```
56
+ Only grant this permission when Pi should be able to access those files. Commands and tools running in Termux use the same storage permissions as the Termux process.
57
+
58
+ ## Use clipboard commands
59
+
60
+ Pi uses `termux-clipboard-set` to copy text and `termux-clipboard-get` for its clipboard-paste shortcut. Shell commands can use both commands directly. Install the Termux:API app and its command-line package:
76
61
 
77
- ## Sharing
78
62
  ```bash
79
- termux-share -a send file.txt # Share file
63
+ pkg install termux-api
80
64
  ```
81
65
 
82
- ## Other Useful Commands
66
+ Verify the integration:
67
+
83
68
  ```bash
84
- termux-toast "message" # Quick toast popup
85
- termux-vibrate # Vibrate device
86
- termux-tts-speak "hello" # Text to speech
87
- termux-camera-photo out.jpg # Take photo
69
+ printf 'Pi clipboard test' | termux-clipboard-set
70
+ termux-clipboard-get
88
71
  ```
89
72
 
90
- ## Notes
91
- - Termux:API app must be installed for `termux-*` commands
92
- - Use `pkg install termux-api` for the command-line tools
93
- - Storage permission needed for `/storage/emulated/0` access
94
- ````
73
+ The second command should print `Pi clipboard test`.
74
+
75
+ The Termux clipboard API supports text only. Pi's clipboard-paste shortcut inserts that text into the editor but cannot attach clipboard images.
76
+
77
+ ## Add Termux-specific instructions
78
+
79
+ Pi detects that it is running in Termux, but it cannot infer how you want it to interact with Android. Add only the environment details relevant to your work to `~/.pi/agent/AGENTS.md`:
95
80
 
96
- ## Limitations
81
+ ````markdown
82
+ # Termux environment
83
+
84
+ - Pi runs in Termux on Android.
85
+ - Shared Android storage is under `/storage/emulated/0`.
86
+ - Open URLs with `termux-open-url "https://example.com"`.
87
+ - Open files with `termux-open <path>`.
88
+ - Do not access shared storage unless the task requires it.
89
+ ````
97
90
 
98
- - **No image clipboard**: Termux clipboard API only supports text
99
- - **Storage access**: To access files in `/storage/emulated/0` (Downloads, etc.), run `termux-setup-storage` once to grant permissions
91
+ Run `/reload` after changing the file during an active session.
100
92
 
101
93
  ## Troubleshooting
102
94
 
103
- ### Clipboard not working
95
+ ### Clipboard integration fails
104
96
 
105
- Ensure both apps are installed:
106
- 1. Termux (from GitHub or F-Droid)
107
- 2. Termux:API (from GitHub or F-Droid)
97
+ Confirm that you installed both components:
108
98
 
109
- Then install the CLI tools:
110
- ```bash
111
- pkg install termux-api
112
- ```
99
+ 1. The Termux:API Android app from the same source as Termux
100
+ 2. The `termux-api` command-line package
113
101
 
114
- ### Permission denied for shared storage
102
+ Then run the clipboard verification commands above outside Pi. If they fail there, fix the Termux:API installation before retrying Pi's copy command.
115
103
 
116
- Run once to grant storage permissions:
117
- ```bash
118
- termux-setup-storage
119
- ```
104
+ ### Shared storage reports permission denied
105
+
106
+ Run `termux-setup-storage`, approve the Android permission request, and retry the path under `~/storage/` or `/storage/emulated/0`.
120
107
 
121
- ### Node.js installation issues
108
+ ### Pi is not found after installation
109
+
110
+ Open a new Termux shell and run:
122
111
 
123
- If npm fails, try clearing the cache:
124
112
  ```bash
125
- npm cache clean --force
113
+ npm prefix -g
114
+ command -v pi
126
115
  ```
116
+
117
+ Confirm that the global npm binary directory is on `PATH`, then reinstall Pi if the package is missing.