anymous 1.6.8 → 1.6.10

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/anymous.mjs CHANGED
@@ -1,24 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawnSync } from "child_process"
4
- import fs from "fs"
5
- import path from "path"
6
- import { fileURLToPath } from "url"
4
+ import { ensureBinary } from "../postinstall.mjs"
7
5
 
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
- const binaryPath = path.join(__dirname, "anymous.exe")
10
-
11
- if (!fs.existsSync(binaryPath)) {
12
- console.error(
13
- "Error: anymous binary not found at",
14
- binaryPath,
15
- "\n\nThis occurs when using --ignore-scripts during installation, or when using a",
16
- "\npackage manager like pnpm that does not run postinstall scripts by default.",
17
- )
6
+ const binary = ensureBinary()
7
+ if (!binary) {
8
+ console.error("Error: no anymous binary is available for this platform.")
9
+ console.error("Install a supported platform or build from source: https://github.com/anymousdark/anymous")
18
10
  process.exit(1)
19
11
  }
20
12
 
21
- const result = spawnSync(binaryPath, process.argv.slice(2), {
13
+ const result = spawnSync(binary, process.argv.slice(2), {
22
14
  stdio: "inherit",
23
15
  windowsHide: true,
24
16
  })
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
- // anymous is distributed as native platform binaries selected at install time
3
- // via optionalDependencies + postinstall. This entry point exists so package
4
- // analyzers can resolve the module; consumers should use the "anymous" bin.
2
+ // anymous is distributed as native platform binaries resolved at first run
3
+ // via optionalDependencies (no install scripts). This entry point exists so
4
+ // package analyzers can resolve the module; consumers should use the "anymous" bin.
5
5
  module.exports = {
6
6
  name: "anymous",
7
- version: "1.6.8",
7
+ version: "1.6.10",
8
8
  description: "AI-powered reverse engineering platform",
9
9
  bin: "bin/anymous.mjs",
10
10
  };
package/package.json CHANGED
@@ -5,10 +5,7 @@
5
5
  "bin": {
6
6
  "anymous": "./bin/anymous.mjs"
7
7
  },
8
- "scripts": {
9
- "postinstall": "node ./postinstall.mjs"
10
- },
11
- "version": "1.6.8",
8
+ "version": "1.6.10",
12
9
  "description": "AI-powered reverse engineering platform",
13
10
  "license": "MIT",
14
11
  "homepage": "https://github.com/anymousdark/anymous",
@@ -26,6 +23,6 @@
26
23
  "x64"
27
24
  ],
28
25
  "optionalDependencies": {
29
- "anymous-windows-x64": "1.6.8"
26
+ "anymous-windows-x64": "1.6.10"
30
27
  }
31
28
  }
package/postinstall.mjs CHANGED
@@ -127,14 +127,15 @@ function installPackage(name) {
127
127
  const version = packageJson.optionalDependencies?.[name]
128
128
  if (!version) return
129
129
 
130
- // On Windows, bare "npm" is not an executable (npm.cmd is).
130
+ // NOTE: .cmd launchers require shell:true on Windows (spawnSync fails with
131
+ // EINVAL otherwise); windowsHide keeps the popup console away.
131
132
  const npmBin = process.platform === "win32" ? "npm.cmd" : "npm"
132
133
  const temp = fs.mkdtempSync(path.join(os.tmpdir(), "anymous-install-"))
133
134
  try {
134
135
  const result = childProcess.spawnSync(
135
136
  npmBin,
136
137
  ["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
137
- { stdio: "inherit", windowsHide: true },
138
+ { stdio: "inherit", windowsHide: true, shell: process.platform === "win32" },
138
139
  )
139
140
  if (result.status !== 0) return
140
141
  const packageDir = path.join(temp, "node_modules", name)
@@ -183,7 +184,19 @@ function copySkills() {
183
184
  return true
184
185
  }
185
186
 
186
- function main() {
187
+ import { pathToFileURL } from "url"
188
+
189
+ /**
190
+ * Ensures a verified platform binary exists at bin/anymous.exe and returns
191
+ * its path, or undefined when no binary could be obtained.
192
+ *
193
+ * Resolution order (no install scripts involved, so npm allow-scripts gating,
194
+ * pnpm strict mode and --omit=optional all keep working):
195
+ * 1. optionalDependency installed alongside the wrapper,
196
+ * 2. previously fetched copy,
197
+ * 3. on-demand fetch from the npm registry (retried every run until present).
198
+ */
199
+ export function ensureBinary() {
187
200
  for (const name of packageNames()) {
188
201
  try {
189
202
  copyBinary(resolveBinary(name), targetBinary)
@@ -193,24 +206,40 @@ function main() {
193
206
  }
194
207
  }
195
208
 
196
- if (!fs.existsSync(targetBinary)) {
209
+ if (!fs.existsSync(targetBinary)) return undefined
210
+
211
+ try {
212
+ copySkills()
213
+ } catch (error) {
214
+ console.error("anymous: could not install bundled skills:", error.message)
215
+ }
216
+ return targetBinary
217
+ }
218
+
219
+ function main() {
220
+ const binary = ensureBinary()
221
+ if (!binary) {
197
222
  throw new Error(
198
223
  `It seems your package manager failed to install the right anymous CLI package. Try manually installing ${packageNames()
199
224
  .map((name) => JSON.stringify(name))
200
225
  .join(" or ")}.`,
201
226
  )
202
227
  }
228
+ }
203
229
 
230
+ const invokedDirectly = (() => {
204
231
  try {
205
- copySkills()
206
- } catch (error) {
207
- console.error("anymous: could not install bundled skills:", error.message)
232
+ return !!process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href
233
+ } catch {
234
+ return false
208
235
  }
209
- }
236
+ })()
210
237
 
211
- try {
212
- main()
213
- } catch (error) {
214
- console.error(error.message)
215
- process.exit(1)
238
+ if (invokedDirectly) {
239
+ try {
240
+ main()
241
+ } catch (error) {
242
+ console.error(error.message)
243
+ process.exit(1)
244
+ }
216
245
  }