slopcode 0.2.106 → 0.2.110
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/slopcode +15 -16
- package/package.json +12 -12
- package/postinstall.mjs +78 -14
package/bin/slopcode
CHANGED
|
@@ -40,6 +40,7 @@ const archMap = {
|
|
|
40
40
|
arm: "arm",
|
|
41
41
|
}
|
|
42
42
|
const supported = {
|
|
43
|
+
android: ["arm64", "x64"],
|
|
43
44
|
darwin: ["arm64", "x64"],
|
|
44
45
|
linux: ["arm64", "x64"],
|
|
45
46
|
windows: ["x64"],
|
|
@@ -136,9 +137,8 @@ function supportsAvx2() {
|
|
|
136
137
|
|
|
137
138
|
function names(prefix) {
|
|
138
139
|
const kind = libc()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const base = `${prefix}-${platform}-${arch}`
|
|
140
|
+
const base = kind === "bionic" ? `${prefix}-android-${arch}` : `${prefix}-${platform}-${arch}`
|
|
141
|
+
if (kind === "bionic") return [`@slopcode-ai/slopcode-android-${arch}`, base]
|
|
142
142
|
const avx2 = supportsAvx2()
|
|
143
143
|
const baseline = arch === "x64" && !avx2
|
|
144
144
|
|
|
@@ -206,25 +206,20 @@ function supportedMessage() {
|
|
|
206
206
|
|
|
207
207
|
function termuxMessage() {
|
|
208
208
|
return [
|
|
209
|
-
"SlopCode
|
|
210
|
-
"
|
|
211
|
-
" pkg
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
" curl -fsSL https://slopcode.dev/install | bash",
|
|
209
|
+
"SlopCode native Termux support could not find the Android runtime.",
|
|
210
|
+
"Reinstall from Termux with:",
|
|
211
|
+
" pkg update",
|
|
212
|
+
" pkg install nodejs git ripgrep neovim tar",
|
|
213
|
+
" npm install -g slopcode@latest --include=optional",
|
|
214
|
+
"If postinstall could not download the runtime, install the matching GitHub release asset manually.",
|
|
216
215
|
].join("\n")
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
|
|
220
|
-
clearCache()
|
|
221
|
-
console.error(termuxMessage())
|
|
222
|
-
process.exit(1)
|
|
223
|
-
}
|
|
218
|
+
const useCache = libc() !== "bionic"
|
|
224
219
|
|
|
225
220
|
const packageNames = names("slopcode-bin")
|
|
226
221
|
const resolvedNames = Array.from(new Set([...packageNames, ...names("slopcode")]))
|
|
227
|
-
const hit = cacheReady(resolvedNames)
|
|
222
|
+
const hit = useCache ? cacheReady(resolvedNames) : undefined
|
|
228
223
|
if (hit) {
|
|
229
224
|
run(hit)
|
|
230
225
|
}
|
|
@@ -268,6 +263,10 @@ function findBinary(startDir) {
|
|
|
268
263
|
|
|
269
264
|
const resolved = resolveBinary() || findBinary(scriptDir)
|
|
270
265
|
if (!resolved) {
|
|
266
|
+
if (libc() === "bionic") {
|
|
267
|
+
console.error(termuxMessage())
|
|
268
|
+
process.exit(1)
|
|
269
|
+
}
|
|
271
270
|
console.error(
|
|
272
271
|
"It seems that your package manager failed to install the right version of the slopcode CLI for your platform. You can try manually installing " +
|
|
273
272
|
packageNames.map((n) => `\"${n}\"`).join(" or ") +
|
package/package.json
CHANGED
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
36
36
|
},
|
|
37
|
-
"version": "0.2.
|
|
37
|
+
"version": "0.2.110",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"slopcode-bin-darwin-arm64": "0.2.
|
|
41
|
-
"slopcode-bin-linux-x64-baseline": "0.2.
|
|
42
|
-
"slopcode-bin-windows-x64": "0.2.
|
|
43
|
-
"slopcode-bin-linux-x64": "0.2.
|
|
44
|
-
"slopcode-bin-linux-x64-baseline-musl": "0.2.
|
|
45
|
-
"slopcode-bin-linux-x64-musl": "0.2.
|
|
46
|
-
"slopcode-bin-linux-arm64": "0.2.
|
|
47
|
-
"slopcode-bin-windows-x64-baseline": "0.2.
|
|
48
|
-
"slopcode-bin-linux-arm64-musl": "0.2.
|
|
49
|
-
"slopcode-bin-darwin-x64-baseline": "0.2.
|
|
50
|
-
"slopcode-bin-darwin-x64": "0.2.
|
|
40
|
+
"slopcode-bin-darwin-arm64": "0.2.110",
|
|
41
|
+
"slopcode-bin-linux-x64-baseline": "0.2.110",
|
|
42
|
+
"slopcode-bin-windows-x64": "0.2.110",
|
|
43
|
+
"slopcode-bin-linux-x64": "0.2.110",
|
|
44
|
+
"slopcode-bin-linux-x64-baseline-musl": "0.2.110",
|
|
45
|
+
"slopcode-bin-linux-x64-musl": "0.2.110",
|
|
46
|
+
"slopcode-bin-linux-arm64": "0.2.110",
|
|
47
|
+
"slopcode-bin-windows-x64-baseline": "0.2.110",
|
|
48
|
+
"slopcode-bin-linux-arm64-musl": "0.2.110",
|
|
49
|
+
"slopcode-bin-darwin-x64-baseline": "0.2.110",
|
|
50
|
+
"slopcode-bin-darwin-x64": "0.2.110"
|
|
51
51
|
}
|
|
52
52
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -10,6 +10,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
10
10
|
const require = createRequire(import.meta.url)
|
|
11
11
|
const pkg = require("./package.json")
|
|
12
12
|
const supported = {
|
|
13
|
+
android: ["arm64", "x64"],
|
|
13
14
|
darwin: ["arm64", "x64"],
|
|
14
15
|
linux: ["arm64", "x64"],
|
|
15
16
|
windows: ["x64"],
|
|
@@ -91,9 +92,9 @@ function supportsAvx2(platform, arch) {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
function names(platform, arch) {
|
|
94
|
-
const base = `slopcode-bin-${platform}-${arch}`
|
|
95
95
|
const libc = detectLibc(platform, arch)
|
|
96
|
-
|
|
96
|
+
const base = `slopcode-bin-${libc === "bionic" ? "android" : platform}-${arch}`
|
|
97
|
+
if (libc === "bionic") return [`@slopcode-ai/slopcode-android-${arch}`, base, `slopcode-android-${arch}`]
|
|
97
98
|
const avx2 = supportsAvx2(platform, arch)
|
|
98
99
|
const baseline = arch === "x64" && !avx2
|
|
99
100
|
|
|
@@ -141,16 +142,69 @@ function supportedMessage() {
|
|
|
141
142
|
|
|
142
143
|
function termuxMessage() {
|
|
143
144
|
return [
|
|
144
|
-
"SlopCode
|
|
145
|
-
"
|
|
146
|
-
" pkg
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
" curl -fsSL https://slopcode.dev/install | bash",
|
|
145
|
+
"SlopCode native Termux support could not install the Android runtime.",
|
|
146
|
+
"Install from Termux with:",
|
|
147
|
+
" pkg update",
|
|
148
|
+
" pkg install nodejs git ripgrep neovim tar",
|
|
149
|
+
" npm install -g slopcode@latest --include=optional",
|
|
150
|
+
"If that still fails, install the matching GitHub release asset manually.",
|
|
151
151
|
].join("\n")
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
function androidPackage(arch) {
|
|
155
|
+
return `@slopcode-ai/slopcode-android-${arch}`
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function androidTarget(arch) {
|
|
159
|
+
return path.join(__dirname, "node_modules", "@slopcode-ai", `slopcode-android-${arch}`)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function androidUrl(arch) {
|
|
163
|
+
return `https://github.com/teamslop/slopcode/releases/download/v${pkg.version}/slopcode-android-${arch}.tar.gz`
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function androidAsset(arch, tmp) {
|
|
167
|
+
if (process.env.SLOPCODE_ANDROID_ASSET_PATH) return process.env.SLOPCODE_ANDROID_ASSET_PATH
|
|
168
|
+
const out = path.join(tmp, `slopcode-android-${arch}.tar.gz`)
|
|
169
|
+
const res = await fetch(process.env.SLOPCODE_ANDROID_ASSET_URL || androidUrl(arch))
|
|
170
|
+
if (!res.ok) throw new Error(`Failed to download Android runtime: ${res.status} ${res.statusText}`)
|
|
171
|
+
await fs.promises.writeFile(out, Buffer.from(await res.arrayBuffer()))
|
|
172
|
+
return out
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function installAndroid(arch) {
|
|
176
|
+
const tmp = await fs.promises.mkdtemp(path.join(os.tmpdir(), "slopcode-android-"))
|
|
177
|
+
const target = androidTarget(arch)
|
|
178
|
+
try {
|
|
179
|
+
const archive = await androidAsset(arch, tmp)
|
|
180
|
+
const extract = path.join(tmp, "package")
|
|
181
|
+
await fs.promises.mkdir(extract, { recursive: true })
|
|
182
|
+
const result = require("child_process").spawnSync("tar", ["-xzf", archive, "-C", extract], {
|
|
183
|
+
encoding: "utf8",
|
|
184
|
+
timeout: 120000,
|
|
185
|
+
})
|
|
186
|
+
if (result.status !== 0) {
|
|
187
|
+
throw new Error((result.stderr || result.stdout || "tar failed").trim())
|
|
188
|
+
}
|
|
189
|
+
const binary = path.join(extract, "bin", "slopcode")
|
|
190
|
+
if (!fs.existsSync(binary)) throw new Error("Downloaded Android runtime is missing bin/slopcode")
|
|
191
|
+
await fs.promises.rm(target, { recursive: true, force: true })
|
|
192
|
+
await fs.promises.mkdir(path.dirname(target), { recursive: true })
|
|
193
|
+
await fs.promises.rename(extract, target)
|
|
194
|
+
fs.chmodSync(path.join(target, "bin", "slopcode"), 0o755)
|
|
195
|
+
return {
|
|
196
|
+
binaryPath: path.join(target, "bin", "slopcode"),
|
|
197
|
+
binaryName: "slopcode",
|
|
198
|
+
packageName: androidPackage(arch),
|
|
199
|
+
platform: "android",
|
|
200
|
+
arch,
|
|
201
|
+
libc: "bionic",
|
|
202
|
+
}
|
|
203
|
+
} finally {
|
|
204
|
+
await fs.promises.rm(tmp, { recursive: true, force: true })
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
154
208
|
function findBinary() {
|
|
155
209
|
const { platform, arch } = detectPlatformAndArch()
|
|
156
210
|
const binaryName = platform === "windows" ? "slopcode.exe" : "slopcode"
|
|
@@ -214,11 +268,6 @@ function writeMeta(input) {
|
|
|
214
268
|
async function main() {
|
|
215
269
|
try {
|
|
216
270
|
const { platform, arch } = detectPlatformAndArch()
|
|
217
|
-
if (detectLibc(platform, arch) === "bionic") {
|
|
218
|
-
clearCache()
|
|
219
|
-
console.log(termuxMessage())
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
271
|
|
|
223
272
|
if (!(supported[platform] ?? []).includes(arch)) {
|
|
224
273
|
clearCache()
|
|
@@ -236,10 +285,25 @@ async function main() {
|
|
|
236
285
|
const found = findBinary()
|
|
237
286
|
if (!found) {
|
|
238
287
|
clearCache()
|
|
288
|
+
if (detectLibc(platform, arch) === "bionic") {
|
|
289
|
+
try {
|
|
290
|
+
await installAndroid(arch)
|
|
291
|
+
console.log("Android/Termux runtime installed from GitHub release asset")
|
|
292
|
+
} catch (error) {
|
|
293
|
+
console.log(termuxMessage())
|
|
294
|
+
console.error(error.message)
|
|
295
|
+
}
|
|
296
|
+
return
|
|
297
|
+
}
|
|
239
298
|
console.log("No platform binary package detected during postinstall; runtime resolver will handle it")
|
|
240
299
|
return
|
|
241
300
|
}
|
|
242
301
|
|
|
302
|
+
if (found.libc === "bionic") {
|
|
303
|
+
clearCache()
|
|
304
|
+
console.log("Android/Termux runtime package detected; runtime resolver will launch it")
|
|
305
|
+
return
|
|
306
|
+
}
|
|
243
307
|
clearCache()
|
|
244
308
|
const target = path.join(__dirname, "bin", ".slopcode")
|
|
245
309
|
const { targetPath } = prepareBinDirectory(".slopcode")
|