@knightcodeai/cli 0.17.4 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CHANGELOG.md +1303 -0
  2. package/README.md +2 -2
  3. package/dist/bundle/chunks/anthropic-messages-A2IH2IY3.js +6 -0
  4. package/dist/bundle/chunks/anthropic.js +101 -0
  5. package/dist/bundle/chunks/azure-openai-responses-XZILQZOG.js +2 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  7. package/dist/bundle/chunks/chunk-253N4337.js +7 -0
  8. package/dist/bundle/chunks/chunk-2QIKI63P.js +108 -0
  9. package/dist/bundle/chunks/chunk-3LX7U45C.js +130 -0
  10. package/dist/bundle/chunks/chunk-4CRI7BMY.js +2 -0
  11. package/dist/bundle/chunks/chunk-57BPR4HF.js +2 -0
  12. package/dist/bundle/chunks/chunk-A5LJINMT.js +2 -0
  13. package/dist/bundle/chunks/chunk-AANBXVWQ.js +2 -0
  14. package/dist/bundle/chunks/chunk-AHB7JV5B.js +2 -0
  15. package/dist/bundle/chunks/chunk-B2FT7RH5.js +2 -0
  16. package/dist/bundle/chunks/chunk-BPNRVFVQ.js +2 -0
  17. package/dist/bundle/chunks/chunk-BRKUE2MD.js +2 -0
  18. package/dist/bundle/chunks/chunk-BXZL5C3N.js +58 -0
  19. package/dist/bundle/chunks/chunk-DGACKL4S.js +30 -0
  20. package/dist/bundle/chunks/chunk-DKOURXGU.js +2 -0
  21. package/dist/bundle/chunks/chunk-DVFCXHT4.js +2 -0
  22. package/dist/bundle/chunks/chunk-ETOMYYZC.js +2 -0
  23. package/dist/bundle/chunks/chunk-FA32X2UJ.js +7 -0
  24. package/dist/bundle/chunks/chunk-FHM6KUY3.js +44 -0
  25. package/dist/bundle/chunks/chunk-FO7CEQB3.js +11 -0
  26. package/dist/bundle/chunks/chunk-FXS5MU6B.js +2 -0
  27. package/dist/bundle/chunks/chunk-HHWP56PR.js +2 -0
  28. package/dist/bundle/chunks/chunk-HSL72VZI.js +2 -0
  29. package/dist/bundle/chunks/chunk-HUQB436V.js +2 -0
  30. package/dist/bundle/chunks/chunk-HWXGL4YB.js +2 -0
  31. package/dist/bundle/chunks/chunk-KQKUEQJA.js +6 -0
  32. package/dist/bundle/chunks/chunk-LROWZ6UF.js +1333 -0
  33. package/dist/bundle/chunks/chunk-MOALMQWH.js +9 -0
  34. package/dist/bundle/chunks/chunk-MXIWLMNT.js +8 -0
  35. package/dist/bundle/chunks/chunk-N6VDWLND.js +2 -0
  36. package/dist/bundle/chunks/chunk-NCIBB66G.js +2 -0
  37. package/dist/bundle/chunks/chunk-NDQ5OW6U.js +2 -0
  38. package/dist/bundle/chunks/chunk-O6JSP6YG.js +6 -0
  39. package/dist/bundle/chunks/chunk-OFST7FDG.js +2 -0
  40. package/dist/bundle/chunks/chunk-SPAUY3RD.js +12 -0
  41. package/dist/bundle/chunks/chunk-UZWP3NHW.js +2 -0
  42. package/dist/bundle/chunks/chunk-V5ANFNKF.js +11 -0
  43. package/dist/bundle/chunks/chunk-VJJ6J35N.js +20 -0
  44. package/dist/bundle/chunks/chunk-ZW7FVRHT.js +31 -0
  45. package/dist/bundle/chunks/cli-DFJTSQI6.js +51 -0
  46. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-6E2UM7IG.js +2 -0
  47. package/dist/bundle/chunks/codemode-worker.js +478 -0
  48. package/dist/bundle/chunks/dist-DKI7Q6GY.js +13 -0
  49. package/dist/bundle/chunks/easter-egg-3d-7O2AHLAQ.js +2 -0
  50. package/dist/bundle/chunks/execute-4CLOTQIS.js +499 -0
  51. package/dist/bundle/chunks/github-copilot.js +2 -0
  52. package/dist/bundle/chunks/google-generative-ai-CSWR3ORZ.js +2 -0
  53. package/dist/bundle/chunks/google-vertex-QIDRFOFB.js +2 -0
  54. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  55. package/dist/bundle/chunks/jiti-loader-BXVX3Y2R.js +21 -0
  56. package/dist/bundle/chunks/jiti-static-loader-NNBCFAO5.js +2 -0
  57. package/dist/bundle/chunks/kimi-coding.js +2 -0
  58. package/dist/bundle/chunks/knightcode-messages-3GNOTMSI.js +8 -0
  59. package/dist/bundle/chunks/lib-IHWMWJDR.js +9 -0
  60. package/dist/bundle/chunks/llama-cpp-classify-HRPRKOZA.js +22 -0
  61. package/dist/bundle/chunks/meta.js +2 -0
  62. package/dist/bundle/chunks/mistral-conversations-46TK5OBA.js +5 -0
  63. package/dist/bundle/chunks/multipart-parser-VTTMF2EO.js +3 -0
  64. package/dist/bundle/chunks/node-7S3GFMOZ.js +16 -0
  65. package/dist/bundle/chunks/node-MAEICQNS.js +2 -0
  66. package/dist/bundle/chunks/openai-chatgpt.js +101 -0
  67. package/dist/bundle/chunks/openai-codex-responses-IT7VEKUU.js +10 -0
  68. package/dist/bundle/chunks/openai-codex.js +101 -0
  69. package/dist/bundle/chunks/openai-completions-LOKIW33V.js +7 -0
  70. package/dist/bundle/chunks/openai-decisions-4F3LWHMG.js +5 -0
  71. package/dist/bundle/chunks/openai-responses-OK36GJXP.js +3 -0
  72. package/dist/bundle/chunks/openrouter-images-ZI7LLZ4Y.js +2 -0
  73. package/dist/bundle/chunks/openrouter.js +101 -0
  74. package/dist/bundle/chunks/radius.js +101 -0
  75. package/dist/bundle/chunks/runtime-IN7ZPKFY.js +2 -0
  76. package/dist/bundle/chunks/src-ETRMT73D.js +4 -0
  77. package/dist/bundle/chunks/typesafe-system-one-J2CJBWEH.js +2 -0
  78. package/dist/bundle/chunks/virtual-modules-7VXI3TVN.js +2 -0
  79. package/dist/bundle/chunks/xai.js +2 -0
  80. package/dist/bundle/cli-runtime.js +3 -0
  81. package/dist/bundle/cli.js +16 -0
  82. package/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  83. package/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  84. package/dist/bundle/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
  85. package/dist/bundle/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
  86. package/dist/bundle/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
  87. package/dist/bundle/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
  88. package/dist/core/export-html/template.css +1015 -0
  89. package/dist/core/export-html/template.html +55 -0
  90. package/dist/core/export-html/template.js +1929 -0
  91. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  92. package/dist/core/export-html/vendor/marked.min.js +78 -0
  93. package/dist/modes/interactive/theme/dark.json +74 -0
  94. package/dist/modes/interactive/theme/light.json +74 -0
  95. package/dist/modes/interactive/theme/system-theme.ts +579 -0
  96. package/dist/modes/interactive/theme/theme-controller.ts +253 -0
  97. package/dist/modes/interactive/theme/theme-schema.ts +145 -0
  98. package/dist/modes/interactive/theme/theme-tokens.ts +145 -0
  99. package/dist/modes/interactive/theme/theme.ts +1076 -0
  100. package/docs/app-server.md +479 -0
  101. package/docs/app-server.schema.json +8128 -0
  102. package/docs/cli-integration.md +106 -0
  103. package/docs/cli.md +393 -0
  104. package/docs/codemode.md +230 -0
  105. package/docs/compaction.md +463 -0
  106. package/docs/configuration.md +48 -0
  107. package/docs/containerization.md +143 -0
  108. package/docs/custom-provider.md +225 -0
  109. package/docs/desktop.md +73 -0
  110. package/docs/docs.json +236 -0
  111. package/docs/environment-variables.md +138 -0
  112. package/docs/extensions.md +420 -0
  113. package/docs/how-knightcode-works.md +49 -0
  114. package/docs/images/doom-extension.png +0 -0
  115. package/docs/images/interactive-mode.png +0 -0
  116. package/docs/images/tree-view.png +0 -0
  117. package/docs/index.md +39 -0
  118. package/docs/json.md +226 -0
  119. package/docs/keybindings.md +197 -0
  120. package/docs/llama-cpp.md +121 -0
  121. package/docs/mcp.md +272 -0
  122. package/docs/message-types.md +279 -0
  123. package/docs/models-configuration.md +187 -0
  124. package/docs/models.md +221 -0
  125. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  126. package/docs/packages.md +129 -0
  127. package/docs/plan-mode.md +121 -0
  128. package/docs/prompt-templates.md +59 -0
  129. package/docs/providers.md +282 -0
  130. package/docs/quickstart.md +128 -0
  131. package/docs/remote.md +87 -0
  132. package/docs/rpc-commands.md +860 -0
  133. package/docs/rpc-extension-ui.md +214 -0
  134. package/docs/rpc.md +193 -0
  135. package/docs/sdk.md +197 -0
  136. package/docs/security.md +99 -0
  137. package/docs/session-format.md +358 -0
  138. package/docs/sessions.md +135 -0
  139. package/docs/settings.md +220 -0
  140. package/docs/shell-aliases.md +93 -0
  141. package/docs/skills.md +93 -0
  142. package/docs/slash-commands.md +78 -0
  143. package/docs/terminal-setup.md +242 -0
  144. package/docs/termux.md +117 -0
  145. package/docs/themes.md +140 -0
  146. package/docs/tmux.md +55 -0
  147. package/docs/tui.md +195 -0
  148. package/docs/usage.md +167 -0
  149. package/docs/virtual-models.md +114 -0
  150. package/docs/windows.md +67 -0
  151. package/examples/README.md +36 -0
  152. package/examples/extensions/README.md +214 -0
  153. package/examples/extensions/auto-commit-on-exit.ts +55 -0
  154. package/examples/extensions/bash-spawn-hook.ts +30 -0
  155. package/examples/extensions/bookmark.ts +50 -0
  156. package/examples/extensions/border-status-editor.ts +151 -0
  157. package/examples/extensions/built-in-tool-renderer.ts +225 -0
  158. package/examples/extensions/claude-rules.ts +89 -0
  159. package/examples/extensions/commands.ts +72 -0
  160. package/examples/extensions/confirm-destructive.ts +60 -0
  161. package/examples/extensions/custom-compaction.ts +118 -0
  162. package/examples/extensions/custom-footer.ts +66 -0
  163. package/examples/extensions/custom-header.ts +73 -0
  164. package/examples/extensions/custom-provider-anthropic/index.ts +617 -0
  165. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  166. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  167. package/examples/extensions/custom-provider-gitlab-duo/index.ts +399 -0
  168. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  169. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  170. package/examples/extensions/debug-provider.ts +90 -0
  171. package/examples/extensions/dirty-repo-guard.ts +56 -0
  172. package/examples/extensions/doom-overlay/README.md +46 -0
  173. package/examples/extensions/doom-overlay/doom/build.sh +152 -0
  174. package/examples/extensions/doom-overlay/doom/doomgeneric_knightcode.c +72 -0
  175. package/examples/extensions/doom-overlay/doom-component.ts +132 -0
  176. package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
  177. package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
  178. package/examples/extensions/doom-overlay/index.ts +74 -0
  179. package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
  180. package/examples/extensions/dynamic-resources/SKILL.md +8 -0
  181. package/examples/extensions/dynamic-resources/dynamic.json +75 -0
  182. package/examples/extensions/dynamic-resources/dynamic.md +5 -0
  183. package/examples/extensions/dynamic-resources/index.ts +15 -0
  184. package/examples/extensions/dynamic-tools.ts +74 -0
  185. package/examples/extensions/entry-renderer.ts +41 -0
  186. package/examples/extensions/event-bus.ts +43 -0
  187. package/examples/extensions/file-trigger.ts +41 -0
  188. package/examples/extensions/git-checkpoint.ts +53 -0
  189. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  190. package/examples/extensions/github-issue-autocomplete.ts +185 -0
  191. package/examples/extensions/gondolin/index.ts +531 -0
  192. package/examples/extensions/gondolin/package-lock.json +185 -0
  193. package/examples/extensions/gondolin/package.json +19 -0
  194. package/examples/extensions/handoff.ts +190 -0
  195. package/examples/extensions/hello.ts +26 -0
  196. package/examples/extensions/hidden-thinking-label.ts +53 -0
  197. package/examples/extensions/inline-bash.ts +94 -0
  198. package/examples/extensions/input-transform-streaming.ts +39 -0
  199. package/examples/extensions/input-transform.ts +43 -0
  200. package/examples/extensions/interactive-shell.ts +196 -0
  201. package/examples/extensions/jev-router.ts +113 -0
  202. package/examples/extensions/mac-system-theme.ts +47 -0
  203. package/examples/extensions/message-renderer.ts +59 -0
  204. package/examples/extensions/minimal-mode.ts +353 -0
  205. package/examples/extensions/modal-editor.ts +85 -0
  206. package/examples/extensions/model-status.ts +31 -0
  207. package/examples/extensions/notify.ts +57 -0
  208. package/examples/extensions/overlay-qa-tests.ts +1450 -0
  209. package/examples/extensions/overlay-test.ts +153 -0
  210. package/examples/extensions/permission-gate.ts +34 -0
  211. package/examples/extensions/pirate.ts +47 -0
  212. package/examples/extensions/plan-mode/README.md +66 -0
  213. package/examples/extensions/plan-mode/index.ts +387 -0
  214. package/examples/extensions/plan-mode/utils.ts +168 -0
  215. package/examples/extensions/preset.ts +436 -0
  216. package/examples/extensions/project-trust.ts +64 -0
  217. package/examples/extensions/prompt-customizer.ts +49 -0
  218. package/examples/extensions/protected-paths.ts +30 -0
  219. package/examples/extensions/provider-payload.ts +18 -0
  220. package/examples/extensions/qna.ts +118 -0
  221. package/examples/extensions/question.ts +278 -0
  222. package/examples/extensions/questionnaire.ts +440 -0
  223. package/examples/extensions/rainbow-editor.ts +88 -0
  224. package/examples/extensions/reload-runtime.ts +37 -0
  225. package/examples/extensions/rpc-demo.ts +118 -0
  226. package/examples/extensions/sandbox/index.ts +321 -0
  227. package/examples/extensions/sandbox/package-lock.json +92 -0
  228. package/examples/extensions/sandbox/package.json +19 -0
  229. package/examples/extensions/send-user-message.ts +97 -0
  230. package/examples/extensions/session-name.ts +27 -0
  231. package/examples/extensions/shutdown-command.ts +63 -0
  232. package/examples/extensions/snake.ts +343 -0
  233. package/examples/extensions/space-invaders.ts +560 -0
  234. package/examples/extensions/ssh.ts +220 -0
  235. package/examples/extensions/status-line.ts +32 -0
  236. package/examples/extensions/structured-output.ts +65 -0
  237. package/examples/extensions/subagent/README.md +177 -0
  238. package/examples/extensions/subagent/agents/planner.md +37 -0
  239. package/examples/extensions/subagent/agents/reviewer.md +35 -0
  240. package/examples/extensions/subagent/agents/scout.md +50 -0
  241. package/examples/extensions/subagent/agents/worker.md +24 -0
  242. package/examples/extensions/subagent/agents.ts +157 -0
  243. package/examples/extensions/subagent/index.ts +1010 -0
  244. package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
  245. package/examples/extensions/subagent/prompts/implement.md +10 -0
  246. package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
  247. package/examples/extensions/summarize.ts +199 -0
  248. package/examples/extensions/system-prompt-header.ts +17 -0
  249. package/examples/extensions/tic-tac-toe.ts +1004 -0
  250. package/examples/extensions/timed-confirm.ts +70 -0
  251. package/examples/extensions/titlebar-spinner.ts +58 -0
  252. package/examples/extensions/todo.ts +294 -0
  253. package/examples/extensions/tool-override.ts +144 -0
  254. package/examples/extensions/tools.ts +146 -0
  255. package/examples/extensions/trigger-compact.ts +50 -0
  256. package/examples/extensions/truncated-tool.ts +195 -0
  257. package/examples/extensions/widget-placement.ts +9 -0
  258. package/examples/extensions/with-deps/index.ts +32 -0
  259. package/examples/extensions/with-deps/package-lock.json +31 -0
  260. package/examples/extensions/with-deps/package.json +22 -0
  261. package/examples/extensions/working-indicator.ts +121 -0
  262. package/examples/extensions/working-message-test.ts +25 -0
  263. package/examples/rpc-client.ts +35 -0
  264. package/examples/rpc-extension-ui.ts +661 -0
  265. package/examples/sdk/01-minimal.ts +26 -0
  266. package/examples/sdk/02-custom-model.ts +49 -0
  267. package/examples/sdk/03-custom-prompt.ts +70 -0
  268. package/examples/sdk/04-skills.ts +55 -0
  269. package/examples/sdk/05-tools.ts +48 -0
  270. package/examples/sdk/06-extensions.ts +94 -0
  271. package/examples/sdk/07-context-files.ts +42 -0
  272. package/examples/sdk/08-prompt-templates.ts +51 -0
  273. package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
  274. package/examples/sdk/10-settings.ts +53 -0
  275. package/examples/sdk/11-sessions.ts +52 -0
  276. package/examples/sdk/12-full-control.ts +74 -0
  277. package/examples/sdk/13-session-runtime.ts +67 -0
  278. package/examples/sdk/14-codemode-mcp.ts +61 -0
  279. package/examples/sdk/README.md +141 -0
  280. package/package.json +15 -15
  281. package/bin/knightcode +0 -62
@@ -0,0 +1,242 @@
1
+ # Configure your terminal
2
+
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
+
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
+
7
+ ## Troubleshooting
8
+
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) |
19
+
20
+ Use `/hotkeys` to inspect KnightCode's active shortcuts. See [Keybindings](keybindings.md) to change them.
21
+
22
+ ## Text Selection and Copy
23
+
24
+ Which side owns a mouse drag depends on the [TUI mode](usage.md#adjust-the-terminal).
25
+
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.
27
+
28
+ In `regular` mode, knightcode never enables mouse reporting, so a drag is the terminal emulator's own selection and knightcode is not involved in copying it. Use the terminal's copy shortcut — `Ctrl+Shift+C` on most Linux and Windows terminals, `Command+C` on macOS — or enable the terminal's copy-on-select option. Dragging alone does not reach the clipboard in terminals where that option is off by default, which includes Windows Terminal (`copyOnSelect` defaults to `false`) and Apple Terminal, which has no such option. Switch to `fullscreen` if you want drag-to-copy without depending on the terminal.
29
+
30
+ ## Kitty
31
+
32
+ Kitty supports the required keyboard protocol without additional configuration.
33
+
34
+ ## iTerm2
35
+
36
+ Regular terminal mode works without additional configuration.
37
+
38
+ ### Fix slow fullscreen scrolling
39
+
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.
41
+
42
+ To change this behavior:
43
+
44
+ 1. Open **iTerm2 > Settings > Advanced**.
45
+ 2. Search for **Trackpad scrolls fast?**.
46
+ 3. Set it to **No**.
47
+
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).
49
+
50
+ ## Apple Terminal
51
+
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`.
53
+
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.
55
+
56
+ ## Ghostty
57
+
58
+ Add this mapping to Ghostty's configuration if `Alt+Backspace` does not work:
59
+
60
+ ```text
61
+ keybind = alt+backspace=text:\x1b\x7f
62
+ ```
63
+
64
+ The configuration file is `~/Library/Application Support/com.mitchellh.ghostty/config` on macOS and `~/.config/ghostty/config` on Linux.
65
+
66
+ Older Claude Code configurations may contain:
67
+
68
+ ```text
69
+ keybind = shift+enter=text:\n
70
+ ```
71
+
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.
73
+
74
+ ### Open links in fullscreen mode
75
+
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.
77
+
78
+ ## WezTerm
79
+
80
+ WezTerm normally reports `Shift+Enter` through xterm extended keys. To enable the Kitty keyboard protocol explicitly, create `~/.wezterm.lua`:
81
+
82
+ ```lua
83
+ local wezterm = require 'wezterm'
84
+ local config = wezterm.config_builder()
85
+ config.enable_kitty_keyboard = true
86
+ return config
87
+ ```
88
+
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:
102
+
103
+ ```lua
104
+ local wezterm = require 'wezterm'
105
+ local config = wezterm.config_builder()
106
+ config.keys = {
107
+ {
108
+ key = 'Enter',
109
+ mods = 'ALT',
110
+ action = wezterm.action.SendString('\x1b[13;3u'),
111
+ },
112
+ }
113
+ return config
114
+ ```
115
+
116
+ ### Position an IME candidate window in WSL
117
+
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.
126
+
127
+ ## Alacritty
128
+
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:
130
+
131
+ ```toml
132
+ [[keyboard.bindings]]
133
+ key = "Enter"
134
+ mods = "Alt"
135
+ chars = "\u001b[13;3u"
136
+ ```
137
+
138
+ Restart Alacritty after changing the file.
139
+
140
+ ## VS Code integrated terminal
141
+
142
+ VS Code 1.109.5 and newer enable the Kitty keyboard protocol in the integrated terminal by default.
143
+
144
+ For an older version, add a `Shift+Enter` terminal binding to `keybindings.json`:
145
+
146
+ ```json
147
+ {
148
+ "key": "shift+enter",
149
+ "command": "workbench.action.terminal.sendSequence",
150
+ "args": { "text": "\u001b[13;2u" },
151
+ "when": "terminalFocus"
152
+ }
153
+ ```
154
+
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`
160
+
161
+ ## Zed integrated terminal
162
+
163
+ Add these bindings to Zed's `keymap.json`:
164
+
165
+ ```json
166
+ {
167
+ "context": "Terminal",
168
+ "bindings": {
169
+ "shift-enter": ["terminal::SendText", "\u001b[13;2u"],
170
+ "ctrl--": ["terminal::SendText", "\u001b[45;5u"],
171
+ "ctrl-alt-]": ["terminal::SendText", "\u001b[93;7u"]
172
+ }
173
+ }
174
+ ```
175
+
176
+ ## Windows Terminal
177
+
178
+ Windows Terminal uses KnightCode's Windows and WSL shortcut defaults. See [Keybindings](keybindings.md) for the complete list.
179
+
180
+ ### Forward Shift+Enter
181
+
182
+ Open Windows Terminal's `settings.json` with `Ctrl+Shift+,` or **Settings > Open JSON file**. Add this object to its `actions` array:
183
+
184
+ ```json
185
+ {
186
+ "command": { "action": "sendInput", "input": "\u001b[13;2u" },
187
+ "keys": "shift+enter"
188
+ }
189
+ ```
190
+
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
194
+
195
+ Windows Terminal binds `Alt+Enter` to fullscreen by default. KnightCode therefore uses `Ctrl+Q` for follow-ups on Windows and WSL.
196
+
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).
198
+
199
+ ## xfce4-terminal and Terminator
200
+
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.
202
+
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.
204
+
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"` |
225
+
226
+ Settings take precedence over environment variables. An unset value or `auto` preserves automatic detection.
227
+
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.
229
+
230
+ ## Program status
231
+
232
+ KnightCode reports its state with the [Program Status Protocol (OSC 7501)](https://www.superlogical.com/rex/docs/build/program-status), so terminals and agent dashboards can show whether it is working, waiting for you, done, or failed:
233
+
234
+ | State | When |
235
+ |---|---|
236
+ | `working` | An agent run or compaction is in progress. The message is the session name. |
237
+ | `blocked` | An extension dialog or login waits for you. The message is the dialog title. |
238
+ | `done` | A run finished. The message is the session name. |
239
+ | `error` | A run ended with an error that is not retried. The message is the first line of the error. |
240
+ | `idle` | KnightCode started, or you cancelled the run. |
241
+
242
+ Reports never contain prompts or model output. KnightCode sends them only after the terminal answers the protocol's support query; tmux and screen do not forward them. Set `KNIGHTCODE_PROGRAM_STATUS=1` to send reports without asking, or `KNIGHTCODE_PROGRAM_STATUS=0` to turn them off.
package/docs/termux.md ADDED
@@ -0,0 +1,117 @@
1
+ # Run KnightCode on Android with Termux
2
+
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
+
5
+ ## Before you begin
6
+
7
+ Install Termux from [GitHub or F-Droid](https://github.com/termux/termux-app#installation). Do not use the deprecated Google Play build.
8
+
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.
10
+
11
+ ## Install KnightCode
12
+
13
+ 1. Update Termux packages:
14
+
15
+ ```bash
16
+ pkg update && pkg upgrade
17
+ ```
18
+
19
+ 2. Install Node.js and Git:
20
+
21
+ ```bash
22
+ pkg install nodejs git
23
+ ```
24
+
25
+ 3. Install KnightCode:
26
+
27
+ ```bash
28
+ npm install -g --ignore-scripts @knightcodeai/cli
29
+ ```
30
+
31
+ 4. Verify the installation:
32
+
33
+ ```bash
34
+ knightcode --version
35
+ ```
36
+
37
+ 5. Open the folder you want to work in and start KnightCode:
38
+
39
+ ```bash
40
+ cd /path/to/working-folder
41
+ knightcode
42
+ ```
43
+
44
+ Continue with the main [Quickstart](quickstart.md#3-choose-a-model) to connect a model and run your first task.
45
+
46
+ ## Access Android shared storage
47
+
48
+ Termux cannot access shared Android storage until you grant permission. Run this once:
49
+
50
+ ```bash
51
+ termux-setup-storage
52
+ ```
53
+
54
+ After approval, Android shared storage is available under `/storage/emulated/0` and through the links Termux creates under `~/storage/`.
55
+
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:
61
+
62
+ ```bash
63
+ pkg install termux-api
64
+ ```
65
+
66
+ Verify the integration:
67
+
68
+ ```bash
69
+ printf 'KnightCode clipboard test' | termux-clipboard-set
70
+ termux-clipboard-get
71
+ ```
72
+
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`:
80
+
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
+ ````
90
+
91
+ Run `/reload` after changing the file during an active session.
92
+
93
+ ## Troubleshooting
94
+
95
+ ### Clipboard integration fails
96
+
97
+ Confirm that you installed both components:
98
+
99
+ 1. The Termux:API Android app from the same source as Termux
100
+ 2. The `termux-api` command-line package
101
+
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.
103
+
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`.
107
+
108
+ ### KnightCode is not found after installation
109
+
110
+ Open a new Termux shell and run:
111
+
112
+ ```bash
113
+ npm prefix -g
114
+ command -v knightcode
115
+ ```
116
+
117
+ Confirm that the global npm binary directory is on `PATH`, then reinstall KnightCode if the package is missing.
package/docs/themes.md ADDED
@@ -0,0 +1,140 @@
1
+ # Customize KnightCode with themes
2
+
3
+ Themes control the colors KnightCode uses in interactive mode and HTML exports. KnightCode includes the `system` theme and the `dark` and `light` themes, warm grays with an orange accent. You can select one theme, follow your terminal's light or dark appearance, or create your own palette.
4
+
5
+ ## Use your terminal's colors
6
+
7
+ The `system` theme is the default. It builds KnightCode's colors from your terminal's theme, so KnightCode matches the terminal instead of bringing its own palette:
8
+
9
+ - KnightCode queries the terminal's default foreground and background colors and its 16 ANSI colors.
10
+ - Each KnightCode color takes its hue from one ANSI color, for example errors from red and links from blue.
11
+ - KnightCode sets each color's lightness so that it stands out from the background by a minimum contrast. Body text keeps at least a 4.5:1 WCAG contrast ratio on the background and every panel.
12
+ - When the terminal switches between light and dark, KnightCode queries the colors again and rebuilds the theme.
13
+
14
+ The theme adapts to what the terminal reports:
15
+
16
+ | Terminal reports | Result |
17
+ |---|---|
18
+ | Background and ANSI colors | Colors from the terminal palette, placed for the actual background. |
19
+ | Background only | KnightCode's own hues, placed for the actual background. |
20
+ | Nothing | ANSI color indices and the terminal's default colors, which the terminal renders itself. Secondary text is faint, and panels have no background color. |
21
+
22
+ KnightCode asks the terminal for its colors when it starts. Terminals usually answer within a few milliseconds, and KnightCode waits at most 100 ms before showing the startup header. If the terminal does not answer in time, KnightCode uses the ANSI color fallback, and it still applies the colors if they arrive later, for example over a slow SSH connection. `system` is a reserved name: a custom theme with that name is ignored.
23
+
24
+ <a id="selecting-a-theme"></a>
25
+
26
+ ## Choose a theme
27
+
28
+ Open `/settings` and select **Theme**. You can use one theme for every terminal appearance or choose separate themes for light and dark terminals.
29
+
30
+ The selection is saved as the `theme` [setting](settings.md#terminal-and-display):
31
+
32
+ ```json
33
+ {
34
+ "theme": "dark"
35
+ }
36
+ ```
37
+
38
+ Without a `theme` setting, KnightCode uses `system`.
39
+
40
+ Automatic mode stores the light theme first and the dark theme second:
41
+
42
+ ```json
43
+ {
44
+ "theme": "light/dark"
45
+ }
46
+ ```
47
+
48
+ KnightCode decides whether the terminal is light or dark from its reported background and foreground colors. If the terminal does not report its background, KnightCode uses the terminal's light/dark notification, then the `COLORFGBG` environment variable, then dark. The same decision picks the theme of a light/dark pair and the appearance of `system`. 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.
49
+
50
+ Use `--use-theme` to choose the initial theme for one invocation without changing the saved setting:
51
+
52
+ ```bash
53
+ knightcode --use-theme light
54
+ knightcode --use-theme light/dark
55
+ ```
56
+
57
+ See [CLI resources](cli.md#resources) for the command-line option.
58
+
59
+ ## Create a custom theme
60
+
61
+ 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://knightcode.dev/schemas/theme.schema.json). The built-in themes use OKHSL colors, with variables for colors that several roles share, so you can adjust a hue, saturation, or lightness directly.
62
+
63
+ 1. Save the file as `<agent-dir>/themes/my-theme.json`. The agent directory defaults to `~/.knightcode/agent`.
64
+ 2. Set its `name` to `my-theme`.
65
+ 3. Change values in `vars` and `colors`.
66
+ 4. Select `my-theme` through `/settings`.
67
+
68
+ 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.
69
+
70
+ ## Understand the theme file
71
+
72
+ | Property | Required | Responsibility |
73
+ |---|---|---|
74
+ | `$schema` | No | Enables editor validation and completion against KnightCode's published schema. |
75
+ | `name` | Yes | Identifies the theme in selectors and settings. It must be unique, cannot contain `/`, and cannot be `system`. |
76
+ | `appearance` | No | `"dark"` or `"light"`: the background the theme is designed for. KnightCode detects it from the theme colors when omitted. |
77
+ | `vars` | No | Defines reusable color values. Variables can reference other variables. |
78
+ | `colors` | Yes | Assigns colors to terminal UI roles. The schema identifies required and optional roles. |
79
+ | `export` | No | Overrides page and panel backgrounds in HTML exports. |
80
+
81
+ Theme objects are strict: only documented top-level fields and color tokens are accepted. Define reusable custom colors under `vars`; custom keys under `colors` or `export` and additional top-level metadata are rejected.
82
+
83
+ A color can be written in six forms:
84
+
85
+ | Form | Example | Meaning |
86
+ |---|---|---|
87
+ | RGB hexadecimal | `"#0af"` or `"#00aaff"` | A three- or six-digit sRGB color. |
88
+ | OKLCH | `"oklch(62% 0.1 200)"` | Perceptual lightness, chroma, and hue. |
89
+ | OKHSL | `"okhsl(250 60% 55%)"` | Hue, saturation, and lightness. Saturation is relative to the most the sRGB gamut allows at that hue and lightness, so every value is in gamut and equal saturation looks equally colorful. |
90
+ | 256-color index | `39` | An ANSI palette index from `0` through `255`. |
91
+ | Variable reference | `"primary"` | The value of an entry in `vars`. |
92
+ | Terminal default | `""` | The terminal's default foreground or background color. |
93
+
94
+ Terminal default colors render as the terminal's own colors. Where KnightCode needs a concrete value, such as HTML export or extension color math, it uses the default colors the terminal reports, or a black or white guess based on the theme's appearance.
95
+
96
+ KnightCode resolves chained variable references. A missing variable or circular reference makes the theme invalid. KnightCode uses truecolor when available, gamut-maps OKLCH to sRGB, and approximates colors for 256-color terminals. HTML exports convert OKHSL values to hexadecimal because CSS does not support them. If colors differ from their source values, check your terminal's truecolor detection and contrast settings. See [Configure Your Terminal](terminal-setup.md#override-detected-capabilities).
97
+
98
+ Use the [theme JSON schema](https://knightcode.dev/schemas/theme.schema.json) for the exact properties, required colors, and accepted value types.
99
+
100
+ KnightCode reports invalid theme files during startup and `/reload`.
101
+
102
+ ## Find the color to change
103
+
104
+ Theme colors describe interface roles rather than individual components. Use these groups to find the relevant part of the schema:
105
+
106
+ | Area | Color names |
107
+ |---|---|
108
+ | General interface | `accent`, `border*`, `text`, `muted`, `dim`, `success`, `error`, `warning` |
109
+ | Selection and fullscreen | `selectedBg`, `searchMatch*`, `scrollbar*` |
110
+ | Messages | `userMessage*`, `customMessage*`, `thinkingText` |
111
+ | Tool execution | `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`, `toolTitle`, `toolOutput` |
112
+ | Markdown | `md*` |
113
+ | Tool diffs | `toolDiff*`; added and removed rows are tinted with `toolSuccessBg` and `toolErrorBg` |
114
+ | Syntax highlighting | `syntax*` |
115
+ | Editor modes | `border`, mixed 35% toward `text` for contrast, frames the prompt at every thinking level; `bashMode` frames shell input |
116
+ | HTML export | `export.pageBg`, `export.cardBg`, `export.infoBg` |
117
+
118
+ The schema is the format reference. The built-in themes provide complete values that you can copy and adjust.
119
+
120
+ The `thinking*` border colors are no longer used and can be removed from custom themes. Extensions that
121
+ styled the prompt border with `getThinkingBorderColor(level)` should use `getEditorBorderColor()`.
122
+
123
+ Four colors are optional and inherit another color when omitted:
124
+
125
+ | Optional color | Fallback |
126
+ |---|---|
127
+ | `scrollbarTrack` | `muted` |
128
+ | `scrollbarThumb` | `text` |
129
+ | `searchMatchBg` | `selectedBg` |
130
+ | `searchMatchText` | `text` |
131
+
132
+ If `export` colors are omitted, KnightCode derives HTML page and panel backgrounds from `userMessageBg`.
133
+
134
+ ## Load a theme from a project or package
135
+
136
+ Place a project theme in `.knightcode/themes/`. Project themes load only after [project trust](security.md#understand-project-trust) is granted.
137
+
138
+ 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).
139
+
140
+ Each loaded theme must have a unique name. KnightCode reports duplicate names as resource collisions.
package/docs/tmux.md ADDED
@@ -0,0 +1,55 @@
1
+ # Run KnightCode in tmux
2
+
3
+ KnightCode works inside tmux, but tmux can report `Shift+Enter`, `Ctrl+Enter`, and plain `Enter` as the same key. Enable extended keys so KnightCode can distinguish them.
4
+
5
+ ## Check your tmux version
6
+
7
+ ```bash
8
+ tmux -V
9
+ ```
10
+
11
+ For tmux 3.5 or newer, use the recommended CSI-u configuration below. For tmux 3.2 through 3.4, use the older-version configuration.
12
+
13
+ ## Enable extended keys in tmux 3.5 or newer
14
+
15
+ Add these lines to `~/.tmux.conf`:
16
+
17
+ ```tmux
18
+ set -g extended-keys on
19
+ set -g extended-keys-format csi-u
20
+ ```
21
+
22
+ KnightCode requests extended-key reporting when the terminal does not provide the Kitty keyboard protocol directly. CSI-u is the most reliable format for forwarding modified keys through tmux.
23
+
24
+ ## Restart tmux
25
+
26
+ The configuration applies to the tmux server. To guarantee that it is active, close your tmux sessions and start a new server.
27
+
28
+ If you choose to stop the server from the command line, save your work first. This command terminates every session managed by that server:
29
+
30
+ ```bash
31
+ tmux kill-server
32
+ tmux
33
+ ```
34
+
35
+ ## Verify modified keys
36
+
37
+ Start KnightCode inside the new tmux session and check that:
38
+
39
+ 1. `Shift+Enter` inserts a new line in the editor.
40
+ 2. `Enter` submits the prompt.
41
+ 3. `Alt+Enter` queues a follow-up on macOS and Linux. Windows and WSL use `Ctrl+Q` by default.
42
+
43
+ If these keys still behave like plain `Enter`, verify that the terminal outside tmux can report modified keys. See [Configure your terminal](terminal-setup.md).
44
+
45
+ ## Use tmux 3.2 through 3.4
46
+
47
+ These versions support extended keys but not `extended-keys-format csi-u`. Add only:
48
+
49
+ ```tmux
50
+ set -g extended-keys on
51
+ ```
52
+
53
+ KnightCode supports the xterm `modifyOtherKeys` format used by these versions. Restart tmux and repeat the verification steps.
54
+
55
+ For older versions, upgrade tmux or use KnightCode outside tmux rather than relying on modified Enter shortcuts.