pantheon-opencode 2.0.0-beta.2 → 2.0.0-beta.4

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.
@@ -19,7 +19,7 @@ import type { OverridesLoad } from './pantheon-settings-state.ts'
19
19
  import {
20
20
  SETTINGS_BEHAVIORS,
21
21
  type SettingsRow,
22
- type SettingsSection,
22
+ type SettingsTab,
23
23
  } from './pantheon-settings-state.ts'
24
24
  import { comparePantheonVersions } from './update-notice.ts'
25
25
 
@@ -122,77 +122,86 @@ export interface DoctorSectionInput {
122
122
  env?: Record<string, string | undefined>
123
123
  }
124
124
 
125
- export function buildDoctorSection(input: DoctorSectionInput): SettingsSection {
125
+ export function buildDoctorTab(input: DoctorSectionInput): SettingsTab {
126
126
  const env = input.env ?? process.env
127
127
  const rows: SettingsRow[] = []
128
128
 
129
129
  const version = classifyInstallVersion(input.runningVersion, env)
130
130
  rows.push({
131
131
  id: 'doctor.version',
132
- title:
132
+ name: 'Install version',
133
+ value:
133
134
  version.status === 'ok'
134
- ? `Installed version: v${version.installed} — matches`
135
+ ? `v${version.installed} — matches`
135
136
  : version.status === 'older'
136
- ? `Installed v${version.installed} is older than the runtime v${input.runningVersion}`
137
+ ? `v${version.installed} older`
137
138
  : version.status === 'newer'
138
- ? `Installed v${version.installed} is newer than the runtime v${input.runningVersion}`
139
- : 'Installed version: unknown (no install-state)',
140
- description:
139
+ ? `v${version.installed} newer`
140
+ : 'unknown',
141
+ note:
141
142
  version.status === 'older'
142
143
  ? 'refresh with `pantheon-opencode update`'
143
144
  : 'read from <config>/opencode/.pantheon/install-state.json',
144
- marker: version.status === 'ok' ? '[✓]' : version.status === 'older' ? '[!]' : '[i]',
145
- selectable: false,
146
145
  })
147
146
 
148
147
  const nodeOk = isSupportedNodeFloor(input.nodeVersion)
149
148
  rows.push({
150
149
  id: 'doctor.node',
151
- title: `Node runtime: ${input.nodeVersion.replace(/^v/, '')}`,
152
- description: nodeOk
150
+ name: 'Node runtime',
151
+ value: input.nodeVersion.replace(/^v/, ''),
152
+ note: nodeOk
153
153
  ? `meets the >= ${MIN_SUPPORTED_NODE_VERSION} floor`
154
154
  : `below the >= ${MIN_SUPPORTED_NODE_VERSION} floor — tooling may refuse`,
155
- marker: nodeOk ? '[✓]' : '[!]',
156
- selectable: false,
157
155
  })
158
156
 
159
157
  const overrides = classifyOverridesHealth(input.load)
160
158
  rows.push({
161
159
  id: 'doctor.overrides',
162
- title:
160
+ name: 'Overrides',
161
+ value:
163
162
  overrides.status === 'clean'
164
- ? 'Overrides: valid'
163
+ ? 'valid'
165
164
  : overrides.status === 'corrupt'
166
- ? 'Overrides: global file unreadable'
167
- : `Overrides: ${overrides.unknownIds.length} unknown id(s)`,
168
- description:
165
+ ? 'unreadable'
166
+ : `${overrides.unknownIds.length} unknown id(s)`,
167
+ note:
169
168
  overrides.status === 'unknown-ids'
170
169
  ? `${overrides.unknownIds.join(', ')} — harmless; repair with doctor --fix`
171
170
  : overrides.status === 'corrupt'
172
171
  ? 'writes are refused until repaired (doctor --fix)'
173
172
  : 'both files parse against the behavior registry',
174
- marker: overrides.status === 'clean' ? '[✓]' : overrides.status === 'corrupt' ? '[✗]' : '[!]',
175
- selectable: false,
176
173
  })
177
174
 
178
175
  const decision = classifyDecisionConfigHealth(env)
179
176
  rows.push({
180
177
  id: 'doctor.decision',
181
- title:
182
- decision.status === 'ok'
183
- ? 'Decision config: valid'
184
- : decision.status === 'corrupt'
185
- ? 'Decision config: unreadable — runtime fail-closes'
186
- : 'Decision config: absent (local defaults)',
187
- description: 'read from <config>/pantheon/decision-router.json',
188
- marker: decision.status === 'corrupt' ? '[✗]' : '[✓]',
189
- selectable: false,
178
+ name: 'Decision config',
179
+ value:
180
+ decision.status === 'ok' ? 'valid' : decision.status === 'corrupt' ? 'corrupt' : 'absent',
181
+ note:
182
+ decision.status === 'corrupt'
183
+ ? 'runtime fail-closes to disabled · read from <config>/pantheon/decision-router.json'
184
+ : 'read from <config>/pantheon/decision-router.json',
190
185
  })
191
186
 
192
187
  return {
193
188
  id: 'doctor',
194
189
  title: 'Doctor',
195
- rows,
196
- hint: 'file checks only — the full doctor (MCP smoke, venv, git) is `pantheon-opencode doctor`',
190
+ groups: [
191
+ {
192
+ title: 'Health (file-derived)',
193
+ rows,
194
+ },
195
+ {
196
+ rows: [
197
+ {
198
+ id: 'doctor.cli',
199
+ name: 'Full check',
200
+ value: '`pantheon-opencode doctor`',
201
+ note: 'MCP smoke, venv pins, git stay in the CLI',
202
+ },
203
+ ],
204
+ },
205
+ ],
197
206
  }
198
207
  }
@@ -24,7 +24,11 @@ import {
24
24
  MODEL_USAGE_SESSION_LIMIT,
25
25
  MODEL_USAGE_VISIBLE_CEILING,
26
26
  } from './model-usage-limits'
27
- import { maybeShowPantheonSettings } from './pantheon-settings'
27
+ import {
28
+ openPantheonSettings,
29
+ pantheonSettingsBlocking,
30
+ setupPantheonSettings,
31
+ } from './pantheon-settings'
28
32
  import { cellWidth, GRAPHEMES, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
29
33
  import { nextCheckState, pickUpdateNotice, type UpdateCheckState } from './update-notice.ts'
30
34
  import { maybeShowWhatsNewV2 } from './whats-new'
@@ -4253,7 +4257,12 @@ export function dispatchPanelKeymapLayer(
4253
4257
  panel: Pick<PanelInput, 'focused' | 'close' | 'toggleFullscreen'>,
4254
4258
  model: DispatchPanelModel,
4255
4259
  ): KeymapLayer {
4256
- const focused = () => panel.focused === true
4260
+ // The dialog-suspension gate mirrors the host's own convention (global
4261
+ // session layers sleep while a dialog holds the stack): `panel.focused`
4262
+ // stays sticky after a `show()` blur-to-nothing, so without this gate the
4263
+ // dispatch panel stole the settings window's up/down/enter (beta.2 field
4264
+ // report — "navigation stopped working").
4265
+ const focused = () => panel.focused === true && !pantheonSettingsBlocking()
4257
4266
  return {
4258
4267
  mode: 'global',
4259
4268
  enabled: focused,
@@ -4408,7 +4417,7 @@ function PantheonSettingsCommandLayer(props: { context: any }) {
4408
4417
  palette: true,
4409
4418
  slash: { name: 'pantheon-settings' },
4410
4419
  run: () => {
4411
- void maybeShowPantheonSettings(props.context)
4420
+ void openPantheonSettings(props.context)
4412
4421
  },
4413
4422
  },
4414
4423
  ],
@@ -4554,6 +4563,15 @@ const plugin = Plugin.define({
4554
4563
  append: 'app',
4555
4564
  render: () => <PantheonSettingsCommandLayer context={context} />,
4556
4565
  })
4566
+ // The settings window surfaces: the full-screen router page (primary),
4567
+ // the legacy-host dialog fallback, and their keymap layers — registered
4568
+ // ONCE here with priority 1 so a stale same-bind layer can never win
4569
+ // while the window is open.
4570
+ try {
4571
+ setupPantheonSettings(context)
4572
+ } catch {
4573
+ /* settings unavailable on this host — the command toasts/fails open */
4574
+ }
4557
4575
  // One-time "What's new" window (per Pantheon version) — fire-and-forget:
4558
4576
  // resolves the running version and the shipped CHANGELOG.md, then opens a
4559
4577
  // host dialog when the version changed since the last dismissal. Fail-open;
@@ -10,7 +10,7 @@
10
10
  * writes, and the section says so. A file surface is a runtime-plugin change
11
11
  * (beta.3 candidate), not a window change.
12
12
  */
13
- import type { SettingsRow, SettingsSection } from './pantheon-settings-state.ts'
13
+ import type { SettingsTab } from './pantheon-settings-state.ts'
14
14
 
15
15
  export const J1_FLAG_ENV = 'PANTHEON_J1_RISK_SCORE'
16
16
  export const J1_THRESHOLD_ENV = 'PANTHEON_J1_ENFORCE_THRESHOLD'
@@ -44,10 +44,10 @@ const MODE_DESCRIPTION: Record<J1Mode, string> = {
44
44
  enforce: 'high-risk scores DENY the tool call (fail-open on gate unavailability)',
45
45
  }
46
46
 
47
- export function buildJ1Section(
47
+ export function buildJ1Tab(
48
48
  env: Record<string, string | undefined>,
49
49
  disabledByOverride: boolean,
50
- ): SettingsSection {
50
+ ): SettingsTab {
51
51
  const mode = j1ModeFromEnv(env)
52
52
  const threshold = j1ThresholdFromEnv(env)
53
53
  const gateState = disabledByOverride
@@ -55,31 +55,33 @@ export function buildJ1Section(
55
55
  : mode === 'off'
56
56
  ? 'off (env unset)'
57
57
  : 'active'
58
- const rows: SettingsRow[] = [
59
- {
60
- id: 'j1.mode',
61
- title: `Mode: ${mode}`,
62
- description: MODE_DESCRIPTION[mode],
63
- ...(disabledByOverride ? { marker: '[!]' } : {}),
64
- selectable: false,
65
- },
66
- {
67
- id: 'j1.threshold',
68
- title: `Enforce threshold: ${threshold}`,
69
- description: 'deny at or above; 0..1, default 0.8',
70
- selectable: false,
71
- },
72
- {
73
- id: 'j1.gate',
74
- title: `Gate: ${gateState}`,
75
- description: 'the runtime plugin reads this once at startup',
76
- selectable: false,
77
- },
78
- ]
79
58
  return {
80
59
  id: 'j1',
81
- title: 'J1 Risk Gate',
82
- hint: `set ${J1_FLAG_ENV} / ${J1_THRESHOLD_ENV} — restart applies`,
83
- rows,
60
+ title: 'J1',
61
+ groups: [
62
+ {
63
+ title: 'Ladder (env-only — never written here)',
64
+ rows: [
65
+ {
66
+ id: 'j1.mode',
67
+ name: 'Mode',
68
+ value: mode,
69
+ note: `${MODE_DESCRIPTION[mode]} · restart applies`,
70
+ },
71
+ {
72
+ id: 'j1.threshold',
73
+ name: 'Enforce threshold',
74
+ value: String(threshold),
75
+ note: 'deny at or above · 0..1 · default 0.8',
76
+ },
77
+ {
78
+ id: 'j1.gate',
79
+ name: 'Gate',
80
+ value: gateState,
81
+ note: `${J1_FLAG_ENV} / ${J1_THRESHOLD_ENV} · read once at startup`,
82
+ },
83
+ ],
84
+ },
85
+ ],
84
86
  }
85
87
  }
@@ -3,15 +3,14 @@
3
3
  *
4
4
  * TUI-local copy doctrine (same as cost-data.ts): the bundle must stay
5
5
  * self-contained. The behaviors registry mirrors routing.yml's `behaviors:`
6
- * (drift-pinned by tests/pantheon-settings-state.test.mjs); the Gates section
7
- * reads and writes the GLOBAL overrides file — the same one
8
- * `pantheon-opencode`'s installer and doctor consume
9
- * (`<config-dir>/pantheon-overrides.json`).
6
+ * (drift-pinned by tests/pantheon-settings-state.test.mjs).
10
7
  *
11
- * Sections: the window renders one section per page. This module owns the
12
- * section/row model and the Gates section; other sections live in sibling
13
- * TUI-local modules (j1-gate-status.ts, update-status.ts, …) and follow the
14
- * same shape.
8
+ * Model (2.0.0-beta.4, the quota-style full window): the window is a set of
9
+ * TABS; each tab holds GROUPS of setting ROWS; a row carries a display VALUE
10
+ * and — when the setting is editable — the CYCLE of allowed values that
11
+ * ←/→ steps through. Edits stage into a DRAFT (id → pending value); `save`
12
+ * applies the draft through injected writers, `reset` drops it. The disk
13
+ * never changes before save.
15
14
  */
16
15
 
17
16
  export interface SettingsBehavior {
@@ -75,84 +74,19 @@ export interface OverrideEntry {
75
74
 
76
75
  export type EffectiveOverrides = Record<string, OverrideEntry>
77
76
 
78
- /** Which behaviors the settings window can toggle (runtime + install skills). */
77
+ /** Which behaviors the settings window can write (runtime + install skills). */
79
78
  export const SETTINGS_TOGGLABLE_IDS = new Set(SETTINGS_BEHAVIORS.map((b) => b.id))
80
79
 
81
80
  export function isBehaviorDisabled(effective: EffectiveOverrides, id: string): boolean {
82
81
  return effective[id]?.action === 'disable'
83
82
  }
84
83
 
85
- // ── Section / row model ────────────────────────────────────────────────
86
-
87
- export interface SettingsRow {
88
- /** Namespaced action key (`gate.<behavior-id>`, `update.check`, …). */
89
- id: string
90
- title: string
91
- description: string
92
- /** Gates rows: the override disables the behavior (`[x]` marker). */
93
- disabled?: boolean
94
- /** Overrides the `[x]`/`[ ]` marker (`→` action, `✓`/`!` status). */
95
- marker?: string
96
- /** false → skipped by up/down and never dispatched by enter (info lines). */
97
- selectable?: boolean
98
- /** The effective entry comes from the PROJECT overrides file (read-only). */
99
- source?: 'global' | 'project'
100
- }
101
-
102
- export interface SettingsSection {
103
- id: string
104
- title: string
105
- /** One muted hint line under the rows. */
106
- hint?: string
107
- rows: SettingsRow[]
108
- }
109
-
110
- /** The rows up/down can reach and enter can dispatch on, in order. */
111
- export function selectableRows(section: SettingsSection): SettingsRow[] {
112
- return section.rows.filter((row) => row.selectable !== false)
113
- }
114
-
115
- /** Flat selection order across every section of the window. */
116
- export function flatSelectableRows(sections: readonly SettingsSection[]): SettingsRow[] {
117
- return sections.flatMap((section) => selectableRows(section))
118
- }
119
-
120
- export function firstSelectableId(sections: readonly SettingsSection[]): string | undefined {
121
- return flatSelectableRows(sections)[0]?.id
122
- }
123
-
124
- // ── Overrides load (global + project files) ────────────────────────────
125
-
126
- export interface OverridesLoad {
127
- global: EffectiveOverrides
128
- project: EffectiveOverrides
129
- /** The GLOBAL file exists but does not parse — writes are refused. */
130
- corruptGlobal: boolean
131
- }
132
-
133
- /**
134
- * Merge for DISPLAY only, mirroring the runtime precedence: the project file
135
- * wins per id (whole entry). The window still writes only the global file.
136
- */
137
- export function mergedOverrides(load: OverridesLoad): EffectiveOverrides {
138
- return { ...load.global, ...load.project }
139
- }
140
-
141
- export function canWriteOverrides(load: OverridesLoad): boolean {
142
- return !load.corruptGlobal
143
- }
144
-
145
- // ── Toggle semantics ───────────────────────────────────────────────────
146
-
147
84
  export const TOGGLE_REASON = 'toggled in /pantheon-settings'
148
85
 
149
86
  /**
150
- * Toggle: disabled -> enabled; enabled -> disabled.
151
- *
152
- * A `replace` entry is never destroyed by a toggle ("never trap user state"):
153
- * disabling keeps its `content` under the disable entry, and re-enabling
154
- * restores the replace. A settings-written disable (no content) is removed
155
- * outright so the overrides file does not accumulate toggle noise.
87
+ * Toggle (a targeted write keeps the toggle semantics: a `replace` entry is
88
+ * never destroyed — disabling keeps its `content`, re-enabling restores the
89
+ * replace; a settings-written disable is removed outright, no toggle noise).
156
90
  */
157
91
  export function toggledOverrides(
158
92
  effective: EffectiveOverrides,
@@ -163,8 +97,6 @@ export function toggledOverrides(
163
97
  const entry = next[id]
164
98
  if (entry?.action === 'disable') {
165
99
  if (entry.content !== undefined) {
166
- // A settings-written disable restores a clean replace; a hand-authored
167
- // disable+content keeps its own provenance reason.
168
100
  next[id] =
169
101
  entry.reason === reason
170
102
  ? { action: 'replace', content: entry.content }
@@ -185,60 +117,227 @@ export function toggledOverrides(
185
117
  return next
186
118
  }
187
119
 
120
+ /** Set an explicit on/off target (the cycler's save path) via the toggle semantics. */
121
+ export function setOverrideState(
122
+ effective: EffectiveOverrides,
123
+ id: string,
124
+ target: 'enabled' | 'disabled',
125
+ reason: string = TOGGLE_REASON,
126
+ ): EffectiveOverrides {
127
+ const disabled = isBehaviorDisabled(effective, id)
128
+ if ((target === 'disabled') === disabled) return effective
129
+ return toggledOverrides(effective, id, reason)
130
+ }
131
+
188
132
  export function serializeOverrides(effective: EffectiveOverrides): string {
189
133
  const ordered: Record<string, unknown> = {}
190
134
  for (const id of Object.keys(effective).sort()) ordered[id] = effective[id]
191
135
  return `${JSON.stringify(ordered, null, 2)}\n`
192
136
  }
193
137
 
194
- // ── Gates section ──────────────────────────────────────────────────────
138
+ // ── Overrides load (global + project files) ────────────────────────────
139
+
140
+ export interface OverridesLoad {
141
+ global: EffectiveOverrides
142
+ project: EffectiveOverrides
143
+ /** The GLOBAL file exists but does not parse — writes are refused. */
144
+ corruptGlobal: boolean
145
+ }
146
+
147
+ /** Merge for DISPLAY only, mirroring the runtime precedence: project wins per id. */
148
+ export function mergedOverrides(load: OverridesLoad): EffectiveOverrides {
149
+ return { ...load.global, ...load.project }
150
+ }
151
+
152
+ export function canWriteOverrides(load: OverridesLoad): boolean {
153
+ return !load.corruptGlobal
154
+ }
155
+
156
+ // ── Tab / group / row model (the cycler window) ────────────────────────
157
+
158
+ export interface SettingsRow {
159
+ id: string
160
+ name: string
161
+ /** Current effective value (display); the staged draft may differ. */
162
+ value: string
163
+ /** Allowed values for ←/→; presence marks the row as editable. */
164
+ cycle?: readonly string[]
165
+ /** Right-column note (writes-where, applies-live, from-where). */
166
+ note?: string
167
+ /** Enter triggers this action instead of cycling (e.g. `update-check`). */
168
+ action?: string
169
+ }
170
+
171
+ export interface SettingsGroup {
172
+ /** Bold group header; undefined renders rows without a header. */
173
+ title?: string
174
+ rows: SettingsRow[]
175
+ }
176
+
177
+ export interface SettingsTab {
178
+ id: string
179
+ title: string
180
+ groups: SettingsGroup[]
181
+ }
182
+
183
+ /** Neutral tab for out-of-range indexes (noUncheckedIndexedAccess guard). */
184
+ export const EMPTY_TAB: SettingsTab = { id: 'empty', title: '', groups: [] }
185
+
186
+ /** Flat, in-order rows of a tab (the up/down navigation space). */
187
+ export function tabRows(tab: SettingsTab): SettingsRow[] {
188
+ return tab.groups.flatMap((group) => group.rows)
189
+ }
190
+
191
+ export function findRow(tab: SettingsTab, id: string): SettingsRow | undefined {
192
+ return tabRows(tab).find((row) => row.id === id)
193
+ }
194
+
195
+ // ── The cycler ─────────────────────────────────────────────────────────
196
+
197
+ /** Step through the cycle with wrap-around; non-cyclable rows return the input. */
198
+ export function cycleValue(value: string, cycle: readonly string[], direction: 1 | -1): string {
199
+ if (cycle.length === 0) return value
200
+ const index = cycle.indexOf(value)
201
+ if (index === -1) return cycle[0] ?? value
202
+ const next = (index + direction + cycle.length) % cycle.length
203
+ return cycle[next] ?? value
204
+ }
205
+
206
+ // ── The draft (staged edits; the disk never changes before save) ───────
207
+
208
+ export type SettingsDraft = Record<string, string>
209
+
210
+ export function stageValue(
211
+ draft: SettingsDraft,
212
+ row: SettingsRow,
213
+ direction: 1 | -1,
214
+ ): SettingsDraft {
215
+ if (row.cycle === undefined) return draft
216
+ const current = draft[row.id] ?? row.value
217
+ const staged = cycleValue(current, row.cycle, direction)
218
+ if (staged === row.value) {
219
+ // staged back onto the disk value — drop the entry (no toggle noise)
220
+ if (draft[row.id] === undefined) return draft
221
+ const next = { ...draft }
222
+ delete next[row.id]
223
+ return next
224
+ }
225
+ return { ...draft, [row.id]: staged }
226
+ }
227
+
228
+ /** Drop every staged entry of one tab (ctrl+r). */
229
+ export function resetTab(draft: SettingsDraft, tab: SettingsTab): SettingsDraft {
230
+ const ids = new Set(tabRows(tab).map((row) => row.id))
231
+ const next: SettingsDraft = {}
232
+ for (const [id, value] of Object.entries(draft)) {
233
+ if (!ids.has(id)) next[id] = value
234
+ }
235
+ return next
236
+ }
237
+
238
+ export function draftCount(draft: SettingsDraft): number {
239
+ return Object.keys(draft).length
240
+ }
241
+
242
+ export function draftDirty(draft: SettingsDraft): boolean {
243
+ return draftCount(draft) > 0
244
+ }
245
+
246
+ export function tabDirty(draft: SettingsDraft, tab: SettingsTab): boolean {
247
+ return tabRows(tab).some((row) => draft[row.id] !== undefined)
248
+ }
249
+
250
+ // ── Applying the draft ─────────────────────────────────────────────────
251
+
252
+ export interface DraftWriterResult {
253
+ ok: boolean
254
+ reason?: string
255
+ }
195
256
 
196
257
  /**
197
- * The Gates & Overrides page: behavior state from BOTH overrides files.
198
- * A project-owned entry wins the runtime merge and the window only writes
199
- * the global file, so project rows are marked and not togglable here.
258
+ * One callback that dispatches a staged row to its real writer (gates →
259
+ * overrides file, decision → decision-router.json, preset → active-preset).
260
+ *Injected by the glue so the disk never runs in tests.
200
261
  */
201
- export function buildGatesSection(load: OverridesLoad): SettingsSection {
262
+ export type DraftWriter = (id: string, value: string) => DraftWriterResult
263
+
264
+ export interface AppliedDraft {
265
+ applied: string[]
266
+ failed: { id: string; reason: string }[]
267
+ }
268
+
269
+ /** Apply every staged entry; failures are collected, never thrown. */
270
+ export function applyDraft(draft: SettingsDraft, writer: DraftWriter): AppliedDraft {
271
+ const applied: string[] = []
272
+ const failed: AppliedDraft['failed'] = []
273
+ for (const [id, value] of Object.entries(draft)) {
274
+ const result = writer(id, value)
275
+ if (result.ok) applied.push(id)
276
+ else failed.push({ id, reason: result.reason ?? 'write failed' })
277
+ }
278
+ return { applied, failed }
279
+ }
280
+
281
+ /** The rows that succeeded and are still in the draft (failed ones stay staged). */
282
+ export function settledDraft(draft: SettingsDraft, applied: readonly string[]): SettingsDraft {
283
+ const next: SettingsDraft = {}
284
+ for (const [id, value] of Object.entries(draft)) {
285
+ if (!applied.includes(id)) next[id] = value
286
+ }
287
+ return next
288
+ }
289
+
290
+ // ── Gates / About tabs (behavior-native; the other tabs live in their modules) ──
291
+
292
+ export const GATES_ENABLED_CYCLE: readonly string[] = Object.freeze(['enabled', 'disabled'])
293
+
294
+ export function buildGatesTab(load: OverridesLoad): SettingsTab {
202
295
  const merged = mergedOverrides(load)
203
- const rows: SettingsRow[] = SETTINGS_BEHAVIORS.map((behavior) => {
296
+ const rowFor = (behavior: SettingsBehavior): SettingsRow => {
204
297
  const fromProject = load.project[behavior.id] !== undefined
298
+ const writable = !fromProject && canWriteOverrides(load)
205
299
  return {
206
300
  id: `gate.${behavior.id}`,
207
- title: fromProject ? `${behavior.title} (project)` : behavior.title,
208
- description: behavior.description,
209
- disabled: isBehaviorDisabled(merged, behavior.id),
210
- selectable: !fromProject,
211
- source: fromProject ? 'project' : 'global',
301
+ name: fromProject ? `${behavior.title} (project)` : behavior.title,
302
+ value: isBehaviorDisabled(merged, behavior.id) ? 'disabled' : 'enabled',
303
+ ...(writable ? { cycle: GATES_ENABLED_CYCLE } : {}),
304
+ note: fromProject
305
+ ? 'project file wins at runtime — edit .pantheon/overrides.json'
306
+ : behavior.description,
212
307
  }
213
- })
308
+ }
309
+ const install = SETTINGS_BEHAVIORS.filter((behavior) => behavior.kind === 'install')
310
+ const runtime = SETTINGS_BEHAVIORS.filter((behavior) => behavior.kind === 'runtime')
214
311
  return {
215
312
  id: 'gates',
216
- title: 'Gates & Overrides',
217
- hint: canWriteOverrides(load)
218
- ? 'enter: disable/enable · writes pantheon-overrides.json (global)'
219
- : 'overrides file unreadable — writes refused; repair with `pantheon-opencode doctor --fix`',
220
- rows,
313
+ title: 'Gates',
314
+ groups: [
315
+ { title: 'Install skills', rows: install.map(rowFor) },
316
+ { title: 'Runtime gates', rows: runtime.map(rowFor) },
317
+ ],
221
318
  }
222
319
  }
223
320
 
224
- // ── About section ──────────────────────────────────────────────────────
225
-
226
- export function buildAboutSection(version: string): SettingsSection {
321
+ export function buildAboutTab(version: string): SettingsTab {
227
322
  return {
228
323
  id: 'about',
229
324
  title: 'About',
230
- rows: [
231
- {
232
- id: 'about.version',
233
- title: `Pantheon v${version}`,
234
- description: 'OpenCode 2.x only — the V1 contract is removed.',
235
- selectable: false,
236
- },
325
+ groups: [
237
326
  {
238
- id: 'about.behaviors',
239
- title: `${SETTINGS_BEHAVIORS.length} togglable behaviors`,
240
- description: 'Docs: docs/design/2.0-settings-and-install.md',
241
- selectable: false,
327
+ rows: [
328
+ {
329
+ id: 'about.version',
330
+ name: 'Version',
331
+ value: `v${version}`,
332
+ note: 'OpenCode 2.x only — the V1 contract is removed',
333
+ },
334
+ {
335
+ id: 'about.behaviors',
336
+ name: 'Behaviors',
337
+ value: String(SETTINGS_BEHAVIORS.length),
338
+ note: 'docs/design/2.0-settings-and-install.md',
339
+ },
340
+ ],
242
341
  },
243
342
  ],
244
343
  }