@kilocode/cli 7.3.20 → 7.3.22

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.
Files changed (2) hide show
  1. package/bin/kilo +63 -27
  2. package/package.json +13 -13
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
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
20
- stdio: "inherit",
21
- })
22
- if (result.error) {
23
- console.error(result.error.message)
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
- const code = typeof result.status === "number" ? result.status : 0
27
- process.exit(code)
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.20",
10
+ "version": "7.3.22",
11
11
  "license": "MIT",
12
12
  "optionalDependencies": {
13
- "@kilocode/cli-linux-arm64-musl": "7.3.20",
14
- "@kilocode/cli-darwin-x64-baseline": "7.3.20",
15
- "@kilocode/cli-windows-arm64": "7.3.20",
16
- "@kilocode/cli-linux-arm64": "7.3.20",
17
- "@kilocode/cli-linux-x64": "7.3.20",
18
- "@kilocode/cli-darwin-arm64": "7.3.20",
19
- "@kilocode/cli-windows-x64": "7.3.20",
20
- "@kilocode/cli-linux-x64-musl": "7.3.20",
21
- "@kilocode/cli-windows-x64-baseline": "7.3.20",
22
- "@kilocode/cli-darwin-x64": "7.3.20",
23
- "@kilocode/cli-linux-x64-baseline-musl": "7.3.20",
24
- "@kilocode/cli-linux-x64-baseline": "7.3.20"
13
+ "@kilocode/cli-linux-arm64-musl": "7.3.22",
14
+ "@kilocode/cli-darwin-x64-baseline": "7.3.22",
15
+ "@kilocode/cli-windows-arm64": "7.3.22",
16
+ "@kilocode/cli-linux-arm64": "7.3.22",
17
+ "@kilocode/cli-linux-x64": "7.3.22",
18
+ "@kilocode/cli-darwin-arm64": "7.3.22",
19
+ "@kilocode/cli-windows-x64": "7.3.22",
20
+ "@kilocode/cli-linux-x64-musl": "7.3.22",
21
+ "@kilocode/cli-windows-x64-baseline": "7.3.22",
22
+ "@kilocode/cli-darwin-x64": "7.3.22",
23
+ "@kilocode/cli-linux-x64-baseline-musl": "7.3.22",
24
+ "@kilocode/cli-linux-x64-baseline": "7.3.22"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",