slopcode 0.2.105 → 0.2.109

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 CHANGED
@@ -40,18 +40,21 @@ 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"],
46
47
  }
47
48
 
48
- let platform = platformMap[os.platform()]
49
+ const rawPlatform = process.env.SLOPCODE_TEST_PLATFORM || os.platform()
50
+ const rawArch = process.env.SLOPCODE_TEST_ARCH || os.arch()
51
+ let platform = platformMap[rawPlatform]
49
52
  if (!platform) {
50
- platform = os.platform()
53
+ platform = rawPlatform
51
54
  }
52
- let arch = archMap[os.arch()]
55
+ let arch = archMap[rawArch]
53
56
  if (!arch) {
54
- arch = os.arch()
57
+ arch = rawArch
55
58
  }
56
59
  const binary = platform === "windows" ? "slopcode.exe" : "slopcode"
57
60
 
@@ -66,7 +69,12 @@ function clearCache() {
66
69
  remove(sidecar)
67
70
  }
68
71
 
72
+ function termuxEnv() {
73
+ return Boolean(process.env.TERMUX_VERSION || (process.env.PREFIX || "").includes("/com.termux/"))
74
+ }
75
+
69
76
  function libc() {
77
+ if (platform === "android") return "bionic"
70
78
  if (platform !== "linux") return
71
79
  const report = process.report?.getReport?.()
72
80
  if (typeof report?.header?.glibcVersionRuntime === "string" && report.header.glibcVersionRuntime) {
@@ -86,6 +94,7 @@ function libc() {
86
94
  const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
87
95
  if (text.includes("musl")) return "musl"
88
96
  if (text.includes("glibc") || text.includes("gnu libc")) return "glibc"
97
+ if (text.includes("bionic") || termuxEnv()) return "bionic"
89
98
  const loader = arch === "arm64" ? "/lib/ld-musl-aarch64.so.1" : arch === "x64" ? "/lib/ld-musl-x86_64.so.1" : ""
90
99
  if (loader && fs.existsSync(loader)) return "musl"
91
100
  }
@@ -127,10 +136,11 @@ function supportsAvx2() {
127
136
  }
128
137
 
129
138
  function names(prefix) {
130
- const base = `${prefix}-${platform}-${arch}`
139
+ const kind = libc()
140
+ const base = kind === "bionic" ? `${prefix}-android-${arch}` : `${prefix}-${platform}-${arch}`
141
+ if (kind === "bionic") return [`@slopcode-ai/slopcode-android-${arch}`, base]
131
142
  const avx2 = supportsAvx2()
132
143
  const baseline = arch === "x64" && !avx2
133
- const kind = libc()
134
144
 
135
145
  if (platform === "linux") {
136
146
  if (kind === "musl") {
@@ -194,9 +204,23 @@ function supportedMessage() {
194
204
  .join(" ")
195
205
  }
196
206
 
207
+ function termuxMessage() {
208
+ return [
209
+ "SlopCode native Termux support needs the Android runtime package.",
210
+ "Install from Termux with optional npm dependencies enabled:",
211
+ " pkg update",
212
+ " pkg install nodejs git ripgrep neovim",
213
+ " npm install -g slopcode@latest",
214
+ "If npm skipped optional dependencies, rerun with:",
215
+ " npm install -g slopcode@latest --include=optional",
216
+ ].join("\n")
217
+ }
218
+
219
+ const useCache = libc() !== "bionic"
220
+
197
221
  const packageNames = names("slopcode-bin")
198
222
  const resolvedNames = Array.from(new Set([...packageNames, ...names("slopcode")]))
199
- const hit = cacheReady(resolvedNames)
223
+ const hit = useCache ? cacheReady(resolvedNames) : undefined
200
224
  if (hit) {
201
225
  run(hit)
202
226
  }
@@ -240,6 +264,10 @@ function findBinary(startDir) {
240
264
 
241
265
  const resolved = resolveBinary() || findBinary(scriptDir)
242
266
  if (!resolved) {
267
+ if (libc() === "bionic") {
268
+ console.error(termuxMessage())
269
+ process.exit(1)
270
+ }
243
271
  console.error(
244
272
  "It seems that your package manager failed to install the right version of the slopcode CLI for your platform. You can try manually installing " +
245
273
  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.105",
37
+ "version": "0.2.109",
38
38
  "license": "MIT",
39
39
  "optionalDependencies": {
40
- "slopcode-bin-darwin-arm64": "0.2.105",
41
- "slopcode-bin-linux-x64-baseline": "0.2.105",
42
- "slopcode-bin-windows-x64": "0.2.105",
43
- "slopcode-bin-linux-x64": "0.2.105",
44
- "slopcode-bin-linux-x64-baseline-musl": "0.2.105",
45
- "slopcode-bin-linux-x64-musl": "0.2.105",
46
- "slopcode-bin-linux-arm64": "0.2.105",
47
- "slopcode-bin-windows-x64-baseline": "0.2.105",
48
- "slopcode-bin-linux-arm64-musl": "0.2.105",
49
- "slopcode-bin-darwin-x64-baseline": "0.2.105",
50
- "slopcode-bin-darwin-x64": "0.2.105"
40
+ "slopcode-bin-darwin-arm64": "0.2.109",
41
+ "slopcode-bin-linux-x64-baseline": "0.2.109",
42
+ "slopcode-bin-windows-x64": "0.2.109",
43
+ "slopcode-bin-linux-x64": "0.2.109",
44
+ "slopcode-bin-linux-x64-baseline-musl": "0.2.109",
45
+ "slopcode-bin-linux-x64-musl": "0.2.109",
46
+ "slopcode-bin-linux-arm64": "0.2.109",
47
+ "slopcode-bin-windows-x64-baseline": "0.2.109",
48
+ "slopcode-bin-linux-arm64-musl": "0.2.109",
49
+ "slopcode-bin-darwin-x64-baseline": "0.2.109",
50
+ "slopcode-bin-darwin-x64": "0.2.109"
51
51
  }
52
52
  }
package/postinstall.mjs CHANGED
@@ -10,28 +10,36 @@ 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"],
16
17
  }
17
18
 
18
19
  function detectPlatformAndArch() {
20
+ const rawPlatform = process.env.SLOPCODE_TEST_PLATFORM || os.platform()
21
+ const rawArch = process.env.SLOPCODE_TEST_ARCH || os.arch()
19
22
  const platform =
20
23
  {
21
24
  darwin: "darwin",
22
25
  linux: "linux",
23
26
  win32: "windows",
24
- }[os.platform()] ?? os.platform()
27
+ }[rawPlatform] ?? rawPlatform
25
28
  const arch =
26
29
  {
27
30
  x64: "x64",
28
31
  arm64: "arm64",
29
32
  arm: "arm",
30
- }[os.arch()] ?? os.arch()
33
+ }[rawArch] ?? rawArch
31
34
  return { platform, arch }
32
35
  }
33
36
 
37
+ function termuxEnv() {
38
+ return Boolean(process.env.TERMUX_VERSION || (process.env.PREFIX || "").includes("/com.termux/"))
39
+ }
40
+
34
41
  function detectLibc(platform, arch) {
42
+ if (platform === "android") return "bionic"
35
43
  if (platform !== "linux") return
36
44
  const report = process.report?.getReport?.()
37
45
  if (typeof report?.header?.glibcVersionRuntime === "string" && report.header.glibcVersionRuntime) {
@@ -51,6 +59,7 @@ function detectLibc(platform, arch) {
51
59
  const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
52
60
  if (text.includes("musl")) return "musl"
53
61
  if (text.includes("glibc") || text.includes("gnu libc")) return "glibc"
62
+ if (text.includes("bionic") || termuxEnv()) return "bionic"
54
63
  const loader = arch === "arm64" ? "/lib/ld-musl-aarch64.so.1" : arch === "x64" ? "/lib/ld-musl-x86_64.so.1" : ""
55
64
  if (loader && fs.existsSync(loader)) return "musl"
56
65
  }
@@ -83,10 +92,11 @@ function supportsAvx2(platform, arch) {
83
92
  }
84
93
 
85
94
  function names(platform, arch) {
86
- const base = `slopcode-bin-${platform}-${arch}`
95
+ const libc = detectLibc(platform, arch)
96
+ const base = `slopcode-bin-${libc === "bionic" ? "android" : platform}-${arch}`
97
+ if (libc === "bionic") return [`@slopcode-ai/slopcode-android-${arch}`, base, `slopcode-android-${arch}`]
87
98
  const avx2 = supportsAvx2(platform, arch)
88
99
  const baseline = arch === "x64" && !avx2
89
- const libc = detectLibc(platform, arch)
90
100
 
91
101
  if (platform === "linux") {
92
102
  if (libc === "musl") {
@@ -130,6 +140,18 @@ function supportedMessage() {
130
140
  .join(" ")
131
141
  }
132
142
 
143
+ function termuxMessage() {
144
+ return [
145
+ "SlopCode native Termux support needs the Android runtime package.",
146
+ "Install from Termux with optional npm dependencies enabled:",
147
+ " pkg update",
148
+ " pkg install nodejs git ripgrep neovim",
149
+ " npm install -g slopcode@latest",
150
+ "If npm skipped optional dependencies, rerun with:",
151
+ " npm install -g slopcode@latest --include=optional",
152
+ ].join("\n")
153
+ }
154
+
133
155
  function findBinary() {
134
156
  const { platform, arch } = detectPlatformAndArch()
135
157
  const binaryName = platform === "windows" ? "slopcode.exe" : "slopcode"
@@ -193,6 +215,7 @@ function writeMeta(input) {
193
215
  async function main() {
194
216
  try {
195
217
  const { platform, arch } = detectPlatformAndArch()
218
+
196
219
  if (!(supported[platform] ?? []).includes(arch)) {
197
220
  clearCache()
198
221
  console.log(
@@ -209,10 +232,19 @@ async function main() {
209
232
  const found = findBinary()
210
233
  if (!found) {
211
234
  clearCache()
212
- console.log("No platform binary package detected during postinstall; runtime resolver will handle it")
235
+ console.log(
236
+ detectLibc(platform, arch) === "bionic"
237
+ ? termuxMessage()
238
+ : "No platform binary package detected during postinstall; runtime resolver will handle it",
239
+ )
213
240
  return
214
241
  }
215
242
 
243
+ if (found.libc === "bionic") {
244
+ clearCache()
245
+ console.log("Android/Termux runtime package detected; runtime resolver will launch it")
246
+ return
247
+ }
216
248
  clearCache()
217
249
  const target = path.join(__dirname, "bin", ".slopcode")
218
250
  const { targetPath } = prepareBinDirectory(".slopcode")