cerebras-cli 1.1.67 → 1.1.71

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/cerebras ADDED
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env bun
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, args = process.argv.slice(2), cwd) {
9
+ const result = childProcess.spawnSync(target, args, {
10
+ stdio: "inherit",
11
+ cwd: cwd,
12
+ })
13
+ if (result.error) {
14
+ console.error(result.error.message)
15
+ process.exit(1)
16
+ }
17
+ const code = typeof result.status === "number" ? result.status : 0
18
+ process.exit(code)
19
+ }
20
+
21
+ const envPath = process.env.CEREBRAS_BIN_PATH
22
+ if (envPath) {
23
+ run(envPath)
24
+ }
25
+
26
+ const scriptPath = fs.realpathSync(__filename)
27
+ const scriptDir = path.dirname(scriptPath)
28
+
29
+ const platformMap = {
30
+ darwin: "darwin",
31
+ linux: "linux",
32
+ win32: "windows",
33
+ }
34
+ const archMap = {
35
+ x64: "x64",
36
+ arm64: "arm64",
37
+ arm: "arm",
38
+ }
39
+
40
+ let platform = platformMap[os.platform()]
41
+ if (!platform) {
42
+ platform = os.platform()
43
+ }
44
+ let arch = archMap[os.arch()]
45
+ if (!arch) {
46
+ arch = os.arch()
47
+ }
48
+ const base = "cerebras-cli-" + platform + "-" + arch
49
+ const binary = platform === "windows" ? "cerebras.exe" : "cerebras"
50
+
51
+ function supportsAvx2() {
52
+ if (arch !== "x64") return false
53
+
54
+ if (platform === "linux") {
55
+ try {
56
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
57
+ } catch {
58
+ return false
59
+ }
60
+ }
61
+
62
+ if (platform === "darwin") {
63
+ try {
64
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
65
+ encoding: "utf8",
66
+ timeout: 1500,
67
+ })
68
+ if (result.status !== 0) return false
69
+ return (result.stdout || "").trim() === "1"
70
+ } catch {
71
+ return false
72
+ }
73
+ }
74
+
75
+ if (platform === "windows") {
76
+ const cmd =
77
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
78
+
79
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
80
+ try {
81
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
82
+ encoding: "utf8",
83
+ timeout: 3000,
84
+ windowsHide: true,
85
+ })
86
+ if (result.status !== 0) continue
87
+ const out = (result.stdout || "").trim().toLowerCase()
88
+ if (out === "true" || out === "1") return true
89
+ if (out === "false" || out === "0") return false
90
+ } catch {
91
+ continue
92
+ }
93
+ }
94
+
95
+ return false
96
+ }
97
+
98
+ return false
99
+ }
100
+
101
+ const names = (() => {
102
+ const avx2 = supportsAvx2()
103
+ const baseline = arch === "x64" && !avx2
104
+
105
+ if (platform === "linux") {
106
+ const musl = (() => {
107
+ try {
108
+ if (fs.existsSync("/etc/alpine-release")) return true
109
+ } catch {
110
+ // ignore
111
+ }
112
+
113
+ try {
114
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
115
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
116
+ if (text.includes("musl")) return true
117
+ } catch {
118
+ // ignore
119
+ }
120
+
121
+ return false
122
+ })()
123
+
124
+ if (musl) {
125
+ if (arch === "x64") {
126
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
127
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
128
+ }
129
+ return [`${base}-musl`, base]
130
+ }
131
+
132
+ if (arch === "x64") {
133
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
134
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
135
+ }
136
+ return [base, `${base}-musl`]
137
+ }
138
+
139
+ if (arch === "x64") {
140
+ if (baseline) return [`${base}-baseline`, base]
141
+ return [base, `${base}-baseline`]
142
+ }
143
+ return [base]
144
+ })()
145
+
146
+ function findBinary(startDir) {
147
+ let current = startDir
148
+ for (;;) {
149
+ const modules = path.join(current, "node_modules")
150
+ if (fs.existsSync(modules)) {
151
+ for (const name of names) {
152
+ const candidate = path.join(modules, name, "bin", binary)
153
+ if (fs.existsSync(candidate)) return candidate
154
+ }
155
+ }
156
+ const parent = path.dirname(current)
157
+ if (parent === current) {
158
+ return
159
+ }
160
+ current = parent
161
+ }
162
+ }
163
+
164
+ const resolved = findBinary(scriptDir)
165
+
166
+ // If no compiled binary found, run the TypeScript source directly with Bun
167
+ if (!resolved) {
168
+ const srcPath = path.join(scriptDir, "..", "src", "index.ts")
169
+ const pkgDir = path.join(scriptDir, "..")
170
+ if (fs.existsSync(srcPath)) {
171
+ run("bun", [srcPath, ...process.argv.slice(2)], pkgDir)
172
+ } else {
173
+ console.error(
174
+ 'It seems that your package manager failed to install the right version of the cerebras CLI for your platform. You can try manually installing the "' +
175
+ base +
176
+ '" package',
177
+ )
178
+ process.exit(1)
179
+ }
180
+ } else {
181
+ run(resolved)
182
+ }
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "cerebras-cli",
3
- "version": "1.1.67",
3
+ "version": "1.1.71",
4
4
  "description": "Cerebras AI coding agent for the terminal",
5
5
  "bin": {
6
- "cerebras-cli": "./bin/opencode"
6
+ "cerebras-cli": "./bin/cerebras"
7
7
  },
8
8
  "scripts": {
9
9
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
10
10
  },
11
11
  "optionalDependencies": {
12
- "cerebras-cli-darwin-arm64": "1.1.65",
13
- "cerebras-cli-darwin-x64": "*",
14
- "cerebras-cli-linux-arm64": "*",
15
- "cerebras-cli-linux-x64": "*"
12
+ "cerebras-cli-darwin-arm64": "1.1.71",
13
+ "cerebras-cli-darwin-x64": "1.1.71",
14
+ "cerebras-cli-linux-arm64": "1.1.71",
15
+ "cerebras-cli-linux-x64": "1.1.71"
16
16
  },
17
- "license": "MIT"
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/kevint-cerebras/cerebras-code-cli"
21
+ }
18
22
  }
package/postinstall.mjs CHANGED
@@ -50,7 +50,7 @@ function detectPlatformAndArch() {
50
50
  function findBinary() {
51
51
  const { platform, arch } = detectPlatformAndArch()
52
52
  const packageName = `cerebras-cli-${platform}-${arch}`
53
- const binaryName = platform === "windows" ? "opencode.exe" : "opencode"
53
+ const binaryName = platform === "windows" ? "cerebras.exe" : "cerebras"
54
54
 
55
55
  try {
56
56
  // Use require.resolve to find the package
@@ -89,7 +89,7 @@ function symlinkBinary(sourcePath, binaryName) {
89
89
  const { targetPath } = prepareBinDirectory(binaryName)
90
90
 
91
91
  fs.symlinkSync(sourcePath, targetPath)
92
- console.log(`opencode binary symlinked: ${targetPath} -> ${sourcePath}`)
92
+ console.log(`cerebras-cli binary symlinked: ${targetPath} -> ${sourcePath}`)
93
93
 
94
94
  // Verify the file exists after operation
95
95
  if (!fs.existsSync(targetPath)) {
@@ -106,10 +106,13 @@ async function main() {
106
106
  return
107
107
  }
108
108
 
109
- const { binaryPath, binaryName } = findBinary()
110
- symlinkBinary(binaryPath, binaryName)
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")
111
114
  } catch (error) {
112
- console.error("Failed to setup opencode binary:", error.message)
115
+ console.error("Failed to setup cerebras-cli binary:", error.message)
113
116
  process.exit(1)
114
117
  }
115
118
  }
package/bin/opencode DELETED
@@ -1,84 +0,0 @@
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.OPENCODE_BIN_PATH
21
- if (envPath) {
22
- run(envPath)
23
- }
24
-
25
- const scriptPath = fs.realpathSync(__filename)
26
- const scriptDir = path.dirname(scriptPath)
27
-
28
- const platformMap = {
29
- darwin: "darwin",
30
- linux: "linux",
31
- win32: "windows",
32
- }
33
- const archMap = {
34
- x64: "x64",
35
- arm64: "arm64",
36
- arm: "arm",
37
- }
38
-
39
- let platform = platformMap[os.platform()]
40
- if (!platform) {
41
- platform = os.platform()
42
- }
43
- let arch = archMap[os.arch()]
44
- if (!arch) {
45
- arch = os.arch()
46
- }
47
- const base = "cerebras-cli-" + platform + "-" + arch
48
- const binary = platform === "windows" ? "opencode.exe" : "opencode"
49
-
50
- function findBinary(startDir) {
51
- let current = startDir
52
- for (;;) {
53
- const modules = path.join(current, "node_modules")
54
- if (fs.existsSync(modules)) {
55
- const entries = fs.readdirSync(modules)
56
- for (const entry of entries) {
57
- if (!entry.startsWith(base)) {
58
- continue
59
- }
60
- const candidate = path.join(modules, entry, "bin", binary)
61
- if (fs.existsSync(candidate)) {
62
- return candidate
63
- }
64
- }
65
- }
66
- const parent = path.dirname(current)
67
- if (parent === current) {
68
- return
69
- }
70
- current = parent
71
- }
72
- }
73
-
74
- const resolved = findBinary(scriptDir)
75
- if (!resolved) {
76
- console.error(
77
- 'It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing the "' +
78
- base +
79
- '" package',
80
- )
81
- process.exit(1)
82
- }
83
-
84
- run(resolved)
package/bin/opencode.cjs DELETED
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- const childProcess = require("child_process")
3
- const fs = require("fs")
4
- const path = require("path")
5
- const os = require("os")
6
-
7
- function run(target) {
8
- const result = childProcess.spawnSync(target, process.argv.slice(2), { stdio: "inherit" })
9
- if (result.error) { console.error(result.error.message); process.exit(1) }
10
- process.exit(typeof result.status === "number" ? result.status : 0)
11
- }
12
-
13
- const envPath = process.env.CEREBRAS_CLI_BIN_PATH || process.env.OPENCODE_BIN_PATH
14
- if (envPath) run(envPath)
15
-
16
- const scriptDir = path.dirname(fs.realpathSync(__filename))
17
- const base = "cerebras-cli-" + ({"darwin":"darwin","linux":"linux","win32":"windows"}[os.platform()] || os.platform()) + "-" + ({"x64":"x64","arm64":"arm64","arm":"arm"}[os.arch()] || os.arch())
18
- const binary = os.platform() === "win32" ? "cerebras-cli.exe" : "cerebras-cli"
19
-
20
- function findBinary(startDir) {
21
- let current = startDir
22
- while (true) {
23
- const modules = path.join(current, "node_modules")
24
- if (fs.existsSync(modules)) {
25
- for (const entry of fs.readdirSync(modules)) {
26
- if (entry.startsWith(base)) {
27
- const candidate = path.join(modules, entry, "bin", binary)
28
- if (fs.existsSync(candidate)) return candidate
29
- }
30
- }
31
- }
32
- const parent = path.dirname(current)
33
- if (parent === current) return
34
- current = parent
35
- }
36
- }
37
-
38
- const resolved = findBinary(scriptDir)
39
- if (!resolved) { console.error("Binary not found for " + base); process.exit(1) }
40
- run(resolved)