@matrix-ai/matrix 1.1.59 → 1.1.61
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/matrix +108 -13
- package/package.json +12 -12
- package/postinstall.mjs +8 -2
package/bin/matrix
CHANGED
|
@@ -17,7 +17,7 @@ function run(target) {
|
|
|
17
17
|
process.exit(code)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const envPath = process.env.
|
|
20
|
+
const envPath = process.env.MATRIX_BIN_PATH
|
|
21
21
|
if (envPath) {
|
|
22
22
|
run(envPath)
|
|
23
23
|
}
|
|
@@ -25,6 +25,12 @@ if (envPath) {
|
|
|
25
25
|
const scriptPath = fs.realpathSync(__filename)
|
|
26
26
|
const scriptDir = path.dirname(scriptPath)
|
|
27
27
|
|
|
28
|
+
//
|
|
29
|
+
const cached = path.join(scriptDir, ".matrix")
|
|
30
|
+
if (fs.existsSync(cached)) {
|
|
31
|
+
run(cached)
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
const platformMap = {
|
|
29
35
|
darwin: "darwin",
|
|
30
36
|
linux: "linux",
|
|
@@ -47,20 +53,109 @@ if (!arch) {
|
|
|
47
53
|
const base = "matrix-" + platform + "-" + arch
|
|
48
54
|
const binary = platform === "windows" ? "matrix.exe" : "matrix"
|
|
49
55
|
|
|
56
|
+
function supportsAvx2() {
|
|
57
|
+
if (arch !== "x64") return false
|
|
58
|
+
|
|
59
|
+
if (platform === "linux") {
|
|
60
|
+
try {
|
|
61
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
62
|
+
} catch {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (platform === "darwin") {
|
|
68
|
+
try {
|
|
69
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
70
|
+
encoding: "utf8",
|
|
71
|
+
timeout: 1500,
|
|
72
|
+
})
|
|
73
|
+
if (result.status !== 0) return false
|
|
74
|
+
return (result.stdout || "").trim() === "1"
|
|
75
|
+
} catch {
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (platform === "windows") {
|
|
81
|
+
const cmd =
|
|
82
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
83
|
+
|
|
84
|
+
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
85
|
+
try {
|
|
86
|
+
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
87
|
+
encoding: "utf8",
|
|
88
|
+
timeout: 3000,
|
|
89
|
+
windowsHide: true,
|
|
90
|
+
})
|
|
91
|
+
if (result.status !== 0) continue
|
|
92
|
+
const out = (result.stdout || "").trim().toLowerCase()
|
|
93
|
+
if (out === "true" || out === "1") return true
|
|
94
|
+
if (out === "false" || out === "0") return false
|
|
95
|
+
} catch {
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const names = (() => {
|
|
107
|
+
const avx2 = supportsAvx2()
|
|
108
|
+
const baseline = arch === "x64" && !avx2
|
|
109
|
+
|
|
110
|
+
if (platform === "linux") {
|
|
111
|
+
const musl = (() => {
|
|
112
|
+
try {
|
|
113
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
114
|
+
} catch {
|
|
115
|
+
// ignore
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
120
|
+
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
121
|
+
if (text.includes("musl")) return true
|
|
122
|
+
} catch {
|
|
123
|
+
// ignore
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return false
|
|
127
|
+
})()
|
|
128
|
+
|
|
129
|
+
if (musl) {
|
|
130
|
+
if (arch === "x64") {
|
|
131
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
132
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
133
|
+
}
|
|
134
|
+
return [`${base}-musl`, base]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (arch === "x64") {
|
|
138
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
139
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
140
|
+
}
|
|
141
|
+
return [base, `${base}-musl`]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (arch === "x64") {
|
|
145
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
146
|
+
return [base, `${base}-baseline`]
|
|
147
|
+
}
|
|
148
|
+
return [base]
|
|
149
|
+
})()
|
|
150
|
+
|
|
50
151
|
function findBinary(startDir) {
|
|
51
152
|
let current = startDir
|
|
52
153
|
for (;;) {
|
|
53
154
|
const modules = path.join(current, "node_modules")
|
|
54
155
|
if (fs.existsSync(modules)) {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
const candidate = path.join(modules, entry, "bin", binary)
|
|
61
|
-
if (fs.existsSync(candidate)) {
|
|
62
|
-
return candidate
|
|
63
|
-
}
|
|
156
|
+
for (const name of names) {
|
|
157
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
158
|
+
if (fs.existsSync(candidate)) return candidate
|
|
64
159
|
}
|
|
65
160
|
}
|
|
66
161
|
const parent = path.dirname(current)
|
|
@@ -74,9 +169,9 @@ function findBinary(startDir) {
|
|
|
74
169
|
const resolved = findBinary(scriptDir)
|
|
75
170
|
if (!resolved) {
|
|
76
171
|
console.error(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
172
|
+
"It seems that your package manager failed to install the right version of the matrix CLI for your platform. You can try manually installing " +
|
|
173
|
+
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
174
|
+
" package",
|
|
80
175
|
)
|
|
81
176
|
process.exit(1)
|
|
82
177
|
}
|
package/package.json
CHANGED
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.61",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"optionalDependencies": {
|
|
12
|
-
"matrix-
|
|
13
|
-
"matrix-linux-x64": "1.1.
|
|
14
|
-
"matrix-
|
|
15
|
-
"matrix-linux-
|
|
16
|
-
"matrix-
|
|
17
|
-
"matrix-linux-x64-baseline
|
|
18
|
-
"matrix-
|
|
19
|
-
"matrix-
|
|
20
|
-
"matrix-
|
|
21
|
-
"matrix-darwin-x64-baseline": "1.1.
|
|
22
|
-
"matrix-darwin-x64": "1.1.
|
|
12
|
+
"matrix-linux-arm64": "1.1.61",
|
|
13
|
+
"matrix-linux-x64": "1.1.61",
|
|
14
|
+
"matrix-windows-x64": "1.1.61",
|
|
15
|
+
"matrix-linux-x64-musl": "1.1.61",
|
|
16
|
+
"matrix-windows-x64-baseline": "1.1.61",
|
|
17
|
+
"matrix-linux-x64-baseline": "1.1.61",
|
|
18
|
+
"matrix-linux-arm64-musl": "1.1.61",
|
|
19
|
+
"matrix-linux-x64-baseline-musl": "1.1.61",
|
|
20
|
+
"matrix-darwin-arm64": "1.1.61",
|
|
21
|
+
"matrix-darwin-x64-baseline": "1.1.61",
|
|
22
|
+
"matrix-darwin-x64": "1.1.61"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -109,8 +109,14 @@ async function main() {
|
|
|
109
109
|
// On non-Windows platforms, just verify the binary package exists
|
|
110
110
|
// Don't replace the wrapper script - it handles binary execution
|
|
111
111
|
const { binaryPath } = findBinary()
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const target = path.join(__dirname, "bin", ".opencode")
|
|
113
|
+
if (fs.existsSync(target)) fs.unlinkSync(target)
|
|
114
|
+
try {
|
|
115
|
+
fs.linkSync(binaryPath, target)
|
|
116
|
+
} catch {
|
|
117
|
+
fs.copyFileSync(binaryPath, target)
|
|
118
|
+
}
|
|
119
|
+
fs.chmodSync(target, 0o755)
|
|
114
120
|
} catch (error) {
|
|
115
121
|
console.error("Failed to setup matrix binary:", error.message)
|
|
116
122
|
process.exit(1)
|