@kilocode/cli 7.3.45 → 7.3.46
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/package.json +23 -14
- package/postinstall.mjs +113 -86
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"kilocode": "./bin/kilo"
|
|
6
6
|
},
|
|
7
7
|
"scripts": {
|
|
8
|
-
"postinstall": "
|
|
8
|
+
"postinstall": "node ./postinstall.mjs"
|
|
9
9
|
},
|
|
10
|
-
"version": "7.3.
|
|
10
|
+
"version": "7.3.46",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"cli",
|
|
@@ -27,19 +27,28 @@
|
|
|
27
27
|
"developer-tools"
|
|
28
28
|
],
|
|
29
29
|
"private": false,
|
|
30
|
+
"os": [
|
|
31
|
+
"darwin",
|
|
32
|
+
"linux",
|
|
33
|
+
"win32"
|
|
34
|
+
],
|
|
35
|
+
"cpu": [
|
|
36
|
+
"arm64",
|
|
37
|
+
"x64"
|
|
38
|
+
],
|
|
30
39
|
"optionalDependencies": {
|
|
31
|
-
"@kilocode/cli-linux-arm64": "7.3.
|
|
32
|
-
"@kilocode/cli-darwin-x64-baseline": "7.3.
|
|
33
|
-
"@kilocode/cli-darwin-x64": "7.3.
|
|
34
|
-
"@kilocode/cli-linux-arm64-musl": "7.3.
|
|
35
|
-
"@kilocode/cli-windows-arm64": "7.3.
|
|
36
|
-
"@kilocode/cli-linux-x64-musl": "7.3.
|
|
37
|
-
"@kilocode/cli-linux-x64-baseline": "7.3.
|
|
38
|
-
"@kilocode/cli-darwin-arm64": "7.3.
|
|
39
|
-
"@kilocode/cli-linux-x64": "7.3.
|
|
40
|
-
"@kilocode/cli-linux-x64-baseline-musl": "7.3.
|
|
41
|
-
"@kilocode/cli-windows-x64-baseline": "7.3.
|
|
42
|
-
"@kilocode/cli-windows-x64": "7.3.
|
|
40
|
+
"@kilocode/cli-linux-arm64": "7.3.46",
|
|
41
|
+
"@kilocode/cli-darwin-x64-baseline": "7.3.46",
|
|
42
|
+
"@kilocode/cli-darwin-x64": "7.3.46",
|
|
43
|
+
"@kilocode/cli-linux-arm64-musl": "7.3.46",
|
|
44
|
+
"@kilocode/cli-windows-arm64": "7.3.46",
|
|
45
|
+
"@kilocode/cli-linux-x64-musl": "7.3.46",
|
|
46
|
+
"@kilocode/cli-linux-x64-baseline": "7.3.46",
|
|
47
|
+
"@kilocode/cli-darwin-arm64": "7.3.46",
|
|
48
|
+
"@kilocode/cli-linux-x64": "7.3.46",
|
|
49
|
+
"@kilocode/cli-linux-x64-baseline-musl": "7.3.46",
|
|
50
|
+
"@kilocode/cli-windows-x64-baseline": "7.3.46",
|
|
51
|
+
"@kilocode/cli-windows-x64": "7.3.46"
|
|
43
52
|
},
|
|
44
53
|
"repository": {
|
|
45
54
|
"type": "git",
|
package/postinstall.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import childProcess from "child_process"
|
|
3
4
|
import fs from "fs"
|
|
4
|
-
import path from "path"
|
|
5
5
|
import os from "os"
|
|
6
|
-
import
|
|
7
|
-
import { fileURLToPath } from "url"
|
|
6
|
+
import path from "path"
|
|
8
7
|
import { createRequire } from "module"
|
|
8
|
+
import { fileURLToPath } from "url"
|
|
9
9
|
|
|
10
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
11
11
|
const require = createRequire(import.meta.url)
|
|
12
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
|
|
12
13
|
|
|
13
14
|
// kilocode_change start - variant detection matching bin/kilo logic
|
|
14
15
|
const platformMap = {
|
|
@@ -22,14 +23,13 @@ const archMap = {
|
|
|
22
23
|
arm: "arm",
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const platform = platformMap[os.platform()] ?? os.platform()
|
|
27
|
+
const arch = archMap[os.arch()] ?? os.arch()
|
|
28
|
+
const base = `@kilocode/cli-${platform}-${arch}`
|
|
29
|
+
const sourceBinary = platform === "windows" ? "kilo.exe" : "kilo"
|
|
30
|
+
const targetBinary = path.join(__dirname, "bin", ".kilo")
|
|
30
31
|
|
|
31
32
|
function supportsAvx2() {
|
|
32
|
-
const { platform, arch } = detectPlatformAndArch()
|
|
33
33
|
if (arch !== "x64") return false
|
|
34
34
|
|
|
35
35
|
if (platform === "linux") {
|
|
@@ -53,125 +53,152 @@ function supportsAvx2() {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
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
|
+
|
|
56
77
|
return false
|
|
57
78
|
}
|
|
58
79
|
|
|
59
80
|
function isMusl() {
|
|
81
|
+
if (platform !== "linux") return false
|
|
82
|
+
|
|
60
83
|
try {
|
|
61
84
|
if (fs.existsSync("/etc/alpine-release")) return true
|
|
62
85
|
} catch {
|
|
63
|
-
//
|
|
86
|
+
// Ignore filesystem probes that are blocked by the host.
|
|
64
87
|
}
|
|
65
88
|
|
|
66
89
|
try {
|
|
67
90
|
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
68
|
-
|
|
69
|
-
if (text.includes("musl")) return true
|
|
91
|
+
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
70
92
|
} catch {
|
|
71
|
-
|
|
93
|
+
return false
|
|
72
94
|
}
|
|
73
|
-
|
|
74
|
-
return false
|
|
75
95
|
}
|
|
76
96
|
|
|
77
|
-
function
|
|
78
|
-
const
|
|
79
|
-
const base = `@kilocode/cli-${platform}-${arch}`
|
|
80
|
-
const avx2 = supportsAvx2()
|
|
81
|
-
const baseline = arch === "x64" && !avx2
|
|
97
|
+
function packageNames() {
|
|
98
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
82
99
|
|
|
83
100
|
if (platform === "linux") {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
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`]
|
|
90
106
|
return [`${base}-musl`, base]
|
|
91
107
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
|
|
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`]
|
|
96
113
|
return [base, `${base}-musl`]
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
if (arch === "x64") {
|
|
100
|
-
if (baseline) return [`${base}-baseline`, base]
|
|
101
|
-
return [base, `${base}-baseline`]
|
|
102
|
-
}
|
|
116
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
|
|
103
117
|
return [base]
|
|
104
118
|
}
|
|
105
119
|
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
for (const packageName of names) {
|
|
112
|
-
try {
|
|
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
|
-
}
|
|
120
|
-
} catch {
|
|
121
|
-
// package not installed, try next variant
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
throw new Error(`Could not find any binary package. Tried: ${names.map((n) => `"${n}"`).join(", ")}`)
|
|
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
|
|
126
125
|
}
|
|
127
126
|
// kilocode_change end
|
|
128
127
|
|
|
129
128
|
// kilocode_change start - copy runtime resources next to cached binary
|
|
130
|
-
function
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
+
}
|
|
139
140
|
}
|
|
140
141
|
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
142
|
+
function copyBinary(source) {
|
|
143
|
+
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
|
|
144
|
+
fs.mkdirSync(path.dirname(targetBinary), { recursive: true })
|
|
145
|
+
if (fs.existsSync(targetBinary)) fs.unlinkSync(targetBinary)
|
|
146
|
+
try {
|
|
147
|
+
fs.linkSync(source, targetBinary)
|
|
148
|
+
} catch {
|
|
149
|
+
fs.copyFileSync(source, targetBinary)
|
|
150
|
+
}
|
|
151
|
+
copyResources(source)
|
|
152
|
+
fs.chmodSync(targetBinary, 0o755)
|
|
150
153
|
}
|
|
151
154
|
// kilocode_change end
|
|
152
155
|
|
|
156
|
+
function verifyBinary() {
|
|
157
|
+
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
158
|
+
stdio: "ignore",
|
|
159
|
+
windowsHide: true,
|
|
160
|
+
})
|
|
161
|
+
return result.status === 0
|
|
162
|
+
}
|
|
163
|
+
|
|
153
164
|
function main() {
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
165
|
+
if (platform === "windows") {
|
|
166
|
+
console.log("Windows detected: binary setup not needed (using packaged wrapper)")
|
|
157
167
|
return
|
|
158
168
|
}
|
|
159
169
|
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
for (const name of packageNames()) {
|
|
171
|
+
try {
|
|
172
|
+
copyBinary(resolveBinary(name))
|
|
173
|
+
if (verifyBinary()) return
|
|
174
|
+
} catch {
|
|
175
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "kilo-install-"))
|
|
176
|
+
try {
|
|
177
|
+
const version = packageJson.optionalDependencies?.[name]
|
|
178
|
+
if (!version) continue
|
|
179
|
+
const result = childProcess.spawnSync(
|
|
180
|
+
"npm",
|
|
181
|
+
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
182
|
+
{ stdio: "inherit", windowsHide: true },
|
|
183
|
+
)
|
|
184
|
+
if (result.status !== 0) continue
|
|
185
|
+
copyBinary(path.join(temp, "node_modules", name, "bin", sourceBinary))
|
|
186
|
+
if (verifyBinary()) return
|
|
187
|
+
} finally {
|
|
188
|
+
fs.rmSync(temp, { recursive: true, force: true })
|
|
189
|
+
}
|
|
190
|
+
}
|
|
167
191
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
192
|
+
|
|
193
|
+
throw new Error(
|
|
194
|
+
`It seems your package manager failed to install the right Kilo CLI package. Try manually installing ${packageNames()
|
|
195
|
+
.map((name) => JSON.stringify(name))
|
|
196
|
+
.join(" or ")}.`,
|
|
197
|
+
)
|
|
171
198
|
}
|
|
172
199
|
|
|
173
200
|
try {
|
|
174
|
-
|
|
201
|
+
main()
|
|
175
202
|
} catch (error) {
|
|
176
203
|
console.error("Failed to setup kilo binary:", error.message)
|
|
177
204
|
process.exit(1)
|