pantheon-opencode 1.6.1 → 1.6.2-beta.10

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 (169) hide show
  1. package/AGENTS.global.md +11 -11
  2. package/AGENTS.md +2 -2
  3. package/CHANGELOG.md +179 -0
  4. package/README.md +268 -20
  5. package/README.pt-BR.md +34 -11
  6. package/bin/pantheon-init.mjs +301 -32
  7. package/package.json +13 -4
  8. package/plugin.json +1 -1
  9. package/prompts/README.md +58 -0
  10. package/prompts/debug-issue.prompt.md +46 -0
  11. package/prompts/dynamic/agora-generated.txt +38 -0
  12. package/prompts/dynamic/orchestrate-generated.txt +51 -0
  13. package/prompts/focus.prompt.md +42 -0
  14. package/prompts/implement-feature.prompt.md +39 -0
  15. package/prompts/optimize-database.prompt.md +58 -0
  16. package/prompts/orchestrate-with-zeus.prompt.md +441 -0
  17. package/prompts/plan-architecture.prompt.md +59 -0
  18. package/prompts/quick-discovery-large-codebase.prompt.md +294 -0
  19. package/prompts/quick-plan-large-feature.prompt.md +197 -0
  20. package/prompts/semantic-summarize.md +50 -0
  21. package/prompts/sketch.prompt.md +91 -0
  22. package/prompts/subtask.prompt.md +131 -0
  23. package/pyproject.toml +1 -1
  24. package/scripts/build-agents-md.mjs +1 -1
  25. package/scripts/decision-router-budget.mjs +780 -0
  26. package/scripts/decision-router-v2-budget.mjs +218 -0
  27. package/scripts/decision-router-v2-egress.mjs +272 -0
  28. package/scripts/decision-router.mjs +758 -0
  29. package/scripts/docs-check-changelog.mjs +5 -3
  30. package/scripts/doctor.mjs +213 -45
  31. package/scripts/install/agents-md.mjs +2 -1
  32. package/scripts/install/component-selection.mjs +9 -4
  33. package/scripts/install/config-migration.mjs +344 -393
  34. package/scripts/install/config-paths.mjs +15 -0
  35. package/scripts/install/decision-layer-preview.mjs +376 -0
  36. package/scripts/install/decision-router-config.mjs +560 -0
  37. package/scripts/install/health-check.mjs +20 -11
  38. package/scripts/install/interactive.mjs +103 -14
  39. package/scripts/install/interrupt.mjs +4 -3
  40. package/scripts/install/mcp-permissions.mjs +164 -0
  41. package/scripts/install/migrate.mjs +123 -72
  42. package/scripts/install/opencode-version.mjs +31 -13
  43. package/scripts/install/opencode-wildcard.mjs +106 -0
  44. package/scripts/install/opencode.mjs +411 -184
  45. package/scripts/install/plan-artifact.mjs +12 -1
  46. package/scripts/install/plan.mjs +8 -1
  47. package/scripts/install/plugin.mjs +18 -1
  48. package/scripts/install/state.mjs +12 -0
  49. package/scripts/install/strings.mjs +22 -0
  50. package/scripts/install/v2-capabilities.mjs +5 -6
  51. package/scripts/install/venv.mjs +34 -17
  52. package/scripts/mcp_resources.py +11 -9
  53. package/scripts/package-evidence.mjs +1 -0
  54. package/scripts/release-notes.mjs +30 -7
  55. package/scripts/restore.mjs +22 -10
  56. package/scripts/sandbox-env.sh +174 -0
  57. package/scripts/setup-v2-config.mjs +1703 -0
  58. package/scripts/setup.mjs +415 -0
  59. package/scripts/sync-tui.mjs +9 -1
  60. package/scripts/test-opencode-v2-sandbox.sh +448 -157
  61. package/scripts/update-skills-lock.mjs +30 -0
  62. package/scripts/versioning.mjs +41 -5
  63. package/skills-lock.json +10 -10
  64. package/src/agents/aphrodite.md +11 -3
  65. package/src/agents/apollo.md +6 -0
  66. package/src/agents/athena.md +7 -1
  67. package/src/agents/demeter.md +6 -2
  68. package/src/agents/gaia.md +5 -0
  69. package/src/agents/hephaestus.md +7 -2
  70. package/src/agents/hermes.md +14 -13
  71. package/src/agents/iris.md +6 -2
  72. package/src/agents/mnemosyne.md +21 -50
  73. package/src/agents/nyx.md +6 -2
  74. package/src/agents/prometheus.md +5 -1
  75. package/src/agents/talos.md +10 -1
  76. package/src/agents/themis.md +5 -1
  77. package/src/agents/zeus.md +61 -65
  78. package/src/instructions/agent-return-format.instructions.md +1 -1
  79. package/src/instructions/memory-protocol.instructions.md +3 -3
  80. package/src/instructions/test-economy.instructions.md +6 -6
  81. package/src/mcp/eval_store.py +11 -4
  82. package/src/mcp/mcp_resources.py +11 -9
  83. package/src/mcp/memory_mcp.py +293 -150
  84. package/src/mcp/pantheon_vision.py +37 -36
  85. package/src/pantheon/cost-command.ts +30 -133
  86. package/src/pantheon/jev-decision-tool.ts +347 -0
  87. package/src/pantheon/jev-decisions.ts +625 -0
  88. package/src/pantheon/local-decision-agents.ts +170 -0
  89. package/src/pantheon/local-decision-budget.ts +1046 -0
  90. package/src/pantheon/local-decision-egress-gate.ts +144 -0
  91. package/src/pantheon/local-decision-prompt.ts +256 -0
  92. package/src/pantheon/local-decision-provider-matrix.ts +44 -0
  93. package/src/pantheon/local-decision-router.ts +225 -0
  94. package/src/pantheon/local-decision-skills.ts +281 -0
  95. package/src/pantheon/local-decision-tool.ts +160 -0
  96. package/src/pantheon/local-decision-turn.ts +101 -0
  97. package/src/pantheon/local-decision-usage-evidence.internal.ts +168 -0
  98. package/src/pantheon/local-orchestration.ts +322 -0
  99. package/src/pantheon/model-pricing.ts +1 -536
  100. package/src/pantheon/pantheon-decision-catalog.ts +101 -0
  101. package/src/pantheon/v2-decision-budget.ts +456 -0
  102. package/src/pantheon/v2-decision-contracts.ts +300 -0
  103. package/src/pantheon/v2-decision-egress.ts +203 -0
  104. package/src/pantheon/v2-decision-events.ts +180 -0
  105. package/src/pantheon/v2-decision-heuristic.ts +121 -0
  106. package/src/pantheon/v2-decision-points/p1-agent.ts +91 -0
  107. package/src/pantheon/v2-decision-points/p10-claims.ts +243 -0
  108. package/src/pantheon/v2-decision-points/p11-catalog.ts +220 -0
  109. package/src/pantheon/v2-decision-points/p2-skill.ts +83 -0
  110. package/src/pantheon/v2-decision-points/p3-complexity.ts +108 -0
  111. package/src/pantheon/v2-decision-points/p4-memory.ts +137 -0
  112. package/src/pantheon/v2-decision-points/p5-themis-verify.ts +190 -0
  113. package/src/pantheon/v2-decision-points/p6-council.ts +161 -0
  114. package/src/pantheon/v2-decision-points/p7-loop.ts +263 -0
  115. package/src/pantheon/v2-decision-points/p8-guardrail.ts +367 -0
  116. package/src/pantheon/v2-decision-points/p9-memory-compaction.ts +304 -0
  117. package/src/pantheon/v2-decision-points.ts +242 -0
  118. package/src/pantheon/v2-decision-policy.ts +166 -0
  119. package/src/pantheon/v2-decision-premises.ts +146 -0
  120. package/src/pantheon/v2-decision-prompt-surface.ts +115 -0
  121. package/src/pantheon/v2-decision-rank.ts +91 -0
  122. package/src/pantheon/v2-decision-registry.ts +391 -0
  123. package/src/pantheon/v2-decision-resource-ids.ts +127 -0
  124. package/src/pantheon/v2-decision-shadow.ts +123 -0
  125. package/src/pantheon/v2-decision-telemetry.ts +214 -0
  126. package/src/pantheon/v2-decision-verify.ts +51 -0
  127. package/src/pantheon/v2-hook-engine.ts +307 -0
  128. package/src/pantheon/v2-native-decisions.ts +365 -0
  129. package/src/pantheon/v2-shell-hooks.ts +66 -2
  130. package/src/pantheon/v2-tools.ts +38 -15
  131. package/src/pantheon/v2-vision.ts +34 -29
  132. package/src/pantheon/vision.ts +43 -10
  133. package/src/plugin-v2.ts +449 -79
  134. package/src/plugin.ts +4 -0
  135. package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
  136. package/src/plugins/tui/dist/server-v2.d.ts +22 -0
  137. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -0
  138. package/src/plugins/tui/dist/server-v2.js +26 -0
  139. package/src/plugins/tui/dist/server-v2.js.map +1 -0
  140. package/src/plugins/tui/dist/tui-v2.d.ts +54 -51
  141. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  142. package/src/plugins/tui/dist/tui-v2.js +762 -529
  143. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  144. package/src/plugins/tui/dist/tui.js +1 -1
  145. package/src/plugins/tui/index-v2.ts +3 -6
  146. package/src/plugins/tui/package-lock.json +17 -2
  147. package/src/plugins/tui/package.json +6 -3
  148. package/src/plugins/tui/src/context-gauge.ts +59 -0
  149. package/src/plugins/tui/src/cost-data.ts +607 -0
  150. package/src/plugins/tui/src/index-v2.tsx +360 -242
  151. package/src/plugins/tui/src/model-pricing.ts +536 -0
  152. package/src/plugins/tui/src/model-usage-limits.ts +4 -0
  153. package/src/plugins/tui/src/server-v2.ts +21 -0
  154. package/src/plugins/tui/src/sidebar-width.ts +129 -0
  155. package/src/plugins/tui/tsconfig.typecheck.json +1 -1
  156. package/src/plugins/tui/tsdown.config.ts +34 -5
  157. package/src/routing.yml +72 -13
  158. package/src/skills/README.md +4 -0
  159. package/src/skills/agent-coordination/SKILL.md +0 -3
  160. package/src/skills/artifact-management/SKILL.md +0 -3
  161. package/src/skills/auto-continue/SKILL.md +0 -3
  162. package/src/skills/code-review-checklist/SKILL.md +0 -3
  163. package/src/skills/context-compression/SKILL.md +0 -3
  164. package/src/skills/memory-bank/SKILL.md +6 -28
  165. package/src/skills/session-goal/SKILL.md +0 -3
  166. package/src/skills/simplify/SKILL.md +5 -4
  167. package/src/skills/tdd-with-agents/SKILL.md +0 -3
  168. package/src/skills/visual-review-pipeline/SKILL.md +0 -1
  169. package/src/pantheon/memory-context.ts +0 -1017
package/README.pt-BR.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- synced-from: README.md @ 7359e4f -->
1
+ <!-- synced-from: README.md @ 0a6a8e2 -->
2
2
  # Pantheon
3
3
 
4
4
  **Uma forma mais clara de trabalhar com OpenCode em projetos de software
@@ -29,10 +29,10 @@ o que importou. Você continua no controle de cada decisão e de cada merge.
29
29
  - **Um ponto de partida repetível:** o mesmo setup entre projetos e
30
30
  colaboradores.
31
31
  - **Você no comando:** o Pantheon apoia seu julgamento; não o substitui.
32
- - **Coordenação na medida:** trabalho limitado vai para um especialista;
33
- planejamento, descoberta, trabalho paralelo e revisão entram quando escopo e
34
- risco pedem. `/pantheon-deepwork` continua sendo o fluxo com checkpoints para
35
- trabalho pesado em várias fases.
32
+ - **Coordenação na medida:** trabalho delimitado vai para um especialista, que
33
+ reúne o contexto necessário. Planejamento, descoberta separada, paralelismo e
34
+ revisão entram quando escopo e risco pedem. `/pantheon-deepwork` continua sendo
35
+ o fluxo com checkpoints para trabalho pesado em várias fases.
36
36
 
37
37
  ## Comece em 2 minutos
38
38
 
@@ -75,13 +75,32 @@ apenas — `init` → reiniciar → `/dispatch` → primeiro resultado — veja
75
75
  documentar.
76
76
  - **5 servidores MCP locais** para memória de projeto, persistência, recursos,
77
77
  execução confinada de scripts e visão.
78
+ - **Um roteador de decisão seletivo e consultivo**, com resultados locais
79
+ estruturados e recomendações por turno quando habilitado. O egress direto
80
+ pertencente ao Pantheon é inativo; o egress nativo existe apenas na tool
81
+ explícita `pantheon_jev_decide` (só para o Zeus), que chama a API nativa de
82
+ Decisions do host (Jev/TypeSafe via OpenCode Console ou modelo configurado)
83
+ atrás do consentimento e dos limites de orçamento do usuário — ela nunca
84
+ despacha agentes, executa skills ou altera permissões. Veja a
85
+ [referência do roteador](docs/reference/local-decision-router.md) e o
86
+ [Decisions nativas (Jev)](docs/reference/native-decisions.md).
78
87
  - **Uma TUI opcional**, com bloco de dispatch na sidebar e painel `/dispatch`
79
- em largura total.
80
-
81
- A memória é usada seletivamente: o coordenador busca uma vez apenas quando o
82
- histórico do projeto pode afetar a tarefa e repassa os resultados relevantes aos
83
- especialistas. Grave um resultado conciso e reutilizável ao concluir a tarefa
84
- quando ele for importar depois; resumos rotineiros de filhos ficam no handoff.
88
+ em largura total. A sidebar V2 mantém a versão do Pantheon, o preset/fonte
89
+ ativos, o estado do git e um bloco `Context` (tokens, medidor de percentual,
90
+ `$<gasto> gastos` e uma linha mutada `cache <n>% · <n.n> tok/s`); o rodapé
91
+ nativo do prompt segue intacto, e o Pantheon só acrescenta
92
+ `▸<preset> · ✦<n> ativos` enquanto há delegações rodando. A TUI não traz mais
93
+ painel de quota: para ver quota e uso de provedores dentro do OpenCode,
94
+ instale o plugin comunitário recomendado
95
+ [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) — veja
96
+ [Quota & uso](docs/tui-v2-quota-providers.md). As tools `pantheon_cost` e
97
+ `pantheon_model` seguem funcionando sem alterações.
98
+
99
+ A memória MCP fica disponível para busca explícita: o coordenador consulta o
100
+ histórico uma vez quando ele pode mudar a tarefa e repassa apenas resultados
101
+ úteis. Checkpoints de sessão servem para retomadas entre sessões; memória
102
+ durável só é gravada quando solicitada ou autorizada. A compactação nativa do
103
+ OpenCode resume a conversa atual, sem salvar cada fase em outro MCP.
85
104
  Veja [Memória](docs/MEMORY.md).
86
105
 
87
106
  ## Compatibilidade
@@ -155,6 +174,10 @@ bem-vindos. Leia o [CONTRIBUTING.md](CONTRIBUTING.md) antes de abrir uma issue o
155
174
  pull request. Esse arquivo também define a regra de documentação: um único lar
156
175
  por fato, com uma lista curta de fatos que não devem ser duplicados.
157
176
 
177
+ Em mudanças de código, comece pela verificação relevante mais pequena e amplie
178
+ conforme o risco. `npm test` executa a suíte completa do repositório; veja o
179
+ [CONTRIBUTING.md](CONTRIBUTING.md) para saber quando usá-la.
180
+
158
181
  ## Citação e DOI
159
182
 
160
183
  O Pantheon é distribuído sob a [Licença MIT](LICENSE). Cite o
@@ -21,16 +21,18 @@
21
21
  * (scripts/install/opencode-state.mjs).
22
22
  */
23
23
  import fs from 'node:fs'
24
- import os from 'node:os'
25
24
  import path from 'node:path'
26
25
  import { fileURLToPath } from 'node:url'
27
26
  import { configure as configureUi, endGaugeLine, tag } from '../scripts/install/cli-ui.mjs'
28
27
  import { resolveComponentSelection } from '../scripts/install/component-selection.mjs'
28
+ import { resolveGlobalConfigDirectory } from '../scripts/install/config-paths.mjs'
29
29
  import { resolveInstallExitCode } from '../scripts/install/exit-codes.mjs'
30
30
  import { createInterruptHandler } from '../scripts/install/interrupt.mjs'
31
+ import { parseOpenCodeVersion } from '../scripts/install/opencode-version.mjs'
31
32
  import {
32
33
  createPlanArtifact,
33
34
  loadPlanArtifact,
35
+ planArtifactDigest,
34
36
  savePlanArtifact,
35
37
  } from '../scripts/install/plan-artifact.mjs'
36
38
  import { PROMPT_CANCELED } from '../scripts/install/prompt-result.mjs'
@@ -58,6 +60,61 @@ function readVersion() {
58
60
  }
59
61
  }
60
62
 
63
+ /**
64
+ * Merge the TypeSafe decision-model provider entry into the user's
65
+ * `opencode.json` (never replaces existing keys; a non-JSON file is reported,
66
+ * never overwritten). Returns true, or a short failure reason.
67
+ */
68
+ /**
69
+ * Merge (never overwrite) the TypeSafe decision-model entry into the user's
70
+ * OpenCode config, so choosing the TypeSafe route in the wizard needs only the
71
+ * user's own sign-in afterwards. The merge is additive: existing provider
72
+ * entries and an existing jev-1.14.0 model are preserved. Returns true, or a
73
+ * short failure reason for the installer to print.
74
+ */
75
+ function provisionTypesafeProvider() {
76
+ const xdg = process.env.XDG_CONFIG_HOME
77
+ const home = process.env.HOME
78
+ const base = xdg && xdg.startsWith('/') ? xdg : `${home ?? '~'}/.config`
79
+ const candidates = [`${base}/opencode/opencode.json`]
80
+ if (home) candidates.push(`${home}/.config/opencode/opencode.json`)
81
+ const configPath = candidates.find((candidate) => fs.existsSync(candidate))
82
+ if (configPath === undefined) return 'opencode.json not found'
83
+ let data
84
+ try {
85
+ data = JSON.parse(fs.readFileSync(configPath, 'utf8'))
86
+ } catch {
87
+ return 'opencode.json is not plain JSON (comments?)'
88
+ }
89
+ data.providers ??= {}
90
+ data.providers['typesafe-ai'] ??= {}
91
+ data.providers['typesafe-ai'].models ??= {}
92
+ if (data.providers['typesafe-ai'].models['jev-1.14.0'] === undefined) {
93
+ data.providers['typesafe-ai'].models['jev-1.14.0'] = {
94
+ name: 'Jev (TypeSafe direct)',
95
+ modelID: 'jev-latest',
96
+ type: 'decision',
97
+ }
98
+ }
99
+ try {
100
+ fs.writeFileSync(configPath, `${JSON.stringify(data, null, 2)}\n`)
101
+ return true
102
+ } catch (error) {
103
+ return String(error instanceof Error ? error.message : error)
104
+ }
105
+ }
106
+
107
+ /** Value of a repeatable installer flag from the raw argv, or undefined. */
108
+ function readArgValue(name) {
109
+ const prefix = `${name}=`
110
+ for (let i = 1; i < process.argv.length; i++) {
111
+ const arg = process.argv[i]
112
+ if (arg === name) return process.argv[i + 1]
113
+ if (arg.startsWith(prefix)) return arg.slice(prefix.length)
114
+ }
115
+ return undefined
116
+ }
117
+
61
118
  function printUsage() {
62
119
  console.log('Pantheon OpenCode — Multi-agent orchestration platform')
63
120
  console.log('')
@@ -76,12 +133,21 @@ function printUsage() {
76
133
  console.log(' npx pantheon-opencode init --headless # Force non-interactive mode')
77
134
  console.log(' npx pantheon-opencode init -y # Skip confirmations, use defaults')
78
135
  console.log(' npx pantheon-opencode init --components agents,skills,instructions')
136
+ console.log(
137
+ ' npx pantheon-opencode init --decision-model opencode-console-jev/jev-1.13 --decision-monthly-usd 5 --decision-per-decision-usd 0.10',
138
+ )
79
139
  console.log(' npx pantheon-opencode init --opencode-version v1|v2|auto')
80
140
  console.log(' npx pantheon-opencode init --preset <name> # Install and activate model preset')
81
141
  console.log(
82
142
  ' npx pantheon-opencode init --merge-dev-config <path> # Merge a dev config (off by default)',
83
143
  )
84
144
  console.log(' npx pantheon-opencode set-tier <name> # Set active model preset (global)')
145
+ console.log(
146
+ ' npx pantheon-opencode decision-router help|status|setup|preview|holds # read-only',
147
+ )
148
+ console.log(
149
+ ' npx pantheon-opencode decision-router select|enable|consent|caps|period # explicit actions',
150
+ )
85
151
  console.log(
86
152
  ' npx pantheon-opencode update [--stable] # Update package + re-run init (default: beta channel)',
87
153
  )
@@ -190,6 +256,22 @@ async function main() {
190
256
  process.exit(result.status ?? 1)
191
257
  }
192
258
 
259
+ if (command === 'decision-router') {
260
+ const { DecisionRouterUsageError, runDecisionRouterCommand } = await import(
261
+ '../scripts/decision-router.mjs'
262
+ )
263
+ try {
264
+ await runDecisionRouterCommand(args.slice(1))
265
+ } catch (error) {
266
+ // A malformed command line is user input, not a crash: print one line and
267
+ // skip the stack the top-level handler would otherwise dump.
268
+ if (!(error instanceof DecisionRouterUsageError)) throw error
269
+ console.error(`Error: ${error.message}`)
270
+ process.exit(1)
271
+ }
272
+ return
273
+ }
274
+
193
275
  // beta.5: one-command update — check npm dist-tag, install, re-init.
194
276
  // Default channel is `beta` (the prerelease line); `--stable` uses `latest`.
195
277
  if (command === 'update') {
@@ -239,9 +321,7 @@ async function main() {
239
321
  }
240
322
  }
241
323
 
242
- const presetDir = isProject
243
- ? process.cwd()
244
- : path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'opencode')
324
+ const presetDir = isProject ? process.cwd() : resolveGlobalConfigDirectory(process.env)
245
325
  const filePath = path.join(presetDir, '.pantheon', 'active-preset.json')
246
326
  const bakPath = path.join(presetDir, '.pantheon', 'active-preset.json.bak')
247
327
 
@@ -316,9 +396,15 @@ async function main() {
316
396
  !Array.isArray(options.components) ||
317
397
  options.components.some(
318
398
  (component) =>
319
- !['agents', 'skills', 'instructions', 'commands', 'plugins', 'runtime'].includes(
320
- component,
321
- ),
399
+ ![
400
+ 'agents',
401
+ 'skills',
402
+ 'instructions',
403
+ 'prompts',
404
+ 'commands',
405
+ 'plugins',
406
+ 'runtime',
407
+ ].includes(component),
322
408
  ) ||
323
409
  options.clean !== false ||
324
410
  !['v1', 'v2', 'auto'].includes(options.version) ||
@@ -329,7 +415,24 @@ async function main() {
329
415
  }
330
416
  }
331
417
  const isProject = reviewedPlan ? reviewedPlan.options.isProject : args.includes('--project')
418
+ const setupTarget = !reviewedPlan ? process.env.PANTHEON_SETUP_TARGET : undefined
419
+ if (setupTarget !== undefined) {
420
+ const expectedGlobalTarget = path.resolve(resolveGlobalConfigDirectory(process.env))
421
+ if (isProject || path.resolve(setupTarget) !== expectedGlobalTarget) {
422
+ console.error(
423
+ '❌ Invalid setup target; it must match the selected global OpenCode config directory',
424
+ )
425
+ process.exit(1)
426
+ }
427
+ }
332
428
  const isDryRun = reviewedPlan ? false : args.includes('--dry-run')
429
+ const setupConfigPreview = args.includes('--setup-config-preview-stdin')
430
+ const setupPlanJson = args.includes('--setup-plan-json')
431
+ const setupApprovedPlanInput = args.includes('--setup-approved-plan-stdin')
432
+ if (setupConfigPreview && !isDryRun) {
433
+ console.error('❌ Setup config previews are accepted only by init --dry-run')
434
+ process.exit(1)
435
+ }
333
436
  // --clean is an alias of --force (both wipe component dirs + recreate venv).
334
437
  const forceReinstall = reviewedPlan
335
438
  ? reviewedPlan.options.clean
@@ -339,6 +442,17 @@ async function main() {
339
442
  const forceHeadless = args.includes('--headless')
340
443
  let autoYes = args.includes('--yes') || args.includes('-y')
341
444
  const isJson = args.includes('--json')
445
+ if (setupPlanJson && (!isDryRun || !isJson || reviewedPlan)) {
446
+ console.error('❌ Setup plan output is available only with init --dry-run --json')
447
+ process.exit(1)
448
+ }
449
+ if (
450
+ setupApprovedPlanInput &&
451
+ (isDryRun || !autoYes || !forceHeadless || reviewedPlan || setupConfigPreview)
452
+ ) {
453
+ console.error('❌ An approved setup plan is accepted only by authorized headless init')
454
+ process.exit(1)
455
+ }
342
456
  const savePlanIndex = args.indexOf('--save-plan')
343
457
  const inlineSavePlan = args.find((arg) => arg.startsWith('--save-plan='))
344
458
  const savePlanPath =
@@ -377,6 +491,9 @@ async function main() {
377
491
  '--merge-dev-config',
378
492
  '--apply-plan',
379
493
  '--save-plan',
494
+ '--decision-model',
495
+ '--decision-monthly-usd',
496
+ '--decision-per-decision-usd',
380
497
  ])
381
498
  for (let i = 1; i < args.length; i++) {
382
499
  const arg = args[i]
@@ -400,6 +517,9 @@ async function main() {
400
517
  '--yes',
401
518
  '-y',
402
519
  '--json',
520
+ '--setup-config-preview-stdin',
521
+ '--setup-plan-json',
522
+ '--setup-approved-plan-stdin',
403
523
  '--verbose',
404
524
  ].includes(bare)
405
525
  ) {
@@ -440,16 +560,7 @@ async function main() {
440
560
  // --version v1|v2|auto labels the install target. `auto` resolves the
441
561
  // generation from the opencode binary at install time (see
442
562
  // scripts/install/opencode-version.mjs). Invalid values fail fast.
443
- const versionIndex = args.indexOf('--version')
444
- const legacyVersionIndex = args.indexOf('--opencode-version')
445
- const inlineVersion = args.find((arg) => arg.startsWith('--opencode-version='))
446
- const versionOpt = reviewedPlan
447
- ? reviewedPlan.options.version
448
- : versionIndex >= 0
449
- ? (args[versionIndex + 1] ?? null)
450
- : legacyVersionIndex >= 0
451
- ? (args[legacyVersionIndex + 1] ?? null)
452
- : (inlineVersion?.split('=', 2)[1] ?? null)
563
+ const versionOpt = reviewedPlan ? reviewedPlan.options.version : parseOpenCodeVersion(args)
453
564
  if (
454
565
  versionOpt !== null &&
455
566
  versionOpt !== 'v1' &&
@@ -459,9 +570,17 @@ async function main() {
459
570
  console.error(`❌ Invalid --version "${versionOpt}" — expected v1, v2 or auto`)
460
571
  process.exit(1)
461
572
  }
573
+ // The 2.0 deprecation front-run: the legacy plugin line is end-of-life.
574
+ // Loud warning now (the v1 code path still exists for legacy installs);
575
+ // the 2.0 removal turns this into a hard refusal.
576
+ if (versionOpt === 'v1') {
577
+ console.error(
578
+ '⚠️ --opencode-version v1 is DEPRECATED and will be removed in Pantheon 2.0 — the legacy plugin line is end-of-life. OpenCode 2.x hosts are the supported generation; remove the flag (auto detects the host).',
579
+ )
580
+ }
462
581
 
463
- // Resolve the user's explicit selection separately from the defaults. An
464
- // unscoped install gets runtime by default; explicit --components does not.
582
+ // Resolve the user's explicit selection separately from the defaults.
583
+ // Runtime and prompt templates are opt-in in both TTY and headless mode.
465
584
  let componentSelection
466
585
  try {
467
586
  componentSelection = resolveComponentSelection(args, {
@@ -502,9 +621,10 @@ async function main() {
502
621
  // interactive prompts can cancel before a location is chosen. Mirrors the
503
622
  // installer's own default (`~/.config/opencode`), so the record lands next
504
623
  // to the config the next run will read.
505
- const fallbackTarget = isProject
506
- ? process.cwd()
507
- : path.join(os.homedir(), '.config', 'opencode')
624
+ const fallbackTarget = isProject ? process.cwd() : resolveGlobalConfigDirectory(process.env)
625
+ let chosenTarget = reviewedPlan?.target.path ?? fallbackTarget
626
+ let hasAppliedWrites = false
627
+ let recoveryBackup = null
508
628
  /**
509
629
  * Persist the one-line record of this run. Bookkeeping is best-effort: a
510
630
  * failure is reported, never fatal, and never changes the exit code.
@@ -512,7 +632,7 @@ async function main() {
512
632
  * @param {{status: string, reason?: string|null, cancelPoint?: string|null, applied: boolean, target?: string}} outcome
513
633
  */
514
634
  const recordRun = (outcome) => {
515
- const recordTarget = outcome.target ?? result?.target ?? fallbackTarget
635
+ const recordTarget = outcome.target ?? result?.target ?? chosenTarget
516
636
  const record = buildRunRecord({
517
637
  status: outcome.status,
518
638
  reason: outcome.reason ?? null,
@@ -590,16 +710,20 @@ async function main() {
590
710
  // consumes Ctrl-C in raw mode while a question is on screen (that path is
591
711
  // the interactive cancel above), so this covers the rest of the run.
592
712
  const onInterrupt = createInterruptHandler({
593
- message: S.canceledAt(S.cancelPoints.interrupt),
713
+ message: () =>
714
+ hasAppliedWrites
715
+ ? S.interruptedAfterWrite(recoveryBackup)
716
+ : S.canceledAt(S.cancelPoints.interrupt),
594
717
  json: isJson,
595
718
  endGaugeLine,
596
719
  onInterrupt: () => {
597
720
  if (!isDryRun) {
598
721
  recordRun({
599
- status: 'canceled',
600
- reason: 'canceled',
722
+ status: hasAppliedWrites ? 'partial' : 'canceled',
723
+ reason: hasAppliedWrites ? 'interrupted' : 'canceled',
601
724
  cancelPoint: 'interrupt',
602
- applied: false,
725
+ applied: hasAppliedWrites,
726
+ target: chosenTarget,
603
727
  })
604
728
  }
605
729
  },
@@ -608,7 +732,49 @@ async function main() {
608
732
  let installError = null
609
733
  try {
610
734
  const { installOpenCode } = await import('../scripts/install/opencode.mjs')
611
- const target = reviewedPlan ? reviewedPlan.target.path : isProject ? process.cwd() : undefined
735
+ let configPreview = null
736
+ let setupApprovedPlan = null
737
+ if (setupConfigPreview) {
738
+ try {
739
+ configPreview = fs.readFileSync(0, 'utf8')
740
+ if (configPreview.length === 0) throw new Error('empty')
741
+ } catch {
742
+ throw new Error('The setup config preview input is invalid.')
743
+ }
744
+ }
745
+ if (setupApprovedPlanInput) {
746
+ try {
747
+ const envelope = JSON.parse(fs.readFileSync(0, 'utf8'))
748
+ if (
749
+ envelope?.schema_version !== 1 ||
750
+ !envelope.plan ||
751
+ !Array.isArray(envelope.configPreconditions) ||
752
+ typeof envelope.digest !== 'string' ||
753
+ planArtifactDigest(envelope.plan) !== envelope.digest
754
+ ) {
755
+ throw new Error('invalid setup plan envelope')
756
+ }
757
+ if (envelope.configPreconditions.length > 0) {
758
+ const { verifyConfigPreconditions } = await import('../scripts/setup-v2-config.mjs')
759
+ if (
760
+ !verifyConfigPreconditions(envelope.configPreconditions, {
761
+ configDir: setupTarget,
762
+ stage: 'expected',
763
+ })
764
+ ) {
765
+ throw new Error('reviewed config inputs changed')
766
+ }
767
+ }
768
+ setupApprovedPlan = envelope
769
+ } catch {
770
+ throw new Error('The approved setup plan or config snapshots are invalid or drifted.')
771
+ }
772
+ }
773
+ const target = reviewedPlan
774
+ ? reviewedPlan.target.path
775
+ : isProject
776
+ ? process.cwd()
777
+ : setupTarget
612
778
  result = await installOpenCode(target, isDryRun, forceReinstall, components, {
613
779
  interactive: forceInteractive,
614
780
  headless: reviewedPlan ? true : forceHeadless,
@@ -618,13 +784,29 @@ async function main() {
618
784
  preset: presetOpt,
619
785
  version: versionOpt ?? 'auto',
620
786
  mergeDevConfig: mergeDevConfigOpt,
621
- expectedPlan: reviewedPlan,
787
+ expectedPlan: reviewedPlan ?? setupApprovedPlan?.plan ?? null,
788
+ isProject,
622
789
  requestedComponents: requestedComponentsForPrompt,
623
790
  noMcp: skipMCP,
624
791
  planTimestamp,
625
792
  quiet: isJson,
626
793
  verbose: args.includes('--verbose') && !isJson,
794
+ configPreview,
795
+ onTargetResolved: (resolvedTarget) => {
796
+ chosenTarget = resolvedTarget
797
+ },
798
+ onWrite: ({ target: writeTarget, backupDir }) => {
799
+ hasAppliedWrites = true
800
+ chosenTarget = writeTarget
801
+ if (backupDir) recoveryBackup = backupDir
802
+ },
627
803
  })
804
+ // File writers and the runtime installer use synchronous APIs. If SIGINT
805
+ // arrives during one of those calls, Node queues the signal callback
806
+ // until the event loop runs again. Keep the handler armed for one turn
807
+ // after the installer returns so a queued post-write interrupt is still
808
+ // recorded as partial instead of being lost to the success path.
809
+ await new Promise((resolve) => setImmediate(resolve))
628
810
  } catch (err) {
629
811
  installError = err
630
812
  } finally {
@@ -647,8 +829,15 @@ async function main() {
647
829
  `${S.installFailed(installError.message)}\n${S.failHintNoMcp}\n${S.failHintForce}`,
648
830
  )
649
831
  }
650
- // No record for a thrown failure: the error itself is the explanation,
651
- // and a run that failed has nothing to remember beyond its message.
832
+ if (!isDryRun) {
833
+ const outcome = installError.installOutcome ?? {}
834
+ recordRun({
835
+ status: outcome.applied ? 'partial' : 'failed',
836
+ reason: 'failed',
837
+ applied: outcome.applied === true,
838
+ target: outcome.target ?? chosenTarget,
839
+ })
840
+ }
652
841
  process.exitCode = 1
653
842
  return
654
843
  }
@@ -700,6 +889,26 @@ async function main() {
700
889
  if (Object.hasOwn(totals, file.action)) totals[file.action] += 1
701
890
  }
702
891
  const mcpServers = result.mcpServers ?? []
892
+ const setupPlan = setupPlanJson
893
+ ? createPlanArtifact({
894
+ target: result.target,
895
+ packageRoot: ROOT,
896
+ packageVersion: version,
897
+ plannedAt: planTimestamp,
898
+ options: {
899
+ clean: forceReinstall,
900
+ components,
901
+ version: result.openCodeVersion,
902
+ isProject,
903
+ model: modelOpt,
904
+ smallModel: smallModelOpt,
905
+ preset: presetOpt,
906
+ mergeDevConfig: mergeDevConfigOpt,
907
+ },
908
+ files: result.files,
909
+ snapshots: result.snapshots,
910
+ })
911
+ : null
703
912
  process.stdout.write(
704
913
  `${JSON.stringify({
705
914
  schema_version: 1,
@@ -728,12 +937,16 @@ async function main() {
728
937
  totals,
729
938
  mcp_servers: mcpServers,
730
939
  mcp_server_count: mcpServers.length,
940
+ runtime_effects: result.runtimeEffects ?? null,
731
941
  files: files.map(({ path: filePath, action, bytes }) => ({
732
942
  path: path.relative(result.target, filePath) || '.',
733
943
  action,
734
944
  bytes,
735
945
  })),
736
946
  saved_plan: savePlanPath ? path.resolve(savePlanPath) : null,
947
+ ...(setupPlan
948
+ ? { setup_plan: setupPlan, setup_plan_digest: planArtifactDigest(setupPlan) }
949
+ : {}),
737
950
  })}\n`,
738
951
  )
739
952
  return
@@ -794,7 +1007,10 @@ async function main() {
794
1007
  const doctorStartedAt = Date.now()
795
1008
  const { spawnSync } = await import('node:child_process')
796
1009
  const doctorScript = path.join(ROOT, 'scripts', 'doctor.mjs')
797
- const doctor = spawnSync(process.execPath, [doctorScript], { stdio: 'inherit', cwd: ROOT })
1010
+ const doctor = spawnSync(process.execPath, [doctorScript, '--target', result.target], {
1011
+ stdio: 'inherit',
1012
+ cwd: ROOT,
1013
+ })
798
1014
  const doctorSeconds = ((Date.now() - doctorStartedAt) / 1000).toFixed(1)
799
1015
  // Never leave "Running health check..." as the last word: report the
800
1016
  // outcome and duration, and propagate the child's exit code so CI sees
@@ -811,6 +1027,56 @@ async function main() {
811
1027
  }
812
1028
  }
813
1029
 
1030
+ // Optional Jev decision-model activation, requested at install time with
1031
+ // explicit caps (the setup-model chain: selection + enable + consent +
1032
+ // user/provider/model caps + period confirmation). Dry-run prints intent
1033
+ // only. Failures never fail the install itself.
1034
+ // Explicit flags win; otherwise honor the wizard's Jev activation choice.
1035
+ const wizardActivation = result.decisionModelActivation ?? null
1036
+ const decisionTarget = readArgValue('--decision-model') ?? wizardActivation?.target ?? null
1037
+ if (decisionTarget) {
1038
+ const monthly = readArgValue('--decision-monthly-usd') ?? wizardActivation?.monthly ?? '5'
1039
+ const perDecision =
1040
+ readArgValue('--decision-per-decision-usd') ?? wizardActivation?.perDecision ?? '0.10'
1041
+ const noConsent = process.argv.includes('--decision-no-consent')
1042
+ console.log('')
1043
+ if (isDryRun) {
1044
+ console.log(` ${S.jevDryRun(decisionTarget)}`)
1045
+ } else {
1046
+ try {
1047
+ const { runDecisionRouterCommand } = await import('../scripts/decision-router.mjs')
1048
+ await runDecisionRouterCommand(
1049
+ [
1050
+ 'setup-model',
1051
+ decisionTarget,
1052
+ '--monthly-usd',
1053
+ monthly,
1054
+ '--per-decision-usd',
1055
+ perDecision,
1056
+ ...(noConsent ? ['--no-consent'] : []),
1057
+ ],
1058
+ { stdout: (line) => console.log(` ${line}`) },
1059
+ )
1060
+ console.log(` ${S.jevConfigured(decisionTarget)}`)
1061
+ if (decisionTarget.startsWith('typesafe-jev')) {
1062
+ const provisioned = provisionTypesafeProvider()
1063
+ console.log(
1064
+ provisioned === true
1065
+ ? ' TypeSafe provider entry merged into opencode.json (models.typesafe-ai, type "decision"). Sign in with `opencode auth login` (TypeSafe) or /connect.'
1066
+ : ` TypeSafe provider entry NOT merged (${provisioned}); merge it manually — see docs/reference/native-decisions.md.`,
1067
+ )
1068
+ }
1069
+ } catch (error) {
1070
+ console.error(
1071
+ ` ${S.jevConfigureFailed(error instanceof Error ? error.message : String(error))}`,
1072
+ )
1073
+ console.error(
1074
+ ` Fix later with: npx pantheon-opencode decision-router setup-model ${decisionTarget} --monthly-usd ${monthly} --per-decision-usd ${perDecision}`,
1075
+ )
1076
+ }
1077
+ }
1078
+ }
1079
+
814
1080
  console.log('')
815
1081
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
816
1082
  console.log(` ${S.installedTitle(version)}`)
@@ -821,6 +1087,9 @@ async function main() {
821
1087
  console.log(` ${S.nextLaunch}`)
822
1088
  console.log(` ${S.nextAgents}`)
823
1089
  console.log(` ${S.nextProject}`)
1090
+ if (!decisionTarget) {
1091
+ console.log(` ${S.nextJev}`)
1092
+ }
824
1093
  console.log('')
825
1094
 
826
1095
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.1",
3
+ "version": "1.6.2-beta.10",
4
4
  "description": "Multi-agent orchestration for OpenCode — 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -11,6 +11,7 @@
11
11
  "registry": "https://registry.npmjs.org/"
12
12
  },
13
13
  "exports": {
14
+ "./local-decision-router": "./src/pantheon/local-decision-router.ts",
14
15
  "./plugin": "./src/plugin.ts",
15
16
  "./plugin-v2": "./src/plugin-v2.ts",
16
17
  "./v2-bridge": "./src/pantheon/v2-bridge.ts"
@@ -18,15 +19,19 @@
18
19
  "scripts": {
19
20
  "postinstall": "node scripts/postinstall.mjs && node scripts/sync-tui.mjs",
20
21
  "prepare": "husky",
21
- "setup": "node bin/pantheon-init.mjs init --yes",
22
+ "setup": "node scripts/setup.mjs",
22
23
  "build:agents-md": "node scripts/build-agents-md.mjs",
24
+ "build:decision-router": "node scripts/build-decision-router.mjs",
25
+ "check:decision-router": "node scripts/build-decision-router.mjs --check",
26
+ "skills:lock": "node scripts/update-skills-lock.mjs",
23
27
  "setup:lite": "node bin/pantheon-init.mjs init --yes --clean --components agents,skills,instructions",
24
28
  "doctor": "node scripts/doctor.mjs",
25
29
  "prune": "node scripts/prune.mjs",
26
30
  "init": "node bin/pantheon-init.mjs init --yes",
27
31
  "opencode": "OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true opencode",
28
32
  "start": "OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true opencode",
29
- "prepublishOnly": "node scripts/validate-routing.mjs",
33
+ "prepack": "npm run check:decision-router",
34
+ "prepublishOnly": "node scripts/validate-routing.mjs && npm run check:decision-router",
30
35
  "postpublish": "node -e \"console.log('✅ Published pantheon-opencode v' + require('./package.json').version + ' to npm')\"",
31
36
  "version:status": "node scripts/versioning.mjs status",
32
37
  "version:apply": "node scripts/versioning.mjs apply",
@@ -34,7 +39,7 @@
34
39
  "release:dry-run": "node scripts/versioning.mjs status && node scripts/release-notes.mjs && node scripts/package-evidence.mjs",
35
40
  "package:evidence": "node scripts/package-evidence.mjs",
36
41
  "engine:check": "node scripts/validate-node-engine-policy.mjs",
37
- "package:validate": "node scripts/validate-package.mjs && npm run engine:check",
42
+ "package:validate": "node scripts/validate-package.mjs && npm run check:decision-router && npm run engine:check",
38
43
  "lint": "biome ci .",
39
44
  "docs:lint": "node scripts/docs-link-check.mjs",
40
45
  "docs:media": "node scripts/docs-media.mjs",
@@ -86,6 +91,7 @@
86
91
  "src/instructions/*.instructions.md",
87
92
  "src/mcp/*.mjs",
88
93
  "scripts/*.mjs",
94
+ "!scripts/build-decision-router.mjs",
89
95
  "src/mcp/*.sh",
90
96
  "src/routing.yml",
91
97
  "src/pantheon/**",
@@ -99,6 +105,7 @@
99
105
  "src/plugins/tui/**",
100
106
  "!src/plugins/tui/node_modules/**",
101
107
  "src/skills/**",
108
+ "prompts/**",
102
109
  "!**/__pycache__/**",
103
110
  "!**/*.pyc"
104
111
  ],
@@ -113,7 +120,9 @@
113
120
  "@biomejs/biome": "2.5.14",
114
121
  "@commitlint/cli": "21.2.3",
115
122
  "@commitlint/config-conventional": "21.2.3",
123
+ "@opencode/plugin": "2.2.5",
116
124
  "ajv": "8.20.0",
125
+ "esbuild": "0.28.2",
117
126
  "husky": "^9.1.7",
118
127
  "tsx": "4.23.15",
119
128
  "typescript": "7.0.2"
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.1",
4
+ "version": "1.6.2-beta.10",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 20 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",