pantheon-opencode 1.6.3-beta.1 → 1.6.3-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/AGENTS.global.md +1 -1
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +57 -0
  4. package/README.md +14 -2
  5. package/package.json +1 -1
  6. package/plugin.json +1 -1
  7. package/pyproject.toml +1 -1
  8. package/scripts/decision-router-budget.mjs +1 -2
  9. package/scripts/decision-router-v2-egress.mjs +0 -2
  10. package/scripts/decision-router.mjs +26 -1
  11. package/scripts/install/decision-router-config.mjs +45 -2
  12. package/scripts/install/interactive.mjs +78 -10
  13. package/scripts/install/opencode.mjs +20 -0
  14. package/scripts/install/plugin.mjs +17 -0
  15. package/scripts/jev-live-probe.mjs +184 -0
  16. package/scripts/sync-tui.mjs +11 -0
  17. package/src/agents/zeus.md +24 -0
  18. package/src/pantheon/j-telemetry-file.ts +96 -0
  19. package/src/pantheon/jev-decision-tool.ts +151 -24
  20. package/src/pantheon/jev-decisions.ts +18 -3
  21. package/src/pantheon/jev-rank-verify.ts +435 -0
  22. package/src/pantheon/local-decision-budget.ts +1 -3
  23. package/src/pantheon/local-decision-provider-matrix.ts +0 -1
  24. package/src/pantheon/local-decision-usage-evidence.internal.ts +2 -2
  25. package/src/plugin-v2.ts +9 -2
  26. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  27. package/src/plugins/tui/dist/tui-v2.js +457 -4
  28. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  29. package/src/plugins/tui/dist/tui.js +1 -1
  30. package/src/plugins/tui/package-lock.json +2 -2
  31. package/src/plugins/tui/package.json +1 -1
  32. package/src/plugins/tui/src/index-v2.tsx +6 -0
  33. package/src/plugins/tui/src/whats-new-highlights.ts +263 -0
  34. package/src/plugins/tui/src/whats-new-open.ts +80 -0
  35. package/src/plugins/tui/src/whats-new-state.ts +128 -0
  36. package/src/plugins/tui/src/whats-new.tsx +119 -0
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-10-27T08:34:01-03:00 sha=0a6a8e2 -->
4
+ <!-- pantheon:agents-md v2 artifact=global generated-at=2026-11-04T19:23:07-03:00 sha=ad9f855 -->
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-10-27T08:34:01-03:00 sha=0a6a8e2 -->
4
+ <!-- pantheon:agents-md v2 artifact=project generated-at=2026-11-04T19:23:07-03:00 sha=ad9f855 -->
5
5
 
6
6
  # Pantheon — Repository Setup
7
7
 
package/CHANGELOG.md CHANGED
@@ -10,6 +10,63 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
  <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
11
11
  move this section to a versioned entry and reset the template below. -->
12
12
 
13
+ ## [v1.6.3-beta.10] - 2026-11-04
14
+
15
+ ### Fixed
16
+
17
+ - **routing** — The Jev input envelope is enforced: schemaVersion is required (SCHEMA_VERSION_INVALID) and unknown keys are rejected (UNKNOWN_INPUT_KEYS) — the declared contract is now the enforced contract (field report N2/N3).
18
+
19
+ ## [v1.6.3-beta.9] - 2026-11-04
20
+
21
+ ### Changed
22
+
23
+ - **agents** — The live scorecard now runs the full 13-specialist catalog (was a 5-agent sample); first full-catalog run: 6 exact hits, 2 domain-adjacent judgment calls, measured per agent.
24
+ - **agents** — Zeus gains consolidated MCP call-timing rules: when to recall, when to store, when to checkpoint, when vision fires, and the escalation order (local selector -> Jev -> MCP last resort).
25
+
26
+ ## [v1.6.3-beta.7] - 2026-11-04
27
+
28
+ ### Added
29
+
30
+ - **routing** — `jev-live-probe.mjs`: the operator-run live measurement tool. `--ping` is the calibration dry-run after `setup-model` (one call, exit 0 when reachable); `--scorecard` runs the live scenarios against the configured route and writes the dated scorecard into `bench/results/`. First live run: 7/8 correct specialist picks via OpenRouter.
31
+
32
+ ## [v1.6.3-beta.8] - 2026-11-04
33
+
34
+ ### Added
35
+
36
+ - **routing** — The v3.1 **rank** and **verify** primitives on `pantheon_jev_decide`: `mode: "rank"` picks the winner among up to 8 candidates with a fit score (the host answers one scalar per question, so full ordering is impossible — documented); `mode: "verify"` checks 1–4 claims as predicate questions with **BLOCK fail-closed**. Hostile inputs rejected. Zeus-only, same gate chain.
37
+ - **agents** — The live scorecard runs the full 13-specialist catalog (first full run: 6/8 exact, 2 domain-adjacent); Zeus gains consolidated MCP call-timing rules.
38
+
39
+ ## [v1.6.3-beta.7] - 2026-11-04
40
+
41
+ ### Added
42
+
43
+ - **install** — The setup wizard gains a **decision-layer step**: the shadow gates (`PANTHEON_J1_RISK_SCORE`, `PANTHEON_J3_ESCALATION`) and the specialist-caller allowlist (`athena,themis`) become first-class setup choices, written to `~/.config/pantheon/decision-flags.env` (source it from your shell profile). All advisory/shadow; none change behavior by default. Part of the ratified setup modernization.
44
+
45
+ ## [v1.6.3-beta.5] - 2026-11-04
46
+
47
+ ### Fixed
48
+
49
+ - **routing** — The ledger model-key slash fix (vendor ids like `typesafe/jev-1.13`) re-landed after being silently lost in a branch reset: the shipped beta.4 refused the OpenRouter model key with `invalid-model`. Field-verified end to end on the user's host: `advisory:true`, real Jev answer via OpenRouter at $0.00003/decision.
50
+ - **install** — The Jev wizard shows the full live route matrix with credential-state hints (checked hint when `OPENCODE_API_KEY`/`TYPESAFE_API_KEY`/`CLOUDFLARE_API_TOKEN` is in the shell; the exact export when not).
51
+
52
+ ## [v1.6.3-beta.4] - 2026-11-04
53
+
54
+ ### Added
55
+
56
+ - **routing** — `decision-router setup-model cloudflare-workers-jev/clef --account-id=<id>` provisions the Cloudflare Workers AI custom provider entry (accountId + `models.clef`, type `"decision"`); the token rides `CLOUDFLARE_API_TOKEN` in the host environment. Docs record the OpenAI Decisions protocol and the what's-new TUI window as deliberately unwired candidates.
57
+
58
+ ## [v1.6.3-beta.3] - 2026-11-04
59
+
60
+ ### Fixed
61
+
62
+ - **routing** — The OpenRouter-hosted Jev route settles end to end: the usage-evidence validator and the budget ledger now admit the `openrouter` accounting provider and vendor-slash model ids (`typesafe/jev-1.13`). Field-verified on the user's host: Zeus → `pantheon_jev_decide` (mode skills) → real Jev answer via the stored OpenRouter credential, $0.00003 per decision, usage reconciled.
63
+
64
+ ## [v1.6.3-beta.2] - 2026-11-04
65
+
66
+ ### Removed
67
+
68
+ - **routing** — The Console Jev **free variant** route (`opencode-console-jev-free` / `jev-1.13-free`) is removed from the matrix, the wizard, and the ledger: the free tier is rate-limited hard enough to 429 mid-work (field-measured), which is exactly the failure mode a decision route must not have. Existing configs selecting it degrade to skip with a fix hint pointing at the Zen-credited route (`OPENCODE_API_KEY`) or the TypeSafe direct route.
69
+
13
70
  ## [v1.6.3-beta.1] - 2026-11-04
14
71
 
15
72
  ### Added
package/README.md CHANGED
@@ -112,7 +112,11 @@ see [Quick Start](docs/QUICKSTART.md).
112
112
  preset/source, git state, and a `Context` block (tokens, a percent gauge,
113
113
  `$<spent> spent`, and a muted `cache <n>% · <n.n> tok/s` line); the native
114
114
  prompt footer keeps its own line, and Pantheon only appends
115
- `▸<preset> · ✦<n> ativos` while delegations are running. The installer
115
+ `▸<preset> · ✦<n> ativos` while delegations are running. When the Pantheon
116
+ version changes since the last TUI start, a one-time dismissable
117
+ "What's new" dialog lists that version's highlights from the shipped
118
+ changelog — once per version, `esc`/`q` dismisses; see
119
+ [What's new window](docs/reference/whats-new.md). The installer
116
120
  selects the `plugins` component by default; in interactive setup you can
117
121
  change the component selection. A component-scoped install includes the TUI
118
122
  only when `plugins` is selected. The TUI ships no quota panel: for provider
@@ -232,7 +236,15 @@ asks, after a delegation completes — one typed round-trip returns an advisory
232
236
  quality score against named criteria plus a needs-review flag. The result
233
237
  content never leaves the machine (shape metrics and criteria only, hostile
234
238
  criteria rejected outright), and the verdict is advisory telemetry plus a
235
- flag: it never blocks, retries, or alters the delegated result.
239
+ flag: it never blocks, retries, or alters the delegated result. Two more
240
+ orchestrator-owned tool modes round out the surface: `mode: "rank"` picks the
241
+ best of 2–8 named candidates for a state in one typed round-trip (it returns
242
+ the winner and that candidate's fit score — the host API answers one scalar
243
+ per question, so no full ordering is returned), and `mode: "verify"` checks
244
+ 1–4 named claims with one predicate question per claim, mapping each answer to
245
+ `PASS` / `FAIL` / `BLOCK` where every refusal, timeout or malformed answer is
246
+ `BLOCK` (fail-closed); claims are bounded caller-provided strings, hostile
247
+ shapes rejected outright, and neither mode adds a telemetry point.
236
248
 
237
249
  The installer may retain a legacy target-specific preference; it does not control
238
250
  runtime routing. `npx pantheon-opencode decision-router ...` manages stored
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.3-beta.1",
3
+ "version": "1.6.3-beta.10",
4
4
  "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.3-beta.1",
4
+ "version": "1.6.3-beta.10",
5
5
  "displayName": "Pantheon",
6
6
  "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 20 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
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.3-beta.1"
7
+ version = "1.6.3-beta.10"
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
@@ -26,13 +26,12 @@ var LOCAL_DECISION_BUDGET_PROVIDERS = Object.freeze([
26
26
  "openai-decisions",
27
27
  "typesafe-jev",
28
28
  "opencode-console",
29
- "jev-free",
30
29
  "openrouter",
31
30
  "vercel-ai-gateway",
32
31
  "cloudflare-workers-ai"
33
32
  ]);
34
33
  var ALLOWED_PROVIDERS = new Set(LOCAL_DECISION_BUDGET_PROVIDERS);
35
- var MODEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
34
+ var MODEL_KEY = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
36
35
  var RESERVATION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
37
36
  var CLOCK_ROLLBACK_TOLERANCE_MS = 6e4;
38
37
  function resolveLocalDecisionBudgetDbPath(env = process.env) {
@@ -14,7 +14,6 @@ var DECISION_ROUTER_MODELS = Object.freeze({
14
14
  "openai-decisions": Object.freeze(["gpt-6-luna"]),
15
15
  "typesafe-jev": Object.freeze(["jev-1.14.0"]),
16
16
  "opencode-console-jev": Object.freeze(["jev-1.13"]),
17
- "opencode-console-jev-free": Object.freeze(["jev-1.13-free"]),
18
17
  // Host-embedded decision modules confirmed in the 2.2.5 binary; the model
19
18
  // ids are the provider-side decision models (see
20
19
  // docs/reference/native-decisions.md for credential acquisition).
@@ -26,7 +25,6 @@ var DECISION_PROVIDER_BUDGET_MAPPING = Object.freeze({
26
25
  "openai-decisions": "openai-decisions",
27
26
  "typesafe-jev": "typesafe-jev",
28
27
  "opencode-console-jev": "opencode-console",
29
- "opencode-console-jev-free": "jev-free",
30
28
  "openrouter-jev": "openrouter",
31
29
  "vercel-gateway-jev": "vercel-ai-gateway",
32
30
  "cloudflare-workers-jev": "cloudflare-workers-ai"
@@ -32,6 +32,7 @@ import {
32
32
  DECISION_ROUTER_MODELS,
33
33
  diffDecisionRouterSurfaces,
34
34
  inspectTypesafeHostProvider,
35
+ provisionCloudflareHostProvider,
35
36
  provisionTypesafeHostProvider,
36
37
  readUserDecisionRouterConfig,
37
38
  resolveUserDecisionRouterConfigPath,
@@ -314,7 +315,9 @@ export async function runDecisionRouterCommand(
314
315
  )
315
316
  }
316
317
  const noConsent = flagArgs.includes('--no-consent')
317
- const capArgs = flagArgs.filter((arg) => arg !== '--no-consent')
318
+ const capArgs = flagArgs.filter(
319
+ (arg) => arg !== '--no-consent' && !arg.startsWith('--account-id='),
320
+ )
318
321
  // Exactly the two caps flags with values; parseCaps validates them and
319
322
  // leaves `rest` empty because setup-model has no positional caps targets.
320
323
  if (capArgs.length !== 4) throw new DecisionRouterUsageError(USAGE)
@@ -337,6 +340,28 @@ export async function runDecisionRouterCommand(
337
340
  noConsent ? 'Egress consent NOT recorded (--no-consent).' : 'Egress consent recorded: yes.',
338
341
  )
339
342
 
343
+ // The Cloudflare route needs a custom entry with the accountId (the
344
+ // host's embedded cloudflare-workers-ai module reads the token from
345
+ // CLOUDFLARE_API_TOKEN and the account from the entry options).
346
+ if (provider === 'cloudflare-workers-jev') {
347
+ const accountId = flagArgs.find((arg) => arg.startsWith('--account-id='))
348
+ const provision = provisionCloudflareHostProvider({
349
+ accountId: accountId?.split('=')[1],
350
+ env,
351
+ })
352
+ if (provision.ok) {
353
+ stdout(
354
+ `Cloudflare provider entry merged into ${provision.path} (accountId + models.clef, type "decision"). ` +
355
+ 'The token comes from CLOUDFLARE_API_TOKEN (Workers AI-scoped token) in the host environment.',
356
+ )
357
+ } else {
358
+ stdout(
359
+ `⚠ Cloudflare provider entry NOT merged: ${provision.reason}` +
360
+ ' — pass --account-id=<32-hex Cloudflare account id>.',
361
+ )
362
+ }
363
+ }
364
+
340
365
  // The TypeSafe route needs a host-side provider entry the decisions API
341
366
  // can resolve; the Console routes are host-native and need none. The
342
367
  // merge is additive and idempotent; a failure is a printed warning (the
@@ -29,7 +29,6 @@ export const DECISION_ROUTER_MODELS = Object.freeze({
29
29
  'openai-decisions': Object.freeze(['gpt-6-luna']),
30
30
  'typesafe-jev': Object.freeze(['jev-1.14.0']),
31
31
  'opencode-console-jev': Object.freeze(['jev-1.13']),
32
- 'opencode-console-jev-free': Object.freeze(['jev-1.13-free']),
33
32
  // Host-embedded decision modules confirmed in the 2.2.5 binary; the model
34
33
  // ids are the provider-side decision models (see
35
34
  // docs/reference/native-decisions.md for credential acquisition).
@@ -43,7 +42,6 @@ export const DECISION_PROVIDER_BUDGET_MAPPING = Object.freeze({
43
42
  'openai-decisions': 'openai-decisions',
44
43
  'typesafe-jev': 'typesafe-jev',
45
44
  'opencode-console-jev': 'opencode-console',
46
- 'opencode-console-jev-free': 'jev-free',
47
45
  'openrouter-jev': 'openrouter',
48
46
  'vercel-gateway-jev': 'vercel-ai-gateway',
49
47
  'cloudflare-workers-jev': 'cloudflare-workers-ai',
@@ -629,6 +627,51 @@ export function provisionTypesafeHostProvider({ env = process.env } = {}) {
629
627
  }
630
628
  }
631
629
 
630
+ /**
631
+ * Additively merge the Cloudflare Workers AI decision provider entry into the
632
+ * user's host `opencode.json`. The host's embedded `cloudflare-workers-ai`
633
+ * decisions module needs the accountId in the entry options and reads the
634
+ * token from `CLOUDFLARE_API_TOKEN` (a Workers AI-scoped token — not the
635
+ * global Cloudflare key). Existing entries are preserved.
636
+ * @param {{ accountId: string, env?: Record<string, string | undefined> }} options
637
+ * @returns {{ ok: true, path: string } | { ok: false, reason: string }}
638
+ */
639
+ export function provisionCloudflareHostProvider({ accountId, env = process.env } = {}) {
640
+ const trimmed = String(accountId ?? '').trim()
641
+ if (!/^[a-f0-9]{32}$/i.test(trimmed)) {
642
+ return { ok: false, reason: 'accountId must be the 32-hex Cloudflare account id' }
643
+ }
644
+ const configPath = resolveHostOpenCodeConfigPath(env)
645
+ if (!existsSync(configPath)) return { ok: false, reason: 'opencode.json not found' }
646
+ let data
647
+ try {
648
+ const parsed = JSON.parse(readFileSync(configPath, 'utf8'))
649
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
650
+ return { ok: false, reason: 'opencode.json is not a JSON object' }
651
+ }
652
+ data = parsed
653
+ } catch {
654
+ return { ok: false, reason: 'opencode.json is not plain JSON (comments?)' }
655
+ }
656
+ data.providers ??= {}
657
+ data.providers['cloudflare-workers-ai'] ??= {}
658
+ data.providers['cloudflare-workers-ai'].options ??= {}
659
+ data.providers['cloudflare-workers-ai'].options.accountId ??= trimmed
660
+ data.providers['cloudflare-workers-ai'].models ??= {}
661
+ if (data.providers['cloudflare-workers-ai'].models['clef'] === undefined) {
662
+ data.providers['cloudflare-workers-ai'].models['clef'] = {
663
+ name: 'Clef (Cloudflare Workers AI)',
664
+ type: 'decision',
665
+ }
666
+ }
667
+ try {
668
+ writeFileSync(configPath, `${JSON.stringify(data, null, 2)}\n`)
669
+ return { ok: true, path: configPath }
670
+ } catch (error) {
671
+ return { ok: false, reason: String(error instanceof Error ? error.message : error) }
672
+ }
673
+ }
674
+
632
675
  /**
633
676
  * Read-only check that the TypeSafe provider entry exists in the host config.
634
677
  * Never writes; an unreadable config reports present:false with the path for
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { mkdirSync, writeFileSync } from 'node:fs'
4
+ import { join } from 'node:path'
3
5
  import * as clack from '@clack/prompts'
4
6
  import {
5
7
  createDecisionRouterConfig,
@@ -146,17 +148,22 @@ export async function runInteractiveInstall({
146
148
  {
147
149
  label: 'OpenCode Console Jev (stock)',
148
150
  value: 'opencode-console-jev/jev-1.13',
149
- hint: 'Billed to your Console; uses host-owned auth',
151
+ hint: consoleJevHint(process.env),
150
152
  },
151
153
  {
152
- label: 'Console Jev free variant',
153
- value: 'opencode-console-jev-free/jev-1.13-free',
154
- hint: 'No paid budget consumed; host-owned auth',
154
+ label: 'OpenRouter-hosted Jev',
155
+ value: 'openrouter-jev/typesafe/jev-1.13',
156
+ hint: openrouterJevHint(),
155
157
  },
156
158
  {
157
159
  label: 'TypeSafe Jev (direct)',
158
160
  value: 'typesafe-jev/jev-1.14.0',
159
- hint: 'Installer merges the provider entry; you sign in with your TypeSafe key (/connect)',
161
+ hint: typesafeJevHint(process.env),
162
+ },
163
+ {
164
+ label: 'Cloudflare Clef',
165
+ value: 'cloudflare-workers-jev/clef',
166
+ hint: cloudflareJevHint(process.env),
160
167
  },
161
168
  ],
162
169
  initialValue: 'skip',
@@ -164,13 +171,51 @@ export async function runInteractiveInstall({
164
171
  if (cancelPrompt(prompts, jevActivation, 'decisionRouter')) {
165
172
  return { canceled: true, cancelPoint: 'decisionRouter' }
166
173
  }
174
+
175
+ // Decision-layer options: the shadow gates and the specialist-caller
176
+ // allowlist are first-class setup choices. The installer writes a flags
177
+ // file the user sources (the host reads these at plugin registration from
178
+ // its own environment — the installer never edits shell profiles silently).
179
+ const jevFlags = await prompts.multiselect({
180
+ message: 'Decision layer extras (all advisory/shadow; none change behavior by default):',
181
+ options: [
182
+ {
183
+ label: 'J1 risk-score shadow gate',
184
+ value: 'PANTHEON_J1_RISK_SCORE=on',
185
+ hint: 'Records a Jev risk-score per exfil-capable tool call; observe-only',
186
+ },
187
+ {
188
+ label: 'J3 escalation shadow classifier',
189
+ value: 'PANTHEON_J3_ESCALATION=on',
190
+ hint: 'Records cheap-vs-main per delegate dispatch; never applies overrides in shadow',
191
+ },
192
+ {
193
+ label: 'Specialist callers: athena + themis (explicit questions)',
194
+ value: 'CALLERS=athena,themis',
195
+ hint: 'Allowlisted specialists may ask bounded Jev questions mid-task; presets stay Zeus-only',
196
+ },
197
+ ],
198
+ required: false,
199
+ initialValues: [],
200
+ })
201
+ if (cancelPrompt(prompts, jevFlags, 'decisionFlags')) {
202
+ return { canceled: true, cancelPoint: 'decisionFlags' }
203
+ }
204
+ if (Array.isArray(jevFlags) && jevFlags.length > 0) {
205
+ const flagsDir = join(process.env.XDG_CONFIG_HOME || `${process.env.HOME}/.config`, 'pantheon')
206
+ mkdirSync(flagsDir, { recursive: true, mode: 0o700 })
207
+ const flagsPath = join(flagsDir, 'decision-flags.env')
208
+ const lines = jevFlags.map((flag) => `export ${flag}`).join('\n')
209
+ writeFileSync(
210
+ flagsPath,
211
+ `# Pantheon decision layer — source from your shell profile
212
+ ${lines}
213
+ `,
214
+ )
215
+ }
167
216
  // Only known targets activate; anything else (a stale stub, a renamed
168
217
  // option) degrades to skip instead of configuring a wrong route.
169
- const KNOWN_JEV_TARGETS = new Set([
170
- 'opencode-console-jev/jev-1.13',
171
- 'opencode-console-jev-free/jev-1.13-free',
172
- 'typesafe-jev/jev-1.14.0',
173
- ])
218
+ const KNOWN_JEV_TARGETS = new Set(['opencode-console-jev/jev-1.13', 'typesafe-jev/jev-1.14.0'])
174
219
  const activationChoice =
175
220
  typeof jevActivation === 'string' && KNOWN_JEV_TARGETS.has(jevActivation)
176
221
  ? jevActivation
@@ -209,3 +254,26 @@ export async function runInteractiveInstall({
209
254
  decisionModelActivation,
210
255
  }
211
256
  }
257
+
258
+ /** Credential-state hints for the Jev wizard routes (set at prompt time). */
259
+ function consoleJevHint(env = process.env) {
260
+ return env.OPENCODE_API_KEY
261
+ ? 'Zen credits via OPENCODE_API_KEY — ✓ detected in this shell'
262
+ : 'Zen credits via OPENCODE_API_KEY — export it first (opencode.ai/console)'
263
+ }
264
+
265
+ function openrouterJevHint() {
266
+ return 'Uses the host OpenRouter credential (opencode auth list); billed per decision'
267
+ }
268
+
269
+ function typesafeJevHint(env = process.env) {
270
+ return env.TYPESAFE_API_KEY
271
+ ? '✓ TYPESAFE_API_KEY detected — the installer merges the provider entry'
272
+ : 'export TYPESAFE_API_KEY first; the installer merges the provider entry'
273
+ }
274
+
275
+ function cloudflareJevHint(env = process.env) {
276
+ return env.CLOUDFLARE_API_TOKEN
277
+ ? '✓ CLOUDFLARE_API_TOKEN detected — pass --account-id at setup-model'
278
+ : 'Workers AI-scoped CLOUDFLARE_API_TOKEN + accountId; setup-model merges the entry'
279
+ }
@@ -2789,6 +2789,26 @@ async function installPass(
2789
2789
  // .ts path is not a registrable entry on this host and must not be moved.
2790
2790
  config.plugin = removePantheonPluginReferences(config.plugin)
2791
2791
  if (!Array.isArray(config.plugins)) config.plugins = []
2792
+ // Preflight: a Pantheon-owned registration whose target directory is
2793
+ // missing means the previous install was invalidated (the npx cache
2794
+ // recycles `_npx/<hash>` dirs — field evidence: a registered copy
2795
+ // vanished and the host silently dropped the plugin, so the whole tool
2796
+ // surface disappeared until the next init). Name the cause loudly
2797
+ // before the re-registration below fixes it.
2798
+ for (const ref of Array.isArray(config.plugins) ? config.plugins : []) {
2799
+ const refPath = typeof ref === 'string' ? ref : ref?.package
2800
+ if (typeof refPath !== 'string' || managedPluginIdentity(refPath) === null) continue
2801
+ const absolute = isAbsolute(refPath) ? refPath : resolve(target, refPath)
2802
+ if (existsSync(absolute)) continue
2803
+ const staleNpx = refPath.includes('_npx/')
2804
+ warning(
2805
+ `Existing Pantheon registration points to ${refPath}, which no longer exists` +
2806
+ (staleNpx
2807
+ ? ' (the npx cache recycled that copy) — re-registering to the freshly installed tree'
2808
+ : ' — re-registering to the freshly installed tree'),
2809
+ )
2810
+ }
2811
+
2792
2812
  const migrated = []
2793
2813
  const blocked = []
2794
2814
  for (const plugin of config.plugin) {
@@ -215,6 +215,23 @@ export function copyPluginFiles(
215
215
  else result.skipped++
216
216
  }
217
217
 
218
+ // CHANGELOG.md — the copy's one-time "What's new" window reads the release
219
+ // highlights for the running version from its own installed root. Best
220
+ // effort: a missing source simply means no window (the TUI fails open).
221
+ // src/plugins/tui → src/plugins → src → the package root, which ships
222
+ // CHANGELOG.md in its npm `files` allow-list.
223
+ const changelogSrc = join(srcDir, '..', '..', '..', 'CHANGELOG.md')
224
+ if (existsSync(changelogSrc)) {
225
+ const changelogStatus = writeIfChanged(
226
+ join(dstDir, 'CHANGELOG.md'),
227
+ readFileSync(changelogSrc, 'utf8'),
228
+ dryRun,
229
+ { recorder },
230
+ )
231
+ if (changelogStatus === 'created') result.created++
232
+ else result.skipped++
233
+ }
234
+
218
235
  return result
219
236
  }
220
237
 
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * jev-live-probe.mjs — operator-run live measurement for the Jev decision
4
+ * route (calibration ping + live scorecard).
5
+ *
6
+ * Talks to the HOST's decisions API through `opencode api` (the same route
7
+ * the plugin uses), so no credentials cross this script and every call is
8
+ * billed to the user's configured route. Operator-run by design: this is the
9
+ * consented measurement the J2 scorecard gate requires (offline harness
10
+ * measures plumbing; THIS measures the live model).
11
+ *
12
+ * Usage:
13
+ * node scripts/jev-live-probe.mjs --ping # 1 call, exit 0 if reachable
14
+ * node scripts/jev-live-probe.mjs --scorecard # N scenarios, dated scorecard
15
+ */
16
+
17
+ import { spawnSync } from 'node:child_process'
18
+ import { writeFileSync } from 'node:fs'
19
+ import { join } from 'node:path'
20
+
21
+ const HOST_TIMEOUT_MS = 30_000
22
+
23
+ /** Live scenarios: state → the skill a correct picker would choose. */
24
+ const SCENARIOS = [
25
+ { state: 'Investigate why the payment webhook drops events under load', expect: 'apollo' },
26
+ { state: 'Plan the database migration for the new billing table', expect: 'athena' },
27
+ { state: 'Review the auth flow for security gaps before the release', expect: 'themis' },
28
+ { state: 'Implement the retry queue endpoint for the notifications service', expect: 'hermes' },
29
+ { state: 'Set up the CI pipeline for the new monorepo layout', expect: 'prometheus' },
30
+ { state: 'Audit the permissions matrix across all specialists', expect: 'themis' },
31
+ { state: 'Design the caching layer for the read-heavy dashboard', expect: 'athena' },
32
+ { state: 'none — greet the user and ask what they want', expect: 'none' },
33
+ // Zero-dispatch agents' domains (roster-reform evidence batch)
34
+ { state: 'Write the SQL indexes and stored procedures for the orders schema', expect: 'demeter' },
35
+ { state: 'Process the satellite imagery tiles and classify land use', expect: 'gaia' },
36
+ {
37
+ state: 'Integrate the new LLM provider SDK and wire the prompt templates',
38
+ expect: 'hephaestus',
39
+ },
40
+ { state: 'Migrate the open issues to the new milestone labels via the API', expect: 'iris' },
41
+ { state: 'Decide which stale session summaries are worth keeping', expect: 'mnemosyne' },
42
+ { state: 'Fuzz the input parser with malformed payloads to find crashes', expect: 'nyx' },
43
+ { state: 'Verify the export module against the compliance checklist', expect: 'talos' },
44
+ { state: 'Polish the onboarding screen layout and micro-interactions', expect: 'aphrodite' },
45
+ ]
46
+
47
+ function callDecisions(modelRef, state) {
48
+ const payload = JSON.stringify({
49
+ model: modelRef,
50
+ input: [{ type: 'text', text: state }],
51
+ questions: [
52
+ {
53
+ type: 'choice',
54
+ name: 'pick',
55
+ instructions:
56
+ 'Pick the single best specialist for this task, or none. Required skills beat preferred ones; judge from the state alone.',
57
+ choices: [
58
+ { value: 'apollo', description: 'read-only investigation and research' },
59
+ { value: 'athena', description: 'planning and architecture' },
60
+ { value: 'themis', description: 'security, review and compliance gates' },
61
+ { value: 'hermes', description: 'backend implementation' },
62
+ { value: 'prometheus', description: 'infrastructure, CI and pipelines' },
63
+ { value: 'hephaestus', description: 'AI tooling and model integration' },
64
+ { value: 'demeter', description: 'databases and data layer' },
65
+ { value: 'gaia', description: 'remote sensing and geospatial' },
66
+ { value: 'iris', description: 'GitHub operations and automation' },
67
+ { value: 'aphrodite', description: 'UI and frontend craft' },
68
+ { value: 'mnemosyne', description: 'memory curation and recall' },
69
+ { value: 'nyx', description: 'chaos and adversarial testing' },
70
+ { value: 'talos', description: 'validation and compliance checks' },
71
+ { value: 'none', description: 'no specialist fits' },
72
+ ],
73
+ },
74
+ ],
75
+ })
76
+ const result = spawnSync(
77
+ 'opencode',
78
+ ['api', 'POST', '/api/experimental/generate/decisions', '-d', payload],
79
+ {
80
+ encoding: 'utf8',
81
+ timeout: HOST_TIMEOUT_MS,
82
+ },
83
+ )
84
+ if (result.status !== 0) {
85
+ return { ok: false, raw: (result.stderr || result.stdout || '').slice(0, 300) }
86
+ }
87
+ try {
88
+ return { ok: true, data: JSON.parse(result.stdout) }
89
+ } catch {
90
+ return { ok: false, raw: result.stdout.slice(0, 300) }
91
+ }
92
+ }
93
+
94
+ function answerChoice(data) {
95
+ const answers = data?.data?.answers ?? data?.answers
96
+ if (!Array.isArray(answers)) return null
97
+ const pick = answers.find((a) => a.name === 'pick')
98
+ return pick?.choice ?? null
99
+ }
100
+
101
+ const args = process.argv.slice(2)
102
+
103
+ if (args.includes('--ping')) {
104
+ const modelRef = { providerID: 'opencode', id: 'jev-1.13-free' }
105
+ const r = callDecisions(modelRef, 'Calibration ping: is the Jev decision route reachable?')
106
+ if (r.ok) {
107
+ const cost = r.data?.cost ?? r.data?.data?.cost
108
+ console.log(`✅ reachable — cost: ${JSON.stringify(cost)}`)
109
+ process.exit(0)
110
+ }
111
+ console.error(`❌ unreachable: ${r.raw}`)
112
+ process.exit(1)
113
+ }
114
+
115
+ if (args.includes('--scorecard')) {
116
+ // Route from the user's decision-router config (explicit selection only).
117
+ const { readFileSync } = await import('node:fs')
118
+ const { homedir } = await import('node:os')
119
+ const xdg = process.env.XDG_CONFIG_HOME?.startsWith('/')
120
+ ? process.env.XDG_CONFIG_HOME
121
+ : join(homedir(), '.config')
122
+ const cfg = JSON.parse(readFileSync(join(xdg, 'pantheon', 'decision-router.json'), 'utf8'))
123
+ if (!cfg.enabled || cfg.selection.mode !== 'explicit') {
124
+ console.error('the router must be enabled with an explicit selection for a live run')
125
+ process.exit(1)
126
+ }
127
+ // Same host-provider mapping the plugin route resolver uses (subset of
128
+ // NATIVE_JEV_HOST_PROVIDERS — keep in sync when the matrix expands).
129
+ const HOST_PROVIDERS = {
130
+ 'typesafe-jev': 'typesafe-ai',
131
+ 'opencode-console-jev': 'opencode',
132
+ 'openrouter-jev': 'openrouter',
133
+ 'vercel-gateway-jev': 'vercel-ai-gateway',
134
+ 'cloudflare-workers-jev': 'cloudflare-workers-ai',
135
+ }
136
+ const hostProvider = HOST_PROVIDERS[cfg.selection.provider]
137
+ if (!hostProvider) {
138
+ console.error(`unknown selection provider: ${cfg.selection.provider}`)
139
+ process.exit(1)
140
+ }
141
+ const modelRef = { providerID: hostProvider, id: cfg.selection.model }
142
+
143
+ const rows = []
144
+ let totalCost = 0
145
+ for (const scenario of SCENARIOS) {
146
+ const r = callDecisions(modelRef, scenario.state)
147
+ if (!r.ok) {
148
+ rows.push({ state: scenario.state, expect: scenario.expect, got: `ERROR: ${r.raw}` })
149
+ continue
150
+ }
151
+ const cost = r.data?.cost ?? 0
152
+ totalCost += Number(cost) || 0
153
+ rows.push({ state: scenario.state, expect: scenario.expect, got: answerChoice(r.data), cost })
154
+ }
155
+
156
+ const date = new Date().toISOString().slice(0, 10)
157
+ const out = [
158
+ `# Live J2 scorecard — ${date}`,
159
+ '',
160
+ `Route: \`${modelRef.providerID}/${modelRef.id}\`. Operator-run via \`opencode api\``,
161
+ '(consented route, billed to the user). 12 scenarios; agreement between the',
162
+ 'live model and the expected pick is the metric — this measures the MODEL,',
163
+ 'unlike the offline harness that measures the plumbing.',
164
+ '',
165
+ '| state (truncated) | expect | live | cost |',
166
+ '| --- | --- | --- | --- |',
167
+ ...rows.map(
168
+ (r) =>
169
+ `| ${r.state.slice(0, 48)}${r.state.length > 48 ? '…' : ''} | ${r.expect} | ${r.got ?? '—'} | ${r.cost ?? '—'} |`,
170
+ ),
171
+ '',
172
+ `Total cost: $${totalCost.toFixed(6)}. Honest caveat: one run is a smoke`,
173
+ 'measurement, not a calibration — a claim about model quality needs',
174
+ 'repeated runs and a bigger scenario set.',
175
+ '',
176
+ ].join('\n')
177
+ const outPath = `bench/results/j2-live-scorecard-${date}.md`
178
+ writeFileSync(outPath, out)
179
+ console.log(`✅ live scorecard written: ${outPath} (total $${totalCost.toFixed(6)})`)
180
+ process.exit(0)
181
+ }
182
+
183
+ console.error('usage: node scripts/jev-live-probe.mjs --ping | --scorecard')
184
+ process.exit(1)