@cyber-dash-tech/revela 0.15.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.
- package/README.md +6 -7
- package/README.zh-CN.md +6 -7
- package/designs/starter/DESIGN.md +168 -171
- package/designs/starter/preview.html +2 -2
- package/designs/summit/DESIGN.md +283 -129
- package/lib/commands/edit.ts +2 -21
- package/lib/commands/help.ts +1 -2
- package/lib/commands/narrative.ts +26 -0
- package/lib/commands/review.ts +49 -12
- package/lib/decks-state.ts +122 -3
- package/lib/design/designs.ts +1 -2
- package/lib/edit/prompt.ts +6 -5
- package/lib/edit/resolve-deck.ts +1 -1
- package/lib/narrative-state/render-plan.ts +10 -1
- package/lib/qa/artifact.ts +77 -0
- package/lib/qa/checks.ts +100 -10
- package/lib/qa/index.ts +8 -6
- package/lib/qa/measure.ts +85 -0
- package/lib/refine/open.ts +21 -1
- package/lib/refine/server.ts +127 -4
- package/lib/workspace-state/types.ts +1 -0
- package/package.json +1 -1
- package/plugin.ts +36 -130
- package/skill/NARRATIVE_SKILL.md +1 -1
- package/skill/SKILL.md +5 -10
- package/tools/decks.ts +29 -3
- package/tools/narrative-view.ts +1 -1
- package/tools/qa.ts +17 -11
package/lib/commands/edit.ts
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
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
|
}
|
package/lib/commands/help.ts
CHANGED
|
@@ -28,7 +28,7 @@ export async function handleHelp(
|
|
|
28
28
|
`\`/revela disable\` — disable ambient Revela mode\n` +
|
|
29
29
|
`\`/revela init\` — initialize or refresh workspace DECKS.json\n` +
|
|
30
30
|
`\`/revela research\` — research, bind evidence, and reduce story gaps\n` +
|
|
31
|
-
`\`/revela story\`
|
|
31
|
+
`\`/revela story [-l language]\` — open the read-only story workspace UI\n` +
|
|
32
32
|
`\`/revela review\` — legacy readiness report for story state\n` +
|
|
33
33
|
`\`/revela narrative\` — compatibility alias for /revela story\n` +
|
|
34
34
|
`\`/revela make deck\` — make a deck from approved story state\n` +
|
|
@@ -37,7 +37,6 @@ export async function handleHelp(
|
|
|
37
37
|
`\`/revela deck\` — compatibility alias for /revela make deck\n` +
|
|
38
38
|
`\`/revela brief [file.md]\` — compatibility alias for /revela make brief\n` +
|
|
39
39
|
`\`/revela refine\` — open unified reading, inspection, and editing workspace\n` +
|
|
40
|
-
`\`/revela edit\` — deprecated compatibility shim to /revela refine Edit\n` +
|
|
41
40
|
`\`/revela inspect\` — deprecated compatibility shim to /revela refine Inspect\n` +
|
|
42
41
|
`\`/revela remember <text>\` — save an explicit preference to DECKS.json\n` +
|
|
43
42
|
`\`/revela design\` — list installed designs\n` +
|
|
@@ -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)
|
package/lib/commands/review.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
-
|
|
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.
|
|
96
|
-
7.
|
|
97
|
-
8.
|
|
98
|
-
9.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
-
|
|
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,
|
|
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({
|
package/lib/decks-state.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "./workspace-state/review-snapshots"
|
|
19
19
|
import { WORKSPACE_STATE_FILE, type RenderTarget, type ReviewSnapshot, type WorkspaceAction } from "./workspace-state/types"
|
|
20
20
|
import { normalizeCanonicalNarrativeState, normalizeNarrativeState } from "./narrative-state/normalize"
|
|
21
|
+
import { computeNarrativeHash } from "./narrative-state/hash"
|
|
21
22
|
import type { NarrativeStateV1 } from "./narrative-state/types"
|
|
22
23
|
|
|
23
24
|
export const DECKS_STATE_FILE = WORKSPACE_STATE_FILE
|
|
@@ -91,6 +92,7 @@ export interface DeckSpec {
|
|
|
91
92
|
researchPlan: ResearchAxis[]
|
|
92
93
|
slides: SlideSpec[]
|
|
93
94
|
assets: DeckAsset[]
|
|
95
|
+
planReview?: DeckPlanReview
|
|
94
96
|
writeReadiness: {
|
|
95
97
|
status: WriteReadinessStatus
|
|
96
98
|
blockers: string[]
|
|
@@ -98,6 +100,15 @@ export interface DeckSpec {
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
export interface DeckPlanReview {
|
|
104
|
+
status: "pending" | "confirmed"
|
|
105
|
+
narrativeHash: string
|
|
106
|
+
planHash: string
|
|
107
|
+
confirmedAt?: string
|
|
108
|
+
confirmedBy?: "user"
|
|
109
|
+
summary?: string
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
export interface NarrativeBrief {
|
|
102
113
|
audienceBeliefBefore?: string
|
|
103
114
|
audienceBeliefAfter?: string
|
|
@@ -202,6 +213,7 @@ export type ReadinessSeverity = "blocker" | "warning"
|
|
|
202
213
|
export type ReadinessIssueType =
|
|
203
214
|
| "missing_required_input"
|
|
204
215
|
| "missing_slide_spec"
|
|
216
|
+
| "slide_plan_unconfirmed"
|
|
205
217
|
| "research_not_ready"
|
|
206
218
|
| "missing_evidence"
|
|
207
219
|
| "weak_evidence"
|
|
@@ -278,6 +290,22 @@ const SOURCE_TRACE_ACTION = "Add slide evidence with source plus source trace su
|
|
|
278
290
|
|
|
279
291
|
export interface ReviewDeckStateOptions {
|
|
280
292
|
workspaceRoot?: string
|
|
293
|
+
narrativeHash?: string
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface ConfirmDeckPlanOptions {
|
|
297
|
+
approvedBy?: "user"
|
|
298
|
+
note?: string
|
|
299
|
+
now?: string
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface ConfirmDeckPlanResult {
|
|
303
|
+
confirmed: boolean
|
|
304
|
+
skipped: boolean
|
|
305
|
+
reason?: string
|
|
306
|
+
slug?: string
|
|
307
|
+
narrativeHash?: string
|
|
308
|
+
planHash?: string
|
|
281
309
|
}
|
|
282
310
|
|
|
283
311
|
export function decksStatePath(workspaceRoot: string): string {
|
|
@@ -357,10 +385,74 @@ export function createDeckSpec(input: Partial<DeckSpec> & { slug: string }): Dec
|
|
|
357
385
|
researchPlan: input.researchPlan ?? [],
|
|
358
386
|
slides: normalizeSlides(input.slides ?? []),
|
|
359
387
|
assets: input.assets ?? [],
|
|
388
|
+
planReview: normalizeDeckPlanReview(input.planReview),
|
|
360
389
|
writeReadiness: input.writeReadiness ?? { status: "blocked", blockers: [] },
|
|
361
390
|
}
|
|
362
391
|
}
|
|
363
392
|
|
|
393
|
+
export function deckPlanHash(slides: SlideSpec[]): string {
|
|
394
|
+
return createHash("sha1")
|
|
395
|
+
.update(JSON.stringify(normalizeSlides(slides).map((slide) => ({
|
|
396
|
+
index: slide.index,
|
|
397
|
+
title: slide.title,
|
|
398
|
+
purpose: slide.purpose,
|
|
399
|
+
narrativeRole: slide.narrativeRole,
|
|
400
|
+
layout: slide.layout,
|
|
401
|
+
components: slide.components,
|
|
402
|
+
claimIds: slide.claimIds ?? [],
|
|
403
|
+
claimRefs: slide.claimRefs ?? [],
|
|
404
|
+
evidenceBindingIds: slide.evidenceBindingIds ?? [],
|
|
405
|
+
content: slide.content,
|
|
406
|
+
evidence: slide.evidence,
|
|
407
|
+
visuals: slide.visuals ?? [],
|
|
408
|
+
}))))
|
|
409
|
+
.digest("hex")
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export function currentDeckPlanReviewStatus(deck: DeckSpec, narrativeHash?: string): { current: boolean; stale: boolean; reason?: string; planHash: string } {
|
|
413
|
+
const planHash = deckPlanHash(deck.slides)
|
|
414
|
+
const review = deck.planReview
|
|
415
|
+
if (!review) return { current: false, stale: false, reason: "deck plan has not been shown and confirmed", planHash }
|
|
416
|
+
if (review.status !== "confirmed") return { current: false, stale: false, reason: "deck plan is pending user confirmation", planHash }
|
|
417
|
+
if (narrativeHash && review.narrativeHash !== narrativeHash) return { current: false, stale: true, reason: "deck plan confirmation is stale because the narrative hash changed", planHash }
|
|
418
|
+
if (review.planHash !== planHash) return { current: false, stale: true, reason: "deck plan confirmation is stale because the slide plan changed", planHash }
|
|
419
|
+
return { current: true, stale: false, planHash }
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export function confirmDeckPlan(state: DecksState, options: ConfirmDeckPlanOptions = {}): { state: DecksState; result: ConfirmDeckPlanResult } {
|
|
423
|
+
const normalized = normalizeDecksStateWithNarrative(state)
|
|
424
|
+
const key = currentDeckKey(normalized)
|
|
425
|
+
const deck = key ? normalized.decks[key] : undefined
|
|
426
|
+
if (!deck) {
|
|
427
|
+
return { state: normalized, result: { confirmed: false, skipped: true, reason: `No active deck exists in ${DECKS_STATE_FILE}.` } }
|
|
428
|
+
}
|
|
429
|
+
if (deck.slides.length === 0) {
|
|
430
|
+
return { state: normalized, result: { confirmed: false, skipped: true, slug: deck.slug, reason: "Cannot confirm a deck plan with no slides." } }
|
|
431
|
+
}
|
|
432
|
+
const narrative = normalizeNarrativeState(normalized)
|
|
433
|
+
const narrativeHash = computeNarrativeHash(narrative)
|
|
434
|
+
const planHash = deckPlanHash(deck.slides)
|
|
435
|
+
const pending = deck.planReview
|
|
436
|
+
if (pending && pending.status === "pending" && (pending.narrativeHash !== narrativeHash || pending.planHash !== planHash)) {
|
|
437
|
+
return { state: normalized, result: { confirmed: false, skipped: true, slug: deck.slug, narrativeHash, planHash, reason: "Cannot confirm because the pending deck plan is stale. Re-run compileDeckPlan first." } }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
deck.planReview = {
|
|
441
|
+
status: "confirmed",
|
|
442
|
+
narrativeHash,
|
|
443
|
+
planHash,
|
|
444
|
+
confirmedAt: options.now ?? new Date().toISOString(),
|
|
445
|
+
confirmedBy: options.approvedBy ?? "user",
|
|
446
|
+
summary: cleanOptionalText(options.note),
|
|
447
|
+
}
|
|
448
|
+
deck.requiredInputs = { ...deck.requiredInputs, slidePlanConfirmed: true }
|
|
449
|
+
deck.writeReadiness = { status: "blocked", blockers: [] }
|
|
450
|
+
normalized.decks[deck.slug] = deck
|
|
451
|
+
normalized.activeDeck = deck.slug
|
|
452
|
+
normalized.narrative = narrative
|
|
453
|
+
return { state: normalized, result: { confirmed: true, skipped: false, slug: deck.slug, narrativeHash, planHash } }
|
|
454
|
+
}
|
|
455
|
+
|
|
364
456
|
export function readDecksState(workspaceRoot: string): DecksState {
|
|
365
457
|
return readWorkspaceState(workspaceRoot, { fileName: DECKS_STATE_FILE, normalize: normalizeDecksStateWithNarrative })
|
|
366
458
|
}
|
|
@@ -487,7 +579,10 @@ export function reviewDeckState(state: DecksState, slug?: string, options: Revie
|
|
|
487
579
|
}
|
|
488
580
|
}
|
|
489
581
|
|
|
490
|
-
const issues = computeDeckReadinessIssues(deck, normalized.workspace,
|
|
582
|
+
const issues = computeDeckReadinessIssues(deck, normalized.workspace, {
|
|
583
|
+
...options,
|
|
584
|
+
narrativeHash: options.narrativeHash ?? computeNarrativeHash(normalizeNarrativeState(normalized)),
|
|
585
|
+
})
|
|
491
586
|
const blockers = issues.filter((issue) => issue.severity === "blocker").map((issue) => issue.message)
|
|
492
587
|
const warnings = issues.filter((issue) => issue.severity === "warning").map((issue) => issue.message)
|
|
493
588
|
const evidenceCandidates = issues.flatMap((issue) => issue.evidenceCandidates ?? [])
|
|
@@ -544,7 +639,9 @@ export function evaluateDeckStateWriteReadiness(state: DecksState, filePath: str
|
|
|
544
639
|
}
|
|
545
640
|
}
|
|
546
641
|
|
|
547
|
-
const issues = computeDeckReadinessIssues(deck, normalized.workspace
|
|
642
|
+
const issues = computeDeckReadinessIssues(deck, normalized.workspace, {
|
|
643
|
+
narrativeHash: computeNarrativeHash(normalizeNarrativeState(normalized)),
|
|
644
|
+
})
|
|
548
645
|
const blockers = issues.filter((issue) => issue.severity === "blocker").map((issue) => issue.message)
|
|
549
646
|
const warnings = issues.filter((issue) => issue.severity === "warning").map((issue) => issue.message)
|
|
550
647
|
if (normalizeDeckPath(deck.outputPath) !== targetPath) {
|
|
@@ -651,7 +748,7 @@ export function buildDecksStatePromptLayer(workspaceRoot: string, maxChars = 140
|
|
|
651
748
|
}
|
|
652
749
|
let text = JSON.stringify(compact, null, 2)
|
|
653
750
|
if (text.length > maxChars) text = text.slice(0, maxChars).trimEnd() + "\n[DECKS.json state truncated for prompt size.]"
|
|
654
|
-
return `---\n\n# Revela Workspace State From ${DECKS_STATE_FILE}\n\n\`\`\`json\n${text}\n\`\`\`\n\nRules for this state layer:\n- Treat ${DECKS_STATE_FILE} as the source of truth for the single current deck's specs, slide plan, evidence, render targets, and write readiness.\n- The decks map is compatibility storage; operate only on the current workspace deck.\n- ${DECKS_STATE_FILE} deck slides use 1-based \`slides[].index\` values. Render every HTML \`<section class="slide">\` with a matching 1-based \`data-slide-index\` attribute, and do not use 0-based \`data-index\` as slide identity.\n- The active HTML deck is represented as a \`renderTarget\` of type \`html_deck\`; PDF/PPTX exports should be recorded as derived render targets, not as separate deck specs.\n- \`writeReadiness\` is a compatibility projection
|
|
751
|
+
return `---\n\n# Revela Workspace State From ${DECKS_STATE_FILE}\n\n\`\`\`json\n${text}\n\`\`\`\n\nRules for this state layer:\n- Treat ${DECKS_STATE_FILE} as the source of truth for the single current deck's specs, slide plan, evidence, render targets, and write readiness.\n- The decks map is compatibility storage; operate only on the current workspace deck.\n- ${DECKS_STATE_FILE} deck slides use 1-based \`slides[].index\` values. Render every HTML \`<section class="slide">\` with a matching 1-based \`data-slide-index\` attribute, and do not use 0-based \`data-index\` as slide identity.\n- The active HTML deck is represented as a \`renderTarget\` of type \`html_deck\`; PDF/PPTX exports should be recorded as derived render targets, not as separate deck specs.\n- \`writeReadiness\` is a compatibility projection for the /revela make deck generation workflow, not a hard blocker for targeted artifact-level HTML fixes.\n- Do not edit ${DECKS_STATE_FILE} directly; use the revela-decks tool.\n- For /revela make deck generated HTML, use the current deck's outputPath and satisfy the deck HTML contract. For targeted artifact-level edits, patch the requested deck HTML directly without treating \`writeReadiness\` or \`planReview\` as a precondition.`
|
|
655
752
|
}
|
|
656
753
|
|
|
657
754
|
function compactWorkspaceForPrompt(workspace: DecksState["workspace"]): DecksState["workspace"] {
|
|
@@ -765,6 +862,18 @@ function normalizeDecksStateWithNarrative(input: DecksState): DecksState {
|
|
|
765
862
|
return state
|
|
766
863
|
}
|
|
767
864
|
|
|
865
|
+
function normalizeDeckPlanReview(input: DeckPlanReview | undefined): DeckPlanReview | undefined {
|
|
866
|
+
if (!input || !input.narrativeHash || !input.planHash) return undefined
|
|
867
|
+
return {
|
|
868
|
+
status: input.status === "confirmed" ? "confirmed" : "pending",
|
|
869
|
+
narrativeHash: input.narrativeHash,
|
|
870
|
+
planHash: input.planHash,
|
|
871
|
+
confirmedAt: cleanOptionalText(input.confirmedAt),
|
|
872
|
+
confirmedBy: input.confirmedBy === "user" ? "user" : undefined,
|
|
873
|
+
summary: cleanOptionalText(input.summary),
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
768
877
|
function currentDeckKey(state: DecksState): string | undefined {
|
|
769
878
|
if (state.activeDeck && state.decks[state.activeDeck]) return state.activeDeck
|
|
770
879
|
const keys = Object.keys(state.decks)
|
|
@@ -800,6 +909,16 @@ function computeDeckReadinessIssues(deck: DeckSpec, workspace: DecksState["works
|
|
|
800
909
|
}
|
|
801
910
|
|
|
802
911
|
if (deck.slides.length === 0) issues.push(blockerIssue("missing_slide_spec", "slides are missing", "Add the confirmed slide plan through revela-decks upsertSlides."))
|
|
912
|
+
if (deck.slides.length > 0) {
|
|
913
|
+
const planReview = currentDeckPlanReviewStatus(deck, options.narrativeHash)
|
|
914
|
+
if (!planReview.current) {
|
|
915
|
+
issues.push(blockerIssue(
|
|
916
|
+
"slide_plan_unconfirmed",
|
|
917
|
+
planReview.stale ? `Deck slide plan confirmation is stale: ${planReview.reason}` : `Deck slide plan is not confirmed: ${planReview.reason}`,
|
|
918
|
+
"Show the compiled deck plan with low-fidelity layout sketches to the user, then call revela-decks confirmDeckPlan only after explicit user confirmation.",
|
|
919
|
+
))
|
|
920
|
+
}
|
|
921
|
+
}
|
|
803
922
|
for (const slide of deck.slides) {
|
|
804
923
|
const slideRef = { slideIndex: slide.index, slideTitle: slide.title }
|
|
805
924
|
if (!slide.title.trim()) issues.push(blockerIssue("missing_slide_spec", `Slide ${slide.index} title is missing`, "Add a slide title to the slide spec.", slideRef))
|
package/lib/design/designs.ts
CHANGED
|
@@ -642,7 +642,6 @@ const UNIVERSAL_CLASSES = new Set([
|
|
|
642
642
|
"slide-canvas",
|
|
643
643
|
"visible",
|
|
644
644
|
"reveal",
|
|
645
|
-
"editable",
|
|
646
645
|
"page",
|
|
647
646
|
"bg",
|
|
648
647
|
"fg",
|
|
@@ -655,7 +654,7 @@ const UNIVERSAL_CLASSES = new Set([
|
|
|
655
654
|
* CSS class prefixes that are always exempt from compliance checks.
|
|
656
655
|
* Third-party libraries (icons, charts) generate classes with these prefixes.
|
|
657
656
|
*/
|
|
658
|
-
export const DEFAULT_PREFIX_EXEMPTIONS: string[] = ["lucide-", "echarts-"
|
|
657
|
+
export const DEFAULT_PREFIX_EXEMPTIONS: string[] = ["lucide-", "echarts-"]
|
|
659
658
|
|
|
660
659
|
export interface DesignClassVocabulary {
|
|
661
660
|
/** Complete set of allowed CSS class names. */
|
package/lib/edit/prompt.ts
CHANGED
|
@@ -72,14 +72,15 @@ Instructions:
|
|
|
72
72
|
- If there are multiple comments, apply them as one coherent edit pass and avoid changes from one comment overwriting another.
|
|
73
73
|
- Each comment may reference one or more selected elements. Treat the elements in a single comment as a group.
|
|
74
74
|
- Preserve the narrative boundary: if the requested edit changes audience framing, belief shift, decision/action, thesis, recommendation, claim wording, evidence scope, caveat, risk, objection, or decision ask, do not patch the HTML directly. Explain that the canonical narrative must be updated first through ${"`revela-decks`"} action ${"`upsertNarrative`"}, then reviewed/approved or explicitly overridden before updating the deck projection.
|
|
75
|
-
- Pure artifact polish such as layout, spacing, typography, alignment, color, image crop, animation, export fidelity, or deck HTML contract fixes may remain an artifact-level edit.
|
|
75
|
+
- Pure artifact polish such as layout, spacing, typography, alignment, color, image crop, animation, export fidelity, runtime JavaScript fixes, or deck HTML contract fixes may remain an artifact-level edit.
|
|
76
76
|
- If the request mixes content meaning and visual polish, treat it as narrative-impacting unless the user clarifies otherwise.
|
|
77
77
|
- Preserve the existing deck structure, active design language, typography, spacing system, animations, and slide count unless the comment explicitly asks otherwise.
|
|
78
78
|
- Do not rewrite unrelated slides or broad sections of the deck.
|
|
79
79
|
- Locate each target primarily with slideIndex, slideTitle, selected text, nearbyText, and outerHTMLExcerpt. Use selector/domPath as hints; they may be approximate.
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
80
|
+
- For targeted artifact-level edits, patch ${"`decks/*.html`"} directly. Do not call ${"`revela-decks`"} action ${"`review`"} as a precondition, and do not let ${"`writeReadiness`"}, ${"`planReview`"}, or ${"`slide_plan_unconfirmed`"} block the patch.
|
|
81
|
+
- Do not patch or write ${"`DECKS.json`"} directly. If state must change, use the ${"`revela-decks`"} tool.
|
|
82
|
+
- Apply the edit to ${payload.file} with the smallest targeted HTML patch that satisfies the comment.
|
|
83
|
+
- Artifact QA runs automatically after deck writes/patches/edits. It checks deck HTML contract, design component compliance, exact 1920x1080 slide geometry, scrollbars, element overflow, text clipping, and claim/evidence content-density warnings.
|
|
84
|
+
- If the tool result reports hard QA errors, fix them with the smallest targeted patch and let the post-write QA run again. Refine opens automatically only after hard errors pass; warnings such as thin claim/evidence substance do not block opening.
|
|
84
85
|
- If the comment is ambiguous, ask one concise clarification question instead of guessing.`
|
|
85
86
|
}
|
package/lib/edit/resolve-deck.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface EditableDeck {
|
|
|
12
12
|
|
|
13
13
|
export function resolveEditableDeck(workspaceRoot: string, input = ""): EditableDeck {
|
|
14
14
|
if (input.trim()) {
|
|
15
|
-
throw new Error("/revela
|
|
15
|
+
throw new Error("/revela refine does not accept a target. It opens the active HTML deck or the only HTML deck in decks/.")
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if (hasDecksState(workspaceRoot)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { upsertDeck, upsertSlides, type DecksState, type EvidenceRef, type RequiredInputs, type SlideSpec } from "../decks-state"
|
|
1
|
+
import { deckPlanHash, upsertDeck, upsertSlides, type DecksState, type EvidenceRef, type RequiredInputs, type SlideSpec } from "../decks-state"
|
|
2
2
|
import { ensureActiveHtmlDeckRenderTarget } from "../workspace-state/render-targets"
|
|
3
3
|
import { getClaimSlideRefs } from "./queries"
|
|
4
4
|
import { computeNarrativeHash } from "./hash"
|
|
@@ -65,6 +65,15 @@ export function compileDeckPlanFromNarrative(state: DecksState, options: Compile
|
|
|
65
65
|
writeReadiness: deck?.writeReadiness ?? { status: "blocked" as const, blockers: [] },
|
|
66
66
|
})
|
|
67
67
|
next = upsertSlides(next, slug, slides)
|
|
68
|
+
const plannedDeck = next.decks[slug]
|
|
69
|
+
plannedDeck.planReview = {
|
|
70
|
+
status: "pending",
|
|
71
|
+
narrativeHash,
|
|
72
|
+
planHash: deckPlanHash(plannedDeck.slides),
|
|
73
|
+
}
|
|
74
|
+
plannedDeck.requiredInputs = { ...plannedDeck.requiredInputs, slidePlanConfirmed: false }
|
|
75
|
+
plannedDeck.writeReadiness = { status: "blocked", blockers: [] }
|
|
76
|
+
next.decks[slug] = plannedDeck
|
|
68
77
|
next.narrative = { ...narrative, updatedAt: options.now ?? narrative.updatedAt }
|
|
69
78
|
const htmlTarget = ensureActiveHtmlDeckRenderTarget(next)
|
|
70
79
|
if (htmlTarget) {
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { formatDeckHtmlContractReport, validateDeckHtmlContract } from "../deck-html/contract"
|
|
2
|
+
import type { DesignClassVocabulary } from "../design/designs"
|
|
3
|
+
import { formatReport, runQA } from "./index"
|
|
4
|
+
import { runComplianceQA } from "./compliance"
|
|
5
|
+
import type { QAReport } from "./checks"
|
|
6
|
+
|
|
7
|
+
export interface ArtifactQAReport {
|
|
8
|
+
file: string
|
|
9
|
+
passed: boolean
|
|
10
|
+
hardErrorCount: number
|
|
11
|
+
warningCount: number
|
|
12
|
+
sections: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function hardErrors(report: QAReport): number {
|
|
16
|
+
return report.slides.reduce((sum, slide) => sum + slide.issues.filter((issue) => issue.severity === "error").length, 0)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function warnings(report: QAReport): number {
|
|
20
|
+
return report.slides.reduce((sum, slide) => sum + slide.issues.filter((issue) => issue.severity === "warning").length, 0)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function runArtifactQA(input: {
|
|
24
|
+
workspaceRoot: string
|
|
25
|
+
filePath: string
|
|
26
|
+
vocabulary?: DesignClassVocabulary
|
|
27
|
+
}): Promise<ArtifactQAReport> {
|
|
28
|
+
const sections: string[] = []
|
|
29
|
+
let hardErrorCount = 0
|
|
30
|
+
let warningCount = 0
|
|
31
|
+
|
|
32
|
+
const contract = validateDeckHtmlContract(input.workspaceRoot, input.filePath)
|
|
33
|
+
if (contract.status === "invalid") {
|
|
34
|
+
hardErrorCount += contract.issues.filter((issue) => issue.severity === "error").length
|
|
35
|
+
warningCount += contract.warnings.length
|
|
36
|
+
sections.push("**[deck HTML contract]**\n\n" + formatDeckHtmlContractReport(contract))
|
|
37
|
+
} else if (contract.warnings.length > 0) {
|
|
38
|
+
warningCount += contract.warnings.length
|
|
39
|
+
sections.push("**[deck HTML contract]**\n\n" + formatDeckHtmlContractReport(contract))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const compliance = runComplianceQA(input.filePath, input.vocabulary)
|
|
43
|
+
const complianceErrors = hardErrors(compliance)
|
|
44
|
+
if (compliance.totalIssues > 0) {
|
|
45
|
+
hardErrorCount += complianceErrors
|
|
46
|
+
warningCount += warnings(compliance)
|
|
47
|
+
sections.push("**[component compliance]**\n\n" + formatReport(compliance))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const browser = await runQA(input.filePath)
|
|
52
|
+
const browserErrors = hardErrors(browser)
|
|
53
|
+
if (browser.totalIssues > 0) {
|
|
54
|
+
hardErrorCount += browserErrors
|
|
55
|
+
warningCount += warnings(browser)
|
|
56
|
+
sections.push("**[browser artifact QA]**\n\n" + formatReport(browser))
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
hardErrorCount += 1
|
|
60
|
+
sections.push("**[browser artifact QA]**\n\nError running browser QA: " + (e instanceof Error ? e.message : String(e)))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
file: input.filePath,
|
|
65
|
+
passed: hardErrorCount === 0,
|
|
66
|
+
hardErrorCount,
|
|
67
|
+
warningCount,
|
|
68
|
+
sections,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function formatArtifactQAReport(report: ArtifactQAReport): string {
|
|
73
|
+
const heading = report.passed ? "Artifact QA: PASSED" : "Artifact QA: FAILED"
|
|
74
|
+
const summary = `**File:** \`${report.file}\`\n\n**Hard errors:** ${report.hardErrorCount}\n**Warnings:** ${report.warningCount}`
|
|
75
|
+
if (report.sections.length === 0) return `## ${heading}\n\n${summary}\n\nAll artifact QA checks passed.`
|
|
76
|
+
return `## ${heading}\n\n${summary}\n\n${report.sections.join("\n\n---\n\n")}`
|
|
77
|
+
}
|