Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([backport-pre-023-migrations-to-_lib]): retire renamed prompts even when data is at the post-migration hash
[._.]/ Adam Eivy06a9201fa688
diff --git a/scripts/migrations/_lib.js b/scripts/migrations/_lib.jsindex 604f529b5b..c663e0219c 100644--- a/scripts/migrations/_lib.js+++ b/scripts/migrations/_lib.js@@ -83,26 +83,22 @@ export async function applyPromptReplaceMigration({}const existingMd5 = md5(existing);-- if (existingMd5 === current[filename]) {- alreadyCurrent++;- continue;- }-const acceptedOld = accepted[filename];const matchesAcceptedOld = acceptedOld.includes(existingMd5);+ const matchesCurrent = existingMd5 === current[filename];if (retireOnSampleMissing) {- // Peek at the sample before the upgrade branch: a missing sample means- // the prompt was renamed or retired upstream, in which case the on-disk- // file is obsolete and should be removed (when unmodified) or flagged- // (when customized) rather than read-then-crash.+ // Peek at the sample before any other branch: a missing sample means+ // the prompt was renamed or retired upstream, so the on-disk file is+ // obsolete regardless of which shipped version it matches. Unmodified+ // copies (either accepted-old or current hash) are unlinked; customized+ // copies warn and skip.const sampleExists = await readFile(samplePath, 'utf-8').then(() => true, (err) => {if (err.code === 'ENOENT') return false;throw err;});if (!sampleExists) {- if (matchesAcceptedOld) {+ if (matchesAcceptedOld || matchesCurrent) {await unlink(dataPath);console.log(`🗑️ ${label} ${filename} was renamed/retired upstream — removed unmodified copy from data/`);retired++;@@ -117,6 +113,11 @@ export async function applyPromptReplaceMigration({}}+ if (matchesCurrent) {+ alreadyCurrent++;+ continue;+ }+if (!matchesAcceptedOld) {console.warn(`⚠️ ${label} ${filename} has been customized — skipping auto-update.\n` +diff --git a/scripts/migrations/_lib.test.js b/scripts/migrations/_lib.test.jsindex 1d5eb2d398..6ec645d3f2 100644--- a/scripts/migrations/_lib.test.js+++ b/scripts/migrations/_lib.test.js@@ -81,6 +81,17 @@ describe('applyPromptReplaceMigration opt-ins', () => {expect(readFileSync(join(stagesDir, FILENAME), 'utf-8')).toBe(BODY_CUSTOM);});+ it('retires even when data matches the current hash (sample renamed after the migration shipped)', async () => {+ // Regression: a user who already ran the migration (data at NEW hash)+ // and then pulled the rename should still get the now-obsolete file+ // cleaned up. Without this branch the file would be classified as+ // `alreadyCurrent` and left in `data/`.+ writeFileSync(join(stagesDir, FILENAME), BODY_NEW);+ const result = await applyPromptReplaceMigration({ rootDir, ...baseOpts, retireOnSampleMissing: true });+ expect(result).toMatchObject({ retired: 1, alreadyCurrent: 0, skipped: 0 });+ expect(existsSync(join(stagesDir, FILENAME))).toBe(false);+ });+it('still applies the normal upgrade when the sample is present', async () => {writeFileSync(join(stagesDir, FILENAME), BODY_OLD);writeFileSync(join(sampleDir, FILENAME), BODY_NEW);