@kilocode/cli 7.0.32 → 7.0.33
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 +12 -6
- package/package.json +12 -12
- package/postinstall.mjs +109 -88
package/bin/kilo
CHANGED
|
@@ -25,11 +25,20 @@ if (envPath) {
|
|
|
25
25
|
const scriptPath = fs.realpathSync(__filename)
|
|
26
26
|
const scriptDir = path.dirname(scriptPath)
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// kilocode_change start - fall through to findBinary() if cached binary fails
|
|
29
29
|
const cached = path.join(scriptDir, ".kilo")
|
|
30
30
|
if (fs.existsSync(cached)) {
|
|
31
|
-
|
|
31
|
+
const result = childProcess.spawnSync(cached, process.argv.slice(2), {
|
|
32
|
+
stdio: "inherit",
|
|
33
|
+
})
|
|
34
|
+
if (!result.error) {
|
|
35
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
36
|
+
process.exit(code)
|
|
37
|
+
}
|
|
38
|
+
// cached binary failed (e.g. wrong platform/arch, missing dynamic linker),
|
|
39
|
+
// fall through to findBinary() which has better variant detection
|
|
32
40
|
}
|
|
41
|
+
// kilocode_change end
|
|
33
42
|
|
|
34
43
|
const platformMap = {
|
|
35
44
|
darwin: "darwin",
|
|
@@ -166,9 +175,6 @@ function findBinary(startDir) {
|
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
|
|
169
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
170
|
-
const scriptDir = path.dirname(scriptPath)
|
|
171
|
-
|
|
172
178
|
const resolved = findBinary(scriptDir)
|
|
173
179
|
if (!resolved) {
|
|
174
180
|
console.error(
|
|
@@ -179,4 +185,4 @@ if (!resolved) {
|
|
|
179
185
|
process.exit(1)
|
|
180
186
|
}
|
|
181
187
|
|
|
182
|
-
run(resolved)
|
|
188
|
+
run(resolved)
|
package/package.json
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
9
9
|
},
|
|
10
|
-
"version": "7.0.
|
|
10
|
+
"version": "7.0.33",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"optionalDependencies": {
|
|
13
|
-
"@kilocode/cli-linux-arm64": "7.0.
|
|
14
|
-
"@kilocode/cli-linux-x64-musl": "7.0.
|
|
15
|
-
"@kilocode/cli-darwin-arm64": "7.0.
|
|
16
|
-
"@kilocode/cli-linux-arm64-musl": "7.0.
|
|
17
|
-
"@kilocode/cli-windows-x64": "7.0.
|
|
18
|
-
"@kilocode/cli-linux-x64-baseline-musl": "7.0.
|
|
19
|
-
"@kilocode/cli-linux-x64": "7.0.
|
|
20
|
-
"@kilocode/cli-darwin-x64-baseline": "7.0.
|
|
21
|
-
"@kilocode/cli-darwin-x64": "7.0.
|
|
22
|
-
"@kilocode/cli-windows-x64-baseline": "7.0.
|
|
23
|
-
"@kilocode/cli-linux-x64-baseline": "7.0.
|
|
13
|
+
"@kilocode/cli-linux-arm64": "7.0.33",
|
|
14
|
+
"@kilocode/cli-linux-x64-musl": "7.0.33",
|
|
15
|
+
"@kilocode/cli-darwin-arm64": "7.0.33",
|
|
16
|
+
"@kilocode/cli-linux-arm64-musl": "7.0.33",
|
|
17
|
+
"@kilocode/cli-windows-x64": "7.0.33",
|
|
18
|
+
"@kilocode/cli-linux-x64-baseline-musl": "7.0.33",
|
|
19
|
+
"@kilocode/cli-linux-x64": "7.0.33",
|
|
20
|
+
"@kilocode/cli-darwin-x64-baseline": "7.0.33",
|
|
21
|
+
"@kilocode/cli-darwin-x64": "7.0.33",
|
|
22
|
+
"@kilocode/cli-windows-x64-baseline": "7.0.33",
|
|
23
|
+
"@kilocode/cli-linux-x64-baseline": "7.0.33"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
package/postinstall.mjs
CHANGED
|
@@ -3,129 +3,150 @@
|
|
|
3
3
|
import fs from "fs"
|
|
4
4
|
import path from "path"
|
|
5
5
|
import os from "os"
|
|
6
|
+
import childProcess from "child_process"
|
|
6
7
|
import { fileURLToPath } from "url"
|
|
7
8
|
import { createRequire } from "module"
|
|
8
9
|
|
|
9
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
11
|
const require = createRequire(import.meta.url)
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
platform = "windows"
|
|
24
|
-
break
|
|
25
|
-
default:
|
|
26
|
-
platform = os.platform()
|
|
27
|
-
break
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Map architecture names
|
|
31
|
-
let arch
|
|
32
|
-
switch (os.arch()) {
|
|
33
|
-
case "x64":
|
|
34
|
-
arch = "x64"
|
|
35
|
-
break
|
|
36
|
-
case "arm64":
|
|
37
|
-
arch = "arm64"
|
|
38
|
-
break
|
|
39
|
-
case "arm":
|
|
40
|
-
arch = "arm"
|
|
41
|
-
break
|
|
42
|
-
default:
|
|
43
|
-
arch = os.arch()
|
|
44
|
-
break
|
|
45
|
-
}
|
|
13
|
+
// kilocode_change start - variant detection matching bin/kilo logic
|
|
14
|
+
const platformMap = {
|
|
15
|
+
darwin: "darwin",
|
|
16
|
+
linux: "linux",
|
|
17
|
+
win32: "windows",
|
|
18
|
+
}
|
|
19
|
+
const archMap = {
|
|
20
|
+
x64: "x64",
|
|
21
|
+
arm64: "arm64",
|
|
22
|
+
arm: "arm",
|
|
23
|
+
}
|
|
46
24
|
|
|
25
|
+
function detectPlatformAndArch() {
|
|
26
|
+
const platform = platformMap[os.platform()] || os.platform()
|
|
27
|
+
const arch = archMap[os.arch()] || os.arch()
|
|
47
28
|
return { platform, arch }
|
|
48
29
|
}
|
|
49
30
|
|
|
50
|
-
function
|
|
31
|
+
function supportsAvx2() {
|
|
51
32
|
const { platform, arch } = detectPlatformAndArch()
|
|
52
|
-
|
|
53
|
-
const binaryName = platform === "windows" ? "kilo.exe" : "kilo"
|
|
33
|
+
if (arch !== "x64") return false
|
|
54
34
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!fs.existsSync(binaryPath)) {
|
|
62
|
-
throw new Error(`Binary not found at ${binaryPath}`)
|
|
35
|
+
if (platform === "linux") {
|
|
36
|
+
try {
|
|
37
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
38
|
+
} catch {
|
|
39
|
+
return false
|
|
63
40
|
}
|
|
41
|
+
}
|
|
64
42
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
}
|
|
68
54
|
}
|
|
69
|
-
}
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const targetPath = path.join(binDir, binaryName)
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
fs.
|
|
59
|
+
function isMusl() {
|
|
60
|
+
try {
|
|
61
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
62
|
+
} catch {
|
|
63
|
+
// ignore
|
|
78
64
|
}
|
|
79
65
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
66
|
+
try {
|
|
67
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
68
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
69
|
+
if (text.includes("musl")) return true
|
|
70
|
+
} catch {
|
|
71
|
+
// ignore
|
|
83
72
|
}
|
|
84
73
|
|
|
85
|
-
return
|
|
74
|
+
return false
|
|
86
75
|
}
|
|
87
76
|
|
|
88
|
-
function
|
|
89
|
-
const {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
function getPackageNames() {
|
|
78
|
+
const { platform, arch } = detectPlatformAndArch()
|
|
79
|
+
const base = `@kilocode/cli-${platform}-${arch}`
|
|
80
|
+
const avx2 = supportsAvx2()
|
|
81
|
+
const baseline = arch === "x64" && !avx2
|
|
82
|
+
|
|
83
|
+
if (platform === "linux") {
|
|
84
|
+
const musl = isMusl()
|
|
85
|
+
if (musl) {
|
|
86
|
+
if (arch === "x64") {
|
|
87
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
88
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
89
|
+
}
|
|
90
|
+
return [`${base}-musl`, base]
|
|
91
|
+
}
|
|
92
|
+
if (arch === "x64") {
|
|
93
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
94
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
95
|
+
}
|
|
96
|
+
return [base, `${base}-musl`]
|
|
97
|
+
}
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
if (arch === "x64") {
|
|
100
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
101
|
+
return [base, `${base}-baseline`]
|
|
97
102
|
}
|
|
103
|
+
return [base]
|
|
98
104
|
}
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// No postinstall setup needed
|
|
105
|
-
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
106
|
-
return
|
|
107
|
-
}
|
|
106
|
+
function findBinary() {
|
|
107
|
+
const { platform } = detectPlatformAndArch()
|
|
108
|
+
const binaryName = platform === "windows" ? "kilo.exe" : "kilo"
|
|
109
|
+
const names = getPackageNames()
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
// Don't replace the wrapper script - it handles binary execution
|
|
111
|
-
const { binaryPath } = findBinary()
|
|
112
|
-
const target = path.join(__dirname, "bin", ".kilo") // kilocode_change
|
|
113
|
-
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
111
|
+
for (const packageName of names) {
|
|
114
112
|
try {
|
|
115
|
-
|
|
113
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
114
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
115
|
+
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
116
|
+
|
|
117
|
+
if (fs.existsSync(binaryPath)) {
|
|
118
|
+
return { binaryPath, binaryName }
|
|
119
|
+
}
|
|
116
120
|
} catch {
|
|
117
|
-
|
|
121
|
+
// package not installed, try next variant
|
|
118
122
|
}
|
|
119
|
-
fs.chmodSync(target, 0o755)
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.error("Failed to setup kilo binary:", error.message)
|
|
122
|
-
process.exit(1)
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
throw new Error(`Could not find any binary package. Tried: ${names.map((n) => `"${n}"`).join(", ")}`)
|
|
126
|
+
}
|
|
127
|
+
// kilocode_change end
|
|
128
|
+
|
|
129
|
+
function main() {
|
|
130
|
+
if (os.platform() === "win32") {
|
|
131
|
+
// On Windows, the .exe is already included in the package and bin field points to it
|
|
132
|
+
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
133
|
+
return
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { binaryPath } = findBinary()
|
|
137
|
+
const target = path.join(__dirname, "bin", ".kilo") // kilocode_change
|
|
138
|
+
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
139
|
+
try {
|
|
140
|
+
fs.linkSync(binaryPath, target)
|
|
141
|
+
} catch {
|
|
142
|
+
fs.copyFileSync(binaryPath, target)
|
|
143
|
+
}
|
|
144
|
+
fs.chmodSync(target, 0o755)
|
|
124
145
|
}
|
|
125
146
|
|
|
126
147
|
try {
|
|
127
148
|
main()
|
|
128
149
|
} catch (error) {
|
|
129
|
-
console.error("
|
|
130
|
-
process.exit(
|
|
150
|
+
console.error("Failed to setup kilo binary:", error.message)
|
|
151
|
+
process.exit(1)
|
|
131
152
|
}
|