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

2.7 KB
Raw Blame
/**
 * Add anchored findings to the manuscript-completeness ("Finish the draft")
 * prompt.
 *
 * The prompt previously returned findings with only a fuzzy human `location`
 * string. It now also returns a structured `issueNumber` plus a verbatim
 * `anchorQuote` excerpt, so the manuscript editor can map a finding to its
 * issue section and jump to the exact spot the gap occurs. See
 * server/services/pipeline/arcPlanner.js (shapeCompletenessFindings).
 *
 * `scripts/setup-data.js` only copies *missing* prompts, so existing installs
 * keep their old template until this migration rewrites it. Customization-safe:
 * only installs whose copy still hashes to the known pre-change shipped version
 * are auto-updated; customized prompts are left intact and warned about.
 *
 * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
 */

import { makePromptReplaceMigration } from './_lib.js';

// Pre-change shipped hash (location-only findings), plus every later shipped
// body for this file as accepted-old: '1ee5ac…' (the post-057 comic-structure
// shape) so a copy still at either prior version is auto-upgradable to current.
export const ACCEPTED_OLD_MD5 = {
  'pipeline-manuscript-completeness.md': ['e6858c74ab2cead752d388e3f428406c', '1ee5ac936fbf1d365e0eaea99bcf1e77', 'cec8faeb75dfff74e41b8221145c2e92'],
};

// Current shipped hash — migrations 057 (comic-structure), 066
// (replacementStrategy) and 083 (with-edits replace field) further updated this
// file, so this hash reflects the post-083 body. The idempotent-rerun and
// drift-catch tests require it to match the live data.reference body, not 056's
// own output.
export const NEW_SHIPPED_MD5 = {
  'pipeline-manuscript-completeness.md': 'a08a7aaea9b57dcf12311505150672cd',
};

const { applyMigration, up } = makePromptReplaceMigration({
  accepted: ACCEPTED_OLD_MD5,
  current: NEW_SHIPPED_MD5,
  label: 'manuscript-completeness anchored-findings prompt',
  customizedHint: (filename) =>
    `   To add anchored findings manually, diff:\n` +
    `     data.reference/prompts/stages/${filename}\n` +
    `   against your current:\n` +
    `     data/prompts/stages/${filename}\n` +
    `   and add the issueNumber + anchorQuote fields to the output contract.`,
  skipFooter: (count) =>
    `⚠️  ${count} prompt(s) could not be auto-updated because they were\n` +
    `   customized. "Finish the draft" still works, but its findings won't\n` +
    `   carry issueNumber/anchorQuote (so click-to-jump in the manuscript\n` +
    `   editor falls back to the fuzzy location text) until you merge the\n` +
    `   change. See data.reference/prompts/stages/pipeline-manuscript-completeness.md.`,
});

export { applyMigration };
export default { up };