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 +1 @@
1
- {"version":3,"file":"tui-v2.js","names":["numberOrNull"],"sources":["../src/context-gauge.ts","../src/model-usage-limits.ts","../src/sidebar-width.ts"],"sourcesContent":["/** Shared, data-only formatting and visual helpers for compact context gauges. */\n\nexport type ContextProgressTone = 'info' | 'success' | 'warning' | 'error'\n\nexport const CONTEXT_BAR_CELLS = 12\nexport const CONTEXT_BAR_FILLED_CELL = '\\u25B0'\nexport const CONTEXT_BAR_EMPTY_CELL = '\\u25B1'\n\nfunction numberOrNull(value: unknown): number | null {\n return typeof value === 'number' && Number.isFinite(value) ? value : null\n}\n\nexport function contextUsageTone(percent: number): ContextProgressTone {\n if (percent > 90) return 'error'\n if (percent > 50) return 'warning'\n if (percent > 25) return 'success'\n return 'info'\n}\n\nexport function formatTokenCount(tokens: number | null | undefined): string | null {\n const value = numberOrNull(tokens)\n if (value === null || value < 0) return null\n return Math.round(value).toLocaleString('en-US')\n}\n\nexport function formatContextWindow(limit: number | null | undefined): string | null {\n const value = numberOrNull(limit)\n if (value === null || value <= 0) return null\n if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`\n if (value >= 1_000) return `${Math.floor(value / 1_000)}K`\n return `${Math.floor(value)}`\n}\n\nexport function contextBarFilled(percent: number, cells = CONTEXT_BAR_CELLS): number {\n const total = Math.max(1, Math.floor(cells))\n const filled = Math.round((percent / 100) * total)\n if (!Number.isFinite(filled)) return 0\n return Math.min(total, Math.max(0, filled))\n}\n\nexport function contextBar(\n percent: number | null | undefined,\n cells = CONTEXT_BAR_CELLS,\n): { filled: string; empty: string } | null {\n const value = numberOrNull(percent)\n if (value === null) return null\n const total = Math.max(1, Math.floor(cells))\n const filled = contextBarFilled(value, total)\n return {\n filled: CONTEXT_BAR_FILLED_CELL.repeat(filled),\n empty: CONTEXT_BAR_EMPTY_CELL.repeat(total - filled),\n }\n}\n\nexport function formatSpent(cost: number | null | undefined): string | null {\n const value = numberOrNull(cost)\n if (value === null || value < 0) return null\n return `$${value.toFixed(2)}`\n}\n","/** Shared bounds for cached recent model-usage aggregation. */\nexport const MODEL_USAGE_VISIBLE_CEILING = 3\nexport const MODEL_USAGE_MESSAGE_LIMIT = 400\nexport const MODEL_USAGE_SESSION_LIMIT = 8\n","/** Conservative content budget; the host sidebar slot does not report its runtime width. */\nexport const SIDEBAR_CONTENT_WIDTH = 34\n\nexport const GRAPHEMES = new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n\n/** A grapheme the host draws two cells wide: emoji presentation, an extended\n * pictograph (a bare `❤` counts too, exactly as the host's `emoji-regex`\n * does) and a regional-indicator pair (a flag). */\nconst EMOJI_GLYPH = /\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{Regional_Indicator}/u\n/** VS16 asks for emoji presentation; without it `1` is one cell, with it the\n * keycap sequence is drawn as one two-cell glyph. */\nconst EMOJI_PRESENTATION_SELECTOR = '\\uFE0F'\n/** Unicode default-ignorable code points carry no width of their own. */\nconst IGNORABLE_GLYPH = /^\\p{Default_Ignorable_Code_Point}$/u\n/** East Asian Wide/Fullwidth ranges — two cells, never the ambiguous width\n * (the host measures ambiguous as narrow, so `▸`/`✓`/`—` stay one cell).\n * Generated from the host's own measurement (`string-width` over every code\n * point, emoji excluded), so this table can be regenerated verbatim when the\n * host upgrades its Unicode data instead of being hand-edited. */\nconst CELL_WIDE_RANGES: readonly (readonly [number, number])[] = [\n [0x1100, 0x115e],\n [0x2329, 0x232a],\n [0x2630, 0x2637],\n [0x268a, 0x268f],\n [0x2e80, 0x2e99],\n [0x2e9b, 0x2ef3],\n [0x2f00, 0x2fd5],\n [0x2ff0, 0x302f],\n [0x3031, 0x303c],\n [0x303e, 0x303e],\n [0x3041, 0x3096],\n [0x3099, 0x30ff],\n [0x3105, 0x312f],\n [0x3131, 0x3163],\n [0x3165, 0x318e],\n [0x3190, 0x31e5],\n [0x31ef, 0x321e],\n [0x3220, 0x3247],\n [0x3250, 0x3296],\n [0x3298, 0x3298],\n [0x329a, 0xa48c],\n [0xa490, 0xa4c6],\n [0xa960, 0xa97c],\n [0xac00, 0xd7a3],\n [0xf900, 0xfaff],\n [0xfe10, 0xfe19],\n [0xfe30, 0xfe52],\n [0xfe54, 0xfe66],\n [0xfe68, 0xfe6b],\n [0xff01, 0xff60],\n [0xffe0, 0xffe6],\n [0x16fe0, 0x16fe4],\n [0x16ff0, 0x16ff6],\n [0x17000, 0x18cda],\n [0x18cff, 0x18d20],\n [0x18d80, 0x18df2],\n [0x18e00, 0x19191],\n [0x191a0, 0x191d2],\n [0x1aff0, 0x1aff3],\n [0x1aff5, 0x1affb],\n [0x1affd, 0x1affe],\n [0x1b000, 0x1b128],\n [0x1b132, 0x1b132],\n [0x1b150, 0x1b152],\n [0x1b155, 0x1b155],\n [0x1b164, 0x1b168],\n [0x1b170, 0x1b2fb],\n [0x1d300, 0x1d356],\n [0x1d360, 0x1d376],\n [0x1f200, 0x1f200],\n [0x1f210, 0x1f219],\n [0x1f21b, 0x1f22e],\n [0x1f230, 0x1f231],\n [0x1f23b, 0x1f23b],\n [0x1f240, 0x1f248],\n [0x1f260, 0x1f265],\n [0x20000, 0x2fffd],\n [0x30000, 0x3fffd],\n]\n\n/** One code point the terminal draws no cell for: control characters, the\n * zero-width joiners/marks, combining marks and variation selectors. */\nfunction isZeroWidthCodePoint(code: number, glyph: string): boolean {\n if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) return true\n if (code >= 0x200b && code <= 0x200f) return true\n if (code === 0xfeff) return true\n if (code >= 0x300 && code <= 0x36f) return true\n if (code >= 0x1ab0 && code <= 0x1aff) return true\n if (code >= 0x1dc0 && code <= 0x1dff) return true\n if (code >= 0x20d0 && code <= 0x20ff) return true\n if (code >= 0xfe00 && code <= 0xfe0f) return true\n if (code >= 0xfe20 && code <= 0xfe2f) return true\n if (code >= 0xe0100 && code <= 0xe01ef) return true\n if (code >= 0xd800 && code <= 0xdfff) return true // a lone surrogate\n return IGNORABLE_GLYPH.test(glyph)\n}\n\nfunction isWideCodePoint(code: number): boolean {\n for (const [low, high] of CELL_WIDE_RANGES) {\n if (code < low) return false\n if (code <= high) return true\n }\n return false\n}\n\n/** Cells one grapheme occupies. */\nfunction graphemeWidth(segment: string): number {\n if (EMOJI_GLYPH.test(segment)) return 2\n // A lone VS16 carries no width; after a base it asks for emoji presentation.\n if (segment.length > 1 && segment.includes(EMOJI_PRESENTATION_SELECTOR)) return 2\n let width = 0\n for (const glyph of segment) {\n const code = glyph.codePointAt(0) ?? 0\n if (isZeroWidthCodePoint(code, glyph)) continue\n width += isWideCodePoint(code) ? 2 : 1\n }\n return width\n}\n\n/** Terminal cells `value` occupies — the unit every column in this plugin is\n * measured in. Mirrors the host (that is how `@opentui/core` sizes a text\n * run): emoji count as two cells, East Asian Wide/Fullwidth as two, East\n * Asian Ambiguous as one, combining marks and variation selectors as none.\n * Pure. */\nexport function cellWidth(value: string): number {\n let width = 0\n for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment)\n return width\n}\n"],"mappings":";;;;;;;;AAIA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AAEtC,SAASA,eAAa,OAA+B;CACnD,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;AAEA,SAAgB,iBAAiB,SAAsC;CACrE,IAAI,UAAU,IAAI,OAAO;CACzB,IAAI,UAAU,IAAI,OAAO;CACzB,IAAI,UAAU,IAAI,OAAO;CACzB,OAAO;AACT;AAEA,SAAgB,iBAAiB,QAAkD;CACjF,MAAM,QAAQA,eAAa,MAAM;CACjC,IAAI,UAAU,QAAQ,QAAQ,GAAG,OAAO;CACxC,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC,eAAe,OAAO;AACjD;AAEA,SAAgB,oBAAoB,OAAiD;CACnF,MAAM,QAAQA,eAAa,KAAK;CAChC,IAAI,UAAU,QAAQ,SAAS,GAAG,OAAO;CACzC,IAAI,SAAS,KAAW,OAAO,IAAI,QAAQ,IAAA,CAAW,QAAQ,CAAC,EAAE;CACjE,IAAI,SAAS,KAAO,OAAO,GAAG,KAAK,MAAM,QAAQ,GAAK,EAAE;CACxD,OAAO,GAAG,KAAK,MAAM,KAAK;AAC5B;AAEA,SAAgB,iBAAiB,SAAiB,QAAA,IAAmC;CACnF,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;CAC3C,M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CAC3C,IAAI,QAAQ,QAAU,QAAQ,MAAQ,OAAO;CAC7C,IAAI,QAAQ,QAAU,QAAQ,MAAQ,OAAO;CAC7C,IAAI,QAAQ,QAAU,QAAQ,MAAQ,OAAO;CAC7C,IAAI,QAAQ,SAAU,QAAQ,OAAQ,OAAO;CAC7C,IAAI,QAAQ,SAAU,QAAQ,OAAQ,OAAO;CAC7C,IAAI,QAAQ,UAAW,QAAQ,QAAS,OAAO;CAC/C,IAAI,QAAQ,SAAU,QAAQ,OAAQ,OAAO;CAC7C,OAAO,gBAAgB,KAAK,KAAK;AACnC;AAEA,SAAS,gBAAgB,MAAuB;CAC9C,KAAK,MAAM,CAAC,KAAK,SAAS,kBAAkB;EAC1C,IAAI,OAAO,KAAK,OAAO;EACvB,IAAI,QAAQ,MAAM,OAAO;CAC3B;CACA,OAAO;AACT;;AAGA,SAAS,cAAc,SAAyB;CAC9C,IAAI,YAAY,KAAK,OAAO,GAAG,OAAO;CAEtC,IAAI,QAAQ,SAAS,KAAK,QAAQ,SAAS,2BAA2B,GAAG,OAAO;CAChF,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,MAAM,YAAY,CAAC,KAAK;EACrC,IAAI,qBAAqB,MAAM,KAAK,GAAG;EACvC,SAAS,gBAAgB,IAAI,IAAI,IAAI;CACvC;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,UAAU,OAAuB;CAC/C,IAAI,QAAQ;CACZ,KAAK,MAAM,EAAE,aAAa,UAAU,QAAQ,KAAK,GAAG,SAAS,cAAc,OAAO;CAClF,OAAO;AACT"}
1
+ {"version":3,"file":"tui-v2.js","names":["numberOrNull"],"sources":["../src/context-gauge.ts","../src/model-usage-limits.ts","../src/sidebar-width.ts","../src/whats-new-highlights.ts","../src/whats-new-state.ts","../src/whats-new-open.ts"],"sourcesContent":["/** Shared, data-only formatting and visual helpers for compact context gauges. */\n\nexport type ContextProgressTone = 'info' | 'success' | 'warning' | 'error'\n\nexport const CONTEXT_BAR_CELLS = 12\nexport const CONTEXT_BAR_FILLED_CELL = '\\u25B0'\nexport const CONTEXT_BAR_EMPTY_CELL = '\\u25B1'\n\nfunction numberOrNull(value: unknown): number | null {\n return typeof value === 'number' && Number.isFinite(value) ? value : null\n}\n\nexport function contextUsageTone(percent: number): ContextProgressTone {\n if (percent > 90) return 'error'\n if (percent > 50) return 'warning'\n if (percent > 25) return 'success'\n return 'info'\n}\n\nexport function formatTokenCount(tokens: number | null | undefined): string | null {\n const value = numberOrNull(tokens)\n if (value === null || value < 0) return null\n return Math.round(value).toLocaleString('en-US')\n}\n\nexport function formatContextWindow(limit: number | null | undefined): string | null {\n const value = numberOrNull(limit)\n if (value === null || value <= 0) return null\n if (value >= 1_000_000) return `${(value / 1_000_000).toFixed(1)}M`\n if (value >= 1_000) return `${Math.floor(value / 1_000)}K`\n return `${Math.floor(value)}`\n}\n\nexport function contextBarFilled(percent: number, cells = CONTEXT_BAR_CELLS): number {\n const total = Math.max(1, Math.floor(cells))\n const filled = Math.round((percent / 100) * total)\n if (!Number.isFinite(filled)) return 0\n return Math.min(total, Math.max(0, filled))\n}\n\nexport function contextBar(\n percent: number | null | undefined,\n cells = CONTEXT_BAR_CELLS,\n): { filled: string; empty: string } | null {\n const value = numberOrNull(percent)\n if (value === null) return null\n const total = Math.max(1, Math.floor(cells))\n const filled = contextBarFilled(value, total)\n return {\n filled: CONTEXT_BAR_FILLED_CELL.repeat(filled),\n empty: CONTEXT_BAR_EMPTY_CELL.repeat(total - filled),\n }\n}\n\nexport function formatSpent(cost: number | null | undefined): string | null {\n const value = numberOrNull(cost)\n if (value === null || value < 0) return null\n return `$${value.toFixed(2)}`\n}\n","/** Shared bounds for cached recent model-usage aggregation. */\nexport const MODEL_USAGE_VISIBLE_CEILING = 3\nexport const MODEL_USAGE_MESSAGE_LIMIT = 400\nexport const MODEL_USAGE_SESSION_LIMIT = 8\n","/** Conservative content budget; the host sidebar slot does not report its runtime width. */\nexport const SIDEBAR_CONTENT_WIDTH = 34\n\nexport const GRAPHEMES = new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n\n/** A grapheme the host draws two cells wide: emoji presentation, an extended\n * pictograph (a bare `❤` counts too, exactly as the host's `emoji-regex`\n * does) and a regional-indicator pair (a flag). */\nconst EMOJI_GLYPH = /\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{Regional_Indicator}/u\n/** VS16 asks for emoji presentation; without it `1` is one cell, with it the\n * keycap sequence is drawn as one two-cell glyph. */\nconst EMOJI_PRESENTATION_SELECTOR = '\\uFE0F'\n/** Unicode default-ignorable code points carry no width of their own. */\nconst IGNORABLE_GLYPH = /^\\p{Default_Ignorable_Code_Point}$/u\n/** East Asian Wide/Fullwidth ranges — two cells, never the ambiguous width\n * (the host measures ambiguous as narrow, so `▸`/`✓`/`—` stay one cell).\n * Generated from the host's own measurement (`string-width` over every code\n * point, emoji excluded), so this table can be regenerated verbatim when the\n * host upgrades its Unicode data instead of being hand-edited. */\nconst CELL_WIDE_RANGES: readonly (readonly [number, number])[] = [\n [0x1100, 0x115e],\n [0x2329, 0x232a],\n [0x2630, 0x2637],\n [0x268a, 0x268f],\n [0x2e80, 0x2e99],\n [0x2e9b, 0x2ef3],\n [0x2f00, 0x2fd5],\n [0x2ff0, 0x302f],\n [0x3031, 0x303c],\n [0x303e, 0x303e],\n [0x3041, 0x3096],\n [0x3099, 0x30ff],\n [0x3105, 0x312f],\n [0x3131, 0x3163],\n [0x3165, 0x318e],\n [0x3190, 0x31e5],\n [0x31ef, 0x321e],\n [0x3220, 0x3247],\n [0x3250, 0x3296],\n [0x3298, 0x3298],\n [0x329a, 0xa48c],\n [0xa490, 0xa4c6],\n [0xa960, 0xa97c],\n [0xac00, 0xd7a3],\n [0xf900, 0xfaff],\n [0xfe10, 0xfe19],\n [0xfe30, 0xfe52],\n [0xfe54, 0xfe66],\n [0xfe68, 0xfe6b],\n [0xff01, 0xff60],\n [0xffe0, 0xffe6],\n [0x16fe0, 0x16fe4],\n [0x16ff0, 0x16ff6],\n [0x17000, 0x18cda],\n [0x18cff, 0x18d20],\n [0x18d80, 0x18df2],\n [0x18e00, 0x19191],\n [0x191a0, 0x191d2],\n [0x1aff0, 0x1aff3],\n [0x1aff5, 0x1affb],\n [0x1affd, 0x1affe],\n [0x1b000, 0x1b128],\n [0x1b132, 0x1b132],\n [0x1b150, 0x1b152],\n [0x1b155, 0x1b155],\n [0x1b164, 0x1b168],\n [0x1b170, 0x1b2fb],\n [0x1d300, 0x1d356],\n [0x1d360, 0x1d376],\n [0x1f200, 0x1f200],\n [0x1f210, 0x1f219],\n [0x1f21b, 0x1f22e],\n [0x1f230, 0x1f231],\n [0x1f23b, 0x1f23b],\n [0x1f240, 0x1f248],\n [0x1f260, 0x1f265],\n [0x20000, 0x2fffd],\n [0x30000, 0x3fffd],\n]\n\n/** One code point the terminal draws no cell for: control characters, the\n * zero-width joiners/marks, combining marks and variation selectors. */\nfunction isZeroWidthCodePoint(code: number, glyph: string): boolean {\n if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) return true\n if (code >= 0x200b && code <= 0x200f) return true\n if (code === 0xfeff) return true\n if (code >= 0x300 && code <= 0x36f) return true\n if (code >= 0x1ab0 && code <= 0x1aff) return true\n if (code >= 0x1dc0 && code <= 0x1dff) return true\n if (code >= 0x20d0 && code <= 0x20ff) return true\n if (code >= 0xfe00 && code <= 0xfe0f) return true\n if (code >= 0xfe20 && code <= 0xfe2f) return true\n if (code >= 0xe0100 && code <= 0xe01ef) return true\n if (code >= 0xd800 && code <= 0xdfff) return true // a lone surrogate\n return IGNORABLE_GLYPH.test(glyph)\n}\n\nfunction isWideCodePoint(code: number): boolean {\n for (const [low, high] of CELL_WIDE_RANGES) {\n if (code < low) return false\n if (code <= high) return true\n }\n return false\n}\n\n/** Cells one grapheme occupies. */\nfunction graphemeWidth(segment: string): number {\n if (EMOJI_GLYPH.test(segment)) return 2\n // A lone VS16 carries no width; after a base it asks for emoji presentation.\n if (segment.length > 1 && segment.includes(EMOJI_PRESENTATION_SELECTOR)) return 2\n let width = 0\n for (const glyph of segment) {\n const code = glyph.codePointAt(0) ?? 0\n if (isZeroWidthCodePoint(code, glyph)) continue\n width += isWideCodePoint(code) ? 2 : 1\n }\n return width\n}\n\n/** Terminal cells `value` occupies — the unit every column in this plugin is\n * measured in. Mirrors the host (that is how `@opentui/core` sizes a text\n * run): emoji count as two cells, East Asian Wide/Fullwidth as two, East\n * Asian Ambiguous as one, combining marks and variation selectors as none.\n * Pure. */\nexport function cellWidth(value: string): number {\n let width = 0\n for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment)\n return width\n}\n","/**\n * whats-new-highlights.ts — release highlights for the one-time \"What's new\"\n * window, extracted from the CHANGELOG.md shipped with the plugin copy.\n *\n * The section-finding logic is an inline replica of scripts/changelog-extract.mjs\n * `extractSection` (pinned by a parity test in tests/tui-whats-new.test.mjs):\n * the copied plugin ships only dist/ + package.json (+ CHANGELOG.md, copied by\n * both installers), so it cannot reach scripts/ at runtime — the same reason\n * the preset resolver is mirrored in index.tsx/index-v2.tsx rather than\n * imported. The script's CLI main is NOT replicated; the plugin only needs the\n * pure extraction.\n *\n * Everything is reduced to bounded plain text: no markdown syntax artifacts,\n * at most WHATS_NEW_MAX_ITEMS bullets. Missing CHANGELOG.md, an unknown\n * version or an empty section all resolve to an empty highlight set — the\n * window simply does not show (fail-open, like the rest of the plugin).\n */\nimport { readFile } from 'node:fs/promises'\nimport { dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/** Hard cap on bullets shown in the window (the remainder is counted). */\nexport const WHATS_NEW_MAX_ITEMS = 12\n\n/**\n * Cap for the curated `🆕 What's New` summary block — the window shows the\n * summary, never the full Added/Changed/Fixed walls.\n */\nexport const WHATS_NEW_SUMMARY_MAX_ITEMS = 6\n\n/** Bullets longer than this are truncated with an ellipsis (one-line rule). */\nexport const WHATS_NEW_ITEM_MAX_CHARS = 140\n\n/** Prefix of the \"+N more\" line appended when the bullet budget is exceeded. */\nexport const WHATS_NEW_MORE_PREFIX = '… +'\n\n/** H3 subsection headings are kept as plain-text group labels. */\nexport interface WhatsNewGroup {\n heading: string | null\n items: string[]\n}\n\nexport interface WhatsNewHighlights {\n /** Normalized version the highlights belong to (null when not found). */\n version: string | null\n found: boolean\n groups: WhatsNewGroup[]\n /** Total bullets in the section, before the WHATS_NEW_MAX_ITEMS cut. */\n totalItems: number\n /** True when totalItems exceeded WHATS_NEW_MAX_ITEMS. */\n truncated: boolean\n}\n\nexport const EMPTY_HIGHLIGHTS: WhatsNewHighlights = {\n version: null,\n found: false,\n groups: [],\n totalItems: 0,\n truncated: false,\n}\n\n/** Escape regex metacharacters so a version like 1.0.0 matches literally. */\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/**\n * Extract the body of a version section from changelog text — inline replica\n * of scripts/changelog-extract.mjs `extractSection` (see that file for the\n * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date\n * optional, `## [Unreleased]` never matched).\n */\nexport function extractSection(\n changelogText: string,\n version: string,\n): { found: boolean; body: string | null } {\n const normalized = String(version).trim().replace(/^v/i, '')\n if (!normalized || /^unreleased$/i.test(normalized)) return { found: false, body: null }\n\n const escaped = escapeRegExp(normalized)\n // Single-line heading: `## [v?1.2.1]` optionally followed by ` - YYYY-MM-DD`.\n // [ \\t] (not \\s) keeps the match from crossing newlines; the lookahead\n // requires end-of-line or whitespace so `[1.0.0-beta]` can never match `1.0.0`.\n const headingRe = new RegExp(\n `^##[ \\\\t]+\\\\[v?${escaped}\\\\](?:[ \\\\t]*-[ \\\\t]*\\\\d{4}-\\\\d{2}-\\\\d{2})?(?=[ \\\\t]|$)`,\n 'm',\n )\n const match = headingRe.exec(changelogText)\n if (!match) return { found: false, body: null }\n\n // Advance past the heading line (match.index may point mid-line).\n const newline = changelogText.indexOf('\\n', match.index)\n const start = newline === -1 ? changelogText.length : newline + 1\n\n // Body ends at the next `## [` heading or end of text.\n const nextHeading = /^##[ \\t]+\\[/m.exec(changelogText.slice(start))\n const end = nextHeading ? start + nextHeading.index : changelogText.length\n\n return { found: true, body: changelogText.slice(start, end).trim() }\n}\n\n/**\n * Reduce one markdown line to plain text: links keep their label, emphasis\n * and inline-code markers are dropped, HTML comment fragments are removed,\n * and whitespace collapses. Deliberately simple — the input is our own\n * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.\n */\nexport function stripMarkdown(text: string): string {\n return text\n .replace(/<!--[\\s\\S]*?-->/g, ' ')\n .replace(/\\[([^\\]]+)\\]\\([^)]*\\)/g, '$1')\n .replace(/(\\*\\*|__)/g, '')\n .replace(/`/g, '')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** Strip the leading H3 marker (`### Added` → `Added`). */\nfunction stripHeading(text: string): string {\n return text.replace(/^#{1,6}[ \\t]+/, '').trim()\n}\n\n/**\n * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)\n * from a section body: its bullets only, each truncated to\n * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when\n * the section carries no summary block (the full-section fallback applies).\n */\nexport function extractWhatsNewSummary(body: string): string[] | null {\n const lines = body.split('\\n')\n const start = lines.findIndex((line) => /^#{2,3}[ \\t]+.*What'?s New/i.test(line.trim()))\n if (start === -1) return null\n const items: string[] = []\n for (const rawLine of lines.slice(start + 1)) {\n const line = rawLine.trim()\n if (line === '' || line.startsWith('<!--')) continue\n if (/^#{1,6}[ \\t]/.test(line)) break // next subsection — summary ended\n if (!/^[-*][ \\t]/.test(line)) continue\n if (items.length >= WHATS_NEW_SUMMARY_MAX_ITEMS) break\n const content = stripMarkdown(line.replace(/^[-*][ \\t]+/, ''))\n if (content === '') continue\n items.push(\n content.length > WHATS_NEW_ITEM_MAX_CHARS\n ? `${content.slice(0, WHATS_NEW_ITEM_MAX_CHARS - 1)}…`\n : content,\n )\n }\n return items.length > 0 ? items : null\n}\n\n/**\n * Extract the release highlights for `version`. When the section carries a\n * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the\n * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the\n * dialog); otherwise it falls back to the H3-group extraction bounded to\n * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a\n * blank changelog all return EMPTY_HIGHLIGHTS (no window).\n */\nexport function extractHighlights(changelogText: string, version: string): WhatsNewHighlights {\n const { found, body } = extractSection(changelogText ?? '', version ?? '')\n if (!found || !body) return { ...EMPTY_HIGHLIGHTS }\n\n const summary = extractWhatsNewSummary(body)\n if (summary !== null) {\n return {\n version: String(version).trim().replace(/^v/i, ''),\n found: true,\n groups: [{ heading: null, items: summary }],\n totalItems: summary.length,\n truncated: false,\n }\n }\n\n const groups: WhatsNewGroup[] = []\n let totalItems = 0\n let truncated = false\n\n for (const rawLine of body.split('\\n')) {\n const line = rawLine.trim()\n if (line === '' || line.startsWith('<!--')) continue\n\n if (/^#{1,6}[ \\t]/.test(line)) {\n const heading = stripMarkdown(stripHeading(line))\n if (heading === '') continue\n if (groups.at(-1)?.items.length === 0) groups.pop() // empty group boundary\n groups.push({ heading, items: [] })\n continue\n }\n\n if (totalItems >= WHATS_NEW_MAX_ITEMS) {\n // Keep scanning only to count the remainder for the \"+N more\" line.\n if (/^[-*][ \\t]/.test(line)) totalItems += 1\n continue\n }\n\n const isBullet = /^[-*][ \\t]/.test(line)\n const continuation = (groups.at(-1)?.items.length ?? 0) > 0\n if (!isBullet && !continuation) continue // prose between groups — not a highlight\n\n const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \\t]+/, '') : line)\n if (content === '') continue\n const bounded =\n content.length > WHATS_NEW_ITEM_MAX_CHARS\n ? `${content.slice(0, WHATS_NEW_ITEM_MAX_CHARS - 1)}…`\n : content\n const group = groups.at(-1)\n if (group === undefined) {\n groups.push({ heading: null, items: [bounded] })\n } else if (isBullet || group.items.length === 0) {\n group.items.push(bounded)\n } else {\n group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim()\n }\n if (isBullet) totalItems += 1\n }\n\n const kept = groups.filter((group) => group.items.length > 0)\n truncated = totalItems > WHATS_NEW_MAX_ITEMS\n return {\n version: found ? String(version).trim().replace(/^v/i, '') : null,\n found,\n groups: kept,\n totalItems,\n truncated,\n }\n}\n\n/** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */\nexport function whatsNewTitle(version: string): string {\n return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, '')}`\n}\n\n/** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */\nexport function whatsNewLines(highlights: WhatsNewHighlights): string[] {\n const lines: string[] = []\n for (const group of highlights.groups) {\n if (group.heading !== null) lines.push(group.heading)\n for (const item of group.items) lines.push(`• ${item}`)\n }\n if (highlights.truncated) {\n const hidden = Math.max(0, highlights.totalItems - WHATS_NEW_MAX_ITEMS)\n if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`)\n }\n return lines\n}\n\n/**\n * Candidate CHANGELOG.md locations for a bundle, first readable wins:\n * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,\n * shipped by both installers next to package.json);\n * 2. the package root (dev checkout; also an npm-package install when the\n * bundle runs from `<pkg>/src/plugins/tui/dist/`).\n */\nexport function changelogCandidates(bundlePath: string): string[] {\n const dist = dirname(bundlePath)\n const copyRoot = dirname(dist)\n // The second leg targets the package root: src/plugins/tui → plugins → src\n // → package root (dev checkout / npm-package install). On an installed copy\n // the same three levels land on the XDG base, where no CHANGELOG lives —\n // harmless, the copy-root candidate is the one the installers ship.\n const packageRoot = dirname(dirname(dirname(copyRoot)))\n return [join(copyRoot, 'CHANGELOG.md'), join(packageRoot, 'CHANGELOG.md')]\n}\n\n/** Read the first existing candidate; null when none is readable (no window). */\nexport async function readChangelogForBundle(bundleUrl: string): Promise<string | null> {\n try {\n const bundlePath = fileURLToPath(bundleUrl)\n for (const candidate of changelogCandidates(bundlePath)) {\n try {\n return await readFile(candidate, 'utf8')\n } catch {}\n }\n return null\n } catch {\n return null\n }\n}\n\n/** Build-time embedded version (tsdown `define` in tsdown.config.ts). */\ndeclare const __PANTHEON_VERSION__: string | undefined\n\n/** The ambient build-time version, or null outside a tsdown build. */\nexport function embeddedVersion(): string | null {\n return typeof __PANTHEON_VERSION__ !== 'undefined' && __PANTHEON_VERSION__\n ? __PANTHEON_VERSION__\n : null\n}\n\n/**\n * Resolve the running Pantheon version for the what's-new window: the plugin\n * copy's own package.json first (the copy root two levels above the bundle,\n * then the package root four levels above — the same legs as the V1 sidebar's\n * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when\n * nothing resolves → no window (fail-open).\n */\nexport async function resolveRunningVersion(\n bundleUrl: string,\n embedded: string | null = embeddedVersion(),\n): Promise<string | null> {\n try {\n const bundlePath = fileURLToPath(bundleUrl)\n const dist = dirname(bundlePath)\n for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) {\n try {\n const raw = await readFile(join(root, 'package.json'), 'utf8')\n const parsed = JSON.parse(raw) as { version?: unknown }\n if (typeof parsed.version === 'string' && parsed.version.trim() !== '') {\n return parsed.version\n }\n } catch {}\n }\n } catch {\n /* fall through to the embed */\n }\n return embedded\n}\n","/**\n * whats-new-state.ts — last-seen version for the one-time \"What's new\" window.\n *\n * The TUI shows a dismissable release-highlights dialog once per Pantheon\n * version. Whether a version was already seen is persisted next to the other\n * opencode-level Pantheon state: `<configDir>/.pantheon/whats-new.json`, the\n * same directory that already holds `install-state.json` (scripts/install/\n * state.mjs) and the active-preset file the sidebar reads. There is no\n * established persistent TUI KV store (the host `api.kv` is per-process), so\n * the plugin owns one small JSON file with the atomic-write discipline used\n * across the repo (unique tmp + rename, mirrors scripts/install/verify.mjs).\n *\n * Fail-open everywhere: a missing or corrupt file reads as \"never seen\" (the\n * window may show), a failed write is silent (the window may show again) —\n * neither can ever block TUI startup.\n */\nimport { mkdir, readFile, rename, stat, unlink, writeFile } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { dirname, join } from 'node:path'\n\n/** State file name, kept next to `install-state.json` in `<configDir>/.pantheon/`. */\nexport const WHATS_NEW_STATE_FILENAME = 'whats-new.json'\n\n/** Shape of the persisted file — the plugin owns this file outright. */\nexport interface WhatsNewStateFile {\n seenVersion: string | null\n updatedAt: string\n}\n\ntype Env = Record<string, string | undefined>\n\n/** Parse a state file body; null when unreadable as the expected shape. */\nexport function parseWhatsNewState(raw: string): WhatsNewStateFile | null {\n try {\n const parsed: unknown = JSON.parse(raw)\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null\n const record = parsed as Record<string, unknown>\n const seen = record.seenVersion\n if (typeof seen !== 'string' && seen !== null) return null\n return { seenVersion: seen, updatedAt: String(record.updatedAt ?? '') }\n } catch {\n return null\n }\n}\n\n/** Read the persisted state; null when missing or corrupt (never throws). */\nexport async function readWhatsNewState(statePath: string): Promise<WhatsNewStateFile | null> {\n try {\n return parseWhatsNewState(await readFile(statePath, 'utf8'))\n } catch {\n return null\n }\n}\n\n/**\n * Whether the one-time window should show for `version`: any version change\n * since the last dismissal (including downgrades). A falsy version — the\n * resolver failed — never shows.\n */\nexport async function shouldShowWhatsNew(\n version: string | null | undefined,\n statePath: string,\n): Promise<boolean> {\n if (typeof version !== 'string' || version.trim() === '') return false\n const state = await readWhatsNewState(statePath)\n return state?.seenVersion !== version\n}\n\n/**\n * Persist `version` as seen (atomic tmp + rename, 0o600). Never throws: a\n * failed write leaves the state untouched and the window may show again —\n * the same fail-open contract as the rest of the plugin.\n */\nexport async function markSeenWhatsNew(version: string, statePath: string): Promise<boolean> {\n if (typeof version !== 'string' || version.trim() === '') return false\n const previous = await readWhatsNewState(statePath)\n const next: WhatsNewStateFile = {\n seenVersion: version,\n updatedAt: new Date().toISOString(),\n }\n const tmpPath = `${statePath}.tmp-${process.pid}`\n try {\n await mkdir(dirname(statePath), { recursive: true })\n await writeFile(tmpPath, `${JSON.stringify({ ...previous, ...next }, null, 2)}\\n`, {\n encoding: 'utf8',\n mode: 0o600,\n })\n await rename(tmpPath, statePath)\n return true\n } catch {\n try {\n await unlink(tmpPath)\n } catch {\n /* nothing to clean up */\n }\n return false\n }\n}\n\n/** `stat`-based existence probe (async I/O discipline). */\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await stat(path)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Default state path: `<configDir>/.pantheon/whats-new.json`, resolving the\n * OpenCode config directory exactly like src/pantheon/tui-version-check.ts\n * (`$XDG_CONFIG_HOME/opencode` → `~/.opencode`), defaulting to the XDG\n * location `init` creates when neither exists yet.\n */\nexport async function defaultWhatsNewStatePath(\n env: Env = process.env,\n home: string = homedir(),\n): Promise<string> {\n const xdgConfig = env.XDG_CONFIG_HOME || join(home, '.config')\n const primary = join(xdgConfig, 'opencode')\n if (await pathExists(primary)) return join(primary, '.pantheon', WHATS_NEW_STATE_FILENAME)\n\n const legacy = join(home, '.opencode')\n if (await pathExists(legacy)) return join(legacy, '.pantheon', WHATS_NEW_STATE_FILENAME)\n\n return join(primary, '.pantheon', WHATS_NEW_STATE_FILENAME)\n}\n","/**\n * whats-new-open.ts — the show-once decision for the \"What's new\" window.\n *\n * Plain data in, plain data out: the entrypoints (index.tsx / index-v2.tsx)\n * resolve the running version and the shipped CHANGELOG.md, then hand this\n * module a `show` callback that renders the view data through the host's\n * dialog API. Keeping the decision JSX-free makes the whole one-time flow\n * testable offline (node strips the types natively) — the Solid glue lives in\n * whats-new.tsx.\n *\n * Contract (pinned by tests/tui-whats-new.test.mjs):\n * - shows at most once per version: dismissal marks the version seen;\n * - nothing to show (no version, missing CHANGELOG, empty section) → no\n * window AND no pin — the next start may still show it;\n * - never throws on its own inputs; I/O failures inside the state module\n * are fail-open there.\n */\nimport {\n EMPTY_HIGHLIGHTS,\n extractHighlights,\n type WhatsNewHighlights,\n whatsNewLines,\n whatsNewTitle,\n} from './whats-new-highlights.ts'\nimport { markSeenWhatsNew, shouldShowWhatsNew } from './whats-new-state.ts'\n\n/** Muted footer hint teaching the dismiss bind (Portuguese, like the sidebar). */\nexport const WHATS_NEW_CLOSE_HINT = 'esc/q fechar'\n\n/** Hint variant when the highlights span more than one page. */\nexport const WHATS_NEW_PAGES_HINT = 'esc/q fechar · n próxima · p volta'\n\n/** The CHANGELOG pointer shown under the highlights (the window summarizes; the file is complete). */\nexport const WHATS_NEW_MORE_HINT = 'CHANGELOG completo: CHANGELOG.md no pacote'\n\n/** Rows per page — bounded so no changelog can overflow the terminal. */\nexport const WHATS_NEW_PAGE_SIZE = 14\n\n/** Hard-wrap one display line into rows of at most `width` columns (>= 10). */\nexport function wrapWhatsNewLine(line: string, width: number): string[] {\n const bounded = Number.isInteger(width) && width > 10 ? width : 76\n const text = String(line)\n if (text.length <= bounded) return [text]\n const rows: string[] = []\n let rest = text\n while (rest.length > bounded) {\n rows.push(rest.slice(0, bounded))\n rest = rest.slice(bounded)\n }\n if (rest.length > 0) rows.push(rest)\n return rows\n}\n\n/** Slice display lines into fixed-size pages (>= 1 page, empty-safe). */\nexport function paginateWhatsNewLines(\n lines: string[],\n pageSize: number = WHATS_NEW_PAGE_SIZE,\n): string[][] {\n const size = Number.isInteger(pageSize) && pageSize > 0 ? pageSize : WHATS_NEW_PAGE_SIZE\n if (lines.length === 0) return [[]]\n const pages: string[][] = []\n for (let i = 0; i < lines.length; i += size) pages.push(lines.slice(i, i + size))\n return pages\n}\n\n/** Everything the window needs to render — no host types, no JSX. */\nexport interface WhatsNewViewData {\n version: string\n title: string\n lines: string[]\n /** Fixed-size pages of `lines` (single page when the highlights are short). */\n pages: string[][]\n hint: string\n}\n\nexport type WhatsNewShowFn = (render: () => WhatsNewViewData, onClose: () => void) => void\n\nexport interface WhatsNewOpenInput {\n /** Running Pantheon version (null when unresolvable → no window). */\n version: string | null\n /** Path of the seen-version state file (see whats-new-state.ts). */\n statePath: string\n /** Shipped CHANGELOG.md content, or null when unreadable. */\n changelogText: string | null\n /** Host dialog opener; `onClose` fires on host dismissal (ESC / chrome). */\n show: WhatsNewShowFn\n}\n\n/**\n * Open the one-time window when the version changed and highlights exist.\n * Returns true when the window was shown; the caller's `onClose` callback\n * (both host-initiated and local close binds) must funnel into marking seen.\n */\nexport async function openWhatsNew(input: WhatsNewOpenInput): Promise<boolean> {\n const { version, statePath, changelogText, show } = input\n if (typeof version !== 'string' || version.trim() === '') return false\n if (!(await shouldShowWhatsNew(version, statePath))) return false\n\n const highlights: WhatsNewHighlights = changelogText\n ? extractHighlights(changelogText, version)\n : { ...EMPTY_HIGHLIGHTS }\n const lines = whatsNewLines(highlights)\n if (lines.length === 0) return false\n\n const pages = paginateWhatsNewLines(lines)\n const data: WhatsNewViewData = {\n version,\n title: whatsNewTitle(version),\n lines,\n pages,\n hint: pages.length > 1 ? WHATS_NEW_PAGES_HINT : WHATS_NEW_CLOSE_HINT,\n }\n show(\n () => data,\n () => {\n void markSeenWhatsNew(version, statePath)\n },\n )\n return true\n}\n"],"mappings":";;;;;;;;;AAIA,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,yBAAyB;AAEtC,SAASA,eAAa,OAA+B;CACnD,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;AAEA,SAAgB,iBAAiB,SAAsC;CACrE,IAAI,UAAU,IAAI,OAAO;CACzB,IAAI,UAAU,IAAI,OAAO;CACzB,IAAI,UAAU,IAAI,OAAO;CACzB,OAAO;AACT;AAEA,SAAgB,iBAAiB,QAAkD;CACjF,MAAM,QAAQA,eAAa,MAAM;CACjC,IAAI,UAAU,QAAQ,QAAQ,GAAG,OAAO;CACxC,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC,eAAe,OAAO;AACjD;AAEA,SAAgB,oBAAoB,OAAiD;CACnF,MAAM,QAAQA,eAAa,KAAK;CAChC,IAAI,UAAU,QAAQ,SAAS,GAAG,OAAO;CACzC,IAAI,SAAS,KAAW,OAAO,IAAI,QAAQ,IAAA,CAAW,Q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,KAAK,WAAW,IAAI,WAAA;CAC1D,IAAI,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC;CAClC,MAAM,QAAoB,CAAC;CAC3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,MAAM,MAAM,KAAK,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC;CAChF,OAAO;AACT;;;;;;AA8BA,eAAsB,aAAa,OAA4C;CAC7E,MAAM,EAAE,SAAS,WAAW,eAAe,SAAS;CACpD,IAAI,OAAO,YAAY,YAAY,QAAQ,KAAK,MAAM,IAAI,OAAO;CACjE,IAAI,CAAE,MAAM,mBAAmB,SAAS,SAAS,GAAI,OAAO;CAK5D,MAAM,QAAQ,cAHyB,gBACnC,kBAAkB,eAAe,OAAO,IACxC,EAAE,GAAG,iBAAiB,CACY;CACtC,IAAI,MAAM,WAAW,GAAG,OAAO;CAE/B,MAAM,QAAQ,sBAAsB,KAAK;CACzC,MAAM,OAAyB;EAC7B;EACA,OAAO,cAAc,OAAO;EAC5B;EACA;EACA,MAAM,MAAM,SAAS,IAAI,uBAAuB;CAClD;CACA,WACQ,YACA;EACJ,iBAAsB,SAAS,SAAS;CAC1C,CACF;CACA,OAAO;AACT"}
@@ -167,7 +167,7 @@ async function detectVersion(api) {
167
167
  if (ver) return ver;
168
168
  }
169
169
  } catch {}
170
- return "1.6.3-beta.2";
170
+ return "1.6.3-beta.15";
171
171
  }
172
172
  /**
173
173
  * usage-bar — AI subscription usage gauge for the opencode TUI.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
- "version": "1.6.3-beta.2",
3
+ "version": "1.6.3-beta.21",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pantheon-tui",
9
- "version": "1.6.3-beta.2",
9
+ "version": "1.6.3-beta.21",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@opencode-ai/plugin": "1.18.33",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
3
  "type": "module",
4
- "version": "1.6.3-beta.2",
4
+ "version": "1.6.3-beta.21",
5
5
  "description": "Pantheon TUI plugin — V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
6
6
  "license": "MIT",
7
7
  "engines": {
@@ -24,6 +24,7 @@ import {
24
24
  MODEL_USAGE_VISIBLE_CEILING,
25
25
  } from './model-usage-limits'
26
26
  import { cellWidth, GRAPHEMES, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
27
+ import { maybeShowWhatsNewV2 } from './whats-new'
27
28
 
28
29
  export type { ContextProgressTone } from './context-gauge'
29
30
  export {
@@ -4476,6 +4477,11 @@ const plugin = Plugin.define({
4476
4477
  append: 'app',
4477
4478
  render: () => <DispatchCommandLayer context={context} />,
4478
4479
  })
4480
+ // One-time "What's new" window (per Pantheon version) — fire-and-forget:
4481
+ // resolves the running version and the shipped CHANGELOG.md, then opens a
4482
+ // host dialog when the version changed since the last dismissal. Fail-open;
4483
+ // a missing changelog or unreadable state simply means no window.
4484
+ void maybeShowWhatsNewV2(context)
4479
4485
  return () => {
4480
4486
  if (typeof unregisterSidebar === 'function') unregisterSidebar()
4481
4487
  if (typeof unregisterHome === 'function') unregisterHome()
@@ -10,12 +10,19 @@
10
10
  * channel — the initial JSX mounts but effects/refresh/events stay dead (the
11
11
  * "mudo panel" symptom; same contract as the V1 `server.ts` stub).
12
12
  *
13
- * This stub satisfies the loader contract. The native quota RPC that used to
14
- * live here was removed in 1.6.2 — provider quota/usage visibility is now the
15
- * community plugin's job (`@slkiser/opencode-quota`,
16
- * docs/tui-v2-quota-providers.md) — and pantheon-tui has no other background
17
- * server work of its own.
13
+ * This stub satisfies the loader contract. Field report (beta.13): host 2.2.5
14
+ * validates the default export as a DEFINITION OBJECT — "Plugin must export a
15
+ * default definition with an id and an effect or setup function
16
+ * (SchemaError(Expected object at ["default"]))" — the bare `server()`
17
+ * function form failed that schema on every boot (~3.4k load failures in the
18
+ * host log). The native quota RPC that used to live here was removed in 1.6.2
19
+ * — provider quota/usage visibility is now the community plugin's job
20
+ * (`@slkiser/opencode-quota`, docs/tui-v2-quota-providers.md) — and
21
+ * pantheon-tui has no other background server work of its own.
18
22
  */
19
- export default function server() {
20
- return {}
23
+ export default {
24
+ id: 'pantheon.tui.server',
25
+ setup() {
26
+ return {}
27
+ },
21
28
  }
@@ -0,0 +1,317 @@
1
+ /**
2
+ * whats-new-highlights.ts — release highlights for the one-time "What's new"
3
+ * window, extracted from the CHANGELOG.md shipped with the plugin copy.
4
+ *
5
+ * The section-finding logic is an inline replica of scripts/changelog-extract.mjs
6
+ * `extractSection` (pinned by a parity test in tests/tui-whats-new.test.mjs):
7
+ * the copied plugin ships only dist/ + package.json (+ CHANGELOG.md, copied by
8
+ * both installers), so it cannot reach scripts/ at runtime — the same reason
9
+ * the preset resolver is mirrored in index.tsx/index-v2.tsx rather than
10
+ * imported. The script's CLI main is NOT replicated; the plugin only needs the
11
+ * pure extraction.
12
+ *
13
+ * Everything is reduced to bounded plain text: no markdown syntax artifacts,
14
+ * at most WHATS_NEW_MAX_ITEMS bullets. Missing CHANGELOG.md, an unknown
15
+ * version or an empty section all resolve to an empty highlight set — the
16
+ * window simply does not show (fail-open, like the rest of the plugin).
17
+ */
18
+ import { readFile } from 'node:fs/promises'
19
+ import { dirname, join } from 'node:path'
20
+ import { fileURLToPath } from 'node:url'
21
+
22
+ /** Hard cap on bullets shown in the window (the remainder is counted). */
23
+ export const WHATS_NEW_MAX_ITEMS = 12
24
+
25
+ /**
26
+ * Cap for the curated `🆕 What's New` summary block — the window shows the
27
+ * summary, never the full Added/Changed/Fixed walls.
28
+ */
29
+ export const WHATS_NEW_SUMMARY_MAX_ITEMS = 6
30
+
31
+ /** Bullets longer than this are truncated with an ellipsis (one-line rule). */
32
+ export const WHATS_NEW_ITEM_MAX_CHARS = 140
33
+
34
+ /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
35
+ export const WHATS_NEW_MORE_PREFIX = '… +'
36
+
37
+ /** H3 subsection headings are kept as plain-text group labels. */
38
+ export interface WhatsNewGroup {
39
+ heading: string | null
40
+ items: string[]
41
+ }
42
+
43
+ export interface WhatsNewHighlights {
44
+ /** Normalized version the highlights belong to (null when not found). */
45
+ version: string | null
46
+ found: boolean
47
+ groups: WhatsNewGroup[]
48
+ /** Total bullets in the section, before the WHATS_NEW_MAX_ITEMS cut. */
49
+ totalItems: number
50
+ /** True when totalItems exceeded WHATS_NEW_MAX_ITEMS. */
51
+ truncated: boolean
52
+ }
53
+
54
+ export const EMPTY_HIGHLIGHTS: WhatsNewHighlights = {
55
+ version: null,
56
+ found: false,
57
+ groups: [],
58
+ totalItems: 0,
59
+ truncated: false,
60
+ }
61
+
62
+ /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
63
+ function escapeRegExp(text: string): string {
64
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
65
+ }
66
+
67
+ /**
68
+ * Extract the body of a version section from changelog text — inline replica
69
+ * of scripts/changelog-extract.mjs `extractSection` (see that file for the
70
+ * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
71
+ * optional, `## [Unreleased]` never matched).
72
+ */
73
+ export function extractSection(
74
+ changelogText: string,
75
+ version: string,
76
+ ): { found: boolean; body: string | null } {
77
+ const normalized = String(version).trim().replace(/^v/i, '')
78
+ if (!normalized || /^unreleased$/i.test(normalized)) return { found: false, body: null }
79
+
80
+ const escaped = escapeRegExp(normalized)
81
+ // Single-line heading: `## [v?1.2.1]` optionally followed by ` - YYYY-MM-DD`.
82
+ // [ \t] (not \s) keeps the match from crossing newlines; the lookahead
83
+ // requires end-of-line or whitespace so `[1.0.0-beta]` can never match `1.0.0`.
84
+ const headingRe = new RegExp(
85
+ `^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`,
86
+ 'm',
87
+ )
88
+ const match = headingRe.exec(changelogText)
89
+ if (!match) return { found: false, body: null }
90
+
91
+ // Advance past the heading line (match.index may point mid-line).
92
+ const newline = changelogText.indexOf('\n', match.index)
93
+ const start = newline === -1 ? changelogText.length : newline + 1
94
+
95
+ // Body ends at the next `## [` heading or end of text.
96
+ const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start))
97
+ const end = nextHeading ? start + nextHeading.index : changelogText.length
98
+
99
+ return { found: true, body: changelogText.slice(start, end).trim() }
100
+ }
101
+
102
+ /**
103
+ * Reduce one markdown line to plain text: links keep their label, emphasis
104
+ * and inline-code markers are dropped, HTML comment fragments are removed,
105
+ * and whitespace collapses. Deliberately simple — the input is our own
106
+ * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
107
+ */
108
+ export function stripMarkdown(text: string): string {
109
+ return text
110
+ .replace(/<!--[\s\S]*?-->/g, ' ')
111
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
112
+ .replace(/(\*\*|__)/g, '')
113
+ .replace(/`/g, '')
114
+ .replace(/\s+/g, ' ')
115
+ .trim()
116
+ }
117
+
118
+ /** Strip the leading H3 marker (`### Added` → `Added`). */
119
+ function stripHeading(text: string): string {
120
+ return text.replace(/^#{1,6}[ \t]+/, '').trim()
121
+ }
122
+
123
+ /**
124
+ * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
125
+ * from a section body: its bullets only, each truncated to
126
+ * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
127
+ * the section carries no summary block (the full-section fallback applies).
128
+ */
129
+ export function extractWhatsNewSummary(body: string): string[] | null {
130
+ const lines = body.split('\n')
131
+ const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()))
132
+ if (start === -1) return null
133
+ const items: string[] = []
134
+ for (const rawLine of lines.slice(start + 1)) {
135
+ const line = rawLine.trim()
136
+ if (line === '' || line.startsWith('<!--')) continue
137
+ if (/^#{1,6}[ \t]/.test(line)) break // next subsection — summary ended
138
+ if (!/^[-*][ \t]/.test(line)) continue
139
+ if (items.length >= WHATS_NEW_SUMMARY_MAX_ITEMS) break
140
+ const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ''))
141
+ if (content === '') continue
142
+ items.push(
143
+ content.length > WHATS_NEW_ITEM_MAX_CHARS
144
+ ? `${content.slice(0, WHATS_NEW_ITEM_MAX_CHARS - 1)}…`
145
+ : content,
146
+ )
147
+ }
148
+ return items.length > 0 ? items : null
149
+ }
150
+
151
+ /**
152
+ * Extract the release highlights for `version`. When the section carries a
153
+ * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
154
+ * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
155
+ * dialog); otherwise it falls back to the H3-group extraction bounded to
156
+ * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
157
+ * blank changelog all return EMPTY_HIGHLIGHTS (no window).
158
+ */
159
+ export function extractHighlights(changelogText: string, version: string): WhatsNewHighlights {
160
+ const { found, body } = extractSection(changelogText ?? '', version ?? '')
161
+ if (!found || !body) return { ...EMPTY_HIGHLIGHTS }
162
+
163
+ const summary = extractWhatsNewSummary(body)
164
+ if (summary !== null) {
165
+ return {
166
+ version: String(version).trim().replace(/^v/i, ''),
167
+ found: true,
168
+ groups: [{ heading: null, items: summary }],
169
+ totalItems: summary.length,
170
+ truncated: false,
171
+ }
172
+ }
173
+
174
+ const groups: WhatsNewGroup[] = []
175
+ let totalItems = 0
176
+ let truncated = false
177
+
178
+ for (const rawLine of body.split('\n')) {
179
+ const line = rawLine.trim()
180
+ if (line === '' || line.startsWith('<!--')) continue
181
+
182
+ if (/^#{1,6}[ \t]/.test(line)) {
183
+ const heading = stripMarkdown(stripHeading(line))
184
+ if (heading === '') continue
185
+ if (groups.at(-1)?.items.length === 0) groups.pop() // empty group boundary
186
+ groups.push({ heading, items: [] })
187
+ continue
188
+ }
189
+
190
+ if (totalItems >= WHATS_NEW_MAX_ITEMS) {
191
+ // Keep scanning only to count the remainder for the "+N more" line.
192
+ if (/^[-*][ \t]/.test(line)) totalItems += 1
193
+ continue
194
+ }
195
+
196
+ const isBullet = /^[-*][ \t]/.test(line)
197
+ const continuation = (groups.at(-1)?.items.length ?? 0) > 0
198
+ if (!isBullet && !continuation) continue // prose between groups — not a highlight
199
+
200
+ const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, '') : line)
201
+ if (content === '') continue
202
+ const bounded =
203
+ content.length > WHATS_NEW_ITEM_MAX_CHARS
204
+ ? `${content.slice(0, WHATS_NEW_ITEM_MAX_CHARS - 1)}…`
205
+ : content
206
+ const group = groups.at(-1)
207
+ if (group === undefined) {
208
+ groups.push({ heading: null, items: [bounded] })
209
+ } else if (isBullet || group.items.length === 0) {
210
+ group.items.push(bounded)
211
+ } else {
212
+ group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim()
213
+ }
214
+ if (isBullet) totalItems += 1
215
+ }
216
+
217
+ const kept = groups.filter((group) => group.items.length > 0)
218
+ truncated = totalItems > WHATS_NEW_MAX_ITEMS
219
+ return {
220
+ version: found ? String(version).trim().replace(/^v/i, '') : null,
221
+ found,
222
+ groups: kept,
223
+ totalItems,
224
+ truncated,
225
+ }
226
+ }
227
+
228
+ /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
229
+ export function whatsNewTitle(version: string): string {
230
+ return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, '')}`
231
+ }
232
+
233
+ /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
234
+ export function whatsNewLines(highlights: WhatsNewHighlights): string[] {
235
+ const lines: string[] = []
236
+ for (const group of highlights.groups) {
237
+ if (group.heading !== null) lines.push(group.heading)
238
+ for (const item of group.items) lines.push(`• ${item}`)
239
+ }
240
+ if (highlights.truncated) {
241
+ const hidden = Math.max(0, highlights.totalItems - WHATS_NEW_MAX_ITEMS)
242
+ if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`)
243
+ }
244
+ return lines
245
+ }
246
+
247
+ /**
248
+ * Candidate CHANGELOG.md locations for a bundle, first readable wins:
249
+ * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
250
+ * shipped by both installers next to package.json);
251
+ * 2. the package root (dev checkout; also an npm-package install when the
252
+ * bundle runs from `<pkg>/src/plugins/tui/dist/`).
253
+ */
254
+ export function changelogCandidates(bundlePath: string): string[] {
255
+ const dist = dirname(bundlePath)
256
+ const copyRoot = dirname(dist)
257
+ // The second leg targets the package root: src/plugins/tui → plugins → src
258
+ // → package root (dev checkout / npm-package install). On an installed copy
259
+ // the same three levels land on the XDG base, where no CHANGELOG lives —
260
+ // harmless, the copy-root candidate is the one the installers ship.
261
+ const packageRoot = dirname(dirname(dirname(copyRoot)))
262
+ return [join(copyRoot, 'CHANGELOG.md'), join(packageRoot, 'CHANGELOG.md')]
263
+ }
264
+
265
+ /** Read the first existing candidate; null when none is readable (no window). */
266
+ export async function readChangelogForBundle(bundleUrl: string): Promise<string | null> {
267
+ try {
268
+ const bundlePath = fileURLToPath(bundleUrl)
269
+ for (const candidate of changelogCandidates(bundlePath)) {
270
+ try {
271
+ return await readFile(candidate, 'utf8')
272
+ } catch {}
273
+ }
274
+ return null
275
+ } catch {
276
+ return null
277
+ }
278
+ }
279
+
280
+ /** Build-time embedded version (tsdown `define` in tsdown.config.ts). */
281
+ declare const __PANTHEON_VERSION__: string | undefined
282
+
283
+ /** The ambient build-time version, or null outside a tsdown build. */
284
+ export function embeddedVersion(): string | null {
285
+ return typeof __PANTHEON_VERSION__ !== 'undefined' && __PANTHEON_VERSION__
286
+ ? __PANTHEON_VERSION__
287
+ : null
288
+ }
289
+
290
+ /**
291
+ * Resolve the running Pantheon version for the what's-new window: the plugin
292
+ * copy's own package.json first (the copy root two levels above the bundle,
293
+ * then the package root four levels above — the same legs as the V1 sidebar's
294
+ * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
295
+ * nothing resolves → no window (fail-open).
296
+ */
297
+ export async function resolveRunningVersion(
298
+ bundleUrl: string,
299
+ embedded: string | null = embeddedVersion(),
300
+ ): Promise<string | null> {
301
+ try {
302
+ const bundlePath = fileURLToPath(bundleUrl)
303
+ const dist = dirname(bundlePath)
304
+ for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) {
305
+ try {
306
+ const raw = await readFile(join(root, 'package.json'), 'utf8')
307
+ const parsed = JSON.parse(raw) as { version?: unknown }
308
+ if (typeof parsed.version === 'string' && parsed.version.trim() !== '') {
309
+ return parsed.version
310
+ }
311
+ } catch {}
312
+ }
313
+ } catch {
314
+ /* fall through to the embed */
315
+ }
316
+ return embedded
317
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * whats-new-open.ts — the show-once decision for the "What's new" window.
3
+ *
4
+ * Plain data in, plain data out: the entrypoints (index.tsx / index-v2.tsx)
5
+ * resolve the running version and the shipped CHANGELOG.md, then hand this
6
+ * module a `show` callback that renders the view data through the host's
7
+ * dialog API. Keeping the decision JSX-free makes the whole one-time flow
8
+ * testable offline (node strips the types natively) — the Solid glue lives in
9
+ * whats-new.tsx.
10
+ *
11
+ * Contract (pinned by tests/tui-whats-new.test.mjs):
12
+ * - shows at most once per version: dismissal marks the version seen;
13
+ * - nothing to show (no version, missing CHANGELOG, empty section) → no
14
+ * window AND no pin — the next start may still show it;
15
+ * - never throws on its own inputs; I/O failures inside the state module
16
+ * are fail-open there.
17
+ */
18
+ import {
19
+ EMPTY_HIGHLIGHTS,
20
+ extractHighlights,
21
+ type WhatsNewHighlights,
22
+ whatsNewLines,
23
+ whatsNewTitle,
24
+ } from './whats-new-highlights.ts'
25
+ import { markSeenWhatsNew, shouldShowWhatsNew } from './whats-new-state.ts'
26
+
27
+ /** Muted footer hint teaching the dismiss bind (Portuguese, like the sidebar). */
28
+ export const WHATS_NEW_CLOSE_HINT = 'esc/q fechar'
29
+
30
+ /** Hint variant when the highlights span more than one page. */
31
+ export const WHATS_NEW_PAGES_HINT = 'esc/q fechar · n próxima · p volta'
32
+
33
+ /** The CHANGELOG pointer shown under the highlights (the window summarizes; the file is complete). */
34
+ export const WHATS_NEW_MORE_HINT = 'CHANGELOG completo: CHANGELOG.md no pacote'
35
+
36
+ /** Rows per page — bounded so no changelog can overflow the terminal. */
37
+ export const WHATS_NEW_PAGE_SIZE = 14
38
+
39
+ /** Hard-wrap one display line into rows of at most `width` columns (>= 10). */
40
+ export function wrapWhatsNewLine(line: string, width: number): string[] {
41
+ const bounded = Number.isInteger(width) && width > 10 ? width : 76
42
+ const text = String(line)
43
+ if (text.length <= bounded) return [text]
44
+ const rows: string[] = []
45
+ let rest = text
46
+ while (rest.length > bounded) {
47
+ rows.push(rest.slice(0, bounded))
48
+ rest = rest.slice(bounded)
49
+ }
50
+ if (rest.length > 0) rows.push(rest)
51
+ return rows
52
+ }
53
+
54
+ /** Slice display lines into fixed-size pages (>= 1 page, empty-safe). */
55
+ export function paginateWhatsNewLines(
56
+ lines: string[],
57
+ pageSize: number = WHATS_NEW_PAGE_SIZE,
58
+ ): string[][] {
59
+ const size = Number.isInteger(pageSize) && pageSize > 0 ? pageSize : WHATS_NEW_PAGE_SIZE
60
+ if (lines.length === 0) return [[]]
61
+ const pages: string[][] = []
62
+ for (let i = 0; i < lines.length; i += size) pages.push(lines.slice(i, i + size))
63
+ return pages
64
+ }
65
+
66
+ /** Everything the window needs to render — no host types, no JSX. */
67
+ export interface WhatsNewViewData {
68
+ version: string
69
+ title: string
70
+ lines: string[]
71
+ /** Fixed-size pages of `lines` (single page when the highlights are short). */
72
+ pages: string[][]
73
+ hint: string
74
+ }
75
+
76
+ export type WhatsNewShowFn = (render: () => WhatsNewViewData, onClose: () => void) => void
77
+
78
+ export interface WhatsNewOpenInput {
79
+ /** Running Pantheon version (null when unresolvable → no window). */
80
+ version: string | null
81
+ /** Path of the seen-version state file (see whats-new-state.ts). */
82
+ statePath: string
83
+ /** Shipped CHANGELOG.md content, or null when unreadable. */
84
+ changelogText: string | null
85
+ /** Host dialog opener; `onClose` fires on host dismissal (ESC / chrome). */
86
+ show: WhatsNewShowFn
87
+ }
88
+
89
+ /**
90
+ * Open the one-time window when the version changed and highlights exist.
91
+ * Returns true when the window was shown; the caller's `onClose` callback
92
+ * (both host-initiated and local close binds) must funnel into marking seen.
93
+ */
94
+ export async function openWhatsNew(input: WhatsNewOpenInput): Promise<boolean> {
95
+ const { version, statePath, changelogText, show } = input
96
+ if (typeof version !== 'string' || version.trim() === '') return false
97
+ if (!(await shouldShowWhatsNew(version, statePath))) return false
98
+
99
+ const highlights: WhatsNewHighlights = changelogText
100
+ ? extractHighlights(changelogText, version)
101
+ : { ...EMPTY_HIGHLIGHTS }
102
+ const lines = whatsNewLines(highlights)
103
+ if (lines.length === 0) return false
104
+
105
+ const pages = paginateWhatsNewLines(lines)
106
+ const data: WhatsNewViewData = {
107
+ version,
108
+ title: whatsNewTitle(version),
109
+ lines,
110
+ pages,
111
+ hint: pages.length > 1 ? WHATS_NEW_PAGES_HINT : WHATS_NEW_CLOSE_HINT,
112
+ }
113
+ show(
114
+ () => data,
115
+ () => {
116
+ void markSeenWhatsNew(version, statePath)
117
+ },
118
+ )
119
+ return true
120
+ }