patchcord 0.3.36 → 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.
- package/bin/patchcord.mjs +14 -3
- package/package.json +1 -1
package/bin/patchcord.mjs
CHANGED
|
@@ -546,10 +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
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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`;
|
|
552
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);
|
|
553
564
|
// Slash commands (.codex/prompts/)
|
|
554
565
|
const codexPromptsDir = join(codexDir, "prompts");
|
|
555
566
|
mkdirSync(codexPromptsDir, { recursive: true });
|