@kilocode/cli 7.3.21 → 7.3.28
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/kilo +63 -27
- package/package.json +13 -13
- package/postinstall.mjs +13 -1
package/bin/kilo
CHANGED
|
@@ -5,6 +5,8 @@ const fs = require("fs")
|
|
|
5
5
|
const path = require("path")
|
|
6
6
|
const os = require("os")
|
|
7
7
|
|
|
8
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
|
9
|
+
|
|
8
10
|
// kilocode_change start - point packaged binaries at co-located tree-sitter WASM resources
|
|
9
11
|
function configureTreeSitterResources(target) {
|
|
10
12
|
const wasmDir = path.join(path.dirname(target), "tree-sitter")
|
|
@@ -14,42 +16,76 @@ function configureTreeSitterResources(target) {
|
|
|
14
16
|
}
|
|
15
17
|
// kilocode_change end
|
|
16
18
|
|
|
17
|
-
function run(target) {
|
|
19
|
+
function run(target, fallback) {
|
|
20
|
+
// kilocode_change - preserve cached binary fallback
|
|
18
21
|
configureTreeSitterResources(target) // kilocode_change
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// kilocode_change start - fall through if the cached binary cannot be spawned
|
|
23
|
+
const child = (() => {
|
|
24
|
+
try {
|
|
25
|
+
return childProcess.spawn(target, process.argv.slice(2), {
|
|
26
|
+
stdio: "inherit",
|
|
27
|
+
})
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (fallback) {
|
|
30
|
+
run(fallback)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
console.error(error.message)
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
})()
|
|
37
|
+
if (!child) return
|
|
38
|
+
// kilocode_change end
|
|
39
|
+
|
|
40
|
+
const forwarders = {}
|
|
41
|
+
const clear = () => {
|
|
42
|
+
// kilocode_change - remove listeners before cached binary fallback
|
|
43
|
+
for (const signal of forwardedSignals) {
|
|
44
|
+
process.removeListener(signal, forwarders[signal])
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
child.on("error", (error) => {
|
|
49
|
+
clear() // kilocode_change
|
|
50
|
+
// kilocode_change start - fall through to findBinary() if cached binary fails
|
|
51
|
+
if (fallback) {
|
|
52
|
+
run(fallback)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
// kilocode_change end
|
|
56
|
+
console.error(error.message)
|
|
24
57
|
process.exit(1)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
for (const signal of forwardedSignals) {
|
|
61
|
+
forwarders[signal] = () => {
|
|
62
|
+
try {
|
|
63
|
+
child.kill(signal)
|
|
64
|
+
} catch {
|
|
65
|
+
// The child may have already exited.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
process.on(signal, forwarders[signal])
|
|
25
69
|
}
|
|
26
|
-
|
|
27
|
-
|
|
70
|
+
|
|
71
|
+
child.on("exit", (code, signal) => {
|
|
72
|
+
clear() // kilocode_change
|
|
73
|
+
|
|
74
|
+
if (signal) {
|
|
75
|
+
process.kill(process.pid, signal)
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
process.exit(typeof code === "number" ? code : 0)
|
|
80
|
+
})
|
|
28
81
|
}
|
|
29
82
|
|
|
30
83
|
const envPath = process.env.KILO_BIN_PATH
|
|
31
|
-
if (envPath) {
|
|
32
|
-
run(envPath)
|
|
33
|
-
}
|
|
34
84
|
|
|
35
85
|
const scriptPath = fs.realpathSync(__filename)
|
|
36
86
|
const scriptDir = path.dirname(scriptPath)
|
|
37
87
|
|
|
38
|
-
// kilocode_change start - fall through to findBinary() if cached binary fails
|
|
39
88
|
const cached = path.join(scriptDir, ".kilo")
|
|
40
|
-
if (fs.existsSync(cached)) {
|
|
41
|
-
configureTreeSitterResources(cached)
|
|
42
|
-
const result = childProcess.spawnSync(cached, process.argv.slice(2), {
|
|
43
|
-
stdio: "inherit",
|
|
44
|
-
})
|
|
45
|
-
if (!result.error) {
|
|
46
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
47
|
-
process.exit(code)
|
|
48
|
-
}
|
|
49
|
-
// cached binary failed (e.g. wrong platform/arch, missing dynamic linker),
|
|
50
|
-
// fall through to findBinary() which has better variant detection
|
|
51
|
-
}
|
|
52
|
-
// kilocode_change end
|
|
53
89
|
|
|
54
90
|
const platformMap = {
|
|
55
91
|
darwin: "darwin",
|
|
@@ -186,7 +222,7 @@ function findBinary(startDir) {
|
|
|
186
222
|
}
|
|
187
223
|
}
|
|
188
224
|
|
|
189
|
-
const resolved = findBinary(scriptDir)
|
|
225
|
+
const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
|
|
190
226
|
if (!resolved) {
|
|
191
227
|
console.error(
|
|
192
228
|
"It seems that your package manager failed to install the right version of the Kilo CLI for your platform. You can try manually installing " +
|
|
@@ -196,4 +232,4 @@ if (!resolved) {
|
|
|
196
232
|
process.exit(1)
|
|
197
233
|
}
|
|
198
234
|
|
|
199
|
-
run(resolved)
|
|
235
|
+
run(resolved, resolved === cached ? findBinary(scriptDir) : undefined) // kilocode_change - preserve cached binary fallback
|
package/package.json
CHANGED
|
@@ -7,21 +7,21 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
9
9
|
},
|
|
10
|
-
"version": "7.3.
|
|
10
|
+
"version": "7.3.28",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"optionalDependencies": {
|
|
13
|
-
"@kilocode/cli-linux-arm64-musl": "7.3.
|
|
14
|
-
"@kilocode/cli-darwin-x64-baseline": "7.3.
|
|
15
|
-
"@kilocode/cli-windows-arm64": "7.3.
|
|
16
|
-
"@kilocode/cli-linux-arm64": "7.3.
|
|
17
|
-
"@kilocode/cli-linux-x64": "7.3.
|
|
18
|
-
"@kilocode/cli-darwin-arm64": "7.3.
|
|
19
|
-
"@kilocode/cli-windows-x64": "7.3.
|
|
20
|
-
"@kilocode/cli-linux-x64-musl": "7.3.
|
|
21
|
-
"@kilocode/cli-windows-x64-baseline": "7.3.
|
|
22
|
-
"@kilocode/cli-darwin-x64": "7.3.
|
|
23
|
-
"@kilocode/cli-linux-x64-baseline-musl": "7.3.
|
|
24
|
-
"@kilocode/cli-linux-x64-baseline": "7.3.
|
|
13
|
+
"@kilocode/cli-linux-arm64-musl": "7.3.28",
|
|
14
|
+
"@kilocode/cli-darwin-x64-baseline": "7.3.28",
|
|
15
|
+
"@kilocode/cli-windows-arm64": "7.3.28",
|
|
16
|
+
"@kilocode/cli-linux-arm64": "7.3.28",
|
|
17
|
+
"@kilocode/cli-linux-x64": "7.3.28",
|
|
18
|
+
"@kilocode/cli-darwin-arm64": "7.3.28",
|
|
19
|
+
"@kilocode/cli-windows-x64": "7.3.28",
|
|
20
|
+
"@kilocode/cli-linux-x64-musl": "7.3.28",
|
|
21
|
+
"@kilocode/cli-windows-x64-baseline": "7.3.28",
|
|
22
|
+
"@kilocode/cli-darwin-x64": "7.3.28",
|
|
23
|
+
"@kilocode/cli-linux-x64-baseline-musl": "7.3.28",
|
|
24
|
+
"@kilocode/cli-linux-x64-baseline": "7.3.28"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
package/postinstall.mjs
CHANGED
|
@@ -126,7 +126,7 @@ function findBinary() {
|
|
|
126
126
|
}
|
|
127
127
|
// kilocode_change end
|
|
128
128
|
|
|
129
|
-
// kilocode_change start - copy
|
|
129
|
+
// kilocode_change start - copy runtime resources next to cached binary
|
|
130
130
|
function copyTreeSitterResources(binaryPath) {
|
|
131
131
|
const source = path.join(path.dirname(binaryPath), "tree-sitter")
|
|
132
132
|
const target = path.join(__dirname, "bin", "tree-sitter")
|
|
@@ -137,6 +137,17 @@ function copyTreeSitterResources(binaryPath) {
|
|
|
137
137
|
fs.rmSync(target, { recursive: true, force: true })
|
|
138
138
|
fs.cpSync(source, target, { recursive: true })
|
|
139
139
|
}
|
|
140
|
+
|
|
141
|
+
function copyConsoleResources(binaryPath) {
|
|
142
|
+
const source = path.join(path.dirname(binaryPath), "console")
|
|
143
|
+
const target = path.join(__dirname, "bin", "console")
|
|
144
|
+
const index = path.join(source, "index.html")
|
|
145
|
+
|
|
146
|
+
if (!fs.existsSync(index)) return
|
|
147
|
+
|
|
148
|
+
fs.rmSync(target, { recursive: true, force: true })
|
|
149
|
+
fs.cpSync(source, target, { recursive: true })
|
|
150
|
+
}
|
|
140
151
|
// kilocode_change end
|
|
141
152
|
|
|
142
153
|
function main() {
|
|
@@ -155,6 +166,7 @@ function main() {
|
|
|
155
166
|
fs.copyFileSync(binaryPath, target)
|
|
156
167
|
}
|
|
157
168
|
copyTreeSitterResources(binaryPath) // kilocode_change
|
|
169
|
+
copyConsoleResources(binaryPath) // kilocode_change
|
|
158
170
|
fs.chmodSync(target, 0o755)
|
|
159
171
|
}
|
|
160
172
|
|