pantheon-opencode 2.0.0-beta.5 → 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 +22 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/install/opencode.mjs +13 -1
- package/scripts/skill-search.mjs +39 -4
- 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.js +495 -83
- 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/pantheon-settings.tsx +278 -24
- package/src/skills/prompt-refinery/SKILL.md +34 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "2.0.0-beta.
|
|
9
|
+
"version": "2.0.0-beta.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@opencode/plugin": "2.0.26",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.6",
|
|
5
5
|
"description": "Pantheon TUI plugin \u2014 V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
@@ -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
|
}
|