@knightcodeai/cli 0.1.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/README.md +36 -0
- package/bin/knightcode +62 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @knightcodeai/cli
|
|
2
|
+
|
|
3
|
+
`knightcode` — a local-first, bring-your-own-key AI coding CLI for your terminal.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @knightcodeai/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
You don't need Bun — it's bundled into the platform binary. The small launcher
|
|
12
|
+
(`bin/knightcode`) that spawns it runs on Node.js (>=18), which you already have
|
|
13
|
+
if you installed with npm. The right platform binary installs automatically as
|
|
14
|
+
an optional dependency.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
knightcode
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
On first run, set your OpenRouter API key from inside the app.
|
|
23
|
+
|
|
24
|
+
## Configuration
|
|
25
|
+
|
|
26
|
+
State lives in `~/.knightcode/` (sessions, settings, local SQLite database).
|
|
27
|
+
|
|
28
|
+
| Command / env var | Effect |
|
|
29
|
+
| ----------------- | ------ |
|
|
30
|
+
| `knightcode --version` | Print the installed version |
|
|
31
|
+
| `knightcode doctor` | Print diagnostics (config, database, API key, runtime) |
|
|
32
|
+
| `KNIGHTCODE_NO_UPDATE_CHECK=1` | Disable the background update check |
|
|
33
|
+
|
|
34
|
+
## Supported platforms
|
|
35
|
+
|
|
36
|
+
Linux (x64, arm64), macOS (x64, arm64), Windows (x64).
|
package/bin/knightcode
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Dependency-free launcher: resolves the platform-specific compiled binary
|
|
3
|
+
// (shipped as an optional dependency) and spawns it, forwarding args, stdio,
|
|
4
|
+
// signals, and the exit code. Uses only Node builtins.
|
|
5
|
+
import { spawn } from "node:child_process";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
11
|
+
|
|
12
|
+
function run(target) {
|
|
13
|
+
const child = spawn(target, process.argv.slice(2), {
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
child.on("error", (error) => {
|
|
18
|
+
console.error(error.message);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const forwarders = {};
|
|
23
|
+
for (const signal of forwardedSignals) {
|
|
24
|
+
forwarders[signal] = () => {
|
|
25
|
+
try {
|
|
26
|
+
child.kill(signal);
|
|
27
|
+
} catch {
|
|
28
|
+
// The child may have already exited.
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
process.on(signal, forwarders[signal]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
child.on("exit", (code, signal) => {
|
|
35
|
+
for (const s of forwardedSignals) process.removeListener(s, forwarders[s]);
|
|
36
|
+
if (signal) {
|
|
37
|
+
process.kill(process.pid, signal);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
process.exit(typeof code === "number" ? code : 0);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const pkg = `@knightcodeai/cli-${process.platform}-${process.arch}`;
|
|
45
|
+
const binary = process.platform === "win32" ? "knightcode.exe" : "knightcode";
|
|
46
|
+
|
|
47
|
+
let target = process.env.KNIGHTCODE_BIN_PATH;
|
|
48
|
+
if (!target) {
|
|
49
|
+
try {
|
|
50
|
+
target = require.resolve(`${pkg}/bin/${binary}`);
|
|
51
|
+
} catch {
|
|
52
|
+
console.error(
|
|
53
|
+
`knightcode: no prebuilt binary for ${process.platform}-${process.arch}.\n` +
|
|
54
|
+
`Your package manager may have skipped the optional dependency "${pkg}".\n` +
|
|
55
|
+
`Reinstall the CLI with your package manager (npm, yarn, pnpm, or bun), ` +
|
|
56
|
+
`or set KNIGHTCODE_BIN_PATH to a local knightcode binary.`,
|
|
57
|
+
);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
run(target);
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@knightcodeai/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"knightcode": "./bin/knightcode"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"optionalDependencies": {
|
|
16
|
+
"@knightcodeai/cli-linux-x64": "0.1.0",
|
|
17
|
+
"@knightcodeai/cli-linux-arm64": "0.1.0",
|
|
18
|
+
"@knightcodeai/cli-darwin-x64": "0.1.0",
|
|
19
|
+
"@knightcodeai/cli-darwin-arm64": "0.1.0",
|
|
20
|
+
"@knightcodeai/cli-win32-x64": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"dev": "bun run --watch src/index.tsx",
|
|
24
|
+
"check-types": "tsc --noEmit",
|
|
25
|
+
"test": "bun test src/**/*.test.ts"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@ai-sdk/provider-utils": "^4.0.27",
|
|
29
|
+
"@ai-sdk/react": "^3.0.193",
|
|
30
|
+
"@repo/shared": "workspace:*",
|
|
31
|
+
"@openrouter/ai-sdk-provider": "^2.9.0",
|
|
32
|
+
"@opentui/core": "^0.2.10",
|
|
33
|
+
"@opentui/react": "^0.2.10",
|
|
34
|
+
"@repo/eslint-config": "*",
|
|
35
|
+
"@repo/typescript-config": "workspace:*",
|
|
36
|
+
"@types/bun": "latest",
|
|
37
|
+
"@types/html-to-text": "^9.0.4",
|
|
38
|
+
"@types/react": "^19.2.6",
|
|
39
|
+
"ai": "^6.0.191",
|
|
40
|
+
"date-fns": "^4.3.0",
|
|
41
|
+
"drizzle-kit": "^0.31.10",
|
|
42
|
+
"drizzle-orm": "^0.45.2",
|
|
43
|
+
"hono": "^4.12.12",
|
|
44
|
+
"html-to-text": "^10.0.0",
|
|
45
|
+
"open": "^11.0.0",
|
|
46
|
+
"opentui-spinner": "^0.0.6",
|
|
47
|
+
"pretty-ms": "^9.3.0",
|
|
48
|
+
"react": "^19.2.6",
|
|
49
|
+
"react-router": "7.14.2",
|
|
50
|
+
"safe-regex": "^2.1.1",
|
|
51
|
+
"typescript": "^5",
|
|
52
|
+
"zod": "^4.3.6"
|
|
53
|
+
}
|
|
54
|
+
}
|