@neevcode/neev 0.0.0-dev-202607090852 → 0.0.0-dev-202607140653
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/{opencode → neevcode} +15 -5
- package/package.json +14 -15
- package/postinstall.mjs +120 -68
|
@@ -17,6 +17,8 @@ function run(target) {
|
|
|
17
17
|
process.exit(code)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// OPENCODE_BIN_PATH is kept as a deprecated fallback so pre-rebrand wrappers,
|
|
21
|
+
// CI setups, and docs that export it keep working. NEEV_BIN_PATH wins.
|
|
20
22
|
const envPath = process.env.NEEV_BIN_PATH || process.env.OPENCODE_BIN_PATH
|
|
21
23
|
if (envPath) {
|
|
22
24
|
run(envPath)
|
|
@@ -25,10 +27,14 @@ if (envPath) {
|
|
|
25
27
|
const scriptPath = fs.realpathSync(__filename)
|
|
26
28
|
const scriptDir = path.dirname(scriptPath)
|
|
27
29
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// postinstall.mjs hardlinks the platform binary here so startup skips package
|
|
31
|
+
// resolution. The legacy ".opencode" name is still checked so an in-place
|
|
32
|
+
// upgrade whose postinstall failed can reuse the previous install's cache.
|
|
33
|
+
for (const cacheName of [".neevcode", ".opencode"]) {
|
|
34
|
+
const cached = path.join(scriptDir, cacheName)
|
|
35
|
+
if (fs.existsSync(cached)) {
|
|
36
|
+
run(cached)
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
const platformMap = {
|
|
@@ -51,6 +57,10 @@ if (!arch) {
|
|
|
51
57
|
arch = os.arch()
|
|
52
58
|
}
|
|
53
59
|
const base = "@neevcode/neev-" + platform + "-" + arch
|
|
60
|
+
// The platform packages ship their executable as bin/opencode(.exe) — that name
|
|
61
|
+
// comes from script/build.ts's compile outfile, not from this wrapper. It must
|
|
62
|
+
// stay "opencode" here until the build pipeline renames the shipped artifact,
|
|
63
|
+
// or every published @neevcode/neev-* package stops resolving.
|
|
54
64
|
const binary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
55
65
|
|
|
56
66
|
function supportsAvx2() {
|
|
@@ -169,7 +179,7 @@ function findBinary(startDir) {
|
|
|
169
179
|
const resolved = findBinary(scriptDir)
|
|
170
180
|
if (!resolved) {
|
|
171
181
|
console.error(
|
|
172
|
-
"It seems that your package manager failed to install the right version of the
|
|
182
|
+
"It seems that your package manager failed to install the right version of the NeevCode CLI (neev) for your platform. You can try manually installing the " +
|
|
173
183
|
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
174
184
|
" package",
|
|
175
185
|
)
|
package/package.json
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neevcode/neev",
|
|
3
3
|
"bin": {
|
|
4
|
-
"neev": "./bin/
|
|
5
|
-
"opencode": "./bin/opencode"
|
|
4
|
+
"neev": "./bin/neevcode"
|
|
6
5
|
},
|
|
7
6
|
"scripts": {
|
|
8
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
9
8
|
},
|
|
10
|
-
"version": "0.0.0-dev-
|
|
9
|
+
"version": "0.0.0-dev-202607140653",
|
|
11
10
|
"license": "MIT",
|
|
12
11
|
"optionalDependencies": {
|
|
13
|
-
"@neevcode/neev-
|
|
14
|
-
"@neevcode/neev-
|
|
15
|
-
"@neevcode/neev-
|
|
16
|
-
"@neevcode/neev-linux-
|
|
17
|
-
"@neevcode/neev-linux-
|
|
18
|
-
"@neevcode/neev-
|
|
19
|
-
"@neevcode/neev-
|
|
20
|
-
"@neevcode/neev-
|
|
21
|
-
"@neevcode/neev-
|
|
22
|
-
"@neevcode/neev-
|
|
23
|
-
"@neevcode/neev-
|
|
24
|
-
"@neevcode/neev-
|
|
12
|
+
"@neevcode/neev-linux-x64": "0.0.0-dev-202607140653",
|
|
13
|
+
"@neevcode/neev-linux-x64-baseline-musl": "0.0.0-dev-202607140653",
|
|
14
|
+
"@neevcode/neev-linux-arm64": "0.0.0-dev-202607140653",
|
|
15
|
+
"@neevcode/neev-linux-x64-musl": "0.0.0-dev-202607140653",
|
|
16
|
+
"@neevcode/neev-linux-x64-baseline": "0.0.0-dev-202607140653",
|
|
17
|
+
"@neevcode/neev-windows-x64-baseline": "0.0.0-dev-202607140653",
|
|
18
|
+
"@neevcode/neev-darwin-arm64": "0.0.0-dev-202607140653",
|
|
19
|
+
"@neevcode/neev-windows-x64": "0.0.0-dev-202607140653",
|
|
20
|
+
"@neevcode/neev-windows-arm64": "0.0.0-dev-202607140653",
|
|
21
|
+
"@neevcode/neev-linux-arm64-musl": "0.0.0-dev-202607140653",
|
|
22
|
+
"@neevcode/neev-darwin-x64-baseline": "0.0.0-dev-202607140653",
|
|
23
|
+
"@neevcode/neev-darwin-x64": "0.0.0-dev-202607140653"
|
|
25
24
|
}
|
|
26
25
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -1,102 +1,154 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// Runs inside the published @neevcode/neev meta package. Hardlinks the correct
|
|
4
|
+
// platform binary to bin/.neevcode so the wrapper skips resolution on startup.
|
|
5
|
+
// Must stay zero-dependency plain node, and must NEVER fail the install: the
|
|
6
|
+
// wrapper (bin/neevcode) does its own variant resolution at runtime, so any
|
|
7
|
+
// failure here only costs startup latency, not functionality.
|
|
8
|
+
//
|
|
9
|
+
// Variant priority (musl/AVX2 detection) mirrors bin/neevcode — keep in sync.
|
|
10
|
+
|
|
3
11
|
import fs from "fs"
|
|
4
12
|
import path from "path"
|
|
5
13
|
import os from "os"
|
|
14
|
+
import childProcess from "child_process"
|
|
6
15
|
import { fileURLToPath } from "url"
|
|
7
16
|
import { createRequire } from "module"
|
|
8
17
|
|
|
9
18
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
19
|
const require = createRequire(import.meta.url)
|
|
11
20
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
// Keep in sync with DistNpmPackage in packages/core/src/installation/dist.ts.
|
|
22
|
+
const packageBase = "@neevcode/neev"
|
|
23
|
+
|
|
24
|
+
const platformMap = {
|
|
25
|
+
darwin: "darwin",
|
|
26
|
+
linux: "linux",
|
|
27
|
+
win32: "windows",
|
|
28
|
+
}
|
|
29
|
+
const archMap = {
|
|
30
|
+
x64: "x64",
|
|
31
|
+
arm64: "arm64",
|
|
32
|
+
arm: "arm",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const platform = platformMap[os.platform()] || os.platform()
|
|
36
|
+
const arch = archMap[os.arch()] || os.arch()
|
|
37
|
+
const base = `${packageBase}-${platform}-${arch}`
|
|
38
|
+
// Platform packages ship their executable as bin/opencode(.exe) (script/build.ts
|
|
39
|
+
// outfile) — keep in sync with the `binary` constant in bin/neevcode.
|
|
40
|
+
const binaryName = platform === "windows" ? "opencode.exe" : "opencode"
|
|
41
|
+
|
|
42
|
+
function supportsAvx2() {
|
|
43
|
+
if (arch !== "x64") return false
|
|
44
|
+
|
|
45
|
+
if (platform === "linux") {
|
|
46
|
+
try {
|
|
47
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
48
|
+
} catch {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
28
51
|
}
|
|
29
52
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
break
|
|
42
|
-
default:
|
|
43
|
-
arch = os.arch()
|
|
44
|
-
break
|
|
53
|
+
if (platform === "darwin") {
|
|
54
|
+
try {
|
|
55
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
56
|
+
encoding: "utf8",
|
|
57
|
+
timeout: 1500,
|
|
58
|
+
})
|
|
59
|
+
if (result.status !== 0) return false
|
|
60
|
+
return (result.stdout || "").trim() === "1"
|
|
61
|
+
} catch {
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
45
64
|
}
|
|
46
65
|
|
|
47
|
-
return
|
|
66
|
+
return false
|
|
48
67
|
}
|
|
49
68
|
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
function isMusl() {
|
|
70
|
+
try {
|
|
71
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
72
|
+
} catch {
|
|
73
|
+
// ignore
|
|
74
|
+
}
|
|
54
75
|
|
|
55
76
|
try {
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
78
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
79
|
+
if (text.includes("musl")) return true
|
|
80
|
+
} catch {
|
|
81
|
+
// ignore
|
|
82
|
+
}
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function candidateNames() {
|
|
88
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
89
|
+
|
|
90
|
+
if (platform === "linux") {
|
|
91
|
+
if (isMusl()) {
|
|
92
|
+
if (arch === "x64") {
|
|
93
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
94
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
95
|
+
}
|
|
96
|
+
return [`${base}-musl`, base]
|
|
63
97
|
}
|
|
64
98
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
if (arch === "x64") {
|
|
100
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
101
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
102
|
+
}
|
|
103
|
+
return [base, `${base}-musl`]
|
|
68
104
|
}
|
|
69
|
-
}
|
|
70
105
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
}
|
|
106
|
+
if (arch === "x64") {
|
|
107
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
108
|
+
return [base, `${base}-baseline`]
|
|
109
|
+
}
|
|
110
|
+
return [base]
|
|
111
|
+
}
|
|
79
112
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const target = path.join(__dirname, "bin", ".opencode")
|
|
84
|
-
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
113
|
+
function findBinary() {
|
|
114
|
+
const names = candidateNames()
|
|
115
|
+
for (const name of names) {
|
|
85
116
|
try {
|
|
86
|
-
|
|
117
|
+
const packageJsonPath = require.resolve(`${name}/package.json`)
|
|
118
|
+
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", binaryName)
|
|
119
|
+
if (fs.existsSync(binaryPath)) return binaryPath
|
|
87
120
|
} catch {
|
|
88
|
-
|
|
121
|
+
continue
|
|
89
122
|
}
|
|
90
|
-
fs.chmodSync(target, 0o755)
|
|
91
|
-
} catch (error) {
|
|
92
|
-
console.error("Failed to setup opencode binary:", error.message)
|
|
93
|
-
process.exit(1)
|
|
94
123
|
}
|
|
124
|
+
throw new Error(`none of ${names.join(", ")} are installed`)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function main() {
|
|
128
|
+
if (os.platform() === "win32") {
|
|
129
|
+
// On Windows the bin field points at the wrapper and the .exe ships in the
|
|
130
|
+
// platform package — nothing to link.
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const binaryPath = findBinary()
|
|
135
|
+
const target = path.join(__dirname, "bin", ".neevcode")
|
|
136
|
+
// Drop a stale pre-rebrand cache too so upgrades don't leave a second copy
|
|
137
|
+
// of the binary behind (the wrapper would prefer .neevcode anyway).
|
|
138
|
+
const legacy = path.join(__dirname, "bin", ".opencode")
|
|
139
|
+
if (fs.existsSync(legacy)) fs.unlinkSync(legacy)
|
|
140
|
+
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
141
|
+
try {
|
|
142
|
+
fs.linkSync(binaryPath, target)
|
|
143
|
+
} catch {
|
|
144
|
+
fs.copyFileSync(binaryPath, target)
|
|
145
|
+
}
|
|
146
|
+
fs.chmodSync(target, 0o755)
|
|
95
147
|
}
|
|
96
148
|
|
|
97
149
|
try {
|
|
98
|
-
|
|
150
|
+
main()
|
|
99
151
|
} catch (error) {
|
|
100
|
-
console.
|
|
101
|
-
process.exit(0)
|
|
152
|
+
console.warn(`neev postinstall: skipping binary link (${error.message}); the CLI will resolve it at runtime`)
|
|
102
153
|
}
|
|
154
|
+
process.exit(0)
|