@apm-cli/apm 0.0.0

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/apm +106 -0
  2. package/package.json +25 -0
package/bin/apm ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { execFileSync } = require("child_process");
6
+ const { join, dirname } = require("path");
7
+ const { existsSync } = require("fs");
8
+
9
+ // Map Node.js platform/arch to our npm package names
10
+ const PLATFORM_MAP = {
11
+ "darwin-arm64": "@apm-cli/darwin-arm64",
12
+ "darwin-x64": "@apm-cli/darwin-x64",
13
+ "linux-arm64": "@apm-cli/linux-arm64",
14
+ "linux-x64": "@apm-cli/linux-x64",
15
+ "win32-x64": "@apm-cli/win32-x64-msvc",
16
+ };
17
+
18
+ // On Linux x64, check for musl vs glibc
19
+ function getLinuxLibc() {
20
+ try {
21
+ const lddOutput = execFileSync("ldd", ["--version"], {
22
+ encoding: "utf8",
23
+ stdio: ["pipe", "pipe", "pipe"],
24
+ });
25
+ if (lddOutput.toLowerCase().includes("musl")) {
26
+ return "musl";
27
+ }
28
+ } catch {
29
+ // ldd --version exits non-zero on musl systems and prints to stderr
30
+ try {
31
+ const result = require("child_process").spawnSync("ldd", ["--version"], {
32
+ encoding: "utf8",
33
+ });
34
+ const output = (result.stdout || "") + (result.stderr || "");
35
+ if (output.toLowerCase().includes("musl")) {
36
+ return "musl";
37
+ }
38
+ } catch {
39
+ // Fall through to glibc default
40
+ }
41
+ }
42
+ return "glibc";
43
+ }
44
+
45
+ function getBinaryPath() {
46
+ const platform = process.platform;
47
+ const arch = process.arch;
48
+ let key = `${platform}-${arch}`;
49
+
50
+ // Check for musl on Linux x64
51
+ if (platform === "linux" && arch === "x64" && getLinuxLibc() === "musl") {
52
+ key = "linux-x64-musl";
53
+ }
54
+
55
+ // Try the platform-specific package first
56
+ const packageName = key === "linux-x64-musl" ? "@apm-cli/linux-x64-musl" : PLATFORM_MAP[key];
57
+
58
+ if (!packageName) {
59
+ console.error(
60
+ `Error: Unsupported platform ${platform}-${arch}.\n` +
61
+ `APM supports: ${Object.keys(PLATFORM_MAP).join(", ")}, linux-x64-musl`
62
+ );
63
+ process.exit(1);
64
+ }
65
+
66
+ // Resolve the binary from the platform package
67
+ const binName = platform === "win32" ? "apm.exe" : "apm";
68
+
69
+ try {
70
+ const pkgPath = require.resolve(`${packageName}/package.json`);
71
+ const binPath = join(dirname(pkgPath), "bin", binName);
72
+ if (existsSync(binPath)) {
73
+ return binPath;
74
+ }
75
+ } catch {
76
+ // Package not installed
77
+ }
78
+
79
+ console.error(
80
+ `Error: Could not find the APM binary for your platform (${key}).\n` +
81
+ `Expected package: ${packageName}\n\n` +
82
+ `Try reinstalling with:\n` +
83
+ ` npm install -g @apm-cli/apm\n`
84
+ );
85
+ process.exit(1);
86
+ }
87
+
88
+ const binPath = getBinaryPath();
89
+ const args = process.argv.slice(2);
90
+
91
+ try {
92
+ const result = require("child_process").spawnSync(binPath, args, {
93
+ stdio: "inherit",
94
+ windowsHide: false,
95
+ });
96
+
97
+ if (result.error) {
98
+ throw result.error;
99
+ }
100
+
101
+ process.exit(result.status ?? 1);
102
+ } catch (err) {
103
+ console.error(`Error: Failed to execute APM binary at ${binPath}`);
104
+ console.error(err.message);
105
+ process.exit(1);
106
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@apm-cli/apm",
3
+ "version": "0.0.0",
4
+ "description": "Agent Package Manager — a package manager for agent skills",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/orthogonal-dev/apm"
9
+ },
10
+ "homepage": "https://apm.orthg.nl",
11
+ "bin": {
12
+ "apm": "bin/apm"
13
+ },
14
+ "optionalDependencies": {
15
+ "@apm-cli/linux-x64": "0.0.0",
16
+ "@apm-cli/linux-arm64": "0.0.0",
17
+ "@apm-cli/linux-x64-musl": "0.0.0",
18
+ "@apm-cli/darwin-x64": "0.0.0",
19
+ "@apm-cli/darwin-arm64": "0.0.0",
20
+ "@apm-cli/win32-x64-msvc": "0.0.0"
21
+ },
22
+ "engines": {
23
+ "node": ">=16"
24
+ }
25
+ }