@knightcodeai/cli-linux-x64 0.9.1 → 0.9.3

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 +60 -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
package/bin/docs/usage.md CHANGED
@@ -1,342 +1,135 @@
1
- # Using KnightCode
2
-
3
- This page collects day-to-day usage details that do not fit on the quickstart page.
4
-
5
- ## Interactive Mode
6
-
7
- <p align="center"><img src="images/interactive-mode.png" alt="Interactive Mode" width="600"></p>
8
-
9
- The interface has four main areas:
10
-
11
- - **Startup header** - shortcuts, loaded context files, prompt templates, skills, and extensions
12
- - **Messages** - user messages, assistant responses, tool calls, tool results, notifications, errors, and extension UI
13
- - **Editor** - where you type; border color indicates the current thinking level
14
- - **Footer** - working directory, session name, token/cache usage, cost, context usage, and current model. Totals include assistant responses, usage reported by tools, and summary generation.
15
-
16
- The editor can be replaced temporarily by built-in UI such as `/settings` or by custom extension UI.
17
-
18
- ### Editor Features
19
-
20
- | Feature | How |
21
- |---------|-----|
22
- | File reference | Type `@` to fuzzy-search project files |
23
- | Path completion | Press Tab to complete paths |
24
- | Multi-line input | Shift+Enter, or Ctrl+Enter on Windows Terminal |
25
- | Copy response | Ctrl+X copies the selected message in `/tree`; otherwise it copies the active fullscreen text selection when `fullscreenCopyOnSelect` is disabled, falling back to the last assistant message |
26
- | Images | Paste with Ctrl+V, Alt+V on Windows, or drag into the terminal |
27
- | Shell command | `!command` runs and sends output to the model |
28
- | Hidden shell command | `!!command` runs without sending output to the model |
29
- | External editor | Ctrl+G opens `externalEditor`, `$VISUAL`, `$EDITOR`, Notepad on Windows, or `nano` elsewhere |
30
-
31
- See [Keybindings](keybindings.md) for all shortcuts and customization.
32
-
33
- ## Slash Commands
34
-
35
- Type `/` in the editor to open command completion. Extensions can register custom commands, skills are available as `/skill:name`, and prompt templates expand via `/templatename`.
36
-
37
- | Command | Description |
38
- |---------|-------------|
39
- | `/login`, `/logout` | Manage OAuth or API-key credentials |
40
- | [`/llama`](llama-cpp.md) | Download, load, and unload llama.cpp router models |
41
- | `/model` | Switch models; Ctrl+S or Ctrl+D in the picker saves the startup default |
42
- | `/thinking` | Switch thinking level; Ctrl+S or Ctrl+D in the picker saves the startup default |
43
- | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
44
- | `/settings` | Theme, message delivery, transport, and other preferences |
45
- | [`/tools`](#web-tools) | Turn `webfetch` and `websearch` off, on for this session, or on by default; pick the search provider and store its key |
46
- | `/resume` | Pick from previous sessions |
47
- | `/new` | Start a new session |
48
- | `/name <name>` | Set session display name |
49
- | `/session` | Show session file, ID, messages, tokens, and cost |
50
- | `/tree` | Jump to any point in the session and continue from there |
51
- | `/undo` | Go back to an earlier user message; optionally restore the files edited after it |
52
- | `/trust` | Save project trust decision for future sessions |
53
- | `/fork` | Create a new session from a previous user message |
54
- | `/clone` | Duplicate the current active branch into a new session |
55
- | `/compact [prompt]` | Manually compact context, optionally with custom instructions |
56
- | `/copy` | Copy last assistant message to clipboard |
57
- | `/export [file]` | Export session to HTML or JSONL |
58
- | `/import <file>` | Import and resume a session from a JSONL file |
59
- | `/share` | Upload as private GitHub gist with shareable HTML link |
60
- | `/bug [description]` | Report a bug to the KnightCode developers; see [Sessions](sessions.md#reporting-bugs) |
61
- | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
62
- | `/hotkeys` | Show all keyboard shortcuts |
63
- | `/changelog` | Display version history |
64
- | `/quit` | Quit knightcode |
1
+ # Use KnightCode in the terminal
65
2
 
66
- ## Web Tools
67
-
68
- Two tools give the agent read access to the web. Both ship disabled; turn them on with `/tools`.
69
-
70
- | Tool | What it does |
71
- |------|--------------|
72
- | `webfetch` | Fetches a URL and returns the page as markdown, 400 lines at a time. The agent pages with `offset`/`limit` like `read`, or passes `grep` to get only matching lines. Responses are cached for 15 minutes, capped at 5 MB, and time out after 30 seconds. Private, loopback, and link-local addresses are refused. |
73
- | `websearch` | Searches the web and returns up to 10 results (default 5) as title, URL, and snippet. DuckDuckGo needs no key but may rate-limit; Brave Search needs an API key. |
74
-
75
- `/tools` lists each tool with its current state; pick one to open its settings panel. **Status** cycles through three states:
76
-
77
- | State | Effect |
78
- |-------|--------|
79
- | Disabled | The tool is not offered to the model |
80
- | Enabled for this session | On until knightcode exits, including across `/new`, `/resume`, and `/fork`; nothing is written to disk |
81
- | Enabled by default | On in every session |
82
-
83
- The `websearch` panel adds two rows: **Provider** (`duckduckgo` or `brave`) and **Brave API key**. Choosing Brave without a stored key opens the key prompt at once. Get a key at https://brave.com/search/api/; the free plan is enough. The key is also read from `BRAVE_API_KEY` when none is stored, but the provider only switches to Brave when you pick it. Keys show masked in the panel.
84
-
85
- The same changes work without the panel:
86
-
87
- ```bash
88
- /tools websearch on # this session
89
- /tools webfetch always # every session
90
- /tools webfetch off
91
- ```
3
+ Run `knightcode` from the folder you want to work in. KnightCode uses that folder to discover files, instructions, and configuration, and to group saved sessions. If you have not installed KnightCode or chosen a model yet, follow the [Quickstart](quickstart.md).
92
4
 
93
- Settings are stored in `~/.knightcode/agent/tools.json`, owner-readable only because it can hold the Brave key. `--tools` and `--exclude-tools` still apply: a tool excluded on the command line stays off whatever `/tools` says.
94
-
95
- Fetched pages and search results are marked as untrusted in the tool output so the model treats instructions inside them as data, but treat the tools like any other network access: a fetched page can still influence what the agent does next.
5
+ KnightCode may ask whether you trust the working folder before loading its project resources. See [Project trust](security.md#understand-project-trust).
96
6
 
97
- ## Message Queue
7
+ <p align="center"><img src="images/interactive-mode.png" alt="KnightCode interactive mode showing a conversation, editor, and status information" width="750"></p>
98
8
 
99
- You can submit messages while the agent is still working:
9
+ The transcript shows your prompts, KnightCode's responses, tool calls, results, and errors. You write prompts and commands in the editor. The footer shows the current folder, session, model, context usage, and accumulated usage and cost.
100
10
 
101
- - **Enter** queues a steering message, delivered after the current assistant turn finishes executing its tool calls.
102
- - **Alt+Enter** queues a follow-up message, delivered after the agent finishes all work.
103
- - **Escape** aborts and restores queued messages to the editor.
104
- - **Alt+Up** retrieves queued messages back to the editor.
11
+ ## Enter a prompt
105
12
 
106
- On Windows Terminal, Alt+Enter is fullscreen by default. Remap it as described in [Terminal setup](terminal-setup.md) if you want knightcode to receive the shortcut.
107
-
108
- Configure delivery in [Settings](settings.md) with `steeringMode` and `followUpMode`.
109
-
110
- ## Sessions
111
-
112
- Sessions are saved automatically to `~/.knightcode/agent/sessions/`, organized by working directory.
113
-
114
- ```bash
115
- knightcode -c # Continue most recent session
116
- knightcode -r # Browse and select a session
117
- knightcode --no-session # Ephemeral mode; do not save
118
- knightcode --name "my task" # Set session display name at startup
119
- knightcode --session <path|id> # Use a specific session file or session ID
120
- knightcode --fork <path|id> # Fork a session into a new session file
121
- ```
122
-
123
- Useful session commands:
124
-
125
- - `/session` shows the current session file and ID.
126
- - `/tree` navigates the in-file session tree and can summarize abandoned branches.
127
- - `/undo` goes back to an earlier user message and can restore the files edited after it.
128
- - `/fork` creates a new session from an earlier user message.
129
- - `/clone` duplicates the current active branch into a new session file.
130
- - `/compact` summarizes older messages to free context.
13
+ Type a request and press `Enter` to send it. Use `Shift+Enter` to add a line, or press `Ctrl+G` to work on a longer prompt in your configured external editor.
131
14
 
132
- See [Sessions](sessions.md) and [Compaction](compaction.md) for details.
15
+ To include files or images:
133
16
 
134
- ## Context Files
17
+ - Type `@` to search for a file and add it to your prompt.
18
+ - Press `Tab` to complete a path.
19
+ - Paste an image or drag it into a compatible terminal.
135
20
 
136
- KnightCode loads `AGENTS.md` or `CLAUDE.md` at startup from:
21
+ ## Follow KnightCode's work
137
22
 
138
- - `~/.knightcode/agent/AGENTS.md` for global instructions
139
- - parent directories, walking up from the current working directory
140
- - the current directory
23
+ KnightCode shows each tool call and result while it works. Press `Ctrl+O` to expand or collapse tool output. Press `Ctrl+T` to show or hide thinking blocks.
141
24
 
142
- If a directory contains `AGENTS.override.md`, KnightCode loads it instead of `AGENTS.md` or `CLAUDE.md` from that directory. Context files from other directories still layer normally.
25
+ The startup header lists the instructions and resources KnightCode loaded. The editor border indicates the current thinking level. The footer updates as the model uses context and reports usage.
143
26
 
144
- Use context files for project conventions, commands, safety rules, and preferences. Disable loading with `--no-context-files` or `-nc`.
27
+ KnightCode does not ask before every tool call. Review commands and changed files, and use a sandbox for untrusted or unattended work. See [Security](security.md).
145
28
 
146
- ### System Prompt Files
29
+ ## Change direction
147
30
 
148
- Replace the default system prompt with:
31
+ You can send more input while KnightCode is working:
149
32
 
150
- - `.knightcode/SYSTEM.md` for a project
151
- - `~/.knightcode/agent/SYSTEM.md` globally
33
+ | What you want | Action |
34
+ |---|---|
35
+ | Adjust the current task | Type a message and press `Enter` |
36
+ | Add work after the current task | Type a message and press `Alt+Enter` |
37
+ | Return queued messages to the editor | Press `Alt+Up` |
38
+ | Stop the current task | Press `Escape` |
152
39
 
153
- Append to the default prompt without replacing it with `APPEND_SYSTEM.md` in either location.
40
+ A message sent with `Enter` waits until the current response and its tool calls finish, then guides the next response. A follow-up sent with `Alt+Enter` waits until KnightCode finishes the current task. Aborting returns queued messages to the editor.
154
41
 
155
- ### Project Trust
42
+ Windows Terminal reserves some Alt shortcuts. See [Terminal Setup](terminal-setup.md) for the Windows alternatives.
156
43
 
157
- On interactive startup, knightcode asks before trusting a project folder that contains project-local settings, resources, or project `.agents/skills` and has no saved decision for the folder or a parent folder in `~/.knightcode/agent/trust.json`. Trusting a project allows knightcode to load `.knightcode/settings.json` and `.knightcode` resources, install missing project packages, and execute project extensions.
44
+ ## Change the model or settings
158
45
 
159
- Before the trust decision, knightcode loads only context files, user/global extensions, and CLI `-e` extensions so they can handle the `project_trust` event. Project-local extensions, project package-managed extensions, and project settings are loaded only after the project is trusted. This split also applies when switching to a session from a different cwd whose trust has not been resolved in the current process.
46
+ Type `/` to search the available commands. The commands you will use most often are:
160
47
 
161
- Non-interactive modes (`-p`, `--mode json`, and `--mode rpc`) do not show a trust prompt. Without an applicable saved trust decision, they use `defaultProjectTrust` from global settings: `ask` (default) and `never` ignore those project resources, while `always` trusts them. Pass `--approve`/`-a` or `--no-approve`/`-na` to override project trust for one run.
48
+ - `/model` selects a model. Press `Ctrl+L` to open the same selector.
49
+ - `/thinking` selects how much reasoning the current model uses. Press `Shift+Tab` to cycle through supported levels.
50
+ - `/login` and `/logout` manage provider access.
51
+ - `/settings` changes common preferences.
52
+ - `/tools` turns the [web tools](#web-tools) and the [scratchpad](#scratchpad) off, on for this session, or on by default.
162
53
 
163
- If no extension or saved decision applies, `defaultProjectTrust` controls the fallback behavior. Set it to `"ask"`, `"always"`, or `"never"` in `~/.knightcode/agent/settings.json`, or change it with `/settings`.
54
+ Prompt templates, skills, and extensions can add more commands to the same menu. See [Choose a Model](models.md), [Configuration](configuration.md), or the complete [Slash Commands reference](slash-commands.md).
164
55
 
165
- `knightcode config` and package commands use the same project trust flow, except `knightcode update` never prompts. Pass `--approve` to trust project-local settings for one command or `--no-approve` to ignore them.
56
+ ## Continue or start over
166
57
 
167
- Use `/trust` in interactive mode to save a project trust decision for future sessions, including trust for the immediate parent folder. It writes `~/.knightcode/agent/trust.json` only; the current session is not reloaded, so restart knightcode for changes to take effect.
58
+ KnightCode saves sessions automatically unless session persistence is disabled.
168
59
 
60
+ - `/new` starts a new session.
61
+ - `/resume` opens another saved session.
62
+ - `/name` gives the current session a recognizable name.
63
+ - `/session` shows its file, ID, message count, token usage, and cost.
64
+ - `/undo` goes back to an earlier user message and can restore the files edited after it.
169
65
 
170
- ## Exporting and Sharing Sessions
171
-
172
- Use `/export [file]` to write a session to HTML.
173
-
174
- Use `/share` to upload a private GitHub gist with a shareable HTML link.
175
-
176
- ## CLI Reference
177
-
178
- ```bash
179
- knightcode [options] [--] [@files...] [messages...]
180
- ```
181
-
182
- ### Package Commands
183
-
184
- ```bash
185
- knightcode install <source> [-l] # Install package, -l for project-local
186
- knightcode remove <source> [-l] # Remove package
187
- knightcode uninstall <source> [-l] # Alias for remove
188
- knightcode update [source|self|knightcode] # Update knightcode only, or one package source
189
- knightcode update --all # Update knightcode and packages; reconcile pinned git refs
190
- knightcode update --extensions # Update packages only; reconcile pinned git refs
191
- knightcode update --models # Refresh model catalogs only
192
- knightcode update --self # Update knightcode only
193
- knightcode update --extension <src> # Update one package
194
- knightcode list # List installed packages
195
- knightcode config # Enable/disable package resources
196
- ```
197
-
198
- These commands manage knightcode packages and `knightcode update` can update the knightcode CLI installation. To uninstall knightcode itself, see [Quickstart](quickstart.md#uninstall). `knightcode config` and project package commands accept `--approve`/`--no-approve` to trust or ignore project-local settings for one command. `knightcode update` never prompts for project trust.
199
-
200
- See [KnightCode Packages](packages.md) for package sources and security notes.
66
+ Use `/tree`, `/fork`, or `/clone` when you want to explore another approach without losing existing work. Use `/compact` to reduce the conversation history sent to the model. See [Sessions and Context](sessions.md) for these workflows.
201
67
 
202
- ### Modes
68
+ After leaving KnightCode, run `knightcode --continue` from the same folder to resume its most recent session.
203
69
 
204
- | Flag | Description |
205
- |------|-------------|
206
- | default | Interactive mode |
207
- | `-p`, `--print` | Print response and exit |
208
- | `--mode json` | Output all events as JSON lines; see [JSON mode](json.md) |
209
- | `--mode rpc` | RPC mode over stdin/stdout; see [RPC mode](rpc.md) |
210
- | `--export <in> [out]` | Export a session to HTML |
70
+ ## Run a terminal command
211
71
 
212
- In print mode, knightcode also reads piped stdin and merges it into the initial prompt:
72
+ Prefix a command with `!` to run it and include its output in the conversation:
213
73
 
214
- ```bash
215
- cat README.md | knightcode -p "Summarize this text"
74
+ ```text
75
+ !git status
216
76
  ```
217
77
 
218
- ### Model Options
219
-
220
- | Option | Description |
221
- |--------|-------------|
222
- | `--provider <name>` | Provider, such as `anthropic`, `openai`, or `google` |
223
- | `--model <pattern>` | Model pattern or ID; supports `provider/id` and optional `:<thinking>` |
224
- | `--api-key <key>` | API key, overriding environment variables |
225
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
226
- | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
227
- | `--list-models [search]` | List available models |
228
-
229
- ### Session Options
230
-
231
- | Option | Description |
232
- |--------|-------------|
233
- | `-c`, `--continue` | Continue the most recent session |
234
- | `-r`, `--resume` | Browse and select a session |
235
- | `--session <path\|id>` | Use a specific session file or partial UUID |
236
- | `--fork <path\|id>` | Fork a session file or partial UUID into a new session |
237
- | `--session-dir <dir>` | Custom session storage directory |
238
- | `--no-session` | Ephemeral mode; do not save |
239
- | `--name <name>`, `-n <name>` | Set session display name at startup |
240
-
241
- ### Tool Options
242
-
243
- | Option | Description |
244
- |--------|-------------|
245
- | `--tools <list>`, `-t <list>` | Allowlist specific built-in, extension, and custom tools |
246
- | `--exclude-tools <list>`, `-xt <list>` | Disable specific built-in, extension, and custom tools |
247
- | `--no-builtin-tools`, `-nbt` | Disable built-in tools but keep extension/custom tools enabled |
248
- | `--no-tools`, `-nt` | Disable all tools |
249
-
250
- Built-in tools: `read`, `bash`, `powershell` (Windows), `edit`, `write`, `grep`, `find`, `ls`. The [web tools](#web-tools) `webfetch` and `websearch` are off until enabled with `/tools`.
251
-
252
- ### Resource Options
253
-
254
- | Option | Description |
255
- |--------|-------------|
256
- | `-e`, `--extension <source>` | Load an extension from path, npm, or git; repeatable |
257
- | `--no-extensions` | Disable extension discovery |
258
- | `--skill <path>` | Load a skill; repeatable |
259
- | `--no-skills` | Disable skill discovery |
260
- | `--prompt-template <path>` | Load a prompt template; repeatable |
261
- | `--no-prompt-templates` | Disable prompt template discovery |
262
- | `--theme <path>` | Load a theme; repeatable |
263
- | `--no-themes` | Disable theme discovery |
264
- | `--no-context-files`, `-nc` | Disable `AGENTS.md` and `CLAUDE.md` discovery |
265
-
266
- Combine `--no-*` with explicit flags to load exactly what you need, ignoring settings. Example:
78
+ Use `!!` when you want to run a command without sending its output to the model.
267
79
 
268
- ```bash
269
- knightcode --no-extensions -e ./my-extension.ts
270
- ```
80
+ ## Web Tools
271
81
 
272
- ### Other Options
82
+ Two tools give the agent read access to the web. Both ship disabled; turn them on with `/tools`.
273
83
 
274
- | Option | Description |
275
- |--------|-------------|
276
- | `--system-prompt <text>` | Replace default prompt; context files and skills are still appended |
277
- | `--append-system-prompt <text>` | Append to system prompt |
278
- | `--tui-mode <mode>` | TUI mode: `regular` (default) or experimental `fullscreen` |
279
- | `--use-theme <name[/name]>` | Set the initial interactive theme for this run without changing settings |
280
- | `--verbose` | Force verbose startup |
281
- | `-a`, `--approve` | Trust project-local files for this run |
282
- | `-na`, `--no-approve` | Ignore project-local files for this run |
283
- | `--` | Stop option parsing; remaining arguments are prompts or `@file` inputs |
284
- | `-h`, `--help` | Show help |
285
- | `-v`, `--version` | Show version |
84
+ | Tool | What it does |
85
+ |------|--------------|
86
+ | `webfetch` | Fetches a URL and returns the page as markdown, 400 lines at a time. The agent pages with `offset`/`limit` like `read`, or passes `grep` to get only matching lines. Responses are cached for 15 minutes, capped at 5 MB, and time out after 30 seconds. Private, loopback, and link-local addresses are refused. |
87
+ | `websearch` | Searches the web and returns up to 10 results (default 5) as title, URL, and snippet. DuckDuckGo needs no key but may rate-limit; Brave Search needs an API key. |
286
88
 
287
- In `fullscreen` mode, the transcript scrolls inside the terminal viewport while queued messages, working status, extension widgets, editor, and footer remain fixed at the bottom. Mouse/trackpad input scrolls the region under the pointer; keyboard viewport actions always remain available. Inline images work in terminals that support the Kitty graphics protocol, including Kitty and Ghostty. In iTerm2 they render as text placeholders because its inline-image protocol cannot delete or crop placements during application-owned scrolling. In `regular` mode, knightcode uses the main screen and terminal-owned scrollback, and iTerm2 inline images continue to render normally. Text selection differs between the two modes: fullscreen captures the mouse and owns selection, so dragging copies to the clipboard on release, while regular mode never captures the mouse and leaves both selecting and copying to the terminal emulator. See [Text selection and copy](terminal-setup.md#text-selection-and-copy) for the per-terminal shortcuts, and [Terminal setup](terminal-setup.md) for other terminal-specific settings and workarounds.
89
+ `/tools` lists each tool with its current state; pick one to open its settings panel. **Status** cycles through three states:
288
90
 
289
- Set **TUI mode** in `/settings` to switch between `regular` and `fullscreen` immediately and choose the default for future sessions. **Fullscreen exit output** controls whether exiting fullscreen prints the final transcript or restores the previous screen and prints only the session resume hint.
91
+ | State | Effect |
92
+ |-------|--------|
93
+ | Disabled | The tool is not offered to the model |
94
+ | Enabled for this session | On until knightcode exits, including across `/new`, `/resume`, and `/fork`; nothing is written to disk |
95
+ | Enabled by default | On in every session |
290
96
 
291
- ### File Arguments
97
+ The `websearch` panel adds two rows: **Provider** (`duckduckgo` or `brave`) and **Brave API key**. Choosing Brave without a stored key opens the key prompt at once. Get a key at https://brave.com/search/api/; the free plan is enough. The key is also read from `BRAVE_API_KEY` when none is stored, but the provider only switches to Brave when you pick it. Keys show masked in the panel.
292
98
 
293
- Prefix files with `@` to include them in the message:
99
+ The same changes work without the panel:
294
100
 
295
101
  ```bash
296
- knightcode @prompt.md "Answer this"
297
- knightcode -p @screenshot.png "What's in this image?"
298
- knightcode @code.ts @test.ts "Review these files"
102
+ /tools websearch on # this session
103
+ /tools webfetch always # every session
104
+ /tools webfetch off
299
105
  ```
300
106
 
301
- ### Examples
107
+ Settings are stored in `~/.knightcode/agent/tools.json`, owner-readable only because it can hold the Brave key. `--tools` and `--exclude-tools` still apply: a tool excluded on the command line stays off whatever `/tools` says.
302
108
 
303
- ```bash
304
- # Interactive with initial prompt
305
- knightcode "List all .ts files in src/"
109
+ Fetched pages and search results are marked as untrusted in the tool output so the model treats instructions inside them as data, but treat the tools like any other network access: a fetched page can still influence what the agent does next.
306
110
 
307
- # Non-interactive
308
- knightcode -p "Summarize this codebase"
111
+ ## Scratchpad
309
112
 
310
- # Prompt beginning with a dash
311
- knightcode -p -- "- Summarize these points"
113
+ `/tools scratchpad on` gives each session a private working directory under the system temp directory (`<tmp>/knightcode-<uid>/scratchpad/<session-id>`, or `<tmp>\knightcode\scratchpad\<session-id>` on Windows). The system prompt names it and asks the agent to put throwaway scripts and intermediate output there instead of in your project.
312
114
 
313
- # Non-interactive with piped stdin
314
- cat README.md | knightcode -p "Summarize this text"
115
+ The agent keeps its working notes there in `notes.md`: task list, decisions, `file:line` facts, next steps. After each compaction the first 8 KB of `notes.md` is put back into the context once, so those notes outlive the summary. Open the file to see what the agent is tracking.
315
116
 
316
- # Named one-shot session
317
- knightcode --name "release audit" -p "Audit this repository"
117
+ The scratchpad is off by default. When on, it adds about 60 tokens to the system prompt, which is cached; the notes cost tokens only after a compaction. It is not a tool, so `--tools` and `--exclude-tools` do not affect it. `/fork` starts a new, empty directory, and the operating system clears old ones with the rest of its temp files. If `<tmp>/knightcode-<uid>` already exists but is not a private directory you own, as when another user on a shared machine created it first, the scratchpad stays off and KnightCode reports why.
318
118
 
319
- # Different model
320
- knightcode --provider openai --model gpt-4o "Help me refactor"
119
+ ## Copy, export, or share results
321
120
 
322
- # Model with provider prefix
323
- knightcode --model openai/gpt-4o "Help me refactor"
121
+ Press `Ctrl+X` or run `/copy` to copy the last assistant response. Use `/export` to save the session as HTML or JSONL.
324
122
 
325
- # Model with thinking level shorthand
326
- knightcode --model sonnet:high "Solve this complex problem"
123
+ Use `/share` to upload the session and get a viewer link. With Radius authentication, the artifact is visible to your Radius organization. Otherwise, KnightCode creates a private GitHub gist through the GitHub CLI. Review the session first because it can contain prompts, tool output, file contents, and credentials exposed during the conversation.
327
124
 
328
- # Limit model cycling
329
- knightcode --models "claude-*,gpt-4o"
125
+ ## Adjust the terminal
330
126
 
331
- # Read-only mode
332
- knightcode --tools read,grep,find,ls -p "Review the code"
127
+ Regular mode uses the terminal's normal scrollback. Fullscreen mode keeps the editor and status area fixed while the transcript scrolls within the terminal window. Choose a mode through `/settings` or `--tui-mode`.
333
128
 
334
- # Disable one extension or built-in tool while keeping the rest available
335
- knightcode --exclude-tools ask_question
336
- ```
129
+ Terminal support for mouse input, keyboard shortcuts, and inline images varies. See [Terminal Setup](terminal-setup.md) for platform-specific configuration and [Keybindings](keybindings.md) for every configurable shortcut. Run `/hotkeys` to inspect the shortcuts active in your current session.
337
130
 
338
- ## Design Principles
131
+ ## Collect diagnostic information
339
132
 
340
- KnightCode keeps the core small and pushes workflow-specific behavior into extensions, skills, prompt templates, and packages.
133
+ When troubleshooting terminal rendering or conversation state, run `/debug`. KnightCode writes the rendered terminal lines and current session messages to `knightcode-debug.log` in your [agent directory](configuration.md#agent-directory).
341
134
 
342
- It intentionally does not include built-in MCP, sub-agents, permission popups, plan mode, to-dos, or background bash. You can build or install those workflows as extensions or packages, or use external tools such as containers and tmux.
135
+ Review this file before sharing it. It can contain prompts, model responses, tool output, file contents, and terminal data.
@@ -1,39 +1,65 @@
1
- # Windows Setup
1
+ # Run KnightCode on Windows
2
2
 
3
- KnightCode uses Git Bash by default on Windows. Checked locations (in order):
3
+ Run KnightCode either as a native Windows process or inside Windows Subsystem for Linux (WSL). Native Windows uses Git Bash by default for Bash commands and can optionally expose PowerShell to the model. KnightCode inside WSL uses the Linux environment and its Bash installation.
4
4
 
5
- 1. Custom path from `~/.knightcode/agent/settings.json`
6
- 2. Git Bash (`C:\Program Files\Git\bin\bash.exe`)
7
- 3. `bash.exe` on PATH (Cygwin, MSYS2, WSL)
5
+ Follow the main [Quickstart](quickstart.md) to install and authenticate KnightCode. Use this page to choose and configure its command environment.
8
6
 
9
- For most users, [Git for Windows](https://git-scm.com/download/win) is sufficient.
7
+ ## Choose native Windows or WSL
10
8
 
11
- ## PowerShell Tool
9
+ | Environment | Command environment | Use it when |
10
+ |---|---|---|
11
+ | Native Windows with Git Bash | Git Bash for the built-in `bash` tool and `!` commands | Your files and development tools primarily live on Windows |
12
+ | Native Windows with the `powershell` tool | PowerShell for model tool calls; Bash remains available for `!` commands | The task depends on PowerShell modules or Windows-native commands |
13
+ | WSL | Linux Bash and tools inside the selected WSL distribution | Your files and toolchain already live in Linux or WSL |
12
14
 
13
- The optional `powershell` tool runs commands through `pwsh.exe` when available, otherwise Windows PowerShell. It starts PowerShell with `-NoProfile -NonInteractive -ExecutionPolicy Bypass`. Administrator-enforced execution policies can still take precedence.
15
+ ## Use Git Bash on native Windows
14
16
 
15
- Use `defaultTools` to replace the model-facing `bash` tool:
17
+ For most native Windows users, installing [Git for Windows](https://git-scm.com/download/win) is sufficient.
16
18
 
17
- ```json
18
- {
19
- "defaultTools": ["read", "powershell", "edit", "write"]
20
- }
19
+ KnightCode resolves Bash in this order:
20
+
21
+ 1. `shellPath` from `~/.knightcode/agent/settings.json`
22
+ 2. Git Bash under `Program Files` or `Program Files (x86)`
23
+ 3. `bash.exe` on `PATH`, including Cygwin, MSYS2, or legacy WSL Bash
24
+
25
+ Start KnightCode and enter this command to verify the shell:
26
+
27
+ ```text
28
+ !printf 'Bash is working\n'
21
29
  ```
22
30
 
23
- Or enable both while comparing behavior:
31
+ If KnightCode cannot find Bash, it reports the locations it checked. Install Git for Windows, put another Bash executable on `PATH`, or configure `shellPath`.
32
+
33
+ ## Let the model use PowerShell
34
+
35
+ The optional `powershell` tool runs commands through `pwsh.exe` when available, then falls back to Windows PowerShell. It starts PowerShell with `-NoProfile -NonInteractive -ExecutionPolicy Bypass`. Administrator-enforced execution policies can still take precedence.
36
+
37
+ To replace the model-facing `bash` tool with `powershell`, add this to `~/.knightcode/agent/settings.json`:
24
38
 
25
39
  ```json
26
40
  {
27
- "defaultTools": ["read", "bash", "powershell", "edit", "write"]
41
+ "defaultTools": ["read", "powershell", "edit", "write"]
28
42
  }
29
43
  ```
30
44
 
31
- The `!` and `!!` editor commands still use Bash.
45
+ Restart KnightCode, then ask it to run a harmless PowerShell command. The `!` and `!!` editor commands continue to use Bash. The `powershell` tool is available only when KnightCode runs as a native Windows process.
46
+
47
+ See [Settings](settings.md#tools) for other tool combinations.
48
+
49
+ ## Use a custom Bash executable
32
50
 
33
- ## Custom Bash Path
51
+ Set `shellPath` when Bash is installed somewhere KnightCode does not discover automatically:
34
52
 
35
53
  ```json
36
54
  {
37
55
  "shellPath": "C:\\cygwin64\\bin\\bash.exe"
38
56
  }
39
57
  ```
58
+
59
+ JSON uses backslashes for escape sequences. When you write a Windows path with backslashes, write each backslash twice, as shown above.
60
+
61
+ See [Configure shell commands](shell-aliases.md) for command prefixes, aliases, and the complete shell-resolution behavior.
62
+
63
+ ## Configure Windows Terminal
64
+
65
+ Windows Terminal reserves or rewrites some modified keys. See [Windows Terminal](terminal-setup.md#windows-terminal) to configure `Shift+Enter` and `Alt+Enter`, and [Keybindings](keybindings.md) for KnightCode's Windows and WSL shortcut defaults.
@@ -357,6 +357,9 @@
357
357
  case 'thinking_level_change':
358
358
  parts.push('thinking', entry.thinkingLevel);
359
359
  break;
360
+ case 'context_edit':
361
+ parts.push('context edit', entry.replacement === null ? 'omit' : 'replace', entry.targetId);
362
+ break;
360
363
  }
361
364
 
362
365
  return parts.join(' ').toLowerCase();
@@ -385,7 +388,7 @@
385
388
  }
386
389
 
387
390
  // Apply filter mode
388
- const isSettingsEntry = ['label', 'custom', 'model_change', 'thinking_level_change'].includes(entry.type);
391
+ const isSettingsEntry = ['label', 'custom', 'context_edit', 'model_change', 'thinking_level_change'].includes(entry.type);
389
392
  let passesFilter = true;
390
393
 
391
394
  switch (filterMode) {
@@ -696,6 +699,8 @@
696
699
  return labelHtml + `<span class="tree-muted">[model: ${escapeHtml(entry.modelId)}]</span>`;
697
700
  case 'thinking_level_change':
698
701
  return labelHtml + `<span class="tree-muted">[thinking: ${escapeHtml(entry.thinkingLevel)}]</span>`;
702
+ case 'context_edit':
703
+ return labelHtml + `<span class="tree-muted">[context ${entry.replacement === null ? 'omit' : 'replace'}: ${escapeHtml(entry.targetId)}]</span>`;
699
704
  default:
700
705
  return labelHtml + `<span class="tree-muted">[${escapeHtml(entry.type)}]</span>`;
701
706
  }
package/bin/knightcode CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/knightcode
3
- size: 117581290 bytes
4
- sha256: 55b9ab58d9aa29d2bc21f39a279a44e92cb0f78d4b37bdd91f7907734d5a6d4b
3
+ size: 117790736 bytes
4
+ sha256: e9c9096d0b519543704dee054a87424bf55ea7feddbffc01ba03e06e172e3ff3
package/bin/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knightcodeai/cli",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "KnightCode — a local, BYOK terminal coding agent powered by OpenRouter.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,11 +37,11 @@
37
37
  "test": "vitest --run"
38
38
  },
39
39
  "optionalDependencies": {
40
- "@knightcodeai/cli-linux-x64": "0.9.1",
41
- "@knightcodeai/cli-linux-arm64": "0.9.1",
42
- "@knightcodeai/cli-darwin-x64": "0.9.1",
43
- "@knightcodeai/cli-darwin-arm64": "0.9.1",
44
- "@knightcodeai/cli-win32-x64": "0.9.1"
40
+ "@knightcodeai/cli-linux-x64": "0.9.3",
41
+ "@knightcodeai/cli-linux-arm64": "0.9.3",
42
+ "@knightcodeai/cli-darwin-x64": "0.9.3",
43
+ "@knightcodeai/cli-darwin-arm64": "0.9.3",
44
+ "@knightcodeai/cli-win32-x64": "0.9.3"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@agentclientprotocol/sdk": "1.4.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knightcodeai/cli-linux-x64",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",