patchcord 0.5.47 → 0.5.49

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/patchcord.mjs +29 -3
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -12,6 +12,13 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
12
12
  const pluginRoot = join(__dirname, "..");
13
13
  const cmd = process.argv[2];
14
14
 
15
+ if (cmd === "--version" || cmd === "-v") {
16
+ const { readFileSync: _rf } = await import("fs");
17
+ const { version } = JSON.parse(_rf(join(__dirname, "..", "package.json"), "utf-8"));
18
+ process.stdout.write(`${version}\n`);
19
+ process.exit(0);
20
+ }
21
+
15
22
  function run(cmd) {
16
23
  try {
17
24
  return execSync(cmd, { stdio: "pipe", encoding: "utf-8" }).trim();
@@ -386,12 +393,31 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
386
393
  // ── Install patchcord as a global CLI tool ───────────────────
387
394
  // Avoids relying on `npx patchcord subscribe` which is subject to npx
388
395
  // caching and supply-chain-protection min-release-age policies that
389
- // cause npx to silently downgrade to an older version.
390
- // --prefer-offline reuses what npx already downloaded no extra network.
391
- run(`npm install -g patchcord@${currentVersion} --prefer-offline`);
396
+ // silently downgrade to older cached versions.
397
+ // If npm install -g fails (e.g. system npm requires sudo), fall back to
398
+ // copying the package to a stable local path and writing a wrapper there.
399
+ // The fallback MUST NOT point to the npx cache — that gets swept on each install.
400
+ let globalCliInstalled = false;
401
+ try {
402
+ execSync(`npm install -g patchcord@${currentVersion}`, { stdio: "pipe" });
403
+ globalCliInstalled = true;
404
+ } catch {
405
+ try {
406
+ const stableDir = join(HOME, ".local", "share", "patchcord");
407
+ mkdirSync(stableDir, { recursive: true });
408
+ cpSync(pluginRoot, stableDir, { recursive: true, force: true });
409
+ const localBin = join(HOME, ".local", "bin");
410
+ mkdirSync(localBin, { recursive: true });
411
+ const wrapper = join(localBin, "patchcord");
412
+ writeFileSync(wrapper, `#!/bin/sh\nexec node "${join(stableDir, "bin", "patchcord.mjs")}" "$@"\n`);
413
+ chmodSync(wrapper, 0o755);
414
+ globalCliInstalled = true;
415
+ } catch {}
416
+ }
392
417
 
393
418
  // ── Global setup (silent if nothing changed) ──
394
419
  let globalChanges = [];
420
+ if (globalCliInstalled) globalChanges.push("Patchcord CLI installed globally");
395
421
 
396
422
  // Claude Code
397
423
  const hasClaude = run("which claude");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.47",
3
+ "version": "0.5.49",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",