pantheon-opencode 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.global.md 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-12T20:41:50-03:00 sha=c84abe9 -->
5
5
 
6
6
  # Pantheon Agent System — OpenCode
7
7
 
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-12T20:41:50-03:00 sha=c84abe9 -->
5
5
 
6
6
  # Pantheon — Repository Setup
7
7
 
package/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ 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.0] - 2026-11-12
17
+
18
+ ### 🆕 What's New
19
+
20
+ - **Deepwork Canonical Plan**: Structured JSON ground truth (`plan.json`) and append-only event log with Mermaid DAG and zero HTML.
21
+ - **Vision Modernization**: Configurable Vision Model row in TUI Settings synced to `opencode-vision.json` and explicit `vision_describe`.
22
+ - **Project Skill Decision**: Proactive interactive question gate for external skills, strictly isolated into `.agents/skills/`.
23
+ - **TUI Settings Polish**: Full pt-BR localization across tabs, formatted status badges, and resolved title collision in Changelog tab.
24
+
25
+ ### Added
26
+
27
+ - **deepwork** — canonical JSON-driven plan architecture, `pantheon_deepwork` tool, fail-first acceptance criteria, native `question` gates, and Mermaid DAG projections.
28
+ - **vision** — configurable vision model in TUI Settings (`Preset` tab), `.opencode/opencode-vision.json` support in Python MCP server, and explicit `vision_describe` guidance.
29
+ - **skills** — proactive interactive question gate for 1-click project-scoped installation (`.agents/skills/`) with execution delegated to `@hermes`/`@talos`.
30
+ - **tui** — Portuguese localization across tabs, rich system metadata in About tab, and formatted status badges (`< ativado >`, `< desativado >`).
31
+
32
+ ### Changed
33
+
34
+ - **agents** — updated Zeus rules in `src/agents/zeus.md` and prompts to forbid manual terminal commands and enforce project-isolated `.agents/skills/`.
35
+
36
+ ### Fixed
37
+
38
+ - **vision** — eliminate prompt context clutter and raw HTML comment dumps (`<!-- pantheon-v2-visual-context -->`), ensuring models invoke `vision_describe`.
39
+ - **tui** — resolved title collision visual bug in Changelog tab by splitting on delimiters and omitting empty middle box for highlight rows.
40
+
8
41
  ## [v2.0.4] - 2026-11-12
9
42
 
10
43
  ### 🆕 What's New
package/README.md CHANGED
@@ -137,16 +137,19 @@ For multi-phase tasks spanning 10+ turns or multiple sessions:
137
137
  ```text
138
138
  /pantheon-deepwork "Implement OAuth2 PKCE authentication flow"
139
139
  ```
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`).
140
+ - **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.
141
+ - **Native OpenCode Gates (Strictly No HTML):** Approvals (Gate 1) and decision resolutions use OpenCode's native interactive `question` tool directly in the chat UI.
142
+ - **Dependency DAG:** Automatically projects task dependencies into live Mermaid diagrams (`flowchart LR`) inside `PLAN.md` and chat status.
143
+ - **Fail-First Acceptance:** Every task defines concrete acceptance criteria (`kind: test|command|file|manual`, `fails_now: true`) verified with cryptographic receipts.
144
+ - **Tool Automation (`pantheon_deepwork`):** Structured tool for `init`, `status`, `update_task`, `verify_acceptance`, and `resolve_decision`.
144
145
  - **Resumability:** Checkpoints persisted to `.pantheon/deepwork/<slug>/`. Resume anytime with `/pantheon-deepwork --resume <slug>`.
145
146
 
146
147
  ---
147
148
 
148
149
  ## The 14 Specialized Agents
149
150
 
151
+ For a complete breakdown of permissions, tools, MCP access, and boundary constraints per agent, see the [Agent Capability Matrix](docs/AGENT-CAPABILITY-MATRIX.md).
152
+
150
153
  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
154
 
152
155
  | Agent | Domain Authority | Core Responsibilities |
@@ -170,7 +173,7 @@ Every root dispatch carries a concise handoff brief — objective, bounded scope
170
173
 
171
174
  ## Skills & MCP Tooling
172
175
 
173
- - **In-Process Skill Search (`pantheon_skill_search`):** Quickly discovers local skills and external ecosystem skills without requiring shell execution permissions.
176
+ - **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
177
  - **25 Production Skills:** Includes `test-slicing`, `fast-path-execution`, `tdd-with-agents`, `instruction-forge`, and `incremental-implementation`.
175
178
  - **5 Local MCP Servers:**
176
179
  - `pantheon-memory`: Shared project memory with atomic SQLite locking.
package/README.pt-BR.md CHANGED
@@ -133,16 +133,19 @@ Para tarefas complexas com mais de 10 turnos ou distribuídas em várias sessõe
133
133
  ```text
134
134
  /pantheon-deepwork "Implementar autenticação OAuth2 PKCE"
135
135
  ```
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`).
136
+ - **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.
137
+ - **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.
138
+ - **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.
139
+ - **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.
140
+ - **Automação via Ferramenta (`pantheon_deepwork`):** Ferramenta estruturada para `init`, `status`, `update_task`, `verify_acceptance` e `resolve_decision`.
140
141
  - **Resumibilidade:** Progresso salvo em `.pantheon/deepwork/<slug>/`. Retome a qualquer momento com `/pantheon-deepwork --resume <slug>`.
141
142
 
142
143
  ---
143
144
 
144
145
  ## Os 14 Agentes Especializados
145
146
 
147
+ 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).
148
+
146
149
  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
150
 
148
151
  | Agente | Autoridade de Domínio | Responsabilidades Principais |
@@ -166,7 +169,7 @@ Toda delegação raiz carrega um brief conciso — objetivo, escopo delimitado,
166
169
 
167
170
  ## Skills & Ferramental MCP
168
171
 
169
- - **Busca de Skills In-Process (`pantheon_skill_search`):** Encontra rapidamente skills locais e do ecossistema aberto sem depender de permissões de shell.
172
+ - **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
173
  - **25 Skills de Produção:** Inclui `test-slicing`, `fast-path-execution`, `tdd-with-agents`, `instruction-forge` e `incremental-implementation`.
171
174
  - **5 Servidores MCP Locais:**
172
175
  - `pantheon-memory`: Memória compartilhada com travas atômicas SQLite.
@@ -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.0",
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.0",
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.0"
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)
@@ -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
@@ -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:** Always invoke the native `question` tool with structured choices (e.g. `["Aprovar escopo e iniciar execução", "Ajustar escopo/premissas"]`) to obtain explicit user confirmation before dispatching implementers.
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 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
 
@@ -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'),