@momo792/agentsmd 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/bin/agentsmd.js +14 -12
  2. package/package.json +1 -1
package/bin/agentsmd.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // agentsmd npm shim: resolve the platform binary and forward execution.
3
3
  const { spawnSync } = require("child_process");
4
+ const fs = require("fs");
4
5
  const path = require("path");
5
6
 
6
7
  const plat = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
@@ -10,19 +11,20 @@ if (!plat || !arch) {
10
11
  process.exit(1);
11
12
  }
12
13
  const ext = process.platform === "win32" ? ".exe" : "";
13
- const bin = path.join(__dirname, "..", "..", `agentsmd-${plat}-${arch}`, "bin", `agentsmd${ext}`);
14
+ const pkg = `agentsmd-${plat}-${arch}`;
15
+ const bin = path.join(pkg, "bin", `agentsmd${ext}`);
14
16
 
15
- let result;
16
- try {
17
- result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
18
- } catch (e) {
19
- console.error(`agentsmd: failed to run ${bin}: ${e.message}`);
20
- console.error("reinstall with: npm install agentsmd --force, or use: go install github.com/youwei792/agentsmd@latest");
21
- process.exit(1);
22
- }
23
- if (result.error) {
24
- console.error(`agentsmd: platform binary missing (${result.error.message})`);
25
- console.error("reinstall with: npm install agentsmd --force, or use: go install github.com/youwei792/agentsmd@latest");
17
+ // The platform package lands in different places depending on whether this
18
+ // package is installed scoped (nested node_modules) or unscoped (flat).
19
+ const candidates = [
20
+ path.join(__dirname, "..", "node_modules", bin), // scoped main, nested deps
21
+ path.join(__dirname, "..", "..", pkg, "bin", `agentsmd${ext}`), // unscoped main, flat
22
+ path.join(__dirname, "..", "..", "..", bin), // scoped main, flat sibling
23
+ ];
24
+ const binPath = candidates.find((p) => fs.existsSync(p));
25
+ if (!binPath) {
26
+ console.error("agentsmd: platform binary missing (reinstall with: npm install -g @momo792/agentsmd --force)");
26
27
  process.exit(1);
27
28
  }
29
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit" });
28
30
  process.exit(result.status ?? 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo792/agentsmd",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "CI for your AI agent's instructions: validate AGENTS.md, bridge CLAUDE.md. Zero-dependency Go binary.",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/youwei792/agentsmd",