@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,187 @@
|
|
|
1
|
+
# Models Configuration
|
|
2
|
+
|
|
3
|
+
<!-- This file is generated from TypeScript source. Do not edit it manually; run bun run generate:references. -->
|
|
4
|
+
|
|
5
|
+
This reference lists the fields of `models.json`. See [Configure a compatible endpoint](models.md#configure-a-compatible-endpoint) for examples and [Configuration](configuration.md#agent-directory) for the file location.
|
|
6
|
+
|
|
7
|
+
Add `"$schema": "https://knightcode.dev/schemas/models.schema.json"` to `models.json` for editor validation and completion.
|
|
8
|
+
|
|
9
|
+
## Providers
|
|
10
|
+
|
|
11
|
+
Each key under `providers` is a provider ID. A built-in provider ID changes that provider. Any other ID adds a provider, which needs `baseUrl` and an `api` at provider or model level.
|
|
12
|
+
|
|
13
|
+
| Field | Type | Default | Description |
|
|
14
|
+
|---|---|---|---|
|
|
15
|
+
| `name` | string | | Display name. |
|
|
16
|
+
| `baseUrl` | string | | API base URL. Also applies to the provider's built-in models. |
|
|
17
|
+
| `apiKey` | string | | Literal key, "$NAME" environment interpolation, or "!command" output. |
|
|
18
|
+
| `api` | string | | API for the provider's models, such as "openai-completions", "openai-responses", "anthropic-messages", or "google-generative-ai". |
|
|
19
|
+
| `oauth` | `"radius"` | | OAuth login flow. Requires baseUrl. |
|
|
20
|
+
| `headers` | object | | Request headers. Values resolve like apiKey. |
|
|
21
|
+
| `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
|
|
22
|
+
| `authHeader` | boolean | `false` | Whether to send the resolved API key as Authorization: Bearer. |
|
|
23
|
+
| `models` | [`object[]`](#models) | | |
|
|
24
|
+
| `modelOverrides` | [object](#model-overrides) | | |
|
|
25
|
+
|
|
26
|
+
## Models
|
|
27
|
+
|
|
28
|
+
Each `models` entry adds a model to the provider. An entry whose `id` matches an existing model replaces it.
|
|
29
|
+
|
|
30
|
+
| Field | Type | Default | Description |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| `id` | string | | Required. Model ID sent to the API. |
|
|
33
|
+
| `name` | string | | Display name, also matched by --model patterns. |
|
|
34
|
+
| `api` | string | | Overrides the provider api. |
|
|
35
|
+
| `baseUrl` | string | | Overrides the provider baseUrl. |
|
|
36
|
+
| `reasoning` | boolean | `false` | Whether the model supports thinking. |
|
|
37
|
+
| `thinkingLevelMap` | object | | Provider value sent for each thinking level. null marks a level unsupported. Levels the model does not map use the provider's default value through high; xhigh and max are unsupported. |
|
|
38
|
+
| `input` | `("text" \| "image")[]` | `["text"]` | |
|
|
39
|
+
| `inputLimits` | [object](#input-limits) | | |
|
|
40
|
+
| `cost` | object | | |
|
|
41
|
+
| `cost.input` | number | | Required. Input cost in USD per million tokens. |
|
|
42
|
+
| `cost.output` | number | | Required. Output cost in USD per million tokens. |
|
|
43
|
+
| `cost.cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
|
|
44
|
+
| `cost.cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
|
|
45
|
+
| `cost.tiers` | `object[]` | | Request-wide pricing tiers. The highest matching input threshold applies to the full request. |
|
|
46
|
+
| `cost.tiers[].inputTokensAbove` | number | | Required. Use this tier when total request input exceeds this token count. |
|
|
47
|
+
| `cost.tiers[].input` | number | | Required. Input cost in USD per million tokens. |
|
|
48
|
+
| `cost.tiers[].output` | number | | Required. Output cost in USD per million tokens. |
|
|
49
|
+
| `cost.tiers[].cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
|
|
50
|
+
| `cost.tiers[].cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
|
|
51
|
+
| `promptCache` | object | | Best-effort prompt cache lifetime in seconds for the short and long retention tiers. KnightCode warms only tiers with a known lifetime. |
|
|
52
|
+
| `contextWindow` | number | `128000` | Context window in tokens. |
|
|
53
|
+
| `maxTokens` | number | `16384` | Maximum output tokens. |
|
|
54
|
+
| `samplingParams` | object | | Fields merged into every request body. Applies only to OpenAI-compatible APIs. |
|
|
55
|
+
| `samplingParamsByThinkingLevel` | object | | samplingParams per thinking level, merged over samplingParams. |
|
|
56
|
+
| `headers` | object | | Request headers. Values resolve like apiKey. |
|
|
57
|
+
| `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
|
|
58
|
+
|
|
59
|
+
## Model overrides
|
|
60
|
+
|
|
61
|
+
Each `modelOverrides` key is the ID of a built-in or extension model. Unknown IDs are ignored. Object fields, such as `cost`, merge with the model's value field by field; other fields replace it.
|
|
62
|
+
|
|
63
|
+
| Field | Type | Default | Description |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| `name` | string | | Display name, also matched by --model patterns. |
|
|
66
|
+
| `reasoning` | boolean | | Whether the model supports thinking. |
|
|
67
|
+
| `thinkingLevelMap` | object | | Provider value sent for each thinking level. null marks a level unsupported. Levels the model does not map use the provider's default value through high; xhigh and max are unsupported. |
|
|
68
|
+
| `input` | `("text" \| "image")[]` | | |
|
|
69
|
+
| `inputLimits` | [object](#input-limits) | | |
|
|
70
|
+
| `cost` | object | | |
|
|
71
|
+
| `cost.input` | number | | Input cost in USD per million tokens. |
|
|
72
|
+
| `cost.output` | number | | Output cost in USD per million tokens. |
|
|
73
|
+
| `cost.cacheRead` | number | | Cache-read cost in USD per million tokens. |
|
|
74
|
+
| `cost.cacheWrite` | number | | Cache-write cost in USD per million tokens. |
|
|
75
|
+
| `cost.tiers` | `object[]` | | Request-wide pricing tiers. The highest matching input threshold applies to the full request. |
|
|
76
|
+
| `cost.tiers[].inputTokensAbove` | number | | Required. Use this tier when total request input exceeds this token count. |
|
|
77
|
+
| `cost.tiers[].input` | number | | Required. Input cost in USD per million tokens. |
|
|
78
|
+
| `cost.tiers[].output` | number | | Required. Output cost in USD per million tokens. |
|
|
79
|
+
| `cost.tiers[].cacheRead` | number | | Required. Cache-read cost in USD per million tokens. |
|
|
80
|
+
| `cost.tiers[].cacheWrite` | number | | Required. Cache-write cost in USD per million tokens. |
|
|
81
|
+
| `promptCache` | object | | Best-effort prompt cache lifetime in seconds for the short and long retention tiers. KnightCode warms only tiers with a known lifetime. |
|
|
82
|
+
| `contextWindow` | number | | Context window in tokens. |
|
|
83
|
+
| `maxTokens` | number | | Maximum output tokens. |
|
|
84
|
+
| `samplingParams` | object | | Fields merged into every request body. Applies only to OpenAI-compatible APIs. |
|
|
85
|
+
| `samplingParamsByThinkingLevel` | object | | samplingParams per thinking level, merged over samplingParams. |
|
|
86
|
+
| `headers` | object | | Request headers. Values resolve like apiKey. |
|
|
87
|
+
| `compat` | [object](#compatibility) | | Provider and model compatibility overrides. |
|
|
88
|
+
|
|
89
|
+
## Input limits
|
|
90
|
+
|
|
91
|
+
See [Describe model input and caching](models.md#describe-model-input-and-caching).
|
|
92
|
+
|
|
93
|
+
| Field | Type | Default | Description |
|
|
94
|
+
|---|---|---|---|
|
|
95
|
+
| `maxRequestBytes` | integer | | Maximum serialized provider request size in bytes. |
|
|
96
|
+
| `images` | object | | |
|
|
97
|
+
| `images.resize` | object | | Cache-safe resize profile applied before a new image enters conversation history. |
|
|
98
|
+
| `images.resize.maxWidth` | integer | | |
|
|
99
|
+
| `images.resize.maxHeight` | integer | | |
|
|
100
|
+
| `images.resize.maxBytes` | integer | | Maximum base64-encoded payload size in bytes. |
|
|
101
|
+
| `images.resize.jpegQuality` | integer | | |
|
|
102
|
+
| `images.maxPerMessage` | integer | | Maximum images accepted in one provider message. |
|
|
103
|
+
| `images.maxPerRequest` | integer | | Maximum images accepted across one provider request. |
|
|
104
|
+
|
|
105
|
+
## Compatibility
|
|
106
|
+
|
|
107
|
+
`compat` describes verified differences from an API's standard request and response behavior. Model values override provider values per field. The fields that apply depend on the model's `api`.
|
|
108
|
+
|
|
109
|
+
### `openai-completions`
|
|
110
|
+
|
|
111
|
+
| Field | Type | Default | Description |
|
|
112
|
+
|---|---|---|---|
|
|
113
|
+
| `supportsStore` | boolean | | Whether the provider supports the store field. Default: auto-detected from URL. |
|
|
114
|
+
| `supportsDeveloperRole` | boolean | | Whether the provider supports the developer role instead of system. Default: auto-detected from URL. |
|
|
115
|
+
| `supportsReasoningEffort` | boolean | | Whether the provider supports reasoning_effort. Default: auto-detected from URL. |
|
|
116
|
+
| `supportsUsageInStreaming` | boolean | `true` | Whether the provider supports stream_options.include_usage for token usage in streaming responses. |
|
|
117
|
+
| `supportsFinishReason` | boolean | `true` | Whether streamed responses include finish_reason. When false, KnightCode infers stop or toolUse when the stream ends. |
|
|
118
|
+
| `maxTokensField` | `"max_completion_tokens" \| "max_tokens"` | | Which field to use for max tokens. Default: auto-detected from URL. |
|
|
119
|
+
| `requiresToolResultName` | boolean | | Whether tool results require the name field. Default: auto-detected from URL. |
|
|
120
|
+
| `requiresAssistantAfterToolResult` | boolean | | Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. |
|
|
121
|
+
| `requiresThinkingAsText` | boolean | | Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. |
|
|
122
|
+
| `requiresReasoningContentOnAssistantMessages` | boolean | | Whether all replayed assistant messages must include an empty reasoning_content field when reasoning is enabled. Default: auto-detected from URL. |
|
|
123
|
+
| `thinkingFormat` | `"openai" \| "openrouter" \| "deepseek" \| "together" \| "baseten" \| "zai" \| "qwen" \| "chat-template" \| "qwen-chat-template" \| "string-thinking" \| "ant-ling"` | | Format for reasoning or thinking parameters. When omitted, KnightCode auto-detects the format from the provider URL. "openai" uses reasoning_effort, "openrouter" uses reasoning.effort, "deepseek" uses thinking.type plus reasoning_effort when supported, "together" uses reasoning.enabled plus reasoning_effort when supported, "baseten" uses configurable chat_template_args plus reasoning_effort when supported, "zai" uses thinking.type, "qwen" uses top-level enable_thinking, "qwen-chat-template" uses chat_template_kwargs.enable_thinking and preserve_thinking, "chat-template" uses configurable chat_template_kwargs, "string-thinking" uses top-level thinking, and "ant-ling" uses reasoning.effort only when the mapped effort is non-null. |
|
|
124
|
+
| `chatTemplateKwargs` | object | | Kwargs sent as chat_template_kwargs when thinkingFormat is "chat-template". Use $var with "thinking.enabled", "thinking.effort", or "thinking.budget" for knightcode-controlled values. |
|
|
125
|
+
| `chatTemplateArgs` | object | | Arguments sent as chat_template_args when thinkingFormat is "baseten". Use $var with "thinking.enabled", "thinking.effort", or "thinking.budget" for knightcode-controlled values. |
|
|
126
|
+
| `openRouterRouting` | object | | OpenRouter provider routing preferences. Controls which upstream providers OpenRouter routes requests to. Sent as the provider field in the OpenRouter API request body. See https://openrouter.ai/docs/guides/routing/provider-selection. |
|
|
127
|
+
| `vercelGatewayRouting` | object | | Vercel AI Gateway routing preferences. Controls which upstream providers the gateway routes requests to. See https://vercel.com/docs/ai-gateway/models-and-providers/provider-options. |
|
|
128
|
+
| `zaiToolStream` | boolean | `false` | Whether z.ai supports top-level tool_stream for streaming tool call deltas. |
|
|
129
|
+
| `thinkingTokenBudgetField` | `"thinking_token_budget" \| "thinking_budget" \| "thinking_budget_tokens"` | | Top-level request field used to cap reasoning tokens from thinkingBudgets. Reasoning and the answer share max_tokens on these endpoints. "thinking_token_budget" is vLLM, "thinking_budget" is Qwen, DashScope, or SGLang, and "thinking_budget_tokens" is llama.cpp. Off by default and not set on the generated catalog. |
|
|
130
|
+
| `supportsThinkingTokenBudget` | boolean | `false` | Alias for thinkingTokenBudgetField: "thinking_token_budget" (vLLM). Prefer thinkingTokenBudgetField. |
|
|
131
|
+
| `supportsOpenAIGrammarTools` | boolean | `false` | Whether the provider supports OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models. |
|
|
132
|
+
| `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system or developer messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models. |
|
|
133
|
+
| `supportsMidConvoToolAdditions` | boolean | `false` | Whether system messages can introduce additional tools mid-conversation. Requires supportsMidConvoSystemMessages. The generated catalog enables this for capable models. |
|
|
134
|
+
| `supportsStrictMode` | boolean | `false` | Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly. |
|
|
135
|
+
| `cacheControlFormat` | `"anthropic"` | | Cache control convention for prompt caching. Anthropic applies cache_control markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. |
|
|
136
|
+
| `sendSessionAffinityHeaders` | boolean | | Whether to send session-affinity data from options.sessionId. Default: true for OpenRouter endpoints, false otherwise. |
|
|
137
|
+
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id, x-client-request-id, and x-session-affinity; openai-nosession sends x-client-request-id and x-session-affinity; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected. |
|
|
138
|
+
| `supportsLongCacheRetention` | boolean | | Whether the provider supports long prompt cache retention (prompt_cache_retention: "24h" or Anthropic-style cache_control.ttl: "1h", depending on format). Default: auto-detected from provider and URL. |
|
|
139
|
+
| `vllmPriority` | number | | vLLM scheduler priority sent as the top-level priority request field. Lower values are handled earlier and the server default is 0. Only meaningful with --scheduling-policy priority. Off by default and not set on the generated catalog. |
|
|
140
|
+
|
|
141
|
+
### `openai-responses`
|
|
142
|
+
|
|
143
|
+
Also applies to `azure-openai-responses` and `openai-codex-responses`.
|
|
144
|
+
|
|
145
|
+
| Field | Type | Default | Description |
|
|
146
|
+
|---|---|---|---|
|
|
147
|
+
| `supportsDeveloperRole` | boolean | `true` | Whether the provider supports the developer role instead of system. |
|
|
148
|
+
| `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models. |
|
|
149
|
+
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id and x-client-request-id; openai-nosession sends x-client-request-id; openrouter sends x-session-id. Does not affect prompt_cache_key. Default: auto-detected. |
|
|
150
|
+
| `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: "30m" on GPT-5.6+ and prompt_cache_retention: "24h" on earlier models. |
|
|
151
|
+
| `supportsStrictMode` | boolean | | Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly. |
|
|
152
|
+
| `supportsOpenAIGrammarTools` | boolean | `false` | Whether to emit OpenAI custom tools with Lark or regex grammar formats. When false, grammar-constrained tools fall back to normal function tools. The generated catalog enables this for capable models. |
|
|
153
|
+
| `supportsAdditionalTools` | boolean | `false` | Whether the model supports message-anchored additional_tools input items. |
|
|
154
|
+
| `supportsToolSearch` | boolean | `false` | Whether the model supports client-executed tool search for transcript-anchored additions. |
|
|
155
|
+
| `supportsExplicitPromptCacheMode` | boolean | `false` | Whether the model accepts prompt_cache_options. Older OpenAI models reject the parameter. |
|
|
156
|
+
| `supportsMidConvoEffort` | boolean | `false` | Whether thinking level changes are sent as configuration_update input items instead of changing reasoning.effort, so a change keeps the prompt cache. Only used by the openai-responses API, and ignored with Sign in with ChatGPT on the openai provider. |
|
|
157
|
+
| `supportsMaxOutputTokens` | boolean | `true` | Whether the provider accepts max_output_tokens. Some Codex-protocol gateways reject it. |
|
|
158
|
+
|
|
159
|
+
### `anthropic-messages`
|
|
160
|
+
|
|
161
|
+
| Field | Type | Default | Description |
|
|
162
|
+
|---|---|---|---|
|
|
163
|
+
| `supportsEagerToolInputStreaming` | boolean | `true` | Whether the provider accepts per-tool eager_input_streaming. When false, the Anthropic provider omits tools[].eager_input_streaming and sends the legacy fine-grained-tool-streaming-2025-05-14 beta header for tool-enabled requests. |
|
|
164
|
+
| `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports Anthropic long cache retention through cache_control.ttl. |
|
|
165
|
+
| `sendSessionAffinityHeaders` | boolean | | Whether to send x-session-affinity from options.sessionId when caching is enabled. Required for providers like Fireworks that use session affinity for prompt cache routing; requests to the same replica maximize cache hits. Default: true for OpenRouter endpoints, false otherwise. |
|
|
166
|
+
| `sessionAffinityFormat` | `"openrouter"` | | Session-affinity format. openrouter sends x-session-id; when unset, sends x-session-affinity. |
|
|
167
|
+
| `supportsCacheControlOnTools` | boolean | `true` | Whether the provider supports Anthropic-style cache_control markers on tool definitions. When false, cache_control is omitted from tool parameters. Some Anthropic-compatible providers, such as Fireworks, do not support this field on tools and may reject or ignore it. |
|
|
168
|
+
| `supportsTemperature` | boolean | `true` | Whether the model accepts the Anthropic temperature request field. Claude Opus 4.7+ rejects non-default values. |
|
|
169
|
+
| `forceAdaptiveThinking` | boolean | `false` | Whether to force adaptive thinking (thinking.type: adaptive plus output_config.effort) regardless of model ID. Built-in models that require adaptive thinking set this in generated metadata. Custom Anthropic-compatible providers can set this to true for any model whose upstream requires the adaptive format. Set false to opt out on overridden built-in models. |
|
|
170
|
+
| `allowEmptySignature` | boolean | `false` | Whether to replay empty thinking signatures instead of converting thinking to text. |
|
|
171
|
+
| `supportsStrictTools` | boolean | `false` | Whether the provider supports Anthropic strict tool schemas. Generated Anthropic models enable it explicitly. |
|
|
172
|
+
| `supportsMidConvoEffort` | boolean | `false` | Whether the exact model transport supports effort-only system messages and thinking binding controls. |
|
|
173
|
+
| `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system-role messages inside the conversation. When false, later system messages are folded into the top-level system prompt. |
|
|
174
|
+
| `supportsMidConvoToolChanges` | boolean | `false` | Whether the exact model accepts mid-conversation tool_addition and tool_removal blocks. Requires supportsMidConvoSystemMessages. |
|
|
175
|
+
| `allowedFallbackModels` | `object[]` | | Models Anthropic accepts for server-side refusal fallback, with local pricing metadata for returned fallback responses. When absent or empty, callers must omit fallbacks; Anthropic rejects the field for models with no permitted fallback targets. |
|
|
176
|
+
|
|
177
|
+
### `bedrock-converse-stream`
|
|
178
|
+
|
|
179
|
+
| Field | Type | Default | Description |
|
|
180
|
+
|---|---|---|---|
|
|
181
|
+
| `supportsStrictMode` | boolean | `false` | Whether the model supports Bedrock strict tool schemas. |
|
|
182
|
+
|
|
183
|
+
### `mistral-conversations`
|
|
184
|
+
|
|
185
|
+
| Field | Type | Default | Description |
|
|
186
|
+
|---|---|---|---|
|
|
187
|
+
| `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts system messages after the conversation has started. When false, later system messages are folded into the leading system message. |
|
package/docs/models.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Choose a Model
|
|
2
|
+
|
|
3
|
+
For a built-in provider, start with `/login`, then choose a model with `/model`. Use custom model configuration only when KnightCode does not already include the provider or endpoint you need.
|
|
4
|
+
|
|
5
|
+
## Choose a connection
|
|
6
|
+
|
|
7
|
+
| What you have | Recommended setup |
|
|
8
|
+
|---|---|
|
|
9
|
+
| A supported subscription | Sign in through `/login` |
|
|
10
|
+
| A provider API key | Store it through `/login` or set its environment variable |
|
|
11
|
+
| A local GGUF model | Connect KnightCode to the llama.cpp router |
|
|
12
|
+
| An OpenAI-, Anthropic-, or Google-compatible endpoint | Add it to `models.json` |
|
|
13
|
+
| A provider with a custom protocol or authentication flow | Build or install a provider extension |
|
|
14
|
+
|
|
15
|
+
Browse the [model catalog](https://knightcode.dev/models) for current providers, model IDs, capabilities, context limits, and pricing. KnightCode starts with its bundled catalog and can overlay newer catalog data from knightcode.dev. Cached catalog data remains available offline; run `knightcode update --models` to force a refresh.
|
|
16
|
+
|
|
17
|
+
## Authenticate
|
|
18
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
25
|
+
Keep `auth.json` and any credential commands private. Project settings and extensions can execute inside the KnightCode process after you trust a project. Review [Security](security.md) before loading configuration from an untrusted directory.
|
|
26
|
+
|
|
27
|
+
## Select a model
|
|
28
|
+
|
|
29
|
+
Run `/model` to search available models. The picker shows models whose providers have usable authentication. Press `Ctrl+S` (or `Ctrl+D`, if your terminal swallows `Ctrl+S`) on a model to save it as the default for new sessions.
|
|
30
|
+
|
|
31
|
+
Run `/thinking` to select the thinking level for the current model. Press `Ctrl+S` or `Ctrl+D` there to save the startup level. KnightCode limits the choices to levels supported by the selected model.
|
|
32
|
+
|
|
33
|
+
`Ctrl+P` cycles through available models. Use `/scoped-models` to control that cycle and save the selection, or configure model patterns through [Settings](settings.md#model-cycling).
|
|
34
|
+
|
|
35
|
+
A session records model and thinking-level changes. Resuming the session restores them without changing defaults for new sessions.
|
|
36
|
+
|
|
37
|
+
## Connect local models
|
|
38
|
+
|
|
39
|
+
KnightCode integrates directly with the llama.cpp router. The router discovers GGUF files and loads models on demand. KnightCode's `/llama` command manages the router, while `/model` selects one of its loaded models.
|
|
40
|
+
|
|
41
|
+
Follow [Local Models with llama.cpp](llama-cpp.md) for server startup, model layout, downloads, and connection troubleshooting.
|
|
42
|
+
|
|
43
|
+
For Ollama, LM Studio, vLLM, SGLang, and other compatible servers, [configure a compatible endpoint](#configure-a-compatible-endpoint) in `models.json`.
|
|
44
|
+
|
|
45
|
+
## Configure a compatible endpoint
|
|
46
|
+
|
|
47
|
+
Use [`models.json`](configuration.md#agent-directory) when an endpoint speaks an API KnightCode already supports. This includes most Ollama, LM Studio, vLLM, SGLang, and proxy deployments.
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"$schema": "https://knightcode.dev/schemas/models.schema.json",
|
|
52
|
+
"providers": {
|
|
53
|
+
"ollama": {
|
|
54
|
+
"baseUrl": "http://localhost:11434/v1",
|
|
55
|
+
"api": "openai-completions",
|
|
56
|
+
"apiKey": "ollama",
|
|
57
|
+
"models": [
|
|
58
|
+
{ "id": "qwen2.5-coder:7b" }
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The dummy key makes the model available to KnightCode; Ollama ignores it. For an authenticated endpoint, `apiKey` and header values can use `$NAME` or `${NAME}` environment interpolation, a literal value, or a leading `!command`. `$$` and `$!` produce a literal `$` and `!`. Commands in `models.json` run at request time and are not cached by KnightCode.
|
|
66
|
+
|
|
67
|
+
Opening `/model` reloads the file. A `models` entry adds or replaces a model with the same ID on that provider. Use `modelOverrides` to change metadata for an existing built-in or extension-provided model without replacing the provider's model list. Unknown override IDs are ignored.
|
|
68
|
+
|
|
69
|
+
To route a built-in provider through a proxy, set only its `baseUrl`. Its models and authentication stay unchanged:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"providers": {
|
|
74
|
+
"anthropic": { "baseUrl": "https://proxy.example.com/v1" }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
[Models Configuration](models-configuration.md) lists every field.
|
|
80
|
+
|
|
81
|
+
### Describe model input and caching
|
|
82
|
+
|
|
83
|
+
Use `inputLimits.images.resize` to control how KnightCode encodes new image attachments, `read` results, and tool-result images before storing them in conversation history:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"id": "vision-model",
|
|
88
|
+
"input": ["text", "image"],
|
|
89
|
+
"inputLimits": {
|
|
90
|
+
"images": {
|
|
91
|
+
"resize": {
|
|
92
|
+
"maxWidth": 1568,
|
|
93
|
+
"maxHeight": 1568,
|
|
94
|
+
"maxBytes": 524288,
|
|
95
|
+
"jpegQuality": 75
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`maxBytes` limits the base64-encoded payload. Omitted resize fields use conservative defaults of 2000 by 2000 pixels, 4.5 MiB encoded, and JPEG quality 80. Images are encoded once; changing models does not rewrite historical images. The catalog can also describe hard request limits with `inputLimits.maxRequestBytes`, `images.maxPerMessage`, and `images.maxPerRequest`, but KnightCode does not yet rewrite or reject history based on them.
|
|
103
|
+
|
|
104
|
+
<a id="prompt-cache-lifetimes"></a>
|
|
105
|
+
|
|
106
|
+
Use `promptCache` to declare the provider's best-effort cache lifetime in seconds for the `short` or `long` retention tier:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{ "id": "claude-sonnet-5", "promptCache": { "short": 300, "long": 3600 } }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Choose the conservative end of any published range. A model without a lifetime for the active tier is not eligible for cache warming. A `modelOverrides` entry can set `inputLimits` or `promptCache` for a built-in or extension model, including a model accessed through a validated proxy. See [`cacheWarming`](settings.md#model-and-thinking).
|
|
113
|
+
|
|
114
|
+
### Configure sampling by thinking level
|
|
115
|
+
|
|
116
|
+
OpenAI-compatible APIs support free-form `samplingParams` model defaults and `samplingParamsByThinkingLevel` overrides. The latter uses KnightCode thinking-level keys (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`), not provider values from `thinkingLevelMap`:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"id": "qwen-thinking-model",
|
|
121
|
+
"reasoning": true,
|
|
122
|
+
"samplingParams": {
|
|
123
|
+
"temperature": 1.0,
|
|
124
|
+
"top_p": 0.95
|
|
125
|
+
},
|
|
126
|
+
"samplingParamsByThinkingLevel": {
|
|
127
|
+
"off": {
|
|
128
|
+
"temperature": 0.7,
|
|
129
|
+
"top_p": 0.8
|
|
130
|
+
},
|
|
131
|
+
"high": {
|
|
132
|
+
"top_k": 20
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
KnightCode first clamps unsupported thinking levels, then merges model `samplingParams`, the effective level's override, and request-level `samplingParams` in that order. Later values win per key. Missing levels inherit the model defaults. `modelOverrides` merges per-level entries per key with the base model. These fields apply only to `openai-completions`, `openai-responses`, and `azure-openai-responses`; other APIs ignore them.
|
|
139
|
+
|
|
140
|
+
Compatibility settings should describe verified differences in the endpoint's request or response behavior. Do not enable them based only on an endpoint advertising OpenAI or Anthropic compatibility.
|
|
141
|
+
|
|
142
|
+
## Use classifier models
|
|
143
|
+
|
|
144
|
+
Classifier models do not chat. They answer typed questions about JSON state: pick one of several choices, answer yes or no, or give a score, each with probabilities. KnightCode includes TypeSafe's Jev model from these providers, Cloudflare's Clef and Clef Flash models from Workers AI, and OpenAI's GPT-6 Luna through the [Decisions API](https://developers.openai.com/api/docs/guides/decisions):
|
|
145
|
+
|
|
146
|
+
| Provider | Model IDs | Authentication |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `typesafe` | `jev-latest` | `TYPESAFE_API_KEY` |
|
|
149
|
+
| `openrouter` | `typesafe/jev-1.13`, `~typesafe/jev-latest` | `OPENROUTER_API_KEY` or `/login` |
|
|
150
|
+
| `cloudflare-workers-ai` | `typesafe/jev`, `@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash` | `CLOUDFLARE_API_KEY` and `CLOUDFLARE_ACCOUNT_ID` |
|
|
151
|
+
| `vercel-ai-gateway` | `typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
|
|
152
|
+
| `opencode` | `jev-1.13`, `jev-1.13-free` | `OPENCODE_API_KEY` |
|
|
153
|
+
| `openai` | `gpt-6-luna` | `OPENAI_API_KEY` |
|
|
154
|
+
|
|
155
|
+
A [llama.cpp router](llama-cpp.md#classification) lists decision models as native classifiers, and also lists each chat model as a classifier.
|
|
156
|
+
|
|
157
|
+
OpenAI's Decisions API needs an API key. ChatGPT sign-in does not work with it, so `gpt-6-luna` is not listed as available while `openai` is logged in through `/login`, even when `OPENAI_API_KEY` is set; log out of `openai` to use the key. GPT-6 Luna also judges images passed in `images` (see [Codemode](codemode.md#classify)); other classifier models return an error for them. The API rejects inputs above 922K tokens, but requests that run longer than about five seconds, currently above roughly 600K input tokens, fail with a gateway timeout.
|
|
158
|
+
|
|
159
|
+
Classifier models do not appear in `/model`. The [classifier gate](usage.md#classifier-gate) uses one to screen risky tool calls. The model reaches them through the [`codemode`](cli.md#enable-codemode) tool, which is off unless an MCP server turned it on. Enable it with `"defaultTools": ["+codemode"]` in [settings](settings.md#tools). Scripts then list classifier models with `models.getAvailableOfType("classifier")` and call `models.classify(model, { state, questions })`:
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
|
|
163
|
+
const result = await models.classify(jev, {
|
|
164
|
+
state: { message: "The change works, thanks." },
|
|
165
|
+
questions: {
|
|
166
|
+
approved: {
|
|
167
|
+
type: "bool",
|
|
168
|
+
instructions: "Does the user approve of the result?",
|
|
169
|
+
criteria: { true: "Approval", false: "No approval" },
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
return result.answers;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
[Codemode](codemode.md#classify) describes the question and answer types.
|
|
177
|
+
|
|
178
|
+
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.
|
|
179
|
+
|
|
180
|
+
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.
|
|
181
|
+
|
|
182
|
+
## Use image models
|
|
183
|
+
|
|
184
|
+
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.
|
|
185
|
+
|
|
186
|
+
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:
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
|
|
190
|
+
const result = await models.generateImages(painter, {
|
|
191
|
+
input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
|
|
192
|
+
});
|
|
193
|
+
if (result.stopReason !== "stop") return result.errorMessage;
|
|
194
|
+
for (const block of result.output) if (block.type === "image") image(block);
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`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.
|
|
198
|
+
|
|
199
|
+
Extensions generate images through `ctx.modelRegistry.generateImages()`, without codemode.
|
|
200
|
+
|
|
201
|
+
## Add a custom provider
|
|
202
|
+
|
|
203
|
+
Use an extension when the provider needs custom streaming, model discovery, or authentication behavior. See [Custom Providers](custom-provider.md) for the extension workflow.
|
|
204
|
+
|
|
205
|
+
## Troubleshooting
|
|
206
|
+
|
|
207
|
+
### A model does not appear
|
|
208
|
+
|
|
209
|
+
Confirm that its provider has usable authentication. Custom models can load from `models.json` but remain unavailable in `/model` until KnightCode can resolve credentials. For llama.cpp, only models currently loaded by the router appear.
|
|
210
|
+
|
|
211
|
+
### Authentication works in one shell only
|
|
212
|
+
|
|
213
|
+
Check whether the key came from an environment variable rather than `auth.json`. Environment variables must be present in the process that starts KnightCode.
|
|
214
|
+
|
|
215
|
+
### Sign-in opens a browser on a remote machine
|
|
216
|
+
|
|
217
|
+
Complete the provider's headless authentication flow when available. Some providers let you paste the final redirect URL or authorization code back into KnightCode. See [Authenticate interactively](providers.md#authenticate-interactively).
|
|
218
|
+
|
|
219
|
+
### A compatible endpoint rejects requests
|
|
220
|
+
|
|
221
|
+
Check its API type and compatibility settings in `models.json`. The upstream server must support the corresponding request fields and behavior.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Run KnightCode with NVIDIA RTX and llama.cpp
|
|
2
|
+
|
|
3
|
+
[NVIDIA Local AI Inference Recipes](https://nvidia.github.io/local-ai-inference-recipes/index.html) provides llama.cpp settings tuned for specific NVIDIA hardware and models. Each recipe gives a single-model `llama-server` command. KnightCode works with the llama.cpp router, which can serve and manage several models, so this guide converts the recipe command into a router preset.
|
|
4
|
+
|
|
5
|
+
The examples below use Windows PowerShell. See [Local Models with llama.cpp](llama-cpp.md) for KnightCode's complete router and model-management reference.
|
|
6
|
+
|
|
7
|
+
## Before you begin
|
|
8
|
+
|
|
9
|
+
1. Open the [recipe catalog](https://nvidia.github.io/local-ai-inference-recipes/index.html), select your hardware, operating system, and model, then choose **llama.cpp**. Check the prerequisites and memory requirements. Keep the recipe's launch command for the conversion below.
|
|
10
|
+
2. Install llama.cpp with the recipe's setup instructions. The recipe's settings depend on its build, for example CUDA support or speculative decoding options.
|
|
11
|
+
3. Run `llama-server --help` and check that it lists `--models-preset`. Without it, the build cannot load the recipe as a router preset. Use a newer build that still meets the recipe's requirements.
|
|
12
|
+
4. Install KnightCode with the [Quickstart](quickstart.md). On native Windows, also see [Run KnightCode on Windows](windows.md).
|
|
13
|
+
|
|
14
|
+
## Convert the recipe to a preset
|
|
15
|
+
|
|
16
|
+
A preset lists the settings for one or more models. Each section name becomes the model ID shown in KnightCode. Save the preset next to `llama-server`, or pass its full path when starting the router.
|
|
17
|
+
|
|
18
|
+
Convert each option from the recipe command into one preset line:
|
|
19
|
+
|
|
20
|
+
- Remove the leading dashes: `--ctx-size 65536` becomes `ctx-size = 65536`.
|
|
21
|
+
- Write options without a value as `true`: `--jinja` becomes `jinja = true`.
|
|
22
|
+
- Remove quotes and PowerShell line-continuation backticks around values.
|
|
23
|
+
- Leave out `--host` and `--port`. They belong on the router command line.
|
|
24
|
+
- Add `load-on-startup = true` so the router loads the model when it starts.
|
|
25
|
+
- Replace short model-file options with their long preset keys:
|
|
26
|
+
|
|
27
|
+
| Recipe option | Preset key |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `-hf` | `hf-repo` |
|
|
30
|
+
| `-hff` | `hf-file` |
|
|
31
|
+
| `-hfrd` | `hf-repo-draft` |
|
|
32
|
+
| `--spec-draft-model` | `spec-draft-model` |
|
|
33
|
+
|
|
34
|
+
For example, this recipe command:
|
|
35
|
+
|
|
36
|
+
```powershell
|
|
37
|
+
llama-server.exe -hf "unsloth/Qwen3.8-27B-GGUF" `
|
|
38
|
+
-hff "Qwen3.8-27B-UD-Q4_K_M.gguf" `
|
|
39
|
+
-hfrd "z-lab/Qwen3.8-27B-DFlash2-GGUF" `
|
|
40
|
+
--spec-draft-model "Qwen3.8-27B-DFlash2-Q4_K_M.gguf" `
|
|
41
|
+
--no-mmproj `
|
|
42
|
+
--host 127.0.0.1 `
|
|
43
|
+
--port 9931 `
|
|
44
|
+
--batch-size 4096 `
|
|
45
|
+
--ubatch-size 1024 `
|
|
46
|
+
--ctx-size 65536 `
|
|
47
|
+
--parallel 1 `
|
|
48
|
+
-ngl 999 `
|
|
49
|
+
--jinja `
|
|
50
|
+
--chat-template-kwargs '{"preserve_thinking":true}' `
|
|
51
|
+
--spec-type draft-dflash `
|
|
52
|
+
--spec-draft-n-max 7 `
|
|
53
|
+
--spec-draft-backend-sampling
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
becomes `qwen3.8-27b.ini`:
|
|
57
|
+
|
|
58
|
+
```ini
|
|
59
|
+
version = 1
|
|
60
|
+
|
|
61
|
+
[qwen3.8-27b]
|
|
62
|
+
load-on-startup = true
|
|
63
|
+
hf-repo = unsloth/Qwen3.8-27B-GGUF
|
|
64
|
+
hf-file = Qwen3.8-27B-UD-Q4_K_M.gguf
|
|
65
|
+
hf-repo-draft = z-lab/Qwen3.8-27B-DFlash2-GGUF
|
|
66
|
+
spec-draft-model = Qwen3.8-27B-DFlash2-Q4_K_M.gguf
|
|
67
|
+
no-mmproj = true
|
|
68
|
+
batch-size = 4096
|
|
69
|
+
ubatch-size = 1024
|
|
70
|
+
ctx-size = 65536
|
|
71
|
+
parallel = 1
|
|
72
|
+
ngl = 999
|
|
73
|
+
jinja = true
|
|
74
|
+
chat-template-kwargs = {"preserve_thinking":true}
|
|
75
|
+
spec-type = draft-dflash
|
|
76
|
+
spec-draft-n-max = 7
|
|
77
|
+
spec-draft-backend-sampling = true
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Start the router
|
|
81
|
+
|
|
82
|
+
Open PowerShell in the llama.cpp folder and run:
|
|
83
|
+
|
|
84
|
+
```powershell
|
|
85
|
+
.\llama-server.exe --models-preset qwen3.8-27b.ini --host 127.0.0.1 --port 8080
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
If the recipe requires a Hugging Face token, set `$env:HF_TOKEN` in the same PowerShell window before starting the router. On its first start, the router downloads the model files.
|
|
89
|
+
|
|
90
|
+
Use the [router health checks](llama-cpp.md#troubleshooting) to confirm that the server is ready. In Windows PowerShell, use `curl.exe` rather than `curl`, which PowerShell maps to a different command. The model is ready when `/models` lists `qwen3.8-27b` with the status `loaded`.
|
|
91
|
+
|
|
92
|
+
## Use the model in KnightCode
|
|
93
|
+
|
|
94
|
+
Follow [Configure KnightCode](llama-cpp.md#configure-knightcode) and connect to `http://127.0.0.1:8080`. The preset section name is the model ID, so select `qwen3.8-27b` in `/model` for this example.
|
|
95
|
+
|
|
96
|
+
NVIDIA recipe memory settings assume that only the selected model uses the GPU. If `/llama` shows other loaded models, unload them before using the recipe model.
|
package/docs/packages.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# KnightCode Packages
|
|
2
|
+
|
|
3
|
+
KnightCode packages install and distribute extensions, skills, prompt templates, and themes as one unit. Use a package when a customization should be shared through npm or git, or when several resources belong together.
|
|
4
|
+
|
|
5
|
+
A package is an ordinary directory or npm package. It can expose conventional resource directories, declare explicit paths under the `knightcode` key in `package.json`, and carry its own runtime dependencies.
|
|
6
|
+
|
|
7
|
+
## Install and manage packages
|
|
8
|
+
|
|
9
|
+
Install from npm, git, or a local path:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
knightcode install npm:@example/knightcode-tools@1.0.0
|
|
13
|
+
knightcode install git:github.com/example/knightcode-tools@v1
|
|
14
|
+
knightcode install ./local-package
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`knightcode list` shows configured packages. Use `knightcode remove <source>` to remove one and `knightcode update --extensions` to reconcile package installations. See [Command Line](cli.md#package-commands) for every package command and option.
|
|
18
|
+
|
|
19
|
+
Personal installs are written to `~/.knightcode/agent/settings.json`. Add `--local` or `-l` to write the package declaration to `.knightcode/settings.json`. KnightCode reads declarations from that file only after project trust is granted.
|
|
20
|
+
|
|
21
|
+
Project packages are installed and loaded only after project trust is resolved. Packages can execute extension code and can include skills that instruct the model to run programs. Review third-party package source before installing it. Review project package declarations before granting project trust.
|
|
22
|
+
|
|
23
|
+
Use `--extension` or `-e` to try a package for one invocation without adding it to settings:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
knightcode -e npm:@example/knightcode-tools
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Choose a source
|
|
30
|
+
|
|
31
|
+
| Source | Example | Behavior |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| npm | `npm:@example/knightcode-tools@1.0.0` | Installed under the KnightCode npm directory |
|
|
34
|
+
| git | `git:github.com/example/knightcode-tools@v1` | Cloned and reconciled to the selected ref |
|
|
35
|
+
| URL | `https://github.com/example/knightcode-tools` | Treated as a git source |
|
|
36
|
+
| Local | `./knightcode-tools` | Loaded from the resolved path without copying |
|
|
37
|
+
|
|
38
|
+
Versioned npm specifications are pinned. Git tags and commits are also pinned; package updates reconcile the checkout but do not move a configured ref.
|
|
39
|
+
|
|
40
|
+
Relative local paths resolve from the settings file that contains them. A file path loads one extension. A directory follows normal package discovery rules.
|
|
41
|
+
|
|
42
|
+
## Create a package
|
|
43
|
+
|
|
44
|
+
The simplest package uses conventional directories:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
my-knightcode-package/
|
|
48
|
+
├── package.json
|
|
49
|
+
├── extensions/
|
|
50
|
+
├── skills/
|
|
51
|
+
├── prompts/
|
|
52
|
+
└── themes/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Without a `knightcode` manifest, KnightCode discovers TypeScript and JavaScript extensions, skill directories, Markdown prompts, and JSON themes from those directories.
|
|
56
|
+
|
|
57
|
+
Use an explicit manifest when resources live elsewhere or need filtering:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"name": "my-knightcode-package",
|
|
62
|
+
"keywords": ["knightcode-package"],
|
|
63
|
+
"knightcode": {
|
|
64
|
+
"extensions": ["./src/extension.ts"],
|
|
65
|
+
"skills": ["./resources/skills"],
|
|
66
|
+
"prompts": ["./resources/prompts/*.md"],
|
|
67
|
+
"themes": ["./resources/themes/*.json"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Paths are relative to the package root. Arrays accept glob patterns and exclusions. List dot-prefixed or symlinked resource roots directly when traversal through a glob would not discover them.
|
|
73
|
+
|
|
74
|
+
The `knightcode-package` keyword makes an npm package eligible for discovery in the [KnightCode package gallery](https://knightcode.dev/packages). Optional `knightcode.image` and `knightcode.video` fields add gallery previews.
|
|
75
|
+
|
|
76
|
+
## Declare dependencies
|
|
77
|
+
|
|
78
|
+
Put runtime packages imported by extensions in `dependencies`. KnightCode installs package dependencies when it installs an npm or git source.
|
|
79
|
+
|
|
80
|
+
KnightCode supplies these packages to extensions and skills:
|
|
81
|
+
|
|
82
|
+
- `@knightcode/ai`
|
|
83
|
+
- `@knightcode/agent`
|
|
84
|
+
- `@knightcodeai/cli`
|
|
85
|
+
- `@knightcode/tui`
|
|
86
|
+
- `typebox`
|
|
87
|
+
|
|
88
|
+
Declare the host-provided packages listed above in `peerDependencies` with a `"*"` range and do not bundle them. KnightCode suppresses automatic peer installation for managed npm packages and git packages installed with npm, pnpm, or Bun. Local packages are not installed or modified, so their dependency tree remains the package author's responsibility.
|
|
89
|
+
|
|
90
|
+
Do not list host-provided packages in `dependencies`. A physical copy can bypass KnightCode's extension module mapping in compiled ESM and create duplicate classes, registries, and initialization work. KnightCode reports an extension warning when it detects this manifest configuration. Other KnightCode packages used as dependencies must be included in the published tarball and referenced through their `node_modules` resource paths.
|
|
91
|
+
|
|
92
|
+
Installed packages load with separate module roots. Do not rely on two packages sharing one dependency instance or one package resolving another package’s undeclared dependency.
|
|
93
|
+
|
|
94
|
+
## Select package resources
|
|
95
|
+
|
|
96
|
+
The object form in settings narrows which resources load from a package:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"packages": [
|
|
101
|
+
{
|
|
102
|
+
"source": "npm:@example/knightcode-tools",
|
|
103
|
+
"extensions": ["extensions/*.ts", "!extensions/legacy.ts"],
|
|
104
|
+
"skills": [],
|
|
105
|
+
"prompts": ["prompts/review.md"]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For each resource type:
|
|
112
|
+
|
|
113
|
+
- Omit the property to load everything allowed by the package.
|
|
114
|
+
- Use `[]` to load none of that type.
|
|
115
|
+
- Use `!pattern` to exclude glob matches.
|
|
116
|
+
- Use `+path` to include one exact allowed path.
|
|
117
|
+
- Use `-path` to exclude one exact path.
|
|
118
|
+
|
|
119
|
+
Filters narrow the package manifest. They do not expose resources that the package itself did not declare.
|
|
120
|
+
|
|
121
|
+
Run `knightcode config` to enable or disable discovered resources and knightcode's built-in extensions. It starts with personal configuration; press Tab to switch scope, or run `knightcode config --local` to start with project overrides.
|
|
122
|
+
|
|
123
|
+
## Understand scope and identity
|
|
124
|
+
|
|
125
|
+
The same package can appear in personal and project settings. A project entry normally replaces the personal entry. With `autoload: false`, the project entry instead acts as a filtering delta over the personal package.
|
|
126
|
+
|
|
127
|
+
KnightCode identifies npm packages by package name, git packages by repository URL without the ref, and local packages by resolved absolute path. This prevents the same package from loading twice through equivalent declarations.
|
|
128
|
+
|
|
129
|
+
Use [Extensions](extensions.md), [Skills](skills.md), [Prompt Templates](prompt-templates.md), and [Themes](themes.md) to design each resource before packaging it.
|