patchcord 0.3.37 → 0.3.39

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 +23 -13
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -408,6 +408,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
408
408
 
409
409
  rl.close();
410
410
 
411
+ const hostname = run("hostname -s") || run("hostname") || "unknown";
412
+
411
413
  if (isCursor) {
412
414
  // Cursor: write .cursor/mcp.json (per-project)
413
415
  const cursorDir = join(cwd, ".cursor");
@@ -422,6 +424,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
422
424
  serverUrl,
423
425
  "--header",
424
426
  `Authorization: Bearer ${token}`,
427
+ "--header",
428
+ `X-Patchcord-Machine: ${hostname}`,
425
429
  ],
426
430
  },
427
431
  },
@@ -453,6 +457,8 @@ if (!cmd || cmd === "install" || cmd === "agent") {
453
457
  serverUrl,
454
458
  "--header",
455
459
  `Authorization: Bearer ${token}`,
460
+ "--header",
461
+ `X-Patchcord-Machine: ${hostname}`,
456
462
  ],
457
463
  },
458
464
  },
@@ -494,6 +500,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
494
500
  httpUrl: `${serverUrl}/mcp`,
495
501
  headers: {
496
502
  Authorization: `Bearer ${token}`,
503
+ "X-Patchcord-Machine": hostname,
497
504
  },
498
505
  };
499
506
  // Clean up deprecated tools.allowed if present (removed in Gemini CLI 1.0)
@@ -517,6 +524,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
517
524
  url: `${serverUrl}/mcp`,
518
525
  headers: {
519
526
  Authorization: `Bearer ${token}`,
527
+ "X-Patchcord-Machine": hostname,
520
528
  },
521
529
  },
522
530
  },
@@ -546,20 +554,21 @@ if (!cmd || cmd === "install" || cmd === "agent") {
546
554
  mkdirSync(codexDir, { recursive: true });
547
555
  const configPath = join(codexDir, "config.toml");
548
556
  let existing = existsSync(configPath) ? readFileSync(configPath, "utf-8") : "";
549
- if (!existing.includes("[mcp_servers.patchcord]")) {
550
- // Codex requires bearer_token via env var — http_headers not supported for auth
551
- const envName = "PATCHCORD_TOKEN";
552
- process.env[envName] = token;
553
- // Write token to project .env for persistence
554
- const envPath = join(cwd, ".env");
555
- let envContent = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
556
- if (!envContent.includes(envName)) {
557
- envContent = envContent.trimEnd() + `\n${envName}=${token}\n`;
558
- writeFileSync(envPath, envContent);
559
- }
560
- existing = existing.trimEnd() + `\n\n[mcp_servers.patchcord]\nurl = "${serverUrl}/mcp/bearer"\nbearer_token_env_var = "${envName}"\n`;
561
- writeFileSync(configPath, existing);
557
+ // Remove old patchcord config block if present
558
+ existing = existing.replace(/\[mcp_servers\.patchcord\][^\[]*/s, "").replace(/\n{3,}/g, "\n\n").trim();
559
+ // Codex requires bearer_token via env var — http_headers not supported for auth
560
+ const envName = "PATCHCORD_TOKEN";
561
+ const envPath = join(cwd, ".env");
562
+ let envContent = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
563
+ // Replace or add token in .env
564
+ if (envContent.includes(envName)) {
565
+ envContent = envContent.replace(new RegExp(`${envName}=.*`), `${envName}=${token}`);
566
+ } else {
567
+ envContent = envContent.trimEnd() + `\n${envName}=${token}\n`;
562
568
  }
569
+ writeFileSync(envPath, envContent);
570
+ existing = existing.trimEnd() + `\n\n[mcp_servers.patchcord]\nurl = "${serverUrl}/mcp/bearer"\nbearer_token_env_var = "${envName}"\n`;
571
+ writeFileSync(configPath, existing);
563
572
  // Slash commands (.codex/prompts/)
564
573
  const codexPromptsDir = join(codexDir, "prompts");
565
574
  mkdirSync(codexPromptsDir, { recursive: true });
@@ -577,6 +586,7 @@ if (!cmd || cmd === "install" || cmd === "agent") {
577
586
  url: `${serverUrl}/mcp`,
578
587
  headers: {
579
588
  Authorization: `Bearer ${token}`,
589
+ "X-Patchcord-Machine": hostname,
580
590
  },
581
591
  },
582
592
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.3.37",
3
+ "version": "0.3.39",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",