klaatcode 1.15.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/README.md +15 -0
- package/bin/opencode +199 -0
- package/package.json +186 -0
package/README.md
ADDED
package/bin/opencode
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
const path = require("path")
|
|
6
|
+
const os = require("os")
|
|
7
|
+
|
|
8
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
|
9
|
+
|
|
10
|
+
function run(target) {
|
|
11
|
+
const child = childProcess.spawn(target, process.argv.slice(2), {
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
child.on("error", (error) => {
|
|
16
|
+
console.error(error.message)
|
|
17
|
+
process.exit(1)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const forwarders = {}
|
|
21
|
+
for (const signal of forwardedSignals) {
|
|
22
|
+
forwarders[signal] = () => {
|
|
23
|
+
try {
|
|
24
|
+
child.kill(signal)
|
|
25
|
+
} catch {
|
|
26
|
+
// The child may have already exited.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
process.on(signal, forwarders[signal])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
child.on("exit", (code, signal) => {
|
|
33
|
+
for (const forwardedSignal of forwardedSignals) {
|
|
34
|
+
process.removeListener(forwardedSignal, forwarders[forwardedSignal])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (signal) {
|
|
38
|
+
process.kill(process.pid, signal)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
process.exit(typeof code === "number" ? code : 0)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const envPath = process.env.OPENCODE_BIN_PATH
|
|
47
|
+
|
|
48
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
49
|
+
const scriptDir = path.dirname(scriptPath)
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
const cached = path.join(scriptDir, ".opencode")
|
|
53
|
+
|
|
54
|
+
const platformMap = {
|
|
55
|
+
darwin: "darwin",
|
|
56
|
+
linux: "linux",
|
|
57
|
+
win32: "windows",
|
|
58
|
+
}
|
|
59
|
+
const archMap = {
|
|
60
|
+
x64: "x64",
|
|
61
|
+
arm64: "arm64",
|
|
62
|
+
arm: "arm",
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let platform = platformMap[os.platform()]
|
|
66
|
+
if (!platform) {
|
|
67
|
+
platform = os.platform()
|
|
68
|
+
}
|
|
69
|
+
let arch = archMap[os.arch()]
|
|
70
|
+
if (!arch) {
|
|
71
|
+
arch = os.arch()
|
|
72
|
+
}
|
|
73
|
+
const base = "klaatcode-" + platform + "-" + arch
|
|
74
|
+
const binary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
75
|
+
|
|
76
|
+
function supportsAvx2() {
|
|
77
|
+
if (arch !== "x64") return false
|
|
78
|
+
|
|
79
|
+
if (platform === "linux") {
|
|
80
|
+
try {
|
|
81
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
82
|
+
} catch {
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (platform === "darwin") {
|
|
88
|
+
try {
|
|
89
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
90
|
+
encoding: "utf8",
|
|
91
|
+
timeout: 1500,
|
|
92
|
+
})
|
|
93
|
+
if (result.status !== 0) return false
|
|
94
|
+
return (result.stdout || "").trim() === "1"
|
|
95
|
+
} catch {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (platform === "windows") {
|
|
101
|
+
const cmd =
|
|
102
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
103
|
+
|
|
104
|
+
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
105
|
+
try {
|
|
106
|
+
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
107
|
+
encoding: "utf8",
|
|
108
|
+
timeout: 3000,
|
|
109
|
+
windowsHide: true,
|
|
110
|
+
})
|
|
111
|
+
if (result.status !== 0) continue
|
|
112
|
+
const out = (result.stdout || "").trim().toLowerCase()
|
|
113
|
+
if (out === "true" || out === "1") return true
|
|
114
|
+
if (out === "false" || out === "0") return false
|
|
115
|
+
} catch {
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const names = (() => {
|
|
127
|
+
const avx2 = supportsAvx2()
|
|
128
|
+
const baseline = arch === "x64" && !avx2
|
|
129
|
+
|
|
130
|
+
if (platform === "linux") {
|
|
131
|
+
const musl = (() => {
|
|
132
|
+
try {
|
|
133
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
134
|
+
} catch {
|
|
135
|
+
// ignore
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
140
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
141
|
+
if (text.includes("musl")) return true
|
|
142
|
+
} catch {
|
|
143
|
+
// ignore
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return false
|
|
147
|
+
})()
|
|
148
|
+
|
|
149
|
+
if (musl) {
|
|
150
|
+
if (arch === "x64") {
|
|
151
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
152
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
153
|
+
}
|
|
154
|
+
return [`${base}-musl`, base]
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (arch === "x64") {
|
|
158
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
159
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
160
|
+
}
|
|
161
|
+
return [base, `${base}-musl`]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (arch === "x64") {
|
|
165
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
166
|
+
return [base, `${base}-baseline`]
|
|
167
|
+
}
|
|
168
|
+
return [base]
|
|
169
|
+
})()
|
|
170
|
+
|
|
171
|
+
function findBinary(startDir) {
|
|
172
|
+
let current = startDir
|
|
173
|
+
for (;;) {
|
|
174
|
+
const modules = path.join(current, "node_modules")
|
|
175
|
+
if (fs.existsSync(modules)) {
|
|
176
|
+
for (const name of names) {
|
|
177
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
178
|
+
if (fs.existsSync(candidate)) return candidate
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const parent = path.dirname(current)
|
|
182
|
+
if (parent === current) {
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
current = parent
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
|
|
190
|
+
if (!resolved) {
|
|
191
|
+
console.error(
|
|
192
|
+
"It seems that your package manager failed to install the right version of the klaatcode CLI for your platform. You can try manually installing " +
|
|
193
|
+
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
194
|
+
" package",
|
|
195
|
+
)
|
|
196
|
+
process.exit(1)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
run(resolved)
|
package/package.json
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"version": "1.15.3",
|
|
4
|
+
"name": "klaatcode",
|
|
5
|
+
"description": "KlaatCode — AI coding assistant CLI with smart model routing",
|
|
6
|
+
"homepage": "https://klaatai.com",
|
|
7
|
+
"author": "KlaatAI <hello@klaatai.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/klaatai/klaatcode"
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["ai", "cli", "coding-assistant", "llm", "terminal", "opencode", "claude", "klaatai"],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"typecheck": "tsgo --noEmit",
|
|
17
|
+
"test": "bun test --timeout 30000",
|
|
18
|
+
"test:ci": "mkdir -p .artifacts/unit && bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
|
|
19
|
+
"test:httpapi": "bun run script/httpapi-exercise.ts --mode coverage --fail-on-missing --fail-on-skip && bun run script/httpapi-exercise.ts --mode auth --fail-on-missing --fail-on-skip && bun run script/httpapi-exercise.ts --mode effect --fail-on-missing --fail-on-skip",
|
|
20
|
+
"build": "bun run script/build.ts",
|
|
21
|
+
"fix-node-pty": "bun run script/fix-node-pty.ts",
|
|
22
|
+
"dev": "bun run --conditions=browser ./src/index.ts",
|
|
23
|
+
"dev:temporary": "bun run --conditions=browser ./src/temporary.ts",
|
|
24
|
+
"db": "bun drizzle-kit"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"klaatcode": "./bin/opencode"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"bin/opencode"
|
|
31
|
+
],
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"klaatcode-darwin-arm64": "1.15.3",
|
|
34
|
+
"klaatcode-darwin-x64": "1.15.3",
|
|
35
|
+
"klaatcode-linux-x64": "1.15.3",
|
|
36
|
+
"klaatcode-linux-arm64": "1.15.3",
|
|
37
|
+
"klaatcode-windows-x64": "1.15.3"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
"./*": "./src/*.ts"
|
|
41
|
+
},
|
|
42
|
+
"imports": {
|
|
43
|
+
"#db": {
|
|
44
|
+
"bun": "./src/storage/db.bun.ts",
|
|
45
|
+
"node": "./src/storage/db.node.ts",
|
|
46
|
+
"default": "./src/storage/db.bun.ts"
|
|
47
|
+
},
|
|
48
|
+
"#pty": {
|
|
49
|
+
"bun": "./src/pty/pty.bun.ts",
|
|
50
|
+
"node": "./src/pty/pty.node.ts",
|
|
51
|
+
"default": "./src/pty/pty.bun.ts"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@babel/core": "7.28.4",
|
|
56
|
+
"@octokit/webhooks-types": "7.6.1",
|
|
57
|
+
"@opencode-ai/script": "workspace:*",
|
|
58
|
+
"@opencode-ai/core": "workspace:*",
|
|
59
|
+
"@parcel/watcher-darwin-arm64": "2.5.1",
|
|
60
|
+
"@parcel/watcher-darwin-x64": "2.5.1",
|
|
61
|
+
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
|
|
62
|
+
"@parcel/watcher-linux-arm64-musl": "2.5.1",
|
|
63
|
+
"@parcel/watcher-linux-x64-glibc": "2.5.1",
|
|
64
|
+
"@parcel/watcher-linux-x64-musl": "2.5.1",
|
|
65
|
+
"@parcel/watcher-win32-arm64": "2.5.1",
|
|
66
|
+
"@parcel/watcher-win32-x64": "2.5.1",
|
|
67
|
+
"@standard-schema/spec": "1.0.0",
|
|
68
|
+
"@tsconfig/bun": "catalog:",
|
|
69
|
+
"@types/babel__core": "7.20.5",
|
|
70
|
+
"@types/bun": "catalog:",
|
|
71
|
+
"@types/cross-spawn": "catalog:",
|
|
72
|
+
"@types/mime-types": "3.0.1",
|
|
73
|
+
"@types/npm-package-arg": "6.1.4",
|
|
74
|
+
"@types/semver": "^7.5.8",
|
|
75
|
+
"@types/turndown": "5.0.5",
|
|
76
|
+
"@types/which": "3.0.4",
|
|
77
|
+
"@types/yargs": "17.0.33",
|
|
78
|
+
"@typescript/native-preview": "catalog:",
|
|
79
|
+
"drizzle-kit": "catalog:",
|
|
80
|
+
"drizzle-orm": "catalog:",
|
|
81
|
+
"prettier": "3.6.2",
|
|
82
|
+
"typescript": "catalog:",
|
|
83
|
+
"vscode-languageserver-types": "3.17.5",
|
|
84
|
+
"why-is-node-running": "3.2.2"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@actions/core": "1.11.1",
|
|
88
|
+
"@actions/github": "6.0.1",
|
|
89
|
+
"@agentclientprotocol/sdk": "0.21.0",
|
|
90
|
+
"@ai-sdk/alibaba": "1.0.17",
|
|
91
|
+
"@ai-sdk/amazon-bedrock": "4.0.96",
|
|
92
|
+
"@ai-sdk/anthropic": "3.0.71",
|
|
93
|
+
"@ai-sdk/azure": "3.0.49",
|
|
94
|
+
"@ai-sdk/cerebras": "2.0.41",
|
|
95
|
+
"@ai-sdk/cohere": "3.0.27",
|
|
96
|
+
"@ai-sdk/deepinfra": "2.0.41",
|
|
97
|
+
"@ai-sdk/gateway": "3.0.104",
|
|
98
|
+
"@ai-sdk/google": "3.0.63",
|
|
99
|
+
"@ai-sdk/google-vertex": "4.0.112",
|
|
100
|
+
"@ai-sdk/groq": "3.0.31",
|
|
101
|
+
"@ai-sdk/mistral": "3.0.27",
|
|
102
|
+
"@ai-sdk/openai": "3.0.53",
|
|
103
|
+
"@ai-sdk/openai-compatible": "2.0.41",
|
|
104
|
+
"@ai-sdk/perplexity": "3.0.26",
|
|
105
|
+
"@ai-sdk/provider": "3.0.8",
|
|
106
|
+
"@ai-sdk/togetherai": "2.0.41",
|
|
107
|
+
"@ai-sdk/vercel": "2.0.39",
|
|
108
|
+
"@ai-sdk/xai": "3.0.82",
|
|
109
|
+
"@aws-sdk/credential-providers": "3.993.0",
|
|
110
|
+
"@clack/prompts": "1.0.0-alpha.1",
|
|
111
|
+
"@effect/opentelemetry": "catalog:",
|
|
112
|
+
"@effect/platform-node": "catalog:",
|
|
113
|
+
"@gitlab/opencode-gitlab-auth": "1.3.3",
|
|
114
|
+
"@lydell/node-pty": "catalog:",
|
|
115
|
+
"@modelcontextprotocol/sdk": "1.27.1",
|
|
116
|
+
"@octokit/graphql": "9.0.2",
|
|
117
|
+
"@octokit/rest": "catalog:",
|
|
118
|
+
"@openauthjs/openauth": "catalog:",
|
|
119
|
+
"@opencode-ai/plugin": "workspace:*",
|
|
120
|
+
"@opencode-ai/script": "workspace:*",
|
|
121
|
+
"@opencode-ai/sdk": "workspace:*",
|
|
122
|
+
"@opencode-ai/ui": "workspace:*",
|
|
123
|
+
"@openrouter/ai-sdk-provider": "2.8.1",
|
|
124
|
+
"@opentelemetry/api": "1.9.0",
|
|
125
|
+
"@opentelemetry/context-async-hooks": "2.6.1",
|
|
126
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.214.0",
|
|
127
|
+
"@opentelemetry/sdk-trace-base": "2.6.1",
|
|
128
|
+
"@opentelemetry/sdk-trace-node": "2.6.1",
|
|
129
|
+
"@opentui/core": "catalog:",
|
|
130
|
+
"@opentui/keymap": "catalog:",
|
|
131
|
+
"@opentui/solid": "catalog:",
|
|
132
|
+
"@parcel/watcher": "2.5.1",
|
|
133
|
+
"@pierre/diffs": "catalog:",
|
|
134
|
+
"@silvia-odwyer/photon-node": "0.3.4",
|
|
135
|
+
"@solid-primitives/event-bus": "1.1.2",
|
|
136
|
+
"@solid-primitives/scheduled": "1.5.2",
|
|
137
|
+
"@standard-schema/spec": "1.0.0",
|
|
138
|
+
"@zip.js/zip.js": "2.7.62",
|
|
139
|
+
"ai": "catalog:",
|
|
140
|
+
"ai-gateway-provider": "3.1.2",
|
|
141
|
+
"bonjour-service": "1.3.0",
|
|
142
|
+
"bun-pty": "0.4.8",
|
|
143
|
+
"chokidar": "4.0.3",
|
|
144
|
+
"clipboardy": "4.0.0",
|
|
145
|
+
"cross-spawn": "catalog:",
|
|
146
|
+
"decimal.js": "10.5.0",
|
|
147
|
+
"diff": "catalog:",
|
|
148
|
+
"drizzle-orm": "catalog:",
|
|
149
|
+
"effect": "catalog:",
|
|
150
|
+
"fuzzysort": "3.1.0",
|
|
151
|
+
"gitlab-ai-provider": "6.6.0",
|
|
152
|
+
"glob": "13.0.5",
|
|
153
|
+
"google-auth-library": "10.5.0",
|
|
154
|
+
"gray-matter": "4.0.3",
|
|
155
|
+
"htmlparser2": "8.0.2",
|
|
156
|
+
"ignore": "7.0.5",
|
|
157
|
+
"immer": "11.1.4",
|
|
158
|
+
"jsonc-parser": "3.3.1",
|
|
159
|
+
"mime-types": "3.0.2",
|
|
160
|
+
"minimatch": "10.0.3",
|
|
161
|
+
"npm-package-arg": "13.0.2",
|
|
162
|
+
"open": "10.1.2",
|
|
163
|
+
"opencode-gitlab-auth": "2.0.1",
|
|
164
|
+
"opencode-poe-auth": "0.0.1",
|
|
165
|
+
"opentui-spinner": "catalog:",
|
|
166
|
+
"partial-json": "0.1.7",
|
|
167
|
+
"remeda": "catalog:",
|
|
168
|
+
"semver": "^7.6.3",
|
|
169
|
+
"solid-js": "catalog:",
|
|
170
|
+
"strip-ansi": "7.1.2",
|
|
171
|
+
"tree-sitter-bash": "0.25.0",
|
|
172
|
+
"tree-sitter-powershell": "0.25.10",
|
|
173
|
+
"turndown": "7.2.0",
|
|
174
|
+
"ulid": "catalog:",
|
|
175
|
+
"venice-ai-sdk-provider": "2.0.1",
|
|
176
|
+
"vscode-jsonrpc": "8.2.1",
|
|
177
|
+
"web-tree-sitter": "0.25.10",
|
|
178
|
+
"which": "6.0.1",
|
|
179
|
+
"xdg-basedir": "5.1.0",
|
|
180
|
+
"yargs": "18.0.0",
|
|
181
|
+
"zod": "catalog:"
|
|
182
|
+
},
|
|
183
|
+
"overrides": {
|
|
184
|
+
"drizzle-orm": "catalog:"
|
|
185
|
+
}
|
|
186
|
+
}
|