@opencode-ai/cli 0.0.0-beta-202606050000

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/lildax +130 -0
  2. package/package.json +35 -0
package/bin/lildax ADDED
@@ -0,0 +1,130 @@
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
+ const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
9
+
10
+ function run(target) {
11
+ const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit" })
12
+ child.on("error", (error) => {
13
+ console.error(error.message)
14
+ process.exit(1)
15
+ })
16
+ const forwarders = {}
17
+ for (const signal of forwardedSignals) {
18
+ forwarders[signal] = () => {
19
+ try {
20
+ child.kill(signal)
21
+ } catch {}
22
+ }
23
+ process.on(signal, forwarders[signal])
24
+ }
25
+ child.on("exit", (code, signal) => {
26
+ for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal])
27
+ if (signal) return process.kill(process.pid, signal)
28
+ process.exit(typeof code === "number" ? code : 0)
29
+ })
30
+ }
31
+
32
+ const envPath = process.env.OPENCODE_BIN_PATH
33
+ const scriptDir = path.dirname(fs.realpathSync(__filename))
34
+ const cached = path.join(scriptDir, ".lildax")
35
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] || os.platform()
36
+ const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] || os.arch()
37
+ const base = "@opencode-ai/cli-" + platform + "-" + arch
38
+ const binary = platform === "windows" ? "lildax.exe" : "lildax"
39
+
40
+ function supportsAvx2() {
41
+ if (arch !== "x64") return false
42
+ if (platform === "linux") {
43
+ try {
44
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
45
+ } catch {
46
+ return false
47
+ }
48
+ }
49
+ if (platform === "darwin") {
50
+ try {
51
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
52
+ return result.status === 0 && (result.stdout || "").trim() === "1"
53
+ } catch {
54
+ return false
55
+ }
56
+ }
57
+ if (platform === "windows") {
58
+ const command =
59
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
60
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
61
+ try {
62
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
63
+ encoding: "utf8",
64
+ timeout: 3000,
65
+ windowsHide: true,
66
+ })
67
+ if (result.status !== 0) continue
68
+ const output = (result.stdout || "").trim().toLowerCase()
69
+ if (output === "true" || output === "1") return true
70
+ if (output === "false" || output === "0") return false
71
+ } catch {
72
+ continue
73
+ }
74
+ }
75
+ }
76
+ return false
77
+ }
78
+
79
+ const names = (() => {
80
+ const baseline = arch === "x64" && !supportsAvx2()
81
+ if (platform === "linux") {
82
+ const musl = (() => {
83
+ try {
84
+ if (fs.existsSync("/etc/alpine-release")) return true
85
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
86
+ return ((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")
87
+ } catch {
88
+ return false
89
+ }
90
+ })()
91
+ if (musl)
92
+ return arch === "x64"
93
+ ? baseline
94
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
95
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
96
+ : [`${base}-musl`, base]
97
+ return arch === "x64"
98
+ ? baseline
99
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
100
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
101
+ : [base, `${base}-musl`]
102
+ }
103
+ return arch === "x64" ? (baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]) : [base]
104
+ })()
105
+
106
+ function findBinary(startDir) {
107
+ let current = startDir
108
+ for (;;) {
109
+ const modules = path.join(current, "node_modules")
110
+ if (fs.existsSync(modules))
111
+ for (const name of names) {
112
+ const candidate = path.join(modules, name, "bin", binary)
113
+ if (fs.existsSync(candidate)) return candidate
114
+ }
115
+ const parent = path.dirname(current)
116
+ if (parent === current) return
117
+ current = parent
118
+ }
119
+ }
120
+
121
+ const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
122
+ if (!resolved) {
123
+ console.error(
124
+ "It seems that your package manager failed to install the right lildax CLI package. Try manually installing " +
125
+ names.map((name) => `"${name}"`).join(" or ") +
126
+ " package",
127
+ )
128
+ process.exit(1)
129
+ }
130
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@opencode-ai/cli",
3
+ "bin": {
4
+ "lildax": "./bin/lildax"
5
+ },
6
+ "version": "0.0.0-beta-202606050000",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/anomalyco/opencode.git"
11
+ },
12
+ "os": [
13
+ "darwin",
14
+ "linux",
15
+ "win32"
16
+ ],
17
+ "cpu": [
18
+ "arm64",
19
+ "x64"
20
+ ],
21
+ "optionalDependencies": {
22
+ "@opencode-ai/cli-darwin-x64": "0.0.0-beta-202606050000",
23
+ "@opencode-ai/cli-windows-arm64": "0.0.0-beta-202606050000",
24
+ "@opencode-ai/cli-linux-x64-musl": "0.0.0-beta-202606050000",
25
+ "@opencode-ai/cli-linux-x64-baseline-musl": "0.0.0-beta-202606050000",
26
+ "@opencode-ai/cli-linux-arm64-musl": "0.0.0-beta-202606050000",
27
+ "@opencode-ai/cli-windows-x64": "0.0.0-beta-202606050000",
28
+ "@opencode-ai/cli-linux-x64-baseline": "0.0.0-beta-202606050000",
29
+ "@opencode-ai/cli-darwin-arm64": "0.0.0-beta-202606050000",
30
+ "@opencode-ai/cli-linux-arm64": "0.0.0-beta-202606050000",
31
+ "@opencode-ai/cli-windows-x64-baseline": "0.0.0-beta-202606050000",
32
+ "@opencode-ai/cli-darwin-x64-baseline": "0.0.0-beta-202606050000",
33
+ "@opencode-ai/cli-linux-x64": "0.0.0-beta-202606050000"
34
+ }
35
+ }