cerebras-cli 1.0.159 → 1.0.161

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.
@@ -1,9 +1,4 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Cerebras CLI Bin Loader
4
- *
5
- * This script finds and executes the correct platform-specific binary.
6
- */
7
2
  const childProcess = require("child_process")
8
3
  const fs = require("fs")
9
4
  const path = require("path")
@@ -11,21 +6,15 @@ const os = require("os")
11
6
 
12
7
  function run(target) {
13
8
  const result = childProcess.spawnSync(target, process.argv.slice(2), { stdio: "inherit" })
14
- if (result.error) {
15
- console.error(result.error.message)
16
- process.exit(1)
17
- }
9
+ if (result.error) { console.error(result.error.message); process.exit(1) }
18
10
  process.exit(typeof result.status === "number" ? result.status : 0)
19
11
  }
20
12
 
21
- // Allow override via environment variable
22
- const envPath = process.env.CEREBRAS_CLI_BIN_PATH
13
+ const envPath = process.env.CEREBRAS_CLI_BIN_PATH || process.env.OPENCODE_BIN_PATH
23
14
  if (envPath) run(envPath)
24
15
 
25
16
  const scriptDir = path.dirname(fs.realpathSync(__filename))
26
- const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
27
- const archMap = { x64: "x64", arm64: "arm64", arm: "arm" }
28
- const base = "cerebras-cli-" + (platformMap[os.platform()] || os.platform()) + "-" + (archMap[os.arch()] || os.arch())
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())
29
18
  const binary = os.platform() === "win32" ? "cerebras-cli.exe" : "cerebras-cli"
30
19
 
31
20
  function findBinary(startDir) {
@@ -47,11 +36,5 @@ function findBinary(startDir) {
47
36
  }
48
37
 
49
38
  const resolved = findBinary(scriptDir)
50
- if (!resolved) {
51
- console.error(`Cerebras CLI binary not found for ${base}`)
52
- console.error(`Please ensure the correct platform package is installed.`)
53
- console.error(`Expected: ${base}`)
54
- process.exit(1)
55
- }
56
-
39
+ if (!resolved) { console.error("Binary not found for " + base); process.exit(1) }
57
40
  run(resolved)
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "cerebras-cli",
3
- "version": "1.0.159",
3
+ "version": "1.0.161",
4
4
  "description": "The fastest AI coding assistant, powered by Cerebras inference",
5
5
  "bin": {
6
6
  "cerebras-cli": "./bin/cerebras-cli.cjs"
7
7
  },
8
- "scripts": {
9
- "postinstall": "node ./postinstall.mjs || true"
10
- },
11
8
  "optionalDependencies": {
12
- "cerebras-cli-darwin-arm64": "1.0.159"
9
+ "cerebras-cli-darwin-arm64": "1.0.161"
13
10
  },
14
11
  "license": "MIT"
15
12
  }
package/postinstall.mjs DELETED
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Cerebras CLI Postinstall Script
4
- *
5
- * Creates symlinks to the platform-specific binary after npm install.
6
- */
7
-
8
- import fs from "fs"
9
- import path from "path"
10
- import os from "os"
11
- import { fileURLToPath } from "url"
12
- import { createRequire } from "module"
13
-
14
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
15
- const require = createRequire(import.meta.url)
16
-
17
- function detectPlatformAndArch() {
18
- let platform
19
- switch (os.platform()) {
20
- case "darwin":
21
- platform = "darwin"
22
- break
23
- case "linux":
24
- platform = "linux"
25
- break
26
- case "win32":
27
- platform = "windows"
28
- break
29
- default:
30
- platform = os.platform()
31
- break
32
- }
33
-
34
- let arch
35
- switch (os.arch()) {
36
- case "x64":
37
- arch = "x64"
38
- break
39
- case "arm64":
40
- arch = "arm64"
41
- break
42
- case "arm":
43
- arch = "arm"
44
- break
45
- default:
46
- arch = os.arch()
47
- break
48
- }
49
-
50
- return { platform, arch }
51
- }
52
-
53
- function findBinary() {
54
- const { platform, arch } = detectPlatformAndArch()
55
- const packageName = `cerebras-cli-${platform}-${arch}`
56
- const binaryName = platform === "windows" ? "cerebras-cli.exe" : "cerebras-cli"
57
-
58
- try {
59
- const packageJsonPath = require.resolve(`${packageName}/package.json`)
60
- const packageDir = path.dirname(packageJsonPath)
61
- const binaryPath = path.join(packageDir, "bin", binaryName)
62
-
63
- if (!fs.existsSync(binaryPath)) {
64
- throw new Error(`Binary not found at ${binaryPath}`)
65
- }
66
-
67
- return { binaryPath, binaryName }
68
- } catch (error) {
69
- throw new Error(`Could not find package ${packageName}: ${error.message}`)
70
- }
71
- }
72
-
73
- function prepareBinDirectory(binaryName) {
74
- const binDir = path.join(__dirname, "bin")
75
- const targetPath = path.join(binDir, binaryName)
76
-
77
- if (!fs.existsSync(binDir)) {
78
- fs.mkdirSync(binDir, { recursive: true })
79
- }
80
-
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(`cerebras-cli binary symlinked: ${targetPath} -> ${sourcePath}`)
93
-
94
- if (!fs.existsSync(targetPath)) {
95
- throw new Error(`Failed to symlink binary to ${targetPath}`)
96
- }
97
- }
98
-
99
- async function main() {
100
- try {
101
- if (os.platform() === "win32") {
102
- console.log("Windows detected: binary setup not needed (using packaged .exe)")
103
- return
104
- }
105
-
106
- const { binaryPath, binaryName } = findBinary()
107
- symlinkBinary(binaryPath, binaryName)
108
- } catch (error) {
109
- console.error("Failed to setup cerebras-cli binary:", error.message)
110
- process.exit(1)
111
- }
112
- }
113
-
114
- try {
115
- main()
116
- } catch (error) {
117
- console.error("Postinstall script error:", error.message)
118
- process.exit(0)
119
- }