pantheon-opencode 2.1.6 → 2.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/AGENTS.global.md +2 -2
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +64 -0
  4. package/README.md +13 -9
  5. package/README.pt-BR.md +13 -9
  6. package/bin/pantheon-init.mjs +1 -1
  7. package/commands/pantheon-audit.md +4 -5
  8. package/commands/pantheon-model.md +1 -2
  9. package/package.json +8 -2
  10. package/plugin.json +1 -1
  11. package/prompts/dynamic/agora-generated.txt +2 -2
  12. package/prompts/dynamic/orchestrate-generated.txt +4 -4
  13. package/prompts/sketch.prompt.md +1 -1
  14. package/pyproject.toml +1 -1
  15. package/scripts/build-agents-md.mjs +73 -12
  16. package/scripts/build-plugin.mjs +3 -1
  17. package/scripts/hooks/format-multi-language.sh +30 -29
  18. package/scripts/install-mcp.mjs +55 -27
  19. package/scripts/prune.mjs +124 -2
  20. package/scripts/setup.mjs +1 -1
  21. package/scripts/themis_heuristic_scan.py +3 -5
  22. package/skills-lock.json +1 -1
  23. package/src/agents/aphrodite.md +1 -1
  24. package/src/agents/athena.md +6 -14
  25. package/src/agents/demeter.md +1 -1
  26. package/src/agents/hermes.md +3 -2
  27. package/src/agents/iris.md +4 -6
  28. package/src/agents/prometheus.md +3 -7
  29. package/src/agents/roster.json +567 -0
  30. package/src/agents/zeus.md +3 -0
  31. package/src/instructions/agent-return-format.instructions.md +1 -1
  32. package/src/instructions/zeus-anti-stall.instructions.md +11 -35
  33. package/src/instructions/zeus-council-synthesis.instructions.md +17 -49
  34. package/src/instructions/zeus-timeout-retry.instructions.md +12 -80
  35. package/src/mcp/mcp_codemap_module.py +6 -5
  36. package/src/mcp/pantheon-mcp-server.mjs +875 -0
  37. package/src/pantheon/agent-forge-tool.ts +316 -0
  38. package/src/pantheon/auto-permissions.ts +31 -1
  39. package/src/pantheon/codemap-tools.ts +525 -0
  40. package/src/pantheon/deepwork/plan-tracker.ts +63 -2
  41. package/src/pantheon/execute-after.ts +21 -0
  42. package/src/pantheon/hook-engine.ts +2 -1
  43. package/src/pantheon/native-memory-tools.ts +686 -0
  44. package/src/pantheon/presets.mjs +15 -0
  45. package/src/pantheon/step-ledger.ts +259 -0
  46. package/src/pantheon/swe-eval-harness.ts +211 -0
  47. package/src/pantheon/tools.ts +62 -7
  48. package/src/plugin/index.js +2091 -136
  49. package/src/plugin/index.ts +1 -14
  50. package/src/plugin.ts +167 -10
  51. package/src/plugins/tui/dist/tui.d.ts +66 -0
  52. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  53. package/src/plugins/tui/dist/tui.js +1259 -367
  54. package/src/plugins/tui/dist/tui.js.map +1 -1
  55. package/src/plugins/tui/package-lock.json +2 -2
  56. package/src/plugins/tui/package.json +1 -1
  57. package/src/plugins/tui/src/index.tsx +632 -71
  58. package/src/plugins/tui/src/pantheon-settings.tsx +78 -14
  59. package/src/plugins/tui/src/quota-state.ts +190 -0
  60. package/src/plugins/tui/src/tui-prefs.ts +169 -12
  61. package/src/routing.yml +3 -0
  62. package/src/skills/auto-continue/references/auto-continue-details.md +2 -31
  63. /package/scripts/{setup-v2-config.mjs → setup-config.mjs} +0 -0
@@ -60,6 +60,8 @@ import {
60
60
  type EffectiveOverrides,
61
61
  EMPTY_TAB,
62
62
  findRow,
63
+ isBehaviorDisabled,
64
+ mergedOverrides,
63
65
  type OverridesLoad,
64
66
  resetTab,
65
67
  type SettingsDraft,
@@ -84,12 +86,14 @@ import {
84
86
  writeActivePreset,
85
87
  writeConfiguredVisionModel,
86
88
  } from './preset-state.ts'
89
+ import { applyQuotaRow, buildQuotaTab, readQuotaPrefs, writeQuotaPrefs } from './quota-state.ts'
87
90
  import { resolveLanguage } from './settings-i18n.ts'
88
91
  import {
89
92
  applyTuiRow,
90
93
  buildTuiTab,
91
94
  clearTuiDraftPreview,
92
95
  mutateTuiPrefs,
96
+ resolveAccentColor,
93
97
  setTuiDraftPreview,
94
98
  tuiPrefs,
95
99
  } from './tui-prefs.ts'
@@ -676,7 +680,11 @@ export function SettingsWindow(props: {
676
680
  flexShrink={0}
677
681
  rowGap={1}
678
682
  >
679
- <box backgroundColor="#fba970" flexShrink={0} onMouseDown={() => props.onSave?.()}>
683
+ <box
684
+ backgroundColor={props.warn ?? '#fba970'}
685
+ flexShrink={0}
686
+ onMouseDown={() => props.onSave?.()}
687
+ >
680
688
  <text fg="#000000">{isPt() ? ' Salvar ' : ' Save '}</text>
681
689
  </box>
682
690
  <text fg={props.muted} flexShrink={0}>
@@ -731,7 +739,7 @@ export function SettingsWindow(props: {
731
739
  <text fg={props.warn ?? '#f59e0b'} attributes={1}>
732
740
  {isPt() ? 'Deseja salvar as alterações? ' : 'Keep your changes? '}
733
741
  </text>
734
- <box backgroundColor="#fba970" onMouseDown={() => props.onSave?.()}>
742
+ <box backgroundColor={props.warn ?? '#fba970'} onMouseDown={() => props.onSave?.()}>
735
743
  <text fg="#000000">{isPt() ? ' Salvar ' : ' Save '}</text>
736
744
  </box>
737
745
  <text fg={props.muted}>{' '}</text>
@@ -864,6 +872,7 @@ function createWindowController(
864
872
  buildGatesTab(load(), lang),
865
873
  buildDecisionTab(decision(), process.env, readAuthProviders(), readConfigProviders(), lang),
866
874
  buildPresetTab(presetInput(), lang),
875
+ buildQuotaTab(undefined, lang, readQuotaPrefs()),
867
876
  buildTuiTab(tuiPrefs(), lang),
868
877
  buildAutonomyTab({
869
878
  goalLoop: goalLoop(),
@@ -871,7 +880,11 @@ function createWindowController(
871
880
  goalLoopRestartPending: autonomyRestartPending(),
872
881
  languagePref: lang,
873
882
  }),
874
- buildJ1Tab(process.env, false, lang),
883
+ buildJ1Tab(
884
+ process.env,
885
+ isBehaviorDisabled(mergedOverrides(load()), 'gate-j1-risk-gate'),
886
+ lang,
887
+ ),
875
888
  buildUpdatesTab({ ...updatesInput(), languagePref: lang }),
876
889
  buildChangelogTab(currentVersion, changelogItems(), lang),
877
890
  buildDoctorTab({
@@ -1100,6 +1113,16 @@ function createWindowController(
1100
1113
  return { ok: false, reason: 'tui prefs storage unavailable' }
1101
1114
  }
1102
1115
  }
1116
+ if (id.startsWith('quota.')) {
1117
+ try {
1118
+ const current = readQuotaPrefs()
1119
+ const updated = applyQuotaRow(current, id, value)
1120
+ writeQuotaPrefs(updated)
1121
+ return { ok: true }
1122
+ } catch {
1123
+ return { ok: false, reason: 'quota prefs disk write failed' }
1124
+ }
1125
+ }
1103
1126
  return { ok: false, reason: 'unknown staged row' }
1104
1127
  }
1105
1128
 
@@ -1282,14 +1305,19 @@ function createWindowController(
1282
1305
 
1283
1306
  // ── The router page (the primary surface) ──────────────────────────────
1284
1307
 
1285
- function SettingsPage(props: { context: Context; data: Record<string, any> | undefined }) {
1308
+ function SettingsPage(props: {
1309
+ context: Context
1310
+ data: Record<string, any> | undefined
1311
+ renderSidebar?: (context: Context) => any
1312
+ }) {
1286
1313
  const returnRoute = (props.data as { returnRoute?: WindowRoute } | undefined)?.returnRoute
1287
1314
  const context = props.context
1288
1315
  const controller = createWindowController(context, () =>
1289
1316
  navigateBack(context, returnRoute !== undefined ? { returnRoute } : {}),
1290
1317
  )
1291
1318
  const theme = context.theme?.text ?? {}
1292
- const warn = (theme?.feedback as any)?.warning?.base ?? theme.muted
1319
+ const accent = () => resolveAccentColor(tuiPrefs().theme?.accent, context.theme)
1320
+ const warn = () => accent()
1293
1321
  // The page owns the keyboard while mounted: push an input MODE so the
1294
1322
  // composer's base-mode layers sleep (they eat escape and plain letters —
1295
1323
  // the host's own menus push a mode for exactly this). The page layer is
@@ -1304,7 +1332,8 @@ function SettingsPage(props: { context: Context; data: Record<string, any> | und
1304
1332
  onCleanup(controller.cleanup)
1305
1333
  setBlocking(true)
1306
1334
  pageApi = controller.api
1307
- return (
1335
+
1336
+ const window = () => (
1308
1337
  <SettingsWindow
1309
1338
  version={resolveRunningVersion()}
1310
1339
  tabs={controller.tabs}
@@ -1315,7 +1344,7 @@ function SettingsPage(props: { context: Context; data: Record<string, any> | und
1315
1344
  confirmExit={controller.confirmExit}
1316
1345
  fg={theme.base}
1317
1346
  muted={theme.muted}
1318
- warn={warn}
1347
+ warn={warn()}
1319
1348
  onJumpTab={(idx) => controller.api.jumpTab(idx)}
1320
1349
  onSelectRow={(id) => controller.api.selectById?.(id)}
1321
1350
  onCycleValue={(id, dir) => controller.api.cycleRowById?.(id, dir)}
@@ -1327,6 +1356,27 @@ function SettingsPage(props: { context: Context; data: Record<string, any> | und
1327
1356
  onCancelExit={() => controller.api.cancelExit?.()}
1328
1357
  />
1329
1358
  )
1359
+
1360
+ const sidebar = () => (props.renderSidebar ? props.renderSidebar(context) : null)
1361
+
1362
+ return (
1363
+ <Show when={sidebar()} fallback={window()}>
1364
+ <box flexDirection="row" flexGrow={1} flexBasis={0} minHeight={0} width="100%">
1365
+ <box flexDirection="column" flexGrow={1} flexBasis={0} minHeight={0} minWidth={0}>
1366
+ {window()}
1367
+ </box>
1368
+ <box
1369
+ width={32}
1370
+ flexShrink={0}
1371
+ border
1372
+ borderStyle="single"
1373
+ borderColor={theme.muted ?? '#333333'}
1374
+ >
1375
+ {sidebar()}
1376
+ </box>
1377
+ </box>
1378
+ </Show>
1379
+ )
1330
1380
  }
1331
1381
 
1332
1382
  function navigateBack(context: Context, data?: { returnRoute?: WindowRoute }): void {
@@ -1346,7 +1396,8 @@ let dialogDismiss: () => void = () => {}
1346
1396
  function openSettingsDialog(context: Context): void {
1347
1397
  const controller = createWindowController(context, () => dialogDismiss())
1348
1398
  const theme = context.theme?.text ?? {}
1349
- const warn = (theme?.feedback as any)?.warning?.base ?? theme.muted
1399
+ const accent = () => resolveAccentColor(tuiPrefs().theme?.accent, context.theme)
1400
+ const warn = () => accent()
1350
1401
  controller.cleanup = () => {
1351
1402
  pageApi = undefined
1352
1403
  setBlocking(false)
@@ -1383,7 +1434,7 @@ function openSettingsDialog(context: Context): void {
1383
1434
  confirmExit={controller.confirmExit}
1384
1435
  fg={theme.base}
1385
1436
  muted={theme.muted}
1386
- warn={warn}
1437
+ warn={warn()}
1387
1438
  isDialog={true}
1388
1439
  maxHeight={maxHeight()}
1389
1440
  onJumpTab={(idx) => controller.api.jumpTab(idx)}
@@ -1399,7 +1450,7 @@ function openSettingsDialog(context: Context): void {
1399
1450
  ),
1400
1451
  close,
1401
1452
  )
1402
- context.ui.dialog.set({ size: 'large' })
1453
+ context.ui.dialog.set({ size: 'medium', centered: true })
1403
1454
  } catch {
1404
1455
  /* dialog stack unavailable — fail-open */
1405
1456
  }
@@ -1515,7 +1566,8 @@ function InSessionSettingsWindow(props: { context: Context; sessionID: string })
1515
1566
  pageApi = controller.api
1516
1567
 
1517
1568
  const theme = (context as any).theme?.text ?? {}
1518
- const warn = (theme?.feedback as any)?.warning?.base ?? '#fba970'
1569
+ const accent = () => resolveAccentColor(tuiPrefs().theme?.accent, context.theme)
1570
+ const warn = () => accent()
1519
1571
 
1520
1572
  return (
1521
1573
  <SettingsWindow
@@ -1536,7 +1588,7 @@ function InSessionSettingsWindow(props: { context: Context; sessionID: string })
1536
1588
  confirmExit={controller.confirmExit}
1537
1589
  fg={theme.base}
1538
1590
  muted={theme.muted}
1539
- warn={warn}
1591
+ warn={warn()}
1540
1592
  hasKeyboard={hasKeyboard}
1541
1593
  onJumpTab={(idx) => controller.api.jumpTab(idx)}
1542
1594
  onSelectRow={(id) => controller.api.selectById?.(id)}
@@ -1558,11 +1610,23 @@ function InSessionSettingsWindow(props: { context: Context; sessionID: string })
1558
1610
 
1559
1611
  // ── Setup: register once, gate once, priority 1 (anti-theft) ───────────
1560
1612
 
1561
- export function setupPantheonSettings(context: Context): void {
1613
+ let registeredSidebarRenderer: ((context: Context) => any) | undefined
1614
+
1615
+ export function setupPantheonSettings(
1616
+ context: Context,
1617
+ options?: { renderSidebar?: (context: Context) => any },
1618
+ ): void {
1619
+ registeredSidebarRenderer = options?.renderSidebar
1562
1620
  try {
1563
1621
  context.ui.router?.register?.({
1564
1622
  name: ROUTE_NAME,
1565
- render: ({ data }) => <SettingsPage context={context} data={data} />,
1623
+ render: ({ data }) => (
1624
+ <SettingsPage
1625
+ context={context}
1626
+ data={data}
1627
+ {...(registeredSidebarRenderer ? { renderSidebar: registeredSidebarRenderer } : {})}
1628
+ />
1629
+ ),
1566
1630
  })
1567
1631
  routerAvailable = true
1568
1632
  } catch {
@@ -0,0 +1,190 @@
1
+ /**
2
+ * quota-state.ts — the Quotas & Spend tab (inspired by opencode-quota).
3
+ *
4
+ * Exposes live model token spending, daily budgets, rate-limits per provider,
5
+ * and context token telemetry in a dedicated tab in the Pantheon Settings window.
6
+ */
7
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
8
+ import { homedir } from 'node:os'
9
+ import { dirname, join } from 'node:path'
10
+ import type { SettingsTab } from './pantheon-settings-state.ts'
11
+ import { resolveLanguage } from './settings-i18n.ts'
12
+
13
+ export interface QuotaSnapshot {
14
+ todaySpend?: string
15
+ monthSpend?: string
16
+ sessionSpend?: string
17
+ sessionTokens?: string
18
+ cacheHit?: string
19
+ speed?: string
20
+ }
21
+
22
+ export interface QuotaPrefs {
23
+ sessionCap: string
24
+ alertThreshold: 'enabled' | 'disabled'
25
+ autoCompact: 'enabled' | 'disabled'
26
+ }
27
+
28
+ export const DEFAULT_QUOTA_PREFS: QuotaPrefs = {
29
+ sessionCap: '$5.00',
30
+ alertThreshold: 'enabled',
31
+ autoCompact: 'enabled',
32
+ }
33
+
34
+ export function resolveQuotaPrefsPath(): string {
35
+ const xdg = process.env.XDG_CONFIG_HOME
36
+ const base = xdg?.startsWith('/') ? xdg : join(homedir(), '.config')
37
+ return join(base, 'opencode', 'pantheon-quota.json')
38
+ }
39
+
40
+ export function readQuotaPrefs(filePath = resolveQuotaPrefsPath()): QuotaPrefs {
41
+ try {
42
+ if (!existsSync(filePath)) return { ...DEFAULT_QUOTA_PREFS }
43
+ const raw = JSON.parse(readFileSync(filePath, 'utf8')) as Partial<QuotaPrefs>
44
+ return {
45
+ sessionCap:
46
+ typeof raw.sessionCap === 'string' &&
47
+ ['$1.00', '$2.00', '$5.00', '$10.00', 'unlimited'].includes(raw.sessionCap)
48
+ ? raw.sessionCap
49
+ : DEFAULT_QUOTA_PREFS.sessionCap,
50
+ alertThreshold: raw.alertThreshold === 'disabled' ? 'disabled' : 'enabled',
51
+ autoCompact: raw.autoCompact === 'disabled' ? 'disabled' : 'enabled',
52
+ }
53
+ } catch {
54
+ return { ...DEFAULT_QUOTA_PREFS }
55
+ }
56
+ }
57
+
58
+ export function writeQuotaPrefs(prefs: QuotaPrefs, filePath = resolveQuotaPrefsPath()): void {
59
+ mkdirSync(dirname(filePath), { recursive: true })
60
+ writeFileSync(filePath, `${JSON.stringify(prefs, null, 2)}\n`, 'utf8')
61
+ }
62
+
63
+ export function applyQuotaRow(prefs: QuotaPrefs, id: string, value: string): QuotaPrefs {
64
+ const next = { ...prefs }
65
+ if (id === 'quota.budget.sessionCap') {
66
+ if (['$1.00', '$2.00', '$5.00', '$10.00', 'unlimited'].includes(value)) {
67
+ next.sessionCap = value
68
+ }
69
+ } else if (id === 'quota.budget.alertThreshold') {
70
+ next.alertThreshold = value === 'disabled' ? 'disabled' : 'enabled'
71
+ } else if (id === 'quota.compaction.auto') {
72
+ next.autoCompact = value === 'disabled' ? 'disabled' : 'enabled'
73
+ }
74
+ return next
75
+ }
76
+
77
+ export function buildQuotaTab(
78
+ snapshot?: QuotaSnapshot,
79
+ languagePref?: string,
80
+ prefs: QuotaPrefs = readQuotaPrefs(),
81
+ ): SettingsTab {
82
+ const isPt = resolveLanguage(languagePref) === 'pt-BR'
83
+
84
+ return {
85
+ id: 'quota',
86
+ title: isPt ? 'Cotas & Gastos' : 'Quotas & Spend',
87
+ groups: [
88
+ {
89
+ title: isPt ? 'Consumo & Gastos de Sessão' : 'Session Spend & Tokens',
90
+ rows: [
91
+ {
92
+ id: 'quota.spend.today',
93
+ name: isPt ? 'Gasto hoje (00h-agora)' : 'Spend today (00h-now)',
94
+ value: snapshot?.todaySpend ?? '—',
95
+ note: isPt ? 'Calculado a partir de opencode.db' : 'Derived from opencode.db ledger',
96
+ },
97
+ {
98
+ id: 'quota.spend.month',
99
+ name: isPt ? 'Gasto acumulado (30d)' : 'Spend last 30 days',
100
+ value: snapshot?.monthSpend ?? '—',
101
+ note: isPt ? 'Janela móvel de 30 dias' : 'Rolling 30-day window',
102
+ },
103
+ {
104
+ id: 'quota.spend.session',
105
+ name: isPt ? 'Gasto na sessão ativa' : 'Active session spend',
106
+ value: snapshot?.sessionSpend ?? '—',
107
+ note: isPt ? 'Custo de todas as mensagens do turno' : 'Sum of turn assistant messages',
108
+ },
109
+ {
110
+ id: 'quota.tokens.context',
111
+ name: isPt ? 'Tokens de contexto' : 'Context tokens',
112
+ value: snapshot?.sessionTokens ?? '—',
113
+ note: isPt
114
+ ? 'Tokens consumidos vs janela do modelo'
115
+ : 'Tokens used vs model context limit',
116
+ },
117
+ {
118
+ id: 'quota.tokens.cache',
119
+ name: isPt ? 'Eficiência de cache' : 'Prompt cache hit',
120
+ value: snapshot?.cacheHit ?? '—',
121
+ note: isPt ? 'Desconto de leitura em cache aplicado' : 'Cache read discount applied',
122
+ },
123
+ ],
124
+ },
125
+ {
126
+ title: isPt ? 'Limites & Teto de Orçamento' : 'Rate Limits & Budget Caps',
127
+ rows: [
128
+ {
129
+ id: 'quota.budget.sessionCap',
130
+ name: isPt ? 'Teto por sessão' : 'Session budget cap',
131
+ value: prefs.sessionCap,
132
+ cycle: ['$1.00', '$2.00', '$5.00', '$10.00', 'unlimited'],
133
+ note: isPt
134
+ ? 'Avisa ou pausa ao atingir o teto'
135
+ : 'Warns or pauses when session spend reaches cap',
136
+ },
137
+ {
138
+ id: 'quota.budget.alertThreshold',
139
+ name: isPt ? 'Alerta em 80% do teto' : 'Alert at 80% of cap',
140
+ value: prefs.alertThreshold,
141
+ cycle: ['enabled', 'disabled'],
142
+ note: isPt
143
+ ? 'Emite aviso visual no footer da TUI'
144
+ : 'Shows visual notice in TUI footer',
145
+ },
146
+ {
147
+ id: 'quota.compaction.auto',
148
+ name: isPt ? 'Auto-compactar em 80% do contexto' : 'Auto-compact at 80% context',
149
+ value: prefs.autoCompact,
150
+ cycle: ['enabled', 'disabled'],
151
+ note: isPt
152
+ ? 'Aciona compressão automática de histórico'
153
+ : 'Triggers automatic context compaction',
154
+ },
155
+ ],
156
+ },
157
+ {
158
+ title: isPt
159
+ ? 'Provedores & Janelas de Cota (Referência)'
160
+ : 'Providers & Quota Windows (Reference)',
161
+ rows: [
162
+ {
163
+ id: 'quota.ref.anthropic',
164
+ name: 'Anthropic (Claude 3.7)',
165
+ value: 'Tier 4',
166
+ note: isPt
167
+ ? '400k TPM · Reset diário às 00:00 UTC'
168
+ : '400k TPM · Daily reset at 00:00 UTC',
169
+ },
170
+ {
171
+ id: 'quota.ref.openai',
172
+ name: 'OpenAI (GPT-4o)',
173
+ value: 'Tier 4',
174
+ note: isPt
175
+ ? '800k TPM · Reset por janela móvel de 1 min'
176
+ : '800k TPM · 1-minute rolling window',
177
+ },
178
+ {
179
+ id: 'quota.ref.google',
180
+ name: 'Google (Gemini 2.5)',
181
+ value: 'Pay-as-you-go',
182
+ note: isPt
183
+ ? '4M TPM · Alta capacidade com cota flexível'
184
+ : '4M TPM · High capacity with flexible quota',
185
+ },
186
+ ],
187
+ },
188
+ ],
189
+ }
190
+ }