pantheon-opencode 2.0.0-beta.5 → 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.
- package/AGENTS.global.md +6 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +67 -0
- package/README.md +169 -510
- package/README.pt-BR.md +177 -149
- package/bin/pantheon-init.mjs +1 -1
- package/commands/pantheon-deepwork.md +6 -1
- package/commands/pantheon.md +10 -5
- package/package.json +1 -1
- package/plugin.json +2 -2
- package/prompts/orchestrate-with-zeus.prompt.md +82 -290
- package/prompts/subtask.prompt.md +1 -1
- package/pyproject.toml +1 -1
- package/scripts/doctor.mjs +27 -11
- package/scripts/hooks/format-multi-language.sh +30 -48
- package/scripts/install/opencode.mjs +13 -1
- package/scripts/jev-live-probe.mjs +1 -1
- package/scripts/release-gates.mjs +19 -5
- package/scripts/skill-search.mjs +66 -7
- package/scripts/test-opencode-sandbox.sh +44 -15
- package/scripts/update.mjs +9 -2
- package/skills-lock.json +5 -3
- package/src/agents/aphrodite.md +2 -0
- package/src/agents/apollo.md +8 -206
- package/src/agents/athena.md +25 -29
- package/src/agents/hermes.md +3 -1
- package/src/agents/mnemosyne.md +1 -1
- package/src/agents/nyx.md +1 -1
- package/src/agents/prometheus.md +0 -203
- package/src/agents/talos.md +2 -0
- package/src/agents/themis.md +8 -3
- package/src/agents/zeus.md +18 -12
- package/src/instructions/memory-protocol.instructions.md +4 -0
- package/src/instructions/test-economy.instructions.md +1 -0
- package/src/instructions/zeus-council-synthesis.instructions.md +13 -1
- package/src/pantheon/goal-loop-config.ts +55 -0
- package/src/pantheon/native-vision.ts +9 -5
- package/src/pantheon/pantheon-decision-catalog.ts +8 -0
- package/src/pantheon/skill-search-tool.ts +193 -0
- package/src/pantheon/tools.ts +2 -0
- package/src/pantheon/vision.ts +14 -1
- package/src/plugin.ts +39 -7
- package/src/plugins/tui/dist/tui.d.ts +12 -2
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +1399 -365
- 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/context-gauge.ts +64 -5
- package/src/plugins/tui/src/decision-router-state.ts +175 -6
- package/src/plugins/tui/src/index.tsx +25 -3
- package/src/plugins/tui/src/pantheon-settings-state.ts +99 -0
- package/src/plugins/tui/src/pantheon-settings.tsx +647 -103
- package/src/plugins/tui/src/tui-prefs.ts +161 -9
- package/src/plugins/tui/src/update-status.ts +27 -8
- package/src/routing.yml +9 -0
- package/src/skills/README.md +35 -25
- package/src/skills/fast-path-execution/SKILL.md +54 -0
- package/src/skills/prompt-refinery/SKILL.md +53 -37
- package/src/skills/tdd-with-agents/SKILL.md +22 -10
- package/src/skills/test-slicing/SKILL.md +56 -0
- package/src/skills/verification-planning/SKILL.md +4 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pantheon-tui",
|
|
9
|
-
"version": "2.0.0-
|
|
9
|
+
"version": "2.0.0-rc.1",
|
|
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-
|
|
4
|
+
"version": "2.0.0-rc.1",
|
|
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 { 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
|
+
}
|
|
@@ -6,6 +6,29 @@ export const CONTEXT_BAR_CELLS = 12
|
|
|
6
6
|
export const CONTEXT_BAR_FILLED_CELL = '\u25B0'
|
|
7
7
|
export const CONTEXT_BAR_EMPTY_CELL = '\u25B1'
|
|
8
8
|
|
|
9
|
+
export type BarShape = 'block' | 'line' | 'smooth' | 'ascii' | 'dots' | 'braille'
|
|
10
|
+
|
|
11
|
+
export interface BarShapeGlyphs {
|
|
12
|
+
filled: string
|
|
13
|
+
empty: string
|
|
14
|
+
mark?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const BAR_SHAPES: Record<BarShape, BarShapeGlyphs> = {
|
|
18
|
+
block: { filled: '\u25B0', empty: '\u25B1', mark: '│' },
|
|
19
|
+
line: { filled: '━', empty: '─', mark: '┼' },
|
|
20
|
+
smooth: { filled: '█', empty: '░', mark: '┆' },
|
|
21
|
+
ascii: { filled: '=', empty: '-', mark: '|' },
|
|
22
|
+
dots: { filled: '●', empty: '○', mark: '│' },
|
|
23
|
+
braille: { filled: '⣿', empty: '⣀', mark: '⡇' },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ContextBarOptions {
|
|
27
|
+
cells?: number
|
|
28
|
+
shape?: BarShape
|
|
29
|
+
evenMark?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
function numberOrNull(value: unknown): number | null {
|
|
10
33
|
return typeof value === 'number' && Number.isFinite(value) ? value : null
|
|
11
34
|
}
|
|
@@ -40,15 +63,51 @@ export function contextBarFilled(percent: number, cells = CONTEXT_BAR_CELLS): nu
|
|
|
40
63
|
|
|
41
64
|
export function contextBar(
|
|
42
65
|
percent: number | null | undefined,
|
|
43
|
-
|
|
66
|
+
options: number | ContextBarOptions = CONTEXT_BAR_CELLS,
|
|
44
67
|
): { filled: string; empty: string } | null {
|
|
45
68
|
const value = numberOrNull(percent)
|
|
46
69
|
if (value === null) return null
|
|
47
|
-
const total = Math.max(
|
|
48
|
-
|
|
70
|
+
const total = Math.max(
|
|
71
|
+
1,
|
|
72
|
+
Math.floor(typeof options === 'number' ? options : (options?.cells ?? CONTEXT_BAR_CELLS)),
|
|
73
|
+
)
|
|
74
|
+
const shapeKey =
|
|
75
|
+
typeof options === 'object' && options?.shape && options.shape in BAR_SHAPES
|
|
76
|
+
? options.shape
|
|
77
|
+
: 'block'
|
|
78
|
+
const glyphs = BAR_SHAPES[shapeKey] ?? BAR_SHAPES.block
|
|
79
|
+
const evenMark = typeof options === 'object' ? Boolean(options?.evenMark) : false
|
|
80
|
+
|
|
81
|
+
const filledCount = contextBarFilled(value, total)
|
|
82
|
+
const emptyCount = total - filledCount
|
|
83
|
+
|
|
84
|
+
if (!evenMark || total < 4) {
|
|
85
|
+
return {
|
|
86
|
+
filled: glyphs.filled.repeat(filledCount),
|
|
87
|
+
empty: glyphs.empty.repeat(emptyCount),
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Insert even-use mark at the midpoint (50%)
|
|
92
|
+
const mid = Math.floor(total / 2)
|
|
93
|
+
const mark = glyphs.mark ?? '|'
|
|
94
|
+
|
|
95
|
+
if (filledCount <= mid) {
|
|
96
|
+
// Mark is in the empty portion
|
|
97
|
+
const emptyBefore = mid - filledCount
|
|
98
|
+
const emptyAfter = Math.max(0, emptyCount - emptyBefore - 1)
|
|
99
|
+
return {
|
|
100
|
+
filled: glyphs.filled.repeat(filledCount),
|
|
101
|
+
empty: `${glyphs.empty.repeat(emptyBefore)}${mark}${glyphs.empty.repeat(emptyAfter)}`,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Mark is in the filled portion
|
|
106
|
+
const filledBefore = mid
|
|
107
|
+
const filledAfter = Math.max(0, filledCount - filledBefore - 1)
|
|
49
108
|
return {
|
|
50
|
-
filled:
|
|
51
|
-
empty:
|
|
109
|
+
filled: `${glyphs.filled.repeat(filledBefore)}${mark}${glyphs.filled.repeat(filledAfter)}`,
|
|
110
|
+
empty: glyphs.empty.repeat(emptyCount),
|
|
52
111
|
}
|
|
53
112
|
}
|
|
54
113
|
|
|
@@ -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,102 @@ 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
|
+
/** The host's provider auth store (`opencode auth login` writes here). */
|
|
294
|
+
export function decisionAuthStorePath(env: Record<string, string | undefined> = process.env) {
|
|
295
|
+
const xdgData = env.XDG_DATA_HOME
|
|
296
|
+
const home = env.HOME ?? ''
|
|
297
|
+
const root = xdgData ?? join(home, '.local', 'share')
|
|
298
|
+
return join(root, 'opencode', 'auth.json')
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Provider ids as they appear in the host auth store / config providers. */
|
|
302
|
+
const PROVIDER_AUTH_NAMES: Readonly<Record<string, readonly string[]>> = Object.freeze({
|
|
303
|
+
'openai-decisions': Object.freeze(['openai']),
|
|
304
|
+
'typesafe-jev': Object.freeze(['typesafe-ai']),
|
|
305
|
+
'opencode-console-jev': Object.freeze([]),
|
|
306
|
+
'openrouter-jev': Object.freeze(['openrouter']),
|
|
307
|
+
'vercel-gateway-jev': Object.freeze(['vercel-ai-gateway', 'vercel']),
|
|
308
|
+
'cloudflare-workers-jev': Object.freeze(['cloudflare-workers-ai']),
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
export type CredentialForm = 'env' | 'auth store' | 'config' | 'missing'
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* TWO recognition forms (field feedback beta.6: keys registered via
|
|
315
|
+
* `opencode auth login` showed MISSING because only env vars were checked):
|
|
316
|
+
* env var set → 'env'; provider present in the host auth store → 'auth
|
|
317
|
+
* store'; provider entry in opencode.json providers → 'config'. Values are
|
|
318
|
+
* NEVER read — existence only.
|
|
319
|
+
*/
|
|
320
|
+
export function credentialStatus(
|
|
321
|
+
provider: string,
|
|
322
|
+
env: Record<string, string | undefined>,
|
|
323
|
+
authProviders: ReadonlySet<string>,
|
|
324
|
+
configProviders: ReadonlySet<string>,
|
|
325
|
+
): CredentialForm {
|
|
326
|
+
const credential = DECISION_PROVIDER_CREDENTIALS[provider]
|
|
327
|
+
if (credential?.env !== undefined && env[credential.env]) return 'env'
|
|
328
|
+
for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) {
|
|
329
|
+
if (authProviders.has(name)) return 'auth store'
|
|
330
|
+
}
|
|
331
|
+
for (const name of PROVIDER_AUTH_NAMES[provider] ?? []) {
|
|
332
|
+
if (configProviders.has(name)) return 'config'
|
|
333
|
+
}
|
|
334
|
+
if (provider === 'opencode-console-jev') return 'auth store'
|
|
335
|
+
return 'missing'
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function buildDecisionTab(
|
|
339
|
+
read: DecisionConfigRead,
|
|
340
|
+
env: Record<string, string | undefined> = process.env,
|
|
341
|
+
authProviders: ReadonlySet<string> = new Set(),
|
|
342
|
+
configProviders: ReadonlySet<string> = new Set(),
|
|
343
|
+
): SettingsTab {
|
|
209
344
|
const { config, corrupt } = read
|
|
210
345
|
const rows: SettingsRow[] = [
|
|
211
346
|
{
|
|
@@ -219,12 +354,24 @@ export function buildDecisionTab(read: DecisionConfigRead): SettingsTab {
|
|
|
219
354
|
: 'applies live — the runtime re-reads this on every gated call',
|
|
220
355
|
},
|
|
221
356
|
{
|
|
222
|
-
id: 'decision.selection',
|
|
223
|
-
name: 'Selection',
|
|
224
|
-
value:
|
|
357
|
+
id: 'decision.selection.mode',
|
|
358
|
+
name: 'Selection mode',
|
|
359
|
+
value: config.selection.mode,
|
|
360
|
+
...(corrupt ? {} : { cycle: DECISION_SELECTION_CYCLE }),
|
|
225
361
|
note: 'local routes on-device; auto/explicit pick a remote decision model',
|
|
226
362
|
},
|
|
227
363
|
]
|
|
364
|
+
if (config.selection.mode === 'explicit' || config.selection.provider !== undefined) {
|
|
365
|
+
rows.push({
|
|
366
|
+
id: 'decision.selection.target',
|
|
367
|
+
name: 'Explicit target',
|
|
368
|
+
value: config.selection.provider
|
|
369
|
+
? `${config.selection.provider}/${config.selection.model ?? ''}`
|
|
370
|
+
: 'none',
|
|
371
|
+
...(corrupt || config.selection.mode !== 'explicit' ? {} : { cycle: DECISION_TARGET_CYCLE }),
|
|
372
|
+
note: 'provider/model — sets the candidate list',
|
|
373
|
+
})
|
|
374
|
+
}
|
|
228
375
|
if (config.enabled_candidates.length > 0) {
|
|
229
376
|
rows.push({
|
|
230
377
|
id: 'decision.candidates',
|
|
@@ -237,9 +384,31 @@ export function buildDecisionTab(read: DecisionConfigRead): SettingsTab {
|
|
|
237
384
|
: 'egress consent NOT granted — remote routes fail closed',
|
|
238
385
|
})
|
|
239
386
|
}
|
|
387
|
+
rows.push({
|
|
388
|
+
id: 'decision.consent',
|
|
389
|
+
name: 'Egress consent',
|
|
390
|
+
value: config.egress_consent ? 'granted' : 'not granted',
|
|
391
|
+
...(corrupt ? {} : { cycle: DECISION_CONSENT_CYCLE }),
|
|
392
|
+
note: 'granted = remote decision routes may call their gateway (budget-capped)',
|
|
393
|
+
})
|
|
240
394
|
return {
|
|
241
395
|
id: 'decision',
|
|
242
396
|
title: 'Decision',
|
|
243
|
-
groups: [
|
|
397
|
+
groups: [
|
|
398
|
+
{ title: 'Decision router', rows },
|
|
399
|
+
{
|
|
400
|
+
title: 'Credentials (status only — values never enter the window)',
|
|
401
|
+
rows: DECISION_KNOWN_PROVIDERS.map((provider) => {
|
|
402
|
+
const status = credentialStatus(provider, env, authProviders, configProviders)
|
|
403
|
+
const credential = DECISION_PROVIDER_CREDENTIALS[provider] ?? { note: '' }
|
|
404
|
+
return {
|
|
405
|
+
id: `decision.key.${provider}`,
|
|
406
|
+
name: provider,
|
|
407
|
+
value: status === 'missing' ? 'MISSING' : status,
|
|
408
|
+
note: credential.note,
|
|
409
|
+
}
|
|
410
|
+
}),
|
|
411
|
+
},
|
|
412
|
+
],
|
|
244
413
|
}
|
|
245
414
|
}
|
|
@@ -12,6 +12,7 @@ import type { Context, KeymapLayer, PanelInput } from '@opencode/plugin/tui/cont
|
|
|
12
12
|
import type { Accessor, JSX } from 'solid-js'
|
|
13
13
|
import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js'
|
|
14
14
|
import {
|
|
15
|
+
CONTEXT_BAR_CELLS,
|
|
15
16
|
type ContextProgressTone,
|
|
16
17
|
contextBar,
|
|
17
18
|
contextUsageTone,
|
|
@@ -693,6 +694,7 @@ export function contextBlockRows(
|
|
|
693
694
|
usage: ContextUsage | null,
|
|
694
695
|
cost: number | null | undefined,
|
|
695
696
|
gaugeStyle: 'both' | 'bar' | 'percent' | 'off' = 'both',
|
|
697
|
+
barOptions?: number | { shape?: any; cells?: number; evenMark?: boolean },
|
|
696
698
|
): ContextBlockRows | null {
|
|
697
699
|
const spentValue = formatSpent(cost)
|
|
698
700
|
const spent: ContextRow | null =
|
|
@@ -709,7 +711,7 @@ export function contextBlockRows(
|
|
|
709
711
|
|
|
710
712
|
const percentValue = numberOrNull(usage.percent)
|
|
711
713
|
const window = formatContextWindow(usage.limit)
|
|
712
|
-
const bar = contextBar(percentValue)
|
|
714
|
+
const bar = contextBar(percentValue, barOptions ?? CONTEXT_BAR_CELLS)
|
|
713
715
|
let percent: ContextRow | null = null
|
|
714
716
|
if (gaugeStyle !== 'off' && bar !== null && percentValue !== null) {
|
|
715
717
|
const suffix = window === null ? null : ` of ${window}`
|
|
@@ -4025,7 +4027,19 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
4025
4027
|
// host store, so a flip in /pantheon-settings re-renders here instantly).
|
|
4026
4028
|
const contextRows = () => {
|
|
4027
4029
|
const prefs = tuiPrefs()
|
|
4028
|
-
const
|
|
4030
|
+
const barCells =
|
|
4031
|
+
prefs.sidebar.context.barWidth === 'compact'
|
|
4032
|
+
? 8
|
|
4033
|
+
: prefs.sidebar.context.barWidth === 'wide'
|
|
4034
|
+
? 16
|
|
4035
|
+
: prefs.sidebar.context.barWidth === 'full'
|
|
4036
|
+
? 20
|
|
4037
|
+
: 12
|
|
4038
|
+
const rows = contextBlockRows(model.contextUsage(), model.cost(), prefs.sidebar.context.gauge, {
|
|
4039
|
+
shape: prefs.sidebar.context.barShape,
|
|
4040
|
+
cells: barCells,
|
|
4041
|
+
evenMark: prefs.sidebar.context.evenMark,
|
|
4042
|
+
})
|
|
4029
4043
|
if (rows === null) return null
|
|
4030
4044
|
return {
|
|
4031
4045
|
tokens: prefs.sidebar.context.tokens ? rows.tokens : null,
|
|
@@ -4053,10 +4067,18 @@ function Sidebar(props: SidebarProps): JSX.Element {
|
|
|
4053
4067
|
// session each drop independently; nothing reflows — the column just shortens.
|
|
4054
4068
|
const header = () => tuiPrefs().sidebar.header
|
|
4055
4069
|
return (
|
|
4056
|
-
<box
|
|
4070
|
+
<box
|
|
4071
|
+
flexDirection="column"
|
|
4072
|
+
width="100%"
|
|
4073
|
+
paddingLeft={1}
|
|
4074
|
+
paddingRight={1}
|
|
4075
|
+
paddingTop={tuiPrefs().layout.preset === 'compact' ? 0 : 1}
|
|
4076
|
+
paddingBottom={tuiPrefs().layout.preset === 'compact' ? 0 : 1}
|
|
4077
|
+
>
|
|
4057
4078
|
<Show when={header().version}>
|
|
4058
4079
|
<text fg={text()} attributes={1}>{`Pantheon v${__PANTHEON_VERSION__}`}</text>
|
|
4059
4080
|
</Show>
|
|
4081
|
+
|
|
4060
4082
|
{/* Preset plus the provider of the model in use — both derived from host
|
|
4061
4083
|
state. The provider is dropped when nothing resolves, so the row is
|
|
4062
4084
|
never a placeholder. */}
|
|
@@ -162,6 +162,8 @@ export interface SettingsRow {
|
|
|
162
162
|
value: string
|
|
163
163
|
/** Allowed values for ←/→; presence marks the row as editable. */
|
|
164
164
|
cycle?: readonly string[]
|
|
165
|
+
/** The row's DEFAULT value — what the Defaults action stages. */
|
|
166
|
+
def?: string
|
|
165
167
|
/** Right-column note (writes-where, applies-live, from-where). */
|
|
166
168
|
note?: string
|
|
167
169
|
/** Enter triggers this action instead of cycling (e.g. `update-check`). */
|
|
@@ -225,6 +227,45 @@ export function stageValue(
|
|
|
225
227
|
return { ...draft, [row.id]: staged }
|
|
226
228
|
}
|
|
227
229
|
|
|
230
|
+
/** Stage an explicit target value for one row (the Defaults action path). */
|
|
231
|
+
export function stageRowToValue(
|
|
232
|
+
draft: SettingsDraft,
|
|
233
|
+
row: SettingsRow,
|
|
234
|
+
target: string,
|
|
235
|
+
): SettingsDraft {
|
|
236
|
+
if (!row.cycle?.includes(target)) return draft
|
|
237
|
+
if (target === row.value) {
|
|
238
|
+
if (draft[row.id] === undefined) return draft
|
|
239
|
+
const next = { ...draft }
|
|
240
|
+
delete next[row.id]
|
|
241
|
+
return next
|
|
242
|
+
}
|
|
243
|
+
return { ...draft, [row.id]: target }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Stage every cyclable row's DEFAULT value of a tab. Rows already at their
|
|
248
|
+
* default have their staged entry dropped; rows staged elsewhere keep it
|
|
249
|
+
* until the Defaults action targets them.
|
|
250
|
+
*/
|
|
251
|
+
export function stageDefaults(draft: SettingsDraft, tab: SettingsTab): SettingsDraft {
|
|
252
|
+
let next = draft
|
|
253
|
+
for (const row of tabRows(tab)) {
|
|
254
|
+
if (row.cycle === undefined || row.def === undefined) continue
|
|
255
|
+
const candidate = next[row.id] ?? row.value
|
|
256
|
+
if (candidate === row.def) {
|
|
257
|
+
if (next[row.id] !== undefined) {
|
|
258
|
+
const copy = { ...next }
|
|
259
|
+
delete copy[row.id]
|
|
260
|
+
next = copy
|
|
261
|
+
}
|
|
262
|
+
continue
|
|
263
|
+
}
|
|
264
|
+
next = stageRowToValue(next, { ...row, value: candidate }, row.def)
|
|
265
|
+
}
|
|
266
|
+
return next
|
|
267
|
+
}
|
|
268
|
+
|
|
228
269
|
/** Drop every staged entry of one tab (ctrl+r). */
|
|
229
270
|
export function resetTab(draft: SettingsDraft, tab: SettingsTab): SettingsDraft {
|
|
230
271
|
const ids = new Set(tabRows(tab).map((row) => row.id))
|
|
@@ -342,3 +383,61 @@ export function buildAboutTab(version: string): SettingsTab {
|
|
|
342
383
|
],
|
|
343
384
|
}
|
|
344
385
|
}
|
|
386
|
+
|
|
387
|
+
export interface ChangelogHighlightItem {
|
|
388
|
+
title: string
|
|
389
|
+
detail: string
|
|
390
|
+
group?: string | undefined
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export function buildChangelogTab(
|
|
394
|
+
version: string,
|
|
395
|
+
items: ChangelogHighlightItem[] = [],
|
|
396
|
+
): SettingsTab {
|
|
397
|
+
const rows: SettingsRow[] = []
|
|
398
|
+
if (items.length > 0) {
|
|
399
|
+
items.forEach((item, index) => {
|
|
400
|
+
rows.push({
|
|
401
|
+
id: `changelog.item.${index + 1}`,
|
|
402
|
+
name: item.title.slice(0, 26),
|
|
403
|
+
value: item.detail.length > 20 ? `${item.detail.slice(0, 19)}…` : item.detail,
|
|
404
|
+
note: item.detail,
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
} else {
|
|
408
|
+
rows.push({
|
|
409
|
+
id: 'changelog.info',
|
|
410
|
+
name: 'Release',
|
|
411
|
+
value: `v${version}`,
|
|
412
|
+
note: 'view full history in CHANGELOG.md or GitHub releases',
|
|
413
|
+
})
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
id: 'changelog',
|
|
418
|
+
title: 'Changelog',
|
|
419
|
+
groups: [
|
|
420
|
+
{
|
|
421
|
+
title: `What's New in v${version}`,
|
|
422
|
+
rows,
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
title: 'Release References',
|
|
426
|
+
rows: [
|
|
427
|
+
{
|
|
428
|
+
id: 'changelog.docs',
|
|
429
|
+
name: 'Documentation',
|
|
430
|
+
value: 'CHANGELOG.md',
|
|
431
|
+
note: 'shipped at plugin root and repository root',
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
id: 'changelog.repo',
|
|
435
|
+
name: 'GitHub Repository',
|
|
436
|
+
value: 'ils15/pantheon-opencode',
|
|
437
|
+
note: 'releases, pull requests and discussion',
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
}
|
|
443
|
+
}
|