@knightcodeai/cli-win32-x64 0.4.1 → 0.5.0
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 +178 -0
- package/bin/README.md +36 -0
- package/bin/docs/compaction.md +416 -0
- package/bin/docs/containerization.md +111 -0
- package/bin/docs/custom-provider.md +777 -0
- package/bin/docs/development.md +71 -0
- package/bin/docs/docs.json +156 -0
- package/bin/docs/environment-variables.md +97 -0
- package/bin/docs/extensions.md +3020 -0
- package/bin/docs/images/doom-extension.png +0 -0
- package/bin/docs/images/interactive-mode.png +0 -0
- package/bin/docs/images/tree-view.png +0 -0
- package/bin/docs/index.md +84 -0
- package/bin/docs/json.md +98 -0
- package/bin/docs/keybindings.md +236 -0
- package/bin/docs/llama-cpp.md +101 -0
- package/bin/docs/models.md +571 -0
- package/bin/docs/packages.md +228 -0
- package/bin/docs/prompt-templates.md +96 -0
- package/bin/docs/providers.md +317 -0
- package/bin/docs/quickstart.md +167 -0
- package/bin/docs/rpc.md +1618 -0
- package/bin/docs/sdk.md +1219 -0
- package/bin/docs/security.md +59 -0
- package/bin/docs/session-format.md +438 -0
- package/bin/docs/sessions.md +145 -0
- package/bin/docs/settings.md +368 -0
- package/bin/docs/shell-aliases.md +13 -0
- package/bin/docs/skills.md +231 -0
- package/bin/docs/terminal-setup.md +177 -0
- package/bin/docs/termux.md +127 -0
- package/bin/docs/themes.md +320 -0
- package/bin/docs/tmux.md +63 -0
- package/bin/docs/tui.md +942 -0
- package/bin/docs/usage.md +307 -0
- package/bin/docs/windows.md +39 -0
- package/bin/export-html/template.css +1066 -0
- package/bin/export-html/template.html +55 -0
- package/bin/export-html/template.js +1864 -0
- package/bin/export-html/vendor/highlight.min.js +1213 -0
- package/bin/export-html/vendor/marked.min.js +78 -0
- package/bin/knightcode.exe +0 -0
- package/bin/package.json +76 -0
- package/bin/photon_rs_bg.wasm +0 -0
- package/bin/theme/dark.json +90 -0
- package/bin/theme/light.json +89 -0
- package/bin/theme/theme-schema.json +352 -0
- package/package.json +7 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
See [AGENTS.md](https://github.com/KnightCodeAI/knightcode/blob/main/AGENTS.md) for additional guidelines.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/KnightCodeAI/knightcode
|
|
9
|
+
cd knightcode
|
|
10
|
+
npm install
|
|
11
|
+
npm run build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Run from source:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
/path/to/knightcode/knightcode-test.sh
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The script can be run from any directory. KnightCode keeps the caller's current working directory.
|
|
21
|
+
|
|
22
|
+
## Forking / Rebranding
|
|
23
|
+
|
|
24
|
+
Configure via `package.json`:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"piConfig": {
|
|
29
|
+
"name": "knightcode",
|
|
30
|
+
"configDir": ".knightcode"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Change `name`, `configDir`, and `bin` field for your fork. Affects CLI banner, config paths, and environment variable names.
|
|
36
|
+
|
|
37
|
+
## Path Resolution
|
|
38
|
+
|
|
39
|
+
Three execution modes: npm install, standalone binary, tsx from source.
|
|
40
|
+
|
|
41
|
+
**Always use `src/config.ts`** for package assets:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { getPackageDir, getThemeDir } from "./config.js";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Never use `__dirname` directly for package assets.
|
|
48
|
+
|
|
49
|
+
## Debug Command
|
|
50
|
+
|
|
51
|
+
`/debug` (hidden) writes to `~/.knightcode/agent/knightcode-debug.log`:
|
|
52
|
+
- Rendered TUI lines with ANSI codes
|
|
53
|
+
- Last messages sent to the LLM
|
|
54
|
+
|
|
55
|
+
## Testing
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
./test.sh # Run non-LLM tests (no API keys needed)
|
|
59
|
+
npm test # Run all tests
|
|
60
|
+
npm test -- test/specific.test.ts # Run specific test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Project Structure
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
packages/
|
|
67
|
+
ai/ # LLM provider abstraction
|
|
68
|
+
agent/ # Agent loop and message types
|
|
69
|
+
tui/ # Terminal UI components
|
|
70
|
+
coding-agent/ # CLI and interactive mode
|
|
71
|
+
```
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
{
|
|
2
|
+
"navigation": [
|
|
3
|
+
{
|
|
4
|
+
"title": "Start here",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"title": "Overview",
|
|
8
|
+
"path": "index.md"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"title": "Quickstart",
|
|
12
|
+
"path": "quickstart.md"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"title": "Using KnightCode",
|
|
16
|
+
"path": "usage.md"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"title": "Providers",
|
|
20
|
+
"path": "providers.md"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"title": "Security",
|
|
24
|
+
"path": "security.md"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"title": "Containerization",
|
|
28
|
+
"path": "containerization.md"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"title": "Settings",
|
|
32
|
+
"path": "settings.md"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"title": "Keybindings",
|
|
36
|
+
"path": "keybindings.md"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"title": "Sessions",
|
|
40
|
+
"path": "sessions.md"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"title": "Compaction",
|
|
44
|
+
"path": "compaction.md"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"title": "Customization",
|
|
50
|
+
"items": [
|
|
51
|
+
{
|
|
52
|
+
"title": "Extensions",
|
|
53
|
+
"path": "extensions.md"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"title": "Skills",
|
|
57
|
+
"path": "skills.md"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"title": "Prompt Templates",
|
|
61
|
+
"path": "prompt-templates.md"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"title": "Themes",
|
|
65
|
+
"path": "themes.md"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"title": "KnightCode Packages",
|
|
69
|
+
"path": "packages.md"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"title": "Custom Models",
|
|
73
|
+
"path": "models.md"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"title": "Custom Providers",
|
|
77
|
+
"path": "custom-provider.md"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"title": "Reference",
|
|
83
|
+
"items": [
|
|
84
|
+
{
|
|
85
|
+
"title": "Session Format",
|
|
86
|
+
"path": "session-format.md"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"title": "Programmatic Usage",
|
|
92
|
+
"items": [
|
|
93
|
+
{
|
|
94
|
+
"title": "SDK",
|
|
95
|
+
"path": "sdk.md"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"title": "RPC Mode",
|
|
99
|
+
"path": "rpc.md"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"title": "JSON Event Stream Mode",
|
|
103
|
+
"path": "json.md"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"title": "TUI Components",
|
|
107
|
+
"path": "tui.md"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"title": "Platform Setup",
|
|
113
|
+
"items": [
|
|
114
|
+
{
|
|
115
|
+
"title": "Windows",
|
|
116
|
+
"path": "windows.md"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"title": "Termux on Android",
|
|
120
|
+
"path": "termux.md"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"title": "tmux",
|
|
124
|
+
"path": "tmux.md"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"title": "Terminal Setup",
|
|
128
|
+
"path": "terminal-setup.md"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"title": "Shell Aliases",
|
|
132
|
+
"path": "shell-aliases.md"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"title": "Development",
|
|
138
|
+
"items": [
|
|
139
|
+
{
|
|
140
|
+
"title": "Development",
|
|
141
|
+
"path": "development.md"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"redirects": [
|
|
147
|
+
{
|
|
148
|
+
"from": "session.md",
|
|
149
|
+
"to": "session-format.md"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"from": "tree.md",
|
|
153
|
+
"to": "sessions.md"
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Environment Variables
|
|
2
|
+
|
|
3
|
+
KnightCode uses environment variables in three ways:
|
|
4
|
+
|
|
5
|
+
- Variables such as `KNIGHTCODE_OFFLINE` configure the KnightCode process.
|
|
6
|
+
- KnightCode sets process markers so child processes can identify KnightCode as the launching agent.
|
|
7
|
+
- Commands run by the LLM-callable shell tools receive `KNIGHTCODE_*` variables describing the current session.
|
|
8
|
+
|
|
9
|
+
Provider API-key variables are documented separately in [Providers](providers.md#environment-variables-or-auth-file).
|
|
10
|
+
|
|
11
|
+
## Process Marker
|
|
12
|
+
|
|
13
|
+
The CLI and RPC entry points set two process markers:
|
|
14
|
+
|
|
15
|
+
- `AI_AGENT=knightcode` is a generic marker that lets tooling identify KnightCode as the agent that launched the process.
|
|
16
|
+
- `KNIGHTCODE_CODING_AGENT=true` is KnightCode-specific and lets child processes detect that they run inside KnightCode.
|
|
17
|
+
|
|
18
|
+
Child processes inherit both markers. They are not session-specific and are not set automatically when KnightCode is embedded through the SDK.
|
|
19
|
+
|
|
20
|
+
## Shell Tool Session Environment
|
|
21
|
+
|
|
22
|
+
Commands run by the `bash` and `powershell` tools receive the current KnightCode session state:
|
|
23
|
+
|
|
24
|
+
| Variable | Description |
|
|
25
|
+
|----------|-------------|
|
|
26
|
+
| `KNIGHTCODE_SESSION_ID` | Current session ID |
|
|
27
|
+
| `KNIGHTCODE_SESSION_FILE` | Absolute path to the current session JSONL file; unset for ephemeral sessions |
|
|
28
|
+
| `KNIGHTCODE_PROVIDER` | Currently selected model provider |
|
|
29
|
+
| `KNIGHTCODE_MODEL` | Currently selected model ID |
|
|
30
|
+
| `KNIGHTCODE_REASONING_LEVEL` | Current effective reasoning level: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max` |
|
|
31
|
+
|
|
32
|
+
The values are resolved when each command starts. Switching models or changing the reasoning level therefore affects the next shell command without restarting KnightCode. `KNIGHTCODE_PROVIDER` and `KNIGHTCODE_MODEL` identify the selected KnightCode model, not a different upstream model that a router may choose internally.
|
|
33
|
+
|
|
34
|
+
When asked which model or provider is running, inspect these variables instead of inferring the answer from the system prompt:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
printf '%s/%s\n' "$KNIGHTCODE_PROVIDER" "$KNIGHTCODE_MODEL"
|
|
38
|
+
printf 'reasoning=%s session=%s\n' "$KNIGHTCODE_REASONING_LEVEL" "$KNIGHTCODE_SESSION_ID"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The session file can be inspected directly when the session is persistent:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
if [ -n "$KNIGHTCODE_SESSION_FILE" ]; then
|
|
45
|
+
tail -n 1 "$KNIGHTCODE_SESSION_FILE"
|
|
46
|
+
fi
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
These variables are injected into the LLM-callable `bash` and `powershell` tools. They are not injected into user-entered `!` or `!!` commands.
|
|
50
|
+
|
|
51
|
+
### Custom Shell Tools
|
|
52
|
+
|
|
53
|
+
Tools created with `createBashTool()` or `createPowerShellTool()` expose the session environment by default when registered with KnightCode. Injection happens before `spawnHook`, so a hook receives the variables in `ctx.env`:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const bashTool = createBashTool(cwd, {
|
|
57
|
+
spawnHook: (ctx) => ({
|
|
58
|
+
...ctx,
|
|
59
|
+
env: { ...ctx.env, CI: "1" },
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Disable session metadata independently of the spawn hook:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const powershellTool = createPowerShellTool(cwd, {
|
|
68
|
+
exposeSessionEnvironment: false,
|
|
69
|
+
spawnHook: (ctx) => ctx,
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
When disabled, KnightCode removes inherited values for these variables so nested KnightCode processes do not expose stale parent-session metadata.
|
|
74
|
+
|
|
75
|
+
## KnightCode Process Configuration
|
|
76
|
+
|
|
77
|
+
These variables are read by KnightCode itself:
|
|
78
|
+
|
|
79
|
+
| Variable | Description |
|
|
80
|
+
|----------|-------------|
|
|
81
|
+
| `KNIGHTCODE_CODING_AGENT_DIR` | Override the config directory; default is `~/.knightcode/agent` |
|
|
82
|
+
| `KNIGHTCODE_CODING_AGENT_SESSION_DIR` | Override session storage; overridden by `--session-dir` |
|
|
83
|
+
| `KNIGHTCODE_PACKAGE_DIR` | Override the package directory, useful for Nix/Guix store paths |
|
|
84
|
+
| `KNIGHTCODE_OFFLINE` | Disable startup network operations, including update checks, package updates, and install/update telemetry |
|
|
85
|
+
| `KNIGHTCODE_SKIP_VERSION_CHECK` | Disable the `knightcode.dev` latest-version request |
|
|
86
|
+
| `KNIGHTCODE_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no` |
|
|
87
|
+
| `KNIGHTCODE_CACHE_RETENTION` | Set to `long` for extended provider prompt caching where supported |
|
|
88
|
+
| `KNIGHTCODE_SHARE_VIEWER_URL` | Override the base URL used by `/share` |
|
|
89
|
+
| `KNIGHTCODE_HARDWARE_CURSOR` | Set to `1` to show the hardware cursor; see [Terminal setup](terminal-setup.md) |
|
|
90
|
+
| `KNIGHTCODE_HYPERLINKS` | Override OSC 8 hyperlink detection with `1`, `0`, or `auto` |
|
|
91
|
+
| `KNIGHTCODE_IMAGE_PROTOCOL` | Override inline image detection with `kitty`, `iterm2`, `none`, or `auto` |
|
|
92
|
+
| `KNIGHTCODE_TRUE_COLOR` | Override truecolor detection with `1`, `0`, or `auto` |
|
|
93
|
+
| `KNIGHTCODE_TUI_ESC_TIMEOUT` | How long to wait after a lone ESC before treating it as Escape, in milliseconds; defaults to `100` over SSH and `10` otherwise. Increase if Alt-key input is misread as Escape |
|
|
94
|
+
| `VISUAL`, `EDITOR` | External editor fallback when `externalEditor` is unset |
|
|
95
|
+
| `HTTP_PROXY`, `HTTPS_PROXY` | Proxy outbound HTTP requests |
|
|
96
|
+
|
|
97
|
+
Provider credentials such as `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and cloud-provider configuration are listed in [Providers](providers.md#environment-variables-or-auth-file).
|