@clanker-code/c2c 0.9.1 → 0.11.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.
@@ -10,6 +10,25 @@ function executableForWrapper(argv1) {
10
10
  return basename.startsWith("c2c-deliver-inbox") ? "c2c-deliver-inbox" : "c2c";
11
11
  }
12
12
 
13
+ function packageManagerForWrapper(selfPath, env = process.env) {
14
+ const userAgent = env.npm_config_user_agent || "";
15
+ if (userAgent.startsWith("pnpm/")) {
16
+ return "pnpm";
17
+ }
18
+ if (userAgent.startsWith("bun/")) {
19
+ return "bun";
20
+ }
21
+
22
+ const normalizedPath = selfPath.replace(/\\/g, "/").toLowerCase();
23
+ if (normalizedPath.includes("/.bun/install/global/")) {
24
+ return "bun";
25
+ }
26
+ if (normalizedPath.includes("/pnpm/global/")) {
27
+ return "pnpm";
28
+ }
29
+ return "npm";
30
+ }
31
+
13
32
  function main() {
14
33
  const executable = executableForWrapper(process.argv[1]);
15
34
  let binary;
@@ -22,7 +41,14 @@ function main() {
22
41
 
23
42
  const result = childProcess.spawnSync(binary, process.argv.slice(2), {
24
43
  stdio: "inherit",
25
- env: process.env,
44
+ // The native binary cannot otherwise tell that it was launched by this
45
+ // npm package wrapper. Preserve the owning package manager so
46
+ // `c2c self-update` upgrades the package instead of replacing the bundled
47
+ // binary under node_modules.
48
+ env: {
49
+ ...process.env,
50
+ C2C_SELF_UPDATE_PACKAGE_MANAGER: packageManagerForWrapper(__filename),
51
+ },
26
52
  });
27
53
 
28
54
  if (result.error) {
@@ -38,4 +64,8 @@ function main() {
38
64
  process.exit(result.status === null ? 1 : result.status);
39
65
  }
40
66
 
41
- main();
67
+ if (require.main === module) {
68
+ main();
69
+ }
70
+
71
+ module.exports = { executableForWrapper, packageManagerForWrapper, main };
@@ -10,6 +10,25 @@ function executableForWrapper(argv1) {
10
10
  return basename.startsWith("c2c-deliver-inbox") ? "c2c-deliver-inbox" : "c2c";
11
11
  }
12
12
 
13
+ function packageManagerForWrapper(selfPath, env = process.env) {
14
+ const userAgent = env.npm_config_user_agent || "";
15
+ if (userAgent.startsWith("pnpm/")) {
16
+ return "pnpm";
17
+ }
18
+ if (userAgent.startsWith("bun/")) {
19
+ return "bun";
20
+ }
21
+
22
+ const normalizedPath = selfPath.replace(/\\/g, "/").toLowerCase();
23
+ if (normalizedPath.includes("/.bun/install/global/")) {
24
+ return "bun";
25
+ }
26
+ if (normalizedPath.includes("/pnpm/global/")) {
27
+ return "pnpm";
28
+ }
29
+ return "npm";
30
+ }
31
+
13
32
  function main() {
14
33
  const executable = executableForWrapper(process.argv[1]);
15
34
  let binary;
@@ -22,7 +41,14 @@ function main() {
22
41
 
23
42
  const result = childProcess.spawnSync(binary, process.argv.slice(2), {
24
43
  stdio: "inherit",
25
- env: process.env,
44
+ // The native binary cannot otherwise tell that it was launched by this
45
+ // npm package wrapper. Preserve the owning package manager so
46
+ // `c2c self-update` upgrades the package instead of replacing the bundled
47
+ // binary under node_modules.
48
+ env: {
49
+ ...process.env,
50
+ C2C_SELF_UPDATE_PACKAGE_MANAGER: packageManagerForWrapper(__filename),
51
+ },
26
52
  });
27
53
 
28
54
  if (result.error) {
@@ -38,4 +64,8 @@ function main() {
38
64
  process.exit(result.status === null ? 1 : result.status);
39
65
  }
40
66
 
41
- main();
67
+ if (require.main === module) {
68
+ main();
69
+ }
70
+
71
+ module.exports = { executableForWrapper, packageManagerForWrapper, main };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clanker-code/c2c",
3
- "version": "0.9.1",
3
+ "version": "0.11.0",
4
4
  "description": "Resolver and CLI wrapper for the c2c agent messaging binary",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,9 +17,9 @@
17
17
  "index.js"
18
18
  ],
19
19
  "optionalDependencies": {
20
- "@clanker-code/c2c-linux-x64": "0.9.1",
21
- "@clanker-code/c2c-linux-arm64": "0.9.1",
22
- "@clanker-code/c2c-darwin-x64": "0.9.1",
23
- "@clanker-code/c2c-darwin-arm64": "0.9.1"
20
+ "@clanker-code/c2c-linux-x64": "0.11.0",
21
+ "@clanker-code/c2c-linux-arm64": "0.11.0",
22
+ "@clanker-code/c2c-darwin-x64": "0.11.0",
23
+ "@clanker-code/c2c-darwin-arm64": "0.11.0"
24
24
  }
25
25
  }