From bf2f57105fd5140e4035dc5a0424f51e4bfe99e8 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Thu, 19 Feb 2026 12:21:04 -0600 Subject: [PATCH] fix(#657): create backup before STATE.md regeneration /gsd:health --repair now creates a timestamped backup (STATE.md.bak-YYYY-MM-DDTHH-MM-SS) before overwriting STATE.md, preventing accidental data loss of accumulated context. Co-Authored-By: Claude --- get-shit-done/bin/gsd-tools.cjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/get-shit-done/bin/gsd-tools.cjs b/get-shit-done/bin/gsd-tools.cjs index 2e6a2ff89..1f5f6646e 100755 --- a/get-shit-done/bin/gsd-tools.cjs +++ b/get-shit-done/bin/gsd-tools.cjs @@ -3830,6 +3830,13 @@ function cmdValidateHealth(cwd, options, raw) { break; } case 'regenerateState': { + // Create timestamped backup before overwriting + if (fs.existsSync(statePath)) { + const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19); + const backupPath = `${statePath}.bak-${timestamp}`; + fs.copyFileSync(statePath, backupPath); + repairActions.push({ action: 'backupState', success: true, path: backupPath }); + } // Generate minimal STATE.md from ROADMAP.md structure const milestone = getMilestoneInfo(cwd); let stateContent = `# Session State\n\n`;