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
address review (claude): seed CWQE quality stages + craft-anti-patterns partial for pm2-restart upgrades
[._.]/ Adam Eivy3dd0cf39529f
diff --git a/scripts/migrations/182-seed-cwqe-quality-stages.js b/scripts/migrations/182-seed-cwqe-quality-stages.jsnew file mode 100644index 0000000000..5c165aca18--- /dev/null+++ b/scripts/migrations/182-seed-cwqe-quality-stages.js@@ -0,0 +1,34 @@+/**+ * Seed the six Creative Writing Quality Engine judge/revision stages into+ * existing installs (v2.27.0 — CWQE calibrated-judge + Writers-Room revision work,+ * #2167 / #2169 / #2171 / #2176 / #2168 / #2173).+ *+ * Mirrors `165-reader-panel-persona-stages.js`: copies each `.md` template from+ * `data.reference/prompts/stages/` and merges the matching stage-config entry into+ * `data/prompts/stage-config.json`. Boot runs migrations (server/index.js) but NOT+ * `setup-data.js`, so an upgrade that pulls + `pm2 restart`s (rather than running+ * `update.sh`) would otherwise leave these stages unseeded and the first+ * invocation would throw "Stage <name> not found":+ * - `pipeline-judge-issue` — the calibrated per-issue quality judge (#2167)+ * - `pipeline-judge-foundation` — the pre-draft world/character/arc gate (#2176)+ * - `pipeline-judge-compare` — the multi-candidate / Elo head-to-head gate (#2169)+ * - `pipeline-editorial-adversarial-cuts` — the "what a ruthless editor cuts" check (#2168)+ * - `writers-room-cuts` — Writers-Room autonomous polish: identify cuts (#2173)+ * - `writers-room-revise` — Writers-Room autonomous polish: apply the brief (#2173)+ *+ * Every other new stage in this release ships its own seed migration (cd-plan→175,+ * reader panel→165, world doctrine→167, premature-reveal→168, voice-discover→174,+ * concept-judge→180); these six were the gap. Customization-safe + idempotent: each+ * template is copied only when missing and each config entry merged only when absent.+ */++import { makeSeedMigrations } from './_seedStageHelpers.js';++export default makeSeedMigrations([+ 'pipeline-judge-issue',+ 'pipeline-judge-foundation',+ 'pipeline-judge-compare',+ 'pipeline-editorial-adversarial-cuts',+ 'writers-room-cuts',+ 'writers-room-revise',+]);diff --git a/scripts/migrations/183-seed-craft-anti-patterns-partial.js b/scripts/migrations/183-seed-craft-anti-patterns-partial.jsnew file mode 100644index 0000000000..1355b5d113--- /dev/null+++ b/scripts/migrations/183-seed-craft-anti-patterns-partial.js@@ -0,0 +1,52 @@+/**+ * Seed the `craft-anti-patterns` prompt PARTIAL into existing installs (v2.27.0 —+ * CWQE craft-knowledge prompt upgrades, #2172).+ *+ * Migration `166-craft-knowledge-prompt-upgrades.js` injects a `{{> craft-anti-patterns }}`+ * reference into un-customized installs' `pipeline-prose.md` (and `181` into+ * `writers-room-continue.md`), but assumed `setup-data.js` would copy the NEW+ * partial file itself on the next boot. Boot runs migrations, NOT `setup-data.js`,+ * so on an upgrade that pulls + `pm2 restart`s (rather than running `update.sh`)+ * the reference lands with no partial on disk, and rendering the prose or+ * Writers-Room-continue stage throws `Prompt partial not found: "craft-anti-patterns"`+ * (`server/lib/promptPartials.js` — partials resolve strictly from+ * `data/prompts/_partials/`, with no `data.reference` fallback). Core drafting is a+ * hard throw, not an opt-in feature, so this seed is release-blocking.+ *+ * Mirrors the stage-seed family (`_seedStageHelpers.js`) but for the `_partials/`+ * directory, which that helper doesn't cover. Runs AFTER 166/181 within a single+ * boot's migration pass (filename sort), so the partial exists before any render.+ * Customization-safe + idempotent: copied only when missing, never clobbering a+ * hand-edited partial.+ */++import { access, copyFile, mkdir, constants } from 'fs/promises';+import { join } from 'path';++const PARTIAL_FILENAME = 'craft-anti-patterns.md';++export default {+ async up({ rootDir }) {+ const partialsDir = join(rootDir, 'data', 'prompts', '_partials');+ const dataPath = join(partialsDir, PARTIAL_FILENAME);+ const samplePath = join(rootDir, 'data.reference', 'prompts', '_partials', PARTIAL_FILENAME);++ const exists = await access(dataPath, constants.F_OK).then(() => true, () => false);+ if (exists) {+ console.log('📝 craft-anti-patterns partial: already present');+ return;+ }+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);+ if (!sampleExists) {+ console.warn(`⚠️ craft-anti-patterns: sample missing for ${PARTIAL_FILENAME} — skipping copy`);+ return;+ }+ await mkdir(partialsDir, { recursive: true });+ try {+ await copyFile(samplePath, dataPath);+ console.log(`✅ seeded ${PARTIAL_FILENAME}`);+ } catch (err) {+ console.warn(`⚠️ craft-anti-patterns: copy failed for ${PARTIAL_FILENAME}: ${err.message}`);+ }+ },+};