pantheon-opencode 1.6.3-beta.2 → 1.6.3-beta.21

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.
Files changed (69) hide show
  1. package/AGENTS.global.md +1 -1
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +143 -0
  4. package/README.md +21 -3
  5. package/README.pt-BR.md +1 -1
  6. package/bin/pantheon-init.mjs +46 -28
  7. package/package.json +1 -1
  8. package/plugin.json +2 -2
  9. package/pyproject.toml +1 -1
  10. package/scripts/decision-router-budget.mjs +103 -3
  11. package/scripts/decision-router-v2-budget.mjs +2 -2
  12. package/scripts/decision-router.mjs +88 -6
  13. package/scripts/install/cli-ui.mjs +2 -1
  14. package/scripts/install/decision-router-config.mjs +53 -0
  15. package/scripts/install/interactive.mjs +103 -9
  16. package/scripts/install/opencode.mjs +101 -30
  17. package/scripts/install/plugin.mjs +17 -0
  18. package/scripts/jev-live-probe.mjs +212 -0
  19. package/scripts/skill-search.mjs +273 -0
  20. package/scripts/sync-tui.mjs +11 -0
  21. package/skills-lock.json +1 -0
  22. package/src/agents/aphrodite.md +34 -1
  23. package/src/agents/apollo.md +227 -0
  24. package/src/agents/athena.md +26 -0
  25. package/src/agents/demeter.md +33 -0
  26. package/src/agents/gaia.md +24 -0
  27. package/src/agents/hephaestus.md +24 -0
  28. package/src/agents/hermes.md +33 -0
  29. package/src/agents/iris.md +24 -0
  30. package/src/agents/mnemosyne.md +25 -3
  31. package/src/agents/nyx.md +50 -22
  32. package/src/agents/prometheus.md +242 -1
  33. package/src/agents/talos.md +24 -0
  34. package/src/agents/themis.md +24 -0
  35. package/src/agents/zeus.md +67 -6
  36. package/src/pantheon/j-telemetry-file.ts +96 -0
  37. package/src/pantheon/j1-approvals.ts +123 -0
  38. package/src/pantheon/jev-decision-tool.ts +268 -34
  39. package/src/pantheon/jev-decisions.ts +92 -8
  40. package/src/pantheon/jev-escalation.ts +1 -1
  41. package/src/pantheon/jev-quality-score.ts +7 -2
  42. package/src/pantheon/jev-rank-verify.ts +661 -0
  43. package/src/pantheon/jev-risk-gate.ts +75 -8
  44. package/src/pantheon/local-decision-budget.ts +170 -3
  45. package/src/pantheon/local-decision-router.ts +16 -0
  46. package/src/pantheon/local-decision-turn.ts +39 -4
  47. package/src/pantheon/local-decision-usage-evidence.internal.ts +2 -2
  48. package/src/pantheon/pantheon-decision-catalog.ts +9 -2
  49. package/src/pantheon/v2-decision-budget.ts +4 -2
  50. package/src/plugin-v2.ts +94 -7
  51. package/src/plugins/tui/dist/server-v2.d.ts +14 -6
  52. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  53. package/src/plugins/tui/dist/server-v2.js +16 -9
  54. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  55. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  56. package/src/plugins/tui/dist/tui-v2.js +560 -4
  57. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  58. package/src/plugins/tui/dist/tui.js +1 -1
  59. package/src/plugins/tui/package-lock.json +2 -2
  60. package/src/plugins/tui/package.json +1 -1
  61. package/src/plugins/tui/src/index-v2.tsx +6 -0
  62. package/src/plugins/tui/src/server-v2.ts +14 -7
  63. package/src/plugins/tui/src/whats-new-highlights.ts +317 -0
  64. package/src/plugins/tui/src/whats-new-open.ts +120 -0
  65. package/src/plugins/tui/src/whats-new-state.ts +128 -0
  66. package/src/plugins/tui/src/whats-new.tsx +172 -0
  67. package/src/routing.yml +1 -0
  68. package/src/skills/README.md +1 -1
  69. package/src/skills/prompt-refinery/SKILL.md +41 -0
@@ -1,7 +1,8 @@
1
1
  import { createComponent, createElement, createTextNode, effect, insert, insertNode, memo, setProp } from "@opentui/solid";
2
- import { readFile } from "node:fs/promises";
2
+ import { mkdir, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
- import { join } from "node:path";
4
+ import { dirname, join } from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
  import { For, Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from "solid-js";
6
7
  import { execFile } from "node:child_process";
7
8
  import { Plugin } from "@opencode/plugin/tui";
@@ -179,6 +180,560 @@ function cellWidth(value) {
179
180
  for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment);
180
181
  return width;
181
182
  }
183
+ /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
184
+ const WHATS_NEW_MORE_PREFIX = "… +";
185
+ const EMPTY_HIGHLIGHTS = {
186
+ version: null,
187
+ found: false,
188
+ groups: [],
189
+ totalItems: 0,
190
+ truncated: false
191
+ };
192
+ /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
193
+ function escapeRegExp(text) {
194
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
195
+ }
196
+ /**
197
+ * Extract the body of a version section from changelog text — inline replica
198
+ * of scripts/changelog-extract.mjs `extractSection` (see that file for the
199
+ * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
200
+ * optional, `## [Unreleased]` never matched).
201
+ */
202
+ function extractSection(changelogText, version) {
203
+ const normalized = String(version).trim().replace(/^v/i, "");
204
+ if (!normalized || /^unreleased$/i.test(normalized)) return {
205
+ found: false,
206
+ body: null
207
+ };
208
+ const escaped = escapeRegExp(normalized);
209
+ const match = new RegExp(`^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`, "m").exec(changelogText);
210
+ if (!match) return {
211
+ found: false,
212
+ body: null
213
+ };
214
+ const newline = changelogText.indexOf("\n", match.index);
215
+ const start = newline === -1 ? changelogText.length : newline + 1;
216
+ const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start));
217
+ const end = nextHeading ? start + nextHeading.index : changelogText.length;
218
+ return {
219
+ found: true,
220
+ body: changelogText.slice(start, end).trim()
221
+ };
222
+ }
223
+ /**
224
+ * Reduce one markdown line to plain text: links keep their label, emphasis
225
+ * and inline-code markers are dropped, HTML comment fragments are removed,
226
+ * and whitespace collapses. Deliberately simple — the input is our own
227
+ * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
228
+ */
229
+ function stripMarkdown(text) {
230
+ return text.replace(/<!--[\s\S]*?-->/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/(\*\*|__)/g, "").replace(/`/g, "").replace(/\s+/g, " ").trim();
231
+ }
232
+ /** Strip the leading H3 marker (`### Added` → `Added`). */
233
+ function stripHeading(text) {
234
+ return text.replace(/^#{1,6}[ \t]+/, "").trim();
235
+ }
236
+ /**
237
+ * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
238
+ * from a section body: its bullets only, each truncated to
239
+ * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
240
+ * the section carries no summary block (the full-section fallback applies).
241
+ */
242
+ function extractWhatsNewSummary(body) {
243
+ const lines = body.split("\n");
244
+ const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()));
245
+ if (start === -1) return null;
246
+ const items = [];
247
+ for (const rawLine of lines.slice(start + 1)) {
248
+ const line = rawLine.trim();
249
+ if (line === "" || line.startsWith("<!--")) continue;
250
+ if (/^#{1,6}[ \t]/.test(line)) break;
251
+ if (!/^[-*][ \t]/.test(line)) continue;
252
+ if (items.length >= 6) break;
253
+ const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ""));
254
+ if (content === "") continue;
255
+ items.push(content.length > 140 ? `${content.slice(0, 139)}…` : content);
256
+ }
257
+ return items.length > 0 ? items : null;
258
+ }
259
+ /**
260
+ * Extract the release highlights for `version`. When the section carries a
261
+ * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
262
+ * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
263
+ * dialog); otherwise it falls back to the H3-group extraction bounded to
264
+ * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
265
+ * blank changelog all return EMPTY_HIGHLIGHTS (no window).
266
+ */
267
+ function extractHighlights(changelogText, version) {
268
+ const { found, body } = extractSection(changelogText ?? "", version ?? "");
269
+ if (!found || !body) return { ...EMPTY_HIGHLIGHTS };
270
+ const summary = extractWhatsNewSummary(body);
271
+ if (summary !== null) return {
272
+ version: String(version).trim().replace(/^v/i, ""),
273
+ found: true,
274
+ groups: [{
275
+ heading: null,
276
+ items: summary
277
+ }],
278
+ totalItems: summary.length,
279
+ truncated: false
280
+ };
281
+ const groups = [];
282
+ let totalItems = 0;
283
+ let truncated = false;
284
+ for (const rawLine of body.split("\n")) {
285
+ const line = rawLine.trim();
286
+ if (line === "" || line.startsWith("<!--")) continue;
287
+ if (/^#{1,6}[ \t]/.test(line)) {
288
+ const heading = stripMarkdown(stripHeading(line));
289
+ if (heading === "") continue;
290
+ if (groups.at(-1)?.items.length === 0) groups.pop();
291
+ groups.push({
292
+ heading,
293
+ items: []
294
+ });
295
+ continue;
296
+ }
297
+ if (totalItems >= 12) {
298
+ if (/^[-*][ \t]/.test(line)) totalItems += 1;
299
+ continue;
300
+ }
301
+ const isBullet = /^[-*][ \t]/.test(line);
302
+ const continuation = (groups.at(-1)?.items.length ?? 0) > 0;
303
+ if (!isBullet && !continuation) continue;
304
+ const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, "") : line);
305
+ if (content === "") continue;
306
+ const bounded = content.length > 140 ? `${content.slice(0, 139)}…` : content;
307
+ const group = groups.at(-1);
308
+ if (group === void 0) groups.push({
309
+ heading: null,
310
+ items: [bounded]
311
+ });
312
+ else if (isBullet || group.items.length === 0) group.items.push(bounded);
313
+ else group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim();
314
+ if (isBullet) totalItems += 1;
315
+ }
316
+ const kept = groups.filter((group) => group.items.length > 0);
317
+ truncated = totalItems > 12;
318
+ return {
319
+ version: found ? String(version).trim().replace(/^v/i, "") : null,
320
+ found,
321
+ groups: kept,
322
+ totalItems,
323
+ truncated
324
+ };
325
+ }
326
+ /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
327
+ function whatsNewTitle(version) {
328
+ return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, "")}`;
329
+ }
330
+ /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
331
+ function whatsNewLines(highlights) {
332
+ const lines = [];
333
+ for (const group of highlights.groups) {
334
+ if (group.heading !== null) lines.push(group.heading);
335
+ for (const item of group.items) lines.push(`• ${item}`);
336
+ }
337
+ if (highlights.truncated) {
338
+ const hidden = Math.max(0, highlights.totalItems - 12);
339
+ if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`);
340
+ }
341
+ return lines;
342
+ }
343
+ /**
344
+ * Candidate CHANGELOG.md locations for a bundle, first readable wins:
345
+ * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
346
+ * shipped by both installers next to package.json);
347
+ * 2. the package root (dev checkout; also an npm-package install when the
348
+ * bundle runs from `<pkg>/src/plugins/tui/dist/`).
349
+ */
350
+ function changelogCandidates(bundlePath) {
351
+ const dist = dirname(bundlePath);
352
+ const copyRoot = dirname(dist);
353
+ const packageRoot = dirname(dirname(dirname(copyRoot)));
354
+ return [join(copyRoot, "CHANGELOG.md"), join(packageRoot, "CHANGELOG.md")];
355
+ }
356
+ /** Read the first existing candidate; null when none is readable (no window). */
357
+ async function readChangelogForBundle(bundleUrl) {
358
+ try {
359
+ const bundlePath = fileURLToPath(bundleUrl);
360
+ for (const candidate of changelogCandidates(bundlePath)) try {
361
+ return await readFile(candidate, "utf8");
362
+ } catch {}
363
+ return null;
364
+ } catch {
365
+ return null;
366
+ }
367
+ }
368
+ /** The ambient build-time version, or null outside a tsdown build. */
369
+ function embeddedVersion() {
370
+ return "1.6.3-beta.15";
371
+ }
372
+ /**
373
+ * Resolve the running Pantheon version for the what's-new window: the plugin
374
+ * copy's own package.json first (the copy root two levels above the bundle,
375
+ * then the package root four levels above — the same legs as the V1 sidebar's
376
+ * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
377
+ * nothing resolves → no window (fail-open).
378
+ */
379
+ async function resolveRunningVersion(bundleUrl, embedded = embeddedVersion()) {
380
+ try {
381
+ const bundlePath = fileURLToPath(bundleUrl);
382
+ const dist = dirname(bundlePath);
383
+ for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) try {
384
+ const raw = await readFile(join(root, "package.json"), "utf8");
385
+ const parsed = JSON.parse(raw);
386
+ if (typeof parsed.version === "string" && parsed.version.trim() !== "") return parsed.version;
387
+ } catch {}
388
+ } catch {}
389
+ return embedded;
390
+ }
391
+ //#endregion
392
+ //#region src/whats-new-state.ts
393
+ /**
394
+ * whats-new-state.ts — last-seen version for the one-time "What's new" window.
395
+ *
396
+ * The TUI shows a dismissable release-highlights dialog once per Pantheon
397
+ * version. Whether a version was already seen is persisted next to the other
398
+ * opencode-level Pantheon state: `<configDir>/.pantheon/whats-new.json`, the
399
+ * same directory that already holds `install-state.json` (scripts/install/
400
+ * state.mjs) and the active-preset file the sidebar reads. There is no
401
+ * established persistent TUI KV store (the host `api.kv` is per-process), so
402
+ * the plugin owns one small JSON file with the atomic-write discipline used
403
+ * across the repo (unique tmp + rename, mirrors scripts/install/verify.mjs).
404
+ *
405
+ * Fail-open everywhere: a missing or corrupt file reads as "never seen" (the
406
+ * window may show), a failed write is silent (the window may show again) —
407
+ * neither can ever block TUI startup.
408
+ */
409
+ /** State file name, kept next to `install-state.json` in `<configDir>/.pantheon/`. */
410
+ const WHATS_NEW_STATE_FILENAME = "whats-new.json";
411
+ /** Parse a state file body; null when unreadable as the expected shape. */
412
+ function parseWhatsNewState(raw) {
413
+ try {
414
+ const parsed = JSON.parse(raw);
415
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
416
+ const record = parsed;
417
+ const seen = record.seenVersion;
418
+ if (typeof seen !== "string" && seen !== null) return null;
419
+ return {
420
+ seenVersion: seen,
421
+ updatedAt: String(record.updatedAt ?? "")
422
+ };
423
+ } catch {
424
+ return null;
425
+ }
426
+ }
427
+ /** Read the persisted state; null when missing or corrupt (never throws). */
428
+ async function readWhatsNewState(statePath) {
429
+ try {
430
+ return parseWhatsNewState(await readFile(statePath, "utf8"));
431
+ } catch {
432
+ return null;
433
+ }
434
+ }
435
+ /**
436
+ * Whether the one-time window should show for `version`: any version change
437
+ * since the last dismissal (including downgrades). A falsy version — the
438
+ * resolver failed — never shows.
439
+ */
440
+ async function shouldShowWhatsNew(version, statePath) {
441
+ if (typeof version !== "string" || version.trim() === "") return false;
442
+ return (await readWhatsNewState(statePath))?.seenVersion !== version;
443
+ }
444
+ /**
445
+ * Persist `version` as seen (atomic tmp + rename, 0o600). Never throws: a
446
+ * failed write leaves the state untouched and the window may show again —
447
+ * the same fail-open contract as the rest of the plugin.
448
+ */
449
+ async function markSeenWhatsNew(version, statePath) {
450
+ if (typeof version !== "string" || version.trim() === "") return false;
451
+ const previous = await readWhatsNewState(statePath);
452
+ const next = {
453
+ seenVersion: version,
454
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
455
+ };
456
+ const tmpPath = `${statePath}.tmp-${process.pid}`;
457
+ try {
458
+ await mkdir(dirname(statePath), { recursive: true });
459
+ await writeFile(tmpPath, `${JSON.stringify({
460
+ ...previous,
461
+ ...next
462
+ }, null, 2)}\n`, {
463
+ encoding: "utf8",
464
+ mode: 384
465
+ });
466
+ await rename(tmpPath, statePath);
467
+ return true;
468
+ } catch {
469
+ try {
470
+ await unlink(tmpPath);
471
+ } catch {}
472
+ return false;
473
+ }
474
+ }
475
+ /** `stat`-based existence probe (async I/O discipline). */
476
+ async function pathExists(path) {
477
+ try {
478
+ await stat(path);
479
+ return true;
480
+ } catch {
481
+ return false;
482
+ }
483
+ }
484
+ /**
485
+ * Default state path: `<configDir>/.pantheon/whats-new.json`, resolving the
486
+ * OpenCode config directory exactly like src/pantheon/tui-version-check.ts
487
+ * (`$XDG_CONFIG_HOME/opencode` → `~/.opencode`), defaulting to the XDG
488
+ * location `init` creates when neither exists yet.
489
+ */
490
+ async function defaultWhatsNewStatePath(env = process.env, home = homedir()) {
491
+ const xdgConfig = env.XDG_CONFIG_HOME || join(home, ".config");
492
+ const primary = join(xdgConfig, "opencode");
493
+ if (await pathExists(primary)) return join(primary, ".pantheon", WHATS_NEW_STATE_FILENAME);
494
+ const legacy = join(home, ".opencode");
495
+ if (await pathExists(legacy)) return join(legacy, ".pantheon", WHATS_NEW_STATE_FILENAME);
496
+ return join(primary, ".pantheon", WHATS_NEW_STATE_FILENAME);
497
+ }
498
+ //#endregion
499
+ //#region src/whats-new-open.ts
500
+ /**
501
+ * whats-new-open.ts — the show-once decision for the "What's new" window.
502
+ *
503
+ * Plain data in, plain data out: the entrypoints (index.tsx / index-v2.tsx)
504
+ * resolve the running version and the shipped CHANGELOG.md, then hand this
505
+ * module a `show` callback that renders the view data through the host's
506
+ * dialog API. Keeping the decision JSX-free makes the whole one-time flow
507
+ * testable offline (node strips the types natively) — the Solid glue lives in
508
+ * whats-new.tsx.
509
+ *
510
+ * Contract (pinned by tests/tui-whats-new.test.mjs):
511
+ * - shows at most once per version: dismissal marks the version seen;
512
+ * - nothing to show (no version, missing CHANGELOG, empty section) → no
513
+ * window AND no pin — the next start may still show it;
514
+ * - never throws on its own inputs; I/O failures inside the state module
515
+ * are fail-open there.
516
+ */
517
+ /** Muted footer hint teaching the dismiss bind (Portuguese, like the sidebar). */
518
+ const WHATS_NEW_CLOSE_HINT = "esc/q fechar";
519
+ /** Hint variant when the highlights span more than one page. */
520
+ const WHATS_NEW_PAGES_HINT = "esc/q fechar · n próxima · p volta";
521
+ /** Hard-wrap one display line into rows of at most `width` columns (>= 10). */
522
+ function wrapWhatsNewLine(line, width) {
523
+ const bounded = Number.isInteger(width) && width > 10 ? width : 76;
524
+ const text = String(line);
525
+ if (text.length <= bounded) return [text];
526
+ const rows = [];
527
+ let rest = text;
528
+ while (rest.length > bounded) {
529
+ rows.push(rest.slice(0, bounded));
530
+ rest = rest.slice(bounded);
531
+ }
532
+ if (rest.length > 0) rows.push(rest);
533
+ return rows;
534
+ }
535
+ /** Slice display lines into fixed-size pages (>= 1 page, empty-safe). */
536
+ function paginateWhatsNewLines(lines, pageSize = 14) {
537
+ const size = Number.isInteger(pageSize) && pageSize > 0 ? pageSize : 14;
538
+ if (lines.length === 0) return [[]];
539
+ const pages = [];
540
+ for (let i = 0; i < lines.length; i += size) pages.push(lines.slice(i, i + size));
541
+ return pages;
542
+ }
543
+ /**
544
+ * Open the one-time window when the version changed and highlights exist.
545
+ * Returns true when the window was shown; the caller's `onClose` callback
546
+ * (both host-initiated and local close binds) must funnel into marking seen.
547
+ */
548
+ async function openWhatsNew(input) {
549
+ const { version, statePath, changelogText, show } = input;
550
+ if (typeof version !== "string" || version.trim() === "") return false;
551
+ if (!await shouldShowWhatsNew(version, statePath)) return false;
552
+ const lines = whatsNewLines(changelogText ? extractHighlights(changelogText, version) : { ...EMPTY_HIGHLIGHTS });
553
+ if (lines.length === 0) return false;
554
+ const pages = paginateWhatsNewLines(lines);
555
+ const data = {
556
+ version,
557
+ title: whatsNewTitle(version),
558
+ lines,
559
+ pages,
560
+ hint: pages.length > 1 ? WHATS_NEW_PAGES_HINT : WHATS_NEW_CLOSE_HINT
561
+ };
562
+ show(() => data, () => {
563
+ markSeenWhatsNew(version, statePath);
564
+ });
565
+ return true;
566
+ }
567
+ //#endregion
568
+ //#region src/whats-new.tsx
569
+ /** @jsxImportSource @opentui/solid */
570
+ /**
571
+ * whats-new.tsx — the one-time "What's new" window (per Pantheon version).
572
+ *
573
+ * When the running Pantheon version changed since the last TUI start, the V2
574
+ * entrypoint fires {@link maybeShowWhatsNewV2} (fire-and-forget, never
575
+ * awaited — startup must never block). The decision lives in
576
+ * whats-new-open.ts; this file is only the host glue + view:
577
+ * `context.ui.dialog.show` plus a keymap layer gated on the open signal so
578
+ * `escape`/`q` dismiss and `n`/`p` flip pages while (and only while) the
579
+ * window is up — the same gated-layer pattern as the dispatch panel.
580
+ *
581
+ * The window shows the curated 🆕 What's New summary (whats-new-highlights
582
+ * prefers it), hard-wrapped to the window width and sliced into fixed-size
583
+ * pages — a big changelog can never overflow the terminal; the footer points
584
+ * at the complete CHANGELOG.md.
585
+ *
586
+ * Deliberately V2-only: the two dist entries are self-contained (the V1
587
+ * sidebar mirrors the preset resolver rather than importing it) because any
588
+ * module shared by both entries becomes a content-hashed chunk in dist/,
589
+ * changing the artifact shape the byte-reproducible-dist gate pins. The V1
590
+ * generation (OpenCode 1.x, legacy) does not show the window; the pure
591
+ * modules here are generation-agnostic, so a V1 mirror can follow the
592
+ * documented inline-replica precedent if it is ever wanted.
593
+ *
594
+ * Dismissal always funnels into `markSeenWhatsNew` (idempotent), so the window
595
+ * is shown exactly once per version. Every failure path is silent: missing
596
+ * CHANGELOG.md, unreadable state, a host API that throws — the window simply
597
+ * does not show (fail-open, like the rest of the plugin).
598
+ */
599
+ /** Window body: title, rule, the current page (wrapped), footer hint. */
600
+ function WhatsNewContent(props) {
601
+ const rows = () => {
602
+ const current = props.data.pages[Math.min(props.page(), props.pageCount() - 1)] ?? [];
603
+ const wrapped = [];
604
+ for (const line of current) wrapped.push(...wrapWhatsNewLine(line, 76));
605
+ return wrapped;
606
+ };
607
+ return (() => {
608
+ var _el$ = createElement("box"), _el$2 = createElement("text"), _el$3 = createElement("text"), _el$5 = createElement("box"), _el$6 = createElement("text");
609
+ insertNode(_el$, _el$2);
610
+ insertNode(_el$, _el$3);
611
+ insertNode(_el$, _el$5);
612
+ insertNode(_el$, _el$6);
613
+ setProp(_el$, "flexDirection", "column");
614
+ setProp(_el$, "paddingLeft", 1);
615
+ setProp(_el$, "paddingRight", 1);
616
+ setProp(_el$, "paddingTop", 1);
617
+ setProp(_el$2, "attributes", 1);
618
+ insert(_el$2, () => props.data.title);
619
+ insertNode(_el$3, createTextNode(`──────────────────────────────────────`));
620
+ insert(_el$, createComponent(For, {
621
+ get each() {
622
+ return rows();
623
+ },
624
+ children: (line) => (() => {
625
+ var _el$7 = createElement("text");
626
+ insert(_el$7, line);
627
+ effect((_$p) => setProp(_el$7, "fg", line.startsWith("• ") ? props.fg : props.muted, _$p));
628
+ return _el$7;
629
+ })()
630
+ }), _el$5);
631
+ setProp(_el$5, "height", 1);
632
+ insert(_el$6, (() => {
633
+ var _c$ = memo(() => props.pageCount() > 1);
634
+ return () => _c$() ? `${props.page() + 1}/${props.pageCount()} · ` : "";
635
+ })(), null);
636
+ insert(_el$6, () => props.data.hint, null);
637
+ effect((_p$) => {
638
+ var _v$ = props.fg, _v$2 = props.muted, _v$3 = props.muted;
639
+ _v$ !== _p$.e && (_p$.e = setProp(_el$2, "fg", _v$, _p$.e));
640
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$3, "fg", _v$2, _p$.t));
641
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$6, "fg", _v$3, _p$.a));
642
+ return _p$;
643
+ }, {
644
+ e: void 0,
645
+ t: void 0,
646
+ a: void 0
647
+ });
648
+ return _el$;
649
+ })();
650
+ }
651
+ /**
652
+ * Entry glue: resolve version + shipped CHANGELOG.md, then show the window
653
+ * through the host dialog stack once. Never throws.
654
+ */
655
+ async function maybeShowWhatsNewV2(context) {
656
+ try {
657
+ const version = await resolveRunningVersion(import.meta.url);
658
+ if (!version) return;
659
+ const statePath = await defaultWhatsNewStatePath();
660
+ const changelogText = await readChangelogForBundle(import.meta.url);
661
+ const [open, setOpen] = createSignal(false);
662
+ const [page, setPage] = createSignal(0);
663
+ let viewData;
664
+ const pageCount = () => Math.max(1, Math.ceil(viewData?.pages.length ?? 1));
665
+ let dismiss = () => {};
666
+ try {
667
+ context.keymap.layer(() => ({
668
+ mode: "global",
669
+ enabled: () => open(),
670
+ commands: [
671
+ {
672
+ id: "pantheon.whats-new.close",
673
+ title: "Fechar o que há de novo",
674
+ bind: "escape,q",
675
+ run: () => {
676
+ if (!open()) return false;
677
+ dismiss();
678
+ }
679
+ },
680
+ {
681
+ id: "pantheon.whats-new.next",
682
+ title: "Próxima página",
683
+ bind: "n,right",
684
+ run: () => {
685
+ if (!open()) return false;
686
+ setPage((current) => Math.min(current + 1, pageCount() - 1));
687
+ }
688
+ },
689
+ {
690
+ id: "pantheon.whats-new.prev",
691
+ title: "Página anterior",
692
+ bind: "p,left",
693
+ run: () => {
694
+ if (!open()) return false;
695
+ setPage((current) => Math.max(current - 1, 0));
696
+ }
697
+ }
698
+ ]
699
+ }));
700
+ } catch {}
701
+ await openWhatsNew({
702
+ version,
703
+ statePath,
704
+ changelogText,
705
+ show: (render, onClose) => {
706
+ const close = () => {
707
+ setOpen(false);
708
+ onClose();
709
+ };
710
+ dismiss = () => {
711
+ try {
712
+ context.ui.dialog.clear();
713
+ } catch {}
714
+ close();
715
+ };
716
+ viewData = render();
717
+ setPage(0);
718
+ setOpen(true);
719
+ try {
720
+ const theme = context.theme?.text ?? {};
721
+ context.ui.dialog.show(() => createComponent(WhatsNewContent, {
722
+ data: viewData,
723
+ page,
724
+ pageCount,
725
+ get fg() {
726
+ return theme.base;
727
+ },
728
+ get muted() {
729
+ return theme.muted;
730
+ }
731
+ }), close);
732
+ } catch {}
733
+ }
734
+ });
735
+ } catch {}
736
+ }
182
737
  //#endregion
183
738
  //#region src/index-v2.tsx
184
739
  /** @jsxImportSource @opentui/solid */
@@ -3197,7 +3752,7 @@ function Sidebar(props) {
3197
3752
  setProp(_el$12, "width", "100%");
3198
3753
  setProp(_el$12, "padding", 1);
3199
3754
  setProp(_el$13, "attributes", 1);
3200
- insert(_el$13, `Pantheon v1.6.3-beta.2`);
3755
+ insert(_el$13, `Pantheon v1.6.3-beta.15`);
3201
3756
  insert(_el$14, () => presetHeaderLine(model.preset().name ?? "", model.provider()));
3202
3757
  insert(_el$12, createComponent(Show, {
3203
3758
  get when() {
@@ -3918,7 +4473,7 @@ function HomeStatus(props) {
3918
4473
  const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base;
3919
4474
  return (() => {
3920
4475
  var _el$72 = createElement("text");
3921
- insert(_el$72, () => `Pantheon v1.6.3-beta.2${preset().name ? ` ▸ ${preset().name}` : ""}`);
4476
+ insert(_el$72, () => `Pantheon v1.6.3-beta.15${preset().name ? ` ▸ ${preset().name}` : ""}`);
3922
4477
  effect((_$p) => setProp(_el$72, "fg", muted(), _$p));
3923
4478
  return _el$72;
3924
4479
  })();
@@ -4025,6 +4580,7 @@ const plugin = Plugin.define({
4025
4580
  append: "app",
4026
4581
  render: () => createComponent(DispatchCommandLayer, { context })
4027
4582
  });
4583
+ maybeShowWhatsNewV2(context);
4028
4584
  return () => {
4029
4585
  if (typeof unregisterSidebar === "function") unregisterSidebar();
4030
4586
  if (typeof unregisterHome === "function") unregisterHome();