pantheon-opencode 1.6.2-beta.8 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +121 -3
  2. package/README.md +34 -60
  3. package/README.pt-BR.md +10 -12
  4. package/bin/pantheon-init.mjs +30 -32
  5. package/package.json +3 -3
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/decision-router.mjs +41 -56
  9. package/scripts/install/decision-router-config.mjs +67 -1
  10. package/scripts/install/npx-cache-sweep.mjs +103 -0
  11. package/scripts/install/opencode.mjs +7 -7
  12. package/scripts/install/plugin.mjs +4 -3
  13. package/scripts/install/strings.mjs +4 -0
  14. package/scripts/release-gates.mjs +6 -82
  15. package/scripts/sync-tui.mjs +3 -3
  16. package/src/agents/aphrodite.md +1 -1
  17. package/src/agents/apollo.md +1 -0
  18. package/src/agents/athena.md +1 -0
  19. package/src/agents/demeter.md +1 -1
  20. package/src/agents/gaia.md +1 -0
  21. package/src/agents/hephaestus.md +1 -1
  22. package/src/agents/hermes.md +1 -1
  23. package/src/agents/iris.md +1 -1
  24. package/src/agents/mnemosyne.md +1 -0
  25. package/src/agents/nyx.md +1 -1
  26. package/src/agents/prometheus.md +1 -1
  27. package/src/agents/talos.md +1 -1
  28. package/src/agents/themis.md +1 -1
  29. package/src/agents/zeus.md +5 -2
  30. package/src/pantheon/jev-decision-tool.ts +366 -114
  31. package/src/pantheon/jev-decisions.ts +11 -13
  32. package/src/pantheon/jev-escalation.ts +639 -0
  33. package/src/pantheon/jev-quality-score.ts +432 -0
  34. package/src/pantheon/jev-risk-gate.ts +479 -0
  35. package/src/pantheon/local-decision-prompt.ts +12 -18
  36. package/src/pantheon/v2-decision-telemetry.ts +14 -4
  37. package/src/pantheon/v2-native-decisions.ts +1 -1
  38. package/src/plugin-v2.ts +201 -24
  39. package/src/plugins/tui/dist/server-v2.d.ts +19 -11
  40. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  41. package/src/plugins/tui/dist/server-v2.js +19 -789
  42. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  43. package/src/plugins/tui/dist/tui-v2.d.ts +12 -331
  44. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  45. package/src/plugins/tui/dist/tui-v2.js +257 -5370
  46. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  47. package/src/plugins/tui/dist/tui.js +1 -1
  48. package/src/plugins/tui/package-lock.json +2 -2
  49. package/src/plugins/tui/package.json +1 -1
  50. package/src/plugins/tui/src/index-v2.tsx +213 -86
  51. package/src/plugins/tui/src/server-v2.ts +18 -982
  52. package/src/plugins/tui/tsconfig.typecheck.json +1 -6
  53. package/src/plugins/tui/tsdown.config.ts +1 -11
  54. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js +0 -749
  55. package/src/plugins/tui/dist/cost-data-CCZUs1aJ.js.map +0 -1
  56. package/src/plugins/tui/dist/quota-adapters.d.ts +0 -89
  57. package/src/plugins/tui/dist/quota-adapters.d.ts.map +0 -1
  58. package/src/plugins/tui/dist/quota-adapters.js +0 -1142
  59. package/src/plugins/tui/dist/quota-adapters.js.map +0 -1
  60. package/src/plugins/tui/dist/quota-cli.d.ts +0 -17
  61. package/src/plugins/tui/dist/quota-cli.d.ts.map +0 -1
  62. package/src/plugins/tui/dist/quota-cli.js +0 -184
  63. package/src/plugins/tui/dist/quota-cli.js.map +0 -1
  64. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js +0 -684
  65. package/src/plugins/tui/dist/quota-rpc-DMmXBhBe.js.map +0 -1
  66. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js +0 -118
  67. package/src/plugins/tui/dist/usage-history-contract-nt1rnBPE.js.map +0 -1
  68. package/src/plugins/tui/dist/usage-history-worker.js +0 -25
  69. package/src/plugins/tui/dist/usage-history-worker.js.map +0 -1
  70. package/src/plugins/tui/src/go-key-diagnostic-ui.ts +0 -100
  71. package/src/plugins/tui/src/go-key-diagnostic.ts +0 -125
  72. package/src/plugins/tui/src/quota-adapters.ts +0 -1598
  73. package/src/plugins/tui/src/quota-cli.ts +0 -237
  74. package/src/plugins/tui/src/quota-rpc.ts +0 -373
  75. package/src/plugins/tui/src/quota-v2-model.ts +0 -1032
  76. package/src/plugins/tui/src/quota-v2.tsx +0 -1238
  77. package/src/plugins/tui/src/usage-history-contract.ts +0 -217
  78. package/src/plugins/tui/src/usage-history-validation.ts +0 -104
  79. package/src/plugins/tui/src/usage-history-view.tsx +0 -236
  80. package/src/plugins/tui/src/usage-history-worker.ts +0 -25
  81. package/src/plugins/tui/src/usage-view-model.ts +0 -272
package/CHANGELOG.md CHANGED
@@ -7,6 +7,125 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
11
+ move this section to a versioned entry and reset the template below. -->
12
+
13
+ ## [v1.6.2] - 2026-11-03
14
+
15
+ ### Added
16
+
17
+ - **routing** — The Jev uplift: the native `pantheon_jev_decide` route works end to end (Console free variant field-verified), and TypeSafe direct is one `decision-router setup-model` command away.
18
+ - **routing** — `decision-router doctor` is route-aware: Console routes pass host-native without a catalog probe; the TypeSafe route is checked against the provider entry.
19
+ - **hooks** — J1 risk-score advisory gate (shadow): one Jev risk-score + intent observation per exfil-capable tool call when `PANTHEON_J1_RISK_SCORE` is on; never blocks; zero user content.
20
+ - **hooks** — J3 turn-complexity escalation (shadow): cheap-vs-main per delegate dispatch with local rails, behind `PANTHEON_J3_ESCALATION`; the override is proven, never applied in shadow.
21
+ - **routing** — J4 `mode: "review"` quality scoring: one round-trip quality + needs-review predicate for delegated results, on demand; the result never leaves the machine.
22
+ - **routing** — The offline J2 skill-selection scorecard harness ships in `bench/results/` (29 scenarios, replies faked, honest negatives).
23
+ - **install** — `init` sweeps stale `pantheon-opencode` copies from the npm cache's `_npx/` after a successful install (failures retry on the next init).
24
+
25
+ ### Deprecated
26
+
27
+ - **install** — `--opencode-version v1` keeps its deprecation warning on this line; Pantheon 2.0 refuses it outright.
28
+
29
+ ### Removed
30
+
31
+ - **tui** — The native `/quota` panel, the sidebar quota block, usage history, go-key diagnostics, and the `pantheon.quota` RPC; see the community replacement below.
32
+ - **tui** — `/quota-go-check` and the undocumented `PANTHEON_TRUSTED_BL_EXECUTABLE` env var.
33
+ - **docs** — The quota replacement is documented in `docs/tui-v2-quota-providers.md`: `@slkiser/opencode-quota`.
34
+
35
+ ### Fixed
36
+
37
+ - **routing** — Three field-measured causes of a dead `pantheon_jev_decide` are fixed: the detached `model.list()` call, the wrapped `{ data: [...] }` shape, and the catalog-presence gate.
38
+ - **routing** — Decision models are not chat models: route resolution reads config only; the visible `pantheon-decision-router:v1` prompt marker is suppressed.
39
+ - **agents** — Zeus's decision-routing instructions no longer reference the removed `/quota-go-check` command.
40
+
41
+ ## [v1.6.2-beta.17] - 2026-11-03
42
+
43
+ ### Added
44
+
45
+ - **routing** — J2 skill-selection scorecard harness: an offline, rerunnable, dated scorecard (29 synthetic scenarios including adversarial injection and refusal shapes, every Jev reply faked — zero network) measuring the P2 prefilter and the skills preset against expected picks, with honest negatives recorded in `bench/results/`. Activation gate: two consecutive scorecards, separately reviewed.
46
+ - **hooks** — J3 turn-complexity escalation policy (shadow): when `PANTHEON_J3_ESCALATION` is on, delegate dispatches get one Jev complexity classification resolved cheap-vs-main through a pure policy with independent local rails (risk-word states never downgrade, user-pinned models always win, oversize context never downgrades, uncertainty resolves to main). Structurally shadow-only — the wiring cannot reach the override mechanism (contract-test enforced); the mechanism itself is proven by direct tests for the separately reviewed activation. Default off.
47
+ - **routing** — J4 output quality scoring: a new `mode: "review"` on `pantheon_jev_decide` scores a delegated result against caller-named criteria (one round-trip: quality score + needs-human-review predicate). The request carries no result content — only delegate id, result kind, shape metrics, and bounded criteria. Advisory flag only; nothing blocks. On demand (Zeus-only, same consent/caps/permission chain).
48
+
49
+ ## [v1.6.2-beta.16] - 2026-11-03
50
+
51
+ ### Added
52
+
53
+ - **hooks** — J1 risk-score advisory gate (shadow): when `PANTHEON_J1_RISK_SCORE` is on, exfil-capable tool calls get one Jev risk-score + intent-predicate observation through the same gate chain as `pantheon_jev_decide` (consent, budget caps, `decision.egress` permission). Shadow only — the verdict is always observed, never enforced; nothing blocks or delays (2s abandon, fail-open on every failure mode). The request carries zero user content: tool name token, scope class, input hash only. Default off.
54
+
55
+ ## [v1.6.2-beta.15] - 2026-11-03
56
+
57
+ ### Added
58
+
59
+ - **routing** — `decision-router setup-model typesafe-jev/...` now provisions the TypeSafe host provider entry itself (the same additive `providers.typesafe-ai` merge the installer's `--decision-model` path performs), so the TypeSafe direct route is one command plus your own sign-in.
60
+ - **routing** — `doctor` checks are route-aware: the Console routes pass as host-native without any catalog probe (decision models are not chat models and never appear in `opencode models`), and the TypeSafe route is verified against the provider entry with a provisioning fix hint.
61
+
62
+ ## [v1.6.2-beta.14] - 2026-11-03
63
+
64
+ ### Fixed
65
+
66
+ - **routing** — The native Jev route no longer consults the host chat catalog. Decision models are not chat models: on a measured 2.2.5 host the catalog carries 561 entries and zero jev models, while the decisions API answers the exact same model ref directly (`jev-1.13-free` -> real answer at $0.00; the paid `jev-1.13` without a Zen workspace -> the host's own 404). The catalog-presence gate was a wrong assumption that sandbox mocks reinforced; route resolution is now config + budget admission, with consent, caps and the host permission assertion unchanged as the safety gates. `ROUTE_UNRESOLVED` and its inner verdicts are gone from the surface. Field-verified end to end: Zeus -> `pantheon_jev_decide` (mode skills) -> real Jev answer, usage reconciled.
67
+ - **routing** — The `decision-router setup-model` checklist no longer tells users to verify the model in the host catalog (it is not there by design).
68
+
69
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
70
+ move this section to a versioned entry and reset the template below. --&gt;
71
+ ## [v1.6.2-beta.13] - 2026-11-03
72
+
73
+ ### Added
74
+
75
+ - **install** — `init` now sweeps stale `pantheon-opencode` copies out of the npm cache's `_npx/` after a successful install (only the package subtree; unrelated packages and the just-installed copy survive). Field evidence: a 1.6.1 npx copy beside the registered 1.6.2-beta.12 made a bare `npx pantheon-opencode doctor` report the registered plugin as outdated, and old copies accumulate forever because npm never prunes them. Removal failures are swallowed and retried by the next init.
76
+ - **routing** — `ROUTE_UNRESOLVED` refusals now carry the inner verdict in `detail` (`MODEL_NOT_IN_CATALOG`, `AMBIGUOUS_MODEL`, `MODEL_NOT_DECISION`): the class alone does not tell whether the configured decision model is absent from the host catalog or present but not decision-typed, and those have different fixes. Field-measured on 2.2.5: a host catalog without the Console Jev model (no OpenCode Console credential) reports `MODEL_NOT_IN_CATALOG`.
77
+
78
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
79
+ move this section to a versioned entry and reset the template below. --&gt;
80
+ ## [v1.6.2-beta.12] - 2026-11-03
81
+
82
+ ### Added
83
+
84
+ - **routing** — `ROUTE_UNRESOLVED` refusals now carry the inner verdict in `detail` (`MODEL_NOT_IN_CATALOG`, `AMBIGUOUS_MODEL`, `MODEL_NOT_DECISION`): the class alone does not tell whether the configured decision model is absent from the host catalog or present but not decision-typed, and those have different fixes. Field-measured on 2.2.5: a host catalog without the Console Jev model (no OpenCode Console credential) reports `MODEL_NOT_IN_CATALOG`.
85
+
86
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
87
+ move this section to a versioned entry and reset the template below. --&gt;
88
+ ## [v1.6.2-beta.11] - 2026-11-03
89
+
90
+ ### Fixed
91
+
92
+ - **routing** — `pantheon_jev_decide` now accepts the host's wrapped catalog shape. The 2.2.5 host returns `{ data: [...] }` from `model.list()`, not a bare array; requiring an array turned every real session into `CATALOG_UNAVAILABLE` (field evidence: the sanitized `detail: TypeError` under beta.10 once the receiver binding landed). Same tolerance as the vision surface, which already unwrapped the page object.
93
+
94
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
95
+ move this section to a versioned entry and reset the template below. --&gt;
96
+ ## [v1.6.2-beta.10] - 2026-11-03
97
+
98
+ ### Added
99
+
100
+ - **routing** — Jev refusals carry the sanitized error CLASS in a `detail` field (`TypeError`, `RangeError`, …): enough to tell a detached-call failure from a host-side data failure, while the message (which can carry paths or provider detail) never reaches the chat.
101
+
102
+ ### Changed
103
+
104
+ - **tui** — The native quota surface is removed: the `/quota` panel, the sidebar quota block, usage history, the go-key diagnostics, and the `pantheon.quota` RPC no longer ship. The recommended community plugin [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) covers provider quota and usage (OpenCode 2.0.26+; an `npx` installer path exists for 1.x hosts) — see [Quota & usage](docs/tui-v2-quota-providers.md). `pantheon_cost` and the sidebar `Context` block are unaffected.
105
+ - **routing** — The visible `&lt;!-- pantheon-decision-router:v1 … --&gt;` marker is no longer appended to the prompt: the host chat rendered the HTML comment to the user. The router keeps running (shadow observation, telemetry, budget, presets); measured evidence showed every prompt mutation was a no-op (F-24, F-08/F-09), so no behavioral routing is lost.
106
+ - **agents** — Zeus's decision-routing instructions no longer reference the removed `/quota-go-check` command.
107
+
108
+ ### Fixed
109
+
110
+ - **routing** — The native Jev runtime now invokes host methods with their owning domain as receiver. `model.list()` was called detached from the host object and threw on real sessions, surfacing only as `CATALOG_UNAVAILABLE`; the canary always exercised the bound call and never caught it. `decisions()` and `skill.list()` are bound the same way, with a contract test that fails on any detached call.
111
+
112
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
113
+ move this section to a versioned entry and reset the template below. --&gt;
114
+ ## [v1.6.2-beta.9] - 2026-11-02
115
+
116
+ ### Added
117
+
118
+ - **install** — `init --decision-model typesafe-jev/jev-1.14.0` merges the TypeSafe provider entry additively into the user's `opencode.json`; only the sign-in remains.
119
+
120
+ ### Changed
121
+
122
+ - **agents** — Every agent frontmatter declares terminal permissions under `shell:` — the action a measured 2.2.5 host actually evaluates (canary-recorded evidence: a `shell` deny is enforced while `bash` falls through unruled).
123
+ - **agents** — Deny intents keep a `bash:` twin; the former `bash:`-only keys never matched, which made specialists' terminal grants inconsistent.
124
+ - **agents** — Zeus must never ask the user to type terminal commands: terminal work dispatches to a bash-capable specialist.
125
+ - **install** — `--opencode-version v1` is refused with a deprecation message front-running the 2.0 removal of the legacy plugin line.
126
+ - **docs** — New [Skill provenance search](docs/reference/skill-search-design.md) investigation (three tiers, Jev as typed ranker; deliberately unwired).
127
+ - **docs** — Measured MCP numbers in [Performance](docs/reference/performance.md) (fastmcp startup, FTS5 memory, vision deps).
128
+
10
129
  ### Added
11
130
 
12
131
  - **install** — The wizard's decision-model question now configures the real route (consent + caps + period in one write): Console Jev, the free variant, or TypeSafe direct.
@@ -19,9 +138,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
19
138
  - **performance** — The in-process secret scan is gated to exfil-capable tools (shell, file writes, web); read-only tools skip it, unknown names stay scanned (fail-closed).
20
139
  - **agents** — Zeus must never ask the user to type terminal commands: terminal work dispatches to a bash-capable specialist.
21
140
 
22
- <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
23
- move this section to a versioned entry and reset the template below. -->
24
-
141
+ &lt;!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
142
+ move this section to a versioned entry and reset the template below. --&gt;
25
143
  ## [v1.6.2-beta.8] - 2026-11-02
26
144
 
27
145
  ### Added
package/README.md CHANGED
@@ -104,68 +104,22 @@ see [Quick Start](docs/QUICKSTART.md).
104
104
  the host's native Decisions API (TypeSafe Jev via OpenCode Console or a
105
105
  configured decision model) behind the user's consent and budget gates — it
106
106
  never dispatches agents, runs skills, or changes permissions. This does not
107
- change separately documented quota and Vision integrations. See the
107
+ change the separately documented Vision integration. See the
108
108
  [router reference](docs/reference/local-decision-router.md) and the
109
109
  [Native Decisions (Jev)](docs/reference/native-decisions.md).
110
110
  - **An optional TUI** with a dispatch sidebar block and a full-width
111
- `/dispatch` panel. The V2 TUI also provides a quota overview in the
112
- sidebar/footer and a `/quota` details panel. Quota display is enabled by
113
- default; the sidebar keeps Todo and places quota immediately after Dispatch
114
- (header/version → Session → Context → Git → Todo → Dispatch → quota).
115
- Status stays in the native sidebar footer. Use `E` to disable quota or `M`
116
- to switch between remaining and used. The `/quota` panel has **Usage, Limits,
117
- Plugin, and Settings** tabs. Usage charts cover 7, 15, 30 days, or Total and
118
- plot recorded daily token usage and model totals rather than filling gaps with
119
- invented data. The panel identifies the active chat model; a partial-data
120
- warning appears only when the quota snapshot is actually partial.
121
- Session-reported spend is shown separately. The active context estimate uses
122
- the active model's input price times pre-cache context tokens, applies no cache
123
- discount, and is explicitly not billable.
124
- Quota windows show text amounts and status, not provider progress gauges. They
125
- show a local countdown and the provider-reported reset date/time in UTC when
126
- valid timing is available; missing timing is not inferred. After expiry the UI
127
- shows “aguardando atualização” until refreshed data arrives.
128
- When a quota status request fails, the UI preserves the last valid
129
- snapshot, marks it stale, and shows the failure cause as `Erro: <causa>`
130
- in the sidebar and `/quota` panel (plus a `Último erro` line) instead
131
- of a blind "Status indisponível"; the cause is logged as
132
- `[pantheon-tui quota]`.
133
- Usage severity uses warning color from 60% consumed and error color above 85%.
134
- Session costs, provider balances and selected-key usage retain their distinct
135
- labels and reported periods. Long values and states continue onto additional
136
- lines within the sidebar's fixed 34-column content budget.
137
- The installer selects the `plugins` component by default; in interactive setup
138
- you can change the component selection. A component-scoped install includes
139
- the TUI only when `plugins` is selected.
140
- The V2 quota RPC shows providers when OpenCode lists an active supported
141
- connection and Pantheon can locally resolve a nonblank credential. OpenCode
142
- Go also supports `OPENCODE_API_KEY` and effective `opencode-go`/`opencode`
143
- provider settings. This is not proof that the provider accepted the
144
- credential; failed requests and unsupported adapters can remain visible as
145
- unavailable. OpenCode Go checks a selected Console OAuth login first when
146
- available, then uses the first available API key if no Console login exists
147
- or its request fails; a Console 404 or a successful response without an
148
- access object reports no Go subscription and does not fall back.
149
- The API-key route follows OpenCode Quota's supported Go usage endpoint. See
150
- the
151
- [quota provider coverage table](docs/tui-v2-quota-providers.md) for limits and
152
- troubleshooting.
153
-
154
-
155
- Quota status requests are separate from the decision subsystem and continue to use
156
- their documented provider APIs. Removing decision-provider transport does not
157
- disable these quota requests.
158
- `/quota-go-check` is a separate manual, confirmation-gated diagnostic: one
159
- GET to `https://opencode.ai/zen/go/v1/usage` with the configured Go API key
160
- (not OAuth), at most one attempt per plugin runtime. It never refreshes quota,
161
- follows redirects or retries. Only HTTP 401 bodies are inspected, up to 4096
162
- bytes, for an own top-level JSON `error` property; its value is never inspected.
163
- Results contain only a safe category, optional HTTP status, coarse content type,
164
- and (for 401) whether that structure is present, absent, or unavailable.
165
- No error code, type, message, body, request ID, or byte count is displayed;
166
- a 401 rejection's cause remains unknown. `success` means
167
- HTTP success only—not a stable quota contract or parsed quota correctness.
168
- Require Themis security review before using this diagnostic.
111
+ `/dispatch` panel. The V2 sidebar keeps the Pantheon version, the active
112
+ preset/source, git state, and a `Context` block (tokens, a percent gauge,
113
+ `$<spent> spent`, and a muted `cache <n>% · <n.n> tok/s` line); the native
114
+ prompt footer keeps its own line, and Pantheon only appends
115
+ `▸<preset> · ✦<n> ativos` while delegations are running. The installer
116
+ selects the `plugins` component by default; in interactive setup you can
117
+ change the component selection. A component-scoped install includes the TUI
118
+ only when `plugins` is selected. The TUI ships no quota panel: for provider
119
+ quota and usage inside OpenCode, install the recommended community plugin
120
+ [`@slkiser/opencode-quota`](https://github.com/slkiser/opencode-quota) — see
121
+ [Quota & usage](docs/tui-v2-quota-providers.md). `pantheon_cost` and
122
+ `pantheon_model` keep working unchanged.
169
123
 
170
124
  Vision requests to OpenCode Zen require a valid active session and are rejected
171
125
  before image fetching or model-catalog lookup when the session is missing or
@@ -258,7 +212,27 @@ credentials cannot activate it. Native child-session dispatch remains separate.
258
212
  The one native egress surface is the Zeus-only `pantheon_jev_decide` tool,
259
213
  available on hosts that expose the V2.2.5 native Decisions API; its full gate
260
214
  chain, routes, and settlement rules are documented once in
261
- [V2 native Decisions](docs/reference/native-decisions.md).
215
+ [V2 native Decisions](docs/reference/native-decisions.md). An opt-in second
216
+ consumer of that chain, the J1 risk-score shadow gate, fires one bounded
217
+ native decision per write/execute tool call behind `PANTHEON_J1_RISK_SCORE`
218
+ (off by default, zero overhead when off): the request carries no user content
219
+ (tool name token, scope class, input sha256 only), every failure mode skips
220
+ silently with a reason token, and the shadow record is the whole effect — it
221
+ never blocks, asks, or narrows a permission. A third opt-in consumer, the J3
222
+ turn-complexity escalation, runs in shadow behind `PANTHEON_J3_ESCALATION`
223
+ (off by default): it classifies each delegate dispatch with one bounded score
224
+ question (Brief sha256, length and a risk-word flag only — the Brief text
225
+ never leaves the machine), local rails (risk words, user-pinned models, large
226
+ context) and every unsure answer always favor the main model, and the recorded
227
+ verdict never changes the dispatched model — the per-agent override mechanism
228
+ is proved by test and reserved for a separately reviewed activation with its
229
+ own measured baseline. A fourth consumer needs no flag at all: the tool's
230
+ `mode: "review"` (J4 output-quality scoring) runs only when Zeus explicitly
231
+ asks, after a delegation completes — one typed round-trip returns an advisory
232
+ quality score against named criteria plus a needs-review flag. The result
233
+ content never leaves the machine (shape metrics and criteria only, hostile
234
+ criteria rejected outright), and the verdict is advisory telemetry plus a
235
+ flag: it never blocks, retries, or alters the delegated result.
262
236
 
263
237
  The installer may retain a legacy target-specific preference; it does not control
264
238
  runtime routing. `npx pantheon-opencode decision-router ...` manages stored
package/README.pt-BR.md CHANGED
@@ -85,18 +85,16 @@ apenas — `init` → reiniciar → `/dispatch` → primeiro resultado — veja
85
85
  [referência do roteador](docs/reference/local-decision-router.md) e o
86
86
  [Decisions nativas (Jev)](docs/reference/native-decisions.md).
87
87
  - **Uma TUI opcional**, com bloco de dispatch na sidebar e painel `/dispatch`
88
- em largura total. A TUI V2 também inclui um resumo de quota na sidebar/rodapé
89
- e o painel `/quota`, com abas Usage, Limits, Plugin e Settings. Usage mostra
90
- gráficos de tokens registrados e totais por modelo em períodos de 7, 15, 30
91
- dias ou Total, sem inventar dados para preencher lacunas. O painel identifica
92
- o modelo ativo da conversa; o aviso de dados parciais só aparece quando a
93
- resposta de quota é realmente parcial. O gasto reportado da sessão fica
94
- separado da estimativa de contexto pré-cache, calculada com o preço de entrada
95
- do modelo ativo, sem desconto de cache e sem representar uma cobrança. As
96
- quotas aparecem como valores e status em texto, sem medidores de progresso;
97
- quando há horário válido, mostram contagem regressiva local e o reset informado
98
- pelo provedor em UTC. Horários ausentes não são inferidos. Use `E` para
99
- desativar a quota e `M` para alternar entre restante e usado.
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.
100
98
 
101
99
  A memória MCP fica disponível para busca explícita: o coordenador consulta o
102
100
  histórico uma vez quando ele pode mudar a tarefa e repassa apenas resultados
@@ -26,6 +26,7 @@ import { fileURLToPath } from 'node:url'
26
26
  import { configure as configureUi, endGaugeLine, tag } from '../scripts/install/cli-ui.mjs'
27
27
  import { resolveComponentSelection } from '../scripts/install/component-selection.mjs'
28
28
  import { resolveGlobalConfigDirectory } from '../scripts/install/config-paths.mjs'
29
+ import { provisionTypesafeHostProvider } from '../scripts/install/decision-router-config.mjs'
29
30
  import { resolveInstallExitCode } from '../scripts/install/exit-codes.mjs'
30
31
  import { createInterruptHandler } from '../scripts/install/interrupt.mjs'
31
32
  import { parseOpenCodeVersion } from '../scripts/install/opencode-version.mjs'
@@ -68,40 +69,13 @@ function readVersion() {
68
69
  /**
69
70
  * Merge (never overwrite) the TypeSafe decision-model entry into the user's
70
71
  * 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.
72
+ * user's own sign-in afterwards. Delegates to the shared installer module —
73
+ * the same provisioner `decision-router setup-model typesafe-jev/...` uses.
74
+ * Returns true, or a short failure reason for the installer to print.
74
75
  */
75
76
  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
- }
77
+ const result = provisionTypesafeHostProvider({ env: process.env })
78
+ return result.ok ? true : result.reason
105
79
  }
106
80
 
107
81
  /** Value of a repeatable installer flag from the raw argv, or undefined. */
@@ -570,6 +544,14 @@ async function main() {
570
544
  console.error(`❌ Invalid --version "${versionOpt}" — expected v1, v2 or auto`)
571
545
  process.exit(1)
572
546
  }
547
+ // The 2.0 deprecation front-run: the legacy plugin line is end-of-life.
548
+ // Loud warning now (the v1 code path still exists for legacy installs);
549
+ // the 2.0 removal turns this into a hard refusal.
550
+ if (versionOpt === 'v1') {
551
+ console.error(
552
+ '⚠️ --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).',
553
+ )
554
+ }
573
555
 
574
556
  // Resolve the user's explicit selection separately from the defaults.
575
557
  // Runtime and prompt templates are opt-in in both TTY and headless mode.
@@ -1069,6 +1051,22 @@ async function main() {
1069
1051
  }
1070
1052
  }
1071
1053
 
1054
+ // Old-version residue: every `npx pantheon-opencode` invocation materializes
1055
+ // a full copy under the npm cache's _npx/ and nothing in npm removes old
1056
+ // ones. The registration points at THIS run's copy, so every other copy is
1057
+ // unreferenced residue — sweep it (only the pantheon-opencode subtree;
1058
+ // failures are swallowed and retried by the next init).
1059
+ try {
1060
+ const { sweepStalePantheonNpxCaches } = await import('../scripts/install/npx-cache-sweep.mjs')
1061
+ const sweep = await sweepStalePantheonNpxCaches({ keep: ROOT })
1062
+ if (sweep.removed.length > 0) {
1063
+ console.log('')
1064
+ console.log(` ${S.sweptNpxCaches(sweep.removed.length)}`)
1065
+ }
1066
+ } catch {
1067
+ // Diagnostics-only: a failed sweep never fails the install.
1068
+ }
1069
+
1072
1070
  console.log('')
1073
1071
  console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
1074
1072
  console.log(` ${S.installedTitle(version)}`)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.2-beta.8",
4
- "description": "Multi-agent orchestration for OpenCode — 14 specialized agents, TDD, Themis review gates.",
3
+ "version": "1.6.2",
4
+ "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
7
7
  "src/plugins/tui"
@@ -32,7 +32,7 @@
32
32
  "start": "OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true opencode",
33
33
  "prepack": "npm run check:decision-router",
34
34
  "prepublishOnly": "node scripts/validate-routing.mjs && npm run check:decision-router",
35
- "postpublish": "node -e \"console.log('✅ Published pantheon-opencode v' + require('./package.json').version + ' to npm')\"",
35
+ "postpublish": "node -e \"console.log('\u2705 Published pantheon-opencode v' + require('./package.json').version + ' to npm')\"",
36
36
  "version:status": "node scripts/versioning.mjs status",
37
37
  "version:apply": "node scripts/versioning.mjs apply",
38
38
  "version:check": "node scripts/version-check.mjs",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.2-beta.8",
4
+ "version": "1.6.2",
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",
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 = "1.6.2-beta.8"
7
+ version = "1.6.2"
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
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { spawnSync } from 'node:child_process'
3
2
  import { existsSync } from 'node:fs'
4
3
  import { pathToFileURL } from 'node:url'
5
4
  // Prebuilt bundles: Node refuses to strip TypeScript types under node_modules,
@@ -32,6 +31,8 @@ import {
32
31
  DECISION_PROVIDER_BUDGET_MAPPING,
33
32
  DECISION_ROUTER_MODELS,
34
33
  diffDecisionRouterSurfaces,
34
+ inspectTypesafeHostProvider,
35
+ provisionTypesafeHostProvider,
35
36
  readUserDecisionRouterConfig,
36
37
  resolveUserDecisionRouterConfigPath,
37
38
  updateUserDecisionRouterConfig,
@@ -336,6 +337,23 @@ export async function runDecisionRouterCommand(
336
337
  noConsent ? 'Egress consent NOT recorded (--no-consent).' : 'Egress consent recorded: yes.',
337
338
  )
338
339
 
340
+ // The TypeSafe route needs a host-side provider entry the decisions API
341
+ // can resolve; the Console routes are host-native and need none. The
342
+ // merge is additive and idempotent; a failure is a printed warning (the
343
+ // decision config stays valid — the call fails at the host until the
344
+ // entry exists).
345
+ if (provider === 'typesafe-jev') {
346
+ const provision = provisionTypesafeHostProvider({ env })
347
+ if (provision.ok) {
348
+ stdout(
349
+ `TypeSafe provider entry merged into ${provision.path} (models.typesafe-ai, type "decision"). ` +
350
+ 'Sign in with `opencode auth login` (TypeSafe) or /connect.',
351
+ )
352
+ } else {
353
+ stdout(`⚠ TypeSafe provider entry NOT merged: ${provision.reason}`)
354
+ }
355
+ }
356
+
339
357
  const ledger = openLedger(env)
340
358
  try {
341
359
  ledger.configureUserCaps({
@@ -373,11 +391,11 @@ export async function runDecisionRouterCommand(
373
391
 
374
392
  stdout('')
375
393
  stdout('Native route checklist:')
376
- stdout(
377
- ' 1. Host catalog: the model must exist as type "decision" (stock: opencode/jev-1.13; custom providers need type: "decision" in opencode.json). Verify: decision-router doctor',
378
- )
379
- stdout(' 2. Restart OpenCode so the plugin registers pantheon_jev_decide.')
380
- stdout(' 3. Ask the Zeus agent to call pantheon_jev_decide (mode: "delegation" or "skills").')
394
+ // Decision models are not chat models: they never appear in the host
395
+ // model catalog (field evidence 2.2.5: 561 entries, 0 jev, while the
396
+ // decisions API answers the same ref directly). No catalog step here.
397
+ stdout(' 1. Restart OpenCode so the plugin registers pantheon_jev_decide.')
398
+ stdout(' 2. Ask the Zeus agent to call pantheon_jev_decide (mode: "delegation" or "skills").')
381
399
  stdout('Read-only verification: decision-router status / doctor / holds.')
382
400
  return
383
401
  }
@@ -468,25 +486,27 @@ export async function runDecisionRouterCommand(
468
486
  ? { provider: egress.provider, model: egress.candidate.model }
469
487
  : null
470
488
  if (target !== null) {
471
- const probe = probeHostCatalog(env)
472
- const hostProvider = target.provider === 'typesafe-jev' ? 'typesafe-ai' : 'opencode'
473
- if (probe.ok) {
474
- const exact = probe.models.has(`${hostProvider}/${target.model}`)
475
- const loose = probe.models.has(target.model)
476
- if (exact || loose) {
477
- pass('host-catalog', `${hostProvider}/${target.model} listed by \`opencode models\``)
489
+ // Route-aware checks, not a catalog probe: decision models are not chat
490
+ // models and never appear in `opencode models` (field evidence 2.2.5:
491
+ // 561 entries, 0 jev, while the decisions API answers the same ref).
492
+ if (target.provider === 'typesafe-jev') {
493
+ const hostProvider = inspectTypesafeHostProvider({ env })
494
+ if (hostProvider.present) {
495
+ pass(
496
+ 'native-route',
497
+ `typesafe-ai provider entry present (${hostProvider.path}); credential via \`opencode auth login\` (TypeSafe) or /connect`,
498
+ )
478
499
  } else {
479
- warn(
480
- 'host-catalog',
481
- `${hostProvider}/${target.model} not in the flat models list`,
482
- 'the flat list can omit decision-typed models; if a call refuses with ROUTE_UNRESOLVED, add a custom provider entry with type: "decision" (see docs/reference/native-decisions.md) or pick a listed decision model',
500
+ fail(
501
+ 'native-route',
502
+ `opencode.json has no providers.typesafe-ai entry (${hostProvider.path})`,
503
+ 'decision-router setup-model typesafe-jev/jev-1.14.0 merges it (type: "decision")',
483
504
  )
484
505
  }
485
506
  } else {
486
- warn(
487
- 'host-catalog',
488
- `could not probe: ${probe.reason}`,
489
- 'run `opencode models` manually; slow plugin activation is the usual cause',
507
+ pass(
508
+ 'native-route',
509
+ 'host-native opencode route; decision models are not listed in the chat catalog by design',
490
510
  )
491
511
  }
492
512
  }
@@ -503,41 +523,6 @@ export async function runDecisionRouterCommand(
503
523
  throw new DecisionRouterUsageError(USAGE)
504
524
  }
505
525
 
506
- /** Spawn-sync timeout floor so a wedged host cannot stall the doctor. */
507
- const HOST_PROBE_TIMEOUT_MS = 30_000
508
-
509
- /**
510
- * Best-effort host catalog probe for the doctor. Returns the set of
511
- * `provider/model` (and bare model ids, for exact-id matching) the host
512
- * reports, or the reason the probe failed. Never writes anything.
513
- */
514
- function probeHostCatalog(env) {
515
- let result
516
- try {
517
- result = spawnSync('opencode', ['models'], {
518
- encoding: 'utf8',
519
- timeout: HOST_PROBE_TIMEOUT_MS,
520
- env,
521
- })
522
- } catch (error) {
523
- return { ok: false, reason: String(error?.message ?? error) }
524
- }
525
- if (result.error) return { ok: false, reason: String(result.error.message ?? result.error) }
526
- if (result.status !== 0) {
527
- const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim()
528
- return { ok: false, reason: output.slice(0, 120) || `exit ${result.status}` }
529
- }
530
- const models = new Set()
531
- for (const line of `${result.stdout ?? ''}`.split(/\r?\n/)) {
532
- const id = line.trim()
533
- if (!id) continue
534
- models.add(id)
535
- const slash = id.indexOf('/')
536
- if (slash > 0) models.add(id.slice(slash + 1))
537
- }
538
- return { ok: true, models }
539
- }
540
-
541
526
  /** Cap- and period-eligible candidates, read-only, from the separated surfaces. */
542
527
  function capEligibleCandidates(config, inspection, wallPeriod) {
543
528
  if (inspection.caps === null) return []
@@ -1,4 +1,4 @@
1
- import { chmodSync, lstatSync, mkdirSync, readFileSync } from 'node:fs'
1
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
2
2
  import { homedir } from 'node:os'
3
3
  import { dirname, isAbsolute, join, parse, resolve, sep } from 'node:path'
4
4
  import { assertNoSymlinkAncestors, writeFileAtomically } from './verify.mjs'
@@ -558,3 +558,69 @@ function assertTrustedDirectoryChain(directory) {
558
558
  }
559
559
  }
560
560
  }
561
+
562
+ /** Host config file the TypeSafe provisioner merges into. */
563
+ function resolveHostOpenCodeConfigPath(env) {
564
+ const xdg = env.XDG_CONFIG_HOME
565
+ const home = env.HOME && isAbsolute(env.HOME) ? env.HOME : homedir()
566
+ const root = xdg && isAbsolute(xdg) ? xdg : join(home, '.config')
567
+ return resolve(root, 'opencode', 'opencode.json')
568
+ }
569
+
570
+ /**
571
+ * Additively merge the TypeSafe decision provider entry into the user's host
572
+ * `opencode.json` (`providers.typesafe-ai.models["jev-1.14.0"]`, type
573
+ * "decision"). Existing provider entries and an existing model entry are
574
+ * preserved. Read-only on the decision-router config; the merge is the one
575
+ * write.
576
+ * @param {{ env?: Record<string, string | undefined> }} [options]
577
+ * @returns {{ ok: true, path: string } | { ok: false, reason: string }}
578
+ */
579
+ export function provisionTypesafeHostProvider({ env = process.env } = {}) {
580
+ const configPath = resolveHostOpenCodeConfigPath(env)
581
+ if (!existsSync(configPath)) return { ok: false, reason: 'opencode.json not found' }
582
+ let data
583
+ try {
584
+ const parsed = JSON.parse(readFileSync(configPath, 'utf8'))
585
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
586
+ return { ok: false, reason: 'opencode.json is not a JSON object' }
587
+ }
588
+ data = parsed
589
+ } catch {
590
+ return { ok: false, reason: 'opencode.json is not plain JSON (comments?)' }
591
+ }
592
+ data.providers ??= {}
593
+ data.providers['typesafe-ai'] ??= {}
594
+ data.providers['typesafe-ai'].models ??= {}
595
+ if (data.providers['typesafe-ai'].models['jev-1.14.0'] === undefined) {
596
+ data.providers['typesafe-ai'].models['jev-1.14.0'] = {
597
+ name: 'Jev (TypeSafe direct)',
598
+ modelID: 'jev-latest',
599
+ type: 'decision',
600
+ }
601
+ }
602
+ try {
603
+ writeFileSync(configPath, `${JSON.stringify(data, null, 2)}\n`)
604
+ return { ok: true, path: configPath }
605
+ } catch (error) {
606
+ return { ok: false, reason: String(error instanceof Error ? error.message : error) }
607
+ }
608
+ }
609
+
610
+ /**
611
+ * Read-only check that the TypeSafe provider entry exists in the host config.
612
+ * Never writes; an unreadable config reports present:false with the path for
613
+ * the doctor's fix hint.
614
+ * @param {{ env?: Record<string, string | undefined> }} [options]
615
+ * @returns {{ present: boolean, path: string }}
616
+ */
617
+ export function inspectTypesafeHostProvider({ env = process.env } = {}) {
618
+ const configPath = resolveHostOpenCodeConfigPath(env)
619
+ try {
620
+ const parsed = JSON.parse(readFileSync(configPath, 'utf8'))
621
+ const model = parsed?.providers?.['typesafe-ai']?.models?.['jev-1.14.0']
622
+ return { present: model !== undefined && model !== null, path: configPath }
623
+ } catch {
624
+ return { present: false, path: configPath }
625
+ }
626
+ }