@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,121 @@
1
+ # Plan mode
2
+
3
+ Plan mode separates investigation from implementation. Enter with `/plan`, or
4
+ send a task with `/plan <task>`. The model explores, asks about unresolved
5
+ trade-offs, and submits a complete Markdown plan. It cannot approve its own
6
+ plan. Sessions that never use planning gain no planning instructions or tool
7
+ declarations.
8
+
9
+ ## Commands
10
+
11
+ | Command | Behavior |
12
+ |---|---|
13
+ | `/plan` | Enter planning; when already planning, review the latest draft |
14
+ | `/plan <task>` | Enter if needed and run the task as a planning prompt |
15
+ | `/plan off` | Leave planning without discarding the draft |
16
+ | `/plan approve [N [note]]` | Approve the latest revision, or exactly revision N, and implement in this session; a note after N is passed to the model |
17
+ | `/plan approve fresh [N [note]]` | Approve and implement in a fresh CLI session linked to the planning transcript |
18
+ | `--plan` | Enter planning on initial startup only, including when initially opening a saved session |
19
+
20
+ All commands require an idle session without queued messages. Finish or
21
+ interrupt the current turn and resolve pending input first. An explicit revision
22
+ that is no longer current is refused; run `/plan` to review again.
23
+
24
+ Without a draft, `/plan` reports “No plan submitted yet; send a task to continue
25
+ planning.” It opens no picker and starts no model request. Approval without a
26
+ draft reports “No plan to approve.” Typing a message while planning requests a
27
+ revision; it is not approval.
28
+
29
+ ## What is enforced
30
+
31
+ Planning permits model-issued calls to `read`, `grep`, `find`, `ls`, `webfetch`,
32
+ `websearch`, `bash`, `powershell`, `ask_user`, and `submit_plan`. Entering plan
33
+ mode turns on `webfetch` and `websearch` unless they are turned off with
34
+ `/tools`; like the other planning tools, they stay on afterwards. Every other
35
+ tool is blocked, including file edits, MCP tools regardless of their read-only
36
+ hints, custom tools, subagents, codemode, and tool search. Nested tool calls
37
+ pass through the same gate. The planning instructions name only the tools the
38
+ session has.
39
+
40
+ Shell commands are not checked. The model is told to run only commands that
41
+ inspect, but a command can still change files. User-started `!` commands are
42
+ not gated.
43
+
44
+ This is not an operating-system sandbox. KnightCode still writes session data,
45
+ and installed extensions remain trusted code that can access files directly.
46
+ The planning gate runs before KnightCode's built-in classifier gate. User and project extensions load first, so their handlers may
47
+ run before it. Another extension registering `/plan`, `--plan`, or either
48
+ planning tool replaces the built-in implementation.
49
+
50
+ ## Questions, submission, and review
51
+
52
+ Questions offer two to four choices, recommended first, plus a free-text answer.
53
+ The TUI shows each option's description. RPC clients receive `select` and
54
+ `input` dialogs. Cancelling a question interrupts the run, like aborting it.
55
+ Without UI, the model takes the recommended choice and records the decision
56
+ under Assumptions.
57
+
58
+ A submitted plan contains the goal, specific changes and paths, verification
59
+ commands, and assumptions. Each submission replaces the complete draft and
60
+ increments its revision. Successful submission ends the run, including a mixed
61
+ tool-call batch; executable sibling calls are blocked. Queued user input is
62
+ preserved, not automatically run after submission.
63
+
64
+ The plan appears once in the transcript, in the submission's tool card. The TUI
65
+ then opens review below it, in the same picker as questions: Implement,
66
+ Implement in a fresh session, Keep planning, or Exit planning, plus **Revise the
67
+ plan**, which takes your feedback as the next planning message. Tab adds a note
68
+ to the highlighted choice; on an implement choice it is sent with the
69
+ approval, and on Keep planning it is sent as feedback. Escape keeps planning. Review does not open automatically on resume. Session replacement, tree navigation, or a new run cancels an open
70
+ picker. An action rechecks the shown revision before changing state.
71
+
72
+ RPC reports a submission notification; `/plan` opens its review selection.
73
+ JSON mode adds no extra output:
74
+ the submission tool-call events contain the Markdown.
75
+
76
+ ## Print mode
77
+
78
+ ```sh
79
+ knightcode -p --plan "Investigate the cache invalidation bug"
80
+ knightcode -p "/plan Investigate the cache invalidation bug"
81
+ knightcode --session <path-or-id> -p "/plan approve"
82
+ ```
83
+
84
+ A successful planning run prints exactly the submitted Markdown. There is no
85
+ automatic headless approval. Command-triggered planning and implementation wait
86
+ for the complete run before print mode exits. Notices and refusals use stderr,
87
+ not stdout.
88
+
89
+ Approval is saved before same-session implementation begins. If dispatch
90
+ fails, the approval remains saved. Fresh handoff seeds the approved draft in a
91
+ new session, preserves the selected model and reasoning level, and dispatches
92
+ the complete plan through the replacement session's input handlers. Cancelling
93
+ the switch leaves the original planning state untouched. The original
94
+ transcript remains resumable.
95
+
96
+ ## Persistence and configuration
97
+
98
+ Draft, mode, and approved revision follow the selected session branch. Exit and
99
+ approval retain the draft. Entering a new planning cycle clears approval while
100
+ retaining the previous draft; revisions continue on that branch. New sessions
101
+ start off. Resume, reload, fork, and tree navigation restore saved state rather
102
+ than reapplying `--plan`.
103
+
104
+ Planning activates `ask_user`, `submit_plan`, and any available `read`,
105
+ `grep`, `find`, and `ls` tools in one initialization checkpoint. The loadout is
106
+ kept after exit or approval. Later transitions append messages without rewriting
107
+ earlier instructions or changing the tool declarations.
108
+
109
+ `--tools` must allow both planning tools; `--exclude-tools` must not exclude
110
+ one, and `--no-tools` is incompatible. Codemode `only` mode with active codemode
111
+ is also incompatible because it hides the direct read tools. Use
112
+ `codemode.mode: "on"` instead. Entry refuses before changing state or tools.
113
+ Restoring incompatible or malformed planning state fails closed: startup or
114
+ reload reports an error and cannot make provider requests until corrected.
115
+ An incompatible tree target is cancelled before navigation.
116
+
117
+ Compaction appends a frozen recovery message containing the planning rules and
118
+ current draft, or the pinned approved plan. Overflow retries temporarily append
119
+ the same message at the request tail until it is persisted. Later revisions
120
+ never rewrite that recovery. See [Session File Format](session-format.md) for
121
+ the stored snapshots and messages.
@@ -0,0 +1,59 @@
1
+ # Prompt Templates
2
+
3
+ Prompt templates turn Markdown files into reusable `/` commands. Use one when you want to reuse the same prompt without adding executable behavior or a larger set of supporting instructions.
4
+
5
+ A template can accept arguments and appear in command completion. KnightCode can load templates from personal configuration, project configuration, an explicit path, or a KnightCode package. Project configuration loads only after project trust is granted.
6
+
7
+ ## Create a template
8
+
9
+ Create `~/.knightcode/agent/prompts/review.md`:
10
+
11
+ ```markdown
12
+ ---
13
+ description: Review staged git changes
14
+ argument-hint: "[focus]"
15
+ ---
16
+ Review the staged changes. Focus on ${1:-correctness, security, and error handling}.
17
+ ```
18
+
19
+ The filename becomes the command name, so this template is available as `/review`. The `description` appears in command completion. If it is omitted, KnightCode uses the first non-empty line.
20
+
21
+ `argument-hint` is optional. Use `<angle brackets>` for required arguments and `[square brackets]` for optional arguments.
22
+
23
+ Run `/reload` after adding or changing a template in an active session.
24
+
25
+ <a id="invoke-a-template"></a>
26
+
27
+ ## Use a template
28
+
29
+ Type the template command in the editor:
30
+
31
+ ```text
32
+ /review
33
+ /review concurrency
34
+ ```
35
+
36
+ KnightCode expands the template before the resulting text enters the agent. Extensions receive the raw input first through the `input` event unless an extension command with the same name handles it.
37
+
38
+ Templates support these substitutions:
39
+
40
+ | Syntax | Result |
41
+ |---|---|
42
+ | `$1`, `$2`, … | One positional argument |
43
+ | `$@` or `$ARGUMENTS` | All arguments joined with spaces |
44
+ | `${1:-default}` | First argument, or a default value |
45
+ | `${@:-default}` | All arguments, or a default value |
46
+ | `${@:N}` | Arguments starting at position `N` |
47
+ | `${@:N:L}` | `L` arguments starting at position `N` |
48
+
49
+ Arguments follow shell-like quoting, so `/review "API compatibility"` supplies one argument containing a space.
50
+
51
+ <a id="choose-where-it-loads"></a>
52
+
53
+ ## Add it to KnightCode
54
+
55
+ Place the template in your user or project prompt directory. Conventional prompt directories load direct `.md` children only.
56
+
57
+ Settings and packages can select nested Markdown files; a package manifest can narrow discovery with explicit paths and globs. See [Settings](settings.md#resources) and [KnightCode Packages](packages.md) for these options.
58
+
59
+ Project templates become commands in the editor after trust is granted. Review their content before trusting an unfamiliar project. See [Security](security.md#understand-project-trust).
@@ -0,0 +1,282 @@
1
+ # Providers
2
+
3
+ Most hosted providers support one or both of these authentication methods:
4
+
5
+ - Sign in through a browser or device flow backed by OAuth.
6
+ - Provide an API key.
7
+
8
+ Use `/login [provider]` to see the methods supported by a provider. Amazon Bedrock and Google Vertex AI can also use ambient cloud credentials.
9
+
10
+ ## Authenticate interactively
11
+
12
+ Run `/login` and select a provider. KnightCode guides you through its OAuth or API-key flow and saves the resulting credential in [`auth.json`](configuration.md#agent-directory).
13
+
14
+ On a remote or headless machine, an OAuth callback may not reach the local process. When prompted, paste the final redirect URL or authorization code back into KnightCode.
15
+
16
+ Run `/logout` and select a provider to remove its stored credential. This does not unset environment variables, remove authentication from `models.json`, or revoke the credential at the provider.
17
+
18
+ `auth.json` can contain API keys and OAuth tokens. Keep it private and do not commit it.
19
+
20
+ ## Check subscription usage
21
+
22
+ Run `/usage` in the interactive terminal to see remaining allowance and reset
23
+ times reported by connected Claude (`anthropic`), OpenAI Codex (legacy)
24
+ (`openai-codex`) and Grok (`xai`) subscription sign-ins. For Grok, run `/login xai`
25
+ and choose "Sign in with SuperGrok or X Premium". The figures cover the whole
26
+ account, not just the current KnightCode session. Other subscription sign-ins,
27
+ including the current `openai` ChatGPT sign-in, are listed as unsupported.
28
+
29
+ Claude shows extra usage first. KnightCode draws from extra usage rather than
30
+ Claude's plan limits. The extra-usage percentage is account-wide and includes
31
+ usage outside KnightCode; it does not measure this client's consumption alone.
32
+ The plan windows are shown only for reference. Codex windows describe the plan
33
+ allowance. Accounts with purchased credits can keep working at 0% remaining.
34
+
35
+ Grok shows the weekly or monthly credit pool and, when reported, the Grok Build
36
+ and API shares. These product lines are shares of the same pool, not separate
37
+ allowances. Accounts with purchased credits or pay-as-you-go can keep working
38
+ at 0% remaining. An xAI API key is billed separately and is not shown.
39
+
40
+ `unavailable` means the provider did not report a valid value. A window whose
41
+ reset has passed asks you to run `/usage` again instead of assuming the allowance
42
+ has refilled. Each opening fetches once; there is no polling or Refresh key.
43
+ Rate-limited providers are not requested again until their cooldown expires.
44
+
45
+ The panel is read-only: it never buys credits or changes provider settings.
46
+ It is available only in the interactive terminal, not RPC, print, JSON, or IDE
47
+ engine sessions. It uses your configured credential store and the existing
48
+ OAuth refresh path. Usage requests go only to the providers' fixed usage
49
+ endpoints, not a configured model endpoint.
50
+
51
+ Disable it with `"extensions": ["-builtin:usage"]` in settings, or disable all
52
+ extensions with `--no-extensions`.
53
+
54
+ ## Use an API key from the environment
55
+
56
+ Environment variables are useful in CI and anywhere KnightCode should not store the key. Set the variable before starting KnightCode:
57
+
58
+ ```bash
59
+ export ANTHROPIC_API_KEY=sk-ant-...
60
+ knightcode
61
+ ```
62
+
63
+ This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [Provider Specific Config](#provider-specific-config).
64
+
65
+ | Provider | Environment variable |
66
+ |---|---|
67
+ | Anthropic | `ANTHROPIC_API_KEY` |
68
+ | AgentRouter | `AGENTROUTER_API_KEY` |
69
+ | Ant Ling | `ANT_LING_API_KEY` |
70
+ | OpenAI | `OPENAI_API_KEY` |
71
+ | DeepSeek | `DEEPSEEK_API_KEY` |
72
+ | NVIDIA NIM | `NVIDIA_API_KEY` |
73
+ | Google Gemini | `GEMINI_API_KEY` |
74
+ | GitHub Copilot | `COPILOT_GITHUB_TOKEN` |
75
+ | Mistral | `MISTRAL_API_KEY` |
76
+ | Groq | `GROQ_API_KEY` |
77
+ | Cerebras | `CEREBRAS_API_KEY` |
78
+ | xAI | `XAI_API_KEY` |
79
+ | OpenRouter | `OPENROUTER_API_KEY` |
80
+ | Vercel AI Gateway | `AI_GATEWAY_API_KEY` |
81
+ | ZAI Coding Plan (Global) | `ZAI_API_KEY` |
82
+ | ZAI Coding Plan (China) | `ZAI_CODING_CN_API_KEY` |
83
+ | OpenCode Zen and Go | `OPENCODE_API_KEY` |
84
+ | Radius | `RADIUS_API_KEY` |
85
+ | TypeSafe ([classifier models](models.md#use-classifier-models)) | `TYPESAFE_API_KEY` |
86
+ | Hugging Face | `HF_TOKEN` |
87
+ | Fireworks | `FIREWORKS_API_KEY` |
88
+ | Together AI | `TOGETHER_API_KEY` |
89
+ | Baseten | `BASETEN_API_KEY` |
90
+ | Kimi For Coding | `KIMI_API_KEY` |
91
+ | Meta | `META_API_KEY` |
92
+ | MiniMax | `MINIMAX_API_KEY` |
93
+ | MiniMax (China) | `MINIMAX_CN_API_KEY` |
94
+ | Moonshot AI (Global and China) | `MOONSHOT_API_KEY` |
95
+ | Qwen Token Plan and Individual | `QWEN_TOKEN_PLAN_API_KEY` |
96
+ | Qwen Token Plan (China) | `QWEN_TOKEN_PLAN_CN_API_KEY` |
97
+ | Xiaomi MiMo | `XIAOMI_API_KEY` |
98
+ | Xiaomi MiMo Token Plan (China) | `XIAOMI_TOKEN_PLAN_CN_API_KEY` |
99
+ | Xiaomi MiMo Token Plan (Amsterdam) | `XIAOMI_TOKEN_PLAN_AMS_API_KEY` |
100
+ | Xiaomi MiMo Token Plan (Singapore) | `XIAOMI_TOKEN_PLAN_SGP_API_KEY` |
101
+
102
+ Anthropic also recognizes `ANTHROPIC_OAUTH_TOKEN` as an API credential and `ANTHROPIC_AUTH_TOKEN` as bearer authentication.
103
+
104
+ With no key or token set, Anthropic uses workload identity federation when `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID` and `ANTHROPIC_IDENTITY_TOKEN_FILE` are set: the Anthropic SDK exchanges the identity token for a short-lived access token and refreshes it itself (re-reading the identity token file, so keep that file fresh for long sessions). `ANTHROPIC_SERVICE_ACCOUNT_ID` and `ANTHROPIC_WORKSPACE_ID` are passed through when set.
105
+
106
+ ## Load an API key from a command
107
+
108
+ To use a secret manager without writing the resolved key to disk, set a provider's `key` in `auth.json` to a command prefixed with `!`:
109
+
110
+ ```json
111
+ {
112
+ "anthropic": {
113
+ "type": "api_key",
114
+ "key": "!security find-generic-password -ws 'anthropic'"
115
+ }
116
+ }
117
+ ```
118
+
119
+ KnightCode runs the command when the key is first needed and caches its standard output for the process lifetime. Empty output, a timeout, or a nonzero exit leaves the key unresolved until KnightCode restarts.
120
+
121
+ ## Provider Specific Config
122
+
123
+ The providers below have additional setup, need additional settings, or can use credentials supplied by their platform.
124
+
125
+ A stored API-key credential can include an `env` object. Its values take priority over the process environment for that provider:
126
+
127
+ ```json
128
+ {
129
+ "cloudflare-workers-ai": {
130
+ "type": "api_key",
131
+ "key": "...",
132
+ "env": {
133
+ "CLOUDFLARE_ACCOUNT_ID": "account-id"
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### Radius
140
+
141
+ Radius is a service crafted for KnightCode by the builders of KnightCode, Earendil Works. It provides a customizable AI gateway with organization-level controls and analytics built in, and artifacts for sharing what you create with KnightCode.
142
+
143
+ To get started, run `/login radius` in KnightCode. This adds Radius as a provider, and its models appear in `/model` like any other provider's.
144
+
145
+ Radius also has an MCP server, so KnightCode can manage Radius for you.
146
+
147
+ Radius is currently in early alpha and evolving quickly. See [radius.earendil.com](https://radius.earendil.com) for more.
148
+
149
+ Radius authentication uses its gateway catalog and caches refreshed model metadata for later offline startup. A custom Radius gateway configured in `models.json` uses its own catalog rather than inheriting the public `radius.pi.dev` catalog.
150
+
151
+ ### OpenRouter
152
+
153
+ Authenticate with `/login openrouter` or `OPENROUTER_API_KEY`.
154
+
155
+ With a key, KnightCode lists only the OpenRouter chat models that key may use, with the key's context size, max output, and prices. These come from OpenRouter's `/models/user` endpoint and reflect guardrails and provider restrictions set in OpenRouter. Image and classifier models are not filtered.
156
+
157
+ KnightCode refreshes the list in the background at startup in interactive mode, when `/model` opens, after `/login`, and on `knightcode update --models`. The last list is saved and used offline and in `knightcode -p` and RPC mode. After switching keys outside `/login`, the previous key's list stays until the next refresh.
158
+
159
+ Regional endpoints filter models to their region. To use one, set the base URL in [`models.json`](models.md#configure-a-compatible-endpoint):
160
+
161
+ ```json
162
+ {
163
+ "providers": {
164
+ "openrouter": { "baseUrl": "https://us.openrouter.ai/api/v1" }
165
+ }
166
+ }
167
+ ```
168
+
169
+ If the base URL rejects the key at `/models/user` or does not have that endpoint, for example a proxy configured as the OpenRouter base URL, KnightCode lists every OpenRouter model.
170
+
171
+ ### Azure OpenAI
172
+
173
+ The provider ID is `azure` (formerly `azure-openai-responses`). Use it as the key in `auth.json`, `models.json`, and `settings.json`, and in model references such as `--model azure/gpt-5.4`.
174
+
175
+ The `azure` provider serves OpenAI models through the Responses API and Microsoft Foundry models through Chat Completions, such as `azure/deepseek-v4-pro`.
176
+
177
+ Set an API key plus either a base URL or resource name:
178
+
179
+ ```bash
180
+ export AZURE_OPENAI_API_KEY=...
181
+ export AZURE_OPENAI_BASE_URL=https://your-resource.ai.azure.com
182
+ # Or:
183
+ export AZURE_OPENAI_RESOURCE_NAME=your-resource
184
+ ```
185
+
186
+ Resource root URLs under `ai.azure.com`, `cognitiveservices.azure.com`, and `openai.azure.com` are normalized to the OpenAI API path.
187
+
188
+ KnightCode sends the model ID as the deployment name. If a deployment has a different name, map it with `AZURE_OPENAI_DEPLOYMENT_NAME_MAP`. The map applies to both the Responses API and Foundry Chat Completions:
189
+
190
+ ```bash
191
+ export AZURE_OPENAI_DEPLOYMENT_NAME_MAP=gpt-5.4=my-gpt-deployment,deepseek-v4-pro=my-deepseek
192
+ ```
193
+
194
+ `AZURE_OPENAI_API_VERSION` overrides the API version for OpenAI models (default `v1`).
195
+
196
+ To use a Foundry model that KnightCode does not include, add it under `azure` in [`models.json`](models.md#configure-a-compatible-endpoint) with `api: "openai-completions"`. Custom models require a `baseUrl`; `AZURE_OPENAI_BASE_URL` and `AZURE_OPENAI_RESOURCE_NAME` take priority over it when set:
197
+
198
+ ```json
199
+ {
200
+ "providers": {
201
+ "azure": {
202
+ "baseUrl": "https://your-resource.services.ai.azure.com",
203
+ "models": [
204
+ { "id": "your-deployment", "api": "openai-completions" }
205
+ ]
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ ### Amazon Bedrock
212
+
213
+ Bedrock can use a bearer token or an ambient AWS credential source:
214
+
215
+ ```bash
216
+ # Named profile
217
+ export AWS_PROFILE=your-profile
218
+
219
+ # IAM keys
220
+ export AWS_ACCESS_KEY_ID=AKIA...
221
+ export AWS_SECRET_ACCESS_KEY=...
222
+ # Required for temporary credentials
223
+ export AWS_SESSION_TOKEN=...
224
+
225
+ # Bedrock bearer token
226
+ export AWS_BEARER_TOKEN_BEDROCK=...
227
+
228
+ # Region, when not supplied by the profile or AWS SDK configuration
229
+ export AWS_REGION=us-west-2
230
+ # AWS_DEFAULT_REGION is also supported
231
+ ```
232
+
233
+ KnightCode also supports ECS task credentials and IRSA through the standard `AWS_CONTAINER_CREDENTIALS_*` and `AWS_WEB_IDENTITY_TOKEN_FILE` variables.
234
+
235
+ ### Cloudflare AI Gateway
236
+
237
+ The gateway requires a token, account ID, and gateway ID:
238
+
239
+ ```bash
240
+ export CLOUDFLARE_API_KEY=...
241
+ export CLOUDFLARE_ACCOUNT_ID=...
242
+ export CLOUDFLARE_GATEWAY_ID=...
243
+ ```
244
+
245
+ The account and gateway IDs can come from the process environment or the credential's `env` object in `auth.json`.
246
+
247
+ `CLOUDFLARE_API_KEY` authenticates KnightCode to the gateway. Upstream access can use Cloudflare unified billing, credentials stored in the gateway, or an `Authorization` header configured for the provider in `models.json`.
248
+
249
+ ### Cloudflare Workers AI
250
+
251
+ Workers AI requires a token and account ID:
252
+
253
+ ```bash
254
+ export CLOUDFLARE_API_KEY=...
255
+ export CLOUDFLARE_ACCOUNT_ID=...
256
+ ```
257
+
258
+ The account ID can also be stored in the credential's `env` object.
259
+
260
+ ### Google Vertex AI
261
+
262
+ Use a Google Cloud API key:
263
+
264
+ ```bash
265
+ export GOOGLE_CLOUD_API_KEY=...
266
+ ```
267
+
268
+ To use Application Default Credentials, configure a project and location:
269
+
270
+ ```bash
271
+ export GOOGLE_CLOUD_PROJECT=your-project
272
+ # GCLOUD_PROJECT is also supported
273
+ export GOOGLE_CLOUD_LOCATION=us-central1
274
+ ```
275
+
276
+ Then authenticate:
277
+
278
+ ```bash
279
+ gcloud auth application-default login
280
+ ```
281
+
282
+ To use a service-account key file instead, set `GOOGLE_APPLICATION_CREDENTIALS` along with the project and location.
@@ -0,0 +1,128 @@
1
+ # Quickstart
2
+
3
+ KnightCode runs in your terminal and works with files on your machine. To use it, you need access to a model through a supported provider. This can be a subscription, an API key, or a local model.
4
+
5
+ For native Windows setup, read [Windows Setup](windows.md). For Android, read [Termux Setup](termux.md).
6
+
7
+ ## 1. Install KnightCode
8
+
9
+ On macOS or Linux, you can use the installer. It installs Node.js 22.19 or newer if Node is missing or older, then installs KnightCode for your user:
10
+
11
+ ```bash
12
+ curl -fsSL https://knightcode.dev/install.sh | sh
13
+ ```
14
+
15
+ Alternatively, install KnightCode from npm. This requires Node.js 22.19 or newer:
16
+
17
+ ```bash
18
+ npm install -g --ignore-scripts @knightcodeai/cli
19
+ ```
20
+
21
+ KnightCode does not require dependency lifecycle scripts for a normal npm installation.
22
+
23
+ Verify the installation:
24
+
25
+ ```bash
26
+ knightcode --version
27
+ ```
28
+
29
+ Supported installations download updates in the background during interactive
30
+ sessions. When the green **Restart for vX.Y.Z** notice appears above the input,
31
+ exit and relaunch when convenient. You can also run `knightcode update` manually. See
32
+ [Updating KnightCode](cli.md#update-knightcode-or-packages) for supported installs
33
+ and how to disable automatic downloads.
34
+
35
+ ## 2. Start KnightCode
36
+
37
+ Change to the folder you want KnightCode to work with, then start it:
38
+
39
+ ```bash
40
+ cd /path/to/folder
41
+ knightcode
42
+ ```
43
+
44
+ The working folder helps KnightCode discover relevant files, instructions, and configuration. KnightCode also uses it to group saved sessions.
45
+
46
+ <p align="center"><img src="images/interactive-mode.png" alt="KnightCode running in a terminal with a conversation, input editor, and status footer" width="750"></p>
47
+
48
+ The interface shows your conversation, an editor for prompts and commands, and a footer with the current folder, model, and session status. See [Use KnightCode in the terminal](usage.md) to learn how to add files, run commands, direct ongoing work, and manage results.
49
+
50
+ ## 3. Choose a model
51
+
52
+ A **model** generates KnightCode's responses. A **provider** is the service or account KnightCode uses to access that model.
53
+
54
+ In KnightCode, run:
55
+
56
+ ```text
57
+ /login
58
+ ```
59
+
60
+ Choose a provider, then follow the prompts to use a subscription or store an API key. Run `/model` afterward if you want to select a different available model.
61
+
62
+ See [Choose a model and provider](models.md) for supported providers, environment-variable authentication, local models, and custom endpoints.
63
+
64
+ ## 4. Give KnightCode a task
65
+
66
+ KnightCode shows each file read, search, command, and edit it performs. It does not ask before every tool call.
67
+
68
+ Enter a task that matches your work, for example:
69
+
70
+ ```text
71
+ Summarize @meeting-notes.md and save the action items to action-items.md.
72
+ ```
73
+
74
+ ```text
75
+ Explain how this repository is structured and how to run its checks.
76
+ ```
77
+
78
+ ```text
79
+ Compare @previous.csv with @current.csv and summarize the important changes.
80
+ ```
81
+
82
+ Type `@` in the editor to search for a file instead of entering its full path. When KnightCode finishes, review its response and any changed files. Use version control or backups for important work. For untrusted or unattended work, use a container or another sandbox. See [Security](security.md).
83
+
84
+ ## Continue later
85
+
86
+ KnightCode saves sessions automatically. Exit KnightCode, then resume the most recent session for the same working folder with:
87
+
88
+ ```bash
89
+ knightcode --continue
90
+ ```
91
+
92
+ Use `/resume` to choose another saved session. See [Continue or branch a session](sessions.md) for session naming, branching, compaction, export, and sharing.
93
+
94
+ ## Next steps
95
+
96
+ - [Use KnightCode interactively](usage.md) to learn input, commands, shortcuts, and queued messages.
97
+ - [Add instructions](configuration.md#context-files) that KnightCode should follow whenever it works in a folder.
98
+ - [Choose a model and provider](models.md).
99
+
100
+ ### Choose how to customize KnightCode
101
+
102
+ Start with the least powerful mechanism that meets your need:
103
+
104
+ | Need | Start with |
105
+ |---|---|
106
+ | Give KnightCode persistent instructions for a folder | [`AGENTS.md`](configuration.md#context-files) |
107
+ | Reuse a prompt from the `/` menu | [Prompt template](prompt-templates.md) |
108
+ | Add task-specific instructions and supporting files | [Skill](skills.md) |
109
+ | Add executable tools, commands, or event handlers | [Extension](extensions.md) |
110
+ | Build a custom terminal component | [Terminal UI](tui.md) |
111
+ | Connect an unsupported model service | [Custom provider](custom-provider.md) |
112
+ | Install or distribute several resources | [KnightCode package](packages.md) |
113
+
114
+ ## Uninstall KnightCode
115
+
116
+ If you installed KnightCode with npm, run:
117
+
118
+ ```bash
119
+ npm uninstall -g @knightcodeai/cli
120
+ ```
121
+
122
+ If you used the installer, run it again and choose **Uninstall KnightCode**:
123
+
124
+ ```bash
125
+ curl -fsSL https://knightcode.dev/install.sh | sh
126
+ ```
127
+
128
+ Neither method removes configuration, credentials, sessions, or installed KnightCode packages from `~/.knightcode/agent/`.
package/docs/remote.md ADDED
@@ -0,0 +1,87 @@
1
+ # Remote sessions
2
+
3
+ `/remote` publishes the session running in your terminal to the web, so you can
4
+ watch it and reply from another device. The terminal keeps working normally.
5
+
6
+ ## Getting started
7
+
8
+ Run `/remote`. The first time, a sign-in screen opens your browser on the
9
+ approval page and shows an eight-character code: sign in with GitHub, check the
10
+ page shows the same code, and approve. Escape cancels. The credential is stored
11
+ in `~/.knightcode/remote-auth.json` and reused afterwards, and the screen also
12
+ prints the URL for a headless box where nothing launched. Once the browser
13
+ approves, the screen confirms it and continues on enter, or by itself a few
14
+ seconds later.
15
+
16
+ Once signed in, `/remote` prints a link. You do not have to copy it: open
17
+ <https://remote.knightcode.dev> on your phone and the session appears in the
18
+ list.
19
+
20
+ ## The web app
21
+
22
+ The list shows every session you have published, newest first, with its state:
23
+ **Working** while a turn is running in the terminal, **Connected** while the
24
+ terminal is attached and idle, **Disconnected** once it has gone. Filter it to
25
+ active or past sessions from the menu on the right.
26
+
27
+ Open a session to read the transcript. Runs of tool calls are folded into one
28
+ line such as _Ran 2 commands, created a file_; tap it to list the calls, and
29
+ tap a call to see what it did — the command and its output, the file and its
30
+ content, the diff an edit made.
31
+
32
+ The composer sends replies to the terminal. Type `/` to list the slash commands
33
+ the terminal can run from a message: extension commands, skills and prompt
34
+ templates. Built-in commands that open a terminal UI, such as `/model`, are not
35
+ offered.
36
+
37
+ The menu in the session's top-right corner copies the link or deletes the
38
+ session from the relay.
39
+
40
+ ## Commands
41
+
42
+ | Command | Effect |
43
+ | --- | --- |
44
+ | `/remote` | Toggle publishing: start and print the link, or pause. Pausing keeps the room readable, and the next `/remote` resumes the same link |
45
+ | `/remote status` | Show the link and how many viewers are connected |
46
+ | `/remote stop` | Stop publishing and delete the room |
47
+ | `/remote logout` | Revoke the stored account credential and delete it locally |
48
+
49
+ `/remote` runs in the interactive terminal only. In `--print`, RPC and JSON
50
+ modes it reports that and does nothing.
51
+
52
+ ## What the remote can and cannot do
53
+
54
+ A viewer can read the transcript, send prompts, run the slash commands listed
55
+ above, and stop the current turn. Prompts arrive as ordinary user messages and
56
+ appear in your terminal; `/remote` itself is never offered to a viewer.
57
+
58
+ A viewer cannot end your session, quit KnightCode, switch sessions, or change
59
+ model. Closing the browser tab, losing signal, or losing the relay does nothing
60
+ to the terminal. Your session ends only when you end it.
61
+
62
+ If the relay becomes unreachable the command does not fail: it reconnects with
63
+ backoff indefinitely, the footer shows `remote retrying`, and the agent carries
64
+ on working.
65
+
66
+ ## Privacy and retention
67
+
68
+ Room contents pass through and are briefly stored by the relay so a device that
69
+ reconnects can catch up. That includes tool output, which can contain secrets if
70
+ a command prints them. Nothing is redacted: anything visible in your terminal is
71
+ visible in the room while it lives. Only the account that created a room can
72
+ read it.
73
+
74
+ A room stays readable as a past session for 30 days after the terminal
75
+ disconnects, and is deleted then, on `/remote stop`, or when you delete it from
76
+ the web app. Stored history is capped at 8 MB per room; older content is
77
+ dropped as the session grows. Images are not mirrored in either direction — an
78
+ image in the transcript appears as a placeholder recording its type and size.
79
+
80
+ ## Configuration
81
+
82
+ | Environment variable | Default | Effect |
83
+ | --- | --- | --- |
84
+ | `KNIGHTCODE_REMOTE_RELAY` | `https://remote.knightcode.dev` | Relay origin to publish to |
85
+ | `KNIGHTCODE_REMOTE_CONFIG_DIR` | `~/.knightcode` | Directory holding `remote-auth.json` |
86
+
87
+ `/remote` refuses to start when `KNIGHTCODE_OFFLINE` is set.