@fabriccode/cli 7.0.31

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kilo Code
4
+ Copyright (c) 2025 opencode
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/bin/fabric ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.FABRIC_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const platformMap = {
26
+ darwin: "darwin",
27
+ linux: "linux",
28
+ win32: "windows",
29
+ }
30
+ const archMap = {
31
+ x64: "x64",
32
+ arm64: "arm64",
33
+ arm: "arm",
34
+ }
35
+
36
+ let platform = platformMap[os.platform()]
37
+ if (!platform) {
38
+ platform = os.platform()
39
+ }
40
+ let arch = archMap[os.arch()]
41
+ if (!arch) {
42
+ arch = os.arch()
43
+ }
44
+ const base = "@fabriccode/cli-" + platform + "-" + arch
45
+ const binary = platform === "windows" ? "fabric.exe" : "fabric"
46
+
47
+ function supportsAvx2() {
48
+ if (arch !== "x64") return false
49
+
50
+ if (platform === "linux") {
51
+ try {
52
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
53
+ } catch {
54
+ return false
55
+ }
56
+ }
57
+
58
+ if (platform === "darwin") {
59
+ try {
60
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
61
+ encoding: "utf8",
62
+ timeout: 1500,
63
+ })
64
+ if (result.status !== 0) return false
65
+ return (result.stdout || "").trim() === "1"
66
+ } catch {
67
+ return false
68
+ }
69
+ }
70
+
71
+ if (platform === "windows") {
72
+ const cmd =
73
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
74
+
75
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
76
+ try {
77
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
78
+ encoding: "utf8",
79
+ timeout: 3000,
80
+ windowsHide: true,
81
+ })
82
+ if (result.status !== 0) continue
83
+ const out = (result.stdout || "").trim().toLowerCase()
84
+ if (out === "true" || out === "1") return true
85
+ if (out === "false" || out === "0") return false
86
+ } catch {
87
+ continue
88
+ }
89
+ }
90
+
91
+ return false
92
+ }
93
+
94
+ return false
95
+ }
96
+
97
+ const names = (() => {
98
+ const avx2 = supportsAvx2()
99
+ const baseline = arch === "x64" && !avx2
100
+
101
+ if (platform === "linux") {
102
+ const musl = (() => {
103
+ try {
104
+ if (fs.existsSync("/etc/alpine-release")) return true
105
+ } catch {
106
+ // ignore
107
+ }
108
+
109
+ try {
110
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
111
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
112
+ if (text.includes("musl")) return true
113
+ } catch {
114
+ // ignore
115
+ }
116
+
117
+ return false
118
+ })()
119
+
120
+ if (musl) {
121
+ if (arch === "x64") {
122
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
123
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
124
+ }
125
+ return [`${base}-musl`, base]
126
+ }
127
+
128
+ if (arch === "x64") {
129
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
130
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
131
+ }
132
+ return [base, `${base}-musl`]
133
+ }
134
+
135
+ if (arch === "x64") {
136
+ if (baseline) return [`${base}-baseline`, base]
137
+ return [base, `${base}-baseline`]
138
+ }
139
+ return [base]
140
+ })()
141
+
142
+ function findBinary(startDir) {
143
+ let current = startDir
144
+ for (;;) {
145
+ const modules = path.join(current, "node_modules")
146
+ if (fs.existsSync(modules)) {
147
+ for (const name of names) {
148
+ const candidate = path.join(modules, name, "bin", binary)
149
+ if (fs.existsSync(candidate)) return candidate
150
+ }
151
+ }
152
+ const parent = path.dirname(current)
153
+ if (parent === current) {
154
+ return
155
+ }
156
+ current = parent
157
+ }
158
+ }
159
+
160
+ const scriptPath = fs.realpathSync(__filename)
161
+ const scriptDir = path.dirname(scriptPath)
162
+
163
+ const resolved = findBinary(scriptDir)
164
+ if (!resolved) {
165
+ console.error(
166
+ "It seems that your package manager failed to install the right version of Fabric Code for your platform. You can try manually installing " +
167
+ names.map((n) => `\"${n}\"`).join(" or ") +
168
+ " package",
169
+ )
170
+ process.exit(1)
171
+ }
172
+
173
+ run(resolved)
package/bin/kilo ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const envPath = process.env.KILO_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const platformMap = {
26
+ darwin: "darwin",
27
+ linux: "linux",
28
+ win32: "windows",
29
+ }
30
+ const archMap = {
31
+ x64: "x64",
32
+ arm64: "arm64",
33
+ arm: "arm",
34
+ }
35
+
36
+ let platform = platformMap[os.platform()]
37
+ if (!platform) {
38
+ platform = os.platform()
39
+ }
40
+ let arch = archMap[os.arch()]
41
+ if (!arch) {
42
+ arch = os.arch()
43
+ }
44
+ const base = "@kilocode/cli-" + platform + "-" + arch
45
+ const binary = platform === "windows" ? "kilo.exe" : "kilo"
46
+
47
+ function supportsAvx2() {
48
+ if (arch !== "x64") return false
49
+
50
+ if (platform === "linux") {
51
+ try {
52
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
53
+ } catch {
54
+ return false
55
+ }
56
+ }
57
+
58
+ if (platform === "darwin") {
59
+ try {
60
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
61
+ encoding: "utf8",
62
+ timeout: 1500,
63
+ })
64
+ if (result.status !== 0) return false
65
+ return (result.stdout || "").trim() === "1"
66
+ } catch {
67
+ return false
68
+ }
69
+ }
70
+
71
+ if (platform === "windows") {
72
+ const cmd =
73
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
74
+
75
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
76
+ try {
77
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
78
+ encoding: "utf8",
79
+ timeout: 3000,
80
+ windowsHide: true,
81
+ })
82
+ if (result.status !== 0) continue
83
+ const out = (result.stdout || "").trim().toLowerCase()
84
+ if (out === "true" || out === "1") return true
85
+ if (out === "false" || out === "0") return false
86
+ } catch {
87
+ continue
88
+ }
89
+ }
90
+
91
+ return false
92
+ }
93
+
94
+ return false
95
+ }
96
+
97
+ const names = (() => {
98
+ const avx2 = supportsAvx2()
99
+ const baseline = arch === "x64" && !avx2
100
+
101
+ if (platform === "linux") {
102
+ const musl = (() => {
103
+ try {
104
+ if (fs.existsSync("/etc/alpine-release")) return true
105
+ } catch {
106
+ // ignore
107
+ }
108
+
109
+ try {
110
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
111
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
112
+ if (text.includes("musl")) return true
113
+ } catch {
114
+ // ignore
115
+ }
116
+
117
+ return false
118
+ })()
119
+
120
+ if (musl) {
121
+ if (arch === "x64") {
122
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
123
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
124
+ }
125
+ return [`${base}-musl`, base]
126
+ }
127
+
128
+ if (arch === "x64") {
129
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
130
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
131
+ }
132
+ return [base, `${base}-musl`]
133
+ }
134
+
135
+ if (arch === "x64") {
136
+ if (baseline) return [`${base}-baseline`, base]
137
+ return [base, `${base}-baseline`]
138
+ }
139
+ return [base]
140
+ })()
141
+
142
+ function findBinary(startDir) {
143
+ let current = startDir
144
+ for (;;) {
145
+ const modules = path.join(current, "node_modules")
146
+ if (fs.existsSync(modules)) {
147
+ for (const name of names) {
148
+ const candidate = path.join(modules, name, "bin", binary)
149
+ if (fs.existsSync(candidate)) return candidate
150
+ }
151
+ }
152
+ const parent = path.dirname(current)
153
+ if (parent === current) {
154
+ return
155
+ }
156
+ current = parent
157
+ }
158
+ }
159
+
160
+ const scriptPath = fs.realpathSync(__filename)
161
+ const scriptDir = path.dirname(scriptPath)
162
+
163
+ const resolved = findBinary(scriptDir)
164
+ if (!resolved) {
165
+ console.error(
166
+ "It seems that your package manager failed to install the right version of the Kilo CLI for your platform. You can try manually installing " +
167
+ names.map((n) => `\"${n}\"`).join(" or ") +
168
+ " package",
169
+ )
170
+ process.exit(1)
171
+ }
172
+
173
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@fabriccode/cli",
3
+ "bin": {
4
+ "fabric": "./bin/fabric",
5
+ "fabriccode": "./bin/fabric"
6
+ },
7
+ "scripts": {
8
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
9
+ },
10
+ "version": "7.0.31",
11
+ "license": "MIT",
12
+ "optionalDependencies": {
13
+ "@fabriccode/cli-windows-x64": "7.0.31",
14
+ "@fabriccode/cli-linux-x64-baseline-musl": "7.0.31",
15
+ "@fabriccode/cli-linux-x64-baseline": "7.0.31",
16
+ "@fabriccode/cli-linux-x64": "7.0.31",
17
+ "@fabriccode/cli-darwin-arm64": "7.0.31",
18
+ "@fabriccode/cli-windows-x64-baseline": "7.0.31",
19
+ "@fabriccode/cli-darwin-x64-baseline": "7.0.31",
20
+ "@fabriccode/cli-linux-arm64": "7.0.31",
21
+ "@fabriccode/cli-linux-arm64-musl": "7.0.31",
22
+ "@fabriccode/cli-linux-x64-musl": "7.0.31",
23
+ "@fabriccode/cli-darwin-x64": "7.0.31"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/Fabric-Pro/fabric-code"
28
+ }
29
+ }
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ // Map platform names
14
+ let platform
15
+ switch (os.platform()) {
16
+ case "darwin":
17
+ platform = "darwin"
18
+ break
19
+ case "linux":
20
+ platform = "linux"
21
+ break
22
+ case "win32":
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
+ }
46
+
47
+ return { platform, arch }
48
+ }
49
+
50
+ function findBinary() {
51
+ const { platform, arch } = detectPlatformAndArch()
52
+ const packageName = `@kilocode/cli-${platform}-${arch}`
53
+ const binaryName = platform === "windows" ? "kilo.exe" : "kilo"
54
+
55
+ try {
56
+ // Use require.resolve to find the package
57
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
58
+ const packageDir = path.dirname(packageJsonPath)
59
+ const binaryPath = path.join(packageDir, "bin", binaryName)
60
+
61
+ if (!fs.existsSync(binaryPath)) {
62
+ throw new Error(`Binary not found at ${binaryPath}`)
63
+ }
64
+
65
+ return { binaryPath, binaryName }
66
+ } catch (error) {
67
+ throw new Error(`Could not find package ${packageName}: ${error.message}`)
68
+ }
69
+ }
70
+
71
+ function prepareBinDirectory(binaryName) {
72
+ const binDir = path.join(__dirname, "bin")
73
+ const targetPath = path.join(binDir, binaryName)
74
+
75
+ // Ensure bin directory exists
76
+ if (!fs.existsSync(binDir)) {
77
+ fs.mkdirSync(binDir, { recursive: true })
78
+ }
79
+
80
+ // Remove existing binary/symlink if it exists
81
+ if (fs.existsSync(targetPath)) {
82
+ fs.unlinkSync(targetPath)
83
+ }
84
+
85
+ return { binDir, targetPath }
86
+ }
87
+
88
+ function symlinkBinary(sourcePath, binaryName) {
89
+ const { targetPath } = prepareBinDirectory(binaryName)
90
+
91
+ fs.symlinkSync(sourcePath, targetPath)
92
+ console.log(`kilo binary symlinked: ${targetPath} -> ${sourcePath}`)
93
+
94
+ // Verify the file exists after operation
95
+ if (!fs.existsSync(targetPath)) {
96
+ throw new Error(`Failed to symlink binary to ${targetPath}`)
97
+ }
98
+ }
99
+
100
+ async function main() {
101
+ try {
102
+ if (os.platform() === "win32") {
103
+ // On Windows, the .exe is already included in the package and bin field points to it
104
+ // No postinstall setup needed
105
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
106
+ return
107
+ }
108
+
109
+ // On non-Windows platforms, just verify the binary package exists
110
+ // Don't replace the wrapper script - it handles binary execution
111
+ const { binaryPath } = findBinary()
112
+ console.log(`Platform binary verified at: ${binaryPath}`)
113
+ console.log("Wrapper script will handle binary execution")
114
+ } catch (error) {
115
+ console.error("Failed to setup kilo binary:", error.message)
116
+ process.exit(1)
117
+ }
118
+ }
119
+
120
+ try {
121
+ main()
122
+ } catch (error) {
123
+ console.error("Postinstall script error:", error.message)
124
+ process.exit(0)
125
+ }