@knightcodeai/cli-linux-x64 0.9.0 → 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 +88 -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 -782
  9. package/bin/docs/docs.json +143 -103
  10. package/bin/docs/environment-variables.md +5 -3
  11. package/bin/docs/extensions.md +134 -2937
  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 +65 -517
  19. package/bin/docs/packages.md +66 -167
  20. package/bin/docs/prompt-templates.md +31 -68
  21. package/bin/docs/providers.md +103 -233
  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 +39 -216
  29. package/bin/docs/sessions.md +43 -121
  30. package/bin/docs/settings.md +112 -367
  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 -285
  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,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.
@@ -1,322 +1,110 @@
1
- > knightcode can create themes. Ask it to build one for your setup.
1
+ # Customize KnightCode with themes
2
2
 
3
- # Themes
3
+ Themes control the colors KnightCode uses in interactive mode and HTML exports. KnightCode includes `dark` and `light` themes. You can select one theme, follow your terminal's light or dark appearance, or create your own palette.
4
4
 
5
- Themes are JSON files that define colors for the TUI.
5
+ <a id="selecting-a-theme"></a>
6
6
 
7
- ## Table of Contents
7
+ ## Choose a theme
8
8
 
9
- - [Locations](#locations)
10
- - [Selecting a Theme](#selecting-a-theme)
11
- - [Creating a Custom Theme](#creating-a-custom-theme)
12
- - [Theme Format](#theme-format)
13
- - [Color Tokens](#color-tokens)
14
- - [Color Values](#color-values)
15
- - [Tips](#tips)
9
+ Open `/settings` and select **Theme**. You can use one theme for every terminal appearance or choose separate themes for light and dark terminals.
16
10
 
17
- ## Locations
11
+ The selection is saved as the `theme` [setting](settings.md#terminal-and-display):
18
12
 
19
- KnightCode loads themes from:
20
-
21
- - Built-in: `dark`, `light`
22
- - Global: `~/.knightcode/agent/themes/*.json`
23
- - Project: `.knightcode/themes/*.json` (only after the project is trusted)
24
- - Packages: `themes/` directories or `knightcode.themes` entries in `package.json`
25
- - Settings: `themes` array with files or directories
26
- - CLI: `--theme <path>` (repeatable)
27
-
28
- Disable discovery with `--no-themes`.
29
-
30
- ## Selecting a Theme
13
+ ```json
14
+ {
15
+ "theme": "dark"
16
+ }
17
+ ```
31
18
 
32
- Select a theme via `/settings` or in `settings.json`:
19
+ Automatic mode stores the light theme first and the dark theme second:
33
20
 
34
21
  ```json
35
22
  {
36
- "theme": "my-theme"
23
+ "theme": "light/dark"
37
24
  }
38
25
  ```
39
26
 
40
- On first run, knightcode detects your terminal background and defaults to `dark` or `light`.
27
+ When automatic mode is active, KnightCode changes themes when the terminal reports an appearance change. Theme names cannot contain `/` because KnightCode reserves it for this setting format.
41
28
 
42
- ### Initial Theme
43
-
44
- Start an interactive run with a theme without changing the saved setting:
29
+ Use `--use-theme` to choose the initial theme for one invocation without changing the saved setting:
45
30
 
46
31
  ```bash
47
32
  knightcode --use-theme light
48
- ```
49
-
50
- To follow terminal appearance, use `lightTheme/darkTheme` syntax:
51
-
52
- ```bash
53
33
  knightcode --use-theme light/dark
54
34
  ```
55
35
 
56
- The CLI value is the initial theme for that run. Choosing another theme later in `/settings` applies it immediately
57
- and saves it normally.
58
-
59
- ## Creating a Custom Theme
60
-
61
- 1. Create a theme file:
62
-
63
- ```bash
64
- mkdir -p ~/.knightcode/agent/themes
65
- vim ~/.knightcode/agent/themes/my-theme.json
66
- ```
67
-
68
- 2. Define the theme with all required colors (see [Color Tokens](#color-tokens)):
36
+ See [CLI resources](cli.md#resources) for the command-line option.
69
37
 
70
- ```json
71
- {
72
- "$schema": "https://raw.githubusercontent.com/KnightCodeAI/knightcode/main/packages/cli/src/modes/interactive/theme/theme-schema.json",
73
- "name": "my-theme",
74
- "vars": {
75
- "primary": "#00aaff",
76
- "secondary": 242
77
- },
78
- "colors": {
79
- "accent": "primary",
80
- "border": "primary",
81
- "borderAccent": "#00ffff",
82
- "borderMuted": "secondary",
83
- "success": "#00ff00",
84
- "error": "#ff0000",
85
- "warning": "#ffff00",
86
- "muted": "secondary",
87
- "dim": 240,
88
- "text": "",
89
- "thinkingText": "secondary",
90
- "selectedBg": "#2d2d30",
91
- "scrollbarTrack": "secondary",
92
- "scrollbarThumb": "",
93
- "searchMatchBg": "#2d2d30",
94
- "searchMatchText": "",
95
- "userMessageBg": "#2d2d30",
96
- "userMessageText": "",
97
- "customMessageBg": "#2d2d30",
98
- "customMessageText": "",
99
- "customMessageLabel": "primary",
100
- "toolPendingBg": "#1e1e2e",
101
- "toolSuccessBg": "#1e2e1e",
102
- "toolErrorBg": "#2e1e1e",
103
- "toolTitle": "primary",
104
- "toolOutput": "",
105
- "mdHeading": "#ffaa00",
106
- "mdLink": "primary",
107
- "mdLinkUrl": "secondary",
108
- "mdCode": "#00ffff",
109
- "mdCodeBlock": "",
110
- "mdCodeBlockBorder": "secondary",
111
- "mdQuote": "secondary",
112
- "mdQuoteBorder": "secondary",
113
- "mdHr": "secondary",
114
- "mdListBullet": "#00ffff",
115
- "toolDiffAdded": "#00ff00",
116
- "toolDiffRemoved": "#ff0000",
117
- "toolDiffContext": "secondary",
118
- "syntaxComment": "secondary",
119
- "syntaxKeyword": "primary",
120
- "syntaxFunction": "#00aaff",
121
- "syntaxVariable": "#ffaa00",
122
- "syntaxString": "#00ff00",
123
- "syntaxNumber": "#ff00ff",
124
- "syntaxType": "#00aaff",
125
- "syntaxOperator": "primary",
126
- "syntaxPunctuation": "secondary",
127
- "thinkingOff": "secondary",
128
- "thinkingMinimal": "primary",
129
- "thinkingLow": "#00aaff",
130
- "thinkingMedium": "#00ffff",
131
- "thinkingHigh": "#ff00ff",
132
- "thinkingXhigh": "#ff0000",
133
- "thinkingMax": "#ff0088",
134
- "bashMode": "#ffaa00"
135
- }
136
- }
137
- ```
38
+ ## Create a custom theme
138
39
 
139
- 3. Select the theme via `/settings`.
40
+ Copy one of the [built-in themes](https://github.com/KnightCodeAI/knightcode/tree/main/packages/cli/src/modes/interactive/theme) or create a new JSON file conforming to the [schema](https://github.com/KnightCodeAI/knightcode/blob/main/packages/cli/src/modes/interactive/theme/theme-schema.json).
140
41
 
141
- **Hot reload:** When you edit the currently active custom theme file, knightcode reloads it automatically for immediate visual feedback.
42
+ 1. Save the file as `<agent-dir>/themes/my-theme.json`. The agent directory defaults to `~/.knightcode/agent`.
43
+ 2. Set its `name` to `my-theme`.
44
+ 3. Change values in `vars` and `colors`.
45
+ 4. Select `my-theme` through `/settings`.
142
46
 
143
- ## Theme Format
47
+ Use the theme name as the filename. KnightCode hot-reloads the active user theme only from `<agent-dir>/themes/<name>.json`. Run `/reload` after adding or changing a theme from any other source.
144
48
 
145
- ```json
146
- {
147
- "$schema": "https://raw.githubusercontent.com/KnightCodeAI/knightcode/main/packages/cli/src/modes/interactive/theme/theme-schema.json",
148
- "name": "my-theme",
149
- "vars": {
150
- "blue": "#0066cc",
151
- "gray": 242
152
- },
153
- "colors": {
154
- "accent": "blue",
155
- "muted": "gray",
156
- "text": "",
157
- ...
158
- }
159
- }
160
- ```
49
+ ## Understand the theme file
161
50
 
162
- - `name` is required, must be unique, and must not contain `/`.
163
- - `vars` is optional. Define reusable colors here, then reference them in `colors`.
164
- - `colors` must define all 53 required tokens. `thinkingMax` and the two search highlight tokens are optional and use the fallbacks listed below.
165
-
166
- The `$schema` field enables editor auto-completion and validation.
167
-
168
- ## Color Tokens
169
-
170
- Every theme must define all 53 required color tokens. The optional tokens preserve compatibility with existing themes: `thinkingMax` falls back to `thinkingXhigh`, `searchMatchBg` falls back to `selectedBg`, and `searchMatchText` falls back to `text`. Other search matches use `searchMatchText` on `searchMatchBg` with an underline; the current match reverses that foreground/background pair and uses bold text.
171
-
172
- ### Core UI (13 colors)
173
-
174
- | Token | Purpose |
175
- |-------|---------|
176
- | `accent` | Primary accent (logo, selected items, cursor) |
177
- | `border` | Normal borders |
178
- | `borderAccent` | Highlighted borders |
179
- | `borderMuted` | Subtle borders (editor) |
180
- | `success` | Success states |
181
- | `error` | Error states |
182
- | `warning` | Warning states |
183
- | `muted` | Secondary text |
184
- | `dim` | Tertiary text |
185
- | `text` | Default text (usually `""`) |
186
- | `thinkingText` | Thinking block text |
187
- | `scrollbarTrack` | Fullscreen scrollbar track foreground |
188
- | `scrollbarThumb` | Fullscreen scrollbar thumb foreground, shared by normal and expanded states |
189
-
190
- ### Backgrounds & Content (11 required, 2 optional)
191
-
192
- | Token | Purpose |
193
- |-------|---------|
194
- | `selectedBg` | Selected line background |
195
- | `searchMatchBg` | Transcript search match background and current-match text; optional, falls back to `selectedBg` |
196
- | `searchMatchText` | Transcript search match text and current-match background; optional, falls back to `text` |
197
- | `userMessageBg` | User message background |
198
- | `userMessageText` | User message text |
199
- | `customMessageBg` | Extension message background |
200
- | `customMessageText` | Extension message text |
201
- | `customMessageLabel` | Extension message label |
202
- | `toolPendingBg` | Tool box (pending) |
203
- | `toolSuccessBg` | Tool box (success) |
204
- | `toolErrorBg` | Tool box (error) |
205
- | `toolTitle` | Tool title |
206
- | `toolOutput` | Tool output text |
207
-
208
- ### Markdown (10 colors)
209
-
210
- | Token | Purpose |
211
- |-------|---------|
212
- | `mdHeading` | Headings |
213
- | `mdLink` | Link text |
214
- | `mdLinkUrl` | Link URL |
215
- | `mdCode` | Inline code |
216
- | `mdCodeBlock` | Code block content |
217
- | `mdCodeBlockBorder` | Code block fences |
218
- | `mdQuote` | Blockquote text |
219
- | `mdQuoteBorder` | Blockquote border |
220
- | `mdHr` | Horizontal rule |
221
- | `mdListBullet` | List bullets |
222
-
223
- ### Tool Diffs (3 colors)
224
-
225
- | Token | Purpose |
226
- |-------|---------|
227
- | `toolDiffAdded` | Added lines |
228
- | `toolDiffRemoved` | Removed lines |
229
- | `toolDiffContext` | Context lines |
230
-
231
- ### Syntax Highlighting (9 colors)
232
-
233
- | Token | Purpose |
234
- |-------|---------|
235
- | `syntaxComment` | Comments |
236
- | `syntaxKeyword` | Keywords |
237
- | `syntaxFunction` | Function names |
238
- | `syntaxVariable` | Variables |
239
- | `syntaxString` | Strings |
240
- | `syntaxNumber` | Numbers |
241
- | `syntaxType` | Types |
242
- | `syntaxOperator` | Operators |
243
- | `syntaxPunctuation` | Punctuation |
244
-
245
- ### Thinking Level Borders (6 required, 1 optional)
246
-
247
- Editor border colors indicating thinking level (visual hierarchy from subtle to prominent):
248
-
249
- | Token | Purpose |
250
- |-------|---------|
251
- | `thinkingOff` | Thinking off |
252
- | `thinkingMinimal` | Minimal thinking |
253
- | `thinkingLow` | Low thinking |
254
- | `thinkingMedium` | Medium thinking |
255
- | `thinkingHigh` | High thinking |
256
- | `thinkingXhigh` | Extra high thinking |
257
- | `thinkingMax` | Maximum thinking; optional, falls back to `thinkingXhigh` |
258
-
259
- ### Bash Mode (1 color)
260
-
261
- | Token | Purpose |
262
- |-------|---------|
263
- | `bashMode` | Editor border in bash mode (`!` prefix) |
264
-
265
- ### HTML Export (optional)
266
-
267
- The `export` section controls colors for `/export` HTML output. If omitted, colors are derived from `userMessageBg`.
51
+ | Property | Required | Responsibility |
52
+ |---|---|---|
53
+ | `$schema` | No | Enables editor validation and completion against KnightCode's published schema. |
54
+ | `name` | Yes | Identifies the theme in selectors and settings. It must be unique and cannot contain `/`. |
55
+ | `vars` | No | Defines reusable color values. Variables can reference other variables. |
56
+ | `colors` | Yes | Assigns colors to terminal UI roles. The schema identifies required and optional roles. |
57
+ | `export` | No | Overrides page and panel backgrounds in HTML exports. |
268
58
 
269
- ```json
270
- {
271
- "export": {
272
- "pageBg": "#18181e",
273
- "cardBg": "#1e1e24",
274
- "infoBg": "#3c3728"
275
- }
276
- }
277
- ```
59
+ A color can be written in four forms:
278
60
 
279
- ## Color Values
61
+ | Form | Example | Meaning |
62
+ |---|---|---|
63
+ | RGB hexadecimal | `"#00aaff"` | A six-digit RGB color. |
64
+ | 256-color index | `39` | An ANSI palette index from `0` through `255`. |
65
+ | Variable reference | `"primary"` | The value of an entry in `vars`. |
66
+ | Terminal default | `""` | The terminal's default foreground or background color. |
280
67
 
281
- Four formats are supported:
68
+ KnightCode resolves chained variable references. A missing variable or circular reference makes the theme invalid. Hexadecimal colors use truecolor when supported and are approximated in terminals limited to 256 colors. If colors differ from their hexadecimal values, check your terminal's truecolor detection and contrast settings. See [Configure Your Terminal](terminal-setup.md#override-detected-capabilities).
282
69
 
283
- | Format | Example | Description |
284
- |--------|---------|-------------|
285
- | Hex | `"#ff0000"` | 6-digit hex RGB |
286
- | 256-color | `39` | xterm 256-color palette index (0-255) |
287
- | Variable | `"primary"` | Reference to a `vars` entry |
288
- | Default | `""` | Terminal's default color |
70
+ Use the [theme JSON schema](https://github.com/KnightCodeAI/knightcode/blob/main/packages/cli/src/modes/interactive/theme/theme-schema.json) for the exact properties, required colors, and accepted value types.
289
71
 
290
- ### 256-Color Palette
72
+ KnightCode reports invalid theme files during startup and `/reload`.
291
73
 
292
- - `0-15`: Basic ANSI colors (terminal-dependent)
293
- - `16-231`: 6×6×6 RGB cube (`16 + 36×R + 6×G + B` where R,G,B are 0-5)
294
- - `232-255`: Grayscale ramp
74
+ ## Find the color to change
295
75
 
296
- ### Terminal Compatibility
76
+ Theme colors describe interface roles rather than individual components. Use these groups to find the relevant part of the schema:
297
77
 
298
- KnightCode uses 24-bit RGB colors. Most modern terminals support this (iTerm2, Kitty, WezTerm, Windows Terminal, VS Code). For older terminals with only 256-color support, knightcode falls back to the nearest approximation.
299
-
300
- Check truecolor support:
301
-
302
- ```bash
303
- echo $COLORTERM # Should output "truecolor" or "24bit"
304
- ```
78
+ | Area | Color names |
79
+ |---|---|
80
+ | General interface | `accent`, `border*`, `text`, `muted`, `dim`, `success`, `error`, `warning` |
81
+ | Selection and fullscreen | `selectedBg`, `searchMatch*`, `scrollbar*` |
82
+ | Messages | `userMessage*`, `customMessage*`, `thinkingText` |
83
+ | Tool execution | `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`, `toolTitle`, `toolOutput` |
84
+ | Markdown | `md*` |
85
+ | Tool diffs | `toolDiff*` |
86
+ | Syntax highlighting | `syntax*` |
87
+ | Editor modes | `thinking*`, `bashMode` |
88
+ | HTML export | `export.pageBg`, `export.cardBg`, `export.infoBg` |
305
89
 
306
- ## Tips
90
+ The schema is the format reference. The built-in themes provide complete values that you can copy and adjust.
307
91
 
308
- **Dark terminals:** Use bright, saturated colors with higher contrast.
92
+ Five colors are optional and inherit another color when omitted:
309
93
 
310
- **Light terminals:** Use darker, muted colors with lower contrast.
94
+ | Optional color | Fallback |
95
+ |---|---|
96
+ | `scrollbarTrack` | `muted` |
97
+ | `scrollbarThumb` | `text` |
98
+ | `searchMatchBg` | `selectedBg` |
99
+ | `searchMatchText` | `text` |
100
+ | `thinkingMax` | `thinkingXhigh` |
311
101
 
312
- **Color harmony:** Start with a base palette (Nord, Gruvbox, Tokyo Night), define it in `vars`, and reference consistently.
102
+ If `export` colors are omitted, KnightCode derives HTML page and panel backgrounds from `userMessageBg`.
313
103
 
314
- **Testing:** Check your theme with different message types, tool states, markdown content, and long wrapped text.
104
+ ## Load a theme from a project or package
315
105
 
316
- **VS Code:** Set `terminal.integrated.minimumContrastRatio` to `1` for accurate colors.
106
+ Place a project theme in `.knightcode/themes/`. Project themes load only after [project trust](security.md#understand-project-trust) is granted.
317
107
 
318
- ## Examples
108
+ You can also load theme files and directories through the `themes` setting or distribute them in a KnightCode package. See [Configuration](configuration.md), [Settings](settings.md#resources), and [KnightCode Packages](packages.md).
319
109
 
320
- See the built-in themes:
321
- - [dark.json](../src/modes/interactive/theme/dark.json)
322
- - [light.json](../src/modes/interactive/theme/light.json)
110
+ Each loaded theme must have a unique name. KnightCode reports duplicate names as resource collisions.