From f4f729bd58742ae091282be9ef57f3486f4e200b Mon Sep 17 00:00:00 2001 From: Admin Date: Sat, 27 Jun 2026 20:11:34 +0300 Subject: [PATCH] fix: add error handling to setMode + check all 6 copilot commands - hooks/ponytail-runtime.js: wrap setMode writeFileSync in try/catch so disk full or permission errors don't crash the hook - tests/copilot-plugin.test.js: check all 6 TOML files, not just 4 Closes #378, Closes #381 --- hooks/ponytail-runtime.js | 8 ++++++-- tests/copilot-plugin.test.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hooks/ponytail-runtime.js b/hooks/ponytail-runtime.js index 2aa61a31..89c4d1f6 100644 --- a/hooks/ponytail-runtime.js +++ b/hooks/ponytail-runtime.js @@ -13,8 +13,12 @@ if (isCopilot) stateDir = process.env.COPILOT_PLUGIN_DATA; const statePath = path.join(stateDir, STATE_FILE); function setMode(mode) { - fs.mkdirSync(path.dirname(statePath), { recursive: true }); - fs.writeFileSync(statePath, mode); + try { + fs.mkdirSync(path.dirname(statePath), { recursive: true }); + fs.writeFileSync(statePath, mode); + } catch (e) { + // Fail silently rather than crash the hook + } } function clearMode() { diff --git a/tests/copilot-plugin.test.js b/tests/copilot-plugin.test.js index dbb45d18..c1246692 100644 --- a/tests/copilot-plugin.test.js +++ b/tests/copilot-plugin.test.js @@ -13,6 +13,8 @@ const REQUIRED_COMMAND_FILES = [ 'ponytail-review.toml', 'ponytail-audit.toml', 'ponytail-debt.toml', + 'ponytail-gain.toml', + 'ponytail-help.toml', ]; function readJSON(relPath) {