Skip to content

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

fix: migration 003 handles upstream prompt rename/retirement

Adam Eivy313a10a1887e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 05be9cdcc2..bb8b1dfd79 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -20,5 +20,6 @@
- **[feeds-ssrf-aaaa-record-blindness] RSS feed subscriptions now check the IPv6 address family too** — a hostname that pointed to a public IPv4 address but a private IPv6 one used to slip past the SSRF guard because only the IPv4 records were checked; now both families are resolved together, any private address in either family rejects the feed, and IPv6-only hostnames (which used to fail outright) are accepted when they resolve to a public address.
- **[legacy-series-canon-orphan-universe-leak-on-throw] Retrying a failed peer-share import no longer leaves empty "(auto-migrated)" universes behind** — when a transient disk error interrupted importing a peer's series, each retry used to mint a fresh empty universe; the importer now reuses the same one across retries so the import either lands cleanly or is harmless to retry.
- **[ansistrip-osc-alternative-unreachable] TUI output no longer leaks window-title and hyperlink escape bodies** — terminal OSC sequences (the ones CLIs use to set window titles or emit clickable links) are now stripped in full instead of leaving fragments like `0;title␇` visible in agent/TUI transcripts, prompt-runner logs, and arc-planner output.
+- **Migration 003 no longer crashes `update.sh` when a stage prompt was renamed upstream.** `pipeline-tv-script.md` was renamed to `pipeline-teleplay.md` in a later commit, leaving older installs unable to run migration 003 (ENOENT on the missing sample file). The migration now treats a sample-side rename/retirement as a soft delete: unmodified copies of the old file are removed cleanly, customized copies emit a warning so edits can be merged into the replacement manually.
## Removed
diff --git a/scripts/migrations/003-update-pipeline-stage-prompts.js b/scripts/migrations/003-update-pipeline-stage-prompts.js
index bcbd7107d8..66b3e3ec69 100644
--- a/scripts/migrations/003-update-pipeline-stage-prompts.js
+++ b/scripts/migrations/003-update-pipeline-stage-prompts.js
@@ -18,7 +18,7 @@
* is a no-op.
*/
-import { readFile, writeFile } from 'fs/promises';
+import { readFile, writeFile, unlink } from 'fs/promises';
import { join } from 'path';
import { createHash } from 'crypto';
@@ -56,6 +56,7 @@ export default {
let updated = 0;
let alreadyCurrent = 0;
let skipped = 0;
+ let retired = 0;
for (const filename of Object.keys(OLD_SHIPPED_MD5)) {
const dataPath = join(stagesDir, filename);
@@ -81,6 +82,33 @@ export default {
continue;
}
+ // Read the sample now so we can both compare and detect a retired
+ // file (sample missing = the prompt was renamed/retired in a later
+ // commit, e.g. pipeline-tv-script.md → pipeline-teleplay.md).
+ const sampleContent = await readFile(samplePath, 'utf-8').catch((err) => {
+ if (err.code !== 'ENOENT') throw err;
+ return null;
+ });
+
+ if (sampleContent === null) {
+ // Sample file no longer exists — the prompt was renamed/retired
+ // upstream. The replacement (if any) is already in data/ via
+ // setup-data.js. Treat as a soft delete: drop the obsolete file
+ // when unmodified; warn when customized.
+ if (existingMd5 === OLD_SHIPPED_MD5[filename]) {
+ await unlink(dataPath);
+ console.log(`🗑️ pipeline stage prompt ${filename} was renamed/retired upstream — removed unmodified copy from data/`);
+ retired++;
+ } else {
+ console.warn(
+ `⚠️ pipeline stage prompt ${filename} was renamed/retired upstream but your local copy has been customized.\n` +
+ ` Check data.sample/prompts/stages/ for the replacement file and merge any custom edits manually.`,
+ );
+ skipped++;
+ }
+ continue;
+ }
+
if (existingMd5 !== OLD_SHIPPED_MD5[filename]) {
// Diverged from the old shipped version — user has customized this file.
// Warn and skip to avoid clobbering their edits.
@@ -97,14 +125,13 @@ export default {
}
// File matches the old shipped version — safe to replace.
- const sampleContent = await readFile(samplePath, 'utf-8');
await writeFile(dataPath, sampleContent);
console.log(`✅ updated pipeline stage prompt: ${filename}`);
updated++;
}
- if (updated > 0) {
- console.log(`📝 pipeline stage prompt migration: ${updated} updated, ${alreadyCurrent} already current, ${skipped} skipped (customized)`);
+ if (updated > 0 || retired > 0) {
+ console.log(`📝 pipeline stage prompt migration: ${updated} updated, ${retired} retired, ${alreadyCurrent} already current, ${skipped} skipped (customized)`);
} else if (skipped > 0) {
console.log(`📝 pipeline stage prompt migration: all files either current or customized (${skipped} skipped)`);
} else {