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 (codex): seed editorial-analysis stage via migration; force re-run
Adam Eivy121e390113a3
diff --git a/client/src/hooks/useSeriesEditorial.js b/client/src/hooks/useSeriesEditorial.jsindex b31de233e2..fda6c56c1a 100644--- a/client/src/hooks/useSeriesEditorial.js+++ b/client/src/hooks/useSeriesEditorial.js@@ -62,10 +62,14 @@ export function useSeriesEditorial(seriesId) {}}, [closed, analysisEnabled, reload]);+ // Force a recompute: this is an explicit user action ("Interpret reader map"+ // / "Re-run all"). On a first run nothing is cached so force is a no-op; on a+ // re-run it bypasses the unchanged-content cache short-circuit so the button+ // actually re-analyzes (e.g. after a prompt/model change or a bad result).const startAnalysis = useCallback(() => {if (!seriesId) return;setStarting(true);- analyzeSeriesEditorial(seriesId, {}, { silent: true })+ analyzeSeriesEditorial(seriesId, { force: true }, { silent: true }).then(() => setAnalysisEnabled(true)).catch((err) => toast.error(err?.message || 'Failed to start analysis')).finally(() => setStarting(false));diff --git a/scripts/migrations/041-editorial-analysis-stage.js b/scripts/migrations/041-editorial-analysis-stage.jsnew file mode 100644index 0000000000..6f56cce0eb--- /dev/null+++ b/scripts/migrations/041-editorial-analysis-stage.js@@ -0,0 +1,75 @@+/**+ * Seed the `pipeline-editorial-analysis` stage into existing installs.+ *+ * Mirrors `020-comic-cover-concepts-stage.js`: copies the `.md` template from+ * `data.reference/prompts/stages/` and merges the 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 the new Editorial Roadmap analysis+ * stage unseeded and `buildPrompt('pipeline-editorial-analysis')` would throw+ * "Stage not found" the first time a user runs the analysis.+ */++import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises';+import { dirname, join } from 'path';++const FILENAME = 'pipeline-editorial-analysis.md';+const STAGE_KEY = 'pipeline-editorial-analysis';++export default {+ async up({ rootDir }) {+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');+ await mkdir(stagesDir, { recursive: true });++ const dataPath = join(stagesDir, FILENAME);+ const samplePath = join(rootDir, 'data.reference', 'prompts', 'stages', FILENAME);++ const exists = await access(dataPath, constants.F_OK).then(() => true, () => false);+ if (exists) {+ console.log(`📝 editorial-analysis prompt: already present`);+ } else {+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);+ if (!sampleExists) {+ console.warn(`⚠️ editorial-analysis: sample missing for ${FILENAME} — skipping copy`);+ } else {+ try {+ await copyFile(samplePath, dataPath);+ console.log(`✅ seeded ${FILENAME}`);+ } catch (err) {+ console.warn(`⚠️ editorial-analysis: copy failed for ${FILENAME}: ${err.message}`);+ }+ }+ }++ const installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');+ const sampleConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');+ const sampleConfigExists = await access(sampleConfigPath, constants.F_OK).then(() => true, () => false);+ if (!sampleConfigExists) {+ console.warn('⚠️ editorial-analysis: data.reference stage-config.json missing — cannot resolve entry; skipping config write');+ return;+ }+ try {+ const sample = JSON.parse(await readFile(sampleConfigPath, 'utf8'));+ const installedExists = await access(installedConfigPath, constants.F_OK).then(() => true, () => false);+ const installed = installedExists+ ? JSON.parse(await readFile(installedConfigPath, 'utf8'))+ : { stages: {} };+ installed.stages = installed.stages || {};+ if (installed.stages[STAGE_KEY]) {+ console.log(`📝 editorial-analysis stage-config: already present`);+ return;+ }+ if (!sample?.stages?.[STAGE_KEY]) {+ console.warn(`⚠️ editorial-analysis: sample stage-config missing ${STAGE_KEY} — skipping`);+ return;+ }+ installed.stages[STAGE_KEY] = sample.stages[STAGE_KEY];+ await mkdir(dirname(installedConfigPath), { recursive: true });+ await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8');+ const action = installedExists ? 'merged' : 'created';+ console.log(`📝 editorial-analysis stage-config (${action}): 1 added`);+ } catch (err) {+ console.warn(`⚠️ editorial-analysis: stage-config merge failed: ${err.message}`);+ }+ },+};