@cyber-dash-tech/revela 0.11.0 → 0.13.0
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 +35 -29
- package/README.zh-CN.md +35 -29
- package/lib/commands/brief.ts +63 -0
- package/lib/commands/designs.ts +2 -2
- package/lib/commands/domains.ts +2 -2
- package/lib/commands/enable.ts +19 -19
- package/lib/commands/help.ts +7 -3
- package/lib/commands/init.ts +30 -19
- package/lib/commands/narrative.ts +160 -0
- package/lib/commands/review.ts +115 -1
- package/lib/decks-state.ts +46 -3
- package/lib/edit/prompt.ts +3 -0
- package/lib/inspection-context/compile.ts +159 -5
- package/lib/inspection-context/project.ts +20 -0
- package/lib/narrative-state/coverage.ts +100 -0
- package/lib/narrative-state/display.ts +219 -0
- package/lib/narrative-state/executive-brief.ts +246 -0
- package/lib/narrative-state/hash.ts +61 -0
- package/lib/narrative-state/map-html.ts +348 -0
- package/lib/narrative-state/map.ts +282 -0
- package/lib/narrative-state/normalize.ts +361 -0
- package/lib/narrative-state/project-compat.ts +14 -0
- package/lib/narrative-state/queries.ts +433 -0
- package/lib/narrative-state/readiness.ts +359 -0
- package/lib/narrative-state/render-plan.ts +250 -0
- package/lib/narrative-state/research-gaps.ts +191 -0
- package/lib/narrative-state/types.ts +172 -0
- package/lib/prompt-builder.ts +59 -26
- package/lib/workspace-state/evidence-status.ts +21 -1
- package/lib/workspace-state/graph.ts +174 -2
- package/lib/workspace-state/types.ts +13 -1
- package/package.json +1 -1
- package/plugin.ts +58 -2
- package/skill/NARRATIVE_SKILL.md +64 -0
- package/tools/decks.ts +265 -2
- package/tools/narrative-view.ts +84 -0
- package/tools/workspace-scan.ts +14 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**English** | [中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@cyber-dash-tech/revela) [](LICENSE) [](https://www.npmjs.com/package/@cyber-dash-tech/revela) [](LICENSE) [](tests/) [](https://opencode.ai) [](https://bun.sh)
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<img src="assets/img/logo.png" alt="Revela" width="800" />
|
|
@@ -17,11 +17,11 @@ Its first render target is still the HTML slide deck: enable Revela for the curr
|
|
|
17
17
|
|
|
18
18
|
## What It Does
|
|
19
19
|
|
|
20
|
-
- injects a
|
|
21
|
-
-
|
|
20
|
+
- injects a narrative-first system prompt into your current agent with `/revela enable`
|
|
21
|
+
- switches into deck-render prompt mode only when you explicitly start `/revela deck`
|
|
22
22
|
- supports workspace document discovery, transparent text extraction for `.pdf`, `.docx`, `.pptx`, and `.xlsx`, and cached embedded-material extraction for those formats
|
|
23
23
|
- keeps `DECKS.json` as the current workspace state engine for sources, research actions, findings, claims, evidence, narrative intent, render targets, and readiness
|
|
24
|
-
-
|
|
24
|
+
- reviews narrative readiness before artifact rendering, then separately gates deck HTML writes through deck/artifact readiness
|
|
25
25
|
- records review snapshots so stale readiness cannot silently authorize new deck HTML after important state changes
|
|
26
26
|
- treats HTML decks, PDF, and PPTX as render targets from shared workspace state rather than isolated output files
|
|
27
27
|
- runs fast design compliance checks whenever the agent writes, patches, or edits `decks/*.html`
|
|
@@ -105,16 +105,17 @@ Optionally switch design or domain:
|
|
|
105
105
|
/revela domains deeptech-investment
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
Then
|
|
108
|
+
Then shape or review the narrative. When the narrative is ready and approved, start deck handoff:
|
|
109
109
|
|
|
110
110
|
```text
|
|
111
|
-
|
|
111
|
+
/revela review
|
|
112
|
+
/revela deck
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
If
|
|
115
|
+
If you need to check only the deck/artifact gate before HTML writing, use:
|
|
115
116
|
|
|
116
117
|
```text
|
|
117
|
-
/revela review
|
|
118
|
+
/revela deck --review
|
|
118
119
|
```
|
|
119
120
|
|
|
120
121
|
Export when needed, either manually or by asking the agent to export:
|
|
@@ -136,11 +137,13 @@ Disable presentation mode when done:
|
|
|
136
137
|
|
|
137
138
|
```text
|
|
138
139
|
/revela show status and help
|
|
139
|
-
/revela enable enable
|
|
140
|
-
/revela disable disable
|
|
140
|
+
/revela enable enable narrative/artifact mode for this session
|
|
141
|
+
/revela disable disable Revela mode
|
|
141
142
|
|
|
142
|
-
/revela init
|
|
143
|
-
/revela review
|
|
143
|
+
/revela init initialize or refresh narrative workspace state
|
|
144
|
+
/revela review review narrative readiness and approval state
|
|
145
|
+
/revela deck start deck handoff from approved narrative
|
|
146
|
+
/revela deck --review review deck/artifact readiness before writing HTML
|
|
144
147
|
/revela remember <text> save an explicit user/workflow preference
|
|
145
148
|
/revela refine open unified Edit/Inspect refinement workspace
|
|
146
149
|
/revela edit open visual editor for the only deck in decks/
|
|
@@ -163,7 +166,7 @@ Disable presentation mode when done:
|
|
|
163
166
|
/revela pptx <file> export an HTML deck to editable PPTX in the same directory
|
|
164
167
|
```
|
|
165
168
|
|
|
166
|
-
Most `/revela` commands run locally with zero LLM cost. `/revela init`, `/revela review`, `/revela remember`, `/revela designs-new`, and `/revela designs-edit` start AI-assisted workflows because they need to read or update project files. `/revela refine` opens a local browser workspace with Edit and Inspect tabs that share the same Cmd/Ctrl-click element references. Edit sends targeted comments back into the current OpenCode session; Inspect renders deterministic Source/Purpose preprocessing first before lazy LLM-generated cards arrive, has no chat box, and does not edit the deck.
|
|
169
|
+
Most `/revela` commands run locally with zero LLM cost. `/revela init`, `/revela review`, `/revela deck`, `/revela remember`, `/revela designs-new`, and `/revela designs-edit` start AI-assisted workflows because they need to read or update project files. `/revela refine` opens a local browser workspace with Edit and Inspect tabs that share the same Cmd/Ctrl-click element references. Edit sends targeted comments back into the current OpenCode session; Inspect renders deterministic Source/Purpose preprocessing first before lazy LLM-generated cards arrive, has no chat box, and does not edit the deck.
|
|
167
170
|
|
|
168
171
|
---
|
|
169
172
|
|
|
@@ -171,9 +174,11 @@ Most `/revela` commands run locally with zero LLM cost. `/revela init`, `/revela
|
|
|
171
174
|
|
|
172
175
|
When Revela is enabled, it appends a generated prompt to the current agent's system prompt.
|
|
173
176
|
|
|
174
|
-
|
|
177
|
+
The default prompt is narrative-first: it focuses on audience belief shift, decision/action, thesis, claims, evidence boundaries, objections, risks, and approval. Active design CSS, layout catalogs, component indexes, chart rules, and deck HTML skeletons are intentionally omitted until `/revela deck` switches the session into deck-render mode.
|
|
178
|
+
|
|
179
|
+
Deck-render mode is built from 3 layers:
|
|
175
180
|
|
|
176
|
-
1. `skill/SKILL.md` - the core
|
|
181
|
+
1. `skill/SKILL.md` - the core deck-render workflow
|
|
177
182
|
2. active domain - domain-specific report structure and terminology
|
|
178
183
|
3. active design - visual system, layouts, components, and chart rules
|
|
179
184
|
|
|
@@ -188,11 +193,11 @@ The state records:
|
|
|
188
193
|
|
|
189
194
|
- workspace source materials and reusable extraction cache paths
|
|
190
195
|
- research plans, saved findings, and compact action provenance
|
|
191
|
-
- narrative
|
|
196
|
+
- canonical narrative state, approvals, objections, risks, slide specs, claim candidates, and evidence trace
|
|
192
197
|
- render targets such as the active HTML deck plus derived PDF and PPTX artifacts
|
|
193
198
|
- review snapshots with input hashes so old readiness results become stale after meaningful state changes
|
|
194
199
|
|
|
195
|
-
|
|
200
|
+
Existing root `DECKS.json` workspaces remain compatible. Running `/revela init` or `/revela review` on an older project can normalize canonical narrative state and refresh projection fields without requiring a manual migration, moving files, or replacing `DECKS.json` with a database. `writeReadiness.status: "ready"` is deck/artifact readiness only; it is never narrative approval.
|
|
196
201
|
|
|
197
202
|
Decks remain the primary authored artifact, but they are now treated as render targets from the same workspace state that can later support briefs, appendix material, Evidence Inspector views, Q&A, and interactive reading layers without duplicating source/evidence logic.
|
|
198
203
|
|
|
@@ -200,21 +205,22 @@ Decks remain the primary authored artifact, but they are now treated as render t
|
|
|
200
205
|
|
|
201
206
|
## Recommended Workflow
|
|
202
207
|
|
|
203
|
-
Use Revela as a
|
|
208
|
+
Use Revela as a narrative-first artifact workflow:
|
|
204
209
|
|
|
205
210
|
1. Enable Revela with `/revela enable`.
|
|
206
211
|
2. Run `/revela init` when starting in a new project or when the workspace has changed significantly.
|
|
207
|
-
3.
|
|
208
|
-
4.
|
|
209
|
-
5.
|
|
210
|
-
6.
|
|
211
|
-
7.
|
|
212
|
-
8. Use `/revela
|
|
213
|
-
9.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
3. Use `/revela review` to check narrative readiness: audience, belief shift, decision/action, thesis, central claims, evidence, objections, risks, and approval state.
|
|
213
|
+
4. Approve the narrative or request revisions. If you intentionally render before full strategic approval, record an explicit render override.
|
|
214
|
+
5. Run `/revela deck` to compile the approved narrative into deck slide specs and enter deck-render mode.
|
|
215
|
+
6. Choose or confirm design only during deck handoff, then run the deck/artifact gate with `/revela deck --review` or the handoff workflow.
|
|
216
|
+
7. Let the agent write the HTML deck under `decks/` only after the artifact gate is ready.
|
|
217
|
+
8. Use `/revela refine` for visual comments, targeted revisions, and optional Source/Purpose inspection of selected deck elements.
|
|
218
|
+
9. Use `/revela edit` or `/revela inspect` directly only if you need the older single-purpose shells.
|
|
219
|
+
10. Export with `/revela pdf <file>` or `/revela pptx <file>`.
|
|
220
|
+
|
|
221
|
+
`/revela review` checks narrative readiness: unclear audience, missing belief shift, missing decision/action, weak thesis, unsupported central claims, weak evidence, unsupported scope, unhandled objections, missing risk/assumption handling, stale approval, or missing approval. It does not review design/layout readiness and does not write the final deck.
|
|
222
|
+
|
|
223
|
+
If Revela blocks a deck write, ask the agent to run `/revela deck --review`, resolve the reported artifact gaps, and try again. This protects the deck file from being overwritten before the slide specs, evidence projection, design/layout readiness, review snapshot, and deck HTML contract are ready.
|
|
218
224
|
|
|
219
225
|
To remember long-term preferences, use:
|
|
220
226
|
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | **中文**
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@cyber-dash-tech/revela) [](LICENSE) [](https://www.npmjs.com/package/@cyber-dash-tech/revela) [](LICENSE) [](tests/) [](https://opencode.ai) [](https://bun.sh)
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<img src="assets/img/logo.png" alt="Revela" width="800" />
|
|
@@ -17,11 +17,11 @@ Revela 是一个 [OpenCode](https://opencode.ai) 插件,用来把工作区来
|
|
|
17
17
|
|
|
18
18
|
## 它能做什么
|
|
19
19
|
|
|
20
|
-
- 通过 `/revela enable` 向当前 agent
|
|
21
|
-
-
|
|
20
|
+
- 通过 `/revela enable` 向当前 agent 注入 narrative-first system prompt
|
|
21
|
+
- 只有在显式运行 `/revela deck` 时,才切换到 deck-render prompt mode
|
|
22
22
|
- 支持工作区文档扫描,以及 `.pdf`、`.docx`、`.pptx`、`.xlsx` 的透明文本提取和嵌入素材缓存提取
|
|
23
23
|
- 将 `DECKS.json` 作为当前 workspace state engine,持续记录来源材料、调研动作、findings、claims、证据、叙事意图、render targets 和 readiness
|
|
24
|
-
-
|
|
24
|
+
- 先检查 narrative readiness,再用独立 deck/artifact gate 保护 deck HTML 写入
|
|
25
25
|
- 记录 review snapshots,避免重要状态变化后旧的 ready 结果继续默默授权写入 deck HTML
|
|
26
26
|
- 把 HTML deck、PDF 和 PPTX 视为来自同一 workspace state 的 render targets,而不是互相孤立的输出文件
|
|
27
27
|
- agent 每次写入、patch 或 edit `decks/*.html` 时自动执行快速 design compliance 检查
|
|
@@ -104,16 +104,17 @@ export { default } from "/absolute/path/to/revela/index.ts";
|
|
|
104
104
|
/revela domains deeptech-investment
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
然后先打磨或检查叙事。叙事 ready 并获得批准后,再进入 deck handoff:
|
|
108
108
|
|
|
109
109
|
```text
|
|
110
|
-
|
|
110
|
+
/revela review
|
|
111
|
+
/revela deck
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
|
|
114
|
+
如果只需要检查写 HTML 前的 deck/artifact gate,使用:
|
|
114
115
|
|
|
115
116
|
```text
|
|
116
|
-
/revela review
|
|
117
|
+
/revela deck --review
|
|
117
118
|
```
|
|
118
119
|
|
|
119
120
|
需要导出时,可以手动调用,也可以让 agent 直接导出:
|
|
@@ -135,11 +136,13 @@ Create a 6-slide HTML deck on humanoid robotics supply chains. Cite the main mar
|
|
|
135
136
|
|
|
136
137
|
```text
|
|
137
138
|
/revela 显示当前状态与帮助
|
|
138
|
-
/revela enable
|
|
139
|
-
/revela disable
|
|
139
|
+
/revela enable 为当前会话启用 narrative/artifact 模式
|
|
140
|
+
/revela disable 关闭 Revela 模式
|
|
140
141
|
|
|
141
|
-
/revela init
|
|
142
|
-
/revela review
|
|
142
|
+
/revela init 初始化或刷新 narrative workspace state
|
|
143
|
+
/revela review 检查 narrative readiness 和 approval state
|
|
144
|
+
/revela deck 从已批准 narrative 开始 deck handoff
|
|
145
|
+
/revela deck --review 写 HTML 前检查 deck/artifact readiness
|
|
143
146
|
/revela remember <text> 保存明确的用户/工作流偏好
|
|
144
147
|
/revela refine 打开统一的 Edit/Inspect refinement workspace
|
|
145
148
|
/revela edit 打开 decks/ 下唯一 deck 的可视化编辑器
|
|
@@ -162,7 +165,7 @@ Create a 6-slide HTML deck on humanoid robotics supply chains. Cite the main mar
|
|
|
162
165
|
/revela pptx <file> 将 HTML deck 导出为同目录可编辑 PPTX
|
|
163
166
|
```
|
|
164
167
|
|
|
165
|
-
大多数 `/revela` 命令都在本地执行,不消耗 LLM token。`/revela init`、`/revela review`、`/revela remember`、`/revela designs-new` 和 `/revela designs-edit` 会启动 AI 辅助流程,因为它们需要读取或更新项目状态。`/revela refine` 会打开一个本地浏览器 workspace,里面有 Edit 和 Inspect 两个 tab,并共享同一套 Cmd/Ctrl-click 元素引用。Edit 会把精准修改评论发回当前 OpenCode 会话;Inspect 会先渲染确定性 Source/Purpose 预处理结果,再 lazy 显示 LLM 生成的卡片。它没有聊天框,也不会修改 deck。
|
|
168
|
+
大多数 `/revela` 命令都在本地执行,不消耗 LLM token。`/revela init`、`/revela review`、`/revela deck`、`/revela remember`、`/revela designs-new` 和 `/revela designs-edit` 会启动 AI 辅助流程,因为它们需要读取或更新项目状态。`/revela refine` 会打开一个本地浏览器 workspace,里面有 Edit 和 Inspect 两个 tab,并共享同一套 Cmd/Ctrl-click 元素引用。Edit 会把精准修改评论发回当前 OpenCode 会话;Inspect 会先渲染确定性 Source/Purpose 预处理结果,再 lazy 显示 LLM 生成的卡片。它没有聊天框,也不会修改 deck。
|
|
166
169
|
|
|
167
170
|
---
|
|
168
171
|
|
|
@@ -170,9 +173,11 @@ Create a 6-slide HTML deck on humanoid robotics supply chains. Cite the main mar
|
|
|
170
173
|
|
|
171
174
|
启用 Revela 后,它会把一份动态生成的 prompt 追加到当前 agent 的 system prompt 中。
|
|
172
175
|
|
|
173
|
-
|
|
176
|
+
默认 prompt 是 narrative-first:它关注受众信念变化、decision/action、thesis、claims、证据边界、objections、risks 和 approval。Active design CSS、layout catalog、component index、chart rules 和 deck HTML skeleton 在 `/revela deck` 切换到 deck-render mode 前不会注入。
|
|
177
|
+
|
|
178
|
+
Deck-render mode 由 3 层组成:
|
|
174
179
|
|
|
175
|
-
1. `skill/SKILL.md` -
|
|
180
|
+
1. `skill/SKILL.md` - 核心 deck-render 流程
|
|
176
181
|
2. 当前 active domain - 行业结构与术语
|
|
177
182
|
3. 当前 active design - 视觉系统、layout、component 和图表规则
|
|
178
183
|
|
|
@@ -187,11 +192,11 @@ Create a 6-slide HTML deck on humanoid robotics supply chains. Cite the main mar
|
|
|
187
192
|
|
|
188
193
|
- 工作区来源材料和可复用的 extraction cache 路径
|
|
189
194
|
- 调研计划、已保存 findings,以及精简的 action provenance
|
|
190
|
-
- narrative
|
|
195
|
+
- canonical narrative state、approvals、objections、risks、slide specs、claim candidates 和 evidence trace
|
|
191
196
|
- active HTML deck 以及派生 PDF、PPTX 等 render targets
|
|
192
197
|
- 带 input hash 的 review snapshots,使重要状态变化后旧的 readiness 自动变 stale
|
|
193
198
|
|
|
194
|
-
|
|
199
|
+
已有的根目录 `DECKS.json` 工作区继续兼容。对旧项目运行 `/revela init` 或 `/revela review` 时,可以安全 normalize canonical narrative state 并刷新 projection 字段;用户不需要手动迁移、不需要移动文件,也不需要把 `DECKS.json` 换成数据库。`writeReadiness.status: "ready"` 只代表 deck/artifact readiness,永远不等于 narrative approval。
|
|
195
200
|
|
|
196
201
|
Deck 仍然是主要 authored artifact,但现在它是从同一份 workspace state 渲染出来的目标之一。后续 briefs、appendix material、Evidence Inspector views、Q&A 和 interactive reading layers 都可以复用同一套来源/证据逻辑,而不是各自生成孤立内容。
|
|
197
202
|
|
|
@@ -199,21 +204,22 @@ Deck 仍然是主要 authored artifact,但现在它是从同一份 workspace s
|
|
|
199
204
|
|
|
200
205
|
## 推荐使用流程
|
|
201
206
|
|
|
202
|
-
把 Revela
|
|
207
|
+
把 Revela 当成 narrative-first artifact workflow:
|
|
203
208
|
|
|
204
209
|
1. 用 `/revela enable` 启用 Revela。
|
|
205
210
|
2. 新项目或工作区明显变化时,运行 `/revela init`。
|
|
206
|
-
3.
|
|
207
|
-
4.
|
|
208
|
-
5.
|
|
209
|
-
6.
|
|
210
|
-
7.
|
|
211
|
-
8.
|
|
212
|
-
9.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
211
|
+
3. 用 `/revela review` 检查 narrative readiness:受众、信念变化、decision/action、thesis、central claims、证据、objections、risks 和 approval state。
|
|
212
|
+
4. 批准 narrative 或要求修改。如果需要在完整战略批准前渲染,必须记录 explicit render override。
|
|
213
|
+
5. 运行 `/revela deck`,把已批准 narrative 编译成 deck slide specs,并进入 deck-render mode。
|
|
214
|
+
6. 只在 deck handoff 阶段选择或确认 design,然后通过 handoff workflow 或 `/revela deck --review` 运行 deck/artifact gate。
|
|
215
|
+
7. 只有 artifact gate ready 后,才让 agent 把 HTML deck 写到 `decks/` 下。
|
|
216
|
+
8. 用 `/revela refine` 对选中 deck 元素做可视化评论、精准修改,以及可选的 Source/Purpose 检查。
|
|
217
|
+
9. 只有在需要旧的单一功能 shell 时,才单独使用 `/revela edit` 或 `/revela inspect`。
|
|
218
|
+
10. 用 `/revela pdf <file>` 或 `/revela pptx <file>` 导出。
|
|
219
|
+
|
|
220
|
+
`/revela review` 检查的是 narrative readiness:受众不清、缺信念变化、缺 decision/action、thesis 弱、central claims 无证据、evidence 弱、unsupported scope、objection 未处理、缺风险/假设处理、approval stale 或缺 approval。它不检查 design/layout readiness,也不会写最终 deck。
|
|
221
|
+
|
|
222
|
+
如果 Revela 阻止写入 deck,直接让 agent 运行 `/revela deck --review`,根据报告补齐 artifact 缺口后再写。这样可以避免在 slide specs、evidence projection、design/layout readiness、review snapshot 和 deck HTML contract 还不完整时覆盖真实 deck 文件。
|
|
217
223
|
|
|
218
224
|
记住长期偏好请使用:
|
|
219
225
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "fs"
|
|
2
|
+
import { dirname, isAbsolute, join, normalize, resolve } from "path"
|
|
3
|
+
import { readDecksState, writeDecksState } from "../decks-state"
|
|
4
|
+
import { compileExecutiveBrief, DEFAULT_EXECUTIVE_BRIEF_PATH } from "../narrative-state/executive-brief"
|
|
5
|
+
|
|
6
|
+
export interface BriefArgs {
|
|
7
|
+
outputPath?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type ParseBriefArgsResult = { ok: true; args: BriefArgs } | { ok: false; error: string }
|
|
11
|
+
|
|
12
|
+
export function parseBriefArgs(input: string): ParseBriefArgsResult {
|
|
13
|
+
const value = input.trim()
|
|
14
|
+
if (!value) return { ok: true, args: {} }
|
|
15
|
+
if (value.startsWith("--")) return { ok: false, error: "Usage: `/revela brief [workspace-relative-output.md]`" }
|
|
16
|
+
if (!value.endsWith(".md")) return { ok: false, error: "Executive brief output must be a Markdown file ending in `.md`." }
|
|
17
|
+
if (isAbsolute(value) || value.split(/[\\/]+/).includes("..")) return { ok: false, error: "Executive brief output must be a safe workspace-relative path." }
|
|
18
|
+
return { ok: true, args: { outputPath: normalize(value).replace(/\\/g, "/") } }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function handleBrief(
|
|
22
|
+
input: { workspaceRoot: string; outputPath?: string },
|
|
23
|
+
send: (text: string) => Promise<void>,
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
const statePath = join(input.workspaceRoot, "DECKS.json")
|
|
26
|
+
if (!existsSync(statePath)) {
|
|
27
|
+
await send("No `DECKS.json` found. Run `/revela init` before rendering an executive brief.")
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const state = readDecksState(input.workspaceRoot)
|
|
32
|
+
const result = compileExecutiveBrief(state, { outputPath: input.outputPath })
|
|
33
|
+
if (!result.ok) {
|
|
34
|
+
await send(
|
|
35
|
+
`**Executive brief not rendered**\n\n${result.reason}\n\n` +
|
|
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."
|
|
38
|
+
)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const filePath = safeWorkspaceFilePath(input.workspaceRoot, result.outputPath)
|
|
43
|
+
mkdirSync(dirname(filePath), { recursive: true })
|
|
44
|
+
writeFileSync(filePath, result.content, "utf-8")
|
|
45
|
+
writeDecksState(input.workspaceRoot, result.state)
|
|
46
|
+
|
|
47
|
+
await send(
|
|
48
|
+
`**Executive brief rendered**\n\n` +
|
|
49
|
+
`- Output: \`${result.outputPath}\`\n` +
|
|
50
|
+
`- Render target: \`${result.target.id}\`\n` +
|
|
51
|
+
`- Narrative hash: \`${result.narrativeHash}\`\n\n` +
|
|
52
|
+
"The brief was compiled from canonical narrative state, not from a deck summary."
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function safeWorkspaceFilePath(workspaceRoot: string, outputPath: string): string {
|
|
57
|
+
const relative = outputPath || DEFAULT_EXECUTIVE_BRIEF_PATH
|
|
58
|
+
if (isAbsolute(relative) || relative.split(/[\\/]+/).includes("..")) throw new Error("Executive brief output must be a safe workspace-relative path.")
|
|
59
|
+
const root = resolve(workspaceRoot)
|
|
60
|
+
const target = resolve(root, relative)
|
|
61
|
+
if (target !== root && !target.startsWith(`${root}/`)) throw new Error("Executive brief output must stay inside the workspace.")
|
|
62
|
+
return target
|
|
63
|
+
}
|
package/lib/commands/designs.ts
CHANGED
|
@@ -35,8 +35,8 @@ export async function handleDesignsActivate(
|
|
|
35
35
|
): Promise<void> {
|
|
36
36
|
try {
|
|
37
37
|
activateDesign(name)
|
|
38
|
-
buildPrompt()
|
|
39
|
-
await send(`**Design activated:** \`${name}\`\
|
|
38
|
+
buildPrompt({ mode: "narrative" })
|
|
39
|
+
await send(`**Design activated:** \`${name}\`\nNarrative prompt rebuilt. The design will apply when \`/revela deck\` enters deck-render mode.`)
|
|
40
40
|
} catch (e: any) {
|
|
41
41
|
await send(`**Error:** ${e.message}`)
|
|
42
42
|
}
|
package/lib/commands/domains.ts
CHANGED
|
@@ -35,8 +35,8 @@ export async function handleDomainsActivate(
|
|
|
35
35
|
): Promise<void> {
|
|
36
36
|
try {
|
|
37
37
|
activateDomain(name)
|
|
38
|
-
buildPrompt()
|
|
39
|
-
await send(`**Domain activated:** \`${name}\`\
|
|
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\`.`)
|
|
40
40
|
} catch (e: any) {
|
|
41
41
|
await send(`**Error:** ${e.message}`)
|
|
42
42
|
}
|
package/lib/commands/enable.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/commands/enable.ts
|
|
3
3
|
*
|
|
4
|
-
* Handler for `/revela enable` — activates
|
|
4
|
+
* Handler for `/revela enable` — activates Revela narrative/artifact mode.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { existsSync } from "fs"
|
|
@@ -19,30 +19,30 @@ export async function handleEnable(
|
|
|
19
19
|
const design = activeDesign()
|
|
20
20
|
const domain = activeDomain()
|
|
21
21
|
|
|
22
|
-
//
|
|
23
|
-
//
|
|
22
|
+
// Always rebuild narrative mode on enable. A prior `/revela deck` handoff may
|
|
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 })
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
buildPrompt({ mode: "narrative" })
|
|
29
|
+
log.info("narrative prompt rebuilt on enable", { design, domain, promptFile: ACTIVE_PROMPT_FILE })
|
|
30
|
+
} catch (e) {
|
|
31
|
+
log.error("prompt rebuild failed on enable", { error: e instanceof Error ? e.message : String(e) })
|
|
32
|
+
await send(
|
|
33
|
+
`**Revela enabled (with warnings).** Narrative/artifact mode is active, ` +
|
|
34
|
+
`but the prompt file could not be built. ` +
|
|
35
|
+
`Try \`/revela disable\` then \`/revela enable\` again, or check that the package is correctly installed.\n\n` +
|
|
36
|
+
`Design: \`${design}\` · Domain: \`${domain}\``
|
|
37
|
+
)
|
|
38
|
+
return
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
log.info("revela enabled", { design, domain })
|
|
42
42
|
await send(
|
|
43
|
-
`**Revela enabled.**
|
|
43
|
+
`**Revela enabled.** Narrative/artifact mode is now active.\n` +
|
|
44
44
|
`Design: \`${design}\` · Domain: \`${domain}\`\n\n` +
|
|
45
|
-
`The
|
|
46
|
-
`
|
|
45
|
+
`The narrative-first prompt will be injected into every message. ` +
|
|
46
|
+
`Use \`/revela deck\` when you are ready to enter deck-render mode.`
|
|
47
47
|
)
|
|
48
48
|
}
|
package/lib/commands/help.ts
CHANGED
|
@@ -24,10 +24,14 @@ export async function handleHelp(
|
|
|
24
24
|
`🟠 **Domain:** \`${domain}\`\n\n` +
|
|
25
25
|
`---\n\n` +
|
|
26
26
|
`**Commands**\n\n` +
|
|
27
|
-
`\`/revela enable\` — enable
|
|
28
|
-
`\`/revela disable\` — disable
|
|
27
|
+
`\`/revela enable\` — enable Revela narrative/artifact mode\n` +
|
|
28
|
+
`\`/revela disable\` — disable Revela mode\n` +
|
|
29
29
|
`\`/revela init\` — initialize or refresh workspace DECKS.json\n` +
|
|
30
|
-
`\`/revela review\` — review
|
|
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` +
|
|
31
35
|
`\`/revela refine\` — open unified Edit/Inspect refinement workspace\n` +
|
|
32
36
|
`\`/revela edit\` — open visual editor for the only deck in decks/\n` +
|
|
33
37
|
`\`/revela inspect\` — open Evidence Inspector for click-to-inspect review\n` +
|
package/lib/commands/init.ts
CHANGED
|
@@ -9,17 +9,17 @@ export function buildInitPrompt({
|
|
|
9
9
|
}): string {
|
|
10
10
|
const mode = exists
|
|
11
11
|
? `A ${DECKS_STATE_FILE} file already exists. Read it first through the revela-decks tool and update it conservatively.`
|
|
12
|
-
: `No ${DECKS_STATE_FILE} file exists yet. Create it through the revela-decks tool.`
|
|
12
|
+
: `No ${DECKS_STATE_FILE} file exists yet. Create it through the revela-decks tool only when there is enough stable workspace or narrative context.`
|
|
13
13
|
|
|
14
|
-
return `Initialize Revela workspace state
|
|
14
|
+
return `Initialize Revela narrative workspace state.
|
|
15
15
|
|
|
16
16
|
Goal:
|
|
17
|
-
- Build or update ${DECKS_STATE_FILE}, the workspace-level machine-readable state file for
|
|
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
|
-
- Capture stable
|
|
20
|
-
- Do not treat initialization as permission to write a
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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\`.
|
|
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
|
+
- ${DECKS_STATE_FILE} is the compatibility workspace-state file. Deck specs are render-target projections, not the center of initialization.
|
|
23
23
|
|
|
24
24
|
Current state:
|
|
25
25
|
- ${mode}
|
|
@@ -35,30 +35,41 @@ Workspace boundary rules:
|
|
|
35
35
|
|
|
36
36
|
Workflow:
|
|
37
37
|
1. Use the \`revela-workspace-scan\` tool to inspect document and data files in the workspace. Start with no \`path\` and \`max_depth: 2\`.
|
|
38
|
-
2. Separately search for existing
|
|
38
|
+
2. Separately search for existing artifact history, especially:
|
|
39
39
|
- \`decks/**/*.html\`
|
|
40
40
|
- \`slides/**/*.html\`
|
|
41
41
|
- \`presentations/**/*.html\`
|
|
42
42
|
- \`decks/**/*.pdf\`
|
|
43
43
|
- \`slides/**/*.pdf\`
|
|
44
|
-
Run these searches only inside the current workspace root. These are generated/output
|
|
44
|
+
Run these searches only inside the current workspace root. These are generated/output artifacts, not necessarily source materials. If \`decks/\` contains exactly one HTML file, record it as existing artifact history and possible current deck artifact. If \`decks/\` contains multiple HTML files, do not guess which one is canonical; ask the user which artifact belongs to this workspace or whether extra decks should move to separate workspaces.
|
|
45
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
|
|
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
|
|
46
|
+
4. Select the files that look most relevant for understanding the narrative problem. Prioritize source decks, PDFs, Word docs, spreadsheets, CSVs, Markdown, text notes, and relevant existing generated artifacts.
|
|
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 narrative memory, or when the user explicitly asked to analyze the material now.
|
|
48
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
|
|
50
|
-
8. If
|
|
51
|
-
9.
|
|
52
|
-
10. When
|
|
53
|
-
11.
|
|
54
|
-
12.
|
|
49
|
+
7. Read only the materials needed to form conservative narrative memory. Do not exhaustively read every file if the workspace is large.
|
|
50
|
+
8. If enough information is available, preserve canonical narrative intent through \`revela-decks\` action \`upsertNarrative\`: audience intent, decision intent, thesis, central claims, explicit evidence bindings where known, objections, and risks. This does not require deck rendering inputs.
|
|
51
|
+
9. If the workspace has explicit slide/deck information, existing HTML, or a user-requested deck task, you may also call \`upsertDeck\` and \`upsertSlides\` for explicit deck information. The tool projects canonical narrative state back to compatibility \`narrativeBrief\` when a deck record exists. Do not pass or ask for a deck key; the tool uses the workspace folder name internally. Do not mark deck readiness ready during init.
|
|
52
|
+
10. When adopting an existing HTML deck, analyze the artifact and create one conservative \`SlideSpec\` per identifiable slide/page only if the artifact is clearly the current workspace artifact. Record only visible source notes or explicit source information as evidence; do not infer original evidence that is not present in the artifact.
|
|
53
|
+
11. When a read or extracted source material clearly supports a specific narrative or slide claim, preserve compact evidence trace such as \`sourcePath\`, \`location\`, \`extractedTextPath\`, or \`extractedManifestPath\`. Attach extraction cache paths only when they support that specific claim, not to every claim or slide by default.
|
|
54
|
+
12. Treat \`workspace.sourceMaterials\` as a reusable candidate index, not proof by itself. A source material record alone is not narrative evidence or slide evidence.
|
|
55
|
+
13. Report what was initialized or updated and list the smallest open narrative questions needed to proceed.
|
|
56
|
+
|
|
57
|
+
Narrative questions to ask only when missing:
|
|
58
|
+
- Who is the primary audience?
|
|
59
|
+
- What do they believe before this communication?
|
|
60
|
+
- What should they believe after it?
|
|
61
|
+
- What decision or action is required?
|
|
62
|
+
- What is the working thesis or recommendation?
|
|
63
|
+
- Which central claims support the thesis?
|
|
64
|
+
- Which sources or findings support those claims?
|
|
65
|
+
- What objections, risks, assumptions, or caveats could break the argument?
|
|
55
66
|
|
|
56
67
|
Memory rules:
|
|
57
|
-
- Only write facts supported by workspace files into ${DECKS_STATE_FILE} workspace state, source materials, deck memory, and open questions.
|
|
68
|
+
- Only write facts supported by workspace files or explicit user statements into ${DECKS_STATE_FILE} workspace state, source materials, narrative compatibility fields, deck memory, and open questions.
|
|
58
69
|
- Only write user preferences if the user explicitly stated that Revela should remember them.
|
|
59
70
|
- Do not infer personal preferences from one-off requests.
|
|
60
71
|
- Do not store secrets, credentials, API keys, tokens, account details, or sensitive personal information.
|
|
61
|
-
- Do not mark writeReadiness as ready during init
|
|
72
|
+
- Do not mark narrative approval, render override, or writeReadiness as ready during init.
|
|
62
73
|
- Treat this workspace as a single deck project. If the user wants another deck, guide them to create another workspace/folder rather than adding a second deck record.
|
|
63
74
|
- If new evidence conflicts with existing memory, preserve both briefly and add an Open Question instead of silently overwriting.
|
|
64
75
|
|