pantheon-opencode 2.0.4 → 2.1.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.
Files changed (39) hide show
  1. package/AGENTS.global.md +2 -2
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +53 -0
  4. package/README.md +27 -11
  5. package/README.pt-BR.md +27 -11
  6. package/commands/pantheon-deepwork.md +11 -2
  7. package/package.json +2 -1
  8. package/plugin.json +1 -1
  9. package/prompts/orchestrate-with-zeus.prompt.md +2 -0
  10. package/pyproject.toml +1 -1
  11. package/scripts/cost.mjs +4 -5
  12. package/scripts/docs-media.mjs +1 -1
  13. package/skills-lock.json +1 -1
  14. package/src/agents/athena.md +10 -8
  15. package/src/agents/themis.md +1 -0
  16. package/src/agents/zeus.md +32 -3
  17. package/src/instructions/agent-return-format.instructions.md +1 -1
  18. package/src/mcp/pantheon_vision.py +33 -2
  19. package/src/pantheon/cost-command.ts +4 -1
  20. package/src/pantheon/deepwork/deepwork-tool.ts +370 -0
  21. package/src/pantheon/deepwork/plan-projection.ts +274 -0
  22. package/src/pantheon/deepwork/plan-schema.ts +93 -0
  23. package/src/pantheon/deepwork/plan-tracker.ts +336 -0
  24. package/src/pantheon/native-vision.ts +4 -2
  25. package/src/pantheon/skill-search-tool.ts +2 -2
  26. package/src/pantheon/tools.ts +2 -0
  27. package/src/plugin/index.js +922 -42
  28. package/src/plugin.ts +2 -2
  29. package/src/plugins/tui/dist/tui.js +461 -289
  30. package/src/plugins/tui/dist/tui.js.map +1 -1
  31. package/src/plugins/tui/package-lock.json +2 -2
  32. package/src/plugins/tui/package.json +1 -1
  33. package/src/plugins/tui/src/autonomy-state.ts +14 -16
  34. package/src/plugins/tui/src/decision-router-state.ts +22 -10
  35. package/src/plugins/tui/src/pantheon-settings-state.ts +119 -35
  36. package/src/plugins/tui/src/pantheon-settings.tsx +142 -48
  37. package/src/plugins/tui/src/preset-state.ts +96 -6
  38. package/src/plugins/tui/src/update-status.ts +62 -22
  39. package/src/skills/prompt-refinery/SKILL.md +6 -4
package/AGENTS.global.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <!-- pantheon:generated:begin — Pantheon-managed region; regenerated on install/upgrade, never edit inside -->
2
2
  <!-- Generated by scripts/build-agents-md.mjs — do not edit directly. -->
3
3
  <!-- Source of truth: src/instructions/*.instructions.md + the static sections in this script. -->
4
- <!-- pantheon:agents-md v2 artifact=global generated-at=2026-11-11T22:52:04-03:00 sha=ec8bbf8 -->
4
+ <!-- pantheon:agents-md v2 artifact=global generated-at=2026-11-13T10:55:59-03:00 sha=7d3bb91 -->
5
5
 
6
6
  # Pantheon Agent System — OpenCode
7
7
 
@@ -48,7 +48,7 @@ For investigation agents (Apollo, Athena), return structured findings: key findi
48
48
 
49
49
  ### Athena Plan Handoff
50
50
 
51
- When Zeus delegates Athena through the root `subagent` dispatch, its final task result MUST contain the complete Markdown plan (not a summary, artifact path, or approval question): goal, scope and assumptions, phases, affected files or areas, dependencies, verification, risks, open questions, acceptance criteria — unknowns marked, never guessed. This supersedes the structured-findings format. Athena must not call `agent/askQuestions`, pause for user input, or ask for approval in the child session. Zeus publishes the full plan as a normal message before any approval UI, never bundling plan and approval question; if the runtime cannot guarantee that order, Zeus asks for approval in plain text afterwards and waits for the next user message. Direct Athena invocations show the complete plan before requesting approval.
51
+ When Zeus delegates Athena through the root `subagent` dispatch, its final task result MUST contain the complete Markdown plan (not a summary, artifact path, or approval question): goal, scope and assumptions, phases, affected files or areas, dependencies, verification, risks, open questions, acceptance criteria — unknowns marked, never guessed. This supersedes the structured-findings format. Athena must not call `agent/askQuestions`, pause for user input, or ask for approval in the child session. Zeus publishes the full plan before approval UI, never bundling them; if order is not guaranteed, Zeus asks in plain text afterwards. For Open Questions or decisions needed, Zeus prompts via the native `question` tool with structured options and marked recommended defaults, never leaving inert text bullets. Direct Athena invocations show the complete plan before requesting approval.
52
52
 
53
53
  ## Council Specialist Response Format
54
54
 
package/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <!-- pantheon:generated:begin — Pantheon-managed region; regenerated on install/upgrade, never edit inside -->
2
2
  <!-- Generated by scripts/build-agents-md.mjs — do not edit directly. -->
3
3
  <!-- Source of truth: project sections in scripts/build-agents-md.mjs. -->
4
- <!-- pantheon:agents-md v2 artifact=project generated-at=2026-11-11T22:52:04-03:00 sha=ec8bbf8 -->
4
+ <!-- pantheon:agents-md v2 artifact=project generated-at=2026-11-13T10:55:59-03:00 sha=7d3bb91 -->
5
5
 
6
6
  # Pantheon — Repository Setup
7
7
 
package/CHANGELOG.md CHANGED
@@ -5,6 +5,59 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
7
 
8
+ ## [Unreleased]
9
+
10
+ <!-- Add new changes here.
11
+ Canonical sections (docs/RELEASING.md): ### 🆕 What's New (curated highlights, ≤6 bullets ≤140 chars) →
12
+ ### Added / Changed / Deprecated / Removed / Fixed / Security → ### ⚠️ Known Issues / ### ✅ Closed Issues.
13
+ `node scripts/versioning.mjs apply --notes` pre-fills the generated sections from conventional commits.
14
+ Running apply will move this section to a versioned entry and reset the template below. -->
15
+
16
+ ## [v2.1.1] - 2026-11-13
17
+
18
+ ### 🆕 What's New
19
+
20
+ - **Interactive Question Gate**: Native OpenCode `question` tool strictly enforced for all open decisions in planning, with marked defaults.
21
+ - **Runnable Real-World Examples**: Complete production examples (`examples/saas-dashboard` & `examples/cli-tool`) with automated test suites.
22
+ - **Comprehensive Docs & Wiki**: Modernized guides portal (`docs/guides/`), interactive Mermaid capability matrix, and GitHub Wiki mirror.
23
+ - **V2 Legacy Cleanup**: Removed obsolete "V2" naming clutter across internal policy markers, visual context tags, tape scripts, and docs.
24
+
25
+ ### Added
26
+
27
+ - **docs** — modern guide collection (`first-project.md`, `deepwork.md`, `vision.md`, `cookbook.md`), bilingual README tables, and interactive Mermaid decision diagrams.
28
+ - **examples** — `saas-dashboard` (React 19 + Fastify + CSV streaming + canonical Deepwork plan) and `cli-tool` (repo health checker CLI with tests).
29
+ - **wiki** — comprehensive GitHub Wiki mirror in `wiki/` (`Home.md`, `Agent-Matrix.md`, `Deepwork-Guide.md`, `Pantheon-Vision.md`, `FAQ.md`).
30
+
31
+ ### Changed
32
+
33
+ - **agents** — updated `@zeus`, `@athena`, and `prompt-refinery` to forbid dumping open questions into chat; required interactive `question` tool with marked `(Recomendado)` defaults.
34
+ - **core** — renamed internal markers to `<!-- pantheon-policy -->` and `<!-- pantheon-visual-context -->`; cleaned up legacy V2 file names.
35
+
36
+ ## [v2.1.0] - 2026-11-12
37
+
38
+ ### 🆕 What's New
39
+
40
+ - **Deepwork Canonical Plan**: Structured JSON ground truth (`plan.json`) and append-only event log with Mermaid DAG and zero HTML.
41
+ - **Vision Modernization**: Configurable Vision Model row in TUI Settings synced to `opencode-vision.json` and explicit `vision_describe`.
42
+ - **Project Skill Decision**: Proactive interactive question gate for external skills, strictly isolated into `.agents/skills/`.
43
+ - **TUI Settings Polish**: Full pt-BR localization across tabs, formatted status badges, and resolved title collision in Changelog tab.
44
+
45
+ ### Added
46
+
47
+ - **deepwork** — canonical JSON-driven plan architecture, `pantheon_deepwork` tool, fail-first acceptance criteria, native `question` gates, and Mermaid DAG projections.
48
+ - **vision** — configurable vision model in TUI Settings (`Preset` tab), `.opencode/opencode-vision.json` support in Python MCP server, and explicit `vision_describe` guidance.
49
+ - **skills** — proactive interactive question gate for 1-click project-scoped installation (`.agents/skills/`) with execution delegated to `@hermes`/`@talos`.
50
+ - **tui** — Portuguese localization across tabs, rich system metadata in About tab, and formatted status badges (`< ativado >`, `< desativado >`).
51
+
52
+ ### Changed
53
+
54
+ - **agents** — updated Zeus rules in `src/agents/zeus.md` and prompts to forbid manual terminal commands and enforce project-isolated `.agents/skills/`.
55
+
56
+ ### Fixed
57
+
58
+ - **vision** — eliminate prompt context clutter and raw HTML comment dumps (`<!-- pantheon-v2-visual-context -->`), ensuring models invoke `vision_describe`.
59
+ - **tui** — resolved title collision visual bug in Changelog tab by splitting on delimiters and omitting empty middle box for highlight rows.
60
+
8
61
  ## [v2.0.4] - 2026-11-12
9
62
 
10
63
  ### 🆕 What's New
package/README.md CHANGED
@@ -9,6 +9,7 @@ and teams who want useful structure without giving up speed or control of their
9
9
  [Repository](https://github.com/ils15/pantheon-opencode) · [MIT License](LICENSE)
10
10
 
11
11
  [![Version](https://img.shields.io/github/v/release/ils15/pantheon-opencode?label=version)](https://github.com/ils15/pantheon-opencode/releases/latest)
12
+ [![Docs](https://img.shields.io/badge/docs-portal-indigo)](https://ils15.github.io/pantheon-opencode/)
12
13
  [![CI](https://img.shields.io/github/actions/workflow/status/ils15/pantheon-opencode/ci.yml?branch=main&label=CI)](https://github.com/ils15/pantheon-opencode/actions)
13
14
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.22650136.svg)](https://doi.org/10.5281/zenodo.22650136)
14
15
 
@@ -137,16 +138,19 @@ For multi-phase tasks spanning 10+ turns or multiple sessions:
137
138
  ```text
138
139
  /pantheon-deepwork "Implement OAuth2 PKCE authentication flow"
139
140
  ```
140
- - **Phase 0 (Plan):** Athena maps affected modules and returns a complete Markdown plan displayed directly in the main conversation.
141
- - **Phase 1 (Discovery):** Apollo performs structured exploration.
142
- - **Phase 2–N (Implementation):** Specialists implement features in parallel phases.
143
- - **Phase Gates:** Themis audits each phase (`PASS` or `FAIL`).
141
+ - **The Plan is the Artifact:** The canonical ground truth is stored in `.pantheon/deepwork/<slug>/plan.json` with an append-only event log (`journal.ndjson`) for resilient crash recovery.
142
+ - **Native OpenCode Gates (Strictly No HTML):** Approvals (Gate 1) and decision resolutions use OpenCode's native interactive `question` tool directly in the chat UI.
143
+ - **Dependency DAG:** Automatically projects task dependencies into live Mermaid diagrams (`flowchart LR`) inside `PLAN.md` and chat status.
144
+ - **Fail-First Acceptance:** Every task defines concrete acceptance criteria (`kind: test|command|file|manual`, `fails_now: true`) verified with cryptographic receipts.
145
+ - **Tool Automation (`pantheon_deepwork`):** Structured tool for `init`, `status`, `update_task`, `verify_acceptance`, and `resolve_decision`.
144
146
  - **Resumability:** Checkpoints persisted to `.pantheon/deepwork/<slug>/`. Resume anytime with `/pantheon-deepwork --resume <slug>`.
145
147
 
146
148
  ---
147
149
 
148
150
  ## The 14 Specialized Agents
149
151
 
152
+ For a complete breakdown of permissions, tools, MCP access, and boundary constraints per agent, see the [Agent Capability Matrix](docs/AGENT-CAPABILITY-MATRIX.md).
153
+
150
154
  Every root dispatch carries a concise handoff brief — objective, bounded scope, relevant inputs, constraints, expected return format, and verification. Work is routed qualitatively — uncertainty, domain expertise, dependencies, risk, and verification — not by fixed file or line thresholds. Return contracts are role-specific: implementation uses `## subtask_summary`, investigation returns structured findings, Athena returns the complete plan, and council responses use `## specialist_response`.
151
155
 
152
156
  | Agent | Domain Authority | Core Responsibilities |
@@ -170,7 +174,7 @@ Every root dispatch carries a concise handoff brief — objective, bounded scope
170
174
 
171
175
  ## Skills & MCP Tooling
172
176
 
173
- - **In-Process Skill Search (`pantheon_skill_search`):** Quickly discovers local skills and external ecosystem skills without requiring shell execution permissions.
177
+ - **In-Process Skill Search (`pantheon_skill_search`) & Proactive Installation:** Quickly discovers local and external ecosystem skills; when gaps are identified, Zeus proactively invokes the interactive `question` tool for 1-click project-scoped installation into `.agents/skills/` (via `npx skills add <skill> -a opencode -y`), delegated to execution specialists with zero manual shell typing required.
174
178
  - **25 Production Skills:** Includes `test-slicing`, `fast-path-execution`, `tdd-with-agents`, `instruction-forge`, and `incremental-implementation`.
175
179
  - **5 Local MCP Servers:**
176
180
  - `pantheon-memory`: Shared project memory with atomic SQLite locking.
@@ -198,14 +202,26 @@ Run `/pantheon-settings` (or `Pantheon: Settings` in the command palette) to ope
198
202
 
199
203
  ---
200
204
 
201
- ## Documentation
205
+ ## Documentation & Tutorials
206
+
207
+ > 📖 **Official Documentation Portal:** Explore full searchable guides, interactive Mermaid diagrams, and versioned releases at **[https://ils15.github.io/pantheon-opencode/](https://ils15.github.io/pantheon-opencode/)**.
202
208
 
203
- | Start Here | Architecture & Deep Dives | Reference & Operations |
209
+ | Guides & Tutorials | Architecture & Deep Dives | Reference & Operations |
204
210
  |---|---|---|
205
- | [Quick Start](docs/QUICKSTART.md) | [Architecture](docs/ARCHITECTURE.md) | [MCP Tools](docs/mcp-tools.md) |
206
- | [Installation Guide](docs/INSTALLATION.md) | [Delegation & Gates](docs/PERMISSIONS-QUALITY-DELEGATION.md) | [Native Decisions (Jev)](docs/reference/native-decisions.md) |
207
- | [Compatibility](docs/COMPATIBILITY.md) | [Memory System](docs/MEMORY.md) | [Model Routing](docs/reference/model-routing.md) |
208
- | [Upgrading](docs/UPGRADING.md) | [OpenCode 2.x Integration](docs/opencode.md) | [Changelog](CHANGELOG.md) |
211
+ | [First Project (End-to-End)](docs/guides/first-project.md) | [Architecture](docs/ARCHITECTURE.md) | [MCP Tools](docs/mcp-tools.md) |
212
+ | [Agent Capability Matrix](docs/AGENT-CAPABILITY-MATRIX.md) | [Delegation & Gates](docs/PERMISSIONS-QUALITY-DELEGATION.md) | [Native Decisions (Jev)](docs/reference/native-decisions.md) |
213
+ | [Deepwork Blueprint](docs/guides/deepwork.md) | [Memory System](docs/MEMORY.md) | [Model Routing](docs/reference/model-routing.md) |
214
+ | [Pantheon Vision](docs/guides/vision.md) | [OpenCode Integration](docs/opencode.md) | [Changelog](CHANGELOG.md) |
215
+ | [Cookbook](docs/guides/cookbook.md) | [Compatibility](docs/COMPATIBILITY.md) | [Wiki](wiki/Home.md) |
216
+
217
+ ---
218
+
219
+ ## Real-World Examples
220
+
221
+ Working runnable reference projects demonstrating Pantheon orchestration in practice:
222
+
223
+ * **[SaaS Performance Dashboard](examples/saas-dashboard/) (`examples/saas-dashboard`):** Fullstack web application with React 19, Fastify backend, streaming CSV export, automated tests, and a real Deepwork execution plan (`plan.json`, `journal.ndjson`, `PLAN.md`).
224
+ * **[Repo Health CLI](examples/cli-tool/) (`examples/cli-tool`):** Sub-second diagnostic CLI tool demonstrating the fast-path execution of `@talos` and `@hermes`.
209
225
 
210
226
  ---
211
227
 
package/README.pt-BR.md CHANGED
@@ -8,6 +8,7 @@ O Pantheon reúne planejamento, implementação, revisão e documentação numa
8
8
  [Repositório](https://github.com/ils15/pantheon-opencode) · [Licença MIT](LICENSE)
9
9
 
10
10
  [![Versão](https://img.shields.io/github/v/release/ils15/pantheon-opencode?label=version)](https://github.com/ils15/pantheon-opencode/releases/latest)
11
+ [![Documentação](https://img.shields.io/badge/documenta%C3%A7%C3%A3o-portal-indigo)](https://ils15.github.io/pantheon-opencode/)
11
12
  [![CI](https://img.shields.io/github/actions/workflow/status/ils15/pantheon-opencode/ci.yml?branch=main&label=CI)](https://github.com/ils15/pantheon-opencode/actions)
12
13
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.22650136.svg)](https://doi.org/10.5281/zenodo.22650136)
13
14
 
@@ -133,16 +134,19 @@ Para tarefas complexas com mais de 10 turnos ou distribuídas em várias sessõe
133
134
  ```text
134
135
  /pantheon-deepwork "Implementar autenticação OAuth2 PKCE"
135
136
  ```
136
- - **Fase 0 (Plano):** Athena mapeia os módulos e devolve o plano completo em Markdown exibido diretamente na conversa principal.
137
- - **Fase 1 (Descoberta):** Apollo realiza exploração estruturada.
138
- - **Fases 2–N (Implementação):** Especialistas implementam os módulos em fases paralelas.
139
- - **Gates de Revisão:** Themis audita cada fase (`PASS` ou `FAIL`).
137
+ - **O Plano é o Artefato:** O estado canônico é salvo em `.pantheon/deepwork/<slug>/plan.json` acompanhado do log append-only de eventos (`journal.ndjson`) para recuperação resiliente contra falhas.
138
+ - **Gates Nativos do OpenCode (Sem HTML):** Aprovações (Portão 1) e resoluções de decisão utilizam a ferramenta interativa nativa `question` do OpenCode diretamente no chat.
139
+ - **Grafo de Dependências (DAG):** Projeção automática das tarefas em diagrama Mermaid vivo (`flowchart LR`) dentro do `PLAN.md` e nos resumos de status do chat.
140
+ - **Critérios de Aceite Fail-First:** Cada tarefa define verificações concretas (`kind: test|command|file|manual`, `fails_now: true`) validadas com recibos criptográficos de execução.
141
+ - **Automação via Ferramenta (`pantheon_deepwork`):** Ferramenta estruturada para `init`, `status`, `update_task`, `verify_acceptance` e `resolve_decision`.
140
142
  - **Resumibilidade:** Progresso salvo em `.pantheon/deepwork/<slug>/`. Retome a qualquer momento com `/pantheon-deepwork --resume <slug>`.
141
143
 
142
144
  ---
143
145
 
144
146
  ## Os 14 Agentes Especializados
145
147
 
148
+ Para uma matriz detalhada de permissões, ferramentas, acesso a MCPs e restrições absolutas de cada agente, consulte a [Matriz de Capacidades dos Agentes](docs/AGENT-CAPABILITY-MATRIX.md).
149
+
146
150
  Toda delegação raiz carrega um brief conciso — objetivo, escopo delimitado, entradas relevantes, restrições, formato de retorno esperado e critérios de verificação. O trabalho é roteado de forma qualitativa — incerteza, especialidade de domínio, dependências, risco e verificação — nunca por limites arbitrários de linhas. Os contratos de retorno são específicos por papel: implementação usa `## subtask_summary`, investigações retornam achados estruturados, Athena entrega o plano completo e respostas ao conselho usam `## specialist_response`.
147
151
 
148
152
  | Agente | Autoridade de Domínio | Responsabilidades Principais |
@@ -166,7 +170,7 @@ Toda delegação raiz carrega um brief conciso — objetivo, escopo delimitado,
166
170
 
167
171
  ## Skills & Ferramental MCP
168
172
 
169
- - **Busca de Skills In-Process (`pantheon_skill_search`):** Encontra rapidamente skills locais e do ecossistema aberto sem depender de permissões de shell.
173
+ - **Busca de Skills In-Process (`pantheon_skill_search`) e Instalação Proativa:** Encontra rapidamente skills locais e do ecossistema aberto; ao detectar lacunas de capacidade, Zeus abre proativamente a ferramenta interativa `question` para instalação em 1 clique isolada no projeto em `.agents/skills/` (via `npx skills add <skill> -a opencode -y`), delegando a execução a especialistas sem exigir comandos manuais no terminal.
170
174
  - **25 Skills de Produção:** Inclui `test-slicing`, `fast-path-execution`, `tdd-with-agents`, `instruction-forge` e `incremental-implementation`.
171
175
  - **5 Servidores MCP Locais:**
172
176
  - `pantheon-memory`: Memória compartilhada com travas atômicas SQLite.
@@ -194,14 +198,26 @@ Execute `/pantheon-settings` (ou `Pantheon: Settings` na paleta de comandos) par
194
198
 
195
199
  ---
196
200
 
197
- ## Documentação
201
+ ## Documentação & Tutoriais
202
+
203
+ > 📖 **Portal Oficial de Documentação:** Explore guias completos com pesquisa instantânea, diagramas interativos em Mermaid e histórico de versões em **[https://ils15.github.io/pantheon-opencode/](https://ils15.github.io/pantheon-opencode/)**.
198
204
 
199
- | Comece por aqui | Arquitetura e Aprofundamento | Referência e Operações |
205
+ | Guias & Tutoriais | Arquitetura e Aprofundamento | Referência e Operações |
200
206
  |---|---|---|
201
- | [Início Rápido](docs/QUICKSTART.md) | [Arquitetura](docs/ARCHITECTURE.md) | [Ferramentas MCP](docs/mcp-tools.md) |
202
- | [Guia de Instalação](docs/INSTALLATION.md) | [Delegação & Gates](docs/PERMISSIONS-QUALITY-DELEGATION.md) | [Decisões Nativas (Jev)](docs/reference/native-decisions.md) |
203
- | [Compatibilidade](docs/COMPATIBILITY.md) | [Sistema de Memória](docs/MEMORY.md) | [Roteamento de Modelos](docs/reference/model-routing.md) |
204
- | [Atualização](docs/UPGRADING.md) | [Integração OpenCode 2.x](docs/opencode.md) | [Changelog](CHANGELOG.md) |
207
+ | [Primeiro Projeto (End-to-End)](docs/guides/first-project.md) | [Arquitetura](docs/ARCHITECTURE.md) | [Ferramentas MCP](docs/mcp-tools.md) |
208
+ | [Matriz de Agentes](docs/AGENT-CAPABILITY-MATRIX.md) | [Delegação & Gates](docs/PERMISSIONS-QUALITY-DELEGATION.md) | [Decisões Nativas (Jev)](docs/reference/native-decisions.md) |
209
+ | [Guia do Deepwork](docs/guides/deepwork.md) | [Sistema de Memória](docs/MEMORY.md) | [Roteamento de Modelos](docs/reference/model-routing.md) |
210
+ | [Pantheon Vision](docs/guides/vision.md) | [Integração OpenCode](docs/opencode.md) | [Changelog](CHANGELOG.md) |
211
+ | [Cookbook de Receitas](docs/guides/cookbook.md) | [Compatibilidade](docs/COMPATIBILITY.md) | [Wiki](wiki/Home.md) |
212
+
213
+ ---
214
+
215
+ ## Exemplos Práticos do Mundo Real
216
+
217
+ Projetos funcionais demonstrando a orquestração do Pantheon na prática:
218
+
219
+ * **[SaaS Performance Dashboard](examples/saas-dashboard/) (`examples/saas-dashboard`):** Aplicação fullstack completa com React 19, backend Fastify, streaming de CSV, testes automatizados e plano Deepwork real com evidências (`plan.json`, `journal.ndjson`, `PLAN.md`).
220
+ * **[Repo Health CLI](examples/cli-tool/) (`examples/cli-tool`):** Ferramenta de linha de comando para diagnóstico de repositórios em menos de 1 segundo, demonstrando o fluxo fast-path do `@talos` e `@hermes`.
205
221
 
206
222
  ---
207
223
 
@@ -45,15 +45,24 @@ Phase FINAL: VERIFICATION
45
45
  └─ All tests pass, coverage >80%
46
46
  ```
47
47
 
48
- ## Checkpoints
48
+ ## Checkpoints & Canonical Storage
49
49
 
50
50
  ```
51
51
  Usage: --resume <slug> | --status <slug> | --list
52
52
 
53
53
  .pantheon/deepwork/<slug>/
54
- ├── PLAN.md DISCOVERY.md IMPL-phase-*-*.md phase-*-review.md REVIEW.md STATUS.md
54
+ ├── plan.json # Canonical ground truth (JSON DAG, tasks, acceptance criteria, decisions)
55
+ ├── journal.ndjson # Append-only crash recovery event log (task updates, verified proofs)
56
+ ├── PLAN.md # Markdown projection with Mermaid DAG (zero HTML, renders in TUI & Desktop)
57
+ ├── DISCOVERY.md IMPL-phase-*-*.md phase-*-review.md REVIEW.md STATUS.md
55
58
  ```
56
59
 
60
+ ### Native OpenCode Gates & Acceptance
61
+
62
+ - **Approval Gate (Gate 1):** Uses OpenCode native `question` tool to prompt user approval directly in chat.
63
+ - **Fail-First Acceptance:** Every task defines concrete acceptance criteria (`kind: test|command|file|manual`, `fails_now: true`). Verification is recorded with execution proof receipts.
64
+ - **Deepwork Tool:** Managed natively via `pantheon_deepwork` tool (`init`, `status`, `update_task`, `verify_acceptance`, `resolve_decision`, `list`).
65
+
57
66
  ## Full-Auto Mode (`--full-auto`)
58
67
 
59
68
  > [!WARNING] Automates only eligible review gates. Gate 1 and commit/deploy gates still require approval.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "2.0.4",
3
+ "version": "2.1.1",
4
4
  "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -49,6 +49,7 @@
49
49
  "hooks:install": "pre-commit install",
50
50
  "hooks:update": "pre-commit autoupdate",
51
51
  "test:security": "npm run secret-scan",
52
+ "test:quick": "node --test tests/skill-decision-proactive.test.mjs tests/plan-visibility-contract.test.mjs tests/proportional-execution-contract.test.mjs tests/memory-delegation-prompt.test.mjs tests/tui-settings-draft.test.mjs tests/tui-settings-i18n.test.mjs",
52
53
  "test:node": "node scripts/run-node-tests.mjs --label 'test:node' --exclude 'tests/install-opencode.test.mjs' --exclude 'tests/install-e2e.test.mjs' 'tests/*.mjs' 'tests/pantheon/*.mjs' 'tests/eval/*.mjs'",
53
54
  "test:install": "PANTHEON_RUN_INSTALL_TESTS=1 node scripts/run-node-tests.mjs --label 'test:install' 'tests/install-opencode.test.mjs' 'tests/install-e2e.test.mjs'",
54
55
  "coverage": "echo 'Node coverage (report-only, NO threshold is enforced).' && echo 'Covers: the .mjs/.js modules under scripts/, src/ and bin/ that test:node exercises.' && echo 'Does NOT cover: test:ts (hand-rolled tsx loop, no node --test runner) and test:ci (pytest).' && echo ' TypeScript under src/ (41 files) is therefore entirely unmeasured here.' && echo '' && node scripts/run-node-tests.mjs --label 'coverage' --exclude 'tests/install-opencode.test.mjs' --exclude 'tests/install-e2e.test.mjs' -- --experimental-test-coverage --test-coverage-include='scripts/**/*.mjs' --test-coverage-include='src/**/*.mjs' --test-coverage-include='src/**/*.js' --test-coverage-include='bin/**/*.mjs' 'tests/*.mjs' 'tests/pantheon/*.mjs'",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "2.0.4",
4
+ "version": "2.1.1",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 25 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
@@ -174,10 +174,12 @@ DO: Choose the smallest safe track (Fast-Track for <= 2 files; Deep-Track only f
174
174
  DO: Run focused test slicing (target exact test file) rather than full test suites
175
175
  DO: Use Athena planning and Apollo discovery only when requested or warranted
176
176
  DO: Use in-process `pantheon_skill_search` and `pantheon_jev_decide` for discovery and advisory routing
177
+ DO: For missing capabilities, proactively invoke the `question` tool for 1-click project installation into `.agents/skills/` (via `npx skills add {{SKILL}} -a opencode -y`)
177
178
  DO: Run parallel work only for independent slices
178
179
  DO: Apply Themis review according to risk policy, bypassing for bounded micro-edits
179
180
 
180
181
  DONT: Don't read entire codebase yourself
182
+ DONT: Don't ask the user to run terminal commands for skill installation; never recommend or install global skills (~/.config/opencode/skills/)
181
183
  DONT: Don't force planning, discovery, review, or artifacts onto every task
182
184
  DONT: Don't run full test suites during incremental development
183
185
  DONT: Don't auto-commit or bypass a required safety gate
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
4
4
 
5
5
  [project]
6
6
  name = "pantheon"
7
- version = "2.0.4"
7
+ version = "2.1.1"
8
8
  description = "Multi-agent orchestration framework"
9
9
  requires-python = ">=3.11"
10
10
  # Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
package/scripts/cost.mjs CHANGED
@@ -179,11 +179,10 @@ function readSource(db, source, since) {
179
179
  // too rather than inventing a column the reader never had.
180
180
  const metadata = info.metadata
181
181
  const phase =
182
- source === 'session_message'
183
- ? 'unknown'
184
- : (typeof info.phase === 'string' && info.phase) ||
185
- (typeof metadata?.phase === 'string' && metadata.phase) ||
186
- 'unknown'
182
+ (typeof info.phase === 'string' && info.phase) ||
183
+ (typeof metadata?.phase === 'string' && metadata.phase) ||
184
+ (typeof info.subtask?.phase === 'string' && info.subtask.phase) ||
185
+ 'unknown'
187
186
  const tokensInput = toToken(info.tokens?.input)
188
187
  const tokensOutput = toToken(info.tokens?.output)
189
188
  const key = rowKey(agent, phase)
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Usage:
11
11
  * node scripts/docs-media.mjs # record every *.tape
12
- * node scripts/docs-media.mjs v2-sidebar # record one tape (name or file)
12
+ * node scripts/docs-media.mjs sidebar # record one tape (name or file)
13
13
  * node scripts/docs-media.mjs --check # verify prerequisites only
14
14
  */
15
15
 
package/skills-lock.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "src/skills/memory-bank/references/storage-model.md": "728a9e5f2055ce0f74c759405072a6fe57f65587bdb7b9e5e7fa90b60528b085",
24
24
  "src/skills/memory-bank/references/structure-and-frequency.md": "09caedf905870c688401a2e58b2776a9c6187fe724c576019c58c3b80fe1b98f",
25
25
  "src/skills/memory-bank/SKILL.md": "047b3049c27e908b1d79afb14f79336e32f775385ba23956771166d445944f2f",
26
- "src/skills/prompt-refinery/SKILL.md": "4ffbcddefb4f8937537358386f364ecca1303f928a1b07ff0bbd7e65d6fe7982",
26
+ "src/skills/prompt-refinery/SKILL.md": "61140e0677d4d94432e79aad37dfd2d846b65fa80431d881d3759d05334157b6",
27
27
  "src/skills/reflect/SKILL.md": "297c374f1fbc8e15d3848f51e811e0614d4a008c7d0e1daf88bbb240d605b8a8",
28
28
  "src/skills/security-hardening/SKILL.md": "6d637e122421f7bc3b751f04854ad343a5a5d35249458bc8939233138fd3f20d",
29
29
  "src/skills/session-goal/references/goal-format.md": "071f6f8f12cfbc26d4703cd5f34f839f91e586a3b969bf5f81a74b961c254a83",
@@ -26,6 +26,7 @@ permission:
26
26
  grep: allow
27
27
  glob: allow
28
28
  webfetch: allow
29
+ pantheon_deepwork: allow
29
30
  question: allow
30
31
  task:
31
32
  "*": deny
@@ -165,7 +166,9 @@ flowchart LR
165
166
  ```
166
167
 
167
168
  ### Interactive Question Gate
168
- When directly invoked by the user, if you need trade-off confirmation or final approval, always call the native `question` tool with structured choices (e.g., `["Aprovar e executar", "Ajustar plano"]`), rather than relying solely on unstructured chat text.
169
+ When directly invoked by the user:
170
+ - If the plan contains any Open Questions (`decisions_needed`), **NEVER leave them as plain text bullets in chat**. You MUST call the native `question` tool, decomposing every open question into an interactive multiple-choice item with concrete options (marking recommended choice with `(Recomendado)`).
171
+ - Alongside open questions, always include the approval question with structured choices (e.g., `["(Recomendado) Aprovar e executar", "Ajustar plano"]`), rather than relying on unstructured chat text.
169
172
  Keep unknown paths and unverified assumptions explicit rather than fabricating
170
173
  detail.
171
174
 
@@ -195,14 +198,13 @@ approval.
195
198
 
196
199
  ## Approval Gate
197
200
 
198
- After the complete plan is visible in the current conversation, use
199
- `agent/askQuestions` only for a direct invocation:
200
- ```
201
- Questions:
202
- - "Plan ready. Open questions: [list]. Approve? (yes/changes needed)"
203
- ```
201
+ After the complete plan is visible in the current conversation, use the native `question` tool for direct user invocations:
202
+ - Decompose all Open Questions into interactive questions with concrete choices and marked `(Recomendado)` defaults.
203
+ - Gate Question:
204
+ - Question: "Aprovar plano e iniciar execução?"
205
+ - Options: ["(Recomendado) Aprovar e executar", "Ajustar plano"]
204
206
 
205
- Only after explicit "yes" → delegate to @zeus with plan context.
207
+ Only after explicit user approval → delegate to @zeus with plan context.
206
208
 
207
209
  ## When to Use Apollo
208
210
 
@@ -10,6 +10,7 @@ permission:
10
10
  shell: allow
11
11
  edit: deny
12
12
  hashline_edit: deny
13
+ pantheon_deepwork: allow
13
14
  task:
14
15
  "*": deny
15
16
  temperature: 0.1
@@ -11,6 +11,7 @@ permission:
11
11
  vision_describe: allow
12
12
  pantheon_jev_decide: allow
13
13
  pantheon_skill_search: allow
14
+ pantheon_deepwork: allow
14
15
  question: allow
15
16
  task:
16
17
  "*": allow
@@ -45,6 +46,20 @@ skills:
45
46
  - **Greetings and casual queries** ("oi", "olá", "hello", "hi", "good morning", "how are you", greetings, general questions about Pantheon or capabilities, simple clarifications, or direct calculations that do not require reading or editing project code): **Respond directly and immediately in 1 concise turn.**
46
47
  - **DO NOT dispatch subagents**, do not call Athena/Apollo, do not call Jev or council, and do not invoke tools for greetings and direct queries.
47
48
 
49
+ ## Prompt Refinery & Request Disambiguation (`prompt-refinery`)
50
+
51
+ - **Prefix `>>` (Tier 2 Visual Contract):**
52
+ - When the user's prompt begins with `>>`: DO NOT execute immediately. Trigger Tier 2 Visual Contract.
53
+ - Present the structured engineering brief:
54
+ - Slices table (`Slice | Focus Area | Target Files | Verification Gate`)
55
+ - In Scope, Out of Scope & Negative Constraints
56
+ - Acceptance Criteria
57
+ - Open Questions with Recommended Defaults
58
+ - **MANDATORY `question` tool:** When Open Questions, decisions needed, or scope trade-offs are present, ALWAYS invoke the native `question` tool with structured choices (marking the recommended choice with `(Recomendado)`) alongside the execution approval question (e.g. `["(Recomendado) Aprovar escopo e iniciar execução", "Ajustar escopo/premissas"]`). NEVER leave open questions as inert text bullets in chat and proceed blindly.
59
+ - **Ambiguous or Multi-Concern Prompts (Tier 1 Silent Lean):**
60
+ - When a request mixes refactor/fix/redesign without clear acceptance criteria, extract internal lean brief (Target, Slices, Constraints, Verification, Defaults).
61
+ - If ambiguity blocks safe execution or presents critical trade-offs, **always invoke the native `question` tool** with concrete options (recommended option first) rather than making blind assumptions or writing plain-text questions.
62
+
48
63
  ## Fast-Path Direct Implementation (Default Coding Workflow)
49
64
 
50
65
  - **Direct coding requests (features, bug fixes, refactoring, tests, hotfixes)**:
@@ -71,17 +86,29 @@ These rules are economic, measured against the 2026-11-05 usage audit. They appl
71
86
  - **pantheon-memory** (`memory_store`): durable, reusable facts ONLY (architectural decisions, conventions, user preferences). Session narration never stores — it belongs in conversation history. Check search results before storing to avoid duplicates. Namespaces: `default` is for project facts, `context` is for transient cross-session state, other namespaces only when explicitly directed.
72
87
  - **pantheon-persistence** (`context_save`): milestones only (phases, complex tasks, handoffs). Maximum 3 saves per session. Always name the checkpoint. never re-save the same key unless state genuinely changed.
73
88
  - **pantheon-vision** (`vision_describe`): One pass per image; forward results in prompt to specialists.
89
+ - **pantheon_deepwork**: Structured Deepwork plans (.pantheon/deepwork/<slug>/plan.json, journal.ndjson, PLAN.md). Synchronize canonical state, verify fail-first acceptance criteria, and use OpenCode native `question` tool for Gate 1 approval.
74
90
 
75
91
  ## Local advisory routing before native delegation
76
92
 
77
93
  - For a bounded deliverable, delegate once to the final specialist; the specialist can gather the necessary facts. Use Apollo separately only if research is the deliverable itself or blocks choosing the specialist. Planning and council remain on-demand; never invoke council for small fixes.
78
94
  - Bounded, reversible, low-uncertainty, and non-sensitive tasks: route directly to the specialist; do not force planning or plan approval.
79
95
  - Ambiguous routing: prefer one typed `pantheon_jev_decide` with `mode: "delegation"` or `pantheon_local_decision`. Build `candidateAgents` from available subagent targets.
80
- - Missing capability: run `pantheon_skill_search` or `node scripts/skill-search.mjs` (read-only, never installs). Propose `npx skills add <skill>` for user review.
96
+ - Missing capability & Proactive Project Skill Decision Flow:
97
+ - Discovery: When a task requires capabilities not in the local pool, run `pantheon_skill_search` (in-process, read-only) or `node scripts/skill-search.mjs` across the trust cascade.
98
+ - Arbitration: If multiple or ambiguous external candidates are returned, arbitrate relevance with `pantheon_jev_decide` (`mode: "choice"` or `"rank"`).
99
+ - Proactive Interactive Question Gate (MANDATORY `question` tool):
100
+ - NEVER ask the user to type terminal commands (`bash: deny`, `shell: deny`).
101
+ - SEMPRE no projeto atual: External skills MUST ALWAYS be installed strictly in the current project root under `.agents/skills/` (using `-a opencode -y`). NEVER propose or allow global installation (`~/.config/opencode/skills/`).
102
+ - ALWAYS proactively invoke the native `question` tool immediately after discovery/ranking to offer 1-click installation options:
103
+ * Recommended choice: `"(Recomendado) Instalar skills prioritárias no projeto (.agents/skills/)"` (curated candidates).
104
+ * Granular choice: `"Selecionar skills específicas para instalar"` (or checkbox list if multiselect).
105
+ * Skip choice: `"Prosseguir sem instalar skills adicionais"`.
106
+ - Automated Specialist Execution & Batching: When the user approves in the question prompt, do NOT require them to run commands. Immediately dispatch an execution specialist with bash permitted (@hermes or @talos) to execute `npx skills add <skill1> [skill2...] -a opencode -y` in the project root (batching multiple skills in a single run).
107
+ - Verification: Specialist verifies directory creation in `<project>/.agents/skills/<skill-name>/` and reports completion; subsequent `pantheon_skill_search` confirms `installed: true`.
81
108
 
82
109
  ## Visual Context for Implementation
83
110
 
84
- - When a request includes an image or screenshot, use image content already available in the conversation. Call `vision_describe` only if it appears in the active root tool list; otherwise state the limitation instead of guessing.
111
+ - When a request includes an image or screenshot, use image content already available in the conversation. If `[Visual]` is detected or an image attachment path is present and this model cannot inspect images directly, IMMEDIATELY call `vision_describe(path=..., question=...)` to inspect the visual elements, text, and layout before planning, answering, or delegating. Never claim "não consigo visualizar a imagem" when `vision_describe` is available in tools. Call it first.
85
112
  - For UI work, delegate to @aphrodite and include the image reference (URL/path when available) plus a concise description of the relevant layout, elements, and requested outcome in the task prompt.
86
113
  - Tell the implementer to compare the reference with the current UI and preserve unrelated existing work or changes. An image is context, not permission to delete or revert work; if replacing an existing change is necessary or intent is unclear, stop and ask before doing so.
87
114
 
@@ -106,5 +133,7 @@ Whenever the user explicitly asks for a plan, or starts `/pantheon-deepwork`:
106
133
  - **Execution Flow:** Mermaid diagram (3-4 nodes).
107
134
  - **Slice Table:** Compact table (`Phase | Specialist | Key Deliverable | Verification Slice`).
108
135
  - **Disk Blueprint:** Clear reference that the exhaustive technical spec is preserved in `.pantheon/deepwork/<slug>/PLAN.md`.
109
- 5. **Interactive Question Gate:** Always invoke the native `question` tool to request user approval with explicit options (e.g., `["Aprovar e iniciar execução", "Ajustar plano"]` / `["Approve and begin execution", "Adjust plan"]`), falling back to plain text only if the tool is not exposed.
136
+ 5. **Interactive Question Gate (MANDATORY `question` tool):**
137
+ - **Open Questions & Decisions Needed:** If the plan, task brief, or refinement contains any Open Questions or `decisions_needed`, **NEVER leave them as inert text bullets** in chat or assume "proceed if no objections". You MUST decompose each open question into an interactive item in the native `question` tool with concrete options, marking the recommended choice with `(Recomendado)`.
138
+ - **Plan Approval Gate:** Alongside any open questions, include the approval question with explicit options (e.g., `["(Recomendado) Aprovar e iniciar execução", "Ajustar plano"]` / `["(Recommended) Approve and begin execution", "Adjust plan"]`), falling back to plain text only if the tool is not exposed.
110
139
  6. If the user requests changes, send feedback to Athena, update `.pantheon/deepwork/<slug>/PLAN.md`, and repeat the interactive gate.
@@ -22,7 +22,7 @@ For investigation agents (Apollo, Athena), return structured findings: key findi
22
22
 
23
23
  ### Athena Plan Handoff
24
24
 
25
- When Zeus delegates Athena through the root `subagent` dispatch, its final task result MUST contain the complete Markdown plan (not a summary, artifact path, or approval question): goal, scope and assumptions, phases, affected files or areas, dependencies, verification, risks, open questions, acceptance criteria — unknowns marked, never guessed. This supersedes the structured-findings format. Athena must not call `agent/askQuestions`, pause for user input, or ask for approval in the child session. Zeus publishes the full plan as a normal message before any approval UI, never bundling plan and approval question; if the runtime cannot guarantee that order, Zeus asks for approval in plain text afterwards and waits for the next user message. Direct Athena invocations show the complete plan before requesting approval.
25
+ When Zeus delegates Athena through the root `subagent` dispatch, its final task result MUST contain the complete Markdown plan (not a summary, artifact path, or approval question): goal, scope and assumptions, phases, affected files or areas, dependencies, verification, risks, open questions, acceptance criteria — unknowns marked, never guessed. This supersedes the structured-findings format. Athena must not call `agent/askQuestions`, pause for user input, or ask for approval in the child session. Zeus publishes the full plan before approval UI, never bundling them; if order is not guaranteed, Zeus asks in plain text afterwards. For Open Questions or decisions needed, Zeus prompts via the native `question` tool with structured options and marked recommended defaults, never leaving inert text bullets. Direct Athena invocations show the complete plan before requesting approval.
26
26
 
27
27
  ## Council Specialist Response Format
28
28
 
@@ -389,6 +389,37 @@ def _key_from_credential_db(provider: str) -> str | None:
389
389
  return None
390
390
 
391
391
 
392
+ def _opencode_config_dir() -> Path:
393
+ """Locate the OpenCode configuration directory."""
394
+ xdg = os.getenv("XDG_CONFIG_HOME")
395
+ if xdg and xdg.strip():
396
+ return Path(xdg.strip()) / "opencode"
397
+ return Path.home() / ".config" / "opencode"
398
+
399
+
400
+ def _configured_vision_model() -> str:
401
+ """Resolve configured vision model from env or opencode-vision.json."""
402
+ env_model = os.getenv("PANTHEON_VISION_MODEL")
403
+ if env_model and env_model.strip():
404
+ return env_model.strip()
405
+ candidates = [
406
+ Path.cwd() / ".opencode" / "opencode-vision.json",
407
+ _opencode_config_dir() / "opencode-vision.json",
408
+ Path.home() / ".opencode" / "opencode-vision.json",
409
+ ]
410
+ for path in candidates:
411
+ if path.is_file():
412
+ try:
413
+ data = json.loads(path.read_text(encoding="utf-8"))
414
+ if isinstance(data, dict):
415
+ val = data.get("visionModel")
416
+ if isinstance(val, str) and val.strip() and val.strip() != "auto":
417
+ return val.strip()
418
+ except (OSError, json.JSONDecodeError):
419
+ pass
420
+ return DEFAULT_MODEL
421
+
422
+
392
423
  def _resolve_auth() -> tuple[str | None, str]:
393
424
  """Resolve auth in env-first, then OpenCode credential-store order.
394
425
 
@@ -404,7 +435,7 @@ def _resolve_auth() -> tuple[str | None, str]:
404
435
  graceful callers (``vision_describe`` / ``vision_ocr``) degrade to local
405
436
  extraction, and only the fatal gateway path logs the paths/env vars tried.
406
437
  """
407
- model = os.getenv("PANTHEON_VISION_MODEL") or DEFAULT_MODEL
438
+ model = _configured_vision_model()
408
439
  env_key = os.getenv("PANTHEON_OPENCODE_API_KEY") or os.getenv("OPENCODE_API_KEY")
409
440
  if env_key:
410
441
  return env_key, _endpoint_for_model(model)
@@ -437,7 +468,7 @@ def _resolve_auth() -> tuple[str | None, str]:
437
468
 
438
469
  def _model() -> str:
439
470
  """Return the configured model without exposing configuration secrets."""
440
- return os.getenv("PANTHEON_VISION_MODEL") or DEFAULT_MODEL
471
+ return _configured_vision_model()
441
472
 
442
473
 
443
474
  def _metadata(image: ImageInput) -> dict[str, Any]:
@@ -296,7 +296,10 @@ const COST_AGGREGATE_SQL: Record<CostSource, (sessionId: boolean) => string> = {
296
296
  session_message: (sessionId) => `
297
297
  WITH valid AS (
298
298
  SELECT json_extract(data, '$.agent') AS agent,
299
- 'unknown' AS phase,
299
+ COALESCE(NULLIF(json_extract(data, '$.phase'), ''),
300
+ NULLIF(json_extract(data, '$.metadata.phase'), ''),
301
+ NULLIF(json_extract(data, '$.subtask.phase'), ''),
302
+ 'unknown') AS phase,
300
303
  COALESCE(json_extract(data, '$.model.providerID'),
301
304
  json_extract(data, '$.providerID')) AS provider,
302
305
  COALESCE(json_extract(data, '$.model.id'),