patchcord 0.5.96 → 0.5.97

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 +13 -10
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -1225,16 +1225,19 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
1225
1225
  copyFileSync(hookScriptSrc, hookScriptDest);
1226
1226
  chmodSync(hookScriptDest, 0o755);
1227
1227
 
1228
- // Enable hooks feature flag in config.toml if not already set
1229
- // Migrate any existing codex_hooks = true to hooks = true (deprecated)
1230
- if (globalCodexContent.includes("codex_hooks = true")) {
1231
- globalCodexContent = globalCodexContent.replace(/codex_hooks = true/g, "hooks = true");
1232
- } else if (!globalCodexContent.includes("hooks = true")) {
1233
- if (globalCodexContent.includes("[features]")) {
1234
- globalCodexContent = globalCodexContent.replace(/(\[features\])/, "$1\nhooks = true");
1235
- } else {
1236
- globalCodexContent = globalCodexContent.trimEnd() + "\n\n[features]\nhooks = true";
1237
- }
1228
+ // Enable the `hooks` feature flag exactly once. Older installs / Codex
1229
+ // versions may leave `codex_hooks = true`, `hooks=true` (no spaces), a
1230
+ // `hooks = false`, or even a duplicate `hooks = true` — any of which makes
1231
+ // config.toml fail to load with a "duplicate key" error. Strip every
1232
+ // feature-flag variant first, then add exactly one under [features].
1233
+ globalCodexContent = globalCodexContent
1234
+ .replace(/^[ \t]*(?:codex_)?hooks[ \t]*=[ \t]*(?:true|false)[ \t]*(?:#[^\n]*)?\r?\n?/gm, "")
1235
+ .replace(/\n{3,}/g, "\n\n")
1236
+ .trimEnd() + "\n";
1237
+ if (/^\[features\][ \t]*$/m.test(globalCodexContent)) {
1238
+ globalCodexContent = globalCodexContent.replace(/^(\[features\][ \t]*\r?\n)/m, "$1hooks = true\n");
1239
+ } else {
1240
+ globalCodexContent = globalCodexContent.trimEnd() + "\n\n[features]\nhooks = true\n";
1238
1241
  }
1239
1242
 
1240
1243
  // Remove any old patchcord stop hook entry from config.toml (moved to hooks.json)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.96",
3
+ "version": "0.5.97",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",