@cyber-dash-tech/revela 0.8.4 → 0.8.6

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.
@@ -49,6 +49,12 @@ by the brief. Use \`workspace.sourceMaterials\`, \`workspace.deckMemory\`, and
49
49
  \`workspace.openQuestions\` as workspace context. Treat sourceMaterials as a
50
50
  candidate index, not as proof by itself.
51
51
 
52
+ Before extracting or deeply reading a workspace document, check whether its
53
+ \`workspace.sourceMaterials\` record has the same fingerprint and valid
54
+ \`extraction.manifestPath\`, \`extraction.textPath\`, and \`extraction.cacheDir\`.
55
+ When those paths are present, reuse them instead of re-extracting or rereading
56
+ the original document.
57
+
52
58
  Do not write or patch \`DECKS.json\`. You only write research findings through
53
59
  \`revela-research-save\`; the primary agent decides which stable deck state to preserve.
54
60
 
@@ -63,7 +69,8 @@ Use **\`revela-workspace-scan\`** as a lightweight freshness check when needed:
63
69
 
64
70
  Do not deep-read the whole workspace. Select only files relevant to your axis.
65
71
 
66
- For every selected file, call **\`revela-extract-document-materials\`** first.
72
+ For every selected PDF/PPTX/DOCX/XLSX without valid reusable extraction paths,
73
+ call **\`revela-extract-document-materials\`** first.
67
74
  - \`pdf\`, \`pptx\`, \`docx\`, and \`xlsx\` will produce a manifest plus extracted text and any available embedded materials
68
75
  - unsupported file types will be skipped automatically
69
76
 
@@ -42,6 +42,6 @@ export async function handleHelp(
42
42
  `\`/revela designs-rm <name>\` — remove an installed design\n` +
43
43
  `\`/revela domains-rm <name>\` — remove an installed domain\n` +
44
44
  `\`/revela pdf <file>\` — export HTML slide deck to PDF\n` +
45
- `\`/revela pptx <file>\` — export HTML slide deck to PPTX`
45
+ `\`/revela pptx [file] [--notes]\` — export HTML slide deck to PPTX`
46
46
  )
47
47
  }
@@ -42,13 +42,14 @@ Workflow:
42
42
  - \`decks/**/*.pdf\`
43
43
  - \`slides/**/*.pdf\`
44
44
  Run these searches only inside the current workspace root. These are generated/output decks, not necessarily source materials. If \`decks/\` contains exactly one HTML file, treat it as the current deck artifact. If \`decks/\` contains multiple HTML files, stop and ask the user to move extra decks to separate workspaces before adopting one.
45
- 3. Select the files that look most relevant for future slide decks. Prioritize source decks, PDFs, Word docs, spreadsheets, CSVs, Markdown, text notes, and relevant existing generated decks.
46
- 4. For selected PDF/PPTX/DOCX/XLSX files, call \`revela-extract-document-materials\` before deciding what to summarize.
47
- 5. Read only the materials needed to form a conservative workspace memory. Do not exhaustively read every file if the workspace is large.
48
- 6. Call \`revela-decks\` with action \`init\` to create ${DECKS_STATE_FILE} if needed.
49
- 7. If this conversation or the workspace contains a concrete deck task or an existing deck artifact, call \`revela-decks\` with action \`upsertDeck\` and later \`upsertSlides\` for explicit deck information. Do not pass or ask for a deck key; the tool uses the workspace folder name internally. Do not mark readiness ready during init.
50
- 8. When adopting an existing HTML deck, analyze the artifact and create one conservative \`SlideSpec\` per identifiable slide/page. The \`SlideSpec[]\` itself is the worklist; do not create a separate target slide count.
51
- 9. Report what was initialized or updated and list any open questions.
45
+ 3. Register or refresh source material records by passing the scan result's \`sourceMaterial\` objects to \`revela-decks\` action \`init\`. Preserve unchanged existing records; the tool will upsert by path and fingerprint.
46
+ 4. Select the files that look most relevant for future slide decks. Prioritize source decks, PDFs, Word docs, spreadsheets, CSVs, Markdown, text notes, and relevant existing generated decks.
47
+ 5. Do not automatically extract every PDF/PPTX/DOCX/XLSX during init. Call \`revela-extract-document-materials\` only for selected files that are clearly needed to form conservative workspace memory, or when the user explicitly asked to analyze the material now.
48
+ 6. Before extracting or deeply reading a selected document, check \`DECKS.json.workspace.sourceMaterials\`. If the same path has the same fingerprint and valid extraction paths, reuse those paths instead of repeating extraction.
49
+ 7. Read only the materials needed to form a conservative workspace memory. Do not exhaustively read every file if the workspace is large.
50
+ 8. If this conversation or the workspace contains a concrete deck task or an existing deck artifact, call \`revela-decks\` with action \`upsertDeck\` and later \`upsertSlides\` for explicit deck information. Do not pass or ask for a deck key; the tool uses the workspace folder name internally. Do not mark readiness ready during init.
51
+ 9. When adopting an existing HTML deck, analyze the artifact and create one conservative \`SlideSpec\` per identifiable slide/page. The \`SlideSpec[]\` itself is the worklist; do not create a separate target slide count.
52
+ 10. Report what was initialized or updated and list any open questions.
52
53
 
53
54
  Memory rules:
54
55
  - Only write facts supported by workspace files into ${DECKS_STATE_FILE} workspace state, source materials, deck memory, and open questions.
@@ -1,42 +1,124 @@
1
1
  /**
2
2
  * lib/commands/pptx.ts
3
3
  *
4
- * Handler for `/revela pptx <file_path>` — exports an HTML slide deck to PPTX.
4
+ * Handler for `/revela pptx [file_path]` — exports an HTML slide deck to PPTX.
5
5
  *
6
6
  * Output: same directory and base name as the input, with .pptx extension.
7
7
  * Example: decks/my-deck.html → decks/my-deck.pptx
8
8
  */
9
9
 
10
- import { resolve } from "path"
10
+ import { existsSync, readdirSync } from "fs"
11
+ import { relative, resolve, sep } from "path"
12
+ import { hasDecksState, isDeckHtmlPath, readDecksState } from "../decks-state"
11
13
  import { exportToPptx } from "../pptx/export"
12
- import { assertExportQAPassed } from "../qa/export-gate"
14
+
15
+ export interface PptxArgs {
16
+ filePath: string
17
+ notes: boolean
18
+ }
19
+
20
+ export interface ResolvedPptxDeck {
21
+ file: string
22
+ absoluteFile: string
23
+ source: "decks-state" | "fallback" | "file-path"
24
+ }
13
25
 
14
26
  function formatSecs(ms: number): string {
15
27
  return `${(ms / 1000).toFixed(1)}s`
16
28
  }
17
29
 
18
- export async function handlePptx(
19
- filePath: string,
20
- send: (text: string) => Promise<void>,
21
- ): Promise<void> {
22
- if (!filePath) {
23
- await send(
24
- "**Usage:** `/revela pptx <file_path>`\n\n" +
25
- "Example: `/revela pptx decks/my-deck.html`"
26
- )
27
- return
30
+ export function parsePptxArgs(input: string): PptxArgs {
31
+ const parts = input.trim().split(/\s+/).filter(Boolean)
32
+ const notes = parts.includes("--notes")
33
+ const filePath = parts.filter((part) => part !== "--notes").join(" ").trim()
34
+ return { filePath, notes }
35
+ }
36
+
37
+ export function resolvePptxDeck(workspaceRoot: string, filePath = ""): ResolvedPptxDeck {
38
+ const root = resolve(workspaceRoot)
39
+ const explicit = filePath.trim()
40
+ if (explicit) {
41
+ const absoluteFile = resolve(root, explicit)
42
+ if (!existsSync(absoluteFile)) throw new Error(`Deck HTML not found: ${explicit}`)
43
+ if (!/\.html?$/i.test(absoluteFile)) throw new Error(`File must be an HTML file: ${explicit}`)
44
+ return { file: workspaceRelative(root, absoluteFile), absoluteFile, source: "file-path" }
45
+ }
46
+
47
+ if (hasDecksState(root)) {
48
+ const state = readDecksState(root)
49
+ const key = state.activeDeck || singleDeckKey(state.decks)
50
+ const outputPath = key ? state.decks[key]?.outputPath : undefined
51
+ if (outputPath && isDeckHtmlPath(outputPath)) {
52
+ const absoluteFile = resolve(root, outputPath)
53
+ if (existsSync(absoluteFile)) {
54
+ return { file: workspaceRelative(root, absoluteFile), absoluteFile, source: "decks-state" }
55
+ }
56
+ }
28
57
  }
29
58
 
30
- const abs = resolve(filePath)
31
- await send(`Running pre-export QA for \`${abs}\`...`)
59
+ const htmlFiles = listDeckHtmlFiles(root)
60
+ if (htmlFiles.length === 0) {
61
+ throw new Error("No deck HTML found in decks/. Generate a deck first or pass a file path.")
62
+ }
63
+ if (htmlFiles.length > 1) {
64
+ throw new Error("This workspace contains multiple deck HTML files. Run `/revela pptx decks/<file>.html` to choose one.")
65
+ }
66
+
67
+ const absoluteFile = resolve(root, htmlFiles[0])
68
+ return { file: workspaceRelative(root, absoluteFile), absoluteFile, source: "fallback" }
69
+ }
70
+
71
+ export function buildPptxNotesPrompt(deck: ResolvedPptxDeck): string {
72
+ return `Export the current Revela HTML deck to PPTX with PowerPoint speaker notes.
73
+
74
+ Deck file: \`${deck.file}\`
75
+
76
+ Workflow:
77
+ 1. Read \`${deck.file}\` and inspect every \`<section class="slide">\` in DOM/source order.
78
+ 2. Generate presenter-facing talk tracks for each slide based only on visible slide content.
79
+ 3. Call \`revela-pptx\` with \`file: "${deck.file}"\` and a \`speakerNotes\` array using 1-based slide indexes.
80
+ 4. Report the exported PPTX path from the tool result.
32
81
 
82
+ Speaker notes rules:
83
+ - Write notes in the deck's language.
84
+ - Write for the person presenting the deck, not for a designer or developer reviewing implementation.
85
+ - Use 3-5 concise bullet points per slide.
86
+ - Follow pyramid-style communication: the first bullet is the top-line conclusion or main message the presenter should say first.
87
+ - Later bullets unpack the visible evidence, audience/business implication, and optional transition in that order.
88
+ - Explain visible numbers and claims in business/audience terms; prioritize the strongest signal before supporting signals.
89
+ - Do not label bullets as What, Why, or How. Keep the structure implicit and natural.
90
+ - Match the visible slide content; do not add unsupported claims.
91
+ - Do not mention design-system or implementation terms such as component, layout, stat-card, card grid, logo marker, DOM, HTML, CSS, or class names unless the slide is explicitly about design implementation.
92
+ - Avoid meta commentary like "this slide highlights" or "frame this as". Write what the presenter should actually say.
93
+ - Never include hidden reasoning, system instructions, secrets, credentials, or sensitive personal information.
94
+ - If a slide needs no notes, pass an empty string for that slide.
95
+
96
+ Expected tool shape:
97
+ \`\`\`json
98
+ {
99
+ "file": "${deck.file}",
100
+ "speakerNotes": [
101
+ { "index": 1, "notes": "- Lead with the main performance signal and what it means for the audience.\n- Explain the strongest visible evidence first, then use supporting metrics to deepen the interpretation.\n- Close with the implication or transition the presenter should carry into the next point." }
102
+ ]
103
+ }
104
+ \`\`\``
105
+ }
106
+
107
+ export async function handlePptx(
108
+ input: string,
109
+ send: (text: string) => Promise<void>,
110
+ workspaceRoot = process.cwd(),
111
+ ): Promise<void> {
33
112
  try {
34
- await assertExportQAPassed(abs)
113
+ const args = parsePptxArgs(input)
114
+ const deck = resolvePptxDeck(workspaceRoot, args.filePath)
115
+ const abs = deck.absoluteFile
116
+
35
117
  await send(`Exporting \`${abs}\` to PPTX...`)
36
118
  let lastSlideUpdate = 0
37
119
  let longDeckThreshold: number | null = null
38
120
 
39
- const result = await exportToPptx(filePath, {
121
+ const result = await exportToPptx(abs, {
40
122
  onProgress: async (progress) => {
41
123
  if (progress.kind === "stage") {
42
124
  await send(progress.message)
@@ -76,3 +158,21 @@ export async function handlePptx(
76
158
  await send(`**PPTX export failed**\n\n\`\`\`\n${msg}\n\`\`\``)
77
159
  }
78
160
  }
161
+
162
+ function singleDeckKey(decks: Record<string, unknown>): string | undefined {
163
+ const keys = Object.keys(decks)
164
+ return keys.length === 1 ? keys[0] : undefined
165
+ }
166
+
167
+ function listDeckHtmlFiles(workspaceRoot: string): string[] {
168
+ const dir = resolve(workspaceRoot, "decks")
169
+ if (!existsSync(dir)) return []
170
+ return readdirSync(dir, { withFileTypes: true })
171
+ .filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".html"))
172
+ .map((entry) => `decks/${entry.name}`)
173
+ .sort((a, b) => a.localeCompare(b))
174
+ }
175
+
176
+ function workspaceRelative(root: string, target: string): string {
177
+ return relative(root, target).split(sep).join("/")
178
+ }
@@ -26,9 +26,20 @@ export interface DecksState {
26
26
  export interface SourceMaterial {
27
27
  path: string
28
28
  type?: string
29
+ size?: number
30
+ fingerprint?: string
31
+ status?: "discovered" | "extracted" | "summarized" | "researched"
32
+ extraction?: {
33
+ manifestPath?: string
34
+ textPath?: string
35
+ cacheDir?: string
36
+ }
29
37
  summary?: string
30
38
  bestUsedFor?: string
39
+ firstSeen?: string
31
40
  lastChecked?: string
41
+ lastExtracted?: string
42
+ lastSummarized?: string
32
43
  }
33
44
 
34
45
  export interface DeckMemoryEntry {
@@ -1,5 +1,4 @@
1
- import { createHash } from "crypto"
2
- import { existsSync, mkdirSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs"
1
+ import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "fs"
3
2
  import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "path"
4
3
  import { DOMParser } from "@xmldom/xmldom"
5
4
  import { unzipSync } from "fflate"
@@ -9,6 +8,8 @@ import { extractDocx } from "../read-hooks/extractors/docx"
9
8
  import { extractPdfText } from "../read-hooks/extractors/pdf"
10
9
  import { extractPptx } from "../read-hooks/extractors/pptx"
11
10
  import { extractXlsx } from "../read-hooks/extractors/xlsx"
11
+ import { hasDecksState, readDecksState, writeDecksState } from "../decks-state"
12
+ import { computeSourceFingerprint, sourceMaterialMetadata, upsertSourceMaterial } from "../source-materials"
12
13
 
13
14
  export type DocumentMaterial = {
14
15
  path: string
@@ -50,6 +51,7 @@ export type PptxSlide = {
50
51
 
51
52
  export type DocumentMaterialsResult = {
52
53
  status: "processed" | "skipped" | "failed"
54
+ cache_status?: "hit" | "miss"
53
55
  source: string
54
56
  type: "pptx" | "docx" | "xlsx" | "pdf" | "other"
55
57
  cache_dir?: string
@@ -142,10 +144,7 @@ function workspaceRelative(filePath: string, workspaceDir: string): string {
142
144
  }
143
145
 
144
146
  function buildFingerprint(filePath: string): string {
145
- const stat = statSync(filePath)
146
- return createHash("sha1")
147
- .update(`${resolve(filePath)}:${stat.mtimeMs}:${stat.size}`)
148
- .digest("hex")
147
+ return computeSourceFingerprint(filePath)
149
148
  }
150
149
 
151
150
  function writeCachedBuffer(targetPath: string, buf: Uint8Array): void {
@@ -157,6 +156,33 @@ function materialPath(cacheDir: string, workspaceDir: string, ...segments: strin
157
156
  return workspaceRelative(join(cacheDir, ...segments), workspaceDir)
158
157
  }
159
158
 
159
+ function updateDecksSourceMaterialIndex(
160
+ workspaceDir: string,
161
+ filePath: string,
162
+ result: DocumentMaterialsResult,
163
+ ): void {
164
+ if (!hasDecksState(workspaceDir)) return
165
+
166
+ const base = sourceMaterialMetadata(filePath, workspaceDir)
167
+ const extracted = result.status === "processed" && result.manifest_path && result.text_path && result.cache_dir
168
+ const state = readDecksState(workspaceDir)
169
+ const existing = state.workspace.sourceMaterials.find((entry) => entry.path === base.path)
170
+ const now = new Date().toISOString()
171
+ upsertSourceMaterial(state, {
172
+ ...base,
173
+ status: extracted ? "extracted" : "discovered",
174
+ extraction: extracted
175
+ ? {
176
+ manifestPath: result.manifest_path,
177
+ textPath: result.text_path,
178
+ cacheDir: result.cache_dir,
179
+ }
180
+ : undefined,
181
+ lastExtracted: extracted ? (result.cache_status === "hit" ? existing?.lastExtracted ?? now : now) : undefined,
182
+ }, extracted ? "extracted" : "discovered")
183
+ writeDecksState(workspaceDir, state)
184
+ }
185
+
160
186
  function toRgbaBuffer(image: PdfImageData): Buffer {
161
187
  const pixelCount = image.width * image.height
162
188
 
@@ -672,6 +698,7 @@ async function processPdfFile(filePath: string, workspaceDir: string): Promise<D
672
698
  const manifest = JSON.parse(readFileSync(manifestPath, "utf-8")) as CachedManifest
673
699
  return {
674
700
  status: "processed",
701
+ cache_status: "hit",
675
702
  source: manifest.source,
676
703
  type: manifest.type,
677
704
  cache_dir: manifest.cache_dir,
@@ -696,6 +723,7 @@ async function processPdfFile(filePath: string, workspaceDir: string): Promise<D
696
723
 
697
724
  const result: DocumentMaterialsResult = {
698
725
  status: "processed",
726
+ cache_status: "miss",
699
727
  source: relativeSource,
700
728
  type: "pdf",
701
729
  cache_dir: workspaceRelative(cacheDir, workspaceDir),
@@ -734,6 +762,7 @@ async function processOfficeFile(filePath: string, workspaceDir: string, type: S
734
762
  const manifest = JSON.parse(readFileSync(manifestPath, "utf-8")) as CachedManifest
735
763
  return {
736
764
  status: "processed",
765
+ cache_status: "hit",
737
766
  source: manifest.source,
738
767
  type: manifest.type,
739
768
  cache_dir: manifest.cache_dir,
@@ -775,6 +804,7 @@ async function processOfficeFile(filePath: string, workspaceDir: string, type: S
775
804
 
776
805
  const result: DocumentMaterialsResult = {
777
806
  status: "processed",
807
+ cache_status: "miss",
778
808
  source: relativeSource,
779
809
  type,
780
810
  cache_dir: workspaceRelative(cacheDir, workspaceDir),
@@ -810,17 +840,21 @@ export async function extractDocumentMaterials(filePath: string, workspaceDir: s
810
840
  const type = SUPPORTED_EXTENSIONS[extname(resolvedFile).toLowerCase()]
811
841
 
812
842
  if (!type) {
813
- return {
843
+ const result: DocumentMaterialsResult = {
814
844
  status: "skipped",
815
845
  source: relativeSource,
816
846
  type: "other",
817
847
  reason: "unsupported_file_type",
818
848
  }
849
+ updateDecksSourceMaterialIndex(workspaceDir, resolvedFile, result)
850
+ return result
819
851
  }
820
852
 
821
- return type === "pdf"
853
+ const result = type === "pdf"
822
854
  ? await processPdfFile(resolvedFile, workspaceDir)
823
855
  : await processOfficeFile(resolvedFile, workspaceDir, type)
856
+ updateDecksSourceMaterialIndex(workspaceDir, resolvedFile, result)
857
+ return result
824
858
  } catch (e) {
825
859
  return {
826
860
  status: "failed",
@@ -65,6 +65,7 @@ interface SlideMeta {
65
65
  index: number
66
66
  pageNo: string | null
67
67
  title: string | null
68
+ speakerNotes: string | null
68
69
  }
69
70
 
70
71
  interface ExportedSlide extends SlideMeta {
@@ -100,6 +101,7 @@ export interface ExportPptxProgress {
100
101
 
101
102
  export interface ExportPptxOptions {
102
103
  onProgress?: (progress: ExportPptxProgress) => void | Promise<void>
104
+ speakerNotes?: Array<string | null | undefined>
103
105
  }
104
106
 
105
107
  export interface ExportPptxTimings {
@@ -474,12 +476,21 @@ async function readSlideMeta(
474
476
  .map((el) => el.textContent?.trim() ?? "")
475
477
  .find((text) => /^\d{2}$/.test(text)) ?? null
476
478
  const title = slide.querySelector("h1,h2,h3")?.textContent?.trim()?.slice(0, 120) ?? null
477
- return { index, pageNo, title }
479
+ const directChildren = Array.from(slide.children)
480
+ const notesEl =
481
+ directChildren.find((el) => el.matches("template[data-revela-speaker-notes]")) ??
482
+ directChildren.find((el) => el.hasAttribute("data-revela-speaker-notes")) ??
483
+ directChildren.find((el) => el.classList.contains("speaker-notes"))
484
+ const notesText = notesEl instanceof HTMLTemplateElement
485
+ ? notesEl.content.textContent
486
+ : notesEl?.textContent
487
+ const speakerNotes = notesText?.replace(/\r\n?/g, "\n").trim() || null
488
+ return { index, pageNo, title, speakerNotes }
478
489
  })
479
490
  })
480
491
 
481
492
  return Array.from({ length: slideCount }, (_, index) => {
482
- return meta[index] ?? { index, pageNo: null, title: null }
493
+ return meta[index] ?? { index, pageNo: null, title: null, speakerNotes: null }
483
494
  })
484
495
  }
485
496
 
@@ -553,6 +564,22 @@ async function exportSlidePptx(
553
564
  }
554
565
  }
555
566
 
567
+ function applySpeakerNotesOverride(
568
+ slides: SlideMeta[],
569
+ speakerNotes?: Array<string | null | undefined>,
570
+ ): SlideMeta[] {
571
+ if (!speakerNotes) return slides
572
+
573
+ return slides.map((slide) => {
574
+ if (speakerNotes[slide.index] === undefined) return slide
575
+ const notes = speakerNotes[slide.index]
576
+ return {
577
+ ...slide,
578
+ speakerNotes: notes?.replace(/\r\n?/g, "\n").trim() || null,
579
+ }
580
+ })
581
+ }
582
+
556
583
  function parseXml(xml: string) {
557
584
  return new DOMParser().parseFromString(xml, "text/xml")
558
585
  }
@@ -703,6 +730,31 @@ function setNotesSlideNumber(files: ZipFiles, notesPath: string, number: number)
703
730
  files[notesPath] = xmlToBytes(doc)
704
731
  }
705
732
 
733
+ function setSpeakerNotes(files: ZipFiles, notesPath: string, notes: string | null): void {
734
+ if (!files[notesPath]) return
735
+
736
+ const doc = parseXml(getFileText(files, notesPath))
737
+ const shapes = Array.from(doc.getElementsByTagName("p:sp"))
738
+ const notesShape = shapes.find((shape) => {
739
+ return Array.from(shape.getElementsByTagName("p:ph")).some((ph) => ph.getAttribute("type") === "body")
740
+ })
741
+ const textNode = notesShape?.getElementsByTagName("a:t")[0]
742
+ if (!textNode) return
743
+
744
+ textNode.textContent = notes ?? ""
745
+ files[notesPath] = xmlToBytes(doc)
746
+ }
747
+
748
+ export function applySpeakerNotesToPptx(pptxBytes: Uint8Array, notesBySlide: Array<string | null | undefined>): Uint8Array {
749
+ const files = unzipSync(pptxBytes)
750
+
751
+ notesBySlide.forEach((notes, index) => {
752
+ setSpeakerNotes(files, `ppt/notesSlides/notesSlide${index + 1}.xml`, notes ?? null)
753
+ })
754
+
755
+ return zipSync(files)
756
+ }
757
+
706
758
  function updateAppProperties(files: ZipFiles, slideCount: number): void {
707
759
  const doc = parseXml(getFileText(files, "docProps/app.xml"))
708
760
  const setText = (tag: string, value: string) => {
@@ -786,6 +838,7 @@ function mergeSingleSlidePptx(slides: ExportedSlide[]): Uint8Array {
786
838
 
787
839
  setSlideName(mergedFiles, "ppt/slides/slide1.xml", "Slide 1")
788
840
  setNotesSlideNumber(mergedFiles, "ppt/notesSlides/notesSlide1.xml", 1)
841
+ setSpeakerNotes(mergedFiles, "ppt/notesSlides/notesSlide1.xml", slides[0].speakerNotes)
789
842
 
790
843
  for (let slideIdx = 1; slideIdx < slides.length; slideIdx += 1) {
791
844
  const sourceFiles: ZipFiles = { ...unzipSync(slides[slideIdx].bytes) }
@@ -847,6 +900,7 @@ function mergeSingleSlidePptx(slides: ExportedSlide[]): Uint8Array {
847
900
  setSlideName(mergedFiles, slidePath, `Slide ${slideIdx + 1}`)
848
901
  if (notesPath && mergedFiles[notesPath]) {
849
902
  setNotesSlideNumber(mergedFiles, notesPath, slideIdx + 1)
903
+ setSpeakerNotes(mergedFiles, notesPath, slides[slideIdx].speakerNotes)
850
904
  }
851
905
 
852
906
  const relId = `rId${nextPresentationRelId}`
@@ -940,7 +994,7 @@ export async function exportToPptx(
940
994
  const failures: SlideFailure[] = []
941
995
 
942
996
  try {
943
- const slides = await readSlideMeta(page, slideCount)
997
+ const slides = applySpeakerNotesOverride(await readSlideMeta(page, slideCount), options?.speakerNotes)
944
998
  await emitProgress(options, {
945
999
  kind: "stage",
946
1000
  message: `Deck ready. Exporting ${slides.length} slide(s) to editable PPTX parts...`,
@@ -0,0 +1,93 @@
1
+ import { createHash } from "crypto"
2
+ import { existsSync, realpathSync, statSync } from "fs"
3
+ import { extname, isAbsolute, join, relative, resolve, sep } from "path"
4
+ import {
5
+ type DecksState,
6
+ type SourceMaterial,
7
+ } from "./decks-state"
8
+
9
+ export type SourceMaterialStatus = NonNullable<SourceMaterial["status"]>
10
+
11
+ export function ensureWorkspaceFile(filePath: string, workspaceRoot: string): string {
12
+ const resolvedWorkspace = realpathSync(resolve(workspaceRoot))
13
+ const candidate = isAbsolute(filePath) ? resolve(filePath) : resolve(workspaceRoot, filePath)
14
+ const resolvedFile = existsSync(candidate) ? realpathSync(candidate) : candidate
15
+
16
+ if (resolvedFile !== resolvedWorkspace && !resolvedFile.startsWith(resolvedWorkspace + sep)) {
17
+ throw new Error("file must be within workspace")
18
+ }
19
+
20
+ return resolvedFile
21
+ }
22
+
23
+ export function workspaceRelativePath(filePath: string, workspaceRoot: string): string {
24
+ const resolvedWorkspace = realpathSync(resolve(workspaceRoot))
25
+ const candidate = resolve(filePath)
26
+ const resolvedFile = existsSync(candidate) ? realpathSync(candidate) : candidate
27
+ return relative(resolvedWorkspace, resolvedFile).replace(/\\/g, "/")
28
+ }
29
+
30
+ export function sourceMaterialType(filePath: string): string {
31
+ return extname(filePath).replace(/^\./, "").toLowerCase() || "other"
32
+ }
33
+
34
+ export function computeSourceFingerprint(filePath: string): string {
35
+ const stat = statSync(filePath)
36
+ return createHash("sha1")
37
+ .update(`${resolve(filePath)}:${stat.mtimeMs}:${stat.size}`)
38
+ .digest("hex")
39
+ }
40
+
41
+ export function sourceMaterialMetadata(filePath: string, workspaceRoot: string): SourceMaterial {
42
+ const resolvedFile = ensureWorkspaceFile(filePath, workspaceRoot)
43
+ const stat = statSync(resolvedFile)
44
+ return {
45
+ path: workspaceRelativePath(resolvedFile, workspaceRoot),
46
+ type: sourceMaterialType(resolvedFile),
47
+ size: stat.size,
48
+ fingerprint: computeSourceFingerprint(resolvedFile),
49
+ }
50
+ }
51
+
52
+ export function hasValidExtraction(material: SourceMaterial, workspaceRoot: string): boolean {
53
+ const extraction = material.extraction
54
+ if (!extraction?.manifestPath || !extraction.textPath || !extraction.cacheDir) return false
55
+ return [extraction.manifestPath, extraction.textPath, extraction.cacheDir]
56
+ .every((item) => existsSync(join(workspaceRoot, item)))
57
+ }
58
+
59
+ export function upsertSourceMaterial(
60
+ state: DecksState,
61
+ material: SourceMaterial,
62
+ status: SourceMaterialStatus = material.status ?? "discovered",
63
+ ): DecksState {
64
+ const now = new Date().toISOString()
65
+ const list = state.workspace.sourceMaterials ?? []
66
+ const path = material.path.replace(/\\/g, "/")
67
+ const existingIndex = list.findIndex((entry) => entry.path === path)
68
+ const existing = existingIndex >= 0 ? list[existingIndex] : undefined
69
+ const changedFingerprint = Boolean(existing?.fingerprint && material.fingerprint && existing.fingerprint !== material.fingerprint)
70
+ const nextStatus = changedFingerprint
71
+ ? status === "extracted" ? "extracted" : "discovered"
72
+ : status === "discovered" && existing?.status ? existing.status : status
73
+
74
+ const next: SourceMaterial = {
75
+ ...existing,
76
+ ...material,
77
+ path,
78
+ type: material.type ?? existing?.type,
79
+ status: nextStatus,
80
+ firstSeen: existing?.firstSeen ?? material.firstSeen ?? now,
81
+ lastChecked: now,
82
+ }
83
+
84
+ if (changedFingerprint && status !== "extracted") {
85
+ delete next.extraction
86
+ delete next.lastExtracted
87
+ }
88
+
89
+ if (existingIndex >= 0) list[existingIndex] = next
90
+ else list.push(next)
91
+ state.workspace.sourceMaterials = list.sort((a, b) => a.path.localeCompare(b.path))
92
+ return state
93
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyber-dash-tech/revela",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "OpenCode plugin that turns AI into an HTML slide deck generator",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/plugin.ts CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  handleDomainsRemove,
45
45
  } from "./lib/commands/domains"
46
46
  import { handlePdf } from "./lib/commands/pdf"
47
- import { handlePptx } from "./lib/commands/pptx"
47
+ import { buildPptxNotesPrompt, handlePptx, parsePptxArgs, resolvePptxDeck } from "./lib/commands/pptx"
48
48
  import { handleEdit } from "./lib/commands/edit"
49
49
  import { ensureEditableDeckOpenForChange } from "./lib/edit/open"
50
50
  import { hasLiveEditorSessionForFile } from "./lib/edit/server"
@@ -388,7 +388,20 @@ const server: Plugin = (async (pluginCtx) => {
388
388
  throw new Error("__REVELA_PDF_HANDLED__")
389
389
  }
390
390
  if (sub === "pptx") {
391
- await handlePptx(param, send)
391
+ const args = parsePptxArgs(param)
392
+ if (args.notes) {
393
+ try {
394
+ const deck = resolvePptxDeck(workspaceRoot, args.filePath)
395
+ output.parts.length = 0
396
+ output.parts.push({ type: "text", text: buildPptxNotesPrompt(deck) } as any)
397
+ return
398
+ } catch (e) {
399
+ const msg = e instanceof Error ? e.message : String(e)
400
+ await send(`**PPTX export failed**\n\n\`\`\`\n${msg}\n\`\`\``)
401
+ throw new Error("__REVELA_PPTX_HANDLED__")
402
+ }
403
+ }
404
+ await handlePptx(param, send, workspaceRoot)
392
405
  throw new Error("__REVELA_PPTX_HANDLED__")
393
406
  }
394
407
 
package/skill/SKILL.md CHANGED
@@ -169,7 +169,14 @@ The subagent writes exactly one file through `revela-research-save`:
169
169
 
170
170
  Use `revela-decks` action `read` before scanning from scratch. Its
171
171
  `workspace.sourceMaterials` state is the workspace material index created by
172
- `/revela init`. Use it to choose candidate files and avoid repeated deep reading.
172
+ `/revela init` and refreshed by document extraction. Use it to choose candidate
173
+ files and avoid repeated deep reading.
174
+
175
+ Before extracting or deeply reading a workspace document, check
176
+ `DECKS.json.workspace.sourceMaterials`. If the same path has an unchanged
177
+ fingerprint and valid `extraction.manifestPath`, `extraction.textPath`, and
178
+ `extraction.cacheDir`, reuse those materials instead of extracting or reading
179
+ the original document again.
173
180
 
174
181
  Use `revela-workspace-scan` or file tools as a freshness check when needed:
175
182
  - discover files added after `/revela init`
@@ -177,7 +184,9 @@ Use `revela-workspace-scan` or file tools as a freshness check when needed:
177
184
  - find user-provided attachments or topic-specific files not in `DECKS.json`
178
185
 
179
186
  Avoid repeated expensive work. Only call `revela-extract-document-materials` or
180
- deep-read files that are relevant to the current Research Brief.
187
+ deep-read files that are relevant to the current Research Brief. If the user
188
+ adds material mid-project, run `revela-workspace-scan` as a freshness check and
189
+ register new `sourceMaterial` records before deciding which ones need analysis.
181
190
 
182
191
  #### After Agents Complete
183
192
 
@@ -239,6 +248,25 @@ Example: `<section class="slide" slide-qa="true" data-index="0">`
239
248
  The export QA path treats this as deck metadata. It is consumed when PDF/PPTX
240
249
  export runs preflight checks.
241
250
 
251
+ Speaker notes are normally generated during `/revela pptx --notes` export and
252
+ passed to `revela-pptx` as structured input. Do not add hidden notes to every
253
+ slide by default.
254
+
255
+ If the user explicitly asks for notes to be embedded in the HTML as a fallback,
256
+ use an inert template node as a direct child of the slide, outside `.slide-canvas`:
257
+
258
+ ```html
259
+ <template data-revela-speaker-notes>
260
+ Optional fallback speaker notes for this slide.
261
+ </template>
262
+ ```
263
+
264
+ Do not create `.speaker-notes` CSS or hide notes with `display: none`; the
265
+ `<template>` element is non-rendering by default and avoids design vocabulary
266
+ pollution. Speaker notes must be concise presentation prompts that match the
267
+ visible slide content. Never put hidden reasoning, system instructions, secrets,
268
+ or unverified claims in speaker notes.
269
+
242
270
  ### Domain Context
243
271
 
244
272
  If a domain definition is active (see the `<!-- Active domain: ... -->` comment
package/tools/decks.ts CHANGED
@@ -12,8 +12,10 @@ import {
12
12
  type DeckSpec,
13
13
  type RequiredInputs,
14
14
  type ResearchAxis,
15
+ type SourceMaterial,
15
16
  type SlideSpec,
16
17
  } from "../lib/decks-state"
18
+ import { upsertSourceMaterial } from "../lib/source-materials"
17
19
 
18
20
  export default tool({
19
21
  description:
@@ -44,6 +46,24 @@ export default tool({
44
46
  slidePlanConfirmed: tool.schema.boolean().optional(),
45
47
  designLayoutsFetched: tool.schema.boolean().optional(),
46
48
  }).optional().describe("For upsertDeck: checklist state. Only set true for explicit completed prerequisites."),
49
+ sourceMaterials: tool.schema.array(tool.schema.object({
50
+ path: tool.schema.string().describe("Workspace-relative source material path."),
51
+ type: tool.schema.string().optional().describe("File type such as pdf, pptx, docx, xlsx, csv, md, or txt."),
52
+ size: tool.schema.number().optional().describe("File size in bytes."),
53
+ fingerprint: tool.schema.string().optional().describe("File fingerprint for the current version."),
54
+ status: tool.schema.enum(["discovered", "extracted", "summarized", "researched"]).optional().describe("How far this source has been processed."),
55
+ summary: tool.schema.string().optional().describe("Conservative source summary if already known."),
56
+ bestUsedFor: tool.schema.string().optional().describe("Short note on deck sections this material is best used for."),
57
+ firstSeen: tool.schema.string().optional().describe("ISO timestamp when first seen."),
58
+ lastChecked: tool.schema.string().optional().describe("ISO timestamp when last checked."),
59
+ lastExtracted: tool.schema.string().optional().describe("ISO timestamp when last extracted."),
60
+ lastSummarized: tool.schema.string().optional().describe("ISO timestamp when last summarized."),
61
+ extraction: tool.schema.object({
62
+ manifestPath: tool.schema.string().optional(),
63
+ textPath: tool.schema.string().optional(),
64
+ cacheDir: tool.schema.string().optional(),
65
+ }).optional().describe("Reusable extraction output paths, if any."),
66
+ })).optional().describe("For init/readiness refresh: source material records discovered in the workspace."),
47
67
  researchPlan: tool.schema.array(tool.schema.object({
48
68
  axis: tool.schema.string().describe("Research axis name."),
49
69
  needed: tool.schema.boolean().describe("Whether this research axis is needed for the deck."),
@@ -87,6 +107,9 @@ export default tool({
87
107
  const defaultSlug = workspaceDeckSlug(workspaceRoot)
88
108
 
89
109
  if (args.action === "init") {
110
+ for (const material of (args.sourceMaterials ?? []) as SourceMaterial[]) {
111
+ upsertSourceMaterial(state, material, material.status ?? "discovered")
112
+ }
90
113
  writeDecksState(workspaceRoot, state)
91
114
  return JSON.stringify({ ok: true, path: DECKS_STATE_FILE, state }, null, 2)
92
115
  }
package/tools/pptx.ts CHANGED
@@ -8,12 +8,10 @@ import { tool } from "@opencode-ai/plugin"
8
8
  import { existsSync } from "fs"
9
9
  import { resolve } from "path"
10
10
  import { exportToPptx } from "../lib/pptx/export"
11
- import { assertExportQAPassed } from "../lib/qa/export-gate"
12
11
 
13
12
  export default tool({
14
13
  description:
15
14
  "Export a Revela-generated HTML slide deck to editable PPTX. " +
16
- "Runs pre-export QA before writing the PPTX. " +
17
15
  "Output is written beside the input file with the same basename and a .pptx extension.",
18
16
  args: {
19
17
  file: tool.schema
@@ -22,8 +20,15 @@ export default tool({
22
20
  "Path to the HTML slide file to export. " +
23
21
  "Can be absolute or relative to the current working directory."
24
22
  ),
23
+ speakerNotes: tool.schema.array(tool.schema.object({
24
+ index: tool.schema.number().describe("1-based slide index."),
25
+ notes: tool.schema.string().describe("Speaker notes for this slide. Use an empty string for no notes."),
26
+ })).optional().describe(
27
+ "Optional PowerPoint speaker notes to write during export. " +
28
+ "When provided, these override any fallback notes embedded in the HTML."
29
+ ),
25
30
  },
26
- async execute({ file }, { directory }) {
31
+ async execute({ file, speakerNotes }, { directory }) {
27
32
  const filePath = resolve(directory || process.cwd(), file)
28
33
 
29
34
  if (!existsSync(filePath)) {
@@ -37,8 +42,8 @@ export default tool({
37
42
  const progress: string[] = []
38
43
 
39
44
  try {
40
- await assertExportQAPassed(filePath)
41
45
  const result = await exportToPptx(filePath, {
46
+ speakerNotes: normalizeSpeakerNotes(speakerNotes),
42
47
  onProgress: (event) => {
43
48
  progress.push(event.message)
44
49
  },
@@ -49,3 +54,17 @@ export default tool({
49
54
  }
50
55
  },
51
56
  })
57
+
58
+ function normalizeSpeakerNotes(
59
+ input?: Array<{ index?: number; notes?: string }>,
60
+ ): Array<string | null | undefined> | undefined {
61
+ if (!input) return undefined
62
+
63
+ const notesBySlide: Array<string | null | undefined> = []
64
+ for (const item of input) {
65
+ const index = Math.floor(Number(item.index ?? 0))
66
+ if (index < 1) continue
67
+ notesBySlide[index - 1] = item.notes ?? ""
68
+ }
69
+ return notesBySlide
70
+ }
@@ -1,6 +1,8 @@
1
1
  import { tool } from "@opencode-ai/plugin"
2
2
  import { readdirSync, statSync, existsSync } from "fs"
3
3
  import { join, relative, extname, resolve, sep, isAbsolute } from "path"
4
+ import { sourceMaterialMetadata } from "../lib/source-materials"
5
+ import type { SourceMaterial } from "../lib/decks-state"
4
6
 
5
7
  const DOC_EXTENSIONS = new Set([
6
8
  ".pdf", ".docx", ".doc", ".xlsx", ".xls",
@@ -18,6 +20,8 @@ type FileEntry = {
18
20
  path: string
19
21
  type: string
20
22
  size: string
23
+ sizeBytes: number
24
+ sourceMaterial: SourceMaterial
21
25
  }
22
26
 
23
27
  /**
@@ -80,10 +84,13 @@ function scanDir(dir: string, rootDir: string, results: FileEntry[], maxDepth: n
80
84
  } else if (stat.isFile()) {
81
85
  const ext = extname(entry).toLowerCase()
82
86
  if (DOC_EXTENSIONS.has(ext)) {
87
+ const sourceMaterial = sourceMaterialMetadata(fullPath, rootDir)
83
88
  results.push({
84
89
  path: relative(rootDir, fullPath),
85
90
  type: typeLabel(ext),
86
91
  size: formatSize(stat.size),
92
+ sizeBytes: stat.size,
93
+ sourceMaterial: { ...sourceMaterial, status: "discovered" },
87
94
  })
88
95
  }
89
96
  }