@ilura/northstar 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/LICENSE +23 -0
- package/README.md +90 -0
- package/bin/northstar +236 -0
- package/package.json +57 -0
- package/postinstall.mjs +222 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ilura Technology OÜ
|
|
4
|
+
Copyright (c) 2026 Kilo Code
|
|
5
|
+
Copyright (c) 2025 opencode
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Kilo Code CLI
|
|
2
|
+
|
|
3
|
+
The AI coding agent built for the terminal. Generate code from natural language, automate tasks, and run terminal commands -- powered by 500+ AI models.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Kilo is the all-in-one agentic engineering platform. Build, ship, and iterate faster with the most popular open source coding agent.
|
|
8
|
+
|
|
9
|
+
[Website](https://kilo.ai) · [Install](https://kilo.ai/install) · [IDE](https://kilo.ai/landing/vs-code) · [CLI](https://kilo.ai/cli) · [Docs](https://kilo.ai/docs) · [Models](https://kilo.ai/leaderboard) · [Gateway](https://kilo.ai/gateway) · [Pricing](https://kilo.ai/pricing) · [Kilo Pass](https://kilo.ai/pricing/kilo-pass)
|
|
10
|
+
|
|
11
|
+
[500+ models](https://kilo.ai/leaderboard). One open source agent in [VS Code](https://kilo.ai/vscode-marketplace), [JetBrains](https://plugins.jetbrains.com/plugin/27133-kilo-code), [CLI](https://www.npmjs.com/package/@kilocode/cli), [Slack](https://kilo.ai/slack), and [Cloud](https://kilo.ai/cloud).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @kilocode/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or run directly with npx:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx --package @kilocode/cli kilo
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
27
|
+
Run `kilo` in any project directory to launch the interactive TUI:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
kilo
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Run a one-off task:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
kilo run "add input validation to the signup form"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Features
|
|
40
|
+
|
|
41
|
+
- **Code generation** -- describe what you want in natural language
|
|
42
|
+
- **Terminal commands** -- the agent can run shell commands on your behalf
|
|
43
|
+
- **500+ AI models** -- use models from OpenAI, Anthropic, Google, and more
|
|
44
|
+
- **MCP servers** -- extend agent capabilities with the Model Context Protocol
|
|
45
|
+
- **Multiple modes** -- Plan with Architect, code with Coder, debug with Debugger, or create your own
|
|
46
|
+
- **Sessions** -- resume previous conversations and export transcripts
|
|
47
|
+
- **API keys optional** -- bring your own keys or use Kilo credits
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Description |
|
|
52
|
+
| --------------------- | -------------------------- |
|
|
53
|
+
| `kilo` | Launch interactive TUI |
|
|
54
|
+
| `kilo run "<task>"` | Run a one-off task |
|
|
55
|
+
| `kilo auth` | Manage authentication |
|
|
56
|
+
| `kilo models` | List available models |
|
|
57
|
+
| `kilo mcp` | Manage MCP servers |
|
|
58
|
+
| `kilo session list` | List sessions |
|
|
59
|
+
| `kilo session delete` | Delete a session |
|
|
60
|
+
| `kilo export` | Export session transcripts |
|
|
61
|
+
|
|
62
|
+
Run `kilo --help` for the full list.
|
|
63
|
+
|
|
64
|
+
## Alternative Installation
|
|
65
|
+
|
|
66
|
+
### Homebrew (macOS/Linux)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
brew install Kilo-Org/tap/kilo
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### GitHub Releases
|
|
73
|
+
|
|
74
|
+
Download pre-built binaries from the [Releases page](https://github.com/Kilo-Org/kilocode/releases).
|
|
75
|
+
|
|
76
|
+
## Documentation
|
|
77
|
+
|
|
78
|
+
- [Docs](https://kilo.ai/docs)
|
|
79
|
+
- [Getting Started](https://kilo.ai/docs/getting-started)
|
|
80
|
+
|
|
81
|
+
## Links
|
|
82
|
+
|
|
83
|
+
- [GitHub](https://github.com/Kilo-Org/kilocode)
|
|
84
|
+
- [Discord](https://kilo.ai/discord)
|
|
85
|
+
- [VS Code Extension](https://kilo.ai/vscode-marketplace)
|
|
86
|
+
- [Website](https://kilo.ai)
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
package/bin/northstar
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// kilocode_change - new file
|
|
3
|
+
|
|
4
|
+
const childProcess = require("child_process")
|
|
5
|
+
const fs = require("fs")
|
|
6
|
+
const path = require("path")
|
|
7
|
+
const os = require("os")
|
|
8
|
+
|
|
9
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
|
10
|
+
|
|
11
|
+
// kilocode_change start - point packaged binaries at co-located tree-sitter WASM resources
|
|
12
|
+
function configureTreeSitterResources(target) {
|
|
13
|
+
const wasmDir = path.join(path.dirname(target), "tree-sitter")
|
|
14
|
+
if (!process.env.KILO_TREE_SITTER_WASM_DIR && fs.existsSync(path.join(wasmDir, "tree-sitter.wasm"))) {
|
|
15
|
+
process.env.KILO_TREE_SITTER_WASM_DIR = wasmDir
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// kilocode_change end
|
|
19
|
+
|
|
20
|
+
function run(target, fallback) {
|
|
21
|
+
// kilocode_change - preserve cached binary fallback
|
|
22
|
+
configureTreeSitterResources(target) // kilocode_change
|
|
23
|
+
// kilocode_change start - fall through if the cached binary cannot be spawned
|
|
24
|
+
const child = (() => {
|
|
25
|
+
try {
|
|
26
|
+
return childProcess.spawn(target, process.argv.slice(2), {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
})
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (fallback) {
|
|
31
|
+
run(fallback)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
console.error(error.message)
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
})()
|
|
38
|
+
if (!child) return
|
|
39
|
+
// kilocode_change end
|
|
40
|
+
|
|
41
|
+
const forwarders = {}
|
|
42
|
+
const clear = () => {
|
|
43
|
+
// kilocode_change - remove listeners before cached binary fallback
|
|
44
|
+
for (const signal of forwardedSignals) {
|
|
45
|
+
process.removeListener(signal, forwarders[signal])
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
child.on("error", (error) => {
|
|
50
|
+
clear() // kilocode_change
|
|
51
|
+
// kilocode_change start - fall through to findBinary() if cached binary fails
|
|
52
|
+
if (fallback) {
|
|
53
|
+
run(fallback)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
// kilocode_change end
|
|
57
|
+
console.error(error.message)
|
|
58
|
+
process.exit(1)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
for (const signal of forwardedSignals) {
|
|
62
|
+
forwarders[signal] = () => {
|
|
63
|
+
try {
|
|
64
|
+
child.kill(signal)
|
|
65
|
+
} catch {
|
|
66
|
+
// The child may have already exited.
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
process.on(signal, forwarders[signal])
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
child.on("exit", (code, signal) => {
|
|
73
|
+
clear() // kilocode_change
|
|
74
|
+
|
|
75
|
+
if (signal) {
|
|
76
|
+
process.kill(process.pid, signal)
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
process.exit(typeof code === "number" ? code : 0)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const envPath = process.env.KILO_BIN_PATH
|
|
85
|
+
|
|
86
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
87
|
+
const scriptDir = path.dirname(scriptPath)
|
|
88
|
+
|
|
89
|
+
const cached = path.join(scriptDir, ".kilo")
|
|
90
|
+
|
|
91
|
+
const platformMap = {
|
|
92
|
+
darwin: "darwin",
|
|
93
|
+
linux: "linux",
|
|
94
|
+
win32: "windows",
|
|
95
|
+
}
|
|
96
|
+
const archMap = {
|
|
97
|
+
x64: "x64",
|
|
98
|
+
arm64: "arm64",
|
|
99
|
+
arm: "arm",
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let platform = platformMap[os.platform()]
|
|
103
|
+
if (!platform) {
|
|
104
|
+
platform = os.platform()
|
|
105
|
+
}
|
|
106
|
+
let arch = archMap[os.arch()]
|
|
107
|
+
if (!arch) {
|
|
108
|
+
arch = os.arch()
|
|
109
|
+
}
|
|
110
|
+
const base = "@ilura/northstar-" + platform + "-" + arch
|
|
111
|
+
const binary = platform === "windows" ? "northstar.exe" : "northstar"
|
|
112
|
+
|
|
113
|
+
function supportsAvx2() {
|
|
114
|
+
if (arch !== "x64") return false
|
|
115
|
+
|
|
116
|
+
if (platform === "linux") {
|
|
117
|
+
try {
|
|
118
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
119
|
+
} catch {
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (platform === "darwin") {
|
|
125
|
+
try {
|
|
126
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
127
|
+
encoding: "utf8",
|
|
128
|
+
timeout: 1500,
|
|
129
|
+
})
|
|
130
|
+
if (result.status !== 0) return false
|
|
131
|
+
return (result.stdout || "").trim() === "1"
|
|
132
|
+
} catch {
|
|
133
|
+
return false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (platform === "windows") {
|
|
138
|
+
const cmd =
|
|
139
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
140
|
+
|
|
141
|
+
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
142
|
+
try {
|
|
143
|
+
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
144
|
+
encoding: "utf8",
|
|
145
|
+
timeout: 3000,
|
|
146
|
+
windowsHide: true,
|
|
147
|
+
})
|
|
148
|
+
if (result.status !== 0) continue
|
|
149
|
+
const out = (result.stdout || "").trim().toLowerCase()
|
|
150
|
+
if (out === "true" || out === "1") return true
|
|
151
|
+
if (out === "false" || out === "0") return false
|
|
152
|
+
} catch {
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return false
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const names = (() => {
|
|
164
|
+
const avx2 = supportsAvx2()
|
|
165
|
+
const baseline = arch === "x64" && !avx2
|
|
166
|
+
|
|
167
|
+
if (platform === "linux") {
|
|
168
|
+
const musl = (() => {
|
|
169
|
+
try {
|
|
170
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
171
|
+
} catch {
|
|
172
|
+
// ignore
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
177
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
178
|
+
if (text.includes("musl")) return true
|
|
179
|
+
} catch {
|
|
180
|
+
// ignore
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return false
|
|
184
|
+
})()
|
|
185
|
+
|
|
186
|
+
if (musl) {
|
|
187
|
+
if (arch === "x64") {
|
|
188
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
189
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
190
|
+
}
|
|
191
|
+
return [`${base}-musl`, base]
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (arch === "x64") {
|
|
195
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
196
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
197
|
+
}
|
|
198
|
+
return [base, `${base}-musl`]
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (arch === "x64") {
|
|
202
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
203
|
+
return [base, `${base}-baseline`]
|
|
204
|
+
}
|
|
205
|
+
return [base]
|
|
206
|
+
})()
|
|
207
|
+
|
|
208
|
+
function findBinary(startDir) {
|
|
209
|
+
let current = startDir
|
|
210
|
+
for (;;) {
|
|
211
|
+
const modules = path.join(current, "node_modules")
|
|
212
|
+
if (fs.existsSync(modules)) {
|
|
213
|
+
for (const name of names) {
|
|
214
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
215
|
+
if (fs.existsSync(candidate)) return candidate
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const parent = path.dirname(current)
|
|
219
|
+
if (parent === current) {
|
|
220
|
+
return
|
|
221
|
+
}
|
|
222
|
+
current = parent
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
|
|
227
|
+
if (!resolved) {
|
|
228
|
+
console.error(
|
|
229
|
+
"It seems that your package manager failed to install the right version of the Kilo CLI for your platform. You can try manually installing " +
|
|
230
|
+
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
231
|
+
" package",
|
|
232
|
+
)
|
|
233
|
+
process.exit(1)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
run(resolved, resolved === cached ? findBinary(scriptDir) : undefined) // kilocode_change - preserve cached binary fallback
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ilura/northstar",
|
|
3
|
+
"bin": {
|
|
4
|
+
"northstar": "./bin/northstar",
|
|
5
|
+
"kilocode": "./bin/northstar"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"postinstall": "node ./postinstall.mjs"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cli",
|
|
14
|
+
"tui",
|
|
15
|
+
"terminal",
|
|
16
|
+
"ai",
|
|
17
|
+
"agent",
|
|
18
|
+
"assistant",
|
|
19
|
+
"coding-agent",
|
|
20
|
+
"kilo-code",
|
|
21
|
+
"kilo",
|
|
22
|
+
"opencode",
|
|
23
|
+
"ink",
|
|
24
|
+
"react",
|
|
25
|
+
"copilot",
|
|
26
|
+
"autocomplete",
|
|
27
|
+
"developer-tools"
|
|
28
|
+
],
|
|
29
|
+
"private": false,
|
|
30
|
+
"os": [
|
|
31
|
+
"darwin",
|
|
32
|
+
"linux",
|
|
33
|
+
"win32"
|
|
34
|
+
],
|
|
35
|
+
"cpu": [
|
|
36
|
+
"arm64",
|
|
37
|
+
"x64"
|
|
38
|
+
],
|
|
39
|
+
"optionalDependencies": {
|
|
40
|
+
"@ilura/northstar-linux-x64-musl": "0.1.0",
|
|
41
|
+
"@ilura/northstar-linux-arm64-musl": "0.1.0",
|
|
42
|
+
"@ilura/northstar-darwin-arm64": "0.1.0",
|
|
43
|
+
"@ilura/northstar-linux-arm64": "0.1.0",
|
|
44
|
+
"@ilura/northstar-windows-x64": "0.1.0",
|
|
45
|
+
"@ilura/northstar-darwin-x64": "0.1.0",
|
|
46
|
+
"@ilura/northstar-linux-x64": "0.1.0",
|
|
47
|
+
"@ilura/northstar-linux-x64-baseline": "0.1.0",
|
|
48
|
+
"@ilura/northstar-windows-x64-baseline": "0.1.0",
|
|
49
|
+
"@ilura/northstar-windows-arm64": "0.1.0",
|
|
50
|
+
"@ilura/northstar-darwin-x64-baseline": "0.1.0",
|
|
51
|
+
"@ilura/northstar-linux-x64-baseline-musl": "0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/mrtcnbsk/northstar"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import childProcess from "child_process"
|
|
4
|
+
import fs from "fs"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import path from "path"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
import { fileURLToPath } from "url"
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
|
+
const require = createRequire(import.meta.url)
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
|
|
13
|
+
|
|
14
|
+
// kilocode_change start - variant detection matching bin/kilo logic
|
|
15
|
+
const platformMap = {
|
|
16
|
+
darwin: "darwin",
|
|
17
|
+
linux: "linux",
|
|
18
|
+
win32: "windows",
|
|
19
|
+
}
|
|
20
|
+
const archMap = {
|
|
21
|
+
x64: "x64",
|
|
22
|
+
arm64: "arm64",
|
|
23
|
+
arm: "arm",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const platform = platformMap[os.platform()] ?? os.platform()
|
|
27
|
+
const arch = archMap[os.arch()] ?? os.arch()
|
|
28
|
+
const base = `@ilura/northstar-${platform}-${arch}`
|
|
29
|
+
const sourceBinary = platform === "windows" ? "northstar.exe" : "northstar"
|
|
30
|
+
const targetBinary = path.join(__dirname, "bin", ".kilo")
|
|
31
|
+
|
|
32
|
+
function supportsAvx2() {
|
|
33
|
+
if (arch !== "x64") return false
|
|
34
|
+
|
|
35
|
+
if (platform === "linux") {
|
|
36
|
+
try {
|
|
37
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
38
|
+
} catch {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (platform === "darwin") {
|
|
44
|
+
try {
|
|
45
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
46
|
+
encoding: "utf8",
|
|
47
|
+
timeout: 1500,
|
|
48
|
+
})
|
|
49
|
+
if (result.status !== 0) return false
|
|
50
|
+
return (result.stdout || "").trim() === "1"
|
|
51
|
+
} catch {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (platform === "windows") {
|
|
57
|
+
const command =
|
|
58
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
59
|
+
|
|
60
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
61
|
+
try {
|
|
62
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
63
|
+
encoding: "utf8",
|
|
64
|
+
timeout: 3000,
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
})
|
|
67
|
+
if (result.status !== 0) continue
|
|
68
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
69
|
+
if (output === "true" || output === "1") return true
|
|
70
|
+
if (output === "false" || output === "0") return false
|
|
71
|
+
} catch {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return false
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function isMusl() {
|
|
81
|
+
if (platform !== "linux") return false
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
85
|
+
} catch {
|
|
86
|
+
// Ignore filesystem probes that are blocked by the host.
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
91
|
+
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
92
|
+
} catch {
|
|
93
|
+
return false
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function packageNames() {
|
|
98
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
99
|
+
|
|
100
|
+
if (platform === "linux") {
|
|
101
|
+
if (isMusl()) {
|
|
102
|
+
if (arch === "x64")
|
|
103
|
+
return baseline
|
|
104
|
+
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
105
|
+
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
106
|
+
return [`${base}-musl`, base]
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (arch === "x64")
|
|
110
|
+
return baseline
|
|
111
|
+
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
112
|
+
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
113
|
+
return [base, `${base}-musl`]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
|
|
117
|
+
return [base]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function resolveBinary(name) {
|
|
121
|
+
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
122
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
|
|
123
|
+
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
|
|
124
|
+
return binaryPath
|
|
125
|
+
}
|
|
126
|
+
// kilocode_change end
|
|
127
|
+
|
|
128
|
+
// kilocode_change start - copy runtime resources next to cached binary
|
|
129
|
+
function copyResources(source) {
|
|
130
|
+
for (const [name, entry] of [
|
|
131
|
+
["tree-sitter", "tree-sitter.wasm"],
|
|
132
|
+
["console", "index.html"],
|
|
133
|
+
]) {
|
|
134
|
+
const dir = path.join(path.dirname(source), name)
|
|
135
|
+
if (!fs.existsSync(path.join(dir, entry))) continue
|
|
136
|
+
const target = path.join(__dirname, "bin", name)
|
|
137
|
+
fs.rmSync(target, { recursive: true, force: true })
|
|
138
|
+
fs.cpSync(dir, target, { recursive: true })
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const bwrap = path.join(path.dirname(source), "bwrap")
|
|
142
|
+
if (fs.existsSync(bwrap)) {
|
|
143
|
+
const target = path.join(__dirname, "bin", "bwrap")
|
|
144
|
+
fs.copyFileSync(bwrap, target)
|
|
145
|
+
fs.chmodSync(target, 0o755)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const licenses = path.join(path.dirname(source), "licenses")
|
|
149
|
+
if (fs.existsSync(licenses)) {
|
|
150
|
+
const target = path.join(__dirname, "bin", "licenses")
|
|
151
|
+
fs.rmSync(target, { recursive: true, force: true })
|
|
152
|
+
fs.cpSync(licenses, target, { recursive: true })
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const worker = path.join(path.dirname(source), "kilo-sandbox-mutation-worker.js")
|
|
156
|
+
if (fs.existsSync(worker)) fs.copyFileSync(worker, path.join(__dirname, "bin", "kilo-sandbox-mutation-worker.js"))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function copyBinary(source) {
|
|
160
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
161
|
+
fs.mkdirSync(path.dirname(targetBinary), { recursive: true })
|
|
162
|
+
if (fs.existsSync(targetBinary)) fs.unlinkSync(targetBinary)
|
|
163
|
+
try {
|
|
164
|
+
fs.linkSync(source, targetBinary)
|
|
165
|
+
} catch {
|
|
166
|
+
fs.copyFileSync(source, targetBinary)
|
|
167
|
+
}
|
|
168
|
+
copyResources(source)
|
|
169
|
+
fs.chmodSync(targetBinary, 0o755)
|
|
170
|
+
}
|
|
171
|
+
// kilocode_change end
|
|
172
|
+
|
|
173
|
+
function verifyBinary() {
|
|
174
|
+
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
175
|
+
stdio: "ignore",
|
|
176
|
+
windowsHide: true,
|
|
177
|
+
})
|
|
178
|
+
return result.status === 0
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function main() {
|
|
182
|
+
if (platform === "windows") {
|
|
183
|
+
console.log("Windows detected: binary setup not needed (using packaged wrapper)")
|
|
184
|
+
return
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
for (const name of packageNames()) {
|
|
188
|
+
try {
|
|
189
|
+
copyBinary(resolveBinary(name))
|
|
190
|
+
if (verifyBinary()) return
|
|
191
|
+
} catch {
|
|
192
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "kilo-install-"))
|
|
193
|
+
try {
|
|
194
|
+
const version = packageJson.optionalDependencies?.[name]
|
|
195
|
+
if (!version) continue
|
|
196
|
+
const result = childProcess.spawnSync(
|
|
197
|
+
"npm",
|
|
198
|
+
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
199
|
+
{ stdio: "inherit", windowsHide: true },
|
|
200
|
+
)
|
|
201
|
+
if (result.status !== 0) continue
|
|
202
|
+
copyBinary(path.join(temp, "node_modules", name, "bin", sourceBinary))
|
|
203
|
+
if (verifyBinary()) return
|
|
204
|
+
} finally {
|
|
205
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
throw new Error(
|
|
211
|
+
`It seems your package manager failed to install the right Kilo CLI package. Try manually installing ${packageNames()
|
|
212
|
+
.map((name) => JSON.stringify(name))
|
|
213
|
+
.join(" or ")}.`,
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
main()
|
|
219
|
+
} catch (error) {
|
|
220
|
+
console.error("Failed to setup kilo binary:", error.message)
|
|
221
|
+
process.exit(1)
|
|
222
|
+
}
|