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
fix(pipeline): align voice stage navigation (#6768)
[._.]/ Adam Eivyf2dbbd6f6a7a
diff --git a/client/src/services/apiPipeline.js b/client/src/services/apiPipeline.jsindex 2dcba1f467..6c88de82f3 100644--- a/client/src/services/apiPipeline.js+++ b/client/src/services/apiPipeline.js@@ -1,42 +1,27 @@import { request } from './apiCore.js';import { buildFormData } from './apiImageVideo.js';--// Stage IDs mirror server/services/pipeline/issues.js — keep these in sync.+import {+ PIPELINE_STAGE_IDS,+ PIPELINE_STAGE_LABELS,+ PIPELINE_TAB_STAGE_IDS,+ TEXT_STAGE_IDS,+} from '../../../server/lib/pipelineStages.js';++// Stage IDs come from the browser-safe server/lib/pipelineStages.js leaf.// `nouns` is a UI-only pseudo-stage: it has no server stage record + no LLM// template, and its actions wrap existing endpoints (extract scenes + the// generic image gen API). It appears in PIPELINE_TAB_STAGES so it gets a tab// between Prose and Comic Pages, but it's NOT in server TEXT_STAGE_IDS — so// auto-run text chain skips it and POST /stages/nouns/generate would 400.-export const PIPELINE_TEXT_STAGES = Object.freeze(['idea', 'prose', 'comicScript', 'teleplay']);-const PIPELINE_VISUAL_STAGES = Object.freeze(['comicPages', 'storyboards', 'episodeVideo']);-const PIPELINE_AUDIO_STAGES = Object.freeze(['audio']);+export const PIPELINE_TEXT_STAGES = TEXT_STAGE_IDS;const PIPELINE_UI_STAGES = Object.freeze(['nouns']);export const PIPELINE_STAGES = Object.freeze([- ...PIPELINE_TEXT_STAGES, ...PIPELINE_VISUAL_STAGES, ...PIPELINE_AUDIO_STAGES, ...PIPELINE_UI_STAGES,-]);--// Stages that appear as their own tab, in display order. `comicPages` is-// folded into the Comic Script tab (one merged page-by-page editor) — the-// data still flows through the comicPages routes, the tab is just hidden.-// `nouns` is inserted between Prose and Comic Pages so the workflow reads-// Idea → Prose → Nouns → Comic → Teleplay → Storyboards → Episode Video.-export const PIPELINE_TAB_STAGES = Object.freeze([- 'idea', 'prose', 'nouns', 'comicScript', 'teleplay', 'storyboards', 'episodeVideo', 'audio',+ ...PIPELINE_STAGE_IDS, ...PIPELINE_UI_STAGES,]);-export const PIPELINE_STAGE_LABELS = Object.freeze({- idea: 'Idea',- prose: 'Prose',- nouns: 'Nouns',- // `comicScript` stage now owns the merged Comic Pages editor — the- // standalone Comic Pages tab is hidden via PIPELINE_TAB_STAGES below.- comicScript: 'Comic',- teleplay: 'Teleplay',- comicPages: 'Comic',- storyboards: 'Storyboards',- episodeVideo: 'Video',- audio: 'Audio',-});+// Compatibility aliases for the service's established client-facing names.+export const PIPELINE_TAB_STAGES = PIPELINE_TAB_STAGE_IDS;+export { PIPELINE_STAGE_LABELS };// The stage that conventionally feeds each text-stage target — mirrors the// server's DEFAULT_FORWARD_SOURCE (server/services/pipeline/textStages.js).diff --git a/server/lib/README.md b/server/lib/README.mdindex ee33e0ab83..63c0c0852e 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -478,6 +478,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `personaTraitBlend.js` | Digital-twin persona trait-blending (M34 P7). Blends a persona's `traitAdjustments` against the base twin's communication profile + Big-Five into a "Communication Calibration" directive. A pure leaf — `client/src/lib/personaTraitBlend.js` re-exports it for the Personas UI preview. || `textUtils.js` | Pure dependency-free prose helpers. `countWords(text)` is the canonical whitespace-token count (`\S+`) and the only one — every server word count (Writers Room, lettering density, rapid reader, autobiography, script-video beats) and the client's (`client/src/lib/textUtils.js` re-exports it) resolve here, and the "no private countWords" guard in `textUtils.test.js` fails the suite when a re-spelled count (the whitespace-token match, a split-and-filter, or a helper under either conventional name) reappears in any non-test source under `server/` or any source under `client/src/`; the editorial prose-analysis checks deliberately count LETTER words instead, through `editorial/proseTics.js#tokenizeWords`, which owns that tokenizer the same way; `trimTo(value, max)` trims and bounds strings without coercing non-strings, and is safe for shared modules consumed by the browser; `escapeRegExp(value)` is the one to import instead of re-inlining the escape (the sibling guard in `textUtils.test.js` fails the suite when a copy reappears in any non-test source under `server/`, or in ANY source under `client/src/`, tests and `.jsx` included — `client/src/lib/textUtils.js` re-exports this module for the browser bundle); `trimToClause(v, max)` is its boundary-aware twin for PROSE fields — it backs off to the last sentence terminator, then the last clause boundary, then the last whole word, so a capped field never ends mid-thought (it lives here rather than in `storyBible.js`, which re-exports it, so the pure story-model leaves the browser bundle shares can cap prose without pulling `crypto` / `fileUtils`); `kebabCase(text)` is the canonical ASCII slug transform (PLAN.md `[slug]` ids and `planner:<model>` labels); `clampToCharLimit(text, max)` is `trimTo`'s reader-facing twin — it cuts on a sentence end (when one sits 60%+ into the allowance) or a word boundary rather than mid-word and returns `{ text, truncated }` so the caller can say the text was cut, which is what bounds an AI-enhanced render prompt to a backend's hard cap (reactor.inc fast-h3 rejects an over-length prompt outright). || `pipelineIssueOrder.js` | Pure renumber algorithm for pipeline issues. |+| `pipelineStages.js` | Canonical pipeline data-stage groups, visible tab order, UI/voice labels, spoken aliases, and derived voice-intent regex. || `postAdaptive.js` | Pure POST adaptive-difficulty policy — nudges a math drill's primary knob (`steps`/`maxDigits`/`maxExponent`/`tolerancePct`) up/down within clamped bounds from recent scored performance. Opt-in via the config Adaptive toggle. || `postAppliedNumeracy.js` | Pure seeded Applied Numeracy pack — everyday percentage, ratio, unit, rate, and estimation scenarios plus server-authoritative numeric/fraction/unit scoring with explicit tolerance handling. || `postMultiplicationLadder.js` | Pure progressive multiplication ladder — mastery-gated difficulty rungs (`[1,1]` → `[1,2]` → `[1,1,1]` → …). Resolves the user's current level from per-level speed+accuracy stats so the plain multiplication drill ramps up instead of starting at a fixed hard difficulty. On by default. Built on `postProgression.js`. |diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.jsindex ce70cee1f2..2043784dfa 100644--- a/server/lib/importScoping.test.js+++ b/server/lib/importScoping.test.js@@ -75,7 +75,7 @@ const NARROWED = [['lib/slashdoInvocation.js', 'lib/tuiHandshake.js','needs inferTuiCommand, which providerVendors.js declares'],['services/voice/tools/pipeline.js', 'services/pipeline/issues.js',- 'needs NAVIGABLE_STAGE_IDS, which issuesShared.js declares'],+ 'needs only the pure pipelineStages.js identity leaf'],['services/cosTaskIntake.js', 'lib/validation.js','needs SWARM_COUNT_* and the reviewer normalizers, which cosValidation.js / reviewerConfig.js declare'],];@@ -100,7 +100,7 @@ describe('narrowed imports stay narrow (#6009)', () => {expect(reaches('services/memoryEmbeddings.js', 'services/memoryConfig.js')).toBe(true);expect(reaches('lib/llmRoutePin.js', 'lib/textUtils.js')).toBe(true);expect(reaches('lib/slashdoInvocation.js', 'lib/providerVendors.js')).toBe(true);- expect(reaches('services/voice/tools/pipeline.js', 'services/pipeline/issuesShared.js')).toBe(true);+ expect(reaches('services/voice/tools/pipeline.js', 'lib/pipelineStages.js')).toBe(true);});// And a control on the other side: the barrels themselves still reach whatdiff --git a/server/lib/index.js b/server/lib/index.jsindex de03a11e7c..42ff6e4977 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -461,6 +461,7 @@ export * from './providerRouteRecipes.js';export * from './providerRouteSettings.js';export * from './personaTraitBlend.js';export * from './pipelineIssueOrder.js';+export * from './pipelineStages.js';export * from './postAdaptive.js';export * from './postAppliedNumeracy.js';export * from './postMultiplicationLadder.js';diff --git a/server/lib/pipelineStages.js b/server/lib/pipelineStages.jsnew file mode 100644index 0000000000..1fdf9fb551--- /dev/null+++ b/server/lib/pipelineStages.js@@ -0,0 +1,80 @@+import { escapeRegExp } from './textUtils.js';++// Persisted pipeline stages, grouped by artifact shape and execution behavior.+export const TEXT_STAGE_IDS = Object.freeze(['idea', 'prose', 'comicScript', 'teleplay']);+export const VISUAL_STAGE_IDS = Object.freeze(['comicPages', 'storyboards', 'episodeVideo']);+export const AUDIO_STAGE_IDS = Object.freeze(['audio']);+export const PIPELINE_STAGE_IDS = Object.freeze([+ ...TEXT_STAGE_IDS,+ ...VISUAL_STAGE_IDS,+ ...AUDIO_STAGE_IDS,+]);++// User-visible tab order. Nouns is a UI-only workspace; comicPages is folded+// into the Comic tab even though it remains a persisted data stage.+export const PIPELINE_TAB_STAGE_IDS = Object.freeze([+ 'idea',+ 'prose',+ 'nouns',+ 'comicScript',+ 'teleplay',+ 'storyboards',+ 'episodeVideo',+ 'audio',+]);++export const PIPELINE_STAGE_LABELS = Object.freeze({+ idea: 'Idea',+ prose: 'Prose',+ nouns: 'Nouns',+ comicScript: 'Comic',+ teleplay: 'Teleplay',+ comicPages: 'Comic',+ storyboards: 'Storyboards',+ episodeVideo: 'Video',+ audio: 'Audio',+});++// Spoken aliases resolve to visible tabs. Comic-page wording therefore opens+// the merged Comic tab instead of its hidden persisted-stage URL.+export const PIPELINE_STAGE_ALIASES = Object.freeze({+ idea: 'idea',+ prose: 'prose',+ story: 'prose',+ nouns: 'nouns',+ noun: 'nouns',+ characters: 'nouns',+ 'comic script': 'comicScript',+ comicscript: 'comicScript',+ comic: 'comicScript',+ comics: 'comicScript',+ 'comic pages': 'comicScript',+ 'comic page': 'comicScript',+ comicpages: 'comicScript',+ pages: 'comicScript',+ page: 'comicScript',+ 'tv script': 'teleplay',+ tvscript: 'teleplay',+ teleplay: 'teleplay',+ storyboards: 'storyboards',+ storyboard: 'storyboards',+ scenes: 'storyboards',+ 'episode video': 'episodeVideo',+ episodevideo: 'episodeVideo',+ episode: 'episodeVideo',+ video: 'episodeVideo',+ audio: 'audio',+ 'voice over': 'audio',+ music: 'audio',+});++export function buildPipelineIntentRe(aliases = PIPELINE_STAGE_ALIASES) {+ const spokenStages = Object.keys(aliases)+ .sort((a, b) => b.length - a.length)+ .map((alias) => escapeRegExp(alias).replace(/\s+/g, '\\s+'))+ .join('|');+ return new RegExp(+ `\\b(?:next stage|previous stage|prev stage|stage (?:advance|forward|back)|(?:open|go to|back to)(?: the)? (?:${spokenStages})(?: stage)?)\\b`,+ 'i',+ );+}diff --git a/server/lib/pipelineStages.test.js b/server/lib/pipelineStages.test.jsnew file mode 100644index 0000000000..64db9d9ce4--- /dev/null+++ b/server/lib/pipelineStages.test.js@@ -0,0 +1,43 @@+import { describe, expect, it } from 'vitest';+import {+ buildPipelineIntentRe,+ PIPELINE_STAGE_ALIASES,+ PIPELINE_STAGE_IDS,+ PIPELINE_STAGE_LABELS,+ PIPELINE_TAB_STAGE_IDS,+} from './pipelineStages.js';++describe('pipelineStages', () => {+ it('keeps every spoken alias reachable through the derived intent regex', () => {+ const intentRe = buildPipelineIntentRe(PIPELINE_STAGE_ALIASES);+ for (const alias of Object.keys(PIPELINE_STAGE_ALIASES)) {+ expect(`open ${alias}`).toMatch(intentRe);+ }+ });++ it('maps every spoken alias to a visible pipeline tab', () => {+ for (const stageId of Object.values(PIPELINE_STAGE_ALIASES)) {+ expect(PIPELINE_TAB_STAGE_IDS).toContain(stageId);+ }+ });++ it('labels every visible tab and limits UI-only ids to Nouns', () => {+ for (const stageId of PIPELINE_TAB_STAGE_IDS) {+ expect(PIPELINE_STAGE_LABELS[stageId]).toEqual(expect.any(String));+ expect(PIPELINE_STAGE_IDS.includes(stageId) || stageId === 'nouns').toBe(true);+ }+ });++ it('accepts visible labels through the spoken alias table', () => {+ for (const stageId of PIPELINE_TAB_STAGE_IDS) {+ expect(PIPELINE_STAGE_ALIASES[PIPELINE_STAGE_LABELS[stageId].toLowerCase()]).toBe(stageId);+ }+ });++ it('matches multi-word aliases in each supported navigation phrase', () => {+ const intentRe = buildPipelineIntentRe(PIPELINE_STAGE_ALIASES);+ expect('open voice over').toMatch(intentRe);+ expect('go to the comic script stage').toMatch(intentRe);+ expect('back to episode video').toMatch(intentRe);+ });+});diff --git a/server/services/pipeline/issuesShared.js b/server/services/pipeline/issuesShared.jsindex 30e7a632a3..6fdaba2a1e 100644--- a/server/services/pipeline/issuesShared.js+++ b/server/services/pipeline/issuesShared.js@@ -34,6 +34,23 @@ import { sanitizeCoverLike } from '../../lib/renderSlot.js';import { ensureStoryboardIds } from '../../lib/storyboardScenes.js';import { applyVolumeOrderedNumbers } from '../../lib/pipelineIssueOrder.js';import * as seriesSvc from './series.js';+export {+ AUDIO_STAGE_IDS,+ PIPELINE_STAGE_IDS as STAGE_IDS,+ TEXT_STAGE_IDS,+ VISUAL_STAGE_IDS,+} from '../../lib/pipelineStages.js';+import {+ AUDIO_STAGE_IDS,+ PIPELINE_STAGE_IDS as STAGE_IDS,+ TEXT_STAGE_IDS,+ VISUAL_STAGE_IDS,+} from '../../lib/pipelineStages.js';++// Backward-compatible data-stage export. Voice navigation now uses the visible+// tab order from pipelineStages.js, but existing service consumers may still+// use this name for the persisted stages that were historically navigable.+export const NAVIGABLE_STAGE_IDS = STAGE_IDS;// Storage backend dispatcher (#1015). Issue records moved from per-record// `data/pipeline-issues/{id}/index.json` (collectionStore) to one-row-per-issue@@ -85,22 +102,6 @@ export const ISSUES_PER_RESPONSE_MAX = 1000;// updateStageWithLatest + updateIssue.export const STAGE_RUN_HISTORY_MAX = 5;-// Stage IDs are ordered for UI display; the canonical order is also the-// auto-run text-chain order (idea → prose → scripts in parallel). Comic-// pages / storyboards / episode video stages are visual and stay manual-// in MVP.-export const TEXT_STAGE_IDS = Object.freeze(['idea', 'prose', 'comicScript', 'teleplay']);-export const VISUAL_STAGE_IDS = Object.freeze(['comicPages', 'storyboards', 'episodeVideo']);-// Audio is its own category — voice-over lines + music. Feature-gated on-// series.targetFormat (only meaningful when the series ships video, not-// comic-only). Kept separate from VISUAL_STAGE_IDS so the artifact shape-// (`lines[]`, `music`) stays distinct from visual stages.-export const AUDIO_STAGE_IDS = Object.freeze(['audio']);-export const STAGE_IDS = Object.freeze([...TEXT_STAGE_IDS, ...VISUAL_STAGE_IDS, ...AUDIO_STAGE_IDS]);-// Stages exposed to voice navigation ("next stage" / "previous stage" tools)-// and the tab strip. Includes audio now that the AudioStage UI is wired.-export const NAVIGABLE_STAGE_IDS = Object.freeze([...TEXT_STAGE_IDS, ...VISUAL_STAGE_IDS, ...AUDIO_STAGE_IDS]);-// "This stage has usable content and shouldn't be regenerated by default."// `edited` = user typed into the editor; `ready` = LLM filled and the user// hasn't asked to rerun. Both are good — auto-runners skip past them unlessdiff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 445703f457..bd5a241f5a 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -1258,7 +1258,19 @@ describe('pipeline stage navigation tools', () => {it('refuses to advance past audio (last navigable stage)', async () => {const r = await dispatchTool('pipeline_next_stage', {}, makeCtx('/pipeline/issues/x/audio'));expect(r.ok).toBe(false);- expect(r.summary).toMatch(/last stage/);+ expect(r.summary).toBe("Already on Audio — that's the last stage.");+ });++ it('advances from prose to the Nouns tab', async () => {+ const r = await dispatchTool('pipeline_next_stage', {}, makeCtx('/pipeline/issues/x/prose'));+ expect(r.stage).toBe('nouns');+ expect(r.path).toBe('/pipeline/issues/x/nouns');+ });++ it('advances from teleplay to storyboards without visiting hidden comic pages', async () => {+ const r = await dispatchTool('pipeline_next_stage', {}, makeCtx('/pipeline/issues/x/teleplay'));+ expect(r.stage).toBe('storyboards');+ expect(r.path).toBe('/pipeline/issues/x/storyboards');});it('refuses when not on a pipeline issue page', async () => {@@ -1300,12 +1312,22 @@ describe('pipeline stage navigation tools', () => {expect(ctx.sideEffects).toEqual([{ type: 'navigate', path: '/pipeline/issues/iss-x/storyboards' }]);});- it('resolves spoken aliases (teleplay → teleplay, pages → comicPages, video → episodeVideo)', async () => {+ it('opens the UI-only Nouns tab and Audio stage by name', async () => {+ const ctx = makeCtx('/pipeline/issues/iss-x/idea');+ const nouns = await dispatchTool('pipeline_open_stage', { stage: 'nouns' }, ctx);+ const audio = await dispatchTool('pipeline_open_stage', { stage: 'audio' }, ctx);+ expect(nouns.path).toBe('/pipeline/issues/iss-x/nouns');+ expect(nouns.summary).toBe('Opened Nouns.');+ expect(audio.path).toBe('/pipeline/issues/iss-x/audio');+ expect(audio.summary).toBe('Opened Audio.');+ });++ it('resolves spoken aliases to visible tabs', async () => {const ctx = makeCtx('/pipeline/issues/iss-x/idea');const r1 = await dispatchTool('pipeline_open_stage', { stage: 'teleplay' }, ctx);expect(r1.stage).toBe('teleplay');const r2 = await dispatchTool('pipeline_open_stage', { stage: 'pages' }, ctx);- expect(r2.stage).toBe('comicPages');+ expect(r2.stage).toBe('comicScript');const r3 = await dispatchTool('pipeline_open_stage', { stage: 'video' }, ctx);expect(r3.stage).toBe('episodeVideo');});@@ -1325,9 +1347,9 @@ describe('pipeline stage navigation tools', () => {// at "Unknown stage" with the user staring at a working group.const ctx = makeCtx('/pipeline/issues/iss-x/idea');const r1 = await dispatchTool('pipeline_open_stage', { stage: 'comic page' }, ctx);- expect(r1.stage).toBe('comicPages');+ expect(r1.stage).toBe('comicScript');const r2 = await dispatchTool('pipeline_open_stage', { stage: 'page' }, ctx);- expect(r2.stage).toBe('comicPages');+ expect(r2.stage).toBe('comicScript');});it('rejects an unknown stage with a suggestion list', async () => {@@ -1347,14 +1369,21 @@ describe('pipeline stage navigation tools', () => {expect(r.ok).toBe(true);// If the query bled into the issueId or stage, the navigate path// would carry "?foo=bar" or fall back to 'idea' as the current stage.- expect(ctx.sideEffects[0].path).toBe('/pipeline/issues/iss-abc/comicScript');+ expect(ctx.sideEffects[0].path).toBe('/pipeline/issues/iss-abc/nouns');});it('strips a hash anchor from the path before parsing the id', async () => {const ctx = makeCtx('/pipeline/issues/iss-abc/prose#anchor');const r = await dispatchTool('pipeline_next_stage', {}, ctx);expect(r.ok).toBe(true);- expect(ctx.sideEffects[0].path).toBe('/pipeline/issues/iss-abc/comicScript');+ expect(ctx.sideEffects[0].path).toBe('/pipeline/issues/iss-abc/nouns');+ });++ it('normalizes a legacy comicPages URL to the merged Comic tab', async () => {+ const ctx = makeCtx('/pipeline/issues/iss-abc/comicPages');+ const r = await dispatchTool('pipeline_next_stage', {}, ctx);+ expect(r.stage).toBe('teleplay');+ expect(ctx.sideEffects[0].path).toBe('/pipeline/issues/iss-abc/teleplay');});it('tolerates a missing UI state', async () => {@@ -1392,6 +1421,9 @@ describe('pipeline stage navigation tools', () => {expect(classifyIntent('open episode').has('pipeline')).toBe(true);expect(classifyIntent('open video').has('pipeline')).toBe(true);expect(classifyIntent('back to story').has('pipeline')).toBe(true);+ expect(classifyIntent('open nouns').has('pipeline')).toBe(true);+ expect(classifyIntent('open audio').has('pipeline')).toBe(true);+ expect(classifyIntent('open voice over').has('pipeline')).toBe(true);});});});diff --git a/server/services/voice/tools/pipeline.js b/server/services/voice/tools/pipeline.jsindex d9190a6ee7..5328a7c6b4 100644--- a/server/services/voice/tools/pipeline.js+++ b/server/services/voice/tools/pipeline.js@@ -2,41 +2,22 @@// named stage of the current pipeline issue. These only work on a// /pipeline/issues/... page; off-page calls return a friendly error.-import { NAVIGABLE_STAGE_IDS as PIPELINE_STAGE_IDS } from '../../pipeline/issuesShared.js';+import {+ buildPipelineIntentRe,+ PIPELINE_STAGE_ALIASES,+ PIPELINE_STAGE_LABELS,+ PIPELINE_TAB_STAGE_IDS,+} from '../../../lib/pipelineStages.js';// Pipeline stage navigation — fires on "next stage", "previous stage",// "back to prose", "open the storyboards", "open prose", "open teleplay",-// and the stage names + their spoken aliases (idea, prose, story,-// comic script, teleplay, comic pages, pages, storyboards, scenes,-// episode video, episode, video). The stage-name alternation is shared+// and every stage name + spoken alias declared in pipelineStages.js. The+// stage-name alternation is derived from that table and shared// across open/go-to/back-to so users don't need to say "stage" as a// suffix. The leading anchors keep "take me to pipeline" out of this// group — that still routes to ui_navigate.//-// Alias list must mirror PIPELINE_STAGE_ALIASES below so any alias-// accepted by pipeline_open_stage actually triggers the group.-export const PIPELINE_INTENT_RE = /\b(?:next stage|previous stage|prev stage|stage (?:advance|forward|back)|(?:open|go to|back to)(?: the)? (?:idea|prose|story|comic ?script|comicscript|comics|tv ?script|tvscript|teleplay|comic ?pages?|comicpages|pages?|storyboards?|scenes|episode ?video|episodevideo|episode|video)(?: stage)?)\b/i;--const PIPELINE_STAGE_LABELS = {- idea: 'Idea',- prose: 'Prose',- comicScript: 'Comic Script',- teleplay: 'Teleplay',- comicPages: 'Comic Pages',- storyboards: 'Storyboards',- episodeVideo: 'Episode Video',-};-// Spoken aliases → canonical stage ids. `resolveNavCommand` covers top-level-// pages but not in-route stage names, so this is a dedicated table.-const PIPELINE_STAGE_ALIASES = {- idea: 'idea',- prose: 'prose', story: 'prose',- 'comic script': 'comicScript', comicscript: 'comicScript', comics: 'comicScript',- 'tv script': 'teleplay', tvscript: 'teleplay', teleplay: 'teleplay',- 'comic pages': 'comicPages', 'comic page': 'comicPages', comicpages: 'comicPages', pages: 'comicPages', page: 'comicPages',- storyboards: 'storyboards', storyboard: 'storyboards', scenes: 'storyboards',- 'episode video': 'episodeVideo', episodevideo: 'episodeVideo', episode: 'episodeVideo', video: 'episodeVideo',-};+export const PIPELINE_INTENT_RE = buildPipelineIntentRe();const parsePipelineIssuePath = (path) => {if (typeof path !== 'string') return null;// Strip query/hash before matching — `[^/]+` would otherwise greedily@@ -45,7 +26,10 @@ const parsePipelineIssuePath = (path) => {const clean = path.split(/[?#]/)[0];const m = clean.match(/^\/pipeline\/issues\/([^/]+)(?:\/([^/]+))?/);if (!m) return null;- const stage = PIPELINE_STAGE_IDS.includes(m[2]) ? m[2] : 'idea';+ // Older bookmarks may still point at the hidden comicPages data-stage URL.+ // Treat it as the merged Comic tab so relative navigation stays intuitive.+ const requestedStage = m[2] === 'comicPages' ? 'comicScript' : m[2];+ const stage = PIPELINE_TAB_STAGE_IDS.includes(requestedStage) ? requestedStage : 'idea';return { issueId: m[1], stage };};const NOT_ON_PIPELINE_ISSUE_PAGE = {@@ -62,16 +46,16 @@ const navigateToPipelineStage = (issueId, stage, ctx) => {export const PIPELINE_TOOLS = [{name: 'pipeline_next_stage',- description: 'Advance to the next stage of the current pipeline issue (Idea → Prose → Comic Script → Teleplay → Comic Pages → Storyboards → Episode Video). Only works on a /pipeline/issues/... page.',+ description: 'Advance to the next visible stage of the current pipeline issue (Idea → Prose → Nouns → Comic → Teleplay → Storyboards → Video → Audio). Only works on a /pipeline/issues/... page.',parameters: { type: 'object', properties: {} },execute: async (_args, ctx = {}) => {const cur = parsePipelineIssuePath(ctx.state?.ui?.path);if (!cur) return NOT_ON_PIPELINE_ISSUE_PAGE;- const idx = PIPELINE_STAGE_IDS.indexOf(cur.stage);- if (idx === PIPELINE_STAGE_IDS.length - 1) {+ const idx = PIPELINE_TAB_STAGE_IDS.indexOf(cur.stage);+ if (idx === PIPELINE_TAB_STAGE_IDS.length - 1) {return { ok: false, error: 'Already on last stage', summary: `Already on ${PIPELINE_STAGE_LABELS[cur.stage]} — that's the last stage.` };}- return navigateToPipelineStage(cur.issueId, PIPELINE_STAGE_IDS[idx + 1], ctx);+ return navigateToPipelineStage(cur.issueId, PIPELINE_TAB_STAGE_IDS[idx + 1], ctx);},},{@@ -81,11 +65,11 @@ export const PIPELINE_TOOLS = [execute: async (_args, ctx = {}) => {const cur = parsePipelineIssuePath(ctx.state?.ui?.path);if (!cur) return NOT_ON_PIPELINE_ISSUE_PAGE;- const idx = PIPELINE_STAGE_IDS.indexOf(cur.stage);+ const idx = PIPELINE_TAB_STAGE_IDS.indexOf(cur.stage);if (idx === 0) {return { ok: false, error: 'Already on first stage', summary: `Already on ${PIPELINE_STAGE_LABELS[cur.stage]} — that's the first stage.` };}- return navigateToPipelineStage(cur.issueId, PIPELINE_STAGE_IDS[idx - 1], ctx);+ return navigateToPipelineStage(cur.issueId, PIPELINE_TAB_STAGE_IDS[idx - 1], ctx);},},{@@ -96,7 +80,7 @@ export const PIPELINE_TOOLS = [properties: {stage: {type: 'string',- description: 'Stage name (idea, prose, comic script, tv script, comic pages, storyboards, episode video).',+ description: 'Stage name (idea, prose, nouns, comic script, tv script, storyboards, episode video, audio).',},},required: ['stage'],@@ -106,16 +90,16 @@ export const PIPELINE_TOOLS = [if (!cur) return NOT_ON_PIPELINE_ISSUE_PAGE;const key = String(stage || '').trim().toLowerCase();// Build a case-insensitive canonical lookup so "Prose", "PROSE",- // "prose" all resolve. PIPELINE_STAGE_IDS is mixed-case ('idea',+ // "prose" all resolve. PIPELINE_TAB_STAGE_IDS is mixed-case ('idea',// 'comicScript', ...) so a direct .includes(key) wouldn't match;// compare lowercased forms instead.- const canonicalById = PIPELINE_STAGE_IDS.find((id) => id.toLowerCase() === key);+ const canonicalById = PIPELINE_TAB_STAGE_IDS.find((id) => id.toLowerCase() === key);const canonical = PIPELINE_STAGE_ALIASES[key] || canonicalById || null;if (!canonical) {return {ok: false,error: `Unknown stage "${stage}"`,- summary: `I don't know a stage named "${stage}". Try: idea, prose, comic script, tv script, comic pages, storyboards, or episode video.`,+ summary: `I don't know a stage named "${stage}". Try: idea, prose, nouns, comic script, tv script, storyboards, episode video, or audio.`,};}return navigateToPipelineStage(cur.issueId, canonical, ctx);