@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.
- package/CHANGELOG.md +1303 -0
- package/README.md +2 -2
- package/dist/bundle/chunks/anthropic-messages-A2IH2IY3.js +6 -0
- package/dist/bundle/chunks/anthropic.js +101 -0
- package/dist/bundle/chunks/azure-openai-responses-XZILQZOG.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
- package/dist/bundle/chunks/chunk-253N4337.js +7 -0
- package/dist/bundle/chunks/chunk-2QIKI63P.js +108 -0
- package/dist/bundle/chunks/chunk-3LX7U45C.js +130 -0
- package/dist/bundle/chunks/chunk-4CRI7BMY.js +2 -0
- package/dist/bundle/chunks/chunk-57BPR4HF.js +2 -0
- package/dist/bundle/chunks/chunk-A5LJINMT.js +2 -0
- package/dist/bundle/chunks/chunk-AANBXVWQ.js +2 -0
- package/dist/bundle/chunks/chunk-AHB7JV5B.js +2 -0
- package/dist/bundle/chunks/chunk-B2FT7RH5.js +2 -0
- package/dist/bundle/chunks/chunk-BPNRVFVQ.js +2 -0
- package/dist/bundle/chunks/chunk-BRKUE2MD.js +2 -0
- package/dist/bundle/chunks/chunk-BXZL5C3N.js +58 -0
- package/dist/bundle/chunks/chunk-DGACKL4S.js +30 -0
- package/dist/bundle/chunks/chunk-DKOURXGU.js +2 -0
- package/dist/bundle/chunks/chunk-DVFCXHT4.js +2 -0
- package/dist/bundle/chunks/chunk-ETOMYYZC.js +2 -0
- package/dist/bundle/chunks/chunk-FA32X2UJ.js +7 -0
- package/dist/bundle/chunks/chunk-FHM6KUY3.js +44 -0
- package/dist/bundle/chunks/chunk-FO7CEQB3.js +11 -0
- package/dist/bundle/chunks/chunk-FXS5MU6B.js +2 -0
- package/dist/bundle/chunks/chunk-HHWP56PR.js +2 -0
- package/dist/bundle/chunks/chunk-HSL72VZI.js +2 -0
- package/dist/bundle/chunks/chunk-HUQB436V.js +2 -0
- package/dist/bundle/chunks/chunk-HWXGL4YB.js +2 -0
- package/dist/bundle/chunks/chunk-KQKUEQJA.js +6 -0
- package/dist/bundle/chunks/chunk-LROWZ6UF.js +1333 -0
- package/dist/bundle/chunks/chunk-MOALMQWH.js +9 -0
- package/dist/bundle/chunks/chunk-MXIWLMNT.js +8 -0
- package/dist/bundle/chunks/chunk-N6VDWLND.js +2 -0
- package/dist/bundle/chunks/chunk-NCIBB66G.js +2 -0
- package/dist/bundle/chunks/chunk-NDQ5OW6U.js +2 -0
- package/dist/bundle/chunks/chunk-O6JSP6YG.js +6 -0
- package/dist/bundle/chunks/chunk-OFST7FDG.js +2 -0
- package/dist/bundle/chunks/chunk-SPAUY3RD.js +12 -0
- package/dist/bundle/chunks/chunk-UZWP3NHW.js +2 -0
- package/dist/bundle/chunks/chunk-V5ANFNKF.js +11 -0
- package/dist/bundle/chunks/chunk-VJJ6J35N.js +20 -0
- package/dist/bundle/chunks/chunk-ZW7FVRHT.js +31 -0
- package/dist/bundle/chunks/cli-DFJTSQI6.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-6E2UM7IG.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +478 -0
- package/dist/bundle/chunks/dist-DKI7Q6GY.js +13 -0
- package/dist/bundle/chunks/easter-egg-3d-7O2AHLAQ.js +2 -0
- package/dist/bundle/chunks/execute-4CLOTQIS.js +499 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-CSWR3ORZ.js +2 -0
- package/dist/bundle/chunks/google-vertex-QIDRFOFB.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-BXVX3Y2R.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-NNBCFAO5.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/knightcode-messages-3GNOTMSI.js +8 -0
- package/dist/bundle/chunks/lib-IHWMWJDR.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-HRPRKOZA.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-46TK5OBA.js +5 -0
- package/dist/bundle/chunks/multipart-parser-VTTMF2EO.js +3 -0
- package/dist/bundle/chunks/node-7S3GFMOZ.js +16 -0
- package/dist/bundle/chunks/node-MAEICQNS.js +2 -0
- package/dist/bundle/chunks/openai-chatgpt.js +101 -0
- package/dist/bundle/chunks/openai-codex-responses-IT7VEKUU.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +101 -0
- package/dist/bundle/chunks/openai-completions-LOKIW33V.js +7 -0
- package/dist/bundle/chunks/openai-decisions-4F3LWHMG.js +5 -0
- package/dist/bundle/chunks/openai-responses-OK36GJXP.js +3 -0
- package/dist/bundle/chunks/openrouter-images-ZI7LLZ4Y.js +2 -0
- package/dist/bundle/chunks/openrouter.js +101 -0
- package/dist/bundle/chunks/radius.js +101 -0
- package/dist/bundle/chunks/runtime-IN7ZPKFY.js +2 -0
- package/dist/bundle/chunks/src-ETRMT73D.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-J2CJBWEH.js +2 -0
- package/dist/bundle/chunks/virtual-modules-7VXI3TVN.js +2 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +16 -0
- package/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
- package/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
- package/dist/bundle/native/linux/prebuilds/linux-arm64/linux-platform-x11.node +0 -0
- package/dist/bundle/native/linux/prebuilds/linux-x64/linux-platform-x11.node +0 -0
- package/dist/bundle/native/win32/prebuilds/win32-arm64/win32-platform.node +0 -0
- package/dist/bundle/native/win32/prebuilds/win32-x64/win32-platform.node +0 -0
- package/dist/core/export-html/template.css +1015 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1929 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/modes/interactive/theme/dark.json +74 -0
- package/dist/modes/interactive/theme/light.json +74 -0
- package/dist/modes/interactive/theme/system-theme.ts +579 -0
- package/dist/modes/interactive/theme/theme-controller.ts +253 -0
- package/dist/modes/interactive/theme/theme-schema.ts +145 -0
- package/dist/modes/interactive/theme/theme-tokens.ts +145 -0
- package/dist/modes/interactive/theme/theme.ts +1076 -0
- package/docs/app-server.md +479 -0
- package/docs/app-server.schema.json +8128 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +393 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +463 -0
- package/docs/configuration.md +48 -0
- package/docs/containerization.md +143 -0
- package/docs/custom-provider.md +225 -0
- package/docs/desktop.md +73 -0
- package/docs/docs.json +236 -0
- package/docs/environment-variables.md +138 -0
- package/docs/extensions.md +420 -0
- package/docs/how-knightcode-works.md +49 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +39 -0
- package/docs/json.md +226 -0
- package/docs/keybindings.md +197 -0
- package/docs/llama-cpp.md +121 -0
- package/docs/mcp.md +272 -0
- package/docs/message-types.md +279 -0
- package/docs/models-configuration.md +187 -0
- package/docs/models.md +221 -0
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/packages.md +129 -0
- package/docs/plan-mode.md +121 -0
- package/docs/prompt-templates.md +59 -0
- package/docs/providers.md +282 -0
- package/docs/quickstart.md +128 -0
- package/docs/remote.md +87 -0
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +214 -0
- package/docs/rpc.md +193 -0
- package/docs/sdk.md +197 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +358 -0
- package/docs/sessions.md +135 -0
- package/docs/settings.md +220 -0
- package/docs/shell-aliases.md +93 -0
- package/docs/skills.md +93 -0
- package/docs/slash-commands.md +78 -0
- package/docs/terminal-setup.md +242 -0
- package/docs/termux.md +117 -0
- package/docs/themes.md +140 -0
- package/docs/tmux.md +55 -0
- package/docs/tui.md +195 -0
- package/docs/usage.md +167 -0
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +67 -0
- package/examples/README.md +36 -0
- package/examples/extensions/README.md +214 -0
- package/examples/extensions/auto-commit-on-exit.ts +55 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +151 -0
- package/examples/extensions/built-in-tool-renderer.ts +225 -0
- package/examples/extensions/claude-rules.ts +89 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +60 -0
- package/examples/extensions/custom-compaction.ts +118 -0
- package/examples/extensions/custom-footer.ts +66 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +617 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +399 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_knightcode.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +55 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +75 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +190 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +353 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +57 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +387 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +49 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +118 -0
- package/examples/extensions/question.ts +278 -0
- package/examples/extensions/questionnaire.ts +440 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +177 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +157 -0
- package/examples/extensions/subagent/index.ts +1010 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +199 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1004 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +294 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +121 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +661 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +70 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +42 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +74 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/examples/sdk/README.md +141 -0
- package/package.json +15 -15
- package/bin/knightcode +0 -62
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# CLI Integration
|
|
2
|
+
|
|
3
|
+
By default, running `knightcode` opens the interactive terminal interface. When input or output is piped or redirected, KnightCode uses print mode instead. You can also select print, JSON, or RPC mode explicitly for scripts and applications.
|
|
4
|
+
|
|
5
|
+
All four modes use the same agent, sessions, resources, and tools. The mode determines how input enters KnightCode, how output is exposed, and whether the process remains available for more commands.
|
|
6
|
+
|
|
7
|
+
The SDK is not a CLI mode. It embeds the agent directly in a Node.js or Bun process. See the [SDK](sdk.md) when direct TypeScript access is preferable to a process boundary.
|
|
8
|
+
|
|
9
|
+
## Choose a mode
|
|
10
|
+
|
|
11
|
+
| Mode | Interface | Lifetime | Use it when |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| Interactive | Terminal UI | Until the user exits | A person is working with KnightCode directly |
|
|
14
|
+
| Print | Final text on stdout | One invocation | A script needs the final assistant response |
|
|
15
|
+
| JSON | JSONL events on stdout | One invocation | A process needs structured progress from a run |
|
|
16
|
+
| RPC | JSONL commands, responses, and events | Long-lived | A process needs bidirectional control |
|
|
17
|
+
|
|
18
|
+
CLI options still select the working directory, model, tools, resources, and session persistence independently of the mode. See [Command Line](cli.md) for the complete startup options.
|
|
19
|
+
|
|
20
|
+
## Print to stdout
|
|
21
|
+
|
|
22
|
+
Print mode runs the supplied prompts, writes the final assistant text to stdout, and exits:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
knightcode --print "Summarize the changes in this repository"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use print mode when only the final text is needed, including command substitution, pipelines, and one-shot jobs. Intermediate events are not exposed.
|
|
29
|
+
|
|
30
|
+
Print mode writes errors to stderr. A final assistant response with an `error` or `aborted` stop reason produces a nonzero exit status. A response cut off at the model's output token limit (`length` stop reason) still prints its partial text to stdout, writes a warning to stderr, and produces a nonzero exit status.
|
|
31
|
+
|
|
32
|
+
When no mode is selected explicitly, non-TTY stdin or stdout also selects print mode. This allows piped input and output without adding `--print`.
|
|
33
|
+
|
|
34
|
+
## Stream JSON events
|
|
35
|
+
|
|
36
|
+
JSON mode writes a session header followed by agent and session events as newline-delimited JSON:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
knightcode --mode json "Review this repository" > events.jsonl
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This is structured event output, not a single JSON result or a constraint on the format of the model’s response.
|
|
43
|
+
|
|
44
|
+
All prompts are supplied when the process starts. The process streams events for that run and then exits; it does not accept later commands.
|
|
45
|
+
|
|
46
|
+
A failed or aborted assistant response appears in the event stream but does not by itself produce a nonzero exit status. Inspect the events when success or failure matters. KnightCode still exits nonzero if the invocation throws an error.
|
|
47
|
+
|
|
48
|
+
Streaming `message_update` records contain deltas rather than a growing message snapshot. Assemble live output from the delta events, then replace it with the authoritative message from `message_end`.
|
|
49
|
+
|
|
50
|
+
`agent_end` can be followed by automatic recovery or queued work. `agent_settled` marks the end of automatic work for the current run.
|
|
51
|
+
|
|
52
|
+
Stdout is reserved for JSONL. Diagnostics and application logging are written to stderr. See [JSON Event Stream](json.md) for framing, event shapes, and reconstruction rules.
|
|
53
|
+
|
|
54
|
+
## Control KnightCode with RPC
|
|
55
|
+
|
|
56
|
+
RPC mode keeps KnightCode running while another process sends commands and receives responses and events:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
knightcode --mode rpc --no-session
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Commands are JSON objects written to stdin. Responses and events are JSON objects written to stdout. Every record occupies one line.
|
|
63
|
+
|
|
64
|
+
Add an `id` to commands that need correlation. The matching response repeats that ID. Events generally have no command ID because they describe session activity rather than one request.
|
|
65
|
+
|
|
66
|
+
A successful `prompt` response means the prompt was accepted, queued, or handled. It does not mean the run completed. Continue consuming events through `agent_settled` when completion matters.
|
|
67
|
+
|
|
68
|
+
RPC commands can change models, inspect state, manage sessions, run shell commands, and answer extension UI requests.
|
|
69
|
+
|
|
70
|
+
Extension dialogs form a request-response subprotocol. Other extension UI updates are notifications that a client may display or ignore. TUI-only extension capabilities are unavailable or degraded outside interactive mode.
|
|
71
|
+
|
|
72
|
+
For Node.js or TypeScript integrations, prefer `RpcClient` from `@knightcodeai/cli`. It starts a KnightCode RPC child process, correlates requests, exposes typed command methods, and delivers session events to listeners.
|
|
73
|
+
|
|
74
|
+
The [RPC client example](../examples/rpc-client.ts) sends one prompt, streams text and tool activity, waits for `agent_settled`, and shuts down the child process. It is included in the repository’s TypeScript checks.
|
|
75
|
+
|
|
76
|
+
`RpcClient.promptAndWait()` installs its event listener before sending the prompt, avoiding a race with fast completions. For separate operations, subscribe before calling `prompt()` and call `waitForIdle()` only while a run is active.
|
|
77
|
+
|
|
78
|
+
The client requires a path to a runnable KnightCode CLI. The repository example points at `dist/cli.js`, so the package must be built before that example runs from a checkout.
|
|
79
|
+
|
|
80
|
+
If you are building a client without `RpcClient`, start with [RPC Protocol](rpc.md), then use [RPC Commands](rpc-commands.md) and [JSON Event Stream](json.md) as the wire references.
|
|
81
|
+
|
|
82
|
+
## Fork and rebrand KnightCode
|
|
83
|
+
|
|
84
|
+
A source fork can change the CLI name and configuration directory through `package.json`:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"piConfig": {
|
|
89
|
+
"name": "my-agent",
|
|
90
|
+
"configDir": ".my-agent"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Change the top-level `bin` field to set the executable name. These settings affect the CLI banner, configuration paths, and derived environment variable names.
|
|
96
|
+
|
|
97
|
+
## Examples and references
|
|
98
|
+
|
|
99
|
+
- [RPC client](../examples/rpc-client.ts): typed Node.js integration
|
|
100
|
+
- [RPC extension UI](../examples/rpc-extension-ui.ts): custom terminal client with extension dialogs
|
|
101
|
+
- [Command Line](cli.md): startup options and mode selection
|
|
102
|
+
- [JSON Event Stream](json.md): JSON event reference
|
|
103
|
+
- [RPC Protocol](rpc.md): RPC lifecycle, framing, errors, and shutdown
|
|
104
|
+
- [RPC Commands](rpc-commands.md): command and response reference
|
|
105
|
+
- [RPC Extension UI](rpc-extension-ui.md): extension interaction subprotocol
|
|
106
|
+
- [SDK examples](../examples/sdk/): in-process TypeScript integrations
|
package/docs/cli.md
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
<a id="cli-and-modes-reference"></a>
|
|
2
|
+
|
|
3
|
+
# Command Line
|
|
4
|
+
|
|
5
|
+
This page documents KnightCode's built-in command-line commands and options. Run `knightcode --help` or append `--help` to a command for the exact interface in your installed version. The top-level help also includes options registered by loaded extensions.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
knightcode [options] [--] [@files...] [messages...]
|
|
9
|
+
knightcode install <source> [options]
|
|
10
|
+
knightcode remove <source> [options]
|
|
11
|
+
knightcode uninstall <source> [options]
|
|
12
|
+
knightcode update [target] [options]
|
|
13
|
+
knightcode list
|
|
14
|
+
knightcode config [options]
|
|
15
|
+
knightcode auth <check|print-api-key|print-bearer-token> [options]
|
|
16
|
+
knightcode mcp <list|login|logout> [options]
|
|
17
|
+
knightcode app-server [-e <extension>]... [--session-dir <dir>]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
<a id="modes"></a>
|
|
21
|
+
|
|
22
|
+
## Invocation and output
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
knightcode
|
|
26
|
+
knightcode --print "Summarize this repository"
|
|
27
|
+
git diff | knightcode --print "Review this change"
|
|
28
|
+
knightcode --mode json "Inspect this repository" > events.jsonl
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
With terminal stdin and stdout, KnightCode opens the terminal UI unless `--print`, `--mode json`, or `--mode rpc` selects another interface. When either stream is redirected and neither JSON nor RPC mode is selected, KnightCode uses print mode. See [CLI Integration](cli-integration.md) for choosing between interactive, print, JSON, RPC, and SDK integration.
|
|
32
|
+
|
|
33
|
+
| Input | Behavior |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `message` | Provide an initial prompt |
|
|
36
|
+
| `@path` | Include a text file or image in the first prompt |
|
|
37
|
+
| Piped stdin | Prepend its contents to the first prompt |
|
|
38
|
+
| `--` | Stop option parsing so a prompt can begin with `-` |
|
|
39
|
+
|
|
40
|
+
KnightCode resolves `@path` from the current working directory. The working directory also controls project configuration, resource discovery, and session grouping.
|
|
41
|
+
|
|
42
|
+
`--print` controls whether KnightCode runs once and exits. `--mode` selects the output interface. `--mode text` does not force one-shot execution when stdin and stdout are terminals; use `--print` for that behavior.
|
|
43
|
+
|
|
44
|
+
| Option | Behavior |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `-p`, `--print` | Run the supplied prompts, write the final assistant text to stdout, then exit |
|
|
47
|
+
| `--mode text` | Select text output; still open the terminal UI when stdin and stdout are terminals |
|
|
48
|
+
| `--mode json` | Run the supplied prompts, write JSONL events to stdout, then exit |
|
|
49
|
+
| `--mode rpc` | Read JSONL commands from stdin and write responses and events to stdout until shutdown |
|
|
50
|
+
| `--export <input> [output]` | Export a session file to HTML and exit; derive the destination when `output` is omitted |
|
|
51
|
+
|
|
52
|
+
RPC mode rejects `@file` arguments. JSON and RPC modes reserve stdout for protocol records. See [JSON Event Stream](json.md) and [RPC Protocol](rpc.md).
|
|
53
|
+
|
|
54
|
+
### Plan before implementing
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
knightcode --plan
|
|
58
|
+
knightcode -p --plan "Plan the authentication refactor"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The built-in `--plan` extension flag enters enforced [plan mode](plan-mode.md)
|
|
62
|
+
only on initial startup, including when opening a saved session. Later reloads,
|
|
63
|
+
new sessions, resumes, and forks follow their saved state rather than reapplying
|
|
64
|
+
the flag. Print mode (`-p`) writes the submitted Markdown to stdout;
|
|
65
|
+
implementation requires explicit `/plan approve`. Incompatible tool filters or
|
|
66
|
+
active codemode `only` mode fail startup before any provider request.
|
|
67
|
+
`--no-extensions` disables the built-in unless explicitly loaded with
|
|
68
|
+
`-e builtin:plan-mode`.
|
|
69
|
+
|
|
70
|
+
<a id="model-options"></a>
|
|
71
|
+
|
|
72
|
+
## Models
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
knightcode --model sonnet:high
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
See [Choose a Model](models.md) for model selection and [Providers](providers.md) for credentials.
|
|
79
|
+
|
|
80
|
+
- `--provider <name>`<br>
|
|
81
|
+
Restricts `--model` lookup to one provider. It requires `--model`.
|
|
82
|
+
- `--model <pattern>`<br>
|
|
83
|
+
Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix. If several providers match, KnightCode prefers the one with credentials, otherwise it asks for `--provider`.
|
|
84
|
+
- `--api-key <key>`<br>
|
|
85
|
+
Uses a non-persistent API-key override. It requires a model selected through `--model` or `--models`. It does not choose between providers that offer the same model.
|
|
86
|
+
- `--thinking <level>`<br>
|
|
87
|
+
Sets `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. It overrides a `--model` suffix and is clamped to the model's capabilities.
|
|
88
|
+
- `--models <patterns>`<br>
|
|
89
|
+
Sets a comma-separated scope for startup and cycling. It accepts exact IDs, fuzzy matches, case-insensitive globs, and optional `:<thinking>` suffixes. A model offered by several providers is added for each, with a warning.
|
|
90
|
+
- `--list-models [search]`<br>
|
|
91
|
+
Lists available models, optionally filtered by a fuzzy search, then exits.
|
|
92
|
+
|
|
93
|
+
<a id="session-options"></a>
|
|
94
|
+
|
|
95
|
+
## Sessions
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
knightcode --continue
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See [Sessions and Context](sessions.md) for resuming, forking, naming, and storing sessions.
|
|
102
|
+
|
|
103
|
+
- `-c`, `--continue`<br>
|
|
104
|
+
Continues the most recent session for the current project.
|
|
105
|
+
- `-r`, `--resume`<br>
|
|
106
|
+
Opens the session selector.
|
|
107
|
+
- `--session <path|id>`<br>
|
|
108
|
+
Opens by file path, exact ID, or partial ID. KnightCode searches the current project first and offers to fork a cross-project match.
|
|
109
|
+
- `--session-id <id>`<br>
|
|
110
|
+
Opens the exact project session ID or creates it if absent. IDs accept letters, numbers, `.`, `_`, and `-`.
|
|
111
|
+
- `--fork <path|id>`<br>
|
|
112
|
+
Forks an existing session into a new session for the current project.
|
|
113
|
+
- `--session-dir <dir>`<br>
|
|
114
|
+
Overrides storage and lookup. It takes precedence over `KNIGHTCODE_CODING_AGENT_SESSION_DIR` and the `sessionDir` setting.
|
|
115
|
+
- `--no-session`<br>
|
|
116
|
+
Uses an in-memory session that is not persisted.
|
|
117
|
+
- `-n`, `--name <name>`<br>
|
|
118
|
+
Sets the session display name.
|
|
119
|
+
|
|
120
|
+
Constraints:
|
|
121
|
+
|
|
122
|
+
- Session IDs must start and end with a letter or number.
|
|
123
|
+
- `--fork` cannot be combined with `--session`, `--continue`, `--resume`, or `--no-session`.
|
|
124
|
+
- `--session-id` cannot be combined with `--session`, `--continue`, or `--resume`. Combine it with `--fork` to choose the new ID.
|
|
125
|
+
|
|
126
|
+
<a id="tool-options"></a>
|
|
127
|
+
|
|
128
|
+
## Tools
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
knightcode --tools read,grep,find,ls --print "Review this project"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
See [Settings](settings.md#tools) for configuring the default tool selection.
|
|
135
|
+
|
|
136
|
+
- `-t`, `--tools <list>`<br>
|
|
137
|
+
Replaces the default selection with a comma-separated allowlist of built-in, extension, or custom tools. Entries are tool names or patterns where `*` matches any characters. MCP tools are kept unless an entry starts with `mcp__` (see [MCP tools](#mcp-tools)). A list of only `+name` and `-name` entries is not an allowlist; it changes the default selection instead.
|
|
138
|
+
- `-xt`, `--exclude-tools <list>`<br>
|
|
139
|
+
Disables comma-separated tool names or patterns after all other selection options, MCP tools included.
|
|
140
|
+
- `-nbt`, `--no-builtin-tools`<br>
|
|
141
|
+
Disables default built-in tools while retaining extension and custom tools.
|
|
142
|
+
- `-nt`, `--no-tools`<br>
|
|
143
|
+
Starts with all built-in, extension, custom, and MCP tools disabled.
|
|
144
|
+
|
|
145
|
+
Default enabled tools are `read`, `bash`, `edit`, and `write`, unless `defaultTools` changes them. `--tools` with plain names replaces the whole selection, so name every tool you want. Like `defaultTools`, it also accepts a list of only `+name` and `-name` entries, which adds tools to or removes them from the default selection: `knightcode --tools +codemode,-write` keeps the other default tools, enables `codemode`, and disables `write`. These entries take exact tool names, not `*` patterns; use `--exclude-tools` to disable tools by pattern. Plain names and `+name`/`-name` entries cannot be mixed. `/reload` enables tools newly added to `defaultTools`, but a tool removed with `-name` stays removed.
|
|
146
|
+
|
|
147
|
+
<a id="mcp-tools"></a>
|
|
148
|
+
|
|
149
|
+
`--tools` selects the tools declared to the model. It does not remove MCP tools, whose reach is set by their [exposure](mcp.md#control-tool-exposure): `knightcode --tools read,codemode` keeps every MCP tool callable from codemode scripts. An MCP tool that no entry names or matches is never declared directly, whatever its exposure; only `tool_search`, if listed, can load it. Once an entry starts with `mcp__`, `--tools` filters MCP tools too, so this keeps only the tools of the `radius` server:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
knightcode --tools read,bash,codemode,'mcp__radius__*'
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The MCP resource tools (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`) count as MCP tools. To remove MCP tools, use `--exclude-tools 'mcp__*'` or [`--no-mcp`](#resource-options).
|
|
156
|
+
|
|
157
|
+
| Built-in | Purpose |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `read` | Read text files and supported images |
|
|
160
|
+
| `bash` | Run shell commands |
|
|
161
|
+
| `powershell` | Run PowerShell commands on Windows |
|
|
162
|
+
| `edit` | Apply exact text replacements to an existing file |
|
|
163
|
+
| `write` | Create or overwrite a file |
|
|
164
|
+
| `grep` | Search file contents |
|
|
165
|
+
| `find` | Find paths using glob patterns |
|
|
166
|
+
| `ls` | List directory contents |
|
|
167
|
+
|
|
168
|
+
The [web tools](usage.md#web-tools) `webfetch` and `websearch` and the [question tool](usage.md#questions) `ask_user` are off until enabled with `/tools` or named here. A tool excluded here stays off whatever `/tools` says, and one turned off with `/tools` stays off even when named here.
|
|
169
|
+
|
|
170
|
+
Built-in extensions add two more tools. They are off by default; the MCP extension turns them on when an MCP server needs them (see [MCP](mcp.md#exposure)). To enable them yourself, name them in `--tools` or `defaultTools`.
|
|
171
|
+
|
|
172
|
+
| Built-in extension | Purpose |
|
|
173
|
+
|---|---|
|
|
174
|
+
| `codemode` | Run JavaScript that calls the other tools, for example in parallel with `Promise.allSettled`; only the script's output reaches the model |
|
|
175
|
+
| `tool_search` | Search tools that are not declared to the model (`codemode` and `deferred` exposure, such as MCP tools) and declare the matches for the next call |
|
|
176
|
+
|
|
177
|
+
### Enable codemode
|
|
178
|
+
|
|
179
|
+
To turn on `codemode` for every session, add it to the default tools in `~/.knightcode/agent/settings.json` or a project's `.knightcode/settings.json`:
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"defaultTools": ["+codemode"]
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
This keeps `read`, `bash`, `edit`, and `write` and adds `codemode`. For one invocation, add it with `--tools`:
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
knightcode --tools +codemode
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Codemode is useful without MCP: scripts can run several tool calls in parallel, filter large output before it reaches the model, call classifier models such as TypeSafe's Jev through `models.classify()` (see [Classifier models](models.md#use-classifier-models)), and generate images through `models.generateImages()` (see [Image models](models.md#use-image-models)).
|
|
194
|
+
|
|
195
|
+
### How codemode works
|
|
196
|
+
|
|
197
|
+
Scripts run in a QuickJS sandbox and reach the other tools through `tools.<name>(args)`. [Codemode](codemode.md) describes the script API, how tools are listed and found, the `store()` and `models` globals, and the limits.
|
|
198
|
+
|
|
199
|
+
### Tool search
|
|
200
|
+
|
|
201
|
+
`tool_search` is off by default; enable it with `"defaultTools": ["+tool_search"]` or `--tools`. It uses the same ranking as `searchTools()` over tools that are not declared yet and declares the matches for the next model call. Loaded tools are recorded in the session like other tool changes, so they stay declared on that branch.
|
|
202
|
+
|
|
203
|
+
<a id="resource-options"></a>
|
|
204
|
+
|
|
205
|
+
## Resources
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
knightcode --extension ./review.ts
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
See [Configuration](configuration.md) for conventional directories and project trust, [Settings](settings.md#resources) for configured paths, and [KnightCode Packages](packages.md) for package sources.
|
|
212
|
+
|
|
213
|
+
- `-e`, `--extension <path>`<br>
|
|
214
|
+
Loads an extension file or directory, or a built-in extension such as `builtin:mcp`, and is repeatable.
|
|
215
|
+
- `-ne`, `--no-extensions`<br>
|
|
216
|
+
Disables discovered, configured, and built-in extensions. Explicit `-e` paths still load, so `knightcode -ne -e builtin:mcp` keeps only the built-in MCP support.
|
|
217
|
+
- `--no-mcp`<br>
|
|
218
|
+
Disables the built-in MCP support for this run: no servers connect, and there are no MCP tools or `/mcp`. It does not affect an extension that replaces the built-in MCP support.
|
|
219
|
+
- `--skill <path>`<br>
|
|
220
|
+
Loads a skill file or directory and is repeatable.
|
|
221
|
+
- `-ns`, `--no-skills`<br>
|
|
222
|
+
Disables discovered and configured skills. Explicit `--skill` paths still load.
|
|
223
|
+
- `--prompt-template <path>`<br>
|
|
224
|
+
Loads a prompt-template file or directory and is repeatable.
|
|
225
|
+
- `-np`, `--no-prompt-templates`<br>
|
|
226
|
+
Disables discovered and configured templates. Explicit `--prompt-template` paths still load.
|
|
227
|
+
- `--theme <path>`<br>
|
|
228
|
+
Loads a theme file or directory and is repeatable.
|
|
229
|
+
- `--use-theme <name[/name]>`<br>
|
|
230
|
+
Selects the initial interactive theme for this run.
|
|
231
|
+
- `--no-themes`<br>
|
|
232
|
+
Disables discovered and configured themes. Explicit `--theme` paths still load.
|
|
233
|
+
- `-nc`, `--no-context-files`<br>
|
|
234
|
+
Disables `AGENTS.md` and `CLAUDE.md` discovery.
|
|
235
|
+
|
|
236
|
+
Resource paths apply only to the current process. Relative paths resolve from the current working directory.
|
|
237
|
+
|
|
238
|
+
<a id="prompt-and-display-options"></a>
|
|
239
|
+
|
|
240
|
+
## Prompts and process
|
|
241
|
+
|
|
242
|
+
```sh
|
|
243
|
+
knightcode --append-system-prompt ./instructions.md
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
See [Configuration](configuration.md) for saved configuration, [Security](security.md#understand-project-trust) for project trust, and [Environment Variables](environment-variables.md) for process controls.
|
|
247
|
+
|
|
248
|
+
- `--system-prompt <text|path>`<br>
|
|
249
|
+
Replaces the default system prompt with text or the contents of an existing file.
|
|
250
|
+
- `--append-system-prompt <text|path>`<br>
|
|
251
|
+
Appends text or an existing file to the system prompt and is repeatable.
|
|
252
|
+
- `--tui-mode <mode>`<br>
|
|
253
|
+
Uses `fullscreen` (default) or `regular` terminal mode.
|
|
254
|
+
- `--verbose`<br>
|
|
255
|
+
Shows verbose interactive startup information, overriding `quietStartup`.
|
|
256
|
+
- `-a`, `--approve`<br>
|
|
257
|
+
Trusts project-local configuration and resources for this process.
|
|
258
|
+
- `-na`, `--no-approve`<br>
|
|
259
|
+
Ignores trust-gated project-local configuration and resources for this process.
|
|
260
|
+
- `--offline`<br>
|
|
261
|
+
Disables automatic network activity, including model catalog refreshes. Equivalent to `KNIGHTCODE_OFFLINE=1`.
|
|
262
|
+
- `-h`, `--help`<br>
|
|
263
|
+
Shows help, including flags registered by loaded extensions, then exits.
|
|
264
|
+
- `-v`, `--version`<br>
|
|
265
|
+
Shows the KnightCode version, then exits.
|
|
266
|
+
|
|
267
|
+
Extensions may register additional long-form options. Unknown short options are rejected.
|
|
268
|
+
|
|
269
|
+
## Package commands
|
|
270
|
+
|
|
271
|
+
```sh
|
|
272
|
+
knightcode install npm:@scope/package
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
See [KnightCode Packages](packages.md) for source formats, filtering, installation, and project scope.
|
|
276
|
+
|
|
277
|
+
### Common tasks
|
|
278
|
+
|
|
279
|
+
| Task | Command |
|
|
280
|
+
|---|---|
|
|
281
|
+
| Install a package | `knightcode install <source>` |
|
|
282
|
+
| List configured packages | `knightcode list` |
|
|
283
|
+
| Remove a package and its settings entry | `knightcode remove <source>` |
|
|
284
|
+
| Configure which package resources load | `knightcode config` |
|
|
285
|
+
|
|
286
|
+
Add `--local` or `-l` to `install`, `remove`, `uninstall`, or `config` to use project settings instead of global settings.
|
|
287
|
+
|
|
288
|
+
### Update KnightCode or packages
|
|
289
|
+
|
|
290
|
+
Running `knightcode update` without a target updates KnightCode itself.
|
|
291
|
+
|
|
292
|
+
Interactive sessions check for updates at startup and hourly. Installer-managed
|
|
293
|
+
installs, writable global package manager installs, and downloaded release
|
|
294
|
+
binaries update in the background. A right-aligned line directly above the input
|
|
295
|
+
shows **Downloading vX.Y.Z**, then **Restart for vX.Y.Z** in green. Errors are red;
|
|
296
|
+
waiting for another terminal is yellow. Exit when convenient and relaunch; use
|
|
297
|
+
the displayed restart command to continue the saved session. Active work is never
|
|
298
|
+
restarted automatically.
|
|
299
|
+
|
|
300
|
+
The script installer stages and verifies a separate release before changing the
|
|
301
|
+
launcher, retaining the version that open sessions use. Global package manager
|
|
302
|
+
installs update in place, and the new version is started once to check it before
|
|
303
|
+
the update reports success. A downloaded standalone binary is replaced from the
|
|
304
|
+
matching [GitHub release](https://github.com/KnightCodeAI/knightcode/releases)
|
|
305
|
+
archive, checked against its `SHA256SUMS`, and smoke-tested before any file
|
|
306
|
+
moves; files next to it that the release does not ship are left alone. These
|
|
307
|
+
updates run in a separate process that can finish after you exit. Other open
|
|
308
|
+
sessions keep running, but files on disk change under them; after an in-place
|
|
309
|
+
update, a session warns you to restart if code it loads on demand fails. On
|
|
310
|
+
Windows, automatic global updates support npm and pnpm. Source checkouts,
|
|
311
|
+
non-writable installs, and package renames show manual update notices instead.
|
|
312
|
+
|
|
313
|
+
Failed background updates show a manual retry command and are retried on a later
|
|
314
|
+
check. Automatic updates are on by default. To retain update notices without
|
|
315
|
+
automatic downloads, open `/settings` and set **Automatic updates** to `false`,
|
|
316
|
+
or add `"autoUpdate": false` to your user-level `~/.knightcode/agent/settings.json` (Windows:
|
|
317
|
+
`%USERPROFILE%\.knightcode\agent\settings.json`). Project settings cannot override
|
|
318
|
+
this preference. See [Disable automatic updates](settings.md#disable-automatic-updates)
|
|
319
|
+
for a complete example and reload instructions.
|
|
320
|
+
|
|
321
|
+
Alternatively, set `KNIGHTCODE_DISABLE_AUTO_UPDATE=1` in your shell or operating
|
|
322
|
+
system environment before launching KnightCode; it overrides `autoUpdate: true`.
|
|
323
|
+
`KNIGHTCODE_SKIP_VERSION_CHECK=1` suppresses both automatic checks and downloads.
|
|
324
|
+
Explicit `knightcode update` remains available regardless of the setting or either
|
|
325
|
+
variable. Offline, print, JSON, and RPC sessions do not start background updates.
|
|
326
|
+
|
|
327
|
+
| Task | Command |
|
|
328
|
+
|---|---|
|
|
329
|
+
| Update KnightCode | `knightcode update` |
|
|
330
|
+
| Update all installed packages | `knightcode update --extensions` |
|
|
331
|
+
| Update one installed package | `knightcode update <source>` |
|
|
332
|
+
| Refresh model catalogs | `knightcode update --models` |
|
|
333
|
+
| Update KnightCode and all installed packages | `knightcode update --all` |
|
|
334
|
+
|
|
335
|
+
Add `--force` to reinstall KnightCode when the selected update includes KnightCode.
|
|
336
|
+
|
|
337
|
+
### Aliases and command options
|
|
338
|
+
|
|
339
|
+
- `knightcode uninstall <source>` is an alias for `knightcode remove <source>`.
|
|
340
|
+
- `knightcode update --self`, `knightcode update self`, and `knightcode update knightcode` are aliases for `knightcode update`.
|
|
341
|
+
- `knightcode update --extension <source>` is an alias for `knightcode update <source>`.
|
|
342
|
+
- `-a`, `--approve` trusts project-local files for one command. `-na`, `--no-approve` ignores trust-gated project-local files.
|
|
343
|
+
- Append `-h` or `--help` to a command for its exact usage and option constraints.
|
|
344
|
+
|
|
345
|
+
## Credential commands
|
|
346
|
+
|
|
347
|
+
```sh
|
|
348
|
+
knightcode auth check --provider openai --json
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Authentication commands require `--provider <provider>` or `--model <model>`. See [Providers](providers.md) for supported methods.
|
|
352
|
+
|
|
353
|
+
| Command | Description |
|
|
354
|
+
|---|---|
|
|
355
|
+
| `knightcode auth check` | Print `ready`, `not_ready`, or `invalid`; exit with status `0`, `1`, or `2`, respectively |
|
|
356
|
+
| `knightcode auth print-api-key` | Print the resolved API key |
|
|
357
|
+
| `knightcode auth print-bearer-token` | Print a resolved OAuth bearer token |
|
|
358
|
+
|
|
359
|
+
| Option | Applies to | Description |
|
|
360
|
+
|---|---|---|
|
|
361
|
+
| `--provider <provider>` | All | Resolve credentials for a provider |
|
|
362
|
+
| `--model <model>` | All | Resolve credentials from a model; may be combined with `--provider` |
|
|
363
|
+
| `--json` | `auth check` | Write the structured result as JSON |
|
|
364
|
+
| `--credentials` | `auth check` | Emit the resolved credential when ready |
|
|
365
|
+
| `--no-refresh` | `auth check` | Do not refresh expired OAuth credentials; refresh is the default |
|
|
366
|
+
| `--min-expiry <duration>` | `print-bearer-token` | Require remaining token lifetime using `ms`, `s`, `m`, or `h`, such as `30m` |
|
|
367
|
+
|
|
368
|
+
Credential-printing commands write secrets to stdout.
|
|
369
|
+
|
|
370
|
+
## App server
|
|
371
|
+
|
|
372
|
+
`knightcode app-server` hosts many threads in one headless process. It reads
|
|
373
|
+
newline-delimited JSON requests from stdin, writes protocol messages to stdout,
|
|
374
|
+
and logs to stderr. It exits when stdin closes, unloading sessions and releasing
|
|
375
|
+
their locks. See [App Server](app-server.md) for the handshake, threads, approvals,
|
|
376
|
+
payload retrieval, and limits.
|
|
377
|
+
|
|
378
|
+
## MCP commands
|
|
379
|
+
|
|
380
|
+
These commands work outside a session, so agents can run them through `bash`. See [MCP Servers](mcp.md).
|
|
381
|
+
|
|
382
|
+
| Command | Description |
|
|
383
|
+
|---|---|
|
|
384
|
+
| `knightcode mcp add <server> [options] -- <command> [args...]` | Add or replace a stdio server in `mcp.json`; `--env KEY=VALUE` (repeatable) and `--cwd <dir>` set its environment and working directory. Arguments after the command are passed to it |
|
|
385
|
+
| `knightcode mcp add <server> [options] --url <url>` | Add or replace a streamable HTTP server; `--header KEY=VALUE` (repeatable), `--bearer-token-env-var <NAME>` (sends `Authorization: Bearer ${NAME}`), `--oauth-client-id`, `--oauth-client-secret`, `--oauth-callback-port`, and `--oauth-client-name` configure authentication |
|
|
386
|
+
| `knightcode mcp remove <server>` | Remove a server from `mcp.json`; stored OAuth credentials are kept |
|
|
387
|
+
| `knightcode mcp list [--json]` | Connect to every enabled server and print its state, tools, and errors; exit with `1` when a config entry is invalid or an enabled server is not connected |
|
|
388
|
+
| `knightcode mcp login <server> [--timeout <seconds>]` | Sign in to an OAuth server: open the authorization page and wait for the browser; a terminal also accepts the pasted redirect URL. `--timeout` limits the whole sign-in, including requests to the authorization server (default 300 seconds) |
|
|
389
|
+
| `knightcode mcp logout <server>` | Delete the stored OAuth credentials of a server |
|
|
390
|
+
|
|
391
|
+
`add` and `remove` change `~/.knightcode/agent/mcp.json`, or `.knightcode/mcp.json` in the current directory with `--local` (`-l`). `add` also takes `--exposure <mode>` (see [Exposure](mcp.md#exposure)) and `--description <text>` and does not connect; run `knightcode mcp list` to check the server.
|
|
392
|
+
|
|
393
|
+
Project `.knightcode/mcp.json` files are only read for projects that are already trusted.
|