patchcord 0.5.21 → 0.5.22

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 -6
  2. package/package.json +1 -1
package/bin/patchcord.mjs CHANGED
@@ -299,7 +299,7 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
299
299
  copyFileSync(hookScriptSrc, hookScriptDest);
300
300
  chmodSync(hookScriptDest, 0o755);
301
301
 
302
- // Enable codex_hooks feature flag if not already set
302
+ // Enable codex_hooks feature flag in config.toml if not already set
303
303
  if (!globalCodexContent.includes("codex_hooks")) {
304
304
  if (globalCodexContent.includes("[features]")) {
305
305
  globalCodexContent = globalCodexContent.replace(/(\[features\])/, "$1\ncodex_hooks = true");
@@ -308,11 +308,19 @@ if (!cmd || cmd === "install" || cmd === "agent" || cmd?.startsWith("--")) {
308
308
  }
309
309
  }
310
310
 
311
- // Remove old patchcord stop hook entry (handles updates path may change across npm cache installs)
312
- globalCodexContent = globalCodexContent.replace(/\[\[hooks\.Stop\]\]\nhooks = \[.*patchcord-stop-hook.*\]\n?/g, "").replace(/\n{3,}/g, "\n\n").trim();
313
-
314
- // Add fresh entry
315
- globalCodexContent = globalCodexContent.trimEnd() + `\n\n[[hooks.Stop]]\nhooks = [{ type = "command", command = "${hookScriptDest}", timeout = 10 }]\n`;
311
+ // Remove any old patchcord stop hook entry from config.toml (moved to hooks.json)
312
+ globalCodexContent = globalCodexContent.replace(/\[\[hooks\.Stop\]\]\nhooks = \[.*patchcord-stop-hook.*\]\n?/g, "").replace(/\n{3,}/g, "\n\n").trim() + "\n";
313
+
314
+ // Write Stop hook to hooks.json (avoid dual-source warning when both config.toml and hooks.json exist)
315
+ const hooksJsonPath = join(HOME, ".codex", "hooks.json");
316
+ let hooksJson = existsSync(hooksJsonPath) ? JSON.parse(readFileSync(hooksJsonPath, "utf-8")) : {};
317
+ if (!hooksJson.hooks) hooksJson.hooks = {};
318
+ const stopHooks = (hooksJson.hooks.Stop || []).filter(e =>
319
+ !JSON.stringify(e).includes("patchcord-stop-hook")
320
+ );
321
+ stopHooks.push({ hooks: [{ type: "command", command: hookScriptDest, timeout: 10 }] });
322
+ hooksJson.hooks.Stop = stopHooks;
323
+ writeFileSync(hooksJsonPath, JSON.stringify(hooksJson, null, 2) + "\n");
316
324
 
317
325
  globalChanges.push(`Codex stop hook ${hookAlreadyExisted ? "updated" : "installed"}`);
318
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchcord",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "description": "Cross-machine agent messaging for Claude Code and Codex",
5
5
  "author": "ppravdin",
6
6
  "license": "MIT",