@textcortex/zenocode-ai 0.0.0-dev-202603301644
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 +21 -0
- package/bin/opencode +187 -0
- package/package.json +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 opencode
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/opencode
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
const packageScope = "@textcortex"
|
|
28
|
+
const packagePrefix = "zenocode"
|
|
29
|
+
const packageBaseName = "zenocode-ai"
|
|
30
|
+
const brandedBinName = "zenocode"
|
|
31
|
+
|
|
32
|
+
const platformMap = {
|
|
33
|
+
darwin: "darwin",
|
|
34
|
+
linux: "linux",
|
|
35
|
+
win32: "windows",
|
|
36
|
+
}
|
|
37
|
+
const archMap = {
|
|
38
|
+
x64: "x64",
|
|
39
|
+
arm64: "arm64",
|
|
40
|
+
arm: "arm",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let platform = platformMap[os.platform()]
|
|
44
|
+
if (!platform) {
|
|
45
|
+
platform = os.platform()
|
|
46
|
+
}
|
|
47
|
+
let arch = archMap[os.arch()]
|
|
48
|
+
if (!arch) {
|
|
49
|
+
arch = os.arch()
|
|
50
|
+
}
|
|
51
|
+
const base = packagePrefix + "-" + platform + "-" + arch
|
|
52
|
+
const binary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
53
|
+
|
|
54
|
+
function supportsAvx2() {
|
|
55
|
+
if (arch !== "x64") return false
|
|
56
|
+
|
|
57
|
+
if (platform === "linux") {
|
|
58
|
+
try {
|
|
59
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
60
|
+
} catch {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (platform === "darwin") {
|
|
66
|
+
try {
|
|
67
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
68
|
+
encoding: "utf8",
|
|
69
|
+
timeout: 1500,
|
|
70
|
+
})
|
|
71
|
+
if (result.status !== 0) return false
|
|
72
|
+
return (result.stdout || "").trim() === "1"
|
|
73
|
+
} catch {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (platform === "windows") {
|
|
79
|
+
const cmd =
|
|
80
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
81
|
+
|
|
82
|
+
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
83
|
+
try {
|
|
84
|
+
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
85
|
+
encoding: "utf8",
|
|
86
|
+
timeout: 3000,
|
|
87
|
+
windowsHide: true,
|
|
88
|
+
})
|
|
89
|
+
if (result.status !== 0) continue
|
|
90
|
+
const out = (result.stdout || "").trim().toLowerCase()
|
|
91
|
+
if (out === "true" || out === "1") return true
|
|
92
|
+
if (out === "false" || out === "0") return false
|
|
93
|
+
} catch {
|
|
94
|
+
continue
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const names = (() => {
|
|
105
|
+
const avx2 = supportsAvx2()
|
|
106
|
+
const baseline = arch === "x64" && !avx2
|
|
107
|
+
|
|
108
|
+
if (platform === "linux") {
|
|
109
|
+
const musl = (() => {
|
|
110
|
+
try {
|
|
111
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
117
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
118
|
+
if (text.includes("musl")) return true
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return false
|
|
123
|
+
})()
|
|
124
|
+
|
|
125
|
+
if (musl) {
|
|
126
|
+
if (arch === "x64") {
|
|
127
|
+
if (baseline) return [base + "-baseline-musl", base + "-musl", base + "-baseline", base]
|
|
128
|
+
return [base + "-musl", base + "-baseline-musl", base, base + "-baseline"]
|
|
129
|
+
}
|
|
130
|
+
return [base + "-musl", base]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (arch === "x64") {
|
|
134
|
+
if (baseline) return [base + "-baseline", base, base + "-baseline-musl", base + "-musl"]
|
|
135
|
+
return [base, base + "-baseline", base + "-musl", base + "-baseline-musl"]
|
|
136
|
+
}
|
|
137
|
+
return [base, base + "-musl"]
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (arch === "x64") {
|
|
141
|
+
if (baseline) return [base + "-baseline", base]
|
|
142
|
+
return [base, base + "-baseline"]
|
|
143
|
+
}
|
|
144
|
+
return [base]
|
|
145
|
+
})()
|
|
146
|
+
|
|
147
|
+
function candidatePackageNames(name) {
|
|
148
|
+
const scopedName = packageScope ? packageScope + "/" + name : name
|
|
149
|
+
const legacyName = name.replace(new RegExp("^" + packagePrefix), "opencode")
|
|
150
|
+
return packageScope ? [scopedName, legacyName] : [scopedName]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function resolveFromPackage(packageName) {
|
|
154
|
+
try {
|
|
155
|
+
const packageJsonPath = require.resolve(packageName + "/package.json", {
|
|
156
|
+
paths: [scriptDir],
|
|
157
|
+
})
|
|
158
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
159
|
+
const candidate = path.join(packageDir, "bin", binary)
|
|
160
|
+
if (fs.existsSync(candidate)) return candidate
|
|
161
|
+
} catch {
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function findBinary() {
|
|
166
|
+
for (const name of names) {
|
|
167
|
+
for (const packageName of candidatePackageNames(name)) {
|
|
168
|
+
const candidate = resolveFromPackage(packageName)
|
|
169
|
+
if (candidate) return candidate
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const resolved = findBinary()
|
|
175
|
+
if (!resolved) {
|
|
176
|
+
const installTargets = names.flatMap((name) => candidatePackageNames(name))
|
|
177
|
+
console.error(
|
|
178
|
+
"It seems that your package manager failed to install the right version of the " +
|
|
179
|
+
packageBaseName +
|
|
180
|
+
" CLI for your platform. You can try manually installing " +
|
|
181
|
+
installTargets.map((name) => "\""+name+"\"").join(" or ") +
|
|
182
|
+
" package",
|
|
183
|
+
)
|
|
184
|
+
process.exit(1)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
run(resolved)
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@textcortex/zenocode-ai",
|
|
3
|
+
"version": "0.0.0-dev-202603301644",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"bin": {
|
|
7
|
+
"zenocode-ai": "./bin/opencode",
|
|
8
|
+
"opencode": "./bin/opencode",
|
|
9
|
+
"zenocode": "./bin/opencode"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@textcortex/zenocode-linux-x64": "0.0.0-dev-202603301644"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
]
|
|
18
|
+
}
|