pantheon-opencode 2.0.0-beta.6 → 2.0.0-rc.1

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 (58) hide show
  1. package/AGENTS.global.md +6 -1
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +45 -0
  4. package/README.md +169 -510
  5. package/README.pt-BR.md +177 -149
  6. package/bin/pantheon-init.mjs +1 -1
  7. package/commands/pantheon-deepwork.md +6 -1
  8. package/commands/pantheon.md +10 -5
  9. package/package.json +1 -1
  10. package/plugin.json +2 -2
  11. package/prompts/orchestrate-with-zeus.prompt.md +82 -290
  12. package/prompts/subtask.prompt.md +1 -1
  13. package/pyproject.toml +1 -1
  14. package/scripts/doctor.mjs +27 -11
  15. package/scripts/hooks/format-multi-language.sh +30 -48
  16. package/scripts/jev-live-probe.mjs +1 -1
  17. package/scripts/release-gates.mjs +19 -5
  18. package/scripts/skill-search.mjs +27 -3
  19. package/scripts/test-opencode-sandbox.sh +44 -15
  20. package/scripts/update.mjs +9 -2
  21. package/skills-lock.json +5 -3
  22. package/src/agents/aphrodite.md +2 -0
  23. package/src/agents/apollo.md +8 -206
  24. package/src/agents/athena.md +25 -29
  25. package/src/agents/hermes.md +3 -1
  26. package/src/agents/mnemosyne.md +1 -1
  27. package/src/agents/nyx.md +1 -1
  28. package/src/agents/prometheus.md +0 -203
  29. package/src/agents/talos.md +2 -0
  30. package/src/agents/themis.md +8 -3
  31. package/src/agents/zeus.md +18 -12
  32. package/src/instructions/memory-protocol.instructions.md +4 -0
  33. package/src/instructions/test-economy.instructions.md +1 -0
  34. package/src/instructions/zeus-council-synthesis.instructions.md +13 -1
  35. package/src/pantheon/pantheon-decision-catalog.ts +8 -0
  36. package/src/pantheon/skill-search-tool.ts +193 -0
  37. package/src/pantheon/tools.ts +2 -0
  38. package/src/plugins/tui/dist/tui.d.ts +12 -2
  39. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  40. package/src/plugins/tui/dist/tui.js +980 -358
  41. package/src/plugins/tui/dist/tui.js.map +1 -1
  42. package/src/plugins/tui/package-lock.json +2 -2
  43. package/src/plugins/tui/package.json +1 -1
  44. package/src/plugins/tui/src/autonomy-state.ts +1 -1
  45. package/src/plugins/tui/src/context-gauge.ts +64 -5
  46. package/src/plugins/tui/src/decision-router-state.ts +49 -2
  47. package/src/plugins/tui/src/index.tsx +25 -3
  48. package/src/plugins/tui/src/pantheon-settings-state.ts +99 -0
  49. package/src/plugins/tui/src/pantheon-settings.tsx +391 -101
  50. package/src/plugins/tui/src/tui-prefs.ts +161 -9
  51. package/src/plugins/tui/src/update-status.ts +27 -8
  52. package/src/routing.yml +9 -0
  53. package/src/skills/README.md +35 -25
  54. package/src/skills/fast-path-execution/SKILL.md +54 -0
  55. package/src/skills/prompt-refinery/SKILL.md +51 -65
  56. package/src/skills/tdd-with-agents/SKILL.md +22 -10
  57. package/src/skills/test-slicing/SKILL.md +56 -0
  58. package/src/skills/verification-planning/SKILL.md +4 -3
@@ -11,6 +11,38 @@ import { fileURLToPath } from "node:url";
11
11
  const CONTEXT_BAR_CELLS = 12;
12
12
  const CONTEXT_BAR_FILLED_CELL = "▰";
13
13
  const CONTEXT_BAR_EMPTY_CELL = "▱";
14
+ const BAR_SHAPES = {
15
+ block: {
16
+ filled: "▰",
17
+ empty: "▱",
18
+ mark: "│"
19
+ },
20
+ line: {
21
+ filled: "━",
22
+ empty: "─",
23
+ mark: "┼"
24
+ },
25
+ smooth: {
26
+ filled: "█",
27
+ empty: "░",
28
+ mark: "┆"
29
+ },
30
+ ascii: {
31
+ filled: "=",
32
+ empty: "-",
33
+ mark: "|"
34
+ },
35
+ dots: {
36
+ filled: "●",
37
+ empty: "○",
38
+ mark: "│"
39
+ },
40
+ braille: {
41
+ filled: "⣿",
42
+ empty: "⣀",
43
+ mark: "⡇"
44
+ }
45
+ };
14
46
  function numberOrNull$1(value) {
15
47
  return typeof value === "number" && Number.isFinite(value) ? value : null;
16
48
  }
@@ -38,14 +70,34 @@ function contextBarFilled(percent, cells = 12) {
38
70
  if (!Number.isFinite(filled)) return 0;
39
71
  return Math.min(total, Math.max(0, filled));
40
72
  }
41
- function contextBar(percent, cells = 12) {
73
+ function contextBar(percent, options = 12) {
42
74
  const value = numberOrNull$1(percent);
43
75
  if (value === null) return null;
44
- const total = Math.max(1, Math.floor(cells));
45
- const filled = contextBarFilled(value, total);
76
+ const total = Math.max(1, Math.floor(typeof options === "number" ? options : options?.cells ?? 12));
77
+ const shapeKey = typeof options === "object" && options?.shape && options.shape in BAR_SHAPES ? options.shape : "block";
78
+ const glyphs = BAR_SHAPES[shapeKey] ?? BAR_SHAPES.block;
79
+ const evenMark = typeof options === "object" ? Boolean(options?.evenMark) : false;
80
+ const filledCount = contextBarFilled(value, total);
81
+ const emptyCount = total - filledCount;
82
+ if (!evenMark || total < 4) return {
83
+ filled: glyphs.filled.repeat(filledCount),
84
+ empty: glyphs.empty.repeat(emptyCount)
85
+ };
86
+ const mid = Math.floor(total / 2);
87
+ const mark = glyphs.mark ?? "|";
88
+ if (filledCount <= mid) {
89
+ const emptyBefore = mid - filledCount;
90
+ const emptyAfter = Math.max(0, emptyCount - emptyBefore - 1);
91
+ return {
92
+ filled: glyphs.filled.repeat(filledCount),
93
+ empty: `${glyphs.empty.repeat(emptyBefore)}${mark}${glyphs.empty.repeat(emptyAfter)}`
94
+ };
95
+ }
96
+ const filledBefore = mid;
97
+ const filledAfter = Math.max(0, filledCount - filledBefore - 1);
46
98
  return {
47
- filled: "▰".repeat(filled),
48
- empty: "▱".repeat(total - filled)
99
+ filled: `${glyphs.filled.repeat(filledBefore)}${mark}${glyphs.filled.repeat(filledAfter)}`,
100
+ empty: glyphs.empty.repeat(emptyCount)
49
101
  };
50
102
  }
51
103
  function formatSpent(cost) {
@@ -414,7 +466,31 @@ function applyDecisionRow(config, id, value) {
414
466
  default: return config;
415
467
  }
416
468
  }
417
- function buildDecisionTab(read, env = process.env) {
469
+ /** Provider ids as they appear in the host auth store / config providers. */
470
+ const PROVIDER_AUTH_NAMES = Object.freeze({
471
+ "openai-decisions": Object.freeze(["openai"]),
472
+ "typesafe-jev": Object.freeze(["typesafe-ai"]),
473
+ "opencode-console-jev": Object.freeze([]),
474
+ "openrouter-jev": Object.freeze(["openrouter"]),
475
+ "vercel-gateway-jev": Object.freeze(["vercel-ai-gateway", "vercel"]),
476
+ "cloudflare-workers-jev": Object.freeze(["cloudflare-workers-ai"])
477
+ });
478
+ /**
479
+ * TWO recognition forms (field feedback beta.6: keys registered via
480
+ * `opencode auth login` showed MISSING because only env vars were checked):
481
+ * env var set → 'env'; provider present in the host auth store → 'auth
482
+ * store'; provider entry in opencode.json providers → 'config'. Values are
483
+ * NEVER read — existence only.
484
+ */
485
+ function credentialStatus(provider, env, authProviders, configProviders) {
486
+ const credential = DECISION_PROVIDER_CREDENTIALS[provider];
487
+ if (credential?.env !== void 0 && env[credential.env]) return "env";
488
+ for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) if (authProviders.has(name)) return "auth store";
489
+ for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) if (configProviders.has(name)) return "config";
490
+ if (provider === "opencode-console-jev") return "auth store";
491
+ return "missing";
492
+ }
493
+ function buildDecisionTab(read, env = process.env, authProviders = /* @__PURE__ */ new Set(), configProviders = /* @__PURE__ */ new Set()) {
418
494
  const { config, corrupt } = read;
419
495
  const rows = [{
420
496
  id: "decision.enabled",
@@ -458,12 +534,12 @@ function buildDecisionTab(read, env = process.env) {
458
534
  }, {
459
535
  title: "Credentials (status only — values never enter the window)",
460
536
  rows: DECISION_KNOWN_PROVIDERS.map((provider) => {
537
+ const status = credentialStatus(provider, env, authProviders, configProviders);
461
538
  const credential = DECISION_PROVIDER_CREDENTIALS[provider] ?? { note: "" };
462
- const isSet = credential.env === void 0 ? true : Boolean(env[credential.env]);
463
539
  return {
464
540
  id: `decision.key.${provider}`,
465
541
  name: provider,
466
- value: credential.env === void 0 ? "n/a" : isSet ? "set" : "MISSING",
542
+ value: status === "missing" ? "MISSING" : status,
467
543
  note: credential.note
468
544
  };
469
545
  })
@@ -602,6 +678,45 @@ function stageValue(draft, row, direction) {
602
678
  [row.id]: staged
603
679
  };
604
680
  }
681
+ /** Stage an explicit target value for one row (the Defaults action path). */
682
+ function stageRowToValue(draft, row, target) {
683
+ if (!row.cycle?.includes(target)) return draft;
684
+ if (target === row.value) {
685
+ if (draft[row.id] === void 0) return draft;
686
+ const next = { ...draft };
687
+ delete next[row.id];
688
+ return next;
689
+ }
690
+ return {
691
+ ...draft,
692
+ [row.id]: target
693
+ };
694
+ }
695
+ /**
696
+ * Stage every cyclable row's DEFAULT value of a tab. Rows already at their
697
+ * default have their staged entry dropped; rows staged elsewhere keep it
698
+ * until the Defaults action targets them.
699
+ */
700
+ function stageDefaults(draft, tab) {
701
+ let next = draft;
702
+ for (const row of tabRows(tab)) {
703
+ if (row.cycle === void 0 || row.def === void 0) continue;
704
+ const candidate = next[row.id] ?? row.value;
705
+ if (candidate === row.def) {
706
+ if (next[row.id] !== void 0) {
707
+ const copy = { ...next };
708
+ delete copy[row.id];
709
+ next = copy;
710
+ }
711
+ continue;
712
+ }
713
+ next = stageRowToValue(next, {
714
+ ...row,
715
+ value: candidate
716
+ }, row.def);
717
+ }
718
+ return next;
719
+ }
605
720
  /** Drop every staged entry of one tab (ctrl+r). */
606
721
  function resetTab(draft, tab) {
607
722
  const ids = new Set(tabRows(tab).map((row) => row.id));
@@ -686,6 +801,44 @@ function buildAboutTab(version) {
686
801
  }] }]
687
802
  };
688
803
  }
804
+ function buildChangelogTab(version, items = []) {
805
+ const rows = [];
806
+ if (items.length > 0) items.forEach((item, index) => {
807
+ rows.push({
808
+ id: `changelog.item.${index + 1}`,
809
+ name: item.title.slice(0, 26),
810
+ value: item.detail.length > 20 ? `${item.detail.slice(0, 19)}…` : item.detail,
811
+ note: item.detail
812
+ });
813
+ });
814
+ else rows.push({
815
+ id: "changelog.info",
816
+ name: "Release",
817
+ value: `v${version}`,
818
+ note: "view full history in CHANGELOG.md or GitHub releases"
819
+ });
820
+ return {
821
+ id: "changelog",
822
+ title: "Changelog",
823
+ groups: [{
824
+ title: `What's New in v${version}`,
825
+ rows
826
+ }, {
827
+ title: "Release References",
828
+ rows: [{
829
+ id: "changelog.docs",
830
+ name: "Documentation",
831
+ value: "CHANGELOG.md",
832
+ note: "shipped at plugin root and repository root"
833
+ }, {
834
+ id: "changelog.repo",
835
+ name: "GitHub Repository",
836
+ value: "ils15/pantheon-opencode",
837
+ note: "releases, pull requests and discussion"
838
+ }]
839
+ }]
840
+ };
841
+ }
689
842
  /** Semver-ish compare for X.Y.Z[-beta.N]; betas sort before their release. */
690
843
  function comparePantheonVersions(left, right) {
691
844
  const parse = (version) => {
@@ -1049,12 +1202,23 @@ function initTuiPrefs(context) {
1049
1202
  if (stash() !== void 0) return;
1050
1203
  try {
1051
1204
  const handle = context.storage?.store?.("tui-prefs", { initial: DEFAULT_TUI_PREFS });
1052
- if (handle !== void 0) globalThis[PREFS_SYMBOL] = handle;
1205
+ if (handle !== void 0) {
1206
+ globalThis[PREFS_SYMBOL] = handle;
1207
+ if (!handle[0]?.layout) handle[1]((draft) => {
1208
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1209
+ }).catch(() => {});
1210
+ }
1053
1211
  } catch {}
1054
1212
  }
1055
1213
  /** The live reactive prefs (read properties inside memos/JSX — tracked). */
1056
1214
  function tuiPrefs() {
1057
- return stash()?.[0] ?? DEFAULT_TUI_PREFS;
1215
+ const s = stash()?.[0];
1216
+ if (!s) return DEFAULT_TUI_PREFS;
1217
+ if (!s.layout) return {
1218
+ ...s,
1219
+ layout: DEFAULT_TUI_PREFS.layout
1220
+ };
1221
+ return s;
1058
1222
  }
1059
1223
  /** Stage a mutation against the durable store; resolves when persisted. */
1060
1224
  function mutateTuiPrefs(mutation) {
@@ -1069,8 +1233,33 @@ const GAUGE_STYLES = Object.freeze([
1069
1233
  "off"
1070
1234
  ]);
1071
1235
  const ENABLED_CYCLE = Object.freeze(["enabled", "disabled"]);
1236
+ const BAR_SHAPES_CYCLE = Object.freeze([
1237
+ "line",
1238
+ "block",
1239
+ "smooth",
1240
+ "ascii",
1241
+ "dots",
1242
+ "braille"
1243
+ ]);
1244
+ const BAR_WIDTHS_CYCLE = Object.freeze([
1245
+ "standard",
1246
+ "compact",
1247
+ "wide",
1248
+ "full"
1249
+ ]);
1250
+ const LAYOUT_PRESETS_CYCLE = Object.freeze(["comfortable", "compact"]);
1251
+ const SEPARATOR_STYLES_CYCLE = Object.freeze([
1252
+ "spaces",
1253
+ "pipes",
1254
+ "dots",
1255
+ "slashes"
1256
+ ]);
1072
1257
  const DEFAULT_TUI_PREFS = {
1073
1258
  version: 1,
1259
+ layout: {
1260
+ preset: "comfortable",
1261
+ separator: "spaces"
1262
+ },
1074
1263
  sidebar: {
1075
1264
  header: {
1076
1265
  version: true,
@@ -1085,6 +1274,9 @@ const DEFAULT_TUI_PREFS = {
1085
1274
  },
1086
1275
  context: {
1087
1276
  gauge: "both",
1277
+ barShape: "line",
1278
+ barWidth: "standard",
1279
+ evenMark: false,
1088
1280
  tokens: true,
1089
1281
  spent: true,
1090
1282
  modelUsage: true,
@@ -1110,6 +1302,49 @@ function buildTuiTab(prefs) {
1110
1302
  id: "tui",
1111
1303
  title: "TUI",
1112
1304
  groups: [
1305
+ {
1306
+ title: "Preset & Layout",
1307
+ rows: [{
1308
+ id: "tui.layout.preset",
1309
+ name: "Layout preset",
1310
+ value: prefs.layout?.preset ?? DEFAULT_TUI_PREFS.layout.preset,
1311
+ cycle: LAYOUT_PRESETS_CYCLE,
1312
+ note: "comfortable | compact — sets spacing & borders"
1313
+ }, {
1314
+ id: "tui.layout.separator",
1315
+ name: "Separator",
1316
+ value: prefs.layout?.separator ?? DEFAULT_TUI_PREFS.layout.separator,
1317
+ cycle: SEPARATOR_STYLES_CYCLE,
1318
+ note: "spaces | pipes | dots | slashes — status line glyphs"
1319
+ }]
1320
+ },
1321
+ {
1322
+ title: "Bars & Gauges",
1323
+ rows: [
1324
+ {
1325
+ id: "tui.sidebar.context.barShape",
1326
+ name: "Bar shape",
1327
+ value: prefs.sidebar.context.barShape,
1328
+ cycle: BAR_SHAPES_CYCLE,
1329
+ note: "line (━─) | block (▰▱) | smooth (█░) | ascii (=) | dots (●○) | braille"
1330
+ },
1331
+ {
1332
+ id: "tui.sidebar.context.barWidth",
1333
+ name: "Bar width",
1334
+ value: prefs.sidebar.context.barWidth,
1335
+ cycle: BAR_WIDTHS_CYCLE,
1336
+ note: "standard (12) | compact (8) | wide (16) | full (20 cells)"
1337
+ },
1338
+ row("tui.sidebar.context.evenMark", "Even-use mark", prefs.sidebar.context.evenMark, "| indicator at 50% midpoint in gauge bars"),
1339
+ {
1340
+ id: "tui.sidebar.context.gauge",
1341
+ name: "Gauge style",
1342
+ value: prefs.sidebar.context.gauge,
1343
+ cycle: GAUGE_STYLES,
1344
+ note: "both | bar | percent | off — `▰▱ 42% of 200k`"
1345
+ }
1346
+ ]
1347
+ },
1113
1348
  {
1114
1349
  title: "Sidebar header",
1115
1350
  rows: [
@@ -1130,13 +1365,6 @@ function buildTuiTab(prefs) {
1130
1365
  {
1131
1366
  title: "Context block detail",
1132
1367
  rows: [
1133
- {
1134
- id: "tui.sidebar.context.gauge",
1135
- name: "Gauge style",
1136
- value: prefs.sidebar.context.gauge,
1137
- cycle: GAUGE_STYLES,
1138
- note: "both | bar | percent | off — `▰▱ 42% of 200k`"
1139
- },
1140
1368
  row("tui.sidebar.context.tokens", "Tokens row", prefs.sidebar.context.tokens, "the raw token count line"),
1141
1369
  row("tui.sidebar.context.spent", "Spent row", prefs.sidebar.context.spent, "the `$… gasto na sessão` line"),
1142
1370
  row("tui.sidebar.context.modelUsage", "Model usage table", prefs.sidebar.context.modelUsage, "per-model tokens/USD"),
@@ -1158,6 +1386,27 @@ function buildTuiTab(prefs) {
1158
1386
  function applyTuiRow(draft, id, value) {
1159
1387
  const enabled = value === "enabled";
1160
1388
  switch (id) {
1389
+ case "tui.layout.preset":
1390
+ if (LAYOUT_PRESETS_CYCLE.includes(value)) {
1391
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1392
+ draft.layout.preset = value;
1393
+ }
1394
+ return;
1395
+ case "tui.layout.separator":
1396
+ if (SEPARATOR_STYLES_CYCLE.includes(value)) {
1397
+ if (!draft.layout) draft.layout = { ...DEFAULT_TUI_PREFS.layout };
1398
+ draft.layout.separator = value;
1399
+ }
1400
+ return;
1401
+ case "tui.sidebar.context.barShape":
1402
+ if (BAR_SHAPES_CYCLE.includes(value)) draft.sidebar.context.barShape = value;
1403
+ return;
1404
+ case "tui.sidebar.context.barWidth":
1405
+ if (BAR_WIDTHS_CYCLE.includes(value)) draft.sidebar.context.barWidth = value;
1406
+ return;
1407
+ case "tui.sidebar.context.evenMark":
1408
+ draft.sidebar.context.evenMark = enabled;
1409
+ return;
1161
1410
  case "tui.sidebar.header.version":
1162
1411
  draft.sidebar.header.version = enabled;
1163
1412
  return;
@@ -1227,13 +1476,16 @@ function formatAgo(ms) {
1227
1476
  }
1228
1477
  function buildUpdatesTab(input) {
1229
1478
  const nowMs = input.nowMs ?? Date.now();
1230
- const channel = updateChannelFor(input.currentVersion);
1479
+ const channel = input.selectedChannel ?? updateChannelFor(input.currentVersion);
1231
1480
  const lastCheckMs = input.state.lastCheckMs;
1232
1481
  const latest = input.lastCheckedVersion ?? input.state.lastNotifiedVersion;
1482
+ const stable = (version) => !/-beta\.\d+$/.test(version);
1483
+ const newer = latest !== void 0 && comparePantheonVersions(latest, input.currentVersion) > 0 && !(stable(input.currentVersion) && !stable(latest));
1233
1484
  const rows = [{
1234
1485
  id: "update.channel",
1235
1486
  name: "Channel",
1236
1487
  value: channel,
1488
+ cycle: ["stable", "beta"],
1237
1489
  note: "stable tracks npm `latest`; beta tracks npm `beta`"
1238
1490
  }, {
1239
1491
  id: "update.check",
@@ -1243,24 +1495,243 @@ function buildUpdatesTab(input) {
1243
1495
  note: "enter probes the registry for the running channel"
1244
1496
  }];
1245
1497
  if (latest) {
1246
- const stable = (version) => !/-beta\.\d+$/.test(version);
1247
- const newer = comparePantheonVersions(latest, input.currentVersion) > 0 && !(stable(input.currentVersion) && !stable(latest));
1248
1498
  rows.push({
1249
1499
  id: "update.latest",
1250
1500
  name: "Registry",
1251
1501
  value: newer ? `v${latest} available` : "up to date",
1252
1502
  note: newer ? "adopt with `pantheon-opencode update`" : "no newer compatible version"
1253
1503
  });
1504
+ rows.push({
1505
+ id: "update.run",
1506
+ name: "Update now",
1507
+ value: input.updating ? "updating…" : newer ? `install v${latest}` : "reinstall / refresh",
1508
+ action: "update-run",
1509
+ note: newer ? "enter runs `pantheon-opencode update`" : "enter refreshes installed copy"
1510
+ });
1254
1511
  }
1512
+ rows.push({
1513
+ id: "update.command",
1514
+ name: "CLI command",
1515
+ value: channel === "beta" ? "pantheon-opencode update" : "pantheon-opencode update --stable",
1516
+ note: "run in terminal or OpenCode Desktop terminal"
1517
+ });
1255
1518
  return {
1256
1519
  id: "updates",
1257
1520
  title: "Updates",
1258
1521
  groups: [{
1259
- title: "Updates",
1522
+ title: "Updates & Maintenance",
1260
1523
  rows
1261
1524
  }]
1262
1525
  };
1263
1526
  }
1527
+ /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
1528
+ const WHATS_NEW_MORE_PREFIX = "… +";
1529
+ const EMPTY_HIGHLIGHTS = {
1530
+ version: null,
1531
+ found: false,
1532
+ groups: [],
1533
+ totalItems: 0,
1534
+ truncated: false
1535
+ };
1536
+ /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
1537
+ function escapeRegExp(text) {
1538
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1539
+ }
1540
+ /**
1541
+ * Extract the body of a version section from changelog text — inline replica
1542
+ * of scripts/changelog-extract.mjs `extractSection` (see that file for the
1543
+ * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
1544
+ * optional, `## [Unreleased]` never matched).
1545
+ */
1546
+ function extractSection(changelogText, version) {
1547
+ const normalized = String(version).trim().replace(/^v/i, "");
1548
+ if (!normalized || /^unreleased$/i.test(normalized)) return {
1549
+ found: false,
1550
+ body: null
1551
+ };
1552
+ const escaped = escapeRegExp(normalized);
1553
+ const match = new RegExp(`^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`, "m").exec(changelogText);
1554
+ if (!match) return {
1555
+ found: false,
1556
+ body: null
1557
+ };
1558
+ const newline = changelogText.indexOf("\n", match.index);
1559
+ const start = newline === -1 ? changelogText.length : newline + 1;
1560
+ const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start));
1561
+ const end = nextHeading ? start + nextHeading.index : changelogText.length;
1562
+ return {
1563
+ found: true,
1564
+ body: changelogText.slice(start, end).trim()
1565
+ };
1566
+ }
1567
+ /**
1568
+ * Reduce one markdown line to plain text: links keep their label, emphasis
1569
+ * and inline-code markers are dropped, HTML comment fragments are removed,
1570
+ * and whitespace collapses. Deliberately simple — the input is our own
1571
+ * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
1572
+ */
1573
+ function stripMarkdown(text) {
1574
+ return text.replace(/<!--[\s\S]*?-->/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/(\*\*|__)/g, "").replace(/`/g, "").replace(/\s+/g, " ").trim();
1575
+ }
1576
+ /** Strip the leading H3 marker (`### Added` → `Added`). */
1577
+ function stripHeading(text) {
1578
+ return text.replace(/^#{1,6}[ \t]+/, "").trim();
1579
+ }
1580
+ /**
1581
+ * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
1582
+ * from a section body: its bullets only, each truncated to
1583
+ * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
1584
+ * the section carries no summary block (the full-section fallback applies).
1585
+ */
1586
+ function extractWhatsNewSummary(body) {
1587
+ const lines = body.split("\n");
1588
+ const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()));
1589
+ if (start === -1) return null;
1590
+ const items = [];
1591
+ for (const rawLine of lines.slice(start + 1)) {
1592
+ const line = rawLine.trim();
1593
+ if (line === "" || line.startsWith("<!--")) continue;
1594
+ if (/^#{1,6}[ \t]/.test(line)) break;
1595
+ if (!/^[-*][ \t]/.test(line)) continue;
1596
+ if (items.length >= 6) break;
1597
+ const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ""));
1598
+ if (content === "") continue;
1599
+ items.push(content.length > 140 ? `${content.slice(0, 139)}…` : content);
1600
+ }
1601
+ return items.length > 0 ? items : null;
1602
+ }
1603
+ /**
1604
+ * Extract the release highlights for `version`. When the section carries a
1605
+ * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
1606
+ * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
1607
+ * dialog); otherwise it falls back to the H3-group extraction bounded to
1608
+ * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
1609
+ * blank changelog all return EMPTY_HIGHLIGHTS (no window).
1610
+ */
1611
+ function extractHighlights(changelogText, version) {
1612
+ const { found, body } = extractSection(changelogText ?? "", version ?? "");
1613
+ if (!found || !body) return { ...EMPTY_HIGHLIGHTS };
1614
+ const summary = extractWhatsNewSummary(body);
1615
+ if (summary !== null) return {
1616
+ version: String(version).trim().replace(/^v/i, ""),
1617
+ found: true,
1618
+ groups: [{
1619
+ heading: null,
1620
+ items: summary
1621
+ }],
1622
+ totalItems: summary.length,
1623
+ truncated: false
1624
+ };
1625
+ const groups = [];
1626
+ let totalItems = 0;
1627
+ let truncated = false;
1628
+ for (const rawLine of body.split("\n")) {
1629
+ const line = rawLine.trim();
1630
+ if (line === "" || line.startsWith("<!--")) continue;
1631
+ if (/^#{1,6}[ \t]/.test(line)) {
1632
+ const heading = stripMarkdown(stripHeading(line));
1633
+ if (heading === "") continue;
1634
+ if (groups.at(-1)?.items.length === 0) groups.pop();
1635
+ groups.push({
1636
+ heading,
1637
+ items: []
1638
+ });
1639
+ continue;
1640
+ }
1641
+ if (totalItems >= 12) {
1642
+ if (/^[-*][ \t]/.test(line)) totalItems += 1;
1643
+ continue;
1644
+ }
1645
+ const isBullet = /^[-*][ \t]/.test(line);
1646
+ const continuation = (groups.at(-1)?.items.length ?? 0) > 0;
1647
+ if (!isBullet && !continuation) continue;
1648
+ const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, "") : line);
1649
+ if (content === "") continue;
1650
+ const bounded = content.length > 140 ? `${content.slice(0, 139)}…` : content;
1651
+ const group = groups.at(-1);
1652
+ if (group === void 0) groups.push({
1653
+ heading: null,
1654
+ items: [bounded]
1655
+ });
1656
+ else if (isBullet || group.items.length === 0) group.items.push(bounded);
1657
+ else group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim();
1658
+ if (isBullet) totalItems += 1;
1659
+ }
1660
+ const kept = groups.filter((group) => group.items.length > 0);
1661
+ truncated = totalItems > 12;
1662
+ return {
1663
+ version: found ? String(version).trim().replace(/^v/i, "") : null,
1664
+ found,
1665
+ groups: kept,
1666
+ totalItems,
1667
+ truncated
1668
+ };
1669
+ }
1670
+ /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
1671
+ function whatsNewTitle(version) {
1672
+ return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, "")}`;
1673
+ }
1674
+ /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
1675
+ function whatsNewLines(highlights) {
1676
+ const lines = [];
1677
+ for (const group of highlights.groups) {
1678
+ if (group.heading !== null) lines.push(group.heading);
1679
+ for (const item of group.items) lines.push(`• ${item}`);
1680
+ }
1681
+ if (highlights.truncated) {
1682
+ const hidden = Math.max(0, highlights.totalItems - 12);
1683
+ if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`);
1684
+ }
1685
+ return lines;
1686
+ }
1687
+ /**
1688
+ * Candidate CHANGELOG.md locations for a bundle, first readable wins:
1689
+ * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
1690
+ * shipped by both installers next to package.json);
1691
+ * 2. the package root (dev checkout; also an npm-package install when the
1692
+ * bundle runs from `<pkg>/src/plugins/tui/dist/`).
1693
+ */
1694
+ function changelogCandidates(bundlePath) {
1695
+ const dist = dirname(bundlePath);
1696
+ const copyRoot = dirname(dist);
1697
+ const packageRoot = dirname(dirname(dirname(copyRoot)));
1698
+ return [join(copyRoot, "CHANGELOG.md"), join(packageRoot, "CHANGELOG.md")];
1699
+ }
1700
+ /** Read the first existing candidate; null when none is readable (no window). */
1701
+ async function readChangelogForBundle(bundleUrl) {
1702
+ try {
1703
+ const bundlePath = fileURLToPath(bundleUrl);
1704
+ for (const candidate of changelogCandidates(bundlePath)) try {
1705
+ return await readFile(candidate, "utf8");
1706
+ } catch {}
1707
+ return null;
1708
+ } catch {
1709
+ return null;
1710
+ }
1711
+ }
1712
+ /** The ambient build-time version, or null outside a tsdown build. */
1713
+ function embeddedVersion() {
1714
+ return "2.0.0-rc.1";
1715
+ }
1716
+ /**
1717
+ * Resolve the running Pantheon version for the what's-new window: the plugin
1718
+ * copy's own package.json first (the copy root two levels above the bundle,
1719
+ * then the package root four levels above — the same legs as the V1 sidebar's
1720
+ * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
1721
+ * nothing resolves → no window (fail-open).
1722
+ */
1723
+ async function resolveRunningVersion$1(bundleUrl, embedded = embeddedVersion()) {
1724
+ try {
1725
+ const bundlePath = fileURLToPath(bundleUrl);
1726
+ const dist = dirname(bundlePath);
1727
+ for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) try {
1728
+ const raw = await readFile(join(root, "package.json"), "utf8");
1729
+ const parsed = JSON.parse(raw);
1730
+ if (typeof parsed.version === "string" && parsed.version.trim() !== "") return parsed.version;
1731
+ } catch {}
1732
+ } catch {}
1733
+ return embedded;
1734
+ }
1264
1735
  //#endregion
1265
1736
  //#region src/pantheon-settings.tsx
1266
1737
  /** @jsxImportSource @opentui/solid */
@@ -1413,6 +1884,28 @@ function writeDecisionBudget(budgets) {
1413
1884
  writeFileSync(temp, `${JSON.stringify(doc, null, 2)}\n`, { mode: 384 });
1414
1885
  renameSync(temp, path);
1415
1886
  }
1887
+ function decisionAuthStorePath() {
1888
+ const xdgData = process.env.XDG_DATA_HOME ?? join(process.env.HOME ?? "", ".local", "share");
1889
+ return join(xdgData, "opencode", "auth.json");
1890
+ }
1891
+ /** Provider ids registered in the host auth store (existence only — never values). */
1892
+ function readAuthProviders() {
1893
+ const names = /* @__PURE__ */ new Set();
1894
+ try {
1895
+ const parsed = JSON.parse(readFileSync(decisionAuthStorePath(), "utf8"));
1896
+ for (const key of Object.keys(parsed)) names.add(key);
1897
+ } catch {}
1898
+ return names;
1899
+ }
1900
+ /** Provider ids present in opencode.json `providers` (the config copy the host reads). */
1901
+ function readConfigProviders() {
1902
+ const names = /* @__PURE__ */ new Set();
1903
+ try {
1904
+ const parsed = JSON.parse(readFileSync(userOpenCodeConfigPath(), "utf8"));
1905
+ for (const key of Object.keys(parsed?.providers ?? {})) names.add(key);
1906
+ } catch {}
1907
+ return names;
1908
+ }
1416
1909
  function updateCheckStatePath() {
1417
1910
  const stateDir = process.env.XDG_STATE_HOME ?? join(process.env.HOME ?? "", ".local", "state");
1418
1911
  return join(stateDir, "pantheon", "update-check.json");
@@ -1424,9 +1917,9 @@ function readUpdateCheckState() {
1424
1917
  return {};
1425
1918
  }
1426
1919
  }
1427
- async function fetchLatestForChannel(currentVersion) {
1920
+ async function fetchLatestForChannel(channel) {
1428
1921
  try {
1429
- const response = await fetch(registryUrlForChannel(updateChannelFor(currentVersion)), { signal: AbortSignal.timeout(5e3) });
1922
+ const response = await fetch(registryUrlForChannel(channel), { signal: AbortSignal.timeout(5e3) });
1430
1923
  return String((await response.json())?.version ?? "") || null;
1431
1924
  } catch {
1432
1925
  return null;
@@ -1442,19 +1935,17 @@ function persistUpdateCheckState(previous, latest) {
1442
1935
  } : null, Date.now()), null, 2)}\n`);
1443
1936
  } catch {}
1444
1937
  }
1445
- function resolveRunningVersion$1() {
1446
- return "2.0.0-beta.6";
1938
+ function resolveRunningVersion() {
1939
+ return "2.0.0-rc.1";
1447
1940
  }
1448
1941
  const VALUE_WIDTH = 22;
1449
1942
  function SettingsWindow(props) {
1450
1943
  const tab = () => props.tabs()[props.page()] ?? props.tabs()[0] ?? EMPTY_TAB;
1451
- const rows = () => tabRows(tab());
1452
1944
  return (() => {
1453
- var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("box"), _el$5 = createElement("text"), _el$7 = createElement("text"), _el$0 = createElement("text"), _el$1 = createElement("text");
1945
+ var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("box"), _el$5 = createElement("box"), _el$6 = createElement("text"), _el$8 = createElement("box"), _el$9 = createElement("box"), _el$0 = createElement("text"), _el$10 = createElement("box"), _el$11 = createElement("box"), _el$12 = createElement("box"), _el$13 = createElement("text"), _el$15 = createElement("text"), _el$17 = createElement("box"), _el$18 = createElement("text"), _el$19 = createElement("text");
1454
1946
  insertNode(_el$, _el$2);
1455
- insertNode(_el$, _el$7);
1456
- insertNode(_el$, _el$0);
1457
- insertNode(_el$, _el$1);
1947
+ insertNode(_el$, _el$8);
1948
+ insertNode(_el$, _el$10);
1458
1949
  setProp(_el$, "flexDirection", "column");
1459
1950
  setProp(_el$, "paddingLeft", 1);
1460
1951
  setProp(_el$, "paddingRight", 1);
@@ -1462,136 +1953,328 @@ function SettingsWindow(props) {
1462
1953
  insertNode(_el$2, _el$3);
1463
1954
  insertNode(_el$2, _el$4);
1464
1955
  insertNode(_el$2, _el$5);
1956
+ insertNode(_el$2, _el$6);
1465
1957
  setProp(_el$2, "flexDirection", "row");
1466
- setProp(_el$3, "flexShrink", 0);
1958
+ setProp(_el$2, "alignItems", "center");
1467
1959
  setProp(_el$3, "attributes", 1);
1468
1960
  insert(_el$3, () => `Pantheon v${props.version}`);
1469
- insert(_el$2, createComponent(For, {
1961
+ setProp(_el$4, "width", 2);
1962
+ setProp(_el$5, "flexDirection", "row");
1963
+ setProp(_el$5, "flexGrow", 1);
1964
+ setProp(_el$5, "flexShrink", 1);
1965
+ insert(_el$5, createComponent(For, {
1470
1966
  get each() {
1471
1967
  return props.tabs();
1472
1968
  },
1473
- children: (t, index) => (() => {
1474
- var _el$11 = createElement("text");
1475
- setProp(_el$11, "flexShrink", 0);
1476
- spread(_el$11, mergeProps({ get fg() {
1477
- return memo(() => index() === props.page())() ? props.fg : props.muted;
1478
- } }, () => index() === props.page() ? { attributes: 1 } : {}), true);
1479
- insert(_el$11, () => ` ${t.title}${tabDirty(props.draft(), t) ? " ●" : ""}`);
1480
- return _el$11;
1481
- })()
1482
- }), _el$4);
1483
- setProp(_el$4, "flexGrow", 1);
1484
- insertNode(_el$5, createTextNode(`esc`));
1485
- setProp(_el$5, "flexShrink", 0);
1486
- insertNode(_el$7, createTextNode(`────────────────────────────────────────────────────────────────────────`));
1487
- insert(_el$, createComponent(For, {
1969
+ children: (t, index) => {
1970
+ const isActive = () => index() === props.page();
1971
+ return (() => {
1972
+ var _el$41 = createElement("text");
1973
+ setProp(_el$41, "flexShrink", 0);
1974
+ spread(_el$41, mergeProps({ get fg() {
1975
+ return memo(() => !!isActive())() ? props.warn ?? props.fg : props.muted;
1976
+ } }, () => isActive() ? { attributes: 1 } : {}), true);
1977
+ insert(_el$41, () => `${t.title}${tabDirty(props.draft(), t) ? " ●" : ""} `);
1978
+ return _el$41;
1979
+ })();
1980
+ }
1981
+ }));
1982
+ insertNode(_el$6, createTextNode(`esc`));
1983
+ insertNode(_el$8, _el$9);
1984
+ setProp(_el$8, "flexDirection", "row");
1985
+ setProp(_el$8, "height", 1);
1986
+ insertNode(_el$9, _el$0);
1987
+ setProp(_el$9, "flexGrow", 1);
1988
+ insertNode(_el$0, createTextNode(`──────────────────────────────────────────────────────────────────────────────`));
1989
+ insertNode(_el$10, _el$11);
1990
+ insertNode(_el$10, _el$17);
1991
+ setProp(_el$10, "flexDirection", "row");
1992
+ insertNode(_el$11, _el$12);
1993
+ insertNode(_el$11, _el$13);
1994
+ insertNode(_el$11, _el$15);
1995
+ setProp(_el$11, "width", 18);
1996
+ setProp(_el$11, "flexDirection", "column");
1997
+ insert(_el$11, createComponent(For, {
1998
+ get each() {
1999
+ return props.tabs();
2000
+ },
2001
+ children: (t, index) => {
2002
+ const isActive = () => index() === props.page();
2003
+ return (() => {
2004
+ var _el$42 = createElement("text");
2005
+ spread(_el$42, mergeProps({ get fg() {
2006
+ return memo(() => !!isActive())() ? props.warn ?? props.fg : props.muted;
2007
+ } }, () => isActive() ? { attributes: 1 } : {}), true);
2008
+ insert(_el$42, () => `${isActive() ? "▸ " : " "}${t.title}${tabDirty(props.draft(), t) ? " ●" : ""}`);
2009
+ return _el$42;
2010
+ })();
2011
+ }
2012
+ }), _el$12);
2013
+ setProp(_el$12, "height", 1);
2014
+ insertNode(_el$13, createTextNode(`1-9: tab`));
2015
+ insertNode(_el$15, createTextNode(`tab: next`));
2016
+ insertNode(_el$17, _el$18);
2017
+ insertNode(_el$17, _el$19);
2018
+ setProp(_el$17, "flexGrow", 1);
2019
+ setProp(_el$17, "flexShrink", 1);
2020
+ setProp(_el$17, "flexDirection", "column");
2021
+ setProp(_el$17, "paddingLeft", 1);
2022
+ setProp(_el$18, "attributes", 1);
2023
+ insert(_el$18, () => tab().title);
2024
+ insertNode(_el$19, createTextNode(`────────────────────────────────────────`));
2025
+ insert(_el$17, createComponent(For, {
1488
2026
  get each() {
1489
2027
  return tab().groups;
1490
2028
  },
1491
2029
  children: (group) => (() => {
1492
- var _el$12 = createElement("box"), _el$14 = createElement("box");
1493
- insertNode(_el$12, _el$14);
1494
- setProp(_el$12, "flexDirection", "column");
1495
- insert(_el$12, createComponent(Show, {
2030
+ var _el$43 = createElement("box"), _el$45 = createElement("box");
2031
+ insertNode(_el$43, _el$45);
2032
+ setProp(_el$43, "flexDirection", "column");
2033
+ insert(_el$43, createComponent(Show, {
1496
2034
  get when() {
1497
2035
  return group.title !== void 0;
1498
2036
  },
1499
2037
  get children() {
1500
- var _el$13 = createElement("text");
1501
- setProp(_el$13, "attributes", 1);
1502
- insert(_el$13, () => group.title);
1503
- effect((_$p) => setProp(_el$13, "fg", props.fg, _$p));
1504
- return _el$13;
2038
+ var _el$44 = createElement("text");
2039
+ setProp(_el$44, "attributes", 1);
2040
+ insert(_el$44, () => group.title);
2041
+ effect((_$p) => setProp(_el$44, "fg", props.warn ?? props.fg, _$p));
2042
+ return _el$44;
1505
2043
  }
1506
- }), _el$14);
1507
- insert(_el$12, createComponent(For, {
2044
+ }), _el$45);
2045
+ insert(_el$43, createComponent(For, {
1508
2046
  get each() {
1509
2047
  return group.rows;
1510
2048
  },
1511
2049
  children: (row) => {
1512
- const isSelected = () => rows()[props.selected()]?.id === row.id;
2050
+ const isSelected = () => row.id === props.selectedId();
1513
2051
  const display = () => props.draft()[row.id] ?? row.value;
1514
2052
  const staged = () => props.draft()[row.id] !== void 0;
1515
- const gutter = () => isSelected() ? "▸ " : " ";
2053
+ const gutter = () => isSelected() ? " " : " ";
1516
2054
  const valueCell = () => row.cycle !== void 0 ? `< ${display()} >` : display();
1517
2055
  return (() => {
1518
- var _el$15 = createElement("box"), _el$16 = createElement("box"), _el$17 = createElement("text"), _el$18 = createElement("box"), _el$19 = createElement("text");
1519
- insertNode(_el$15, _el$16);
1520
- insertNode(_el$15, _el$18);
1521
- setProp(_el$15, "flexDirection", "row");
1522
- insertNode(_el$16, _el$17);
1523
- setProp(_el$16, "width", 30);
1524
- spread(_el$17, mergeProps({ get fg() {
1525
- return props.fg;
2056
+ var _el$46 = createElement("box"), _el$47 = createElement("box"), _el$48 = createElement("text"), _el$49 = createElement("box"), _el$50 = createElement("text");
2057
+ insertNode(_el$46, _el$47);
2058
+ insertNode(_el$46, _el$49);
2059
+ setProp(_el$46, "flexDirection", "row");
2060
+ insertNode(_el$47, _el$48);
2061
+ setProp(_el$47, "width", 30);
2062
+ spread(_el$48, mergeProps({ get fg() {
2063
+ return memo(() => !!isSelected())() ? "#000000" : props.fg;
1526
2064
  } }, () => isSelected() ? { attributes: 1 } : {}), true);
1527
- insert(_el$17, () => `${gutter()}${row.name}`.padEnd(30));
1528
- insertNode(_el$18, _el$19);
1529
- setProp(_el$18, "width", 22);
1530
- spread(_el$19, mergeProps({ get fg() {
1531
- return memo(() => !!(isSelected() || staged()))() ? props.fg : props.muted;
1532
- } }, () => isSelected() ? { attributes: 1 } : {}), true);
1533
- insert(_el$19, () => `${valueCell()}${staged() ? " ●" : ""}`.padEnd(VALUE_WIDTH));
1534
- insert(_el$15, createComponent(Show, {
2065
+ insert(_el$48, () => `${gutter()}${row.name}`.padEnd(30));
2066
+ insertNode(_el$49, _el$50);
2067
+ setProp(_el$49, "width", 22);
2068
+ spread(_el$50, mergeProps({ get fg() {
2069
+ return memo(() => !!isSelected())() ? "#000000" : memo(() => !!staged())() ? props.warn ?? props.fg : props.muted;
2070
+ } }, () => isSelected() || staged() ? { attributes: 1 } : {}), true);
2071
+ insert(_el$50, () => `${valueCell()}${staged() ? " ●" : ""}`.padEnd(VALUE_WIDTH));
2072
+ insert(_el$46, createComponent(Show, {
1535
2073
  get when() {
1536
2074
  return row.note !== void 0;
1537
2075
  },
1538
2076
  get children() {
1539
- var _el$20 = createElement("box"), _el$21 = createElement("text");
1540
- insertNode(_el$20, _el$21);
1541
- setProp(_el$20, "flexGrow", 1);
1542
- setProp(_el$20, "flexShrink", 1);
1543
- insert(_el$21, () => row.note);
1544
- effect((_$p) => setProp(_el$21, "fg", props.muted, _$p));
1545
- return _el$20;
2077
+ var _el$51 = createElement("box"), _el$52 = createElement("text");
2078
+ insertNode(_el$51, _el$52);
2079
+ setProp(_el$51, "flexGrow", 1);
2080
+ setProp(_el$51, "flexShrink", 1);
2081
+ insert(_el$52, () => row.note);
2082
+ effect((_$p) => setProp(_el$52, "fg", isSelected() ? "#111827" : props.muted, _$p));
2083
+ return _el$51;
1546
2084
  }
1547
2085
  }), null);
1548
- return _el$15;
2086
+ effect((_$p) => setProp(_el$46, "backgroundColor", isSelected() ? props.warn ?? "#f59e0b" : void 0, _$p));
2087
+ return _el$46;
1549
2088
  })();
1550
2089
  }
1551
- }), _el$14);
1552
- setProp(_el$14, "height", 1);
1553
- return _el$12;
2090
+ }), _el$45);
2091
+ setProp(_el$45, "height", 1);
2092
+ return _el$43;
1554
2093
  })()
1555
- }), _el$0);
2094
+ }), null);
1556
2095
  insert(_el$, createComponent(Show, {
1557
2096
  get when() {
1558
2097
  return props.notice() !== void 0;
1559
2098
  },
1560
2099
  get children() {
1561
- var _el$9 = createElement("text");
1562
- insert(_el$9, (() => {
1563
- var _c$ = memo(() => !!props.notice()?.startsWith("saved"));
2100
+ var _el$21 = createElement("text");
2101
+ insert(_el$21, (() => {
2102
+ var _c$ = memo(() => !!(props.notice()?.startsWith("✅") || props.notice()?.startsWith("saved")));
1564
2103
  return () => _c$() ? props.notice() : `⚠ ${props.notice()}`;
1565
2104
  })());
1566
- effect((_$p) => setProp(_el$9, "fg", props.notice()?.startsWith("saved") ? props.muted : props.warn ?? props.muted, _$p));
1567
- return _el$9;
2105
+ effect((_$p) => setProp(_el$21, "fg", props.notice()?.startsWith("✅") ? props.fg : props.warn ?? props.muted, _$p));
2106
+ return _el$21;
1568
2107
  }
1569
- }), _el$0);
1570
- insert(_el$0, (() => {
1571
- var _c$2 = memo(() => !!draftDirty(props.draft()));
1572
- return () => _c$2() ? `● unsaved (${draftCount(props.draft())}) — ctrl+s save · ctrl+r reset page` : "no staged changes";
1573
- })());
1574
- insertNode(_el$1, createTextNode(`1-9 tab · ←/→ change value · enter apply · tab next tab · ctrl+s save · ctrl+r reset page · esc/q close`));
2108
+ }), null);
2109
+ insert(_el$, createComponent(Show, {
2110
+ get when() {
2111
+ return props.confirmExit?.();
2112
+ },
2113
+ get fallback() {
2114
+ return (() => {
2115
+ var _el$53 = createElement("box"), _el$71 = createElement("text");
2116
+ insertNode(_el$53, _el$71);
2117
+ setProp(_el$53, "flexDirection", "column");
2118
+ insert(_el$53, createComponent(Show, {
2119
+ get when() {
2120
+ return draftDirty(props.draft());
2121
+ },
2122
+ get fallback() {
2123
+ return (() => {
2124
+ var _el$73 = createElement("box"), _el$74 = createElement("box"), _el$75 = createElement("text"), _el$77 = createElement("text"), _el$79 = createElement("box"), _el$80 = createElement("text"), _el$82 = createElement("text"), _el$84 = createElement("box"), _el$85 = createElement("text"), _el$87 = createElement("box"), _el$88 = createElement("text");
2125
+ insertNode(_el$73, _el$74);
2126
+ insertNode(_el$73, _el$77);
2127
+ insertNode(_el$73, _el$79);
2128
+ insertNode(_el$73, _el$82);
2129
+ insertNode(_el$73, _el$84);
2130
+ insertNode(_el$73, _el$87);
2131
+ insertNode(_el$73, _el$88);
2132
+ setProp(_el$73, "flexDirection", "row");
2133
+ insertNode(_el$74, _el$75);
2134
+ setProp(_el$74, "backgroundColor", "#262626");
2135
+ insertNode(_el$75, createTextNode(` Close `));
2136
+ setProp(_el$75, "fg", "#ffffff");
2137
+ insertNode(_el$77, createTextNode(` `));
2138
+ insertNode(_el$79, _el$80);
2139
+ setProp(_el$79, "backgroundColor", "#262626");
2140
+ insertNode(_el$80, createTextNode(` Reset page `));
2141
+ setProp(_el$80, "fg", "#ffffff");
2142
+ insertNode(_el$82, createTextNode(` `));
2143
+ insertNode(_el$84, _el$85);
2144
+ setProp(_el$84, "backgroundColor", "#262626");
2145
+ insertNode(_el$85, createTextNode(` Defaults `));
2146
+ setProp(_el$85, "fg", "#ffffff");
2147
+ setProp(_el$87, "flexGrow", 1);
2148
+ insertNode(_el$88, createTextNode(`no staged changes`));
2149
+ effect((_p$) => {
2150
+ var _v$13 = props.muted, _v$14 = props.muted, _v$15 = props.muted;
2151
+ _v$13 !== _p$.e && (_p$.e = setProp(_el$77, "fg", _v$13, _p$.e));
2152
+ _v$14 !== _p$.t && (_p$.t = setProp(_el$82, "fg", _v$14, _p$.t));
2153
+ _v$15 !== _p$.a && (_p$.a = setProp(_el$88, "fg", _v$15, _p$.a));
2154
+ return _p$;
2155
+ }, {
2156
+ e: void 0,
2157
+ t: void 0,
2158
+ a: void 0
2159
+ });
2160
+ return _el$73;
2161
+ })();
2162
+ },
2163
+ get children() {
2164
+ var _el$54 = createElement("box"), _el$55 = createElement("box"), _el$56 = createElement("text"), _el$58 = createElement("text"), _el$60 = createElement("box"), _el$61 = createElement("text"), _el$63 = createElement("text"), _el$65 = createElement("box"), _el$66 = createElement("text"), _el$68 = createElement("box"), _el$69 = createElement("text");
2165
+ insertNode(_el$54, _el$55);
2166
+ insertNode(_el$54, _el$58);
2167
+ insertNode(_el$54, _el$60);
2168
+ insertNode(_el$54, _el$63);
2169
+ insertNode(_el$54, _el$65);
2170
+ insertNode(_el$54, _el$68);
2171
+ insertNode(_el$54, _el$69);
2172
+ setProp(_el$54, "flexDirection", "row");
2173
+ insertNode(_el$55, _el$56);
2174
+ setProp(_el$55, "backgroundColor", "#fba970");
2175
+ insertNode(_el$56, createTextNode(` Save `));
2176
+ setProp(_el$56, "fg", "#000000");
2177
+ insertNode(_el$58, createTextNode(` `));
2178
+ insertNode(_el$60, _el$61);
2179
+ setProp(_el$60, "backgroundColor", "#262626");
2180
+ insertNode(_el$61, createTextNode(` Discard `));
2181
+ setProp(_el$61, "fg", "#ffffff");
2182
+ insertNode(_el$63, createTextNode(` `));
2183
+ insertNode(_el$65, _el$66);
2184
+ setProp(_el$65, "backgroundColor", "#262626");
2185
+ insertNode(_el$66, createTextNode(` Reset page `));
2186
+ setProp(_el$66, "fg", "#ffffff");
2187
+ setProp(_el$68, "flexGrow", 1);
2188
+ insertNode(_el$69, createTextNode(`unsaved changes`));
2189
+ effect((_p$) => {
2190
+ var _v$10 = props.muted, _v$11 = props.muted, _v$12 = props.warn ?? "#f59e0b";
2191
+ _v$10 !== _p$.e && (_p$.e = setProp(_el$58, "fg", _v$10, _p$.e));
2192
+ _v$11 !== _p$.t && (_p$.t = setProp(_el$63, "fg", _v$11, _p$.t));
2193
+ _v$12 !== _p$.a && (_p$.a = setProp(_el$69, "fg", _v$12, _p$.a));
2194
+ return _p$;
2195
+ }, {
2196
+ e: void 0,
2197
+ t: void 0,
2198
+ a: void 0
2199
+ });
2200
+ return _el$54;
2201
+ }
2202
+ }), _el$71);
2203
+ insertNode(_el$71, createTextNode(`› or ←/→ change · ↑↓ select · tab next tab · ctrl+s save · ctrl+r reset page · esc close`));
2204
+ effect((_$p) => setProp(_el$71, "fg", props.muted, _$p));
2205
+ return _el$53;
2206
+ })();
2207
+ },
2208
+ get children() {
2209
+ var _el$22 = createElement("box"), _el$23 = createElement("box"), _el$24 = createElement("text"), _el$26 = createElement("box"), _el$27 = createElement("text"), _el$29 = createElement("text"), _el$31 = createElement("box"), _el$32 = createElement("text"), _el$34 = createElement("text"), _el$36 = createElement("box"), _el$37 = createElement("text"), _el$39 = createElement("text");
2210
+ insertNode(_el$22, _el$23);
2211
+ insertNode(_el$22, _el$39);
2212
+ setProp(_el$22, "flexDirection", "column");
2213
+ insertNode(_el$23, _el$24);
2214
+ insertNode(_el$23, _el$26);
2215
+ insertNode(_el$23, _el$29);
2216
+ insertNode(_el$23, _el$31);
2217
+ insertNode(_el$23, _el$34);
2218
+ insertNode(_el$23, _el$36);
2219
+ setProp(_el$23, "flexDirection", "row");
2220
+ insertNode(_el$24, createTextNode(`Keep your changes? `));
2221
+ setProp(_el$24, "attributes", 1);
2222
+ insertNode(_el$26, _el$27);
2223
+ setProp(_el$26, "backgroundColor", "#fba970");
2224
+ insertNode(_el$27, createTextNode(` Save `));
2225
+ setProp(_el$27, "fg", "#000000");
2226
+ insertNode(_el$29, createTextNode(` `));
2227
+ insertNode(_el$31, _el$32);
2228
+ setProp(_el$31, "backgroundColor", "#262626");
2229
+ insertNode(_el$32, createTextNode(` Discard `));
2230
+ setProp(_el$32, "fg", "#ffffff");
2231
+ insertNode(_el$34, createTextNode(` `));
2232
+ insertNode(_el$36, _el$37);
2233
+ setProp(_el$36, "backgroundColor", "#262626");
2234
+ insertNode(_el$37, createTextNode(` Keep editing `));
2235
+ setProp(_el$37, "fg", "#ffffff");
2236
+ insertNode(_el$39, createTextNode(`ctrl+s save · d discard the changes · esc keep editing`));
2237
+ effect((_p$) => {
2238
+ var _v$ = props.warn ?? "#f59e0b", _v$2 = props.muted, _v$3 = props.muted, _v$4 = props.muted;
2239
+ _v$ !== _p$.e && (_p$.e = setProp(_el$24, "fg", _v$, _p$.e));
2240
+ _v$2 !== _p$.t && (_p$.t = setProp(_el$29, "fg", _v$2, _p$.t));
2241
+ _v$3 !== _p$.a && (_p$.a = setProp(_el$34, "fg", _v$3, _p$.a));
2242
+ _v$4 !== _p$.o && (_p$.o = setProp(_el$39, "fg", _v$4, _p$.o));
2243
+ return _p$;
2244
+ }, {
2245
+ e: void 0,
2246
+ t: void 0,
2247
+ a: void 0,
2248
+ o: void 0
2249
+ });
2250
+ return _el$22;
2251
+ }
2252
+ }), null);
1575
2253
  effect((_p$) => {
1576
- var _v$ = props.fg, _v$2 = props.muted, _v$3 = props.muted, _v$4 = draftDirty(props.draft()) ? props.warn ?? props.fg : props.muted, _v$5 = props.muted;
1577
- _v$ !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$, _p$.e));
1578
- _v$2 !== _p$.t && (_p$.t = setProp(_el$5, "fg", _v$2, _p$.t));
1579
- _v$3 !== _p$.a && (_p$.a = setProp(_el$7, "fg", _v$3, _p$.a));
1580
- _v$4 !== _p$.o && (_p$.o = setProp(_el$0, "fg", _v$4, _p$.o));
1581
- _v$5 !== _p$.i && (_p$.i = setProp(_el$1, "fg", _v$5, _p$.i));
2254
+ var _v$5 = props.fg, _v$6 = props.muted, _v$7 = props.muted, _v$8 = props.muted, _v$9 = props.muted, _v$0 = props.warn ?? props.fg, _v$1 = props.muted;
2255
+ _v$5 !== _p$.e && (_p$.e = setProp(_el$3, "fg", _v$5, _p$.e));
2256
+ _v$6 !== _p$.t && (_p$.t = setProp(_el$6, "fg", _v$6, _p$.t));
2257
+ _v$7 !== _p$.a && (_p$.a = setProp(_el$0, "fg", _v$7, _p$.a));
2258
+ _v$8 !== _p$.o && (_p$.o = setProp(_el$13, "fg", _v$8, _p$.o));
2259
+ _v$9 !== _p$.i && (_p$.i = setProp(_el$15, "fg", _v$9, _p$.i));
2260
+ _v$0 !== _p$.n && (_p$.n = setProp(_el$18, "fg", _v$0, _p$.n));
2261
+ _v$1 !== _p$.s && (_p$.s = setProp(_el$19, "fg", _v$1, _p$.s));
1582
2262
  return _p$;
1583
2263
  }, {
1584
2264
  e: void 0,
1585
2265
  t: void 0,
1586
2266
  a: void 0,
1587
2267
  o: void 0,
1588
- i: void 0
2268
+ i: void 0,
2269
+ n: void 0,
2270
+ s: void 0
1589
2271
  });
1590
2272
  return _el$;
1591
2273
  })();
1592
2274
  }
1593
2275
  let pageApi;
1594
2276
  function createWindowController(context, exit) {
2277
+ const currentVersion = resolveRunningVersion();
1595
2278
  const [page, setPage] = createSignal(0);
1596
2279
  const [selected, setSelected] = createSignal(0);
1597
2280
  const [load, setLoad] = createSignal(readOverridesLoad());
@@ -1600,11 +2283,31 @@ function createWindowController(context, exit) {
1600
2283
  const [budgets, setBudgets] = createSignal(readDecisionBudgets());
1601
2284
  const [autonomyRestartPending, setAutonomyRestartPending] = createSignal(false);
1602
2285
  const [presetTick, setPresetTick] = createSignal(0);
2286
+ const [selectedChannel, setSelectedChannel] = createSignal(updateChannelFor(currentVersion));
1603
2287
  const [lastChecked, setLastChecked] = createSignal(void 0);
1604
2288
  const [checking, setChecking] = createSignal(false);
2289
+ const [updating, setUpdating] = createSignal(false);
2290
+ const [changelogItems, setChangelogItems] = createSignal([]);
1605
2291
  const [draft, setDraft] = createSignal({});
1606
2292
  const [notice, setNotice] = createSignal(void 0);
1607
- const currentVersion = resolveRunningVersion$1();
2293
+ const [confirmExit, setConfirmExit] = createSignal(false);
2294
+ readChangelogForBundle(import.meta.url).then((text) => {
2295
+ if (!text) return;
2296
+ const hl = extractHighlights(text, currentVersion);
2297
+ if (hl.found) {
2298
+ const items = [];
2299
+ for (const group of hl.groups) for (const item of group.items) {
2300
+ const dash = item.indexOf("—");
2301
+ const title = dash !== -1 ? item.slice(0, dash).trim() : item.slice(0, 26);
2302
+ items.push({
2303
+ title,
2304
+ detail: item,
2305
+ group: group.heading ?? void 0
2306
+ });
2307
+ }
2308
+ setChangelogItems(items);
2309
+ }
2310
+ });
1608
2311
  const presetInput = () => {
1609
2312
  presetTick();
1610
2313
  return {
@@ -1616,7 +2319,9 @@ function createWindowController(context, exit) {
1616
2319
  const input = {
1617
2320
  currentVersion,
1618
2321
  state: readUpdateCheckState(),
2322
+ selectedChannel: selectedChannel(),
1619
2323
  checking: checking(),
2324
+ updating: updating(),
1620
2325
  nowMs: Date.now()
1621
2326
  };
1622
2327
  const seen = lastChecked();
@@ -1625,7 +2330,7 @@ function createWindowController(context, exit) {
1625
2330
  };
1626
2331
  const tabs = () => [
1627
2332
  buildGatesTab(load()),
1628
- buildDecisionTab(decision()),
2333
+ buildDecisionTab(decision(), process.env, readAuthProviders(), readConfigProviders()),
1629
2334
  buildPresetTab(presetInput()),
1630
2335
  buildTuiTab(tuiPrefs()),
1631
2336
  buildAutonomyTab({
@@ -1635,6 +2340,7 @@ function createWindowController(context, exit) {
1635
2340
  }),
1636
2341
  buildJ1Tab(process.env, false),
1637
2342
  buildUpdatesTab(updatesInput()),
2343
+ buildChangelogTab(currentVersion, changelogItems()),
1638
2344
  buildDoctorTab({
1639
2345
  runningVersion: currentVersion,
1640
2346
  nodeVersion: process.versions.node,
@@ -1644,26 +2350,70 @@ function createWindowController(context, exit) {
1644
2350
  ];
1645
2351
  const rows = () => tabRows(tabs()[page()] ?? tabs()[0] ?? EMPTY_TAB);
1646
2352
  const move = (delta) => {
2353
+ if (confirmExit()) setConfirmExit(false);
1647
2354
  const list = rows();
1648
2355
  if (list.length === 0) return;
1649
2356
  setSelected((current) => Math.min(Math.max(current + delta, 0), list.length - 1));
1650
2357
  };
1651
2358
  const step = (direction) => {
2359
+ if (confirmExit()) setConfirmExit(false);
1652
2360
  const row = rows()[selected()];
1653
2361
  if (row === void 0) return;
1654
2362
  setNotice(void 0);
1655
2363
  setDraft(stageValue(draft(), row, direction));
1656
2364
  };
1657
- const checkUpdatesNow = () => {
2365
+ const checkUpdatesNow = (targetChannel = selectedChannel()) => {
1658
2366
  if (checking()) return;
1659
2367
  setChecking(true);
1660
2368
  setNotice(void 0);
1661
- fetchLatestForChannel(currentVersion).then((latest) => {
1662
- if (latest) setLastChecked(latest);
1663
- persistUpdateCheckState(readUpdateCheckState(), latest);
2369
+ fetchLatestForChannel(targetChannel).then((latest) => {
2370
+ if (latest) {
2371
+ setLastChecked(latest);
2372
+ persistUpdateCheckState(readUpdateCheckState(), latest);
2373
+ }
1664
2374
  }).catch(() => {}).finally(() => setChecking(false));
1665
2375
  };
2376
+ const runUpdateNow = () => {
2377
+ if (updating()) return;
2378
+ setUpdating(true);
2379
+ setNotice(`updating to ${selectedChannel()} channel…`);
2380
+ execFile("npm", [
2381
+ "install",
2382
+ "-g",
2383
+ `pantheon-opencode@${selectedChannel()}`
2384
+ ], { timeout: 6e4 }, (err) => {
2385
+ setUpdating(false);
2386
+ if (err) {
2387
+ setNotice("run in terminal: pantheon-opencode update");
2388
+ try {
2389
+ context.ui.toast?.show?.({
2390
+ variant: "warning",
2391
+ message: "Update requires terminal permissions: run `pantheon-opencode update`"
2392
+ });
2393
+ } catch {}
2394
+ } else {
2395
+ setNotice("✅ update complete — restart OpenCode or run `npx pantheon-opencode init`");
2396
+ try {
2397
+ context.ui.toast?.show?.({
2398
+ variant: "info",
2399
+ message: "Pantheon updated successfully!"
2400
+ });
2401
+ } catch {}
2402
+ }
2403
+ });
2404
+ };
1666
2405
  const dispatchWrite = (id, value) => {
2406
+ if (id === "update.channel") {
2407
+ if (value === "stable" || value === "beta") {
2408
+ setSelectedChannel(value);
2409
+ checkUpdatesNow(value);
2410
+ return { ok: true };
2411
+ }
2412
+ return {
2413
+ ok: false,
2414
+ reason: "unknown channel"
2415
+ };
2416
+ }
1667
2417
  if (id.startsWith("gate.")) {
1668
2418
  if (!canWriteOverrides(load())) return {
1669
2419
  ok: false,
@@ -1828,20 +2578,36 @@ function createWindowController(context, exit) {
1828
2578
  setPresetTick((tick) => tick + 1);
1829
2579
  }
1830
2580
  if (failed.length > 0) setNotice(`${failed.map((f) => `${f.id}: ${f.reason}`).join(" · ")} — staged changes kept`);
1831
- else setNotice(`saved ${applied.length} change${applied.length === 1 ? "" : "s"}`);
2581
+ else {
2582
+ setNotice(`saved ${applied.length} change${applied.length === 1 ? "" : "s"}`);
2583
+ if (confirmExit()) exit();
2584
+ }
1832
2585
  };
1833
2586
  const resetPage = () => {
2587
+ if (confirmExit()) setConfirmExit(false);
1834
2588
  const tab = tabs()[page()];
1835
2589
  if (tab === void 0) return;
1836
2590
  setDraft(resetTab(draft(), tab));
1837
2591
  setNotice(void 0);
1838
2592
  };
2593
+ const stageDefaultsPage = () => {
2594
+ if (confirmExit()) setConfirmExit(false);
2595
+ const tab = tabs()[page()];
2596
+ if (tab === void 0) return;
2597
+ setNotice(void 0);
2598
+ setDraft(stageDefaults(draft(), tab));
2599
+ };
1839
2600
  const nextTab = () => {
2601
+ if (confirmExit()) setConfirmExit(false);
1840
2602
  setPage((current) => (current + 1) % tabs().length);
1841
2603
  setSelected(0);
1842
2604
  };
1843
2605
  const close = () => {
1844
2606
  const staged = draftCount(draft());
2607
+ if (staged > 0 && !confirmExit()) {
2608
+ setConfirmExit(true);
2609
+ return;
2610
+ }
1845
2611
  if (staged > 0) {
1846
2612
  setDraft({});
1847
2613
  try {
@@ -1853,21 +2619,42 @@ function createWindowController(context, exit) {
1853
2619
  }
1854
2620
  exit();
1855
2621
  };
2622
+ const discard = () => {
2623
+ const staged = draftCount(draft());
2624
+ setDraft({});
2625
+ setConfirmExit(false);
2626
+ if (staged > 0) try {
2627
+ context.ui.toast?.show?.({
2628
+ variant: "info",
2629
+ message: `settings: ${staged} staged change${staged === 1 ? "" : "s"} discarded`
2630
+ });
2631
+ } catch {}
2632
+ exit();
2633
+ };
2634
+ const cancelExit = () => {
2635
+ setConfirmExit(false);
2636
+ };
2637
+ const selectedId = () => rows()[selected()]?.id;
1856
2638
  return {
1857
2639
  tabs,
1858
2640
  page,
1859
- selected,
2641
+ selectedId,
1860
2642
  draft,
1861
2643
  notice,
2644
+ confirmExit: () => confirmExit(),
1862
2645
  api: {
1863
2646
  move,
1864
2647
  step,
1865
2648
  actuate: () => {
1866
- if (rows()[selected()]?.action === "update-check") checkUpdatesNow();
2649
+ if (confirmExit()) setConfirmExit(false);
2650
+ const row = rows()[selected()];
2651
+ if (row?.action === "update-check") checkUpdatesNow();
2652
+ else if (row?.action === "update-run") runUpdateNow();
1867
2653
  else step(1);
1868
2654
  },
1869
2655
  nextTab,
1870
2656
  jumpTab: (index) => {
2657
+ if (confirmExit()) setConfirmExit(false);
1871
2658
  if (index >= 0 && index < tabs().length) {
1872
2659
  setPage(index);
1873
2660
  setSelected(0);
@@ -1875,7 +2662,11 @@ function createWindowController(context, exit) {
1875
2662
  },
1876
2663
  save,
1877
2664
  resetPage,
1878
- close
2665
+ stageDefaults: stageDefaultsPage,
2666
+ close,
2667
+ discard,
2668
+ cancelExit,
2669
+ confirmExit: () => confirmExit()
1879
2670
  },
1880
2671
  cleanup: () => {
1881
2672
  pageApi = void 0;
@@ -1898,7 +2689,7 @@ function SettingsPage(props) {
1898
2689
  pageApi = controller.api;
1899
2690
  return createComponent(SettingsWindow, {
1900
2691
  get version() {
1901
- return resolveRunningVersion$1();
2692
+ return resolveRunningVersion();
1902
2693
  },
1903
2694
  get tabs() {
1904
2695
  return controller.tabs;
@@ -1906,8 +2697,8 @@ function SettingsPage(props) {
1906
2697
  get page() {
1907
2698
  return controller.page;
1908
2699
  },
1909
- get selected() {
1910
- return controller.selected;
2700
+ get selectedId() {
2701
+ return controller.selectedId;
1911
2702
  },
1912
2703
  get draft() {
1913
2704
  return controller.draft;
@@ -1915,6 +2706,9 @@ function SettingsPage(props) {
1915
2706
  get notice() {
1916
2707
  return controller.notice;
1917
2708
  },
2709
+ get confirmExit() {
2710
+ return controller.confirmExit;
2711
+ },
1918
2712
  get fg() {
1919
2713
  return theme.base;
1920
2714
  },
@@ -1926,12 +2720,7 @@ function SettingsPage(props) {
1926
2720
  }
1927
2721
  function navigateBack(context, data) {
1928
2722
  try {
1929
- const destination = data?.returnRoute ?? { type: "home" };
1930
- context.ui.toast?.show?.({
1931
- variant: "info",
1932
- message: `settings: navigating ${JSON.stringify(destination)}`
1933
- });
1934
- context.ui.router.navigate(destination);
2723
+ context.ui.router.navigate(data?.returnRoute ?? { type: "home" });
1935
2724
  } catch {}
1936
2725
  }
1937
2726
  const [dialogOpen, setDialogOpen] = createSignal(false);
@@ -1960,7 +2749,7 @@ function openSettingsDialog(context) {
1960
2749
  try {
1961
2750
  context.ui.dialog.show(() => createComponent(SettingsWindow, {
1962
2751
  get version() {
1963
- return resolveRunningVersion$1();
2752
+ return resolveRunningVersion();
1964
2753
  },
1965
2754
  get tabs() {
1966
2755
  return controller.tabs;
@@ -1968,8 +2757,8 @@ function openSettingsDialog(context) {
1968
2757
  get page() {
1969
2758
  return controller.page;
1970
2759
  },
1971
- get selected() {
1972
- return controller.selected;
2760
+ get selectedId() {
2761
+ return controller.selectedId;
1973
2762
  },
1974
2763
  get draft() {
1975
2764
  return controller.draft;
@@ -1977,6 +2766,9 @@ function openSettingsDialog(context) {
1977
2766
  get notice() {
1978
2767
  return controller.notice;
1979
2768
  },
2769
+ get confirmExit() {
2770
+ return controller.confirmExit;
2771
+ },
1980
2772
  get fg() {
1981
2773
  return theme.base;
1982
2774
  },
@@ -2029,9 +2821,24 @@ function setupPantheonSettings(context) {
2029
2821
  } catch {}
2030
2822
  return;
2031
2823
  }
2824
+ if (pageApi.confirmExit?.()) {
2825
+ pageApi.cancelExit?.();
2826
+ return;
2827
+ }
2032
2828
  pageApi.close();
2033
2829
  }
2034
2830
  },
2831
+ {
2832
+ id: "pantheon.settings.discard",
2833
+ title: "Discard staged changes and exit",
2834
+ bind: "d",
2835
+ run: () => {
2836
+ if (pageApi?.confirmExit?.()) {
2837
+ pageApi.discard?.();
2838
+ return;
2839
+ }
2840
+ }
2841
+ },
2035
2842
  {
2036
2843
  id: "pantheon.settings.down",
2037
2844
  title: "Select next row",
@@ -2096,6 +2903,14 @@ function setupPantheonSettings(context) {
2096
2903
  pageApi?.resetPage();
2097
2904
  }
2098
2905
  },
2906
+ {
2907
+ id: "pantheon.settings.defaults",
2908
+ title: "Stage defaults for this tab",
2909
+ bind: "ctrl+d",
2910
+ run: () => {
2911
+ pageApi?.stageDefaults();
2912
+ }
2913
+ },
2099
2914
  ...Array.from({ length: 9 }, (_, index) => ({
2100
2915
  id: `pantheon.settings.tab.${index + 1}`,
2101
2916
  title: `Jump to tab ${index + 1}`,
@@ -2264,214 +3079,6 @@ function cellWidth(value) {
2264
3079
  for (const { segment } of GRAPHEMES.segment(value)) width += graphemeWidth(segment);
2265
3080
  return width;
2266
3081
  }
2267
- /** Prefix of the "+N more" line appended when the bullet budget is exceeded. */
2268
- const WHATS_NEW_MORE_PREFIX = "… +";
2269
- const EMPTY_HIGHLIGHTS = {
2270
- version: null,
2271
- found: false,
2272
- groups: [],
2273
- totalItems: 0,
2274
- truncated: false
2275
- };
2276
- /** Escape regex metacharacters so a version like 1.0.0 matches literally. */
2277
- function escapeRegExp(text) {
2278
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2279
- }
2280
- /**
2281
- * Extract the body of a version section from changelog text — inline replica
2282
- * of scripts/changelog-extract.mjs `extractSection` (see that file for the
2283
- * full contract: `## [<version>] - YYYY-MM-DD`, leading `v` and the date
2284
- * optional, `## [Unreleased]` never matched).
2285
- */
2286
- function extractSection(changelogText, version) {
2287
- const normalized = String(version).trim().replace(/^v/i, "");
2288
- if (!normalized || /^unreleased$/i.test(normalized)) return {
2289
- found: false,
2290
- body: null
2291
- };
2292
- const escaped = escapeRegExp(normalized);
2293
- const match = new RegExp(`^##[ \\t]+\\[v?${escaped}\\](?:[ \\t]*-[ \\t]*\\d{4}-\\d{2}-\\d{2})?(?=[ \\t]|$)`, "m").exec(changelogText);
2294
- if (!match) return {
2295
- found: false,
2296
- body: null
2297
- };
2298
- const newline = changelogText.indexOf("\n", match.index);
2299
- const start = newline === -1 ? changelogText.length : newline + 1;
2300
- const nextHeading = /^##[ \t]+\[/m.exec(changelogText.slice(start));
2301
- const end = nextHeading ? start + nextHeading.index : changelogText.length;
2302
- return {
2303
- found: true,
2304
- body: changelogText.slice(start, end).trim()
2305
- };
2306
- }
2307
- /**
2308
- * Reduce one markdown line to plain text: links keep their label, emphasis
2309
- * and inline-code markers are dropped, HTML comment fragments are removed,
2310
- * and whitespace collapses. Deliberately simple — the input is our own
2311
- * CHANGELOG (lint-capped at 200 chars per bullet), not hostile input.
2312
- */
2313
- function stripMarkdown(text) {
2314
- return text.replace(/<!--[\s\S]*?-->/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/(\*\*|__)/g, "").replace(/`/g, "").replace(/\s+/g, " ").trim();
2315
- }
2316
- /** Strip the leading H3 marker (`### Added` → `Added`). */
2317
- function stripHeading(text) {
2318
- return text.replace(/^#{1,6}[ \t]+/, "").trim();
2319
- }
2320
- /**
2321
- * Extract the curated summary block (`### 🆕 What's New` or `## 🆕 What's New`)
2322
- * from a section body: its bullets only, each truncated to
2323
- * WHATS_NEW_ITEM_MAX_CHARS, capped to WHATS_NEW_SUMMARY_MAX_ITEMS. Null when
2324
- * the section carries no summary block (the full-section fallback applies).
2325
- */
2326
- function extractWhatsNewSummary(body) {
2327
- const lines = body.split("\n");
2328
- const start = lines.findIndex((line) => /^#{2,3}[ \t]+.*What'?s New/i.test(line.trim()));
2329
- if (start === -1) return null;
2330
- const items = [];
2331
- for (const rawLine of lines.slice(start + 1)) {
2332
- const line = rawLine.trim();
2333
- if (line === "" || line.startsWith("<!--")) continue;
2334
- if (/^#{1,6}[ \t]/.test(line)) break;
2335
- if (!/^[-*][ \t]/.test(line)) continue;
2336
- if (items.length >= 6) break;
2337
- const content = stripMarkdown(line.replace(/^[-*][ \t]+/, ""));
2338
- if (content === "") continue;
2339
- items.push(content.length > 140 ? `${content.slice(0, 139)}…` : content);
2340
- }
2341
- return items.length > 0 ? items : null;
2342
- }
2343
- /**
2344
- * Extract the release highlights for `version`. When the section carries a
2345
- * curated `🆕 What's New` summary block, THE WINDOW SHOWS ONLY THAT (the
2346
- * full Added/Changed/Fixed walls are for the CHANGELOG readers, not the
2347
- * dialog); otherwise it falls back to the H3-group extraction bounded to
2348
- * WHATS_NEW_MAX_ITEMS bullets. A missing section, a bullet-less section or a
2349
- * blank changelog all return EMPTY_HIGHLIGHTS (no window).
2350
- */
2351
- function extractHighlights(changelogText, version) {
2352
- const { found, body } = extractSection(changelogText ?? "", version ?? "");
2353
- if (!found || !body) return { ...EMPTY_HIGHLIGHTS };
2354
- const summary = extractWhatsNewSummary(body);
2355
- if (summary !== null) return {
2356
- version: String(version).trim().replace(/^v/i, ""),
2357
- found: true,
2358
- groups: [{
2359
- heading: null,
2360
- items: summary
2361
- }],
2362
- totalItems: summary.length,
2363
- truncated: false
2364
- };
2365
- const groups = [];
2366
- let totalItems = 0;
2367
- let truncated = false;
2368
- for (const rawLine of body.split("\n")) {
2369
- const line = rawLine.trim();
2370
- if (line === "" || line.startsWith("<!--")) continue;
2371
- if (/^#{1,6}[ \t]/.test(line)) {
2372
- const heading = stripMarkdown(stripHeading(line));
2373
- if (heading === "") continue;
2374
- if (groups.at(-1)?.items.length === 0) groups.pop();
2375
- groups.push({
2376
- heading,
2377
- items: []
2378
- });
2379
- continue;
2380
- }
2381
- if (totalItems >= 12) {
2382
- if (/^[-*][ \t]/.test(line)) totalItems += 1;
2383
- continue;
2384
- }
2385
- const isBullet = /^[-*][ \t]/.test(line);
2386
- const continuation = (groups.at(-1)?.items.length ?? 0) > 0;
2387
- if (!isBullet && !continuation) continue;
2388
- const content = stripMarkdown(isBullet ? line.replace(/^[-*][ \t]+/, "") : line);
2389
- if (content === "") continue;
2390
- const bounded = content.length > 140 ? `${content.slice(0, 139)}…` : content;
2391
- const group = groups.at(-1);
2392
- if (group === void 0) groups.push({
2393
- heading: null,
2394
- items: [bounded]
2395
- });
2396
- else if (isBullet || group.items.length === 0) group.items.push(bounded);
2397
- else group.items[group.items.length - 1] = `${group.items.at(-1)} ${bounded}`.trim();
2398
- if (isBullet) totalItems += 1;
2399
- }
2400
- const kept = groups.filter((group) => group.items.length > 0);
2401
- truncated = totalItems > 12;
2402
- return {
2403
- version: found ? String(version).trim().replace(/^v/i, "") : null,
2404
- found,
2405
- groups: kept,
2406
- totalItems,
2407
- truncated
2408
- };
2409
- }
2410
- /** Window title — mirrors the sidebar's `Pantheon v<version>` convention. */
2411
- function whatsNewTitle(version) {
2412
- return `O que há de novo — Pantheon v${String(version).trim().replace(/^v/i, "")}`;
2413
- }
2414
- /** Flat display lines for the window: group headings, `• ` bullets, `+N more`. */
2415
- function whatsNewLines(highlights) {
2416
- const lines = [];
2417
- for (const group of highlights.groups) {
2418
- if (group.heading !== null) lines.push(group.heading);
2419
- for (const item of group.items) lines.push(`• ${item}`);
2420
- }
2421
- if (highlights.truncated) {
2422
- const hidden = Math.max(0, highlights.totalItems - 12);
2423
- if (hidden > 0) lines.push(`${WHATS_NEW_MORE_PREFIX}${hidden} mais`);
2424
- }
2425
- return lines;
2426
- }
2427
- /**
2428
- * Candidate CHANGELOG.md locations for a bundle, first readable wins:
2429
- * 1. the plugin copy root (`<configDir>/plugins/pantheon-tui/CHANGELOG.md`,
2430
- * shipped by both installers next to package.json);
2431
- * 2. the package root (dev checkout; also an npm-package install when the
2432
- * bundle runs from `<pkg>/src/plugins/tui/dist/`).
2433
- */
2434
- function changelogCandidates(bundlePath) {
2435
- const dist = dirname(bundlePath);
2436
- const copyRoot = dirname(dist);
2437
- const packageRoot = dirname(dirname(dirname(copyRoot)));
2438
- return [join(copyRoot, "CHANGELOG.md"), join(packageRoot, "CHANGELOG.md")];
2439
- }
2440
- /** Read the first existing candidate; null when none is readable (no window). */
2441
- async function readChangelogForBundle(bundleUrl) {
2442
- try {
2443
- const bundlePath = fileURLToPath(bundleUrl);
2444
- for (const candidate of changelogCandidates(bundlePath)) try {
2445
- return await readFile(candidate, "utf8");
2446
- } catch {}
2447
- return null;
2448
- } catch {
2449
- return null;
2450
- }
2451
- }
2452
- /** The ambient build-time version, or null outside a tsdown build. */
2453
- function embeddedVersion() {
2454
- return "2.0.0-beta.6";
2455
- }
2456
- /**
2457
- * Resolve the running Pantheon version for the what's-new window: the plugin
2458
- * copy's own package.json first (the copy root two levels above the bundle,
2459
- * then the package root four levels above — the same legs as the V1 sidebar's
2460
- * detectVersion try 0a/0b), falling back to the tsdown build embed. Null when
2461
- * nothing resolves → no window (fail-open).
2462
- */
2463
- async function resolveRunningVersion(bundleUrl, embedded = embeddedVersion()) {
2464
- try {
2465
- const bundlePath = fileURLToPath(bundleUrl);
2466
- const dist = dirname(bundlePath);
2467
- for (const root of [dirname(dist), dirname(dirname(dirname(dist)))]) try {
2468
- const raw = await readFile(join(root, "package.json"), "utf8");
2469
- const parsed = JSON.parse(raw);
2470
- if (typeof parsed.version === "string" && parsed.version.trim() !== "") return parsed.version;
2471
- } catch {}
2472
- } catch {}
2473
- return embedded;
2474
- }
2475
3082
  //#endregion
2476
3083
  //#region src/whats-new-state.ts
2477
3084
  /**
@@ -2738,7 +3345,7 @@ function WhatsNewContent(props) {
2738
3345
  */
2739
3346
  async function maybeShowWhatsNewV2(context) {
2740
3347
  try {
2741
- const version = await resolveRunningVersion(import.meta.url);
3348
+ const version = await resolveRunningVersion$1(import.meta.url);
2742
3349
  if (!version) return;
2743
3350
  const statePath = await defaultWhatsNewStatePath();
2744
3351
  const changelogText = await readChangelogForBundle(import.meta.url);
@@ -3300,7 +3907,7 @@ function turnTokensPerSecond(messages, position) {
3300
3907
  * unavailable (never `undefined%`). A block with neither tokens nor cost
3301
3908
  * yields null. `gaugeStyle` (the TUI tab's pref) picks the percent-row
3302
3909
  * shape: `both` (default), `bar`, `percent`, or `off` (row omitted). Pure. */
3303
- function contextBlockRows(usage, cost, gaugeStyle = "both") {
3910
+ function contextBlockRows(usage, cost, gaugeStyle = "both", barOptions) {
3304
3911
  const spentValue = formatSpent(cost);
3305
3912
  const spent = spentValue === null ? null : {
3306
3913
  lead: null,
@@ -3324,7 +3931,7 @@ function contextBlockRows(usage, cost, gaugeStyle = "both") {
3324
3931
  };
3325
3932
  const percentValue = numberOrNull(usage.percent);
3326
3933
  const window = formatContextWindow(usage.limit);
3327
- const bar = contextBar(percentValue);
3934
+ const bar = contextBar(percentValue, barOptions ?? 12);
3328
3935
  let percent = null;
3329
3936
  if (gaugeStyle !== "off" && bar !== null && percentValue !== null) {
3330
3937
  const suffix = window === null ? null : ` of ${window}`;
@@ -5109,7 +5716,7 @@ async function checkForPantheonUpdate(context) {
5109
5716
  const latest = String((await response.json())?.version ?? "");
5110
5717
  if (!latest) return;
5111
5718
  const notice = pickUpdateNotice({
5112
- currentVersion: "2.0.0-beta.6",
5719
+ currentVersion: "2.0.0-rc.1",
5113
5720
  latestVersion: latest,
5114
5721
  state: readState(),
5115
5722
  nowMs: Date.now()
@@ -5873,7 +6480,12 @@ function Sidebar(props) {
5873
6480
  const usageHidden = () => hiddenModelUsageText(model.modelUsage().hidden, model.modelUsage().hiddenCost);
5874
6481
  const contextRows = () => {
5875
6482
  const prefs = tuiPrefs();
5876
- const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge);
6483
+ const barCells = prefs.sidebar.context.barWidth === "compact" ? 8 : prefs.sidebar.context.barWidth === "wide" ? 16 : prefs.sidebar.context.barWidth === "full" ? 20 : 12;
6484
+ const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge, {
6485
+ shape: prefs.sidebar.context.barShape,
6486
+ cells: barCells,
6487
+ evenMark: prefs.sidebar.context.evenMark
6488
+ });
5877
6489
  if (rows === null) return null;
5878
6490
  return {
5879
6491
  tokens: prefs.sidebar.context.tokens ? rows.tokens : null,
@@ -5896,7 +6508,8 @@ function Sidebar(props) {
5896
6508
  var _el$12 = createElement("box");
5897
6509
  setProp(_el$12, "flexDirection", "column");
5898
6510
  setProp(_el$12, "width", "100%");
5899
- setProp(_el$12, "padding", 1);
6511
+ setProp(_el$12, "paddingLeft", 1);
6512
+ setProp(_el$12, "paddingRight", 1);
5900
6513
  insert(_el$12, createComponent(Show, {
5901
6514
  get when() {
5902
6515
  return header().version;
@@ -5904,7 +6517,7 @@ function Sidebar(props) {
5904
6517
  get children() {
5905
6518
  var _el$13 = createElement("text");
5906
6519
  setProp(_el$13, "attributes", 1);
5907
- insert(_el$13, `Pantheon v2.0.0-beta.6`);
6520
+ insert(_el$13, `Pantheon v2.0.0-rc.1`);
5908
6521
  effect((_$p) => setProp(_el$13, "fg", text(), _$p));
5909
6522
  return _el$13;
5910
6523
  }
@@ -6174,9 +6787,9 @@ function Sidebar(props) {
6174
6787
  insertNode(_el$39, createTextNode(`⎇ `));
6175
6788
  insert(_el$41, () => truncateLabel(value(), 32));
6176
6789
  effect((_p$) => {
6177
- var _v$3 = muted(), _v$4 = text();
6178
- _v$3 !== _p$.e && (_p$.e = setProp(_el$39, "fg", _v$3, _p$.e));
6179
- _v$4 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$4, _p$.t));
6790
+ var _v$5 = muted(), _v$6 = text();
6791
+ _v$5 !== _p$.e && (_p$.e = setProp(_el$39, "fg", _v$5, _p$.e));
6792
+ _v$6 !== _p$.t && (_p$.t = setProp(_el$41, "fg", _v$6, _p$.t));
6180
6793
  return _p$;
6181
6794
  }, {
6182
6795
  e: void 0,
@@ -6312,9 +6925,9 @@ function Sidebar(props) {
6312
6925
  setProp(_el$47, "flexShrink", 0);
6313
6926
  insert(_el$48, () => row.text);
6314
6927
  effect((_p$) => {
6315
- var _v$5 = open(row.id), _v$6 = tone("success");
6316
- _v$5 !== _p$.e && (_p$.e = setProp(_el$47, "onMouseDown", _v$5, _p$.e));
6317
- _v$6 !== _p$.t && (_p$.t = setProp(_el$48, "fg", _v$6, _p$.t));
6928
+ var _v$7 = open(row.id), _v$8 = tone("success");
6929
+ _v$7 !== _p$.e && (_p$.e = setProp(_el$47, "onMouseDown", _v$7, _p$.e));
6930
+ _v$8 !== _p$.t && (_p$.t = setProp(_el$48, "fg", _v$8, _p$.t));
6318
6931
  return _p$;
6319
6932
  }, {
6320
6933
  e: void 0,
@@ -6387,6 +7000,15 @@ function Sidebar(props) {
6387
7000
  return _el$23;
6388
7001
  }
6389
7002
  }), null);
7003
+ effect((_p$) => {
7004
+ var _v$3 = tuiPrefs().layout.preset === "compact" ? 0 : 1, _v$4 = tuiPrefs().layout.preset === "compact" ? 0 : 1;
7005
+ _v$3 !== _p$.e && (_p$.e = setProp(_el$12, "paddingTop", _v$3, _p$.e));
7006
+ _v$4 !== _p$.t && (_p$.t = setProp(_el$12, "paddingBottom", _v$4, _p$.t));
7007
+ return _p$;
7008
+ }, {
7009
+ e: void 0,
7010
+ t: void 0
7011
+ });
6390
7012
  return _el$12;
6391
7013
  })();
6392
7014
  }
@@ -6464,10 +7086,10 @@ function DispatchPanel(props) {
6464
7086
  insert(_el$55, () => selected(row.id) ? `▸ ` : " ");
6465
7087
  insert(_el$56, () => row.text);
6466
7088
  effect((_p$) => {
6467
- var _v$7 = selected(row.id) ? text() : muted(), _v$8 = rowFg(row.state), _v$9 = selected(row.id) ? 1 : 0;
6468
- _v$7 !== _p$.e && (_p$.e = setProp(_el$55, "fg", _v$7, _p$.e));
6469
- _v$8 !== _p$.t && (_p$.t = setProp(_el$56, "fg", _v$8, _p$.t));
6470
- _v$9 !== _p$.a && (_p$.a = setProp(_el$56, "attributes", _v$9, _p$.a));
7089
+ var _v$9 = selected(row.id) ? text() : muted(), _v$0 = rowFg(row.state), _v$1 = selected(row.id) ? 1 : 0;
7090
+ _v$9 !== _p$.e && (_p$.e = setProp(_el$55, "fg", _v$9, _p$.e));
7091
+ _v$0 !== _p$.t && (_p$.t = setProp(_el$56, "fg", _v$0, _p$.t));
7092
+ _v$1 !== _p$.a && (_p$.a = setProp(_el$56, "attributes", _v$1, _p$.a));
6471
7093
  return _p$;
6472
7094
  }, {
6473
7095
  e: void 0,
@@ -6599,10 +7221,10 @@ function DispatchPanel(props) {
6599
7221
  setProp(_el$66, "height", 1);
6600
7222
  insert(_el$67, () => model.footer());
6601
7223
  effect((_p$) => {
6602
- var _v$0 = text(), _v$1 = muted(), _v$10 = muted();
6603
- _v$0 !== _p$.e && (_p$.e = setProp(_el$61, "fg", _v$0, _p$.e));
6604
- _v$1 !== _p$.t && (_p$.t = setProp(_el$62, "fg", _v$1, _p$.t));
6605
- _v$10 !== _p$.a && (_p$.a = setProp(_el$67, "fg", _v$10, _p$.a));
7224
+ var _v$10 = text(), _v$11 = muted(), _v$12 = muted();
7225
+ _v$10 !== _p$.e && (_p$.e = setProp(_el$61, "fg", _v$10, _p$.e));
7226
+ _v$11 !== _p$.t && (_p$.t = setProp(_el$62, "fg", _v$11, _p$.t));
7227
+ _v$12 !== _p$.a && (_p$.a = setProp(_el$67, "fg", _v$12, _p$.a));
6606
7228
  return _p$;
6607
7229
  }, {
6608
7230
  e: void 0,
@@ -6667,7 +7289,7 @@ function HomeStatus(props) {
6667
7289
  },
6668
7290
  get children() {
6669
7291
  var _el$73 = createElement("text");
6670
- insert(_el$73, () => `Pantheon v2.0.0-beta.6${preset().name ? ` ▸ ${preset().name}` : ""}`);
7292
+ insert(_el$73, () => `Pantheon v2.0.0-rc.1${preset().name ? ` ▸ ${preset().name}` : ""}`);
6671
7293
  effect((_$p) => setProp(_el$73, "fg", muted(), _$p));
6672
7294
  return _el$73;
6673
7295
  }