@fabriccode/cli 7.0.116 → 7.0.118

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/README.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
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
4
 
5
+ ![Kilo CLI showing code edits in a terminal](https://raw.githubusercontent.com/Kilo-Org/kilocode/main/packages/kilo-docs/public/img/npm-package-readme/kilo-cli.png)
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
+
5
13
  ## Install
6
14
 
7
15
  ```bash
package/bin/fabriccode 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
  // fabriccode_change start
9
11
  function code(signal) {
10
12
  const num = os.constants.signals?.[signal]
@@ -12,38 +14,106 @@ function code(signal) {
12
14
  return 1
13
15
  }
14
16
 
15
- function fail(target, result) {
16
- if (result.signal === "SIGSEGV" && target.includes("cli-linux-x64-baseline")) {
17
+ function reportCrash(target, signal) {
18
+ if (signal === "SIGSEGV" && target.includes("cli-linux-x64-baseline")) {
17
19
  console.error("Fabric's Linux x64 baseline binary crashed inside Bun on a non-AVX CPU.")
18
20
  console.error("This host is not currently supported by the npm-distributed baseline build.")
19
21
  console.error("Use a machine with AVX support for now, or build and run Fabric from source on a supported host.")
20
22
  }
21
- if (result.signal) {
22
- console.error(`Fabric binary crashed with ${result.signal}: ${target}`)
23
- process.exit(code(result.signal))
23
+ console.error(`Fabric binary crashed with ${signal}: ${target}`)
24
+ }
25
+ // fabriccode_change end
26
+
27
+ // fabriccode_change start - point packaged binaries at co-located tree-sitter WASM resources
28
+ function configureTreeSitterResources(target) {
29
+ const wasmDir = path.join(path.dirname(target), "tree-sitter")
30
+ if (!process.env.FABRIC_TREE_SITTER_WASM_DIR && fs.existsSync(path.join(wasmDir, "tree-sitter.wasm"))) {
31
+ process.env.FABRIC_TREE_SITTER_WASM_DIR = wasmDir
24
32
  }
25
- const status = typeof result.status === "number" ? result.status : 1
26
- process.exit(status)
27
33
  }
34
+ // fabriccode_change end
28
35
 
29
- function run(target) {
30
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
31
- stdio: "inherit",
32
- })
33
- if (result.error) {
34
- console.error(result.error.message)
36
+ function run(target, fallback) {
37
+ // fabriccode_change - preserve cached binary fallback
38
+ configureTreeSitterResources(target) // fabriccode_change
39
+ // fabriccode_change start - fall through if the cached binary cannot be spawned
40
+ const child = (() => {
41
+ try {
42
+ return childProcess.spawn(target, process.argv.slice(2), {
43
+ stdio: "inherit",
44
+ })
45
+ } catch (error) {
46
+ if (fallback) {
47
+ run(fallback)
48
+ return
49
+ }
50
+ console.error(error.message)
51
+ process.exit(1)
52
+ }
53
+ })()
54
+ if (!child) return
55
+ // fabriccode_change end
56
+
57
+ const forwarders = {}
58
+ const clear = () => {
59
+ // fabriccode_change - remove listeners before cached binary fallback
60
+ for (const signal of forwardedSignals) {
61
+ process.removeListener(signal, forwarders[signal])
62
+ }
63
+ }
64
+
65
+ child.on("error", (error) => {
66
+ clear() // fabriccode_change
67
+ // fabriccode_change start - fall through to findBinary() if cached binary fails
68
+ if (fallback) {
69
+ run(fallback)
70
+ return
71
+ }
72
+ // fabriccode_change end
73
+ console.error(error.message)
35
74
  process.exit(1)
75
+ })
76
+
77
+ for (const signal of forwardedSignals) {
78
+ forwarders[signal] = () => {
79
+ try {
80
+ child.kill(signal)
81
+ } catch {
82
+ // The child may have already exited.
83
+ }
84
+ }
85
+ process.on(signal, forwarders[signal])
36
86
  }
37
- if (result.signal) fail(target, result)
38
- const status = typeof result.status === "number" ? result.status : 1
39
- process.exit(status)
40
- }
41
87
 
42
- const envPath = process.env.FABRIC_BIN_PATH
43
- if (envPath) {
44
- run(envPath)
88
+ child.on("exit", (exitCode, signal) => {
89
+ clear() // fabriccode_change
90
+
91
+ if (signal) {
92
+ // fabriccode_change start - SIGILL on a non-baseline x64 binary: retry the baseline build
93
+ if (signal === "SIGILL") {
94
+ const baseline = findFallback(scriptDir, target)
95
+ if (baseline) {
96
+ console.error(`Fabric binary crashed with SIGILL, retrying baseline build: ${baseline}`)
97
+ run(baseline)
98
+ return
99
+ }
100
+ }
101
+ reportCrash(target, signal)
102
+ process.exit(code(signal))
103
+ // fabriccode_change end
104
+ }
105
+
106
+ process.exit(typeof exitCode === "number" ? exitCode : 0)
107
+ })
45
108
  }
46
109
 
110
+ const envPath = process.env.FABRIC_BIN_PATH // fabriccode_change
111
+
112
+ const scriptPath = fs.realpathSync(__filename)
113
+ const scriptDir = path.dirname(scriptPath)
114
+
115
+ const cached = path.join(scriptDir, ".fabriccode") // fabriccode_change
116
+
47
117
  const platformMap = {
48
118
  darwin: "darwin",
49
119
  linux: "linux",
@@ -199,10 +269,7 @@ function findFallback(startDir, target) {
199
269
  }
200
270
  // fabriccode_change end
201
271
 
202
- const scriptPath = fs.realpathSync(__filename)
203
- const scriptDir = path.dirname(scriptPath)
204
-
205
- const resolved = findBinary(scriptDir)
272
+ const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
206
273
  if (!resolved) {
207
274
  console.error(
208
275
  "It seems that your package manager failed to install the right version of Fabric Code for your platform. You can try manually installing " +
@@ -212,22 +279,4 @@ if (!resolved) {
212
279
  process.exit(1)
213
280
  }
214
281
 
215
- const result = childProcess.spawnSync(resolved, process.argv.slice(2), {
216
- stdio: "inherit",
217
- })
218
- if (result.error) {
219
- console.error(result.error.message)
220
- process.exit(1)
221
- }
222
- // fabriccode_change start
223
- if (result.signal === "SIGILL") {
224
- const fallback = findFallback(scriptDir, resolved)
225
- if (fallback) {
226
- console.error(`Fabric binary crashed with SIGILL, retrying baseline build: ${fallback}`)
227
- run(fallback)
228
- }
229
- }
230
- // fabriccode_change end
231
- if (result.signal) fail(resolved, result)
232
- const status = typeof result.status === "number" ? result.status : 1
233
- process.exit(status)
282
+ run(resolved, resolved === cached ? findBinary(scriptDir) : undefined) // fabriccode_change - preserve cached binary fallback
package/package.json CHANGED
@@ -6,21 +6,39 @@
6
6
  "scripts": {
7
7
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
8
  },
9
- "version": "7.0.116",
9
+ "version": "7.0.118",
10
10
  "license": "MIT",
11
+ "keywords": [
12
+ "cli",
13
+ "tui",
14
+ "terminal",
15
+ "ai",
16
+ "agent",
17
+ "assistant",
18
+ "coding-agent",
19
+ "kilo-code",
20
+ "kilo",
21
+ "opencode",
22
+ "ink",
23
+ "react",
24
+ "copilot",
25
+ "autocomplete",
26
+ "developer-tools"
27
+ ],
28
+ "private": false,
11
29
  "optionalDependencies": {
12
- "@fabriccode/cli-linux-x64-baseline-musl": "7.0.116",
13
- "@fabriccode/cli-linux-x64-musl": "7.0.116",
14
- "@fabriccode/cli-darwin-x64-baseline": "7.0.116",
15
- "@fabriccode/cli-darwin-x64": "7.0.116",
16
- "@fabriccode/cli-linux-arm64": "7.0.116",
17
- "@fabriccode/cli-linux-x64": "7.0.116",
18
- "@fabriccode/cli-windows-x64-baseline": "7.0.116",
19
- "@fabriccode/cli-linux-arm64-musl": "7.0.116",
20
- "@fabriccode/cli-windows-arm64": "7.0.116",
21
- "@fabriccode/cli-windows-x64": "7.0.116",
22
- "@fabriccode/cli-linux-x64-baseline": "7.0.116",
23
- "@fabriccode/cli-darwin-arm64": "7.0.116"
30
+ "@fabriccode/cli-linux-arm64-musl": "7.0.118",
31
+ "@fabriccode/cli-darwin-x64-baseline": "7.0.118",
32
+ "@fabriccode/cli-windows-arm64": "7.0.118",
33
+ "@fabriccode/cli-linux-arm64": "7.0.118",
34
+ "@fabriccode/cli-linux-x64": "7.0.118",
35
+ "@fabriccode/cli-darwin-arm64": "7.0.118",
36
+ "@fabriccode/cli-windows-x64": "7.0.118",
37
+ "@fabriccode/cli-linux-x64-musl": "7.0.118",
38
+ "@fabriccode/cli-windows-x64-baseline": "7.0.118",
39
+ "@fabriccode/cli-darwin-x64": "7.0.118",
40
+ "@fabriccode/cli-linux-x64-baseline-musl": "7.0.118",
41
+ "@fabriccode/cli-linux-x64-baseline": "7.0.118"
24
42
  },
25
43
  "repository": {
26
44
  "type": "git",
package/postinstall.mjs CHANGED
@@ -126,6 +126,19 @@ function findBinary() {
126
126
  }
127
127
  // fabriccode_change end
128
128
 
129
+ // fabriccode_change start - copy runtime resources (tree-sitter WASM) next to cached binary
130
+ function copyTreeSitterResources(binaryPath) {
131
+ const source = path.join(path.dirname(binaryPath), "tree-sitter")
132
+ const target = path.join(__dirname, "bin", "tree-sitter")
133
+ const runtime = path.join(source, "tree-sitter.wasm")
134
+
135
+ if (!fs.existsSync(runtime)) return
136
+
137
+ fs.rmSync(target, { recursive: true, force: true })
138
+ fs.cpSync(source, target, { recursive: true })
139
+ }
140
+ // fabriccode_change end
141
+
129
142
  function main() {
130
143
  if (os.platform() === "win32") {
131
144
  // On Windows, the .exe is already included in the package and bin field points to it
@@ -141,6 +154,7 @@ function main() {
141
154
  } catch {
142
155
  fs.copyFileSync(binaryPath, target)
143
156
  }
157
+ copyTreeSitterResources(binaryPath) // fabriccode_change
144
158
  fs.chmodSync(target, 0o755)
145
159
  }
146
160