@cyber-dash-tech/revela 0.13.0 → 0.14.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.
@@ -459,6 +459,7 @@ async function handleInspect(req: Request, session: EditSession): Promise<Respon
459
459
  }
460
460
 
461
461
  const snapshot = normalizeSnapshot(body?.snapshot ?? body)
462
+ const language = normalizeInspectLanguage(body?.language)
462
463
  const requestId = typeof body?.requestId === "string" && body.requestId.trim() ? body.requestId.trim() : randomBytes(10).toString("base64url")
463
464
  const version = readDeckVersion(session).version
464
465
  const staleReason = typeof body?.deckVersion === "string" && body.deckVersion !== version
@@ -480,6 +481,7 @@ async function handleInspect(req: Request, session: EditSession): Promise<Respon
480
481
  text: buildInspectionPrompt({
481
482
  requestId,
482
483
  file: session.file,
484
+ language,
483
485
  projection: staleReason
484
486
  ? { ...projection, stale: { stale: true, reason: staleReason } } as any
485
487
  : projection,
@@ -491,7 +493,7 @@ async function handleInspect(req: Request, session: EditSession): Promise<Respon
491
493
  failInspectRequest(requestId, message)
492
494
  })
493
495
 
494
- return jsonResponse({ ok: true, requestId, deckVersion: version, status: "pending", preprocess })
496
+ return jsonResponse({ ok: true, requestId, deckVersion: version, status: "pending", language, preprocess })
495
497
  } catch (error) {
496
498
  const message = error instanceof Error ? error.message : String(error)
497
499
  failInspectRequest(requestId, message)
@@ -510,6 +512,11 @@ function handleInspectResult(requestId: string | null, session: EditSession): Re
510
512
  return jsonResponse({ ok: true, requestId, status: request.status, deckVersion: request.deckVersion })
511
513
  }
512
514
 
515
+ function normalizeInspectLanguage(input: unknown): string {
516
+ const value = typeof input === "string" ? input.trim() : ""
517
+ return value || "Auto"
518
+ }
519
+
513
520
  function normalizeSnapshot(input: any): InspectionElementSnapshot {
514
521
  return {
515
522
  scope: input?.scope === "selection" || input?.scope === "slide" || input?.scope === "element" ? input.scope : undefined,
@@ -657,6 +664,9 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
657
664
  .comment-bubble.stale .comment-bubble-state { color: #a16207; }
658
665
  .comment-bubble.failed .comment-bubble-state { color: #b91c1c; }
659
666
  .inspect-actions { display: flex; flex-direction: column; gap: 8px; }
667
+ .inspect-options { display: flex; flex-direction: column; gap: 5px; }
668
+ .inspect-options label { color: #64748b; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
669
+ .inspect-select { width: 100%; padding: 10px 11px; border: 1px solid #d7e0ea; border-radius: 12px; background: #fff; color: #0f172a; font-weight: 700; }
660
670
  .inspect-cards { display: flex; flex-direction: column; gap: 12px; }
661
671
  .inspect-card { border: 1px solid #d7e0ea; border-radius: 16px; background: #fff; padding: 13px; box-shadow: 0 10px 24px rgba(15,23,42,.05); }
662
672
  .inspect-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
@@ -681,7 +691,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
681
691
  <aside>
682
692
  <div>
683
693
  <h1><span class="wordmark">REVELA</span> Refine</h1>
684
- <p class="hint">Cmd/Ctrl-click slide elements once, then use Edit for fast changes or Inspect for Source/Purpose review.</p>
694
+ <p class="hint">Cmd/Ctrl-click slide elements once, then use Edit for fast changes or Inspect for Narrative Reading, Exploratory Reading, Source, and Purpose review.</p>
685
695
  </div>
686
696
  <div id="selectionSummary" class="selection-summary"><strong>Selection</strong><span>No references selected.</span><div id="selectionChips" class="selection-chips"></div></div>
687
697
  <div class="tabs" role="tablist" aria-label="Refine mode">
@@ -698,10 +708,11 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
698
708
  </div>
699
709
  <div id="inspectPanel" class="tab-panel">
700
710
  <div class="inspect-actions">
711
+ <div class="inspect-options"><label for="inspectLanguage">Display Language</label><select id="inspectLanguage" class="inspect-select"><option>Auto</option><option>English</option><option>简体中文</option><option>繁體中文</option><option>日本語</option><option>Deutsch</option><option>Français</option><option>Español</option><option>Português</option><option>Arabic</option></select></div>
701
712
  <button id="inspectButton" disabled>Inspect Selection</button>
702
713
  <div id="inspectStale"></div>
703
714
  </div>
704
- <div id="inspectCards" class="inspect-cards"><div class="inspect-empty">Select one or more deck elements, then inspect them for Source and Purpose. This does not edit the deck.</div></div>
715
+ <div id="inspectCards" class="inspect-cards"><div class="inspect-empty">Select one or more deck elements, then inspect them for Narrative Reading, Exploratory Reading, Source, and Purpose. This does not edit the deck.</div></div>
705
716
  </div>
706
717
  <div id="status" class="status"></div>
707
718
  </aside>
@@ -744,6 +755,8 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
744
755
  mode: defaultMode === 'inspect' ? 'inspect' : 'edit',
745
756
  inspecting: false,
746
757
  activeInspectRequestId: '',
758
+ inspectLanguage: 'Auto',
759
+ inspectFallback: null,
747
760
  };
748
761
  const els = {
749
762
  frame: null,
@@ -759,6 +772,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
759
772
  commentThread: null,
760
773
  send: null,
761
774
  inspectButton: null,
775
+ inspectLanguage: null,
762
776
  inspectCards: null,
763
777
  inspectStale: null,
764
778
  status: null,
@@ -792,7 +806,9 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
792
806
  els.inspectStale = document.getElementById('inspectStale');
793
807
  els.status = document.getElementById('status');
794
808
 
795
- if (!els.frame || !els.hitbox || !els.resizeHandle || !els.selectionSummary || !els.selectionChips || !els.editTab || !els.inspectTab || !els.editPanel || !els.inspectPanel || !els.comment || !els.commentThread || !els.send || !els.inspectButton || !els.inspectCards || !els.inspectStale || !els.status) {
809
+ els.inspectLanguage = document.getElementById('inspectLanguage');
810
+
811
+ if (!els.frame || !els.hitbox || !els.resizeHandle || !els.selectionSummary || !els.selectionChips || !els.editTab || !els.inspectTab || !els.editPanel || !els.inspectPanel || !els.comment || !els.commentThread || !els.send || !els.inspectButton || !els.inspectLanguage || !els.inspectCards || !els.inspectStale || !els.status) {
796
812
  throw new Error('Editor boot failed: required DOM nodes are missing.');
797
813
  }
798
814
 
@@ -840,6 +856,9 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
840
856
  els.resizeHandle.addEventListener('dblclick', resetEditorWidth);
841
857
  els.send.addEventListener('click', sendComment);
842
858
  els.inspectButton.addEventListener('click', inspectCurrentSelection);
859
+ els.inspectLanguage.addEventListener('change', () => {
860
+ state.inspectLanguage = els.inspectLanguage.value || 'Auto';
861
+ });
843
862
  els.editTab.addEventListener('click', () => setMode('edit'));
844
863
  els.inspectTab.addEventListener('click', () => setMode('inspect'));
845
864
  }
@@ -1075,7 +1094,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1075
1094
  renderReferenceOutlines();
1076
1095
  updateSendState();
1077
1096
  renderSelectionSummary();
1078
- resetInspectCards('References ready. Open Inspect and click Inspect Selection when you want Source/Purpose review.');
1097
+ resetInspectCards('References ready. Open Inspect and click Inspect Selection when you want Narrative Reading, Exploratory Reading, Source, and Purpose review.');
1079
1098
  setStatus('Inserted @' + label + '. ' + state.references.length + ' reference' + (state.references.length === 1 ? '' : 's') + ' will be sent.');
1080
1099
  }
1081
1100
 
@@ -1286,22 +1305,28 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1286
1305
  updateSendState();
1287
1306
  setMode('inspect');
1288
1307
  els.inspectStale.innerHTML = '';
1289
- els.inspectCards.innerHTML = '<div class="inspect-loading"><b>Preparing inspection...</b><br>Deterministic Source/Purpose appears first; generated cards update lazily.</div>';
1308
+ state.inspectFallback = null;
1309
+ els.inspectCards.innerHTML = '<div class="inspect-loading"><b>Reading selection...</b><br>Sending grounded selection context to OpenCode. Deterministic context is kept as fallback if generation fails.</div>';
1290
1310
  try {
1291
1311
  const res = await fetch('/api/inspect?token=' + encodeURIComponent(token), {
1292
1312
  method: 'POST',
1293
1313
  headers: { 'content-type': 'application/json' },
1294
- body: JSON.stringify({ snapshot, deckVersion: state.deckVersion }),
1314
+ body: JSON.stringify({ snapshot, deckVersion: state.deckVersion, language: state.inspectLanguage }),
1295
1315
  });
1296
1316
  const body = await res.json().catch(() => ({}));
1297
1317
  if (!res.ok || !body.ok) throw new Error(body.error || 'Inspection failed');
1298
1318
  state.deckVersion = body.deckVersion || state.deckVersion;
1299
1319
  state.activeInspectRequestId = body.requestId;
1300
- if (body.preprocess) renderInspectResult(body.preprocess, 'Preprocessed');
1301
- els.inspectCards.insertAdjacentHTML('beforeend', '<div class="inspect-loading"><b>Generating lazy inspection...</b><br>Waiting for structured result from OpenCode.</div>');
1320
+ state.inspectFallback = body.preprocess || null;
1321
+ els.inspectCards.innerHTML = '<div class="inspect-loading"><b>Reading selection...</b><br>Waiting for localized structured reading cards.</div>';
1302
1322
  await pollInspectResult(body.requestId);
1303
1323
  } catch (error) {
1304
- resetInspectCards(error && error.message ? error.message : String(error));
1324
+ if (state.inspectFallback) {
1325
+ renderInspectResult(state.inspectFallback, 'Deterministic fallback');
1326
+ els.inspectCards.insertAdjacentHTML('afterbegin', '<div class="inspect-warning">Generated inspection failed or timed out. Showing deterministic fallback context only.</div>');
1327
+ } else {
1328
+ resetInspectCards(error && error.message ? error.message : String(error));
1329
+ }
1305
1330
  } finally {
1306
1331
  state.inspecting = false;
1307
1332
  updateSendState();
@@ -1309,7 +1334,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1309
1334
  }
1310
1335
 
1311
1336
  async function pollInspectResult(requestId) {
1312
- for (;;) {
1337
+ for (let attempt = 0; attempt < 80; attempt++) {
1313
1338
  await delay(900);
1314
1339
  const res = await fetch('/api/inspect-result?token=' + encodeURIComponent(token) + '&requestId=' + encodeURIComponent(requestId));
1315
1340
  const body = await res.json().catch(() => ({}));
@@ -1321,6 +1346,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1321
1346
  }
1322
1347
  if (body.status === 'failed' || body.status === 'expired') throw new Error(body.error || 'Inspection failed');
1323
1348
  }
1349
+ throw new Error('Inspection timed out while waiting for OpenCode result');
1324
1350
  }
1325
1351
 
1326
1352
  function collectReferenceSnapshot() {
@@ -1351,6 +1377,8 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1351
1377
  else els.inspectStale.innerHTML = '';
1352
1378
  els.inspectCards.innerHTML = [
1353
1379
  '<div class="status">' + escapeHtml(phase || 'Inspection') + '</div>',
1380
+ result.cards.reading ? renderInspectCard('Narrative Reading', result.cards.reading.status, result.cards.reading.rationale, renderReading(result.cards.reading)) : '',
1381
+ result.cards.exploratory ? renderInspectCard('Exploratory Reading', result.cards.exploratory.status, result.cards.exploratory.rationale, renderExploratory(result.cards.exploratory)) : '',
1354
1382
  renderInspectCard('Purpose', result.cards.purpose.status, result.cards.purpose.rationale, renderPurpose(result.cards.purpose)),
1355
1383
  renderInspectCard('Source', result.cards.source.status, result.cards.source.rationale, renderSource(result.cards.source)),
1356
1384
  ].join('');
@@ -1364,6 +1392,49 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1364
1392
  return '<div class="inspect-item">' + field('Role', card.role) + field('Why it matters', card.whyItMatters) + '</div>';
1365
1393
  }
1366
1394
 
1395
+ function renderReading(card) {
1396
+ return '<div class="inspect-item">'
1397
+ + field('Claim ID', card.claimId)
1398
+ + field('Canonical claim ID', card.canonicalClaimId)
1399
+ + field('Claim', card.claimText)
1400
+ + field('Evidence status', card.evidenceStatus)
1401
+ + field('Evidence bindings', card.evidenceBindingIds && card.evidenceBindingIds.length ? card.evidenceBindingIds.join(', ') : '')
1402
+ + field('Supported scope', card.supportedScope)
1403
+ + field('Unsupported scope', card.unsupportedScope)
1404
+ + '</div>'
1405
+ + renderSectionList('Caveats', card.caveats)
1406
+ + renderSectionList('Objections', card.relatedObjections)
1407
+ + renderSectionList('Risks', card.relatedRisks)
1408
+ + renderArtifactCoverage(card.artifactCoverage);
1409
+ }
1410
+
1411
+ function renderArtifactCoverage(items) {
1412
+ if (!items || !items.length) return '';
1413
+ return '<div class="label">Artifact Coverage</div>' + items.map((item) => {
1414
+ const title = (item.type || 'artifact') + (item.outputPath ? ' · ' + item.outputPath : '');
1415
+ const status = (item.coverageStatus || 'unknown') + (item.containsClaim ? ' · contains claim' : ' · claim not rendered');
1416
+ return '<div class="inspect-item"><b>' + escapeHtml(title) + '</b>'
1417
+ + field('Coverage', status)
1418
+ + field('Stale', item.stale ? (item.staleReason || 'stale') : '')
1419
+ + field('Note', item.note)
1420
+ + renderSectionList('Locations', item.locations)
1421
+ + '</div>';
1422
+ }).join('');
1423
+ }
1424
+
1425
+ function renderExploratory(card) {
1426
+ return '<div class="inspect-item"><b>Non-official reading aid</b>'
1427
+ + field('Official artifact content', card.official === false ? 'No' : '')
1428
+ + field('Audience', card.audience)
1429
+ + field('Claim focus', card.claimFocus)
1430
+ + field('Audience reframe boundary', card.audienceReframe)
1431
+ + '</div>'
1432
+ + renderSectionList('Objection Prep', card.objectionPrompts)
1433
+ + renderSectionList('Appendix Leads', card.appendixLeads)
1434
+ + renderSectionList('Meeting Prep', card.meetingPrep)
1435
+ + renderSectionList('Boundaries', card.boundaries);
1436
+ }
1437
+
1367
1438
  function renderSource(card) {
1368
1439
  return renderSources(card.sources) + renderWarnings(card.warnings) + renderSectionList('Gaps', card.gaps) + renderSectionList('Caveats', card.caveats);
1369
1440
  }
@@ -1422,7 +1493,7 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1422
1493
  state.references = [];
1423
1494
  if (removeChips) els.comment.querySelectorAll('.ref-chip').forEach((chip) => chip.remove());
1424
1495
  renderSelectionSummary();
1425
- resetInspectCards('Select one or more deck elements, then inspect them for Source and Purpose. This does not edit the deck.');
1496
+ resetInspectCards('Select one or more deck elements, then inspect them for Narrative Reading, Exploratory Reading, Source, and Purpose. This does not edit the deck.');
1426
1497
  }
1427
1498
 
1428
1499
  function getCommentText() {
@@ -1525,10 +1596,17 @@ export function renderRefineShell(token: string, defaultMode: RefineMode = "edit
1525
1596
  }
1526
1597
 
1527
1598
  function findSlide(node) {
1528
- return node.closest('.slide, [slide-qa], .slide-canvas, .page');
1599
+ if (!node || !node.closest) return null;
1600
+ return node.closest('.slide[data-slide-index]')
1601
+ || node.closest('.slide')
1602
+ || node.closest('[slide-qa]')
1603
+ || node.closest('.slide-canvas')
1604
+ || node.closest('.page');
1529
1605
  }
1530
1606
 
1531
1607
  function getSlides(doc) {
1608
+ const canonicalSlides = Array.from(doc.querySelectorAll('.slide[data-slide-index]'));
1609
+ if (canonicalSlides.length) return canonicalSlides;
1532
1610
  const slides = Array.from(doc.querySelectorAll('.slide'));
1533
1611
  if (slides.length) return slides;
1534
1612
  const qaSlides = Array.from(doc.querySelectorAll('[slide-qa]'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyber-dash-tech/revela",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
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
@@ -423,7 +423,7 @@ const server: Plugin = (async (pluginCtx) => {
423
423
  }
424
424
  if (sub === "edit") {
425
425
  if (param) {
426
- await send("`/revela edit` no longer accepts a target. It opens the only HTML deck in `decks/`.")
426
+ await send("`/revela edit` is deprecated and does not accept a target. Use `/revela refine` for the unified refinement workspace.")
427
427
  throw new Error("__REVELA_EDIT_USAGE_HANDLED__")
428
428
  }
429
429
  await handleEdit({ client, sessionID, workspaceRoot }, send)
@@ -431,7 +431,7 @@ const server: Plugin = (async (pluginCtx) => {
431
431
  }
432
432
  if (sub === "inspect") {
433
433
  if (param) {
434
- await send("`/revela inspect` does not accept a target. It opens the only HTML deck in `decks/`.")
434
+ await send("`/revela inspect` is deprecated and does not accept a target. Use `/revela refine` for the unified reading and refinement workspace.")
435
435
  throw new Error("__REVELA_INSPECT_USAGE_HANDLED__")
436
436
  }
437
437
  await handleInspect({ client, sessionID, workspaceRoot }, send)
package/tools/edit.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  /**
2
2
  * tools/edit.ts
3
3
  *
4
- * revela-edit — Open Revela's visual comment editor for an existing deck.
4
+ * revela-edit — Compatibility tool that opens Revela Refine in Edit mode.
5
5
  */
6
6
 
7
7
  import { tool } from "@opencode-ai/plugin"
8
- import { openEditableDeck } from "../lib/edit/open"
8
+ import { openRefineDeck } from "../lib/refine/open"
9
9
 
10
10
  export function createEditTool(options: { client: any; workspaceRoot: string; openBrowser?: boolean }) {
11
11
  return tool({
12
12
  description:
13
- "Open Revela's visual comment editor for an existing slide deck. " +
13
+ "Open Revela Refine in Edit mode for an existing slide deck. " +
14
14
  "Use this when the user asks to edit, revise, annotate, or visually comment on a deck, " +
15
15
  "including when they reference the current deck. " +
16
- "Revela 0.8 opens the only HTML deck in decks/. " +
17
- "This opens a local browser editor where the user can Ctrl/Cmd-click deck elements, write comments, " +
16
+ "This is a compatibility tool for the older edit-only workflow; the user-facing entry is /revela refine. " +
17
+ "It opens a local browser workspace where the user can Ctrl/Cmd-click deck elements, use the Edit tab, " +
18
18
  "and send precise edit requests back to the current OpenCode session.",
19
19
  args: {},
20
20
  async execute(_args, context: any) {
@@ -27,10 +27,11 @@ export function createEditTool(options: { client: any; workspaceRoot: string; op
27
27
  }
28
28
 
29
29
  try {
30
- const result = openEditableDeck("", {
30
+ const result = openRefineDeck("", {
31
31
  client: options.client,
32
32
  sessionID,
33
33
  workspaceRoot: options.workspaceRoot,
34
+ mode: "edit",
34
35
  openBrowser: options.openBrowser,
35
36
  })
36
37
 
@@ -40,9 +41,10 @@ export function createEditTool(options: { client: any; workspaceRoot: string; op
40
41
  file: result.deck.file,
41
42
  source: result.source,
42
43
  url: result.url,
44
+ mode: result.mode,
43
45
  message:
44
- `${result.stateNote} Opened visual editor. ` +
45
- "Ask the user to use Ctrl/Cmd + click in the browser to reference elements, write a comment, then send comments.",
46
+ `${result.stateNote} Opened Revela Refine in Edit mode. ` +
47
+ "Ask the user to use Ctrl/Cmd-click in the browser to reference elements, then use the Edit tab to send comments.",
46
48
  }, null, 2)
47
49
  } catch (error) {
48
50
  return JSON.stringify({
@@ -29,6 +29,43 @@ export default tool({
29
29
  }).optional(),
30
30
  matchConfidence: tool.schema.enum(["none", "low", "medium", "high"]),
31
31
  cards: tool.schema.object({
32
+ reading: tool.schema.object({
33
+ status: tool.schema.enum(["matched", "no_match"]),
34
+ claimId: tool.schema.string().optional(),
35
+ canonicalClaimId: tool.schema.string().optional(),
36
+ claimText: tool.schema.string().optional(),
37
+ evidenceStatus: tool.schema.string().optional(),
38
+ evidenceBindingIds: tool.schema.array(tool.schema.string()),
39
+ supportedScope: tool.schema.string().optional(),
40
+ unsupportedScope: tool.schema.string().optional(),
41
+ caveats: tool.schema.array(tool.schema.string()),
42
+ relatedObjections: tool.schema.array(tool.schema.string()),
43
+ relatedRisks: tool.schema.array(tool.schema.string()),
44
+ artifactCoverage: tool.schema.array(tool.schema.object({
45
+ artifactId: tool.schema.string(),
46
+ type: tool.schema.string(),
47
+ outputPath: tool.schema.string().optional(),
48
+ coverageStatus: tool.schema.enum(["current", "stale", "partial", "missing"]),
49
+ containsClaim: tool.schema.boolean(),
50
+ stale: tool.schema.boolean(),
51
+ staleReason: tool.schema.string().optional(),
52
+ locations: tool.schema.array(tool.schema.string()),
53
+ note: tool.schema.string().optional(),
54
+ })).optional(),
55
+ rationale: tool.schema.string(),
56
+ }).optional(),
57
+ exploratory: tool.schema.object({
58
+ status: tool.schema.enum(["available", "limited", "unavailable"]),
59
+ official: tool.schema.boolean().describe("Must be false; exploratory reading is not official artifact content."),
60
+ audience: tool.schema.string().optional(),
61
+ claimFocus: tool.schema.string().optional(),
62
+ objectionPrompts: tool.schema.array(tool.schema.string()),
63
+ audienceReframe: tool.schema.string(),
64
+ appendixLeads: tool.schema.array(tool.schema.string()),
65
+ meetingPrep: tool.schema.array(tool.schema.string()),
66
+ boundaries: tool.schema.array(tool.schema.string()),
67
+ rationale: tool.schema.string(),
68
+ }).optional(),
32
69
  purpose: tool.schema.object({
33
70
  status: tool.schema.enum(["clear", "weak", "misplaced", "unknown"]),
34
71
  role: tool.schema.string().optional(),