@knightcodeai/cli-linux-x64 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/CHANGELOG.md +72 -0
- package/bin/docs/cli.md +6 -16
- package/bin/docs/codemode.md +207 -0
- package/bin/docs/docs.json +5 -1
- package/bin/docs/environment-variables.md +2 -2
- package/bin/docs/extensions.md +1 -1
- package/bin/docs/index.md +1 -1
- package/bin/docs/mcp.md +23 -4
- package/bin/docs/models.md +22 -1
- package/bin/docs/providers.md +18 -6
- package/bin/docs/sdk.md +1 -1
- package/bin/docs/settings.md +5 -3
- package/bin/docs/usage.md +1 -1
- package/bin/knightcode +2 -2
- package/bin/package.json +6 -7
- package/package.json +1 -1
package/bin/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
# @knightcodeai/cli
|
|
2
2
|
|
|
3
|
+
## 0.11.3
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added Anthropic workload identity federation from the Anthropic SDK environment variables `ANTHROPIC_FEDERATION_RULE_ID`, `ANTHROPIC_ORGANIZATION_ID` and `ANTHROPIC_IDENTITY_TOKEN_FILE`, plus the optional `ANTHROPIC_SERVICE_ACCOUNT_ID` and `ANTHROPIC_WORKSPACE_ID`. API keys and `ANTHROPIC_AUTH_TOKEN` take precedence.
|
|
8
|
+
|
|
9
|
+
- Added a copy-code login method to Anthropic sign-in for machines where the browser runs elsewhere and the localhost callback cannot load. `/login` now asks for browser or copy-code login, and copy-code login asks you to paste the code Anthropic shows.
|
|
10
|
+
|
|
11
|
+
- Added `quietStartup: "header"`, which keeps the startup header with version and key hints but hides the model scope line and loaded-resource listing.
|
|
12
|
+
|
|
13
|
+
- Added Radius to `/login`: "Sign in with Radius" is the last top-level option, with its status, and after signing in `/login` offers to add the Radius MCP server to the global `mcp.json` with `"auth": { "provider": "radius" }`. Cancelling a login returns to the menu it was started from, only subscription-backed providers are labeled "subscription" (other OAuth sign-ins say "account"), and providers without credentials say "not configured".
|
|
14
|
+
|
|
15
|
+
- Added `models.generateImages()` to codemode scripts. It runs image models such as OpenRouter's with the session's credentials and returns image blocks that `image()` attaches to the result; usage counts toward the session cost. Extensions can call `ctx.modelRegistry.generateImages()`.
|
|
16
|
+
|
|
17
|
+
- Added `"auth": { "provider": "<provider>" }` for HTTP MCP servers to send a provider's current `/login` token as the bearer token instead of using MCP OAuth. The token is read on every request, so provider refreshes apply. It is only allowed in the global `mcp.json` and from extensions, and requires https except on loopback hosts.
|
|
18
|
+
|
|
19
|
+
- Added an `oauth.authServerMetadataUrl` setting for MCP servers that advertise a wrong OAuth authorization server or none. KnightCode uses the configured metadata document instead of discovery.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Changed the default TUI mode to fullscreen. Set `tuiMode` to `"regular"` or pass `--tui-mode regular` to keep the terminal's normal scrollback.
|
|
24
|
+
|
|
25
|
+
- Changed codemode to cost far fewer prompt tokens and to say how to recover from errors. The `codemode` description lists the script globals in one line each and points to the new Codemode docs page; reading a tool or `models` member that does not exist names the close matches, so scripts that probed with `typeof tools.name` must use `"name" in tools`.
|
|
26
|
+
|
|
27
|
+
- Changed `/arminsayshi` to play a 3D version in fullscreen mode, with one cube per pixel of Armin.
|
|
28
|
+
|
|
29
|
+
- Changed MCP OAuth credential storage to key credentials by server name and URL, so MCP servers with the same URL can sign in with different accounts. Credentials stored by URL alone move to the first server that uses them.
|
|
30
|
+
|
|
31
|
+
- Changed `/reload` to enable tools newly added to the `defaultTools` setting. Tools removed from it stay enabled, tools turned off during the session stay off unless newly added, and `--tools`, `--no-tools` and `--no-builtin-tools` still override the setting.
|
|
32
|
+
|
|
33
|
+
- Changed MCP servers without `direct` tools to connect in the background instead of blocking the first prompt. They are listed in a short `mcp_servers` system prompt section, and are waited for when a codemode script names them, a script searches tools, or `tool_search` runs. The `codemode` and `tool_search` descriptions no longer change when servers connect.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Fixed provider retries aborting or firing immediately when a `Retry-After` or `retry-after-ms` value is too large to represent, such as `1e999`. They now use exponential backoff, as they do for an unparseable date.
|
|
38
|
+
|
|
39
|
+
- Fixed Anthropic requests failing when a tool schema uses keywords Anthropic strict tool use rejects, such as `minimum` and `maximum`. Such tools are now sent non-strict.
|
|
40
|
+
|
|
41
|
+
- Fixed MCP servers that ask for more scope (`insufficient_scope`) requesting sign-in over and over. The new sign-in requested only the missing scopes, so the new token lost access the previous one had; it now keeps the granted scopes.
|
|
42
|
+
|
|
43
|
+
- Fixed memory retained per rendered message in the transcript: user messages keep one copy of each rendered line instead of two, and markdown, text and box components flatten their cached lines. A long assistant message keeps about a fifth of the heap it kept before.
|
|
44
|
+
|
|
45
|
+
- Fixed deferred MCP tools that `tool_search` loaded being dropped on resume and `/reload` even when their server reconnected before the next prompt, because the session restored its tools before the MCP servers reconnected.
|
|
46
|
+
|
|
47
|
+
- Fixed the system theme making pastel palettes such as Catppuccin Frappe much more vivid; palette colors now keep their chroma.
|
|
48
|
+
|
|
49
|
+
- Fixed `--provider` without `--model` being silently ignored and running the default model from another provider; it now fails with an error.
|
|
50
|
+
|
|
51
|
+
- Fixed prompt submission slowing down with session length, because resolving the session's model selection looked up the model catalog once per assistant message, and model lookups slowing down for providers with a refreshed remote catalog.
|
|
52
|
+
|
|
53
|
+
- Fixed MCP OAuth sign-in failing with `Invalid scope` when the token response contains `"scope": ""`, and similar failures for other empty or `null` optional OAuth fields, including `expires_in: null` marking the token as already expired.
|
|
54
|
+
|
|
55
|
+
- Fixed codemode scripts calling the wrong MCP tool when two tool names differ only in `-` and `_`, such as `read-file` and `read_file`. MCP tool and namespace names now replace `-` with `_` (`mcp__my-server__x` is now `mcp__my_server__x`), colliding tools of a server all get a hash suffix, and server names that differ only in `-` and `_` are rejected.
|
|
56
|
+
|
|
57
|
+
- Fixed collapsed `codemode` and MCP tool results filling the screen when the output is one long line, such as minified JSON. The preview is now limited to wrapped lines instead of logical lines.
|
|
58
|
+
|
|
59
|
+
- Fixed `codemode.mode: "only"` listing `read`, `bash`, `edit` and `write` in the system prompt's tool list although requests only declare `codemode`.
|
|
60
|
+
|
|
61
|
+
- Fixed extension commands registered without a string name or a handler crashing KnightCode when typing `/`. The extension now fails to load with an error instead.
|
|
62
|
+
|
|
63
|
+
- Fixed switching to another OpenAI Responses model after a codemode call failing with an invalid item id. A replayed grammar tool call now drops any id that does not match its item type, since `custom_tool_call` ids must start with `ctc_` and `function_call` ids with `fc_`.
|
|
64
|
+
|
|
65
|
+
- Fixed Together's DeepSeek V4 Pro losing its high reasoning-effort level after Together renamed the model to `deepseek-ai/DeepSeek-V4-Pro-0813`.
|
|
66
|
+
|
|
67
|
+
- Fixed color bleeding past mouse selections and search highlights in fullscreen mode when a styled token ends at the highlight boundary.
|
|
68
|
+
|
|
69
|
+
- Fixed slash command completion not working after leading whitespace in the editor. Typing ` /mod` now completes to ` /model` and keeps the whitespace.
|
|
70
|
+
|
|
71
|
+
### Security
|
|
72
|
+
|
|
73
|
+
- Security: MCP OAuth sign-in now rejects an authorization response whose `iss` parameter names another authorization server before exchanging the code (RFC 9207).
|
|
74
|
+
|
|
3
75
|
## 0.11.2
|
|
4
76
|
|
|
5
77
|
### Added
|
package/bin/docs/cli.md
CHANGED
|
@@ -58,10 +58,10 @@ RPC mode rejects `@file` arguments. JSON and RPC modes reserve stdout for protoc
|
|
|
58
58
|
knightcode --model sonnet:high
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
See [Choose a Model](models.md) for model selection and [
|
|
61
|
+
See [Choose a Model](models.md) for model selection and [Providers](providers.md) for credentials.
|
|
62
62
|
|
|
63
63
|
- `--provider <name>`<br>
|
|
64
|
-
Restricts `--model` lookup to one provider.
|
|
64
|
+
Restricts `--model` lookup to one provider. It requires `--model`.
|
|
65
65
|
- `--model <pattern>`<br>
|
|
66
66
|
Selects by exact ID or fuzzy ID/name match. It accepts `provider/id` and an optional `:<thinking>` suffix.
|
|
67
67
|
- `--api-key <key>`<br>
|
|
@@ -163,21 +163,11 @@ This keeps `read`, `bash`, `edit`, and `write` and adds `codemode`. For one invo
|
|
|
163
163
|
knightcode --tools read,bash,edit,write,codemode
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
Codemode is useful without MCP: scripts can run several tool calls in parallel, filter large output before it reaches the model,
|
|
166
|
+
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)).
|
|
167
167
|
|
|
168
168
|
### How codemode works
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
A script may start with an options line such as `// @options: {"max_output_tokens": 2000, "timeout_ms": 60000}`. `max_output_tokens` (default 10000) limits the output: longer output keeps its start and end, and the full text is written to a temp file whose path is included in the result. `timeout_ms` is a hard deadline, unset by default.
|
|
173
|
-
|
|
174
|
-
While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) decides how the other tools are presented. With `on` (default) declared tools keep being declared and their descriptions show how to call them from scripts. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
|
|
175
|
-
|
|
176
|
-
The `codemode` description lists the callable tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure, which includes MCP tools with the default `codemode` exposure, are not listed; their namespace is listed with its description. Declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](settings.md#tools)), and the description says whether the list is complete. Scripts find the rest with `await searchTools(query, { limit, namespace })`, which ranks tools with BM25, and `await describeTool(name)`, or by filtering `ALL_TOOLS`. `await describeNamespace(name)` returns a namespace's description, its instructions (for MCP servers, the server instructions), and the names of its tools.
|
|
177
|
-
|
|
178
|
-
Tools with an output schema resolve to structured values: `bash` to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes, and MCP tools to their `CallToolResult`. Other tools resolve to their text output. The `output` of `bash` is not limited to the 2000 lines or 50KB the model sees: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
|
|
179
|
-
|
|
180
|
-
`store(key, value)` and `load(key)` keep JSON values across `codemode` calls: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path. Scripts can also use `models`: `getModelsOfType`, `getAvailableOfType`, and `getModelOfType` list the model catalog, and `classify(model, context)` runs a classifier model with the session's credentials, at most four at a time per script.
|
|
170
|
+
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.
|
|
181
171
|
|
|
182
172
|
### Tool search
|
|
183
173
|
|
|
@@ -231,7 +221,7 @@ See [Configuration](configuration.md) for saved configuration, [Security](securi
|
|
|
231
221
|
- `--append-system-prompt <text|path>`<br>
|
|
232
222
|
Appends text or an existing file to the system prompt and is repeatable.
|
|
233
223
|
- `--tui-mode <mode>`<br>
|
|
234
|
-
Uses `
|
|
224
|
+
Uses `fullscreen` (default) or `regular` terminal mode.
|
|
235
225
|
- `--verbose`<br>
|
|
236
226
|
Shows verbose interactive startup information, overriding `quietStartup`.
|
|
237
227
|
- `-a`, `--approve`<br>
|
|
@@ -294,7 +284,7 @@ Add `--force` to reinstall KnightCode when the selected update includes KnightCo
|
|
|
294
284
|
knightcode auth check --provider openai --json
|
|
295
285
|
```
|
|
296
286
|
|
|
297
|
-
Authentication commands require `--provider <provider>` or `--model <model>`. See [
|
|
287
|
+
Authentication commands require `--provider <provider>` or `--model <model>`. See [Providers](providers.md) for supported methods.
|
|
298
288
|
|
|
299
289
|
| Command | Description |
|
|
300
290
|
|---|---|
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Codemode
|
|
2
|
+
|
|
3
|
+
The `codemode` tool lets the model write a JavaScript script that calls KnightCode's other tools and runs non-LLM models, such as classifiers and image models. Only the script's output reaches the model, so a script can run calls in parallel and filter large results before the model sees them. To turn it on, see [Enable codemode](cli.md#enable-codemode).
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
The tool input is raw JavaScript source, not JSON and not a markdown code fence. It runs as the body of an async function in a QuickJS sandbox, so top-level `await` and `return` work. The sandbox has no Node APIs, file system, network, or timers; scripts reach the outside world only through tools and `models`.
|
|
8
|
+
|
|
9
|
+
A script may start with an options line:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// @options: {"max_output_tokens": 2000, "timeout_ms": 60000}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- `max_output_tokens` (default 10000) limits the output. Longer output keeps its start and end, and the full text is written to a temp file whose path is included in the result.
|
|
16
|
+
- `timeout_ms` is a hard deadline for the whole script. It is unset by default. Image generation can take minutes, so do not set a short deadline for scripts that generate images.
|
|
17
|
+
|
|
18
|
+
The result starts with `Script completed` or `Script failed`, the wall time, and the output. A failed script keeps its partial output, followed by `Script error:` and the error. Tool calls are real: calls made before a failure are not undone. Calls still running when the script ends are cancelled, and unawaited promises are discarded.
|
|
19
|
+
|
|
20
|
+
## Globals
|
|
21
|
+
|
|
22
|
+
| Global | Purpose |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `tools.<name>(args)` | Call a tool. See [Call tools](#call-tools). |
|
|
25
|
+
| `text(value)` | Add a text item to the output. Strings are added as is, other values as JSON. |
|
|
26
|
+
| `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. |
|
|
27
|
+
| `console.log(...)` | Like `text()`; `info`, `warn`, `error`, and `debug` do the same. |
|
|
28
|
+
| `return value` | A top-level `return` adds the value like `text()`. |
|
|
29
|
+
| `exit()` | End the script successfully. |
|
|
30
|
+
| `store(key, value)` / `load(key)` | Keep small JSON values across `codemode` calls. See [Store values](#store-values). |
|
|
31
|
+
| `ALL_TOOLS` | Every callable tool as `{ name, description }`, including tools the description does not list. |
|
|
32
|
+
| `searchTools(query, { limit?, namespace? })` | Rank callable tools by relevance (BM25, default limit 8). Resolves to `{ name, description }[]`. |
|
|
33
|
+
| `describeTool(name)` | Resolves to a tool's description and TypeScript declaration, or `undefined`. |
|
|
34
|
+
| `describeNamespace(name)` | Resolves to `{ name, description?, instructions?, tools }` for a namespace such as an MCP server, or `undefined`. |
|
|
35
|
+
| `models` | List and run non-LLM models. See [Models](#models). |
|
|
36
|
+
|
|
37
|
+
## Call tools
|
|
38
|
+
|
|
39
|
+
Every tool the session can call is a method of `tools`, named by its identifier: characters that are not valid in a JavaScript identifier become `_`, so the MCP tool `mcp__dev-radius__search` is `tools.mcp__dev_radius__search`. Each method takes one object with the tool's arguments.
|
|
40
|
+
|
|
41
|
+
What a call resolves to depends on the tool:
|
|
42
|
+
|
|
43
|
+
- Tools with an output schema resolve to a structured value. `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes. Its `output` is not limited to the 2000 lines or 50KB the model sees: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
|
|
44
|
+
- MCP tools resolve to their `CallToolResult`, including `isError` and `structuredContent`.
|
|
45
|
+
- Other tools, such as `read`, `edit`, and `write`, resolve to their text output.
|
|
46
|
+
|
|
47
|
+
A call that fails, is blocked, or gets invalid arguments rejects with an `Error` that carries the tool's error text. Use `Promise.allSettled()` to keep the results of the calls that succeed.
|
|
48
|
+
|
|
49
|
+
The `codemode` description lists tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure, which includes MCP tools with the default `codemode` exposure, are not listed, so the description stays the same while MCP servers connect. Listed declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](settings.md#tools)). Scripts find the other tools with `searchTools()`, `describeTool()`, `describeNamespace()`, or by filtering `ALL_TOOLS`.
|
|
50
|
+
|
|
51
|
+
While `codemode` is active, `codemode.mode` in [settings](settings.md#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say how to call them from scripts. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
|
|
52
|
+
|
|
53
|
+
## Store values
|
|
54
|
+
|
|
55
|
+
`store(key, value)` keeps a JSON value under a string key for later `codemode` calls; storing `undefined` deletes the key. `load(key)` returns the value, or `undefined`. Writes are kept only when the script succeeds: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path.
|
|
56
|
+
|
|
57
|
+
The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()` or write them to a file with a tool.
|
|
58
|
+
|
|
59
|
+
## Models
|
|
60
|
+
|
|
61
|
+
`models` reaches the model catalog and runs non-LLM models with the session's credentials: classifiers, which answer typed questions about JSON state, and image models, which generate images. Chat models are listed but cannot be run from scripts. Which classifier and image models exist is described in [Use classifier models](models.md#use-classifier-models) and [Use image models](models.md#use-image-models).
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
type ModelType = "chat" | "image" | "classifier";
|
|
65
|
+
|
|
66
|
+
/** A catalog entry. `provider` and `id` identify it; other fields depend on the type. */
|
|
67
|
+
interface ModelInfo {
|
|
68
|
+
type?: ModelType;
|
|
69
|
+
provider: string;
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
api: string;
|
|
73
|
+
input: ("text" | "image")[];
|
|
74
|
+
contextWindow?: number;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare const models: {
|
|
79
|
+
/** Every known model of a type, optionally for one provider. */
|
|
80
|
+
getModelsOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
|
|
81
|
+
/** Models of a type whose provider has working credentials. */
|
|
82
|
+
getAvailableOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
|
|
83
|
+
/** One catalog entry, or undefined. */
|
|
84
|
+
getModelOfType(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>;
|
|
85
|
+
/** Answer `context.questions` about `context.state`; answers are in `result.answers` by question ID. */
|
|
86
|
+
classify(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>;
|
|
87
|
+
/** Generate images from `context.input` text and image blocks; show `result.output` blocks with image(). Can take minutes. */
|
|
88
|
+
generateImages(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>;
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`classify()` and `generateImages()` use only the `provider` and `id` of `model`, so `{ provider, id }` works as well. They do not throw on provider errors: check `stopReason` and `errorMessage`. At most four such calls run at once per script; more calls wait for a free slot, so `Promise.all()` over many items is fine. Their usage is added to the `codemode` tool result and counts toward the session cost.
|
|
93
|
+
|
|
94
|
+
Model IDs differ between providers, for example `typesafe/jev-latest` and `openrouter/typesafe/jev-1.13`. Use `models.getAvailableOfType(type)` to find the IDs that work with the current credentials.
|
|
95
|
+
|
|
96
|
+
### Classify
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
interface ClassifierContext {
|
|
100
|
+
/** The data to classify. */
|
|
101
|
+
state: Record<string, unknown>;
|
|
102
|
+
/** Questions by ID. One call answers all of them. */
|
|
103
|
+
questions: Record<string, ClassifierQuestion>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type ClassifierQuestion =
|
|
107
|
+
/** Pick one label. `criteria` maps each label to what it means. */
|
|
108
|
+
| { type: "choice"; instructions: string; criteria: Record<string, string> }
|
|
109
|
+
/** Score on an ordered scale. `criteria` describes each level, lowest first. */
|
|
110
|
+
| { type: "score"; instructions: string; criteria: string[] }
|
|
111
|
+
/** Yes or no. */
|
|
112
|
+
| { type: "bool"; instructions: string; criteria: { true: string; false: string } };
|
|
113
|
+
|
|
114
|
+
interface ClassifierResult {
|
|
115
|
+
provider: string;
|
|
116
|
+
model: string;
|
|
117
|
+
/** Answers by question ID. */
|
|
118
|
+
answers: Record<string, ClassifierAnswer>;
|
|
119
|
+
usage?: ModelUsage;
|
|
120
|
+
stopReason: "stop" | "error" | "aborted";
|
|
121
|
+
errorMessage?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type ClassifierAnswer =
|
|
125
|
+
| { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
|
|
126
|
+
/** `score` is the expected level index, from 0 to `criteria.length - 1`. */
|
|
127
|
+
| { type: "score"; score: number; confidence: number }
|
|
128
|
+
/** Probability of `true`. */
|
|
129
|
+
| { type: "bool"; probability: number };
|
|
130
|
+
|
|
131
|
+
/** Token counts and cost in USD, when the service reports them. */
|
|
132
|
+
type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } };
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Classify several items by calling `classify()` once per item. This script sorts feedback messages, for example ones a tool returned earlier in the script:
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
|
|
139
|
+
const results = await Promise.all(
|
|
140
|
+
messages.map((message) =>
|
|
141
|
+
models.classify(jev, {
|
|
142
|
+
state: { message },
|
|
143
|
+
questions: {
|
|
144
|
+
sentiment: {
|
|
145
|
+
type: "choice",
|
|
146
|
+
instructions: "How does the user feel about the product?",
|
|
147
|
+
criteria: { positive: "Satisfied or happy", negative: "Unhappy or frustrated", neutral: "Neither" },
|
|
148
|
+
},
|
|
149
|
+
urgency: {
|
|
150
|
+
type: "score",
|
|
151
|
+
instructions: "How urgently does this need a reply?",
|
|
152
|
+
criteria: ["no reply needed", "reply this week", "reply today"],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
return results.map((result, i) =>
|
|
159
|
+
result.stopReason === "stop"
|
|
160
|
+
? { message: messages[i], sentiment: result.answers.sentiment.choice, urgency: result.answers.urgency.score }
|
|
161
|
+
: { message: messages[i], error: result.errorMessage },
|
|
162
|
+
);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Generate images
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
interface ImagesContext {
|
|
169
|
+
/** The prompt as text blocks, plus image blocks to edit or use as references. */
|
|
170
|
+
input: (TextBlock | ImageBlock)[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface ImagesResult {
|
|
174
|
+
provider: string;
|
|
175
|
+
model: string;
|
|
176
|
+
/** Generated images, and text blocks for models that also return text. */
|
|
177
|
+
output: (TextBlock | ImageBlock)[];
|
|
178
|
+
usage?: ModelUsage;
|
|
179
|
+
stopReason: "stop" | "error" | "aborted";
|
|
180
|
+
errorMessage?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
type TextBlock = { type: "text"; text: string };
|
|
184
|
+
/** `data` is base64. */
|
|
185
|
+
type ImageBlock = { type: "image"; data: string; mimeType: string };
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text. Generated images are not saved to disk; to keep one, write it to a file with a tool.
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
// @options: {"timeout_ms": 300000}
|
|
192
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
193
|
+
const result = await models.generateImages(painter, {
|
|
194
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
195
|
+
});
|
|
196
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
197
|
+
for (const block of result.output) {
|
|
198
|
+
if (block.type === "image") image(block);
|
|
199
|
+
else text(block.text);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Limits
|
|
204
|
+
|
|
205
|
+
- A script's VM has 256 MB of memory. Running out throws `InternalError: out of memory`; filter or aggregate large data instead of accumulating it.
|
|
206
|
+
- A script that waits on a promise that can never settle (no tool call pending) fails immediately, since there are no timers.
|
|
207
|
+
- Scripts cannot start other `codemode` scripts.
|
package/bin/docs/docs.json
CHANGED
|
@@ -140,6 +140,10 @@
|
|
|
140
140
|
"title": "CLI",
|
|
141
141
|
"path": "cli.md"
|
|
142
142
|
},
|
|
143
|
+
{
|
|
144
|
+
"title": "Codemode",
|
|
145
|
+
"path": "codemode.md"
|
|
146
|
+
},
|
|
143
147
|
{
|
|
144
148
|
"title": "Slash Commands",
|
|
145
149
|
"path": "slash-commands.md"
|
|
@@ -157,7 +161,7 @@
|
|
|
157
161
|
"path": "keybindings.md"
|
|
158
162
|
},
|
|
159
163
|
{
|
|
160
|
-
"title": "
|
|
164
|
+
"title": "Providers",
|
|
161
165
|
"path": "providers.md"
|
|
162
166
|
},
|
|
163
167
|
{
|
|
@@ -6,7 +6,7 @@ KnightCode uses environment variables in three ways:
|
|
|
6
6
|
- KnightCode sets process markers so child processes can identify KnightCode as the launching agent.
|
|
7
7
|
- Commands run by the LLM-callable shell tools receive `KNIGHTCODE_*` variables describing the current session.
|
|
8
8
|
|
|
9
|
-
Provider API-key variables are documented separately in [
|
|
9
|
+
Provider API-key variables are documented separately in [Providers](providers.md#use-an-api-key-from-the-environment).
|
|
10
10
|
|
|
11
11
|
## Process Marker
|
|
12
12
|
|
|
@@ -100,4 +100,4 @@ These variables are read by KnightCode itself:
|
|
|
100
100
|
| `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
|
|
101
101
|
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
102
102
|
|
|
103
|
-
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and
|
|
103
|
+
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and provider-specific configuration are listed in [Providers](providers.md#use-an-api-key-from-the-environment).
|
package/bin/docs/extensions.md
CHANGED
|
@@ -177,7 +177,7 @@ knightcode.on("tool_call", async (event, ctx) => {
|
|
|
177
177
|
});
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
A tool that orchestrates other tools can adjust what the model sees while it is active with `prepareLoadout(loadout)`. It runs whenever the active tools change and receives the declared tools, the callable tools, and every registered tool with its exposure and namespace. It returns replacement `descriptions` for declared tools (including its own) and `hiddenDeclarations`: active tools whose declarations requests leave out while they stay active and callable. `codemode`
|
|
180
|
+
A tool that orchestrates other tools can adjust what the model sees while it is active with `prepareLoadout(loadout)`. It runs whenever the active tools change and receives the declared tools, the callable tools, and every registered tool with its exposure and namespace. It returns replacement `descriptions` for declared tools (including its own) and `hiddenDeclarations`: active tools whose declarations requests leave out while they stay active and callable. `codemode` uses only this hook, `exposure`, and `ctx.executeTool()`, so another tool can implement the same behavior under a different name.
|
|
181
181
|
|
|
182
182
|
### Activate tools dynamically
|
|
183
183
|
|
package/bin/docs/index.md
CHANGED
|
@@ -30,7 +30,7 @@ Use the [Quickstart customization chooser](quickstart.md#choose-how-to-customize
|
|
|
30
30
|
|
|
31
31
|
## Find reference and setup information
|
|
32
32
|
|
|
33
|
-
Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [
|
|
33
|
+
Use the reference pages to look up [CLI options](cli.md), [settings](settings.md), [providers](providers.md), [keybindings](keybindings.md), and [environment variables](environment-variables.md).
|
|
34
34
|
|
|
35
35
|
For platform-specific help, see [Terminal Setup](terminal-setup.md), [Windows](windows.md), [tmux](tmux.md), [Termux on Android](termux.md), or [Containerization](containerization.md).
|
|
36
36
|
|
package/bin/docs/mcp.md
CHANGED
|
@@ -58,13 +58,13 @@ Both server types support:
|
|
|
58
58
|
- `timeout`: per-request timeout in seconds (default 60). Progress notifications reset it.
|
|
59
59
|
- `enabled: false`: keep the entry without connecting to it.
|
|
60
60
|
- `exposure` and `toolExposure`: control how tools reach the model (see [Control tool exposure](#control-tool-exposure)).
|
|
61
|
-
- `description`: what the server offers, in a sentence.
|
|
61
|
+
- `description`: what the server offers, in a sentence. For servers with `codemode` or `deferred` tools, it describes the server in the system prompt's server list (see [Control tool exposure](#control-tool-exposure)), tool search ranks the server's tools by it, and codemode's `describeNamespace()` returns it. Without it, the first line of the server instructions is used once the server connects.
|
|
62
62
|
|
|
63
63
|
Keep personal servers and servers with credentials in the user-level file. Use the project file only for servers the project requires, and only in trusted projects.
|
|
64
64
|
|
|
65
65
|
### Configuration rules
|
|
66
66
|
|
|
67
|
-
- Server names may contain only letters, digits, `_`, and `-`. Tools are named `mcp__<server>__<tool
|
|
67
|
+
- Server names may contain only letters, digits, `_`, and `-`. Tools are named `mcp__<server>__<tool>`, with every character other than letters, digits, and `_` replaced by `_`; tools of a server whose names then collide all get a hash suffix. Server names that differ only in `-` and `_` count as the same server: a second one is rejected, and a `mcp.json` server overrides a registered one.
|
|
68
68
|
- `type` is optional. A `command` selects stdio and a `url` selects streamable HTTP. When present, `type` must be `stdio`, `http`, or `streamable-http`.
|
|
69
69
|
- `sse` is rejected. Servers that document an SSE endpoint often also provide streamable HTTP, commonly at `/mcp` instead of `/sse`.
|
|
70
70
|
- `command` is one executable and `args` contains its arguments. It is not a shell command string.
|
|
@@ -87,7 +87,7 @@ Run `knightcode mcp list` to connect to every enabled server and print its state
|
|
|
87
87
|
|
|
88
88
|
KnightCode reports configuration errors, failed connections, and required sign-ins once after startup. Server logging notifications are appended to `~/.knightcode/agent/mcp.log` as `<time> [<server>] <level> <logger>: <message>`. The file moves to `mcp.log.1` after it grows past 5 MB.
|
|
89
89
|
|
|
90
|
-
KnightCode connects when a session starts. The first prompt waits up to 10 seconds for
|
|
90
|
+
KnightCode connects every enabled server in the background when a session starts. A server's tools appear once it connects; the `codemode` description does not list them, so it does not change when servers connect. The first prompt waits up to 10 seconds only for servers with `direct` tools, which must be declared in its request. Other servers are waited for when they are needed: a codemode script waits for the servers it names (`mcp__<server>`) and, when it calls `searchTools()` or reads `ALL_TOOLS`, for all of them; `tool_search` and the resource tools also wait for all of them. HTTP network errors and transient statuses (408, 429, and 5xx) are retried twice. A dropped connection is shown as disconnected and reconnects on the next call. When a server announces a changed tool list, new tools are added and withdrawn tools become unreachable.
|
|
91
91
|
|
|
92
92
|
Stopping a stdio server closes its stdin, sends SIGTERM, then sends SIGKILL to its process group. This also stops servers launched through wrappers such as `npx` or `uvx`.
|
|
93
93
|
|
|
@@ -118,6 +118,8 @@ When the server rejects an unauthenticated connection, `/mcp` shows that it need
|
|
|
118
118
|
|
|
119
119
|
KnightCode registers itself with the authorization server, stores tokens in `~/.knightcode/agent/mcp-auth.json`, and refreshes access tokens when they expire or the server rejects them. If a server later requests additional scope, KnightCode asks for sign-in again. Signing out deletes the stored credentials.
|
|
120
120
|
|
|
121
|
+
Credentials belong to a server name and URL. Servers with the same URL under different names, such as one per account, sign in separately; servers with the same name and URL in different `mcp.json` files share one sign-in.
|
|
122
|
+
|
|
121
123
|
OAuth applies to HTTP servers without an `Authorization` header. For a server that does not support dynamic client registration, configure a registered client:
|
|
122
124
|
|
|
123
125
|
```json
|
|
@@ -147,19 +149,36 @@ KnightCode registers as `knightcode`. Some servers only accept registrations fro
|
|
|
147
149
|
|
|
148
150
|
The name is only sent when KnightCode registers a client. To register again under a new name, sign out first.
|
|
149
151
|
|
|
152
|
+
KnightCode finds the authorization server through the server's protected resource metadata (RFC 9728) and checks that the authorization server's metadata names the expected issuer (RFC 8414). Some servers advertise the wrong authorization server or none, so sign-in opens a page that does not exist. Set `authServerMetadataUrl` to the metadata document of the right authorization server:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{
|
|
156
|
+
"mcpServers": {
|
|
157
|
+
"example": {
|
|
158
|
+
"url": "https://mcp.example.com/mcp",
|
|
159
|
+
"oauth": { "authServerMetadataUrl": "https://example.okta.com/.well-known/openid-configuration" }
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
KnightCode uses that document instead of discovery and trusts it as configured, so only point it at a document you trust. The URL must use HTTPS, except on `localhost`, `127.0.0.1`, or `[::1]`.
|
|
166
|
+
|
|
150
167
|
## Control tool exposure
|
|
151
168
|
|
|
152
169
|
Each server tool is registered as `mcp__<server>__<tool>`. The server's `exposure` determines how the model reaches it:
|
|
153
170
|
|
|
154
171
|
| Exposure | Behavior | Typical use |
|
|
155
172
|
|---|---|---|
|
|
156
|
-
| `codemode` (default) | Callable from [`codemode`](cli.md#tools) scripts, but neither declared to the model nor listed
|
|
173
|
+
| `codemode` (default) | Callable from [`codemode`](cli.md#tools) scripts, but neither declared to the model nor listed in the codemode description. Scripts find tools with `searchTools()`, `describeTool()`, or `ALL_TOOLS`. | General MCP servers, especially when scripts should combine or filter calls. |
|
|
157
174
|
| `deferred` | Not declared until [`tool_search`](cli.md#tools) loads a match for the next model call. | Large servers whose tools should be called directly after discovery. |
|
|
158
175
|
| `direct` | Declared to the model like a built-in tool and also callable from codemode. | Small, frequently used tool sets. |
|
|
159
176
|
| `hidden` | Registered but unreachable. | Servers or tools that should remain unavailable. |
|
|
160
177
|
|
|
161
178
|
`codemode-deferred` is accepted as an alias for `codemode`.
|
|
162
179
|
|
|
180
|
+
Servers with `codemode` or `deferred` tools are listed in the `mcp_servers` section of the system prompt, with how their tools are reached and one line from the configured `description` or, once connected, from the server instructions. KnightCode updates the section when a prompt starts, after waiting for servers with `direct` tools. When it changed, for example because a server connected and its summary became available, KnightCode appends the new section to the conversation instead of changing tool declarations, so earlier messages stay cached. `describeNamespace()` and the `namespace` option of `searchTools()` accept `mcp__dev-radius`, `mcp__dev_radius`, `dev-radius`, or `dev_radius`.
|
|
181
|
+
|
|
163
182
|
KnightCode activates `codemode` when a server with `codemode` exposure connects. It activates `tool_search` for a server with `deferred` exposure. To make the model see a tool without searching, give it `direct` exposure with `toolExposure`.
|
|
164
183
|
|
|
165
184
|
`toolExposure` overrides the server exposure for individual tools. Keys are exact server tool names or patterns where `*` matches any characters. Exact names win over patterns; among patterns, the first match wins. A server with `hidden` exposure can expose only selected tools:
|
package/bin/docs/models.md
CHANGED
|
@@ -18,7 +18,7 @@ Browse the [model catalog](https://knightcode.dev/models) for current providers,
|
|
|
18
18
|
|
|
19
19
|
Run `/login` and select a provider. KnightCode stores credentials in [`auth.json`](configuration.md#agent-directory). Run `/logout` to remove stored credentials for a provider.
|
|
20
20
|
|
|
21
|
-
You can instead provide an API key through the provider's environment variable. This is useful in CI and other environments where KnightCode should not write credentials. [
|
|
21
|
+
You can instead provide an API key through the provider's environment variable. This is useful in CI and other environments where KnightCode should not write credentials. [Providers](providers.md) lists the variables and provider-specific setup.
|
|
22
22
|
|
|
23
23
|
When several credential sources are configured, KnightCode uses a runtime `--api-key` first, then a stored `auth.json` credential, an `apiKey` from `models.json`, and finally the provider's environment variables or ambient cloud credentials. Provider extensions can define their own authentication behavior.
|
|
24
24
|
|
|
@@ -131,10 +131,31 @@ const result = await models.classify(jev, {
|
|
|
131
131
|
return result.answers;
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
[Codemode](codemode.md#classify) describes the question and answer types.
|
|
135
|
+
|
|
134
136
|
When the service reports token counts, as all System One services do, `result.usage` carries them with their cost. KnightCode adds the usage of a script's classifier calls to the `codemode` tool result, so it counts toward the session cost in the footer and `/session`. The cost uses the model's catalog price; models without one, such as TypeSafe's direct `jev-latest`, report tokens at no cost.
|
|
135
137
|
|
|
136
138
|
Extensions call classifiers through `ctx.modelRegistry.classify()`, without codemode. [Virtual models](virtual-models.md#route-requests) can use them to route requests; see the `jev-router.ts` example.
|
|
137
139
|
|
|
140
|
+
## Use image models
|
|
141
|
+
|
|
142
|
+
Image models generate images from a prompt and optional input images. KnightCode lists OpenRouter's image models, such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, under the `openrouter` provider; they use the same `OPENROUTER_API_KEY` or `/login` credential as its chat models.
|
|
143
|
+
|
|
144
|
+
Like classifier models, image models do not appear in `/model`; the model reaches them through the [`codemode`](cli.md#enable-codemode) tool. Scripts list them with `models.getAvailableOfType("image")` and call `models.generateImages(model, { input })`. The result's `output` holds base64 image blocks, which `image()` attaches to the `codemode` result so the model sees them:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
148
|
+
const result = await models.generateImages(painter, {
|
|
149
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
150
|
+
});
|
|
151
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
152
|
+
for (const block of result.output) if (block.type === "image") image(block);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`input` can also contain `{ type: "image", data, mimeType }` blocks to edit or use as references. KnightCode adds the usage of a script's image calls to the `codemode` tool result, like classifier calls. Generated images are not saved to disk. [Codemode](codemode.md#generate-images) describes the full API.
|
|
156
|
+
|
|
157
|
+
Extensions generate images through `ctx.modelRegistry.generateImages()`, without codemode.
|
|
158
|
+
|
|
138
159
|
## Add a custom provider
|
|
139
160
|
|
|
140
161
|
Use an extension when the provider needs custom streaming, model discovery, or authentication behavior. See [Custom Providers](custom-provider.md) for the extension workflow.
|
package/bin/docs/providers.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Providers
|
|
2
2
|
|
|
3
3
|
Most hosted providers support one or both of these authentication methods:
|
|
4
4
|
|
|
@@ -17,8 +17,6 @@ Run `/logout` and select a provider to remove its stored credential. This does n
|
|
|
17
17
|
|
|
18
18
|
`auth.json` can contain API keys and OAuth tokens. Keep it private and do not commit it.
|
|
19
19
|
|
|
20
|
-
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.
|
|
21
|
-
|
|
22
20
|
## Use an API key from the environment
|
|
23
21
|
|
|
24
22
|
Environment variables are useful in CI and anywhere KnightCode should not store the key. Set the variable before starting KnightCode:
|
|
@@ -28,7 +26,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
28
26
|
knightcode
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
This table covers providers with a single primary API-key variable. Providers that need additional configuration or support ambient credentials are covered under [
|
|
29
|
+
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).
|
|
32
30
|
|
|
33
31
|
| Provider | Environment variable |
|
|
34
32
|
|---|---|
|
|
@@ -69,6 +67,8 @@ This table covers providers with a single primary API-key variable. Providers th
|
|
|
69
67
|
|
|
70
68
|
Anthropic also recognizes `ANTHROPIC_OAUTH_TOKEN` as an API credential and `ANTHROPIC_AUTH_TOKEN` as bearer authentication.
|
|
71
69
|
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
72
|
## Load an API key from a command
|
|
73
73
|
|
|
74
74
|
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 `!`:
|
|
@@ -84,9 +84,9 @@ To use a secret manager without writing the resolved key to disk, set a provider
|
|
|
84
84
|
|
|
85
85
|
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.
|
|
86
86
|
|
|
87
|
-
##
|
|
87
|
+
## Provider Specific Config
|
|
88
88
|
|
|
89
|
-
The providers below need additional settings or can use credentials supplied by their
|
|
89
|
+
The providers below have additional setup, need additional settings, or can use credentials supplied by their platform.
|
|
90
90
|
|
|
91
91
|
A stored API-key credential can include an `env` object. Its values take priority over the process environment for that provider:
|
|
92
92
|
|
|
@@ -102,6 +102,18 @@ A stored API-key credential can include an `env` object. Its values take priorit
|
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
### Radius
|
|
106
|
+
|
|
107
|
+
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.
|
|
108
|
+
|
|
109
|
+
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.
|
|
110
|
+
|
|
111
|
+
Radius also has an MCP server, so KnightCode can manage Radius for you.
|
|
112
|
+
|
|
113
|
+
Radius is currently in early alpha and evolving quickly. See [radius.earendil.com](https://radius.earendil.com) for more.
|
|
114
|
+
|
|
115
|
+
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.
|
|
116
|
+
|
|
105
117
|
### Azure OpenAI
|
|
106
118
|
|
|
107
119
|
Set an API key plus either a base URL or resource name:
|
package/bin/docs/sdk.md
CHANGED
|
@@ -140,7 +140,7 @@ See the focused examples for [models](../examples/sdk/02-custom-model.ts), [tool
|
|
|
140
140
|
|
|
141
141
|
## Resources
|
|
142
142
|
|
|
143
|
-
- [Choose a Model](models.md) covers model selection and compatible endpoints; [
|
|
143
|
+
- [Choose a Model](models.md) covers model selection and compatible endpoints; [Providers](providers.md) covers credentials and provider-specific setup.
|
|
144
144
|
- [Configuration](configuration.md) explains normal discovery and settings; [Settings](settings.md) lists every setting.
|
|
145
145
|
- [Sessions and Context](sessions.md) explains session behavior; [Session Format](session-format.md) defines persisted entries; [Message Types](message-types.md) defines shared transcript values.
|
|
146
146
|
- [Extensions](extensions.md), [Skills](skills.md), and [Prompt Templates](prompt-templates.md) document resources supplied through a `ResourceLoader`.
|
package/bin/docs/settings.md
CHANGED
|
@@ -38,7 +38,7 @@ See [Choose a Model](models.md) for model selection and thinking controls.
|
|
|
38
38
|
| Setting | Type | Default | Description |
|
|
39
39
|
|---|---|---|---|
|
|
40
40
|
| `defaultTools` | `string[]` | `read`, `bash`, `edit`, `write` | Tools enabled at startup. Plain names replace the defaults; `+name` adds a tool and `-name` removes one. An empty array disables all built-in tools but not extension or SDK tools. |
|
|
41
|
-
| `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get
|
|
41
|
+
| `codemode.mode` | `"on"` \| `"only"` | `"on"` | How the `codemode` tool presents tools while it is active. `on`: declared tools get a note on calling them from scripts appended to their description, and `codemode` lists only tools that are not declared. `only`: `codemode` lists every tool scripts can call, and active built-in and extension tools are hidden from the model, so it reaches them through `codemode`. |
|
|
42
42
|
| `codemode.inlineBudget` | number | `3000` | Estimated tokens (characters / 4) the `codemode` tool's description may spend on tool declarations. Tools that do not fit are left out and found with `searchTools()`. `0` lists only namespaces. |
|
|
43
43
|
|
|
44
44
|
Available built-in tools are `read`, `bash`, `powershell`, `edit`, `write`, `grep`, `find`, and `ls`. `defaultTools` can also name `codemode` and `tool_search`, which built-in extensions register inactive, and other extension tools registered inactive.
|
|
@@ -53,6 +53,8 @@ A list of only `+name` and `-name` entries changes the inherited selection inste
|
|
|
53
53
|
|
|
54
54
|
This replaces `bash` with `powershell` and enables `grep`: `["-bash", "+powershell", "+grep"]`. Project settings apply on top of user settings: a project list with only `+name` and `-name` entries changes the user's selection, and a project list with a plain name replaces it. In one list, plain names form the selection, and `+name` and `-name` then apply in order.
|
|
55
55
|
|
|
56
|
+
`/reload` enables tools newly added to `defaultTools`. It does not disable tools removed from it or re-enable unchanged tools you turned off. `--tools`, `--no-tools`, and `--no-builtin-tools` override `defaultTools`, also on reload.
|
|
57
|
+
|
|
56
58
|
CLI tool options override this setting for one invocation; `--tools` does not accept `+name` or `-name`. See [Command Line](cli.md#tools).
|
|
57
59
|
|
|
58
60
|
The [web tools](usage.md#web-tools) `webfetch` and `websearch` are not part of `defaultTools`. `/tools` turns them on and stores their settings, including the search provider and Brave key, in `~/.knightcode/agent/tools.json`.
|
|
@@ -90,8 +92,8 @@ See [Compaction Reference](compaction.md) for trigger, summarization, and valida
|
|
|
90
92
|
| Setting | Type | Default | Description |
|
|
91
93
|
|---|---|---|---|
|
|
92
94
|
| `theme` | string | `"system"` | Built-in or custom theme name. `system` derives colors from the terminal theme. |
|
|
93
|
-
| `quietStartup` | boolean | `false` |
|
|
94
|
-
| `tuiMode` | `"regular" \| "fullscreen"` | `"
|
|
95
|
+
| `quietStartup` | boolean \| `"header"` | `false` | `true` hides the startup header and loaded-resource listing. `"header"` keeps the header (version and key hints) but hides the model scope line and loaded-resource listing. |
|
|
96
|
+
| `tuiMode` | `"regular" \| "fullscreen"` | `"fullscreen"` | Interactive terminal UI mode. Fullscreen captures the mouse and owns text selection, so dragging copies to the clipboard; regular leaves selection and copying to the terminal emulator (see [Text selection and copy](terminal-setup.md#text-selection-and-copy)). |
|
|
95
97
|
| `fullscreenExitOutput` | `"transcript" \| "resume-hint"` | `"transcript"` | Output printed when fullscreen mode exits. |
|
|
96
98
|
| `fullscreenScrollbar` | `"auto" \| "always" \| "hidden"` | `"auto"` | Fullscreen transcript scrollbar behavior. |
|
|
97
99
|
| `fullscreenCopyOnSelect` | boolean | `true` | Copy selected text automatically in fullscreen mode. When disabled, selections stay highlighted and `Ctrl+X` copies the active selection. Has no effect in regular mode. |
|
package/bin/docs/usage.md
CHANGED
|
@@ -132,7 +132,7 @@ Use `/share` to upload the session and get a viewer link. With Radius authentica
|
|
|
132
132
|
|
|
133
133
|
## Adjust the terminal
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
Fullscreen mode, the default, keeps the editor and status area fixed while the transcript scrolls within the terminal window. Regular mode uses the terminal's normal scrollback. Choose a mode through `/settings` or `--tui-mode`.
|
|
136
136
|
|
|
137
137
|
Terminal support for mouse input, keyboard shortcuts, and inline images varies. See [Terminal Setup](terminal-setup.md) for platform-specific configuration and [Keybindings](keybindings.md) for every configurable shortcut. Run `/hotkeys` to inspect the shortcuts active in your current session.
|
|
138
138
|
|
package/bin/knightcode
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/knightcode
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 119270351 bytes
|
|
4
|
+
sha256: 6669ecc3a8c15046dbc76ea2c61e72a6b2c9c85cb8d9b3de7929dd90888eec6f
|
package/bin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knightcodeai/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "KnightCode — a local, BYOK terminal coding agent powered by OpenRouter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"test": "vitest --run"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@knightcodeai/cli-linux-x64": "0.11.
|
|
41
|
-
"@knightcodeai/cli-linux-arm64": "0.11.
|
|
42
|
-
"@knightcodeai/cli-darwin-x64": "0.11.
|
|
43
|
-
"@knightcodeai/cli-darwin-arm64": "0.11.
|
|
44
|
-
"@knightcodeai/cli-win32-x64": "0.11.
|
|
40
|
+
"@knightcodeai/cli-linux-x64": "0.11.3",
|
|
41
|
+
"@knightcodeai/cli-linux-arm64": "0.11.3",
|
|
42
|
+
"@knightcodeai/cli-darwin-x64": "0.11.3",
|
|
43
|
+
"@knightcodeai/cli-darwin-arm64": "0.11.3",
|
|
44
|
+
"@knightcodeai/cli-win32-x64": "0.11.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"@knightcode/remote": "workspace:*",
|
|
55
55
|
"@knightcode/tools": "workspace:*",
|
|
56
56
|
"@knightcode/server": "workspace:*",
|
|
57
|
-
"@knightcode/session-backend-sqlite": "workspace:*",
|
|
58
57
|
"@knightcode/tui": "workspace:*",
|
|
59
58
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
60
59
|
"@types/cross-spawn": "6.0.6",
|