@knightcodeai/cli-linux-x64 0.9.1 → 0.9.2

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 (45) hide show
  1. package/bin/CHANGELOG.md +50 -0
  2. package/bin/README.md +52 -19
  3. package/bin/docs/cli-integration.md +106 -0
  4. package/bin/docs/cli.md +270 -0
  5. package/bin/docs/compaction.md +56 -37
  6. package/bin/docs/configuration.md +46 -0
  7. package/bin/docs/containerization.md +86 -54
  8. package/bin/docs/custom-provider.md +132 -785
  9. package/bin/docs/docs.json +143 -103
  10. package/bin/docs/environment-variables.md +5 -4
  11. package/bin/docs/extensions.md +134 -2956
  12. package/bin/docs/how-knightcode-works.md +49 -0
  13. package/bin/docs/index.md +24 -69
  14. package/bin/docs/json.md +193 -65
  15. package/bin/docs/keybindings.md +56 -101
  16. package/bin/docs/llama-cpp.md +3 -3
  17. package/bin/docs/message-types.md +261 -0
  18. package/bin/docs/models.md +64 -547
  19. package/bin/docs/packages.md +66 -167
  20. package/bin/docs/prompt-templates.md +31 -68
  21. package/bin/docs/providers.md +103 -241
  22. package/bin/docs/quickstart.md +61 -106
  23. package/bin/docs/rpc-commands.md +854 -0
  24. package/bin/docs/rpc-extension-ui.md +200 -0
  25. package/bin/docs/rpc.md +129 -1556
  26. package/bin/docs/sdk.md +76 -1160
  27. package/bin/docs/security.md +70 -32
  28. package/bin/docs/session-format.md +25 -216
  29. package/bin/docs/sessions.md +38 -143
  30. package/bin/docs/settings.md +111 -389
  31. package/bin/docs/shell-aliases.md +85 -5
  32. package/bin/docs/skills.md +51 -189
  33. package/bin/docs/slash-commands.md +63 -0
  34. package/bin/docs/terminal-setup.md +107 -79
  35. package/bin/docs/termux.md +74 -83
  36. package/bin/docs/themes.md +68 -280
  37. package/bin/docs/tmux.md +31 -39
  38. package/bin/docs/tui.md +69 -923
  39. package/bin/docs/usage.md +79 -286
  40. package/bin/docs/windows.md +43 -17
  41. package/bin/export-html/template.js +6 -1
  42. package/bin/knightcode +2 -2
  43. package/bin/package.json +6 -6
  44. package/package.json +1 -1
  45. package/bin/docs/development.md +0 -71
@@ -1,22 +1,27 @@
1
- # Terminal Setup
1
+ # Configure your terminal
2
2
 
3
- KnightCode 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 KnightCode 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
+ KnightCode 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
- KnightCode 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 | `KNIGHTCODE_HYPERLINKS=1\|0\|auto` | `terminal.hyperlinks: true\|false\|"auto"` |
12
- | Inline images | `KNIGHTCODE_IMAGE_PROTOCOL=kitty\|iterm2\|none\|auto` | `terminal.images: "kitty"\|"iterm2"\|false\|"auto"` |
13
- | Truecolor | `KNIGHTCODE_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 KnightCode 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
+ | Dragging does not copy text, or copies it unexpectedly | [Text Selection and Copy](#text-selection-and-copy) |
15
+ | Links work but show no hover preview | [Ghostty](#ghostty) |
16
+ | Inline images or colors are not detected | [Override detected capabilities](#override-detected-capabilities) |
17
+ | An IME candidate window appears in the wrong place | [WezTerm](#wezterm) or [IntelliJ IDEA](#intellij-idea-integrated-terminal) |
18
+ | Modified keys fail only inside tmux | [Run KnightCode in tmux](tmux.md) |
14
19
 
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.
20
+ Use `/hotkeys` to inspect KnightCode's active shortcuts. See [Keybindings](keybindings.md) to change them.
16
21
 
17
22
  ## Text Selection and Copy
18
23
 
19
- Which side owns a mouse drag depends on the [TUI mode](usage.md#other-options).
24
+ Which side owns a mouse drag depends on the [TUI mode](usage.md#adjust-the-terminal).
20
25
 
21
26
  In `fullscreen` mode, knightcode enables mouse reporting and owns text selection itself. Dragging with the primary button selects, and the selection is copied to the clipboard on release. Set `fullscreenCopyOnSelect` to `false` to keep the selection highlighted and copy it with `Ctrl+X` instead. To reach the terminal's own selection while knightcode captures the mouse, hold the terminal's bypass modifier — usually `Shift`, `Option` in iTerm2, and `Shift+Command`/`Shift+Ctrl` in Ghostty.
22
27
 
@@ -24,58 +29,55 @@ In `regular` mode, knightcode never enables mouse reporting, so a drag is the te
24
29
 
25
30
  ## Kitty
26
31
 
27
- Works out of the box.
32
+ Kitty supports the required keyboard protocol without additional configuration.
28
33
 
29
34
  ## iTerm2
30
35
 
31
- ### Regular TUI mode
32
-
33
- Works out of the box.
36
+ Regular terminal mode works without additional configuration.
34
37
 
35
- ### Fullscreen TUI mode
38
+ ### Fix slow fullscreen scrolling
36
39
 
37
- KnightCode 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.
40
+ In fullscreen mode, KnightCode 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.
38
41
 
39
- If fast mouse-wheel gestures move only about one line at a time in fullscreen mode:
42
+ To change this behavior:
40
43
 
41
- 1. Open **iTerm2 → Settings → Advanced**.
42
- 2. Search for **Trackpad scrolls fast?** and set it to **No**.
44
+ 1. Open **iTerm2 > Settings > Advanced**.
45
+ 2. Search for **Trackpad scrolls fast?**.
46
+ 3. Set it to **No**.
43
47
 
44
- 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).
48
+ 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).
45
49
 
46
50
  ## Apple Terminal
47
51
 
48
- KnightCode enables enhanced key reporting when available. If Terminal.app still sends plain Return for `Shift+Enter`, knightcode uses a local macOS modifier fallback to treat that Return as `Shift+Enter`.
52
+ KnightCode enables enhanced key reporting when available. If Terminal.app still sends plain Return for `Shift+Enter`, KnightCode uses a local macOS modifier fallback and treats it as `Shift+Enter`.
49
53
 
50
- This fallback only works when knightcode runs on the same Mac as Terminal.app. It cannot detect the local keyboard over remote SSH.
54
+ The fallback works only when KnightCode runs on the same Mac as Terminal.app. It cannot inspect the local modifier state when KnightCode runs on another machine over SSH.
51
55
 
52
56
  ## Ghostty
53
57
 
54
- Add to your Ghostty config (`~/Library/Application Support/com.mitchellh.ghostty/config` on macOS, `~/.config/ghostty/config` on Linux):
58
+ Add this mapping to Ghostty's configuration if `Alt+Backspace` does not work:
55
59
 
56
- ```
60
+ ```text
57
61
  keybind = alt+backspace=text:\x1b\x7f
58
62
  ```
59
63
 
60
- Older Claude Code versions may have added this Ghostty mapping:
64
+ The configuration file is `~/Library/Application Support/com.mitchellh.ghostty/config` on macOS and `~/.config/ghostty/config` on Linux.
61
65
 
62
- ```
66
+ Older Claude Code configurations may contain:
67
+
68
+ ```text
63
69
  keybind = shift+enter=text:\n
64
70
  ```
65
71
 
66
- That mapping sends a raw linefeed byte. Inside knightcode, that is indistinguishable from `Ctrl+J`, so tmux and knightcode no longer see a real `shift+enter` key event.
67
-
68
- 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.
69
-
70
- KnightCode binds `Ctrl+J` as a default newline alias, so `Shift+Enter` keeps working in tmux via that remap without extra knightcode configuration.
72
+ This sends a raw linefeed, which KnightCode cannot distinguish from `Ctrl+J`. Remove the mapping if an older Claude Code installation is the only reason you added it. KnightCode already binds `Ctrl+J` as a newline alternative, so the mapping may appear to work while still preventing KnightCode and tmux from receiving a real `Shift+Enter` event.
71
73
 
72
- ### Fullscreen TUI mode
74
+ ### Open links in fullscreen mode
73
75
 
74
- In fullscreen mode, links remain clickable, but Ghostty does not show its hover underline or lower-left URL preview while knightcode captures mouse input. Hold `Shift+Command` on macOS or `Shift+Ctrl` on Linux to use Ghostty's native link handling.
76
+ Links remain clickable in fullscreen mode, but Ghostty does not show its normal hover underline or URL preview while KnightCode captures mouse input. Hold `Shift+Command` on macOS or `Shift+Ctrl` on Linux to use Ghostty's native link handling.
75
77
 
76
78
  ## WezTerm
77
79
 
78
- WezTerm usually works out of the box for `Shift+Enter` via xterm modifyOtherKeys. To use the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
80
+ WezTerm normally reports `Shift+Enter` through xterm extended keys. To enable the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
79
81
 
80
82
  ```lua
81
83
  local wezterm = require 'wezterm'
@@ -84,7 +86,19 @@ config.enable_kitty_keyboard = true
84
86
  return config
85
87
  ```
86
88
 
87
- On macOS, WezTerm binds `Option+Enter` to fullscreen by default. To use `Option+Enter` for knightcode follow-up queueing, add this key override:
89
+ ### Forward Alt+Enter on macOS
90
+
91
+ WezTerm binds `Option+Enter` to fullscreen by default on macOS. To use it for KnightCode's follow-up queue, add this entry to your `config.keys` table:
92
+
93
+ ```lua
94
+ {
95
+ key = 'Enter',
96
+ mods = 'ALT',
97
+ action = wezterm.action.SendString('\x1b[13;3u'),
98
+ }
99
+ ```
100
+
101
+ A complete minimal configuration is:
88
102
 
89
103
  ```lua
90
104
  local wezterm = require 'wezterm'
@@ -99,13 +113,20 @@ config.keys = {
99
113
  return config
100
114
  ```
101
115
 
102
- If you already have a `config.keys` table, add the entry to it.
116
+ ### Position an IME candidate window in WSL
103
117
 
104
- 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 `KNIGHTCODE_HARDWARE_CURSOR=1` before running knightcode or set `showHardwareCursor` to `true` in settings.
118
+ If CJK IME candidates do not follow KnightCode's text cursor in WSL, show the hardware cursor:
119
+
120
+ ```bash
121
+ export KNIGHTCODE_HARDWARE_CURSOR=1
122
+ knightcode
123
+ ```
124
+
125
+ You can instead set `showHardwareCursor` to `true` in KnightCode settings.
105
126
 
106
127
  ## Alacritty
107
128
 
108
- Alacritty usually works out of the box for `Shift+Enter`. On macOS, `Option+Enter` may arrive as plain `Enter`. To use `Option+Enter` for knightcode follow-up queueing, add to `~/.config/alacritty/alacritty.toml`:
129
+ 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 KnightCode:
109
130
 
110
131
  ```toml
111
132
  [[keyboard.bindings]]
@@ -114,20 +135,13 @@ mods = "Alt"
114
135
  chars = "\u001b[13;3u"
115
136
  ```
116
137
 
117
- Restart Alacritty after changing the config.
118
-
119
- ## VS Code (Integrated Terminal)
138
+ Restart Alacritty after changing the file.
120
139
 
121
- 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.
140
+ ## VS Code integrated terminal
122
141
 
123
- VS Code versions older than 1.109.5 need an explicit terminal keybinding for `Shift+Enter`.
142
+ VS Code 1.109.5 and newer enable the Kitty keyboard protocol in the integrated terminal by default.
124
143
 
125
- `keybindings.json` locations:
126
- - macOS: `~/Library/Application Support/Code/User/keybindings.json`
127
- - Linux: `~/.config/Code/User/keybindings.json`
128
- - Windows: `%APPDATA%\\Code\\User\\keybindings.json`
129
-
130
- Add to `keybindings.json`:
144
+ For an older version, add a `Shift+Enter` terminal binding to `keybindings.json`:
131
145
 
132
146
  ```json
133
147
  {
@@ -138,9 +152,15 @@ Add to `keybindings.json`:
138
152
  }
139
153
  ```
140
154
 
141
- ## Zed (Integrated Terminal)
155
+ The user `keybindings.json` file is normally located at:
156
+
157
+ - macOS: `~/Library/Application Support/Code/User/keybindings.json`
158
+ - Linux: `~/.config/Code/User/keybindings.json`
159
+ - Windows: `%APPDATA%\\Code\\User\\keybindings.json`
142
160
 
143
- Add these key bindings to your Zed `keymap.json`:
161
+ ## Zed integrated terminal
162
+
163
+ Add these bindings to Zed's `keymap.json`:
144
164
 
145
165
  ```json
146
166
  {
@@ -155,46 +175,54 @@ Add these key bindings to your Zed `keymap.json`:
155
175
 
156
176
  ## Windows Terminal
157
177
 
158
- KnightCode uses Windows-style keybindings when running natively on Windows or in WSL:
178
+ Windows Terminal uses KnightCode's Windows and WSL shortcut defaults. See [Keybindings](keybindings.md) for the complete list.
159
179
 
160
- - `Alt+V` pastes an image or clipboard text.
161
- - `Ctrl+F` searches the transcript in fullscreen mode, and `Ctrl+Up`/`Ctrl+Down` jump between marked messages.
162
- - `Alt+P` cycles to the previous model.
163
- - `Ctrl+Z` undoes editing on native Windows; WSL uses `Alt+Z` so `Ctrl+Z` can suspend knightcode.
164
- - `Ctrl+Q` queues a follow-up message and `Alt+Q` restores queued messages.
180
+ ### Forward Shift+Enter
165
181
 
166
- Add to `settings.json` (Ctrl+Shift+, or Settings → Open JSON file) to forward `Shift+Enter` for inserting a new line:
182
+ Open Windows Terminal's `settings.json` with `Ctrl+Shift+,` or **Settings > Open JSON file**. Add this object to its `actions` array:
167
183
 
168
184
  ```json
169
185
  {
170
- "actions": [
171
- {
172
- "command": { "action": "sendInput", "input": "\u001b[13;2u" },
173
- "keys": "shift+enter"
174
- }
175
- ]
186
+ "command": { "action": "sendInput", "input": "\u001b[13;2u" },
187
+ "keys": "shift+enter"
176
188
  }
177
189
  ```
178
190
 
179
- Windows Terminal binds `Alt+Enter` to fullscreen by default. To use it instead of knightcode's `Ctrl+Q` default for follow-up queueing, configure Windows Terminal to send the key and bind `app.message.followUp` to `alt+enter` in knightcode.
191
+ Fully close and reopen Windows Terminal, then verify that `Shift+Enter` inserts a new line in KnightCode.
192
+
193
+ ### Use Alt+Enter for follow-ups
180
194
 
181
- If you already have an `actions` array, add the object to it. Fully close and reopen Windows Terminal after changing its settings.
195
+ Windows Terminal binds `Alt+Enter` to fullscreen by default. KnightCode therefore uses `Ctrl+Q` for follow-ups on Windows and WSL.
182
196
 
183
- ## xfce4-terminal, terminator
197
+ To use `Alt+Enter` instead, configure Windows Terminal to forward the key and bind `app.message.followUp` to `alt+enter` in KnightCode's `keybindings.json`. See [Keybindings](keybindings.md#assign-keybindings).
184
198
 
185
- 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.
199
+ ## xfce4-terminal and Terminator
186
200
 
187
- For the best experience, use a terminal that supports the Kitty keyboard protocol:
188
- - [Kitty](https://sw.kovidgoyal.net/kitty/)
189
- - [Ghostty](https://ghostty.org/)
190
- - [WezTerm](https://wezfurlong.org/wezterm/)
191
- - [iTerm2](https://iterm2.com/)
192
- - [Alacritty](https://github.com/alacritty/alacritty) (requires compilation with Kitty protocol support)
201
+ These terminals cannot reliably distinguish modified Enter keys from plain `Enter`. Custom bindings such as `Ctrl+Enter` or `Shift+Enter` therefore may not work.
193
202
 
194
- ## IntelliJ IDEA (Integrated Terminal)
203
+ 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.
195
204
 
196
- The built-in terminal has limited escape sequence support. Shift+Enter cannot be distinguished from Enter in IntelliJ's terminal.
205
+ ## IntelliJ IDEA integrated terminal
206
+
207
+ IntelliJ IDEA's built-in terminal cannot reliably distinguish `Shift+Enter` from plain `Enter`. Use `Ctrl+J` for a newline or run KnightCode in a terminal with modern extended-key support.
208
+
209
+ If an IME candidate window does not follow the text cursor, show the hardware cursor:
210
+
211
+ ```bash
212
+ export KNIGHTCODE_HARDWARE_CURSOR=1
213
+ knightcode
214
+ ```
215
+
216
+ ## Override detected capabilities
217
+
218
+ KnightCode automatically detects OSC 8 hyperlinks, inline image protocols, and truecolor support. A terminal proxy or multiplexer can make that detection inaccurate.
219
+
220
+ | Capability | Environment variable | Setting |
221
+ |---|---|---|
222
+ | Hyperlinks | `KNIGHTCODE_HYPERLINKS=1\|0\|auto` | `terminal.hyperlinks: true\|false\|"auto"` |
223
+ | Inline images | `KNIGHTCODE_IMAGE_PROTOCOL=kitty\|iterm2\|none\|auto` | `terminal.images: "kitty"\|"iterm2"\|false\|"auto"` |
224
+ | Truecolor | `KNIGHTCODE_TRUE_COLOR=1\|0\|auto` | `terminal.trueColor: true\|false\|"auto"` |
197
225
 
198
- If you want the hardware cursor visible, set `KNIGHTCODE_HARDWARE_CURSOR=1` before running knightcode (disabled by default for compatibility).
226
+ Settings take precedence over environment variables. An unset value or `auto` preserves automatic detection.
199
227
 
200
- Consider using a dedicated terminal emulator for the best experience.
228
+ Only force a capability supported by the complete terminal path. Unsupported escape sequences can corrupt rendering. See [Environment Variables](environment-variables.md#knightcode-process-configuration) and [Settings](settings.md) for the canonical value definitions.
@@ -1,126 +1,117 @@
1
- # Termux (Android) Setup
1
+ # Run KnightCode on Android with Termux
2
2
 
3
- KnightCode runs on Android via [Termux](https://termux.dev/), a terminal emulator and Linux environment for Android.
3
+ KnightCode runs on Android through [Termux](https://termux.dev/), a terminal emulator and Linux environment. Text input, file tools, and shell commands are supported. KnightCode 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 KnightCode 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 KnightCode
15
12
 
16
- # Install dependencies
17
- pkg install nodejs termux-api git
13
+ 1. Update Termux packages:
18
14
 
19
- # Install knightcode
20
- npm install -g --ignore-scripts @knightcodeai/cli
15
+ ```bash
16
+ pkg update && pkg upgrade
17
+ ```
21
18
 
22
- # Create config directory
23
- mkdir -p ~/.knightcode/agent
19
+ 2. Install Node.js and Git:
24
20
 
25
- # Run knightcode
26
- knightcode
27
- ```
21
+ ```bash
22
+ pkg install nodejs git
23
+ ```
28
24
 
29
- ## Clipboard Support
25
+ 3. Install KnightCode:
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 @knightcodeai/cli
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
+ knightcode --version
35
+ ```
36
36
 
37
- Create `~/.knightcode/agent/AGENTS.md` to help the agent understand the Termux environment:
37
+ 5. Open the folder you want to work in and start KnightCode:
38
38
 
39
- ````markdown
40
- # Agent Environment: Termux on Android
39
+ ```bash
40
+ cd /path/to/working-folder
41
+ knightcode
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 KnightCode 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
+ KnightCode 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 'KnightCode 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 `KnightCode clipboard test`.
74
+
75
+ The Termux clipboard API supports text only. KnightCode's clipboard-paste shortcut inserts that text into the editor but cannot attach clipboard images.
76
+
77
+ ## Add Termux-specific instructions
78
+
79
+ KnightCode 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 `~/.knightcode/agent/AGENTS.md`:
95
80
 
96
- ## Limitations
81
+ ````markdown
82
+ # Termux environment
83
+
84
+ - KnightCode 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 KnightCode. If they fail there, fix the Termux:API installation before retrying KnightCode'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
+ ### KnightCode 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 knightcode
126
115
  ```
116
+
117
+ Confirm that the global npm binary directory is on `PATH`, then reinstall KnightCode if the package is missing.