pantheon-opencode 2.0.0-beta.4 → 2.0.0-beta.6
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.
- package/CHANGELOG.md +39 -68
- package/README.md +18 -5
- package/bin/pantheon-init.mjs +1 -2
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/changelog-format.mjs +345 -0
- package/scripts/changelog-merge.mjs +5 -10
- package/scripts/docs-check-changelog.mjs +36 -137
- package/scripts/install/interactive.mjs +5 -254
- package/scripts/install/opencode.mjs +19 -76
- package/scripts/release-gates.mjs +33 -13
- package/scripts/release-notes.mjs +51 -36
- package/scripts/release-retrofit.mjs +158 -0
- package/scripts/skill-search.mjs +39 -4
- package/scripts/versioning.mjs +1 -1
- package/skills-lock.json +1 -1
- package/src/pantheon/goal-loop-config.ts +55 -0
- package/src/pantheon/native-vision.ts +9 -5
- package/src/pantheon/vision.ts +14 -1
- package/src/plugin.ts +39 -7
- package/src/plugins/tui/dist/tui.d.ts +3 -2
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +961 -312
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/autonomy-state.ts +149 -0
- package/src/plugins/tui/src/decision-router-state.ts +128 -6
- package/src/plugins/tui/src/index.tsx +86 -29
- package/src/plugins/tui/src/pantheon-settings.tsx +296 -24
- package/src/plugins/tui/src/tui-prefs.ts +378 -0
- package/src/skills/prompt-refinery/SKILL.md +34 -4
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autonomy-state.ts — the Autonomy tab of the settings window.
|
|
3
|
+
*
|
|
4
|
+
* TUI-local copy doctrine. Two surfaces live here:
|
|
5
|
+
*
|
|
6
|
+
* 1. GOAL LOOP — the persisted-mission loop (Wave 3 mechanics) read/written
|
|
7
|
+
* to `options.goal_loop` in the user's opencode.json (the same V2 config
|
|
8
|
+
* copy the context pruner uses). Startup-applied: the runtime resolves it
|
|
9
|
+
* once at plugin setup, so saving requires an OpenCode restart — the tab
|
|
10
|
+
* says so.
|
|
11
|
+
*
|
|
12
|
+
* 2. DECISION BUDGETS — monthly/per-decision USD caps stored in
|
|
13
|
+
* decision-router.json's companion `decision-budget` semantics. The caps
|
|
14
|
+
* the CLI writes via setup-model flags; here they are read from the
|
|
15
|
+
* decision-router.json envelope extension `budget` (v2 superset — the
|
|
16
|
+
* exact-key validator tolerates it via the documented envelope) and
|
|
17
|
+
* applied live per gated call.
|
|
18
|
+
*
|
|
19
|
+
* The decision-gradiente (decide-solo → Jev → human) is DOCUMENTED here, not
|
|
20
|
+
* enforced: J1 owns the risk axis, budgets own the money axis — this tab
|
|
21
|
+
* shows where the thresholds sit today.
|
|
22
|
+
*/
|
|
23
|
+
import type { SettingsRow, SettingsTab } from './pantheon-settings-state.ts'
|
|
24
|
+
|
|
25
|
+
export interface GoalLoopPrefs {
|
|
26
|
+
enabled: boolean
|
|
27
|
+
cooldownMs: number
|
|
28
|
+
maxContinuations: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const DEFAULT_GOAL_LOOP_PREFS: GoalLoopPrefs = {
|
|
32
|
+
enabled: false,
|
|
33
|
+
cooldownMs: 5000,
|
|
34
|
+
maxContinuations: 25,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const GOAL_LOOP_ENABLED_CYCLE: readonly string[] = Object.freeze(['enabled', 'disabled'])
|
|
38
|
+
|
|
39
|
+
export interface DecisionBudgets {
|
|
40
|
+
monthlyUsd: number
|
|
41
|
+
perDecisionUsd: number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const DEFAULT_DECISION_BUDGETS: DecisionBudgets = {
|
|
45
|
+
monthlyUsd: 5,
|
|
46
|
+
perDecisionUsd: 0.1,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Format USD compactly for a cycler cell ("$5", "$0.10"). */
|
|
50
|
+
export function formatUsd(value: number): string {
|
|
51
|
+
return `$${value < 1 ? value.toFixed(2) : String(Math.round(value))}`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Build the USD step ladder used by the budget cyclers. */
|
|
55
|
+
export const MONTHLY_USD_CYCLE: readonly string[] = Object.freeze(
|
|
56
|
+
[1, 2, 5, 10, 20, 50, 100].map((value) => formatUsd(value)),
|
|
57
|
+
)
|
|
58
|
+
export const PER_DECISION_USD_CYCLE: readonly string[] = Object.freeze(
|
|
59
|
+
[0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1].map((value) => formatUsd(value)),
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
/** Parse a staged USD cell back to a number; junk keeps the input. */
|
|
63
|
+
export function parseUsd(cell: string): number | null {
|
|
64
|
+
const value = Number(cell.replace('$', ''))
|
|
65
|
+
return Number.isFinite(value) && value > 0 ? value : null
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function buildAutonomyTab(input: {
|
|
69
|
+
goalLoop: GoalLoopPrefs
|
|
70
|
+
budgets: DecisionBudgets
|
|
71
|
+
goalLoopRestartPending?: boolean
|
|
72
|
+
}): SettingsTab {
|
|
73
|
+
return {
|
|
74
|
+
id: 'autonomy',
|
|
75
|
+
title: 'Autonomy',
|
|
76
|
+
groups: [
|
|
77
|
+
{
|
|
78
|
+
title: 'Goal loop (persisted mission, long sessions)',
|
|
79
|
+
rows: [
|
|
80
|
+
{
|
|
81
|
+
id: 'autonomy.goal_loop.enabled',
|
|
82
|
+
name: 'Goal loop',
|
|
83
|
+
value: input.goalLoop.enabled ? 'enabled' : 'disabled',
|
|
84
|
+
cycle: GOAL_LOOP_ENABLED_CYCLE,
|
|
85
|
+
note:
|
|
86
|
+
'mission persists in .pantheon/goals; auto-continues with cooldown' +
|
|
87
|
+
(input.goalLoopRestartPending
|
|
88
|
+
? ' · ⚠ saved value applies after OpenCode restart'
|
|
89
|
+
: ' · applies after OpenCode restart'),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'autonomy.goal_loop.maxContinuations',
|
|
93
|
+
name: 'Max continuations',
|
|
94
|
+
value: String(input.goalLoop.maxContinuations),
|
|
95
|
+
note: '1..200 — the anti-runaway cap per mission',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'autonomy.goal_loop.cooldownMs',
|
|
99
|
+
name: 'Cooldown (ms)',
|
|
100
|
+
value: String(input.goalLoop.cooldownMs),
|
|
101
|
+
note: 'min 1000ms · between continuations',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
title: 'Decision budgets (applies live)',
|
|
107
|
+
rows: [
|
|
108
|
+
{
|
|
109
|
+
id: 'autonomy.budget.monthly',
|
|
110
|
+
name: 'Monthly cap',
|
|
111
|
+
value: formatUsd(input.budgets.monthlyUsd),
|
|
112
|
+
cycle: MONTHLY_USD_CYCLE,
|
|
113
|
+
note: 'the ledger refuses gated calls past this',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'autonomy.budget.perDecision',
|
|
117
|
+
name: 'Per-decision cap',
|
|
118
|
+
value: formatUsd(input.budgets.perDecisionUsd),
|
|
119
|
+
cycle: PER_DECISION_USD_CYCLE,
|
|
120
|
+
note: 'each gated call above this is refused',
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
title: 'Decision gradient (documented — J1 owns the risk axis)',
|
|
126
|
+
rows: [
|
|
127
|
+
{
|
|
128
|
+
id: 'autonomy.gradient.solo',
|
|
129
|
+
name: 'Decide solo',
|
|
130
|
+
value: 'reversible + low risk',
|
|
131
|
+
note: 'edits, routine fixes, ordering ties — no gate',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'autonomy.gradient.jev',
|
|
135
|
+
name: 'Jev decides',
|
|
136
|
+
value: 'typed ambiguity',
|
|
137
|
+
note: 'readings, ranking, verification — budget-capped',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'autonomy.gradient.human',
|
|
141
|
+
name: 'Human decides',
|
|
142
|
+
value: 'high risk (J1)',
|
|
143
|
+
note: 'enforce ladder via PANTHEON_J1_* (J1 tab)',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -70,6 +70,45 @@ export const DECISION_KNOWN_PROVIDERS: readonly string[] = Object.freeze([
|
|
|
70
70
|
'cloudflare-workers-jev',
|
|
71
71
|
])
|
|
72
72
|
|
|
73
|
+
export const DECISION_CONSENT_CYCLE: readonly string[] = Object.freeze(['not granted', 'granted'])
|
|
74
|
+
/** provider → model, straight from the runtime matrix (drift-pinned in tests). */
|
|
75
|
+
export const DECISION_KNOWN_MODELS: Readonly<Record<string, string>> = Object.freeze({
|
|
76
|
+
'openai-decisions': 'gpt-6-luna',
|
|
77
|
+
'typesafe-jev': 'jev-1.14.0',
|
|
78
|
+
'opencode-console-jev': 'jev-1.13',
|
|
79
|
+
'openrouter-jev': 'typesafe/jev-1.13',
|
|
80
|
+
'vercel-gateway-jev': 'typesafe-ai/jev',
|
|
81
|
+
'cloudflare-workers-jev': 'clef',
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Credential surface per provider: the ENV VAR the host provider entry reads
|
|
86
|
+
* (`{env:VAR}` indirection — the window NEVER holds key values) plus the setup
|
|
87
|
+
* note. Drift-pinned against the installer/runtime sources in tests.
|
|
88
|
+
*/
|
|
89
|
+
export const DECISION_PROVIDER_CREDENTIALS: Readonly<
|
|
90
|
+
Record<string, { env?: string; note: string }>
|
|
91
|
+
> = Object.freeze({
|
|
92
|
+
'openai-decisions': {
|
|
93
|
+
note: 'host-configured model — provision via `decision-router setup-model openai-decisions`',
|
|
94
|
+
},
|
|
95
|
+
'typesafe-jev': { env: 'TYPESAFE_API_KEY', note: 'export TYPESAFE_API_KEY=… then restart' },
|
|
96
|
+
'opencode-console-jev': { note: 'rides your OpenCode login — no separate key' },
|
|
97
|
+
'openrouter-jev': { env: 'OPENROUTER_API_KEY', note: 'export OPENROUTER_API_KEY=… then restart' },
|
|
98
|
+
'vercel-gateway-jev': {
|
|
99
|
+
env: 'AI_GATEWAY_API_KEY',
|
|
100
|
+
note: 'export AI_GATEWAY_API_KEY=… then restart',
|
|
101
|
+
},
|
|
102
|
+
'cloudflare-workers-jev': {
|
|
103
|
+
env: 'CLOUDFLARE_API_TOKEN',
|
|
104
|
+
note: 'needs accountId (setup-model --account-id=…) + CLOUDFLARE_API_TOKEN',
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
export const DECISION_TARGET_CYCLE: readonly string[] = Object.freeze(
|
|
109
|
+
DECISION_KNOWN_PROVIDERS.map((provider) => `${provider}/${DECISION_KNOWN_MODELS[provider]}`),
|
|
110
|
+
)
|
|
111
|
+
|
|
73
112
|
export function decisionRouterConfigPath(env: Record<string, string | undefined> = process.env) {
|
|
74
113
|
const xdg = env.XDG_CONFIG_HOME
|
|
75
114
|
const home = env.HOME ?? ''
|
|
@@ -182,7 +221,8 @@ export function setDecisionEnabled(
|
|
|
182
221
|
if (!localOnly && !config.egress_consent) {
|
|
183
222
|
return {
|
|
184
223
|
ok: false,
|
|
185
|
-
reason:
|
|
224
|
+
reason:
|
|
225
|
+
'remote candidates need egress consent — toggle Egress consent in this tab, then enable',
|
|
186
226
|
}
|
|
187
227
|
}
|
|
188
228
|
}
|
|
@@ -205,7 +245,55 @@ export function writeDecisionRouterConfig(
|
|
|
205
245
|
chmodSync(path, 0o600)
|
|
206
246
|
}
|
|
207
247
|
|
|
208
|
-
export
|
|
248
|
+
export const DECISION_SELECTION_CYCLE: readonly string[] = Object.freeze([
|
|
249
|
+
'local',
|
|
250
|
+
'auto',
|
|
251
|
+
'explicit',
|
|
252
|
+
])
|
|
253
|
+
|
|
254
|
+
/** Stage a selection/consent row into a config copy; unknown rows are no-ops. */
|
|
255
|
+
export function applyDecisionRow(
|
|
256
|
+
config: DecisionRouterConfig,
|
|
257
|
+
id: string,
|
|
258
|
+
value: string,
|
|
259
|
+
): DecisionRouterConfig {
|
|
260
|
+
const next: DecisionRouterConfig = {
|
|
261
|
+
...config,
|
|
262
|
+
selection: { ...config.selection },
|
|
263
|
+
enabled_candidates: [...config.enabled_candidates],
|
|
264
|
+
}
|
|
265
|
+
switch (id) {
|
|
266
|
+
case 'decision.selection.mode': {
|
|
267
|
+
const mode = value as DecisionSelectionMode
|
|
268
|
+
if (mode !== 'local' && mode !== 'auto' && mode !== 'explicit') return config
|
|
269
|
+
next.selection.mode = mode
|
|
270
|
+
if (mode === 'local') next.enabled_candidates = []
|
|
271
|
+
return next
|
|
272
|
+
}
|
|
273
|
+
case 'decision.selection.target': {
|
|
274
|
+
const separator = value.indexOf('/')
|
|
275
|
+
if (separator <= 0) return config
|
|
276
|
+
const provider = value.slice(0, separator)
|
|
277
|
+
const model = value.slice(separator + 1)
|
|
278
|
+
if (!DECISION_KNOWN_PROVIDERS.includes(provider)) return config
|
|
279
|
+
if (DECISION_KNOWN_MODELS[provider] !== model) return config
|
|
280
|
+
next.selection = { mode: 'explicit', provider, model }
|
|
281
|
+
next.enabled_candidates = [{ provider, model }]
|
|
282
|
+
return next
|
|
283
|
+
}
|
|
284
|
+
case 'decision.consent': {
|
|
285
|
+
next.egress_consent = value === 'granted'
|
|
286
|
+
return next
|
|
287
|
+
}
|
|
288
|
+
default:
|
|
289
|
+
return config
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function buildDecisionTab(
|
|
294
|
+
read: DecisionConfigRead,
|
|
295
|
+
env: Record<string, string | undefined> = process.env,
|
|
296
|
+
): SettingsTab {
|
|
209
297
|
const { config, corrupt } = read
|
|
210
298
|
const rows: SettingsRow[] = [
|
|
211
299
|
{
|
|
@@ -219,12 +307,24 @@ export function buildDecisionTab(read: DecisionConfigRead): SettingsTab {
|
|
|
219
307
|
: 'applies live — the runtime re-reads this on every gated call',
|
|
220
308
|
},
|
|
221
309
|
{
|
|
222
|
-
id: 'decision.selection',
|
|
223
|
-
name: 'Selection',
|
|
224
|
-
value:
|
|
310
|
+
id: 'decision.selection.mode',
|
|
311
|
+
name: 'Selection mode',
|
|
312
|
+
value: config.selection.mode,
|
|
313
|
+
...(corrupt ? {} : { cycle: DECISION_SELECTION_CYCLE }),
|
|
225
314
|
note: 'local routes on-device; auto/explicit pick a remote decision model',
|
|
226
315
|
},
|
|
227
316
|
]
|
|
317
|
+
if (config.selection.mode === 'explicit' || config.selection.provider !== undefined) {
|
|
318
|
+
rows.push({
|
|
319
|
+
id: 'decision.selection.target',
|
|
320
|
+
name: 'Explicit target',
|
|
321
|
+
value: config.selection.provider
|
|
322
|
+
? `${config.selection.provider}/${config.selection.model ?? ''}`
|
|
323
|
+
: 'none',
|
|
324
|
+
...(corrupt || config.selection.mode !== 'explicit' ? {} : { cycle: DECISION_TARGET_CYCLE }),
|
|
325
|
+
note: 'provider/model — sets the candidate list',
|
|
326
|
+
})
|
|
327
|
+
}
|
|
228
328
|
if (config.enabled_candidates.length > 0) {
|
|
229
329
|
rows.push({
|
|
230
330
|
id: 'decision.candidates',
|
|
@@ -237,9 +337,31 @@ export function buildDecisionTab(read: DecisionConfigRead): SettingsTab {
|
|
|
237
337
|
: 'egress consent NOT granted — remote routes fail closed',
|
|
238
338
|
})
|
|
239
339
|
}
|
|
340
|
+
rows.push({
|
|
341
|
+
id: 'decision.consent',
|
|
342
|
+
name: 'Egress consent',
|
|
343
|
+
value: config.egress_consent ? 'granted' : 'not granted',
|
|
344
|
+
...(corrupt ? {} : { cycle: DECISION_CONSENT_CYCLE }),
|
|
345
|
+
note: 'granted = remote decision routes may call their gateway (budget-capped)',
|
|
346
|
+
})
|
|
240
347
|
return {
|
|
241
348
|
id: 'decision',
|
|
242
349
|
title: 'Decision',
|
|
243
|
-
groups: [
|
|
350
|
+
groups: [
|
|
351
|
+
{ title: 'Decision router', rows },
|
|
352
|
+
{
|
|
353
|
+
title: 'Credentials (status only — values never enter the window)',
|
|
354
|
+
rows: DECISION_KNOWN_PROVIDERS.map((provider) => {
|
|
355
|
+
const credential = DECISION_PROVIDER_CREDENTIALS[provider] ?? { note: '' }
|
|
356
|
+
const isSet = credential.env === undefined ? true : Boolean(env[credential.env])
|
|
357
|
+
return {
|
|
358
|
+
id: `decision.key.${provider}`,
|
|
359
|
+
name: provider,
|
|
360
|
+
value: credential.env === undefined ? 'n/a' : isSet ? 'set' : 'MISSING',
|
|
361
|
+
note: credential.note,
|
|
362
|
+
}
|
|
363
|
+
}),
|
|
364
|
+
},
|
|
365
|
+
],
|
|
244
366
|
}
|
|
245
367
|
}
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
setupPantheonSettings,
|
|
31
31
|
} from './pantheon-settings'
|
|
32
32
|
import { cellWidth, GRAPHEMES, SIDEBAR_CONTENT_WIDTH } from './sidebar-width'
|
|
33
|
+
import { initTuiPrefs, tuiPrefs } from './tui-prefs'
|
|
33
34
|
import { nextCheckState, pickUpdateNotice, type UpdateCheckState } from './update-notice.ts'
|
|
34
35
|
import { maybeShowWhatsNewV2 } from './whats-new'
|
|
35
36
|
|
|
@@ -686,10 +687,12 @@ export type ContextBlockRows = {
|
|
|
686
687
|
* `$<spent> spent`. The percentage row carries the only semantic tone, the
|
|
687
688
|
* gauge bar (12 cells) and is omitted entirely when the percentage is
|
|
688
689
|
* unavailable (never `undefined%`). A block with neither tokens nor cost
|
|
689
|
-
* yields null.
|
|
690
|
+
* yields null. `gaugeStyle` (the TUI tab's pref) picks the percent-row
|
|
691
|
+
* shape: `both` (default), `bar`, `percent`, or `off` (row omitted). Pure. */
|
|
690
692
|
export function contextBlockRows(
|
|
691
693
|
usage: ContextUsage | null,
|
|
692
694
|
cost: number | null | undefined,
|
|
695
|
+
gaugeStyle: 'both' | 'bar' | 'percent' | 'off' = 'both',
|
|
693
696
|
): ContextBlockRows | null {
|
|
694
697
|
const spentValue = formatSpent(cost)
|
|
695
698
|
const spent: ContextRow | null =
|
|
@@ -707,16 +710,30 @@ export function contextBlockRows(
|
|
|
707
710
|
const percentValue = numberOrNull(usage.percent)
|
|
708
711
|
const window = formatContextWindow(usage.limit)
|
|
709
712
|
const bar = contextBar(percentValue)
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
713
|
+
let percent: ContextRow | null = null
|
|
714
|
+
if (gaugeStyle !== 'off' && bar !== null && percentValue !== null) {
|
|
715
|
+
const suffix = window === null ? null : ` of ${window}`
|
|
716
|
+
const tone = contextUsageTone(percentValue)
|
|
717
|
+
if (gaugeStyle === 'bar') {
|
|
718
|
+
percent = { lead: bar.filled, value: '', tail: bar.empty, suffix, tone }
|
|
719
|
+
} else if (gaugeStyle === 'percent') {
|
|
720
|
+
percent = {
|
|
721
|
+
lead: null,
|
|
722
|
+
value: ` ${Math.round(percentValue)}%`,
|
|
723
|
+
tail: null,
|
|
724
|
+
suffix: null,
|
|
725
|
+
tone,
|
|
726
|
+
}
|
|
727
|
+
} else {
|
|
728
|
+
percent = {
|
|
729
|
+
lead: bar.filled,
|
|
730
|
+
value: ` ${Math.round(percentValue)}%`,
|
|
731
|
+
tail: bar.empty,
|
|
732
|
+
suffix,
|
|
733
|
+
tone,
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
720
737
|
|
|
721
738
|
if (tokens === null && percent === null && spent === null) return null
|
|
722
739
|
return { tokens, percent, spent }
|
|
@@ -3792,16 +3809,23 @@ export function createSidebarModel(
|
|
|
3792
3809
|
|
|
3793
3810
|
// Which blocks render, and where a blank line goes. The conditions mirror the
|
|
3794
3811
|
// ones in the view's own `<Show>`s — both read these same memos, so a spacer
|
|
3795
|
-
// can never outlive the block it separates.
|
|
3812
|
+
// can never outlive the block it separates. The TUI tab's prefs gate first
|
|
3813
|
+
// (a disabled block never renders, and the spacer math already tolerates
|
|
3814
|
+
// absence), then the content conditions.
|
|
3796
3815
|
const blocks = createMemo(() => {
|
|
3816
|
+
const prefs = tuiPrefs()
|
|
3797
3817
|
const present: SidebarBlockKey[] = []
|
|
3798
3818
|
// Context also owns the spend line, so the stats totals alone keep it up.
|
|
3799
|
-
if (
|
|
3819
|
+
if (
|
|
3820
|
+
prefs.sidebar.blocks.context &&
|
|
3821
|
+
(contextBlockRows(contextUsage(), cost(), prefs.sidebar.context.gauge) !== null ||
|
|
3822
|
+
(prefs.sidebar.context.localSpend && contextSpendLine(spend()) !== null))
|
|
3823
|
+
) {
|
|
3800
3824
|
present.push('context')
|
|
3801
3825
|
}
|
|
3802
|
-
if (branch() !== null || gitLine() !== null) present.push('git')
|
|
3803
|
-
if (todo().visible.length > 0) present.push('todo')
|
|
3804
|
-
if (dispatch() !== null) present.push('dispatch')
|
|
3826
|
+
if (prefs.sidebar.blocks.git && (branch() !== null || gitLine() !== null)) present.push('git')
|
|
3827
|
+
if (prefs.sidebar.blocks.todo && todo().visible.length > 0) present.push('todo')
|
|
3828
|
+
if (prefs.sidebar.blocks.dispatch && dispatch() !== null) present.push('dispatch')
|
|
3805
3829
|
return withBlockSpacers(present)
|
|
3806
3830
|
})
|
|
3807
3831
|
|
|
@@ -3994,12 +4018,27 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
3994
4018
|
/* Read the flag live (not through a captured entry) so a block that becomes
|
|
3995
4019
|
* the first one loses its spacer instead of keeping a stale blank line. */
|
|
3996
4020
|
const spacer = (key: SidebarBlockKey) => block(key)?.spacer === true
|
|
3997
|
-
const usageRows = () => modelUsageRows(model.modelUsage().visible)
|
|
3998
4021
|
const usageHidden = () =>
|
|
3999
4022
|
hiddenModelUsageText(model.modelUsage().hidden, model.modelUsage().hiddenCost)
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4023
|
+
// The TUI tab's prefs gate the context rows: gauge style shapes the percent
|
|
4024
|
+
// row; the token/spent lines drop entirely (the prefs live in the reactive
|
|
4025
|
+
// host store, so a flip in /pantheon-settings re-renders here instantly).
|
|
4026
|
+
const contextRows = () => {
|
|
4027
|
+
const prefs = tuiPrefs()
|
|
4028
|
+
const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge)
|
|
4029
|
+
if (rows === null) return null
|
|
4030
|
+
return {
|
|
4031
|
+
tokens: prefs.sidebar.context.tokens ? rows.tokens : null,
|
|
4032
|
+
percent: rows.percent,
|
|
4033
|
+
spent: prefs.sidebar.context.spent ? rows.spent : null,
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
const spendLine = () =>
|
|
4037
|
+
tuiPrefs().sidebar.context.localSpend ? contextSpendLine(model.spend()) : null
|
|
4038
|
+
const performanceLine = () =>
|
|
4039
|
+
tuiPrefs().sidebar.context.performance ? contextPerformanceLine(model.performance()) : null
|
|
4040
|
+
const usageRows = () =>
|
|
4041
|
+
tuiPrefs().sidebar.context.modelUsage ? modelUsageRows(model.modelUsage().visible) : []
|
|
4003
4042
|
/* Filled cells and the percent value resolve through the same stage, so the
|
|
4004
4043
|
* bar and its number can never disagree. */
|
|
4005
4044
|
const gaugeFg = (row: ContextRow) => contextProgressColor(row.tone ?? 'warning', context.theme)
|
|
@@ -4010,16 +4049,27 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
4010
4049
|
}
|
|
4011
4050
|
const failedSuffix = () => failedSuffixText(dispatchView()?.failures)
|
|
4012
4051
|
|
|
4052
|
+
// The fixed header lines are prefs-gated too (TUI tab): version, preset and
|
|
4053
|
+
// session each drop independently; nothing reflows — the column just shortens.
|
|
4054
|
+
const header = () => tuiPrefs().sidebar.header
|
|
4013
4055
|
return (
|
|
4014
4056
|
<box flexDirection="column" width="100%" padding={1}>
|
|
4015
|
-
<
|
|
4057
|
+
<Show when={header().version}>
|
|
4058
|
+
<text fg={text()} attributes={1}>{`Pantheon v${__PANTHEON_VERSION__}`}</text>
|
|
4059
|
+
</Show>
|
|
4016
4060
|
{/* Preset plus the provider of the model in use — both derived from host
|
|
4017
4061
|
state. The provider is dropped when nothing resolves, so the row is
|
|
4018
4062
|
never a placeholder. */}
|
|
4019
|
-
<
|
|
4063
|
+
<Show when={header().preset}>
|
|
4064
|
+
<text fg={muted()}>{presetHeaderLine(model.preset().name ?? '', model.provider())}</text>
|
|
4065
|
+
</Show>
|
|
4020
4066
|
<Show
|
|
4021
|
-
when={model.activeSessionID() !== '' && model.session()}
|
|
4022
|
-
fallback={
|
|
4067
|
+
when={header().session && model.activeSessionID() !== '' && model.session()}
|
|
4068
|
+
fallback={
|
|
4069
|
+
<Show when={header().session} fallback={<box height={0} />}>
|
|
4070
|
+
<text fg={muted()}>{sidebarPlaceholder(props.sessionID)}</text>
|
|
4071
|
+
</Show>
|
|
4072
|
+
}
|
|
4023
4073
|
>
|
|
4024
4074
|
{(current: any) => (
|
|
4025
4075
|
<text fg={text()}>{`Sessão: ${truncateLabel(current().title || current().id)}`}</text>
|
|
@@ -4060,7 +4110,7 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
4060
4110
|
numbers right-aligned; the gauge above remains the block's
|
|
4061
4111
|
single accent. When no message carries cost this loop is empty
|
|
4062
4112
|
and the block keeps its original token/spend rows. */}
|
|
4063
|
-
<Show when={usageRows().length > 0}>
|
|
4113
|
+
<Show when={tuiPrefs().sidebar.context.modelUsage && usageRows().length > 0}>
|
|
4064
4114
|
<text fg={muted()}>Sessão · custo reportado</text>
|
|
4065
4115
|
<text fg={muted()}>
|
|
4066
4116
|
{'Modelo'.padEnd(MODEL_USAGE_MODEL_WIDTH) +
|
|
@@ -4432,9 +4482,11 @@ function HomeStatus(props: { context: any }) {
|
|
|
4432
4482
|
const preset = useActivePreset(props.context).preset
|
|
4433
4483
|
const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base
|
|
4434
4484
|
return (
|
|
4435
|
-
<
|
|
4436
|
-
|
|
4437
|
-
|
|
4485
|
+
<Show when={tuiPrefs().footer.home}>
|
|
4486
|
+
<text
|
|
4487
|
+
fg={muted()}
|
|
4488
|
+
>{`Pantheon v${__PANTHEON_VERSION__}${preset().name ? ` ${PRESET_MARKER} ${preset().name}` : ''}`}</text>
|
|
4489
|
+
</Show>
|
|
4438
4490
|
)
|
|
4439
4491
|
}
|
|
4440
4492
|
|
|
@@ -4495,7 +4547,7 @@ function PromptFooter(props: { context: any; sessionID?: string | undefined }) {
|
|
|
4495
4547
|
const model = createFooterModel(props.context, () => props.sessionID)
|
|
4496
4548
|
const muted = () => props.context.theme?.text?.muted ?? props.context.theme?.text?.base
|
|
4497
4549
|
return (
|
|
4498
|
-
<Show when={model.running() > 0}>
|
|
4550
|
+
<Show when={tuiPrefs().footer.prompt && model.running() > 0}>
|
|
4499
4551
|
<text fg={muted()}>
|
|
4500
4552
|
{`${PRESET_MARKER}${model.preset().name ?? 'default'} · ✦${model.running()} ativos`}
|
|
4501
4553
|
</text>
|
|
@@ -4512,6 +4564,11 @@ const plugin = Plugin.define({
|
|
|
4512
4564
|
if (globalState[SINGLETON]) return
|
|
4513
4565
|
globalState[SINGLETON] = true
|
|
4514
4566
|
|
|
4567
|
+
// The durable TUI prefs store — created before any consumer (sidebar,
|
|
4568
|
+
// footers, dispatch panel, settings) reads it, so their first reactive
|
|
4569
|
+
// read hits the live store instead of the defaults.
|
|
4570
|
+
initTuiPrefs(context)
|
|
4571
|
+
|
|
4515
4572
|
const location = resolveLocation(context)
|
|
4516
4573
|
// Eager load/sync at setup so the cache is warm before the slot's first
|
|
4517
4574
|
// render (Known Issue: empty sidebar before the first prompt).
|