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
docs: archive Story Arc Planning Phases 1-4; defer Phase 5
Adam Eivy5e7ce030e455
diff --git a/DONE.md b/DONE.mdindex 0c58eec0bb..5c0c6a2a19 100644--- a/DONE.md+++ b/DONE.md@@ -6,6 +6,13 @@ Archive of completed work. For active roadmap, see [PLAN.md](./PLAN.md). For pro## 2026-05-10+- **Pipeline — Story Arc Planning (Phases 1–4 shipped)** — Four-phase rebuild of the PipelineSeries page from a flat issue list into a structural Arc → Season → Episode tree.+ - **Phase 1** — Two-pane layout: sticky bible sidebar (name, format, logline, premise, characters, etc.) + responsive card-grid canvas. Dropped `max-w-5xl` cap; sidebar collapses to a 48px rail (state in `localStorage['portos-pipeline-series-sidebar-collapsed']`); mobile reflows single-column.+ - **Phase 2** — Schema: `series.arc` (logline, summary, themes, protagonistArc, status), `series.seasons[]` (id, number, title, logline, synopsis, episodeCountTarget, themes, endingHook, status, timestamps), and `issue.seasonId` + `issue.arcPosition`. Backed by new `server/lib/storyArc.js` + `server/services/pipeline/seasons.js` (delete-with-reassign re-points child issues atomically). Routes: `GET/POST/PATCH/DELETE /api/pipeline/series/:id/seasons[/:seasonId]`. Pure additive — existing series.json round-trips unchanged.+ - **Phase 3** — Three LLM-driven passes via shared `stageRunner.js`: `pipeline-arc-overview` (proposes arc + season breakdown, `model: 'heavy'`), `pipeline-season-episodes` (per-season episode breakdown with continuity context from prior seasons), `pipeline-arc-verify` (cross-season continuity pass returning `{ severity, location, problem, suggestion }` findings). Backed by `server/services/pipeline/arcPlanner.js`. Routes: `POST /api/pipeline/series/:id/arc/generate`, `POST /api/pipeline/series/:id/seasons/:seasonId/episodes/generate`, `POST /api/pipeline/series/:id/arc/verify`. All accept `{ providerOverride, modelOverride }`; the first two accept `commit: true` to persist in one shot (default returns a preview).+ - **Phase 4** — `client/src/components/pipeline/ArcCanvas.jsx` (~640 LOC): collapsible Season rows with inline edit, episode rows with hover-revealed season picker for cross-season moves + delete, top-of-canvas arc card with logline/themes/collapsible summary + verify panel with severity-badged findings. Generate-arc + per-season-delete use the two-click-arm replace pattern. New client helpers in `apiPipeline.js` wrap all seven new server routes. PipelineSeries.jsx slimmed to a bible-sidebar + `<ArcCanvas />` composition.+ - **Phase 5 deferred** — `seasonContext` prompt injection in `textStages.js#buildStageContext`. Macro continuity already covered by the planning artifacts (series.arc.protagonistArc, season synopses, episode idea-seed); revisit only if executed per-episode prose breaks continuity in practice.+ - Tests: 18 storyArc unit + 13 seasons service + 11 arcPlanner unit + 17 route tests across Phases 2–3. Full server suite 3889/3889 green after Phase 4.- **CoS agent dedup race fix** — `spawnAgentForTask` released the `spawningTasks` guard before the agent was queued to the runner, so a concurrent `task:ready` could slip a duplicate past the has-check. Spawn call is now wrapped in `try { spawnViaRunner | spawnDirectly } finally { spawningTasks.delete(task.id) }` (`server/services/agentLifecycle.js:536-547`). New behavioral race-repro + source-text regression guard in `agentLifecycle.test.js`; 3831 tests green.- **Video Gen — FFLF keyframe-pair guidance** — `renderFramePanel` in `client/src/pages/VideoGen.jsx` gained a `hint` prop and an accent-coloured line under FFLF mode telling users to use keyframes that share scene geometry. Distinct styling from the experimental advisory.- **Deprecate notapalindrome LTX models** — `ltx2_unified`, `ltx23_unified`, `ltx23_distilled_q4` carry `deprecated: true` in `server/lib/mediaModels.js` + the `data.sample/media-models.json` seed; VideoGen + Creative Director dropdowns group them under a `Legacy` `<optgroup>` below the active dgrauet models. `defaultMacos` deliberately stays on `ltx23_distilled_q4` because dgrauet requires an opt-in `INSTALL_LTX2=1` venv install — fresh installs need a model that works out of the box.diff --git a/PLAN.md b/PLAN.mdindex 033a5617ab..6e655effb3 100644--- a/PLAN.md+++ b/PLAN.md@@ -6,9 +6,8 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]## Next Up-1. **Pipeline — Story Arc Planning + Series Page Redesign** — Phase 1 (Series page layout refactor: left-sidebar bible + right card-grid canvas, drop `max-w-5xl` cap, collapsible sidebar persisted to localStorage) starts immediately. Full multi-phase spec lives below under "Pipeline — Story Arc Planning + Series Page Redesign."-2. **Voice agent next power-ups** — `ui_read` (extract visible page text so "what does this say?" works without hand-navigation), destructive-action confirmation gate (pause and require spoken "confirm" when `ui_click` matches `/delete|remove|discard|reset|clear/i`), proactive CoS speech (server-pushed voice with quiet-hours policy + barge-in contract).-3. **God-file test coverage** — `cos.js` (3115 lines) and `agentLifecycle.js` (1446 lines) still have no test sibling. Add tests for `evaluateTasks` priority ordering + `dequeueNextTask` capacity guards (cos), and `spawnAgentForTask` + `handleAgentCompletion` error recovery (agentLifecycle). Both files are still growing — `agentLifecycle.js` is +11 LOC since last replan; add coverage before further surgery.+1. **Voice agent next power-ups** — `ui_read` (extract visible page text so "what does this say?" works without hand-navigation), destructive-action confirmation gate (pause and require spoken "confirm" when `ui_click` matches `/delete|remove|discard|reset|clear/i`), proactive CoS speech (server-pushed voice with quiet-hours policy + barge-in contract).+2. **God-file test coverage** — `cos.js` (3115 lines) and `agentLifecycle.js` (1446 lines) still have no test sibling. Add tests for `evaluateTasks` priority ordering + `dequeueNextTask` capacity guards (cos), and `spawnAgentForTask` + `handleAgentCompletion` error recovery (agentLifecycle). Both files are still growing — `agentLifecycle.js` is +11 LOC since last replan; add coverage before further surgery.## Backlog@@ -125,124 +124,18 @@ Steps 1–7 shipped (see DONE.md 2026-05-10). The Writers Room and Pipeline now----## Pipeline — Story Arc Planning + Series Page Redesign+## Pipeline — Story Arc Planning (shipped Phases 1–4)-Today the PipelineSeries page (`client/src/pages/PipelineSeries.jsx`) is constrained to `max-w-5xl` and presents a single vertical scroll: bible metadata → characters → "Issues / Episodes" list with a one-line "New issue" input at the bottom. On a wide screen most of the viewport is wasted whitespace, and the only way to seed an issue is "type a title, click New, repeat." For a 24-episode show with a 3-season arc this is the wrong primitive — users want to plan the *whole arc* first, decide on the season/volume count, and only then drill into per-episode work.+Initiative shipped 2026-05-10 (see DONE.md). The PipelineSeries page now has a two-pane layout (sticky bible sidebar + Arc → Season → Episode canvas), the data model carries `series.arc` + `series.seasons[]` + `issue.seasonId` + `issue.arcPosition`, three LLM passes drive arc / per-season-episodes / cross-season verification, and the `ArcCanvas` UI surfaces all of it.-This initiative adds a structural Arc → Season(s) → Issue hierarchy and the LLM scaffolding to plan top-down. Supersedes the prior "Series-arc grouping" backlog item. Ship in phases so each phase is independently reviewable.+**Original Phase 5 (deferred — observe first):** Inject a `seasonContext` variable (current season synopsis + last 1–3 episodes' loglines) into the per-episode prose/script stage prompts via `server/services/pipeline/textStages.js#buildStageContext`. The macro continuity is already implicit in the planning artifacts (`series.arc.protagonistArc`, the season synopses generated upfront by `pipeline-arc-overview`, and the episode's idea-stage seed from `pipeline-season-episodes`), and the bible system already enforces character/setting consistency. Revisit only if executed per-episode prose starts contradicting adjacent episodes in practice.-### Phase 1 — Series page layout redesign (no schema change)--The bible/style/world panels move to a left sidebar; the right side becomes the structural canvas. Drop the `max-w-5xl` cap; use a responsive 2-column grid (`grid-cols-1 lg:grid-cols-[360px_minmax(0,1fr)]`) so the page actually uses the viewport at wider widths.--- Left sidebar (sticky, scroll-internal): NAME / TARGET FORMAT / LOGLINE / TARGET ISSUE COUNT / PREMISE / STYLE NOTES / LINKED WORLD / CHARACTERS. This is the "bible" — high-density inputs the user references but doesn't edit constantly.-- Right canvas: Today this is just "Issues / Episodes" — Phase 2 fills it with the Arc tree. For Phase 1 it gets a card-grid view of existing issues (each card showing number / title / status / last-updated / a thumbnail of the most-recent storyboards image) instead of the current text list.-- Collapsible left sidebar (so the canvas can expand to full width when the user is deep in episode work). Persists in localStorage like the existing Layout sidebar collapse.-- Mobile: stays single-column, sidebar reflows above the canvas.--Files: `client/src/pages/PipelineSeries.jsx`. No new server work.--### Phase 2 — Arc + Season schema (Series → Arc → Season → Issue)--Three new shapes; both stored on the existing `data/pipeline-series.json` (no new files — the arc is part of the series bible).--```js-// series.arc — overall multi-season story spine, optional-{- logline: string, // one-sentence arc pitch- summary: string, // ~500 words: act structure, season-by-season turning points- themes: string[],- protagonistArc: string, // character growth across all seasons- status: 'draft' | 'verified',-}-// series.seasons[] — ordered list of seasons/volumes-{- id: 'sea-<uuid>',- number: 1,- title: string,- logline: string,- synopsis: string, // ~200 words- episodeCountTarget: 8, // user-set target; actual issues may differ- themes: string[],- endingHook: string, // the line/image that pulls into season N+1- status: 'draft' | 'verified' | 'in-production' | 'complete',-}-// issue.seasonId (existing issue schema gains an optional pointer)-{- ...existing fields,- seasonId: 'sea-...' | null, // null for ungrouped issues (back-compat)- arcPosition: number | null, // ordinal within the season — drives auto-sort-}-```--- New `seasons` field on the series sanitizer with `sanitizeSeasonList()` in a new `server/lib/storyArc.js` (mirrors `storyBible.js` — canonical shape + sanitization + merge helpers).-- Issue sanitizer gains `seasonId` + `arcPosition` (back-compat: existing un-grouped issues keep `seasonId: null`).-- Service helpers: `listSeasons(seriesId)`, `createSeason(seriesId, input)`, `updateSeason(seriesId, seasonId, patch)`, `deleteSeason(seriesId, seasonId, { reassignTo: seasonId | null })` (reassigns child issues to a sibling or to null on delete).-- No DB migration needed — JSON files take additive fields cleanly.--Files: `server/lib/storyArc.js` (new), `server/services/pipeline/series.js`, `server/services/pipeline/issues.js`, `server/services/pipeline/seasons.js` (new), `server/routes/pipeline.js`. Route additions: `POST/PATCH/DELETE /api/pipeline/series/:id/seasons[/:seasonId]`. Tests follow the same pattern as `seriesService.test.js`.--### Phase 3 — LLM-assisted arc generation (new stage prompts)--Three new staged-LLM prompts in `data.sample/prompts/stages/`:--- **`pipeline-arc-overview`** (returns JSON `{ logline, summary, themes, protagonistArc, seasonOutlines: [{ number, title, logline, endingHook, episodeCountTarget }] }`). Inputs: series bible (name, logline, premise, characters, target format, target issue count). The model proposes a top-level arc + season breakdown. Default `model: 'heavy'` since this is the most expensive single call in the pipeline (reasoning over the full series scope).-- **`pipeline-season-episodes`** (returns JSON `{ episodes: [{ number, title, logline, synopsis, primaryCharacters, arcRole }] }`). Inputs: series bible + chosen season's outline + prior seasons' synopses (for continuity context). Generates the per-episode breakdown for one season. Called per-season so a user can revise season N's outline without re-generating earlier seasons.-- **`pipeline-arc-verify`** (returns JSON `{ issues: [{ severity, location, problem, suggestion }] }`). Inputs: full arc + all seasons + all issues. Sanity-checks for: character arcs that contradict across seasons, dropped subplots, episode-count mismatch vs. arc weight, unresolved hooks at the series finale.--Reuses the shared `stageRunner.js` so each call is replayable from `/runs`. All three stages register in `stage-config.json` and get the `_partials` treatment for the bible-deference block (same as `pipeline-extract-scenes.md`).--Service: `server/services/pipeline/arcPlanner.js` exposing `generateArcOverview(seriesId)`, `generateSeasonEpisodes(seriesId, seasonId, { force })`, `verifyArc(seriesId)`. Each returns `{ result, runId, providerId, model }` and the caller persists via `updateSeries`/`createSeason`/`createIssue` chains.--Routes: `POST /api/pipeline/series/:id/arc/generate`, `POST /api/pipeline/series/:id/seasons/:seasonId/episodes/generate`, `POST /api/pipeline/series/:id/arc/verify`.--### Phase 4 — Arc canvas UI (right-side replacement)--The Phase 1 card-grid evolves into a vertical Arc → Season → Episode tree:--```-┌─ Arc ──────────────────────────────────────┐-│ Logline: "..." │-│ Themes: [betrayal] [legacy] │-│ [Edit arc] [Verify arc] [Regenerate] │-└────────────────────────────────────────────┘--▶ Season 1 — "The Choir Awakens" [12 episodes]- Episode 1 — "First Light" [draft]- Episode 2 — "Hollow Bones" [ready]- ...- [+ Add episode] [Generate episodes (LLM)]--▶ Season 2 — "Diaspora" [8 episodes]- ...--[+ Add season] [Generate arc (LLM)]-```--- Each season collapsible (`<details>` semantics) — collapsed seasons show season # + title + episode count badge; expanded seasons show the issue rows + the "generate season" action.-- "Generate arc" runs `pipeline-arc-overview` and seeds `series.arc` + `series.seasons[]` after a preview/confirm modal (same two-click-arm pattern as the storyboards extractor).-- "Generate episodes" on a season runs `pipeline-season-episodes` and creates the issue records with `seasonId` set + `arcPosition` numbered sequentially.-- "Verify arc" surfaces findings inline as a sidebar list with severity badges, click-through to the offending season/episode.-- Drag-and-drop to reorder episodes within a season + move between seasons (updates `arcPosition` + `seasonId`). Deferrable to Phase 4b.--Files: `client/src/components/pipeline/ArcCanvas.jsx` (new), per-season `<SeasonRow>` + per-issue `<IssueRow>` subcomponents. Replaces today's flat "Issues / Episodes" list at the bottom of PipelineSeries.--### Phase 5 — Cross-season continuity hooks (deferrable)--Once seasons exist, the per-episode prose/script stages can inject "previous episode arc state" + "where we are in this season" into the prompt context automatically — the LLM stops re-inventing where the characters left off. New variable on issue prompts: `seasonContext` = the season's synopsis + the last 1–3 episodes' loglines. Plumbed through the existing `series` / `issue` prompt context object in textStages.js. Small once Phases 2–4 land; the work is mostly prompt-template edits.--### Out of scope / explicitly not doing+**Out of scope (explicit non-goals):**- Per-season independent media collections (one folder per season). The collection model is already per-series; per-season splits add UX complexity without clear value.- Multi-series arcs (a season that spans two related series). Single-series scope keeps the data model flat and the LLM context bounded.-- Auto-promoting an existing flat list of issues into seasons. Users opt in via the "Generate arc" action; existing issues stay un-grouped (`seasonId: null`) until the user moves them.--### Suggested PR sequence--1. **Phase 1** standalone — pure UI refactor, no schema change. Easy review.-2. **Phase 2** standalone — schema + service + route + tests. No UI yet.-3. **Phase 3 + Phase 4 together** — the LLM prompts only have user value once the canvas surfaces them.-4. **Phase 5** standalone — small prompt-context follow-up.+- Auto-promoting an existing flat list of issues into seasons. Users opt in via "Generate arc"; existing issues stay un-grouped (`seasonId: null`) until the user moves them.+- Drag-and-drop reorder of episodes within / between seasons (Phase 4b). Hover-revealed season picker on each episode covers manual cross-season moves; revisit if users hit reorder pain inside a single season.---