@cyber-dash-tech/revela 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ import type { PromptMode } from "./prompt-builder"
2
+
3
+ export interface PendingCommandIntent {
4
+ sessionID: string
5
+ name: string
6
+ mode: PromptMode
7
+ visibleText: string
8
+ hiddenPrompt: string
9
+ createdAt: number
10
+ }
11
+
12
+ const pendingCommandIntents = new Map<string, PendingCommandIntent>()
13
+
14
+ export function setPendingCommandIntent(intent: Omit<PendingCommandIntent, "createdAt"> & { createdAt?: number }): PendingCommandIntent {
15
+ const normalized: PendingCommandIntent = {
16
+ ...intent,
17
+ createdAt: intent.createdAt ?? Date.now(),
18
+ }
19
+ pendingCommandIntents.set(normalized.sessionID, normalized)
20
+ return normalized
21
+ }
22
+
23
+ export function peekPendingCommandIntent(sessionID: string): PendingCommandIntent | undefined {
24
+ if (!sessionID) return undefined
25
+ return pendingCommandIntents.get(sessionID)
26
+ }
27
+
28
+ export function takePendingCommandIntent(sessionID: string): PendingCommandIntent | undefined {
29
+ if (!sessionID) return undefined
30
+ const intent = pendingCommandIntents.get(sessionID)
31
+ if (intent) pendingCommandIntents.delete(sessionID)
32
+ return intent
33
+ }
34
+
35
+ export function clearPendingCommandIntent(sessionID: string): void {
36
+ if (!sessionID) return
37
+ pendingCommandIntents.delete(sessionID)
38
+ }
39
+
40
+ export function clearAllPendingCommandIntents(): void {
41
+ pendingCommandIntents.clear()
42
+ }
43
+
44
+ export function formatCommandIntentSystemBlock(intent: PendingCommandIntent): string {
45
+ return [
46
+ "<revela-command-intent>",
47
+ `User invoked: /revela ${intent.name}`,
48
+ `Prompt mode: ${intent.mode}`,
49
+ "Visible user intent:",
50
+ intent.visibleText,
51
+ "",
52
+ "Execute the hidden workflow instructions below with the available Revela tools.",
53
+ "Do not persist this command block as workspace memory or user preference.",
54
+ "",
55
+ "Hidden workflow instructions:",
56
+ intent.hiddenPrompt,
57
+ "</revela-command-intent>",
58
+ ].join("\n")
59
+ }
@@ -34,7 +34,7 @@ export async function handleBrief(
34
34
  await send(
35
35
  `**Executive brief not rendered**\n\n${result.reason}\n\n` +
36
36
  (result.narrativeHash ? `Narrative hash: \`${result.narrativeHash}\`\n\n` : "") +
37
- "Run `/revela review` and approve the current narrative, or record an explicit render override before retrying."
37
+ "Run `/revela story` and approve the current narrative, or record an explicit render override before retrying."
38
38
  )
39
39
  return
40
40
  }
@@ -36,7 +36,7 @@ export async function handleDesignsActivate(
36
36
  try {
37
37
  activateDesign(name)
38
38
  buildPrompt({ mode: "narrative" })
39
- await send(`**Design activated:** \`${name}\`\nNarrative prompt rebuilt. The design will apply when \`/revela deck\` enters deck-render mode.`)
39
+ await send(`**Design activated:** \`${name}\`\nNarrative prompt rebuilt. The design will apply when \`/revela make deck\` enters deck-render mode.`)
40
40
  } catch (e: any) {
41
41
  await send(`**Error:** ${e.message}`)
42
42
  }
@@ -36,7 +36,7 @@ export async function handleDomainsActivate(
36
36
  try {
37
37
  activateDomain(name)
38
38
  buildPrompt({ mode: "narrative" })
39
- await send(`**Domain activated:** \`${name}\`\nNarrative prompt rebuilt. Domain reasoning applies now; deck-specific render guidance applies during \`/revela deck\`.`)
39
+ await send(`**Domain activated:** \`${name}\`\nNarrative prompt rebuilt. Domain reasoning applies now; deck-specific render guidance applies during \`/revela make deck\`.`)
40
40
  } catch (e: any) {
41
41
  await send(`**Error:** ${e.message}`)
42
42
  }
@@ -1,26 +1,7 @@
1
- import { openRefineDeck } from "../refine/open"
2
-
3
1
  export async function handleEdit(
4
2
  options: { client: any; sessionID: string; workspaceRoot: string; openBrowser?: boolean },
5
3
  send: (text: string) => Promise<void>,
6
4
  ): Promise<void> {
7
- try {
8
- const result = openRefineDeck("", {
9
- client: options.client,
10
- sessionID: options.sessionID,
11
- workspaceRoot: options.workspaceRoot,
12
- mode: "edit",
13
- openBrowser: options.openBrowser,
14
- })
15
-
16
- await send(
17
- `\`/revela edit\` is deprecated. Opened \`/revela refine\` in Edit mode for the active HTML deck.\n` +
18
- `File: \`${result.deck.file}\`\n` +
19
- `${result.stateNote}\n` +
20
- `URL: ${result.url}\n\n` +
21
- `Use \`/revela refine\` directly going forward. Use Ctrl/Cmd-click in the browser to reference elements, then use the Edit tab to send targeted change comments.`
22
- )
23
- } catch (e: any) {
24
- await send(`**Edit failed:** ${e.message || String(e)}`)
25
- }
5
+ void options
6
+ await send("`/revela edit` has been removed. Use `/revela refine` for the unified reading, inspection, and editing workspace.")
26
7
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * lib/commands/enable.ts
3
3
  *
4
- * Handler for `/revela enable` — activates Revela narrative/artifact mode.
4
+ * Handler for `/revela enable` — activates Revela ambient narrative mode.
5
5
  */
6
6
 
7
7
  import { existsSync } from "fs"
@@ -19,7 +19,7 @@ export async function handleEnable(
19
19
  const design = activeDesign()
20
20
  const domain = activeDomain()
21
21
 
22
- // Always rebuild narrative mode on enable. A prior `/revela deck` handoff may
22
+ // Always rebuild narrative mode on enable. A prior `/revela make deck` handoff may
23
23
  // have intentionally switched the active prompt to deck-render mode.
24
24
  if (!existsSync(ACTIVE_PROMPT_FILE)) {
25
25
  log.warn("active prompt file missing on enable — rebuilding", { promptFile: ACTIVE_PROMPT_FILE })
@@ -30,7 +30,7 @@ export async function handleEnable(
30
30
  } catch (e) {
31
31
  log.error("prompt rebuild failed on enable", { error: e instanceof Error ? e.message : String(e) })
32
32
  await send(
33
- `**Revela enabled (with warnings).** Narrative/artifact mode is active, ` +
33
+ `**Revela ambient mode enabled (with warnings).** Narrative mode is active for normal chat, ` +
34
34
  `but the prompt file could not be built. ` +
35
35
  `Try \`/revela disable\` then \`/revela enable\` again, or check that the package is correctly installed.\n\n` +
36
36
  `Design: \`${design}\` · Domain: \`${domain}\``
@@ -40,9 +40,9 @@ export async function handleEnable(
40
40
 
41
41
  log.info("revela enabled", { design, domain })
42
42
  await send(
43
- `**Revela enabled.** Narrative/artifact mode is now active.\n` +
43
+ `**Revela ambient mode enabled.** Normal chat will stay in Revela narrative mode.\n` +
44
44
  `Design: \`${design}\` · Domain: \`${domain}\`\n\n` +
45
- `The narrative-first prompt will be injected into every message. ` +
46
- `Use \`/revela deck\` when you are ready to enter deck-render mode.`
45
+ `Explicit workflow commands like \`/revela init\`, \`/revela story\`, and \`/revela make deck\` work without enabling first. ` +
46
+ `Use \`/revela disable\` to return normal chat to plain OpenCode mode.`
47
47
  )
48
48
  }
@@ -24,18 +24,26 @@ export async function handleHelp(
24
24
  `🟠 **Domain:** \`${domain}\`\n\n` +
25
25
  `---\n\n` +
26
26
  `**Commands**\n\n` +
27
- `\`/revela enable\` — enable Revela narrative/artifact mode\n` +
28
- `\`/revela disable\` — disable Revela mode\n` +
27
+ `\`/revela enable\` — optional ambient narrative mode for normal chat\n` +
28
+ `\`/revela disable\` — disable ambient Revela mode\n` +
29
29
  `\`/revela init\` — initialize or refresh workspace DECKS.json\n` +
30
- `\`/revela review\` review narrative readiness and approval state\n` +
31
- `\`/revela narrative\` — open read-only narrative workspace map\n` +
32
- `\`/revela brief [file.md]\` render executive brief from approved narrative\n` +
33
- `\`/revela deck\` start deck handoff from approved narrative\n` +
34
- `\`/revela deck --review\` review deck/artifact readiness before writing HTML\n` +
30
+ `\`/revela research\` research, bind evidence, and reduce story gaps\n` +
31
+ `\`/revela story [-l language]\` — open the read-only story workspace UI\n` +
32
+ `\`/revela review\` legacy readiness report for story state\n` +
33
+ `\`/revela narrative\` compatibility alias for /revela story\n` +
34
+ `\`/revela make deck\` make a deck from approved story state\n` +
35
+ `\`/revela make deck --review\` — review deck/artifact readiness before writing HTML\n` +
36
+ `\`/revela make brief [file.md]\` — render executive brief from approved story\n` +
37
+ `\`/revela deck\` — compatibility alias for /revela make deck\n` +
38
+ `\`/revela brief [file.md]\` — compatibility alias for /revela make brief\n` +
35
39
  `\`/revela refine\` — open unified reading, inspection, and editing workspace\n` +
36
- `\`/revela edit\` — deprecated compatibility shim to /revela refine Edit\n` +
37
40
  `\`/revela inspect\` — deprecated compatibility shim to /revela refine Inspect\n` +
38
41
  `\`/revela remember <text>\` — save an explicit preference to DECKS.json\n` +
42
+ `\`/revela design\` — list installed designs\n` +
43
+ `\`/revela design use <name>\` — activate a design\n` +
44
+ `\`/revela design new <name>\` — create a custom design with AI\n` +
45
+ `\`/revela design edit <name>\` — refine an existing custom design with AI\n` +
46
+ `\`/revela design preview [name]\` — open a design preview in browser\n` +
39
47
  `\`/revela designs\` — list installed designs\n` +
40
48
  `\`/revela designs <name>\` — activate a design\n` +
41
49
  `\`/revela designs-new <name>\` — create a new custom design with AI\n` +
@@ -17,7 +17,7 @@ Goal:
17
17
  - Build or update ${DECKS_STATE_FILE}, the workspace-level machine-readable state file for Revela narrative and artifact work.
18
18
  - Use the \`revela-decks\` tool for state updates. Do not write or patch ${DECKS_STATE_FILE} directly.
19
19
  - Capture stable narrative context first: primary audience, belief before, belief after, decision/action, thesis, central claims, evidence availability, objections, risks, available source materials, existing artifact history, and open questions.
20
- - Do not treat initialization as permission to write a deck. Narrative readiness is reviewed later by \`/revela review\`; deck/artifact readiness is reviewed by \`/revela deck --review\`.
20
+ - Do not treat initialization as permission to write a deck. Narrative readiness is reviewed later by \`/revela story\`; deck/artifact readiness is reviewed by \`/revela make deck --review\`.
21
21
  - Do not require slide count, visual style, design selection, output path, layout choices, or component choices during narrative initialization unless the user explicitly asks to render a deck now.
22
22
  - ${DECKS_STATE_FILE} is the compatibility workspace-state file. Deck specs are render-target projections, not the center of initialization.
23
23
 
@@ -12,7 +12,33 @@ export interface NarrativeArgs {
12
12
  raw: boolean
13
13
  }
14
14
 
15
+ export interface StoryArgs {
16
+ language: NarrativeViewLanguage
17
+ }
18
+
15
19
  export type ParseNarrativeArgsResult = { ok: true; args: NarrativeArgs } | { ok: false; error: string }
20
+ export type ParseStoryArgsResult = { ok: true; args: StoryArgs } | { ok: false; error: string }
21
+
22
+ export function parseStoryArgs(param: string): ParseStoryArgsResult {
23
+ const tokens = param.trim().split(/\s+/).filter(Boolean)
24
+ let language: NarrativeViewLanguage = "en"
25
+
26
+ for (let i = 0; i < tokens.length; i++) {
27
+ const token = tokens[i]
28
+ if (token === "--language" || token === "-l") {
29
+ const value = tokens[++i]
30
+ if (!value) return { ok: false, error: "Usage: `/revela story [--language <language> | -l <language>]`" }
31
+ language = normalizeLanguageRequest(value)
32
+ continue
33
+ }
34
+ if (token.startsWith("--language=")) {
35
+ return { ok: false, error: "Usage: `/revela story --language <language>` or `/revela story -l <language>`. Do not use `--language=<language>`." }
36
+ }
37
+ return { ok: false, error: "Usage: `/revela story [--language <language> | -l <language>]`. Use `/revela review` for a readiness report." }
38
+ }
39
+
40
+ return { ok: true, args: { language } }
41
+ }
16
42
 
17
43
  export function parseNarrativeArgs(param: string): ParseNarrativeArgsResult {
18
44
  const tokens = param.trim().split(/\s+/).filter(Boolean)
@@ -0,0 +1,66 @@
1
+ import { DECKS_STATE_FILE } from "../decks-state"
2
+
3
+ export function buildResearchPrompt({
4
+ exists,
5
+ workspaceRoot,
6
+ }: {
7
+ exists: boolean
8
+ workspaceRoot?: string
9
+ }): string {
10
+ const state = exists
11
+ ? `${DECKS_STATE_FILE} exists. Read it through the revela-decks tool before researching.`
12
+ : `${DECKS_STATE_FILE} does not exist yet. Do not start broad internet research; initialize the workspace first with /revela init unless the user supplied a specific research question in chat.`
13
+
14
+ return `Run Revela closed-loop research.
15
+
16
+ Goal:
17
+ - Reduce open gaps, unsupported scope, weak evidence, unattached findings, and overextended relation rationale for the current story.
18
+ - Drive research from canonical narrative gaps: unsupported central claims, objections, risks, decision questions, explicit researchGaps, and claim_chain_gap warnings.
19
+ - Treat /revela research as authorization to bind clearly supported findings into canonical evidence without asking for item-by-item user confirmation.
20
+ - Preserve evidence boundaries: eliminate caveats only when evidence or narrower wording actually resolves them; otherwise keep precise caveats visible.
21
+ - Do not write decks, briefs, or design artifacts during research.
22
+
23
+ Current state:
24
+ - ${state}
25
+ ${workspaceRoot ? `- Current workspace root: \`${workspaceRoot}\`` : ""}
26
+
27
+ Closed-loop workflow:
28
+ 1. Call \`revela-decks\` action \`read\`, then \`reviewNarrative\`.
29
+ 2. If current research gaps are missing or stale, call \`deriveResearchGaps\` when useful. Do not invent gaps that are not tied to a claim, objection, risk, decision, or narrative issue.
30
+ 3. Run up to 3 research loops unless the stop conditions below are met earlier.
31
+ 4. At the start of each loop, choose the highest-value 2-3 targets: open/in-progress high-priority gaps, unattached saved findings, unsupported central claims, weak evidence, high-priority objections/risks, and claim_chain_gap relations. Prefer targets that can improve readiness or materially reduce caveats. Do not repeat searches for claims already strongly supported.
32
+ 5. If a target already has saved findings, prioritize binding/narrowing before doing more external search.
33
+ 6. For targets needing external evidence, mark matching gaps \`in_progress\` with \`revela-decks updateResearchGap\`, then delegate search to the \`revela-research\` subagent. Ask it for source URLs, quotes/snippets, dates or locations when available, caveats, remaining gaps, and a \`## Recommended evidence bindings\` section with claimId, quote, source, supportScope, unsupportedScope, caveat, and strength. Save findings with \`revela-research-save\` under \`researches/{topic}/{axis}.md\` using \`## Data\`, \`## Cases\`, \`## Images\`, and \`## Gaps\` sections as applicable.
34
+ 7. After findings are saved or existing findings are selected, read or inspect the findings file. Attach it with \`revela-decks attachResearchFindings\` when it maps to an existing research axis.
35
+ 8. Automatically bind evidence when all binding criteria are met. Use \`revela-decks applyEvidenceCandidates\` for concrete candidate ids when available, or \`upsertNarrative\` to preserve canonical evidence bindings with exact source, URL/path, quote/snippet, support scope, unsupported scope, caveat, and strength.
36
+ 9. Binding criteria: claimId exists; quote/snippet is traceable to the source and is not invented; source URL or workspace source path is present; supportScope and unsupportedScope are explicit; strength is strong or useful partial; caveat is preserved; binding does not expand the claim beyond the evidence.
37
+ 10. If a claim or relation is broader than the evidence, narrow the claim text, supportedScope, unsupportedScope, or relation rationale through \`upsertNarrative\` only when the narrower wording preserves the user's strategic meaning and source boundaries. Do not silently change the decision ask, central recommendation, or approval meaning.
38
+ 11. Update matching gaps after binding: use \`evidence_bound\` when canonical evidence was added, \`closed\` when the gap is resolved or non-researchable, \`findings_saved\` only when findings exist but binding criteria are not met, and \`open\` with notes when more external research is still warranted.
39
+ 12. Re-run \`reviewNarrative\` after each loop. Compare against the previous loop: fewer open gaps, fewer unattached findings, stronger evidence, narrower unsupported scope, or clearer internal-data caveats should count as progress.
40
+
41
+ Stop conditions:
42
+ - No open externally researchable gaps remain.
43
+ - All useful saved findings have been attached or evidence-bound.
44
+ - A full loop produces no new bindable evidence, narrower wording, or gap status improvement.
45
+ - Remaining gaps require internal user/company data, confidential sources, or strategic judgment.
46
+ - 3 loops have completed.
47
+
48
+ Report format:
49
+ - Start with \`Research loop completed after <n> round(s).\`
50
+ - List bound evidence by claim id and count.
51
+ - List gaps closed or moved to evidence_bound.
52
+ - List claims or relations narrowed, with the remaining unsupported scope.
53
+ - List remaining caveats only as one of: \`internal_data_needed\`, \`not_publicly_researchable\`, \`source_quality_limit\`, or \`still_open\`.
54
+ - If no binding happened, say why binding criteria failed and what exact source type is needed next.
55
+ - End with the next smallest story action, not a generic request for user confirmation.
56
+
57
+ Rules:
58
+ - Do not use primary-agent broad websearch. Use the \`revela-research\` subagent for external search.
59
+ - Do not invent quotes, source paths, URLs, page references, locations, or caveats.
60
+ - Do not treat \`researches/**/*.md\` as canonical evidence until attached or evidence-bound, but do not stop at findings_saved when binding criteria are met.
61
+ - Do not mutate canonical claims merely to fit a source; narrow only to preserve evidence boundaries and avoid overstated claims.
62
+ - Do not ask the user to approve each evidence binding. Ask only when binding would change strategic meaning, downgrade a central claim, rely on suspicious sources, or require narrative approval.
63
+ - Do not store secrets, credentials, tokens, or sensitive personal information.
64
+
65
+ Start now by reading ${DECKS_STATE_FILE} through \`revela-decks\`, reviewing current readiness, and running the first research/binding loop.`
66
+ }
@@ -18,7 +18,7 @@ Goal:
18
18
  - Treat this as a narrative readiness review, not a deck HTML write-readiness review.
19
19
  - Do not write, patch, or directly edit ${DECKS_STATE_FILE}. Use the \`revela-decks\` tool for all state changes.
20
20
  - Call \`revela-decks\` action \`reviewNarrative\` as the authoritative deterministic readiness engine.
21
- - Do not call \`revela-decks\` action \`review\` here. That action is the deck/artifact gate and belongs to \`/revela deck --review\`.
21
+ - Do not call \`revela-decks\` action \`review\` here. That action is the deck/artifact gate and belongs to \`/revela make deck --review\`.
22
22
  - Do not treat legacy \`writeReadiness.status\`, old review snapshots, or an existing HTML deck as narrative approval.
23
23
  - Do not write or overwrite \`decks/*.html\` during narrative review.
24
24
  - If the narrative is \`ready_for_approval\`, ask whether the user wants to approve it or revise it. Do not approve automatically.
@@ -50,7 +50,7 @@ Report format:
50
50
  - If warnings exist, list them after blockers as residual risks.
51
51
  - If approval is missing, ask whether the user wants to approve the narrative or revise it.
52
52
  - If approval is stale, say the prior approval no longer matches the current narrative hash.
53
- - Keep deck/artifact readiness separate. If the user wants to review slide-writing readiness, tell them to run \`/revela deck --review\`.
53
+ - Keep deck/artifact readiness separate. If the user wants to review slide-writing readiness, tell them to run \`/revela make deck --review\`.
54
54
 
55
55
  Rules:
56
56
  - Do not write or overwrite \`decks/*.html\` during narrative review.
@@ -73,12 +73,13 @@ export function buildDeckPrompt({
73
73
  ? `${DECKS_STATE_FILE} exists. Read it through the revela-decks tool.`
74
74
  : `${DECKS_STATE_FILE} does not exist yet. Do not invent a deck; initialize narrative state first with /revela init.`
75
75
 
76
- return `Begin Revela deck render handoff.
76
+ return `Begin Revela deck plan handoff.
77
77
 
78
78
  Goal:
79
- - Treat this as the explicit transition from approved narrative state to deck render planning.
79
+ - Treat this as the explicit transition from approved narrative state to user-confirmed deck planning.
80
80
  - Use the deck-render prompt mode for design, layout, component, HTML, QA, and deck artifact rules.
81
- - Do not write or overwrite \`decks/*.html\` until the narrative handoff and deck/artifact gate are both satisfied.
81
+ - Default behavior is two-stage: first show the compiled deck plan with low-fidelity layout sketches, then stop for user confirmation before any artifact review or HTML writing.
82
+ - Do not write or overwrite \`decks/*.html\` until the narrative handoff, explicit user deck-plan confirmation, and deck/artifact gate are all satisfied.
82
83
  - Do not treat legacy \`writeReadiness.status\`, old review snapshots, or existing HTML decks as narrative approval.
83
84
  - Do not bypass the deck HTML contract, review snapshot freshness, source-trace expectations, or export preflight protections.
84
85
 
@@ -92,25 +93,61 @@ Workflow:
92
93
  3. If narrative readiness is \`approved\`, continue. If it is \`ready_for_approval\`, ask the user for explicit approval before continuing. If it is blocked, stale, or needs research, stop and report the smallest next action. Do not call \`approveNarrative\` unless the user explicitly approves or requests a render override.
93
94
  4. After approval or explicit render override exists, call \`revela-decks\` action \`compileDeckPlan\`. This projects canonical narrative claims and evidence bindings into compatibility \`slides[]\` and \`slides[].evidence[]\`; it must not write HTML.
94
95
  5. If \`compileDeckPlan\` returns \`skipped\`, stop and report the reason. Do not invent slide specs manually to bypass approval.
95
- 6. Ask for or confirm visual design only after the narrative deck plan exists. Fetch required design layouts/components with \`revela-designs read\` as needed.
96
- 7. Update only deck/artifact metadata through \`revela-decks upsertDeck\` / \`upsertSlides\` when required by confirmed design/layout choices. Do not change canonical narrative claims unless the user asks to revise the narrative.
97
- 8. Call \`revela-decks\` action \`review\` as the artifact gate. It computes \`writeReadiness\` and review snapshots for deck HTML writing.
98
- 9. Write \`decks/*.html\` only if the deck/artifact gate is ready and all deck HTML contract requirements can be satisfied. If not ready, report blockers and stop.
99
-
100
- Report format before any HTML write:
101
- - Start with \`Deck handoff: <status>\`.
96
+ 6. Present the compiled deck plan to the user and include a low-fidelity layout sketch for every slide. The sketch is ASCII/text structure only; do not generate visual images or HTML mockups.
97
+ 7. Stop after presenting the plan. Ask the user to confirm or request changes. Do not call \`revela-decks review\`, do not fetch design context, and do not write HTML in the same turn unless the user had already explicitly confirmed the current plan before this command.
98
+ 8. Only after explicit user confirmation of the current slide plan, call \`revela-decks\` action \`confirmDeckPlan\` with \`approvalBy=user\` and a compact \`approvalNote\`.
99
+ 9. After confirmation is recorded, ask for or confirm visual design only after the narrative deck plan exists. Fetch required design layouts/components with \`revela-designs read\` as needed.
100
+ 10. Update only deck/artifact metadata through \`revela-decks upsertDeck\` / \`upsertSlides\` when required by confirmed design/layout choices. Do not change canonical narrative claims unless the user asks to revise the narrative.
101
+ 11. Call \`revela-decks\` action \`review\` as the artifact gate. It computes \`writeReadiness\` and review snapshots for deck HTML writing. If it reports \`slide_plan_unconfirmed\`, stop and ask for explicit deck-plan confirmation.
102
+ 12. Write \`decks/*.html\` only if the deck/artifact gate is ready and all deck HTML contract requirements can be satisfied. After each HTML write, the system automatically runs artifact QA before opening Refine.
103
+ 13. If post-write artifact QA reports hard errors, fix them and let QA run again. Refine opens only after hard errors pass. Density warnings about thin claim/evidence substance should be reported and improved when useful, but they do not block Refine.
104
+
105
+ Deck plan report format:
106
+ - Start with \`Deck plan: awaiting confirmation\` when a plan was compiled and has not yet been confirmed.
102
107
  - Include narrative readiness status and narrative hash when available.
103
108
  - Include whether \`compileDeckPlan\` compiled or skipped.
109
+ - For every slide, include: slide index, title, purpose, narrative role, low-fidelity layout sketch, layout, components, primary/supporting claim ids, evidence binding ids or source summary, visual intent, and caveats/unsupported scope.
110
+ - Use this sketch style or similarly simple ASCII boxes:
111
+
112
+ \`\`\`text
113
+ Slide N: <title>
114
+
115
+ Purpose:
116
+ <one sentence>
117
+
118
+ Layout sketch:
119
+ ┌──────────────────────────────────────────────┐
120
+ │ Headline │
121
+ ├──────────────────────┬───────────────────────┤
122
+ │ Main chart/media │ Evidence boxes │
123
+ │ │ Source/caveat note │
124
+ └──────────────────────┴───────────────────────┘
125
+
126
+ Layout:
127
+ Components:
128
+ Primary claim:
129
+ Supporting claims:
130
+ Evidence bindings:
131
+ Caveats / unsupported scope:
132
+ \`\`\`
133
+ - End by asking the user to confirm the deck plan or request changes.
134
+
135
+ Report format before any HTML write after confirmation:
136
+ - Start with \`Deck handoff: <status>\`.
137
+ - Include which user-confirmed plan, approved narrative hash, and deck review snapshot authorized the artifact work.
104
138
  - If deck/artifact review is blocked, list blockers separately from narrative blockers.
105
- - If proceeding to HTML writing, state which approved narrative hash and deck review snapshot authorized the artifact work.
139
+ - After writing HTML, read the appended \`Artifact QA\` report from the tool output. If it failed, fix hard errors before considering the deck ready for Refine.
106
140
 
107
141
  Rules:
108
142
  - \`compileDeckPlan\` is the canonical narrative-to-deck planning path. Do not manually invent slide specs to avoid it.
109
143
  - Deck slide specs are render-target projections. Canonical narrative remains the authority for audience, decision, claims, evidence boundaries, objections, risks, and approval.
110
144
  - Applying evidence candidates, rewriting canonical claims, or approving narratives requires explicit user instruction.
145
+ - If the user requests slide order, layout, component, or visual-intent changes that do not alter meaning, update only the deck projection through \`upsertSlides\` and present the revised plan for confirmation.
146
+ - If the user requests claim, evidence, caveat, decision, or recommendation meaning changes, update canonical narrative first and rerun narrative review/approval or explicit render override before compiling a new deck plan.
111
147
  - Do not store secrets, credentials, tokens, or sensitive personal information.
148
+ - Artifact QA requires each slide to render exactly 1920x1080px, not merely any 16:9 ratio. It also checks component compliance, text overflow/clipping, page scrollbars, and whether normal QA-enabled content slides have enough claim/evidence/source substance.
112
149
 
113
- Start now by reading ${DECKS_STATE_FILE}, reviewing narrative readiness, and then compiling the deck plan only if approval or explicit render override is current.`
150
+ Start now by reading ${DECKS_STATE_FILE}, reviewing narrative readiness, compiling the deck plan only if approval or explicit render override is current, then showing the deck plan with low-fidelity layout sketches and stopping for user confirmation.`
114
151
  }
115
152
 
116
153
  export function buildDeckReviewPrompt({
@@ -128,7 +165,7 @@ export function buildDeckReviewPrompt({
128
165
 
129
166
  Goal:
130
167
  - Use ${DECKS_STATE_FILE} as the source of truth for whether the current workspace deck is ready to be written to \`decks/*.html\`.
131
- - Treat this as an artifact gate for deck rendering, not strategic narrative approval. Narrative readiness is reviewed by \`/revela review\`.
168
+ - Treat this as an artifact gate for deck rendering, not strategic narrative approval. Narrative readiness reports are reviewed by \`/revela review\`.
132
169
  - Preserve the deck spec for future sessions: every slide's content, layout, components, evidence, visuals, production status, and the 0.9 narrative compiler brief when available.
133
170
  - Do not write, patch, or directly edit ${DECKS_STATE_FILE}. Use the \`revela-decks\` tool for all state changes.
134
171
  - Let \`revela-decks\` action \`review\` compute writeReadiness; do not manually set readiness to ready.