@knightcodeai/cli-linux-x64 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/CHANGELOG.md +50 -0
- package/bin/README.md +52 -19
- package/bin/docs/cli-integration.md +106 -0
- package/bin/docs/cli.md +270 -0
- package/bin/docs/compaction.md +56 -37
- package/bin/docs/configuration.md +46 -0
- package/bin/docs/containerization.md +86 -54
- package/bin/docs/custom-provider.md +132 -785
- package/bin/docs/docs.json +143 -103
- package/bin/docs/environment-variables.md +5 -4
- package/bin/docs/extensions.md +134 -2956
- package/bin/docs/how-knightcode-works.md +49 -0
- package/bin/docs/index.md +24 -69
- package/bin/docs/json.md +193 -65
- package/bin/docs/keybindings.md +56 -101
- package/bin/docs/llama-cpp.md +3 -3
- package/bin/docs/message-types.md +261 -0
- package/bin/docs/models.md +64 -547
- package/bin/docs/packages.md +66 -167
- package/bin/docs/prompt-templates.md +31 -68
- package/bin/docs/providers.md +103 -241
- package/bin/docs/quickstart.md +61 -106
- package/bin/docs/rpc-commands.md +854 -0
- package/bin/docs/rpc-extension-ui.md +200 -0
- package/bin/docs/rpc.md +129 -1556
- package/bin/docs/sdk.md +76 -1160
- package/bin/docs/security.md +70 -32
- package/bin/docs/session-format.md +25 -216
- package/bin/docs/sessions.md +38 -143
- package/bin/docs/settings.md +111 -389
- package/bin/docs/shell-aliases.md +85 -5
- package/bin/docs/skills.md +51 -189
- package/bin/docs/slash-commands.md +63 -0
- package/bin/docs/terminal-setup.md +107 -79
- package/bin/docs/termux.md +74 -83
- package/bin/docs/themes.md +68 -280
- package/bin/docs/tmux.md +31 -39
- package/bin/docs/tui.md +69 -923
- package/bin/docs/usage.md +79 -286
- package/bin/docs/windows.md +43 -17
- package/bin/export-html/template.js +6 -1
- package/bin/knightcode +2 -2
- package/bin/package.json +6 -6
- package/package.json +1 -1
- package/bin/docs/development.md +0 -71
package/bin/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @knightcodeai/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added Claude Opus 5.5 to the Anthropic catalog: 1M context, image input, xhigh and max effort levels, and the mid-conversation effort and system-message support the newer Opus models use.
|
|
8
|
+
|
|
9
|
+
- Added Grok 4.7 to the xAI catalog and made it the default xAI model. xAI models now carry their long-context pricing tier, so requests above 200k input tokens are costed at the higher rate.
|
|
10
|
+
|
|
11
|
+
- Added the `context_with_system` extension event. It runs after the `context` handlers on the full transcript, system messages included, and its result is sent as returned.
|
|
12
|
+
|
|
13
|
+
- Added per-model image resize profiles through `inputLimits.images.resize` in `models.json` and `modelOverrides`. File attachments, `read` and tool-result images are resized once for the selected model before they enter history; built-in vision models carry the previous 2000x2000, 4.5 MiB default explicitly.
|
|
14
|
+
|
|
15
|
+
- Added a crash hint naming loaded extensions whose files appear in the crash stack trace, with the commands to disable them.
|
|
16
|
+
|
|
17
|
+
- Added append-only context edits and actionable turn boundaries for extensions. A `context_edit` entry omits or replaces an earlier message in future model requests without changing raw history, usage or exports, and `turn_end` plus the new `agent_before_settle` event can append entries and ask for one more provider request. See `docs/extensions.md` and `docs/session-format.md`.
|
|
18
|
+
|
|
19
|
+
- Added a session scratchpad, off by default: `/tools scratchpad on` gives the agent a private per-session temp directory for throwaway files and restores its `notes.md` there after each compaction.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Changed the session file to be the source of model context. SDK code that assigned `session.agent.state.messages` to restore history no longer affects the next request: restore with `SessionManager.inMemory(cwd, { id }, entries)` or move with `session.navigateTree()`. Extensions that switch exhaustively must handle the `context_edit` entry and the `agent_before_settle` event, `turn_end` events now carry the persisted entry ids, and runs started from an `agent_settled` handler wait until every settled handler has finished.
|
|
24
|
+
|
|
25
|
+
### Removed
|
|
26
|
+
|
|
27
|
+
- Removed the `shouldStopAfterTurn` agent option. Return `{ action: "end" }` from `finishTurn` instead, and return nothing for error and aborted responses to keep the old normal-response-only behaviour.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Fixed a missing or invalid `--mode` value being silently ignored; KnightCode now reports the valid values and exits with a nonzero status.
|
|
32
|
+
|
|
33
|
+
- Fixed split-turn compaction summaries being refused by Claude Fable 5.1. The summarization request now separates the conversation from the instructions and asks for a continuation checkpoint instead of a prefix summary.
|
|
34
|
+
|
|
35
|
+
- Fixed image-only prompts being rejected by some OpenAI-compatible providers, which refused the empty text part sent alongside the image.
|
|
36
|
+
|
|
37
|
+
- Fixed text files that begin with `GIF` being treated as images and left out of `read` and `@file` input. Detection now requires the full GIF87a or GIF89a signature.
|
|
38
|
+
|
|
39
|
+
- Fixed `/bug` uploading a report in offline mode. Uploads are refused with a pointer to Export as Zip, which still works offline.
|
|
40
|
+
|
|
41
|
+
- Fixed prompt templates with invalid YAML frontmatter being dropped silently. They are now reported as resource warnings, and valid templates beside them still load.
|
|
42
|
+
|
|
43
|
+
- Fixed the jump-to-latest label in fullscreen mode shifting sideways when the scrollbar auto-hides.
|
|
44
|
+
|
|
45
|
+
- Fixed abandoned attempts staying in the model's context after an error retry or a length/overflow recovery. The retried request now omits them; the raw transcript, exports and usage totals still show them.
|
|
46
|
+
|
|
47
|
+
- Fixed `context` extension handlers that filter or slice messages dropping the system prompt and tool declarations, which after extension-driven compaction left requests without built-in tools. Handlers no longer see system messages, and KnightCode restores the prompt and tools after they run.
|
|
48
|
+
|
|
49
|
+
- Fixed custom OpenAI-compatible endpoints receiving strict tool schemas they may reject. Built-in models that support strict tools keep them, and a custom model can opt back in with `compat.supportsStrictMode: true`.
|
|
50
|
+
|
|
51
|
+
- Fixed session files with an invalid session id in their header opening normally. Extensions build directory paths from that id, so such a file is now refused with the same error as an invalid `--session-id`.
|
|
52
|
+
|
|
3
53
|
## 0.9.1
|
|
4
54
|
|
|
5
55
|
### Added
|
package/bin/README.md
CHANGED
|
@@ -1,36 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://knightcode.dev">
|
|
3
|
+
<img alt="KnightCode logo" src="https://knightcode.dev/knightcode-mark.svg" width="128">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<a href="https://www.npmjs.com/package/@knightcodeai/cli"><img alt="npm" src="https://img.shields.io/npm/v/@knightcodeai/cli?style=flat-square&logo=npm&logoColor=white" /></a>
|
|
8
|
+
</p>
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
> New issues and PRs from new contributors are closed automatically. Maintainers review closed submissions daily. See [CONTRIBUTING.md](https://github.com/KnightCodeAI/knightcode/blob/main/CONTRIBUTING.md).
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
# KnightCode
|
|
13
|
+
|
|
14
|
+
KnightCode is a minimal, extensible AI agent for the terminal. Adapt KnightCode to your workflow, not the other way around.
|
|
15
|
+
|
|
16
|
+
Ask KnightCode to create the prompt templates, skills, extensions, and themes you need, or install a KnightCode package. Use KnightCode directly, automate it in print, JSON, or RPC mode, or build applications with the TypeScript SDK.
|
|
17
|
+
|
|
18
|
+
## Getting started
|
|
19
|
+
|
|
20
|
+
Install the command-line interface with npm:
|
|
6
21
|
|
|
7
22
|
```bash
|
|
8
|
-
npm install -g @knightcodeai/cli
|
|
23
|
+
npm install -g --ignore-scripts @knightcodeai/cli
|
|
9
24
|
```
|
|
10
25
|
|
|
11
|
-
You
|
|
12
|
-
(`bin/knightcode`) that spawns it runs on Node.js (>=18), which you already have
|
|
13
|
-
if you installed with npm. The right platform binary installs automatically as
|
|
14
|
-
an optional dependency.
|
|
26
|
+
This requires Node.js 22 or newer. KnightCode does not require dependency lifecycle scripts for a normal npm installation. You do not need Bun: it is bundled into the platform binary, which installs automatically as an optional dependency for Linux (x64, arm64), macOS (x64, arm64), and Windows (x64).
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
On macOS or Linux, you can instead use the installer:
|
|
17
29
|
|
|
18
30
|
```bash
|
|
31
|
+
curl -fsSL https://knightcode.dev/install.sh | sh
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Start KnightCode in the directory where you want it to work:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd /path/to/project
|
|
19
38
|
knightcode
|
|
20
39
|
```
|
|
21
40
|
|
|
22
|
-
|
|
41
|
+
For a built-in AI provider, run `/login` inside KnightCode to connect a subscription or API key. Then give KnightCode a task.
|
|
42
|
+
|
|
43
|
+
See the [documentation](docs/index.md) for full setup and usage instructions.
|
|
23
44
|
|
|
24
|
-
##
|
|
45
|
+
## Development
|
|
25
46
|
|
|
26
|
-
|
|
47
|
+
Clone the repository, install its dependencies, and run KnightCode from source:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
git clone https://github.com/KnightCodeAI/knightcode
|
|
51
|
+
cd knightcode
|
|
52
|
+
bun install
|
|
53
|
+
bun run start
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`bun run start` runs the CLI from source with the repository's `.env` loaded.
|
|
57
|
+
|
|
58
|
+
Before submitting changes, run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
bun run check-types
|
|
62
|
+
cd packages/<package> && bun x vitest --run test/<changed>.test.ts
|
|
63
|
+
```
|
|
27
64
|
|
|
28
|
-
|
|
29
|
-
| ----------------- | ------ |
|
|
30
|
-
| `knightcode --version` | Print the installed version |
|
|
31
|
-
| `knightcode doctor` | Print diagnostics (config, database, API key, runtime) |
|
|
32
|
-
| `KNIGHTCODE_NO_UPDATE_CHECK=1` | Disable the background update check |
|
|
65
|
+
Read [CONTRIBUTING.md](https://github.com/KnightCodeAI/knightcode/blob/main/CONTRIBUTING.md) before opening an issue or pull request. It defines the contribution gate, issue quality bar, and required checks. Read [AGENTS.md](https://github.com/KnightCodeAI/knightcode/blob/main/AGENTS.md) for repository-specific implementation, testing, dependency, and release rules.
|
|
33
66
|
|
|
34
|
-
##
|
|
67
|
+
## License
|
|
35
68
|
|
|
36
|
-
|
|
69
|
+
MIT
|
|
@@ -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.
|
|
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/bin/docs/cli.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
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
|
+
```
|
|
17
|
+
|
|
18
|
+
<a id="modes"></a>
|
|
19
|
+
|
|
20
|
+
## Invocation and output
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
knightcode
|
|
24
|
+
knightcode --print "Summarize this repository"
|
|
25
|
+
git diff | knightcode --print "Review this change"
|
|
26
|
+
knightcode --mode json "Inspect this repository" > events.jsonl
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
| Input | Behavior |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `message` | Provide an initial prompt |
|
|
34
|
+
| `@path` | Include a text file or image in the first prompt |
|
|
35
|
+
| Piped stdin | Prepend its contents to the first prompt |
|
|
36
|
+
| `--` | Stop option parsing so a prompt can begin with `-` |
|
|
37
|
+
|
|
38
|
+
KnightCode resolves `@path` from the current working directory. The working directory also controls project configuration, resource discovery, and session grouping.
|
|
39
|
+
|
|
40
|
+
`--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.
|
|
41
|
+
|
|
42
|
+
| Option | Behavior |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `-p`, `--print` | Run the supplied prompts, write the final assistant text to stdout, then exit |
|
|
45
|
+
| `--mode text` | Select text output; still open the terminal UI when stdin and stdout are terminals |
|
|
46
|
+
| `--mode json` | Run the supplied prompts, write JSONL events to stdout, then exit |
|
|
47
|
+
| `--mode rpc` | Read JSONL commands from stdin and write responses and events to stdout until shutdown |
|
|
48
|
+
| `--export <input> [output]` | Export a session file to HTML and exit; derive the destination when `output` is omitted |
|
|
49
|
+
|
|
50
|
+
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).
|
|
51
|
+
|
|
52
|
+
<a id="model-options"></a>
|
|
53
|
+
|
|
54
|
+
## Models
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
knightcode --model sonnet:high
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See [Choose a Model](models.md) for model selection and [Provider Authentication](providers.md) for credentials.
|
|
61
|
+
|
|
62
|
+
- `--provider <name>`<br>
|
|
63
|
+
Restricts `--model` lookup to one provider.
|
|
64
|
+
- `--model <pattern>`<br>
|
|
65
|
+
Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix.
|
|
66
|
+
- `--api-key <key>`<br>
|
|
67
|
+
Uses a non-persistent API-key override. It requires a model selected through `--model` or `--models`.
|
|
68
|
+
- `--thinking <level>`<br>
|
|
69
|
+
Sets `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`. It overrides a `--model` suffix and is clamped to the model's capabilities.
|
|
70
|
+
- `--models <patterns>`<br>
|
|
71
|
+
Sets a comma-separated scope for startup and cycling. It accepts exact IDs, fuzzy matches, case-insensitive globs, and optional `:<thinking>` suffixes.
|
|
72
|
+
- `--list-models [search]`<br>
|
|
73
|
+
Lists available models, optionally filtered by a fuzzy search, then exits.
|
|
74
|
+
|
|
75
|
+
<a id="session-options"></a>
|
|
76
|
+
|
|
77
|
+
## Sessions
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
knightcode --continue
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
See [Sessions and Context](sessions.md) for resuming, forking, naming, and storing sessions.
|
|
84
|
+
|
|
85
|
+
- `-c`, `--continue`<br>
|
|
86
|
+
Continues the most recent session for the current project.
|
|
87
|
+
- `-r`, `--resume`<br>
|
|
88
|
+
Opens the session selector.
|
|
89
|
+
- `--session <path|id>`<br>
|
|
90
|
+
Opens by file path, exact ID, or partial ID. KnightCode searches the current project first and offers to fork a cross-project match.
|
|
91
|
+
- `--session-id <id>`<br>
|
|
92
|
+
Opens the exact project session ID or creates it if absent. IDs accept letters, numbers, `.`, `_`, and `-`.
|
|
93
|
+
- `--fork <path|id>`<br>
|
|
94
|
+
Forks an existing session into a new session for the current project.
|
|
95
|
+
- `--session-dir <dir>`<br>
|
|
96
|
+
Overrides storage and lookup. It takes precedence over `KNIGHTCODE_CODING_AGENT_SESSION_DIR` and the `sessionDir` setting.
|
|
97
|
+
- `--no-session`<br>
|
|
98
|
+
Uses an in-memory session that is not persisted.
|
|
99
|
+
- `-n`, `--name <name>`<br>
|
|
100
|
+
Sets the session display name.
|
|
101
|
+
|
|
102
|
+
Constraints:
|
|
103
|
+
|
|
104
|
+
- Session IDs must start and end with a letter or number.
|
|
105
|
+
- `--fork` cannot be combined with `--session`, `--continue`, `--resume`, or `--no-session`.
|
|
106
|
+
- `--session-id` cannot be combined with `--session`, `--continue`, or `--resume`. Combine it with `--fork` to choose the new ID.
|
|
107
|
+
|
|
108
|
+
<a id="tool-options"></a>
|
|
109
|
+
|
|
110
|
+
## Tools
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
knightcode --tools read,grep,find,ls --print "Review this project"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
See [Settings](settings.md#tools) for configuring the default tool selection.
|
|
117
|
+
|
|
118
|
+
- `-t`, `--tools <list>`<br>
|
|
119
|
+
Replaces the default selection with a comma-separated allowlist of built-in, extension, or custom tools.
|
|
120
|
+
- `-xt`, `--exclude-tools <list>`<br>
|
|
121
|
+
Disables comma-separated tool names after all other selection options.
|
|
122
|
+
- `-nbt`, `--no-builtin-tools`<br>
|
|
123
|
+
Disables default built-in tools while retaining extension and custom tools.
|
|
124
|
+
- `-nt`, `--no-tools`<br>
|
|
125
|
+
Starts with all built-in, extension, and custom tools disabled.
|
|
126
|
+
|
|
127
|
+
Default enabled tools are `read`, `bash`, `edit`, and `write`, unless `defaultTools` changes them.
|
|
128
|
+
|
|
129
|
+
| Built-in | Purpose |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `read` | Read text files and supported images |
|
|
132
|
+
| `bash` | Run shell commands |
|
|
133
|
+
| `powershell` | Run PowerShell commands on Windows |
|
|
134
|
+
| `edit` | Apply exact text replacements to an existing file |
|
|
135
|
+
| `write` | Create or overwrite a file |
|
|
136
|
+
| `grep` | Search file contents |
|
|
137
|
+
| `find` | Find paths using glob patterns |
|
|
138
|
+
| `ls` | List directory contents |
|
|
139
|
+
|
|
140
|
+
The [web tools](usage.md#web-tools) `webfetch` and `websearch` are off until enabled with `/tools`. A tool excluded here stays off whatever `/tools` says.
|
|
141
|
+
|
|
142
|
+
<a id="resource-options"></a>
|
|
143
|
+
|
|
144
|
+
## Resources
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
knightcode --extension ./review.ts
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
- `-e`, `--extension <path>`<br>
|
|
153
|
+
Loads an extension file or directory and is repeatable.
|
|
154
|
+
- `-ne`, `--no-extensions`<br>
|
|
155
|
+
Disables discovered and configured extensions. Explicit `-e` paths still load.
|
|
156
|
+
- `--skill <path>`<br>
|
|
157
|
+
Loads a skill file or directory and is repeatable.
|
|
158
|
+
- `-ns`, `--no-skills`<br>
|
|
159
|
+
Disables discovered and configured skills. Explicit `--skill` paths still load.
|
|
160
|
+
- `--prompt-template <path>`<br>
|
|
161
|
+
Loads a prompt-template file or directory and is repeatable.
|
|
162
|
+
- `-np`, `--no-prompt-templates`<br>
|
|
163
|
+
Disables discovered and configured templates. Explicit `--prompt-template` paths still load.
|
|
164
|
+
- `--theme <path>`<br>
|
|
165
|
+
Loads a theme file or directory and is repeatable.
|
|
166
|
+
- `--use-theme <name[/name]>`<br>
|
|
167
|
+
Selects the initial interactive theme for this run.
|
|
168
|
+
- `--no-themes`<br>
|
|
169
|
+
Disables discovered and configured themes. Explicit `--theme` paths still load.
|
|
170
|
+
- `-nc`, `--no-context-files`<br>
|
|
171
|
+
Disables `AGENTS.md` and `CLAUDE.md` discovery.
|
|
172
|
+
|
|
173
|
+
Resource paths apply only to the current process. Relative paths resolve from the current working directory.
|
|
174
|
+
|
|
175
|
+
<a id="prompt-and-display-options"></a>
|
|
176
|
+
|
|
177
|
+
## Prompts and process
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
knightcode --append-system-prompt ./instructions.md
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
- `--system-prompt <text|path>`<br>
|
|
186
|
+
Replaces the default system prompt with text or the contents of an existing file.
|
|
187
|
+
- `--append-system-prompt <text|path>`<br>
|
|
188
|
+
Appends text or an existing file to the system prompt and is repeatable.
|
|
189
|
+
- `--tui-mode <mode>`<br>
|
|
190
|
+
Uses `regular` or `fullscreen` terminal mode.
|
|
191
|
+
- `--verbose`<br>
|
|
192
|
+
Shows verbose interactive startup information, overriding `quietStartup`.
|
|
193
|
+
- `-a`, `--approve`<br>
|
|
194
|
+
Trusts project-local configuration and resources for this process.
|
|
195
|
+
- `-na`, `--no-approve`<br>
|
|
196
|
+
Ignores trust-gated project-local configuration and resources for this process.
|
|
197
|
+
- `--offline`<br>
|
|
198
|
+
Disables automatic network activity, including model catalog refreshes. Equivalent to `KNIGHTCODE_OFFLINE=1`.
|
|
199
|
+
- `-h`, `--help`<br>
|
|
200
|
+
Shows help, including flags registered by loaded extensions, then exits.
|
|
201
|
+
- `-v`, `--version`<br>
|
|
202
|
+
Shows the KnightCode version, then exits.
|
|
203
|
+
|
|
204
|
+
Extensions may register additional long-form options. Unknown short options are rejected.
|
|
205
|
+
|
|
206
|
+
## Package commands
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
knightcode install npm:@scope/package
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
See [KnightCode Packages](packages.md) for source formats, filtering, installation, and project scope.
|
|
213
|
+
|
|
214
|
+
### Common tasks
|
|
215
|
+
|
|
216
|
+
| Task | Command |
|
|
217
|
+
|---|---|
|
|
218
|
+
| Install a package | `knightcode install <source>` |
|
|
219
|
+
| List configured packages | `knightcode list` |
|
|
220
|
+
| Remove a package and its settings entry | `knightcode remove <source>` |
|
|
221
|
+
| Configure which package resources load | `knightcode config` |
|
|
222
|
+
|
|
223
|
+
Add `--local` or `-l` to `install`, `remove`, `uninstall`, or `config` to use project settings instead of global settings.
|
|
224
|
+
|
|
225
|
+
### Update KnightCode or packages
|
|
226
|
+
|
|
227
|
+
Running `knightcode update` without a target updates KnightCode itself.
|
|
228
|
+
|
|
229
|
+
| Task | Command |
|
|
230
|
+
|---|---|
|
|
231
|
+
| Update KnightCode | `knightcode update` |
|
|
232
|
+
| Update all installed packages | `knightcode update --extensions` |
|
|
233
|
+
| Update one installed package | `knightcode update <source>` |
|
|
234
|
+
| Refresh model catalogs | `knightcode update --models` |
|
|
235
|
+
| Update KnightCode and all installed packages | `knightcode update --all` |
|
|
236
|
+
|
|
237
|
+
Add `--force` to reinstall KnightCode when the selected update includes KnightCode.
|
|
238
|
+
|
|
239
|
+
### Aliases and command options
|
|
240
|
+
|
|
241
|
+
- `knightcode uninstall <source>` is an alias for `knightcode remove <source>`.
|
|
242
|
+
- `knightcode update --self`, `knightcode update self`, and `knightcode update knightcode` are aliases for `knightcode update`.
|
|
243
|
+
- `knightcode update --extension <source>` is an alias for `knightcode update <source>`.
|
|
244
|
+
- `-a`, `--approve` trusts project-local files for one command. `-na`, `--no-approve` ignores trust-gated project-local files.
|
|
245
|
+
- Append `-h` or `--help` to a command for its exact usage and option constraints.
|
|
246
|
+
|
|
247
|
+
## Credential commands
|
|
248
|
+
|
|
249
|
+
```sh
|
|
250
|
+
knightcode auth check --provider openai --json
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Authentication commands require `--provider <provider>` or `--model <model>`. See [Provider Authentication](providers.md) for supported methods.
|
|
254
|
+
|
|
255
|
+
| Command | Description |
|
|
256
|
+
|---|---|
|
|
257
|
+
| `knightcode auth check` | Print `ready`, `not_ready`, or `invalid`; exit with status `0`, `1`, or `2`, respectively |
|
|
258
|
+
| `knightcode auth print-api-key` | Print the resolved API key |
|
|
259
|
+
| `knightcode auth print-bearer-token` | Print a resolved OAuth bearer token |
|
|
260
|
+
|
|
261
|
+
| Option | Applies to | Description |
|
|
262
|
+
|---|---|---|
|
|
263
|
+
| `--provider <provider>` | All | Resolve credentials for a provider |
|
|
264
|
+
| `--model <model>` | All | Resolve credentials from a model; may be combined with `--provider` |
|
|
265
|
+
| `--json` | `auth check` | Write the structured result as JSON |
|
|
266
|
+
| `--credentials` | `auth check` | Emit the resolved credential when ready |
|
|
267
|
+
| `--no-refresh` | `auth check` | Do not refresh expired OAuth credentials; refresh is the default |
|
|
268
|
+
| `--min-expiry <duration>` | `print-bearer-token` | Require remaining token lifetime using `ms`, `s`, `m`, or `h`, such as `30m` |
|
|
269
|
+
|
|
270
|
+
Credential-printing commands write secrets to stdout.
|