patchcord 0.3.37 → 0.3.38

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 +14 -13
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -546,20 +546,21 @@ if (!cmd || cmd === "install" || cmd === "agent") {
546
546
  mkdirSync(codexDir, { recursive: true });
547
547
  const configPath = join(codexDir, "config.toml");
548
548
  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);
549
+ // Remove old patchcord config block if present
550
+ existing = existing.replace(/\[mcp_servers\.patchcord\][^\[]*/s, "").replace(/\n{3,}/g, "\n\n").trim();
551
+ // Codex requires bearer_token via env var — http_headers not supported for auth
552
+ const envName = "PATCHCORD_TOKEN";
553
+ const envPath = join(cwd, ".env");
554
+ let envContent = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
555
+ // Replace or add token in .env
556
+ if (envContent.includes(envName)) {
557
+ envContent = envContent.replace(new RegExp(`${envName}=.*`), `${envName}=${token}`);
558
+ } else {
559
+ envContent = envContent.trimEnd() + `\n${envName}=${token}\n`;
562
560
  }
561
+ writeFileSync(envPath, envContent);
562
+ existing = existing.trimEnd() + `\n\n[mcp_servers.patchcord]\nurl = "${serverUrl}/mcp/bearer"\nbearer_token_env_var = "${envName}"\n`;
563
+ writeFileSync(configPath, existing);
563
564
  // Slash commands (.codex/prompts/)
564
565
  const codexPromptsDir = join(codexDir, "prompts");
565
566
  mkdirSync(codexPromptsDir, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.3.37",
3
+ "version": "0.3.38",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",