pantheon-opencode 1.6.3-beta.2 → 1.6.3-beta.21
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 +1 -1
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +143 -0
- package/README.md +21 -3
- package/README.pt-BR.md +1 -1
- package/bin/pantheon-init.mjs +46 -28
- package/package.json +1 -1
- package/plugin.json +2 -2
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +103 -3
- package/scripts/decision-router-v2-budget.mjs +2 -2
- package/scripts/decision-router.mjs +88 -6
- package/scripts/install/cli-ui.mjs +2 -1
- package/scripts/install/decision-router-config.mjs +53 -0
- package/scripts/install/interactive.mjs +103 -9
- package/scripts/install/opencode.mjs +101 -30
- package/scripts/install/plugin.mjs +17 -0
- package/scripts/jev-live-probe.mjs +212 -0
- package/scripts/skill-search.mjs +273 -0
- package/scripts/sync-tui.mjs +11 -0
- package/skills-lock.json +1 -0
- package/src/agents/aphrodite.md +34 -1
- package/src/agents/apollo.md +227 -0
- package/src/agents/athena.md +26 -0
- package/src/agents/demeter.md +33 -0
- package/src/agents/gaia.md +24 -0
- package/src/agents/hephaestus.md +24 -0
- package/src/agents/hermes.md +33 -0
- package/src/agents/iris.md +24 -0
- package/src/agents/mnemosyne.md +25 -3
- package/src/agents/nyx.md +50 -22
- package/src/agents/prometheus.md +242 -1
- package/src/agents/talos.md +24 -0
- package/src/agents/themis.md +24 -0
- package/src/agents/zeus.md +67 -6
- package/src/pantheon/j-telemetry-file.ts +96 -0
- package/src/pantheon/j1-approvals.ts +123 -0
- package/src/pantheon/jev-decision-tool.ts +268 -34
- package/src/pantheon/jev-decisions.ts +92 -8
- package/src/pantheon/jev-escalation.ts +1 -1
- package/src/pantheon/jev-quality-score.ts +7 -2
- package/src/pantheon/jev-rank-verify.ts +661 -0
- package/src/pantheon/jev-risk-gate.ts +75 -8
- package/src/pantheon/local-decision-budget.ts +170 -3
- package/src/pantheon/local-decision-router.ts +16 -0
- package/src/pantheon/local-decision-turn.ts +39 -4
- package/src/pantheon/local-decision-usage-evidence.internal.ts +2 -2
- package/src/pantheon/pantheon-decision-catalog.ts +9 -2
- package/src/pantheon/v2-decision-budget.ts +4 -2
- package/src/plugin-v2.ts +94 -7
- package/src/plugins/tui/dist/server-v2.d.ts +14 -6
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/server-v2.js +16 -9
- package/src/plugins/tui/dist/server-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +560 -4
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index-v2.tsx +6 -0
- package/src/plugins/tui/src/server-v2.ts +14 -7
- package/src/plugins/tui/src/whats-new-highlights.ts +317 -0
- package/src/plugins/tui/src/whats-new-open.ts +120 -0
- package/src/plugins/tui/src/whats-new-state.ts +128 -0
- package/src/plugins/tui/src/whats-new.tsx +172 -0
- package/src/routing.yml +1 -0
- package/src/skills/README.md +1 -1
- package/src/skills/prompt-refinery/SKILL.md +41 -0
|
@@ -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,
|
|
@@ -64,6 +65,7 @@ export function decisionRouterHelp() {
|
|
|
64
65
|
' setup [options] computed artifact diff; writes only with --apply',
|
|
65
66
|
' preview alias of `setup` (never writes)',
|
|
66
67
|
' holds unresolved reservations, read-only',
|
|
68
|
+
' holds release --provider <p> --reason "<why>" archive+release dead-route holds',
|
|
67
69
|
'',
|
|
68
70
|
'Explicit actions (each one changes exactly one thing):',
|
|
69
71
|
' select local|auto|<provider>/<model> record a selection; enables nothing',
|
|
@@ -74,7 +76,7 @@ export function decisionRouterHelp() {
|
|
|
74
76
|
' period confirm --current none|YYYY-MM --next YYYY-MM',
|
|
75
77
|
'',
|
|
76
78
|
'Guided (each does the whole chain in one command):',
|
|
77
|
-
' setup-model <provider>/<model> --monthly-usd N --per-decision-usd N [--no-consent]',
|
|
79
|
+
' setup-model <provider>/<model> --monthly-usd N --per-decision-usd N [--no-consent] [--account-id=<32-hex-id>]',
|
|
78
80
|
' select + enable + consent + caps + period in one write,',
|
|
79
81
|
' then print the verification summary',
|
|
80
82
|
' doctor read-only diagnosis of the native decision route with',
|
|
@@ -279,6 +281,49 @@ export async function runDecisionRouterCommand(
|
|
|
279
281
|
return
|
|
280
282
|
}
|
|
281
283
|
|
|
284
|
+
if (command === 'holds' && rest[0] === 'release') {
|
|
285
|
+
// Administrative correction for holds of routes that no longer exist:
|
|
286
|
+
// a dead provider can never reconcile, so its holds would freeze budget
|
|
287
|
+
// forever. Live providers are refused — their holds roll off with the
|
|
288
|
+
// period. Every released row is archived with the mandatory reason.
|
|
289
|
+
const [, ...releaseArgs] = rest
|
|
290
|
+
const options = parseNamedOptions(releaseArgs, ['--provider', '--reason'])
|
|
291
|
+
const provider = options['--provider']
|
|
292
|
+
const reason = options['--reason']
|
|
293
|
+
if (provider === undefined || reason === undefined) {
|
|
294
|
+
throw new DecisionRouterUsageError(
|
|
295
|
+
'Usage: decision-router holds release --provider <dead-provider> --reason "<why>"',
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
if (Object.hasOwn(DECISION_ROUTER_MODELS, provider)) {
|
|
299
|
+
throw new DecisionRouterUsageError(
|
|
300
|
+
`Provider ${provider} is a live catalog route — its holds are not releasable; ` +
|
|
301
|
+
'they reconcile or roll off with the budget period.',
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
const ledger = openLedger(env)
|
|
305
|
+
try {
|
|
306
|
+
const result = ledger.releaseHoldsForProvider(provider, reason)
|
|
307
|
+
if (result.released === 0) {
|
|
308
|
+
stdout(`No unresolved holds for provider ${provider}.`)
|
|
309
|
+
} else {
|
|
310
|
+
stdout(
|
|
311
|
+
`Released ${result.released} hold(s) of provider ${provider}; ` +
|
|
312
|
+
`freed ${(result.freedMicros / 1_000_000).toFixed(2)} USD of reserved budget.`,
|
|
313
|
+
)
|
|
314
|
+
for (const hold of ledger.listReleasedHolds(5)) {
|
|
315
|
+
stdout(
|
|
316
|
+
`Archived ${hold.reservationId}: provider=${hold.provider} model=${hold.model} ` +
|
|
317
|
+
`state_at_release=${hold.stateAtRelease} reason="${hold.reason}"`,
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
} finally {
|
|
322
|
+
ledger.close()
|
|
323
|
+
}
|
|
324
|
+
return
|
|
325
|
+
}
|
|
326
|
+
|
|
282
327
|
if (command === 'period') {
|
|
283
328
|
const [action, ...periodArgs] = rest
|
|
284
329
|
if (action !== 'confirm')
|
|
@@ -314,7 +359,9 @@ export async function runDecisionRouterCommand(
|
|
|
314
359
|
)
|
|
315
360
|
}
|
|
316
361
|
const noConsent = flagArgs.includes('--no-consent')
|
|
317
|
-
const capArgs = flagArgs.filter(
|
|
362
|
+
const capArgs = flagArgs.filter(
|
|
363
|
+
(arg) => arg !== '--no-consent' && !arg.startsWith('--account-id='),
|
|
364
|
+
)
|
|
318
365
|
// Exactly the two caps flags with values; parseCaps validates them and
|
|
319
366
|
// leaves `rest` empty because setup-model has no positional caps targets.
|
|
320
367
|
if (capArgs.length !== 4) throw new DecisionRouterUsageError(USAGE)
|
|
@@ -323,6 +370,29 @@ export async function runDecisionRouterCommand(
|
|
|
323
370
|
const { provider, model } = selection
|
|
324
371
|
const candidate = { provider, model }
|
|
325
372
|
|
|
373
|
+
// Cloudflare's native module requires an account-specific custom host
|
|
374
|
+
// provider entry. Fail before selecting/enabling the route if that entry
|
|
375
|
+
// cannot be provisioned; a warning after activation would leave a route
|
|
376
|
+
// that cannot be resolved by the host.
|
|
377
|
+
let cloudflareProvision = null
|
|
378
|
+
if (provider === 'cloudflare-workers-jev') {
|
|
379
|
+
const accountIdFlag = flagArgs.find((arg) => arg.startsWith('--account-id='))
|
|
380
|
+
if (!accountIdFlag) {
|
|
381
|
+
throw new DecisionRouterUsageError(
|
|
382
|
+
'Cloudflare route requires --account-id=<32-hex-id>; route was not activated',
|
|
383
|
+
)
|
|
384
|
+
}
|
|
385
|
+
cloudflareProvision = provisionCloudflareHostProvider({
|
|
386
|
+
accountId: accountIdFlag.slice('--account-id='.length),
|
|
387
|
+
env,
|
|
388
|
+
})
|
|
389
|
+
if (!cloudflareProvision.ok) {
|
|
390
|
+
throw new DecisionRouterUsageError(
|
|
391
|
+
`Cloudflare route was not activated: ${cloudflareProvision.reason}`,
|
|
392
|
+
)
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
326
396
|
// One update names selection, enablement, candidates and (unless refused)
|
|
327
397
|
// consent together: selecting a different target revokes consent unless
|
|
328
398
|
// the same update names it, so this single write is the consent act.
|
|
@@ -337,6 +407,13 @@ export async function runDecisionRouterCommand(
|
|
|
337
407
|
noConsent ? 'Egress consent NOT recorded (--no-consent).' : 'Egress consent recorded: yes.',
|
|
338
408
|
)
|
|
339
409
|
|
|
410
|
+
if (cloudflareProvision) {
|
|
411
|
+
stdout(
|
|
412
|
+
`Cloudflare provider entry merged into ${cloudflareProvision.path} (accountId + models.clef, type "decision"). ` +
|
|
413
|
+
'The token comes from CLOUDFLARE_API_TOKEN (Workers AI-scoped token) in the host environment.',
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
|
|
340
417
|
// The TypeSafe route needs a host-side provider entry the decisions API
|
|
341
418
|
// can resolve; the Console routes are host-native and need none. The
|
|
342
419
|
// merge is additive and idempotent; a failure is a printed warning (the
|
|
@@ -617,11 +694,16 @@ function formatInstallState(config, target) {
|
|
|
617
694
|
|
|
618
695
|
function parseSelectionTarget(target) {
|
|
619
696
|
if (target === 'local' || target === 'auto') return { mode: target }
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
697
|
+
const value = String(target)
|
|
698
|
+
for (const provider of Object.keys(DECISION_ROUTER_MODELS)) {
|
|
699
|
+
const prefix = `${provider}/`
|
|
700
|
+
if (!value.startsWith(prefix)) continue
|
|
701
|
+
const model = value.slice(prefix.length)
|
|
702
|
+
if (DECISION_ROUTER_MODELS[provider].includes(model)) {
|
|
703
|
+
return { mode: 'explicit', provider, model }
|
|
704
|
+
}
|
|
623
705
|
}
|
|
624
|
-
|
|
706
|
+
throw new DecisionRouterUsageError('Selection must name one supported provider/model pair')
|
|
625
707
|
}
|
|
626
708
|
|
|
627
709
|
function parseNamedFlags(args, expected) {
|
|
@@ -386,8 +386,9 @@ export function printWorktreeGuidance({
|
|
|
386
386
|
projectRoot = process.cwd(),
|
|
387
387
|
interactive = false,
|
|
388
388
|
dryRun = false,
|
|
389
|
+
enabled = true,
|
|
389
390
|
} = {}) {
|
|
390
|
-
if (!interactive || dryRun || !tty()) return
|
|
391
|
+
if (!interactive || dryRun || !tty() || enabled === false) return
|
|
391
392
|
|
|
392
393
|
const recommendation = getWorktreeRecommendation(projectRoot)
|
|
393
394
|
const rows = [
|
|
@@ -627,6 +627,59 @@ export function provisionTypesafeHostProvider({ env = process.env } = {}) {
|
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
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
|
+
const provider = data.providers['cloudflare-workers-ai']
|
|
660
|
+
const existingAccountId = provider.options.accountId
|
|
661
|
+
if (existingAccountId != null && String(existingAccountId).trim() !== '') {
|
|
662
|
+
if (String(existingAccountId).trim().toLowerCase() !== trimmed.toLowerCase()) {
|
|
663
|
+
return { ok: false, reason: 'existing accountId conflicts with --account-id' }
|
|
664
|
+
}
|
|
665
|
+
} else {
|
|
666
|
+
provider.options.accountId = trimmed
|
|
667
|
+
}
|
|
668
|
+
provider.models ??= {}
|
|
669
|
+
if (provider.models.clef === undefined) {
|
|
670
|
+
provider.models.clef = {
|
|
671
|
+
name: 'Clef (Cloudflare Workers AI)',
|
|
672
|
+
type: 'decision',
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
try {
|
|
676
|
+
writeFileSync(configPath, `${JSON.stringify(data, null, 2)}\n`)
|
|
677
|
+
return { ok: true, path: configPath }
|
|
678
|
+
} catch (error) {
|
|
679
|
+
return { ok: false, reason: String(error instanceof Error ? error.message : error) }
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
630
683
|
/**
|
|
631
684
|
* Read-only check that the TypeSafe provider entry exists in the host config.
|
|
632
685
|
* 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,
|
|
@@ -54,8 +56,8 @@ export async function promptReview(
|
|
|
54
56
|
/**
|
|
55
57
|
* Collect interactive setup choices before the installer begins any writes.
|
|
56
58
|
*
|
|
57
|
-
* @param {{ components?: string[], defaultComponents?: string[], noMcp?: boolean, prompts?: typeof clack, isTTY?: boolean, getDecisionRouterConfig?: (target: string) => unknown }} [options]
|
|
58
|
-
* @returns {Promise<{ components?: Set<string>, target?: string, decisionRouterConfig?: object, canceled?: boolean, cancelPoint?: string }>}
|
|
59
|
+
* @param {{ components?: string[], defaultComponents?: string[], noMcp?: boolean, prompts?: typeof clack, isTTY?: boolean, env?: Record<string, string | undefined>, getDecisionRouterConfig?: (target: string) => unknown }} [options]
|
|
60
|
+
* @returns {Promise<{ components?: Set<string>, target?: string, decisionRouterConfig?: object, decisionModelActivation?: object | null, decisionModelDeferredSetup?: object | null, canceled?: boolean, cancelPoint?: string }>}
|
|
59
61
|
*
|
|
60
62
|
* `cancelPoint` names the setup choice where the user stopped (`components` or
|
|
61
63
|
* `target`), so the caller can print one explainable line and persist the same
|
|
@@ -65,6 +67,7 @@ export async function runInteractiveInstall({
|
|
|
65
67
|
components = [],
|
|
66
68
|
defaultComponents = [],
|
|
67
69
|
noMcp = false,
|
|
70
|
+
env = process.env,
|
|
68
71
|
getDecisionRouterConfig = () => DEFAULT_DECISION_ROUTER_CONFIG,
|
|
69
72
|
prompts = clack,
|
|
70
73
|
isTTY = isTerminal(),
|
|
@@ -90,7 +93,7 @@ export async function runInteractiveInstall({
|
|
|
90
93
|
|
|
91
94
|
const componentOptions = [
|
|
92
95
|
{ label: 'agents', value: 'agents', hint: 'Agent configurations and routing (14 agents)' },
|
|
93
|
-
{ label: 'skills', value: 'skills', hint: `Reusable skill workflows (${
|
|
96
|
+
{ label: 'skills', value: 'skills', hint: `Reusable skill workflows (${21} skills)` },
|
|
94
97
|
{ label: 'instructions', value: 'instructions', hint: 'AGENTS.md and instructional files' },
|
|
95
98
|
{ label: 'prompts', value: 'prompts', hint: 'Prompt templates for agents' },
|
|
96
99
|
{ label: 'commands', value: 'commands', hint: 'OpenCode command shortcuts' },
|
|
@@ -136,7 +139,7 @@ export async function runInteractiveInstall({
|
|
|
136
139
|
// that setup-model writes.
|
|
137
140
|
const jevActivation = await prompts.select({
|
|
138
141
|
message:
|
|
139
|
-
'Configure the Jev decision model now? (
|
|
142
|
+
'Configure the Jev decision model now? (Console, OpenRouter, and TypeSafe activate here; Cloudflare is provisioned after install)',
|
|
140
143
|
options: [
|
|
141
144
|
{
|
|
142
145
|
label: 'Skip (default)',
|
|
@@ -146,12 +149,22 @@ export async function runInteractiveInstall({
|
|
|
146
149
|
{
|
|
147
150
|
label: 'OpenCode Console Jev (stock)',
|
|
148
151
|
value: 'opencode-console-jev/jev-1.13',
|
|
149
|
-
hint:
|
|
152
|
+
hint: consoleJevHint(env),
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'OpenRouter-hosted Jev',
|
|
156
|
+
value: 'openrouter-jev/typesafe/jev-1.13',
|
|
157
|
+
hint: openrouterJevHint(),
|
|
150
158
|
},
|
|
151
159
|
{
|
|
152
160
|
label: 'TypeSafe Jev (direct)',
|
|
153
161
|
value: 'typesafe-jev/jev-1.14.0',
|
|
154
|
-
hint:
|
|
162
|
+
hint: typesafeJevHint(env),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: 'Cloudflare Clef (provision after install)',
|
|
166
|
+
value: 'cloudflare-workers-jev/clef',
|
|
167
|
+
hint: cloudflareJevHint(env),
|
|
155
168
|
},
|
|
156
169
|
],
|
|
157
170
|
initialValue: 'skip',
|
|
@@ -159,14 +172,54 @@ export async function runInteractiveInstall({
|
|
|
159
172
|
if (cancelPrompt(prompts, jevActivation, 'decisionRouter')) {
|
|
160
173
|
return { canceled: true, cancelPoint: 'decisionRouter' }
|
|
161
174
|
}
|
|
162
|
-
|
|
163
|
-
//
|
|
164
|
-
|
|
175
|
+
|
|
176
|
+
// Decision-layer options: the shadow gates and the specialist-caller
|
|
177
|
+
// allowlist are first-class setup choices. The installer writes a flags
|
|
178
|
+
// file the user sources (the host reads these at plugin registration from
|
|
179
|
+
// its own environment — the installer never edits shell profiles silently).
|
|
180
|
+
const jevFlags = await prompts.multiselect({
|
|
181
|
+
message:
|
|
182
|
+
'Decision layer extras (shadow gates are observe-only; specialist access is explicit):',
|
|
183
|
+
options: [
|
|
184
|
+
{
|
|
185
|
+
label: 'J1 risk-score shadow gate',
|
|
186
|
+
value: 'PANTHEON_J1_RISK_SCORE=on',
|
|
187
|
+
hint: 'Records a Jev risk-score per exfil-capable tool call; observe-only',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: 'J3 escalation shadow classifier',
|
|
191
|
+
value: 'PANTHEON_J3_ESCALATION=on',
|
|
192
|
+
hint: 'Records cheap-vs-main per delegate dispatch; never applies overrides in shadow',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
label: 'Specialist callers: athena + themis (explicit questions)',
|
|
196
|
+
value: 'PANTHEON_JEV_SPECIALIST_CALLERS=athena,themis',
|
|
197
|
+
hint: 'Allowlisted specialists may ask bounded Jev questions mid-task; presets stay Zeus-only',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
required: false,
|
|
201
|
+
initialValues: [],
|
|
202
|
+
})
|
|
203
|
+
if (cancelPrompt(prompts, jevFlags, 'decisionFlags')) {
|
|
204
|
+
return { canceled: true, cancelPoint: 'decisionFlags' }
|
|
205
|
+
}
|
|
206
|
+
// Cloudflare needs an account-specific host provider entry. It remains an
|
|
207
|
+
// explicit deferred choice; setup-model must receive --account-id before any
|
|
208
|
+
// route is enabled.
|
|
209
|
+
const KNOWN_JEV_TARGETS = new Set([
|
|
210
|
+
'opencode-console-jev/jev-1.13',
|
|
211
|
+
'openrouter-jev/typesafe/jev-1.13',
|
|
212
|
+
'typesafe-jev/jev-1.14.0',
|
|
213
|
+
])
|
|
214
|
+
const cloudflareDeferred = jevActivation === 'cloudflare-workers-jev/clef'
|
|
165
215
|
const activationChoice =
|
|
166
216
|
typeof jevActivation === 'string' && KNOWN_JEV_TARGETS.has(jevActivation)
|
|
167
217
|
? jevActivation
|
|
168
218
|
: 'skip'
|
|
169
219
|
let decisionModelActivation = null
|
|
220
|
+
const decisionModelDeferredSetup = cloudflareDeferred
|
|
221
|
+
? { target: 'cloudflare-workers-jev/clef' }
|
|
222
|
+
: null
|
|
170
223
|
if (activationChoice !== 'skip') {
|
|
171
224
|
// Caps prompts degrade to the recommended defaults when the prompt
|
|
172
225
|
// implementation has no text input (stubbed tests, restricted TTYs).
|
|
@@ -193,10 +246,51 @@ export async function runInteractiveInstall({
|
|
|
193
246
|
}
|
|
194
247
|
}
|
|
195
248
|
|
|
249
|
+
// Empty/absent caller allowlist is intentionally Zeus-only. Persist that
|
|
250
|
+
// default too, so rerunning the wizard cannot leave a prior allowlist active.
|
|
251
|
+
const selectedFlags = Array.isArray(jevFlags) ? jevFlags : []
|
|
252
|
+
const hasCallerFlag = selectedFlags.some((flag) =>
|
|
253
|
+
flag.startsWith('PANTHEON_JEV_SPECIALIST_CALLERS='),
|
|
254
|
+
)
|
|
255
|
+
const flagsDir = join(env.XDG_CONFIG_HOME || `${env.HOME}/.config`, 'pantheon')
|
|
256
|
+
mkdirSync(flagsDir, { recursive: true, mode: 0o700 })
|
|
257
|
+
const flagsPath = join(flagsDir, 'decision-flags.env')
|
|
258
|
+
const lines = selectedFlags.map((flag) => `export ${flag}`)
|
|
259
|
+
if (!hasCallerFlag) lines.push('export PANTHEON_JEV_SPECIALIST_CALLERS=')
|
|
260
|
+
writeFileSync(
|
|
261
|
+
flagsPath,
|
|
262
|
+
`# Pantheon decision layer — source from your shell profile\n${lines.join('\n')}\n`,
|
|
263
|
+
)
|
|
264
|
+
|
|
196
265
|
return {
|
|
197
266
|
components: selectedComponents,
|
|
198
267
|
target,
|
|
199
268
|
decisionRouterConfig: createDecisionRouterConfig(DECISION_ROUTER_PROVIDERS[0], false),
|
|
200
269
|
decisionModelActivation,
|
|
270
|
+
decisionModelDeferredSetup,
|
|
201
271
|
}
|
|
202
272
|
}
|
|
273
|
+
|
|
274
|
+
/** Credential-state hints for the Jev wizard routes (set at prompt time). */
|
|
275
|
+
function consoleJevHint(env = process.env) {
|
|
276
|
+
return env.OPENCODE_API_KEY
|
|
277
|
+
? 'Zen credits via OPENCODE_API_KEY — ✓ detected in this shell'
|
|
278
|
+
: 'Zen credits via OPENCODE_API_KEY — export it first (opencode.ai/console)'
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function openrouterJevHint() {
|
|
282
|
+
return 'Uses the host OpenRouter credential (opencode auth list); billed per decision'
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function typesafeJevHint(env = process.env) {
|
|
286
|
+
return env.TYPESAFE_API_KEY
|
|
287
|
+
? '✓ TYPESAFE_API_KEY detected — the installer merges the provider entry'
|
|
288
|
+
: 'export TYPESAFE_API_KEY first; the installer merges the provider entry'
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function cloudflareJevHint(env = process.env) {
|
|
292
|
+
const tokenHint = env.CLOUDFLARE_API_TOKEN
|
|
293
|
+
? 'CLOUDFLARE_API_TOKEN detected'
|
|
294
|
+
: 'requires a Workers AI-scoped CLOUDFLARE_API_TOKEN'
|
|
295
|
+
return `${tokenHint}; not activated by this wizard. After install run: npx pantheon-opencode decision-router setup-model cloudflare-workers-jev/clef --account-id=<32-hex-id> --monthly-usd 5 --per-decision-usd 0.10`
|
|
296
|
+
}
|
|
@@ -624,13 +624,38 @@ function mergeMissing(target, source) {
|
|
|
624
624
|
* `src/plugin.ts` or `src/plugins/pantheon-hooks.ts` is not evidence that the
|
|
625
625
|
* plugin belongs to Pantheon and must be preserved verbatim.
|
|
626
626
|
*/
|
|
627
|
+
/**
|
|
628
|
+
* Field report (beta.13 §2): a plugin registration into the npx cache
|
|
629
|
+
* (`/_npx/<hash>/`) is VOLATILE — other npx-booted MCPs (playwright, rea)
|
|
630
|
+
* recycle that tree while the host is running, and the plugin dies
|
|
631
|
+
* intermittently with ENOENT. When THIS installer itself runs from the cache,
|
|
632
|
+
* the freshly registered path must be the stable global install instead when
|
|
633
|
+
* one exists; otherwise the registration stays volatile and says so.
|
|
634
|
+
*/
|
|
635
|
+
export function resolveStablePantheonRoot(root = ROOT) {
|
|
636
|
+
const normalized = root.replaceAll('\\', '/')
|
|
637
|
+
if (!normalized.includes('/_npx/')) return { root, volatile: false }
|
|
638
|
+
const globalCandidate = resolve(
|
|
639
|
+
dirname(process.execPath),
|
|
640
|
+
'..',
|
|
641
|
+
'lib',
|
|
642
|
+
'node_modules',
|
|
643
|
+
'pantheon-opencode',
|
|
644
|
+
)
|
|
645
|
+
if (existsSync(join(globalCandidate, 'src', 'plugin-v2', 'index.ts'))) {
|
|
646
|
+
return { root: globalCandidate, volatile: false }
|
|
647
|
+
}
|
|
648
|
+
return { root, volatile: true }
|
|
649
|
+
}
|
|
650
|
+
|
|
627
651
|
export function resolveInstalledPlugin(plugin) {
|
|
628
652
|
if (typeof plugin !== 'string') return plugin
|
|
629
653
|
const normalized = normalizePluginRef(plugin)
|
|
630
|
-
|
|
654
|
+
const stable = resolveStablePantheonRoot()
|
|
655
|
+
if (PANTHEON_PLUGIN_IDENTITIES.has(normalized)) return join(stable.root, normalized)
|
|
631
656
|
// Legacy V2 file ref (pre-directory-contract): migrate to the installed
|
|
632
657
|
// plugin directory so the beta loader accepts the entry.
|
|
633
|
-
if (normalized === PANTHEON_V2_LEGACY_FILE) return join(
|
|
658
|
+
if (normalized === PANTHEON_V2_LEGACY_FILE) return join(stable.root, PANTHEON_V2_PLUGIN)
|
|
634
659
|
const identity = managedPluginIdentity(plugin)
|
|
635
660
|
if (identity !== null && isAbsolute(normalized)) {
|
|
636
661
|
return INSTALLED_PANTHEON_PLUGIN_PATHS.get(identity) ?? plugin
|
|
@@ -1427,6 +1452,8 @@ export function setupRuntimePhase(
|
|
|
1427
1452
|
error(S.runtimeFailed(err.message))
|
|
1428
1453
|
warning(S.runtimeSkippedMcp)
|
|
1429
1454
|
stats.warnings += 1
|
|
1455
|
+
if (!Array.isArray(stats.warningMessages)) stats.warningMessages = []
|
|
1456
|
+
stats.warningMessages.push(S.runtimeSkippedMcp)
|
|
1430
1457
|
stats.errors += 1
|
|
1431
1458
|
return false
|
|
1432
1459
|
}
|
|
@@ -1646,6 +1673,8 @@ async function installPass(
|
|
|
1646
1673
|
)
|
|
1647
1674
|
/** Wizard-confirmed Jev activation (target + caps), surfaced on the result. */
|
|
1648
1675
|
let decisionModelActivation = null
|
|
1676
|
+
/** Cloudflare needs a user-supplied account ID, so the wizard defers it. */
|
|
1677
|
+
let decisionModelDeferredSetup = null
|
|
1649
1678
|
const stats = summary.opencode
|
|
1650
1679
|
// Per-call baseline. `stats` is the module-level cumulative summary, so the
|
|
1651
1680
|
// consistency guard must compare against THIS call's delta, not the total.
|
|
@@ -1804,6 +1833,7 @@ async function installPass(
|
|
|
1804
1833
|
},
|
|
1805
1834
|
prompts: opts.deps?.prompts,
|
|
1806
1835
|
isTTY: opts.deps?.isTTY,
|
|
1836
|
+
env: opts.deps?.env ?? opts.env ?? process.env,
|
|
1807
1837
|
})
|
|
1808
1838
|
|
|
1809
1839
|
// Resolve the location from the SELECTION before any cancel return: a
|
|
@@ -1840,6 +1870,7 @@ async function installPass(
|
|
|
1840
1870
|
decisionRouterConfig = migrateDecisionRouterConfig(result.decisionRouterConfig)
|
|
1841
1871
|
opts.decisionRouterConfig = decisionRouterConfig
|
|
1842
1872
|
decisionModelActivation = result.decisionModelActivation ?? null
|
|
1873
|
+
decisionModelDeferredSetup = result.decisionModelDeferredSetup ?? null
|
|
1843
1874
|
if (!dryRun && _lastRun) _lastRun.target = target
|
|
1844
1875
|
}
|
|
1845
1876
|
|
|
@@ -2402,6 +2433,10 @@ async function installPass(
|
|
|
2402
2433
|
// payload and the host config are already in place.
|
|
2403
2434
|
warning(`Could not disable the builtin Context sidebar block: ${cause.message}`)
|
|
2404
2435
|
stats.warnings++
|
|
2436
|
+
if (!Array.isArray(stats.warningMessages)) stats.warningMessages = []
|
|
2437
|
+
stats.warningMessages.push(
|
|
2438
|
+
`Could not disable the builtin Context sidebar block: ${cause.message}`,
|
|
2439
|
+
)
|
|
2405
2440
|
}
|
|
2406
2441
|
}
|
|
2407
2442
|
if (componentSet.has('plugins')) advancePhase()
|
|
@@ -2565,20 +2600,6 @@ async function installPass(
|
|
|
2565
2600
|
// A. Parse canonical agent config from src/agents/*.md frontmatter
|
|
2566
2601
|
// and merge into opencode.json config.
|
|
2567
2602
|
// --------------------------------------------------------------------
|
|
2568
|
-
function getAgentSources(agentPrefix) {
|
|
2569
|
-
const agentsDir = join(ROOT, 'src', 'agents')
|
|
2570
|
-
if (!existsSync(agentsDir)) return {}
|
|
2571
|
-
const sources = {}
|
|
2572
|
-
const files = readdirSync(agentsDir).filter(
|
|
2573
|
-
(f) => (f.endsWith('.agent.md') || f.endsWith('.md')) && f.toLowerCase() !== 'readme.md',
|
|
2574
|
-
)
|
|
2575
|
-
for (const f of files) {
|
|
2576
|
-
const name = f.replace(/\.(agent\.)?md$/, '')
|
|
2577
|
-
sources[name] = `${agentPrefix}/${name}.md`
|
|
2578
|
-
}
|
|
2579
|
-
return sources
|
|
2580
|
-
}
|
|
2581
|
-
|
|
2582
2603
|
function readAgentConfigFromCanonical() {
|
|
2583
2604
|
const agentsDir = join(ROOT, 'src', 'agents')
|
|
2584
2605
|
if (!existsSync(agentsDir)) return {}
|
|
@@ -2629,8 +2650,6 @@ async function installPass(
|
|
|
2629
2650
|
const configuredMcpServersForPolicies =
|
|
2630
2651
|
version === 'v2' ? configuredMcpServerNames(config.mcp) : []
|
|
2631
2652
|
const canonicalAgentConfig = readAgentConfigFromCanonical()
|
|
2632
|
-
const agentSources = getAgentSources(agentPrefix)
|
|
2633
|
-
|
|
2634
2653
|
if (config.agent === undefined) config.agent = {}
|
|
2635
2654
|
|
|
2636
2655
|
if (config.agent && typeof config.agent === 'object' && !Array.isArray(config.agent)) {
|
|
@@ -2643,7 +2662,12 @@ async function installPass(
|
|
|
2643
2662
|
// Preserve user-customized fields (model, provider, mcp, etc.)
|
|
2644
2663
|
const existing = config.agent[agentName]
|
|
2645
2664
|
if (!existing || typeof existing !== 'object' || Array.isArray(existing)) continue
|
|
2646
|
-
|
|
2665
|
+
// HEAL: older installs wrote `source: "agents/<name>.md"` (cwd-relative
|
|
2666
|
+
// provenance). Host 2.2.5 resolves that path against the SESSION cwd,
|
|
2667
|
+
// so every agent vanished outside the config dir (field report
|
|
2668
|
+
// beta.14: "Agent not found: zeus"). The host loads agents from the
|
|
2669
|
+
// agents directory without this field — remove it wherever found.
|
|
2670
|
+
delete existing.source
|
|
2647
2671
|
for (const field of MANAGED_FIELDS) {
|
|
2648
2672
|
if (field in agentCfg) {
|
|
2649
2673
|
existing[field] = JSON.parse(JSON.stringify(agentCfg[field]))
|
|
@@ -2654,7 +2678,6 @@ async function installPass(
|
|
|
2654
2678
|
} else {
|
|
2655
2679
|
// ── New agent ──
|
|
2656
2680
|
const newAgent = {}
|
|
2657
|
-
if (agentSources[agentName]) newAgent.source = agentSources[agentName]
|
|
2658
2681
|
if (agentCfg.description) newAgent.description = agentCfg.description
|
|
2659
2682
|
|
|
2660
2683
|
// Copy all framework-managed fields from canonical config
|
|
@@ -2784,11 +2807,39 @@ async function installPass(
|
|
|
2784
2807
|
// `npm install`. Copying every entry across would turn "silently ignored"
|
|
2785
2808
|
// into "config fails to load", so only loadable entries move; the rest stay
|
|
2786
2809
|
// where they are and the warning names the exact failure mode.
|
|
2810
|
+
// Preflight (runs for pure-V2 configs too — a stale or volatile Pantheon
|
|
2811
|
+
// registration must be named even when the singular `plugin` key is long
|
|
2812
|
+
// gone). Field report beta.13 §2: an EXISTING `_npx` path is worse than a
|
|
2813
|
+
// missing one — it passes the existsSync check at install time and dies
|
|
2814
|
+
// intermittently later, so volatility is named and the re-registration
|
|
2815
|
+
// below repoints to the stable tree.
|
|
2816
|
+
if (Array.isArray(config.plugins)) {
|
|
2817
|
+
for (const ref of config.plugins) {
|
|
2818
|
+
const refPath = typeof ref === 'string' ? ref : ref?.package
|
|
2819
|
+
if (typeof refPath !== 'string' || managedPluginIdentity(refPath) === null) continue
|
|
2820
|
+
const absolute = isAbsolute(refPath) ? refPath : resolve(target, refPath)
|
|
2821
|
+
if (!existsSync(absolute)) {
|
|
2822
|
+
warning(
|
|
2823
|
+
`Existing Pantheon registration points to ${refPath}, which no longer exists` +
|
|
2824
|
+
(refPath.includes('_npx/')
|
|
2825
|
+
? ' (the npx cache recycled that copy) — re-registering to the freshly installed tree'
|
|
2826
|
+
: ' — re-registering to the freshly installed tree'),
|
|
2827
|
+
)
|
|
2828
|
+
} else if (refPath.replaceAll('\\', '/').includes('/_npx/')) {
|
|
2829
|
+
warning(
|
|
2830
|
+
`Existing Pantheon registration points into the volatile npx cache (${refPath}) — ` +
|
|
2831
|
+
'other npx-booted MCPs recycle that tree and kill the plugin mid-session; ' +
|
|
2832
|
+
're-registering to a stable tree',
|
|
2833
|
+
)
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2787
2837
|
if (Array.isArray(config.plugin)) {
|
|
2788
2838
|
// Strip Pantheon refs FIRST, exactly as the V1 branch does: a stale V1
|
|
2789
2839
|
// .ts path is not a registrable entry on this host and must not be moved.
|
|
2790
2840
|
config.plugin = removePantheonPluginReferences(config.plugin)
|
|
2791
2841
|
if (!Array.isArray(config.plugins)) config.plugins = []
|
|
2842
|
+
|
|
2792
2843
|
const migrated = []
|
|
2793
2844
|
const blocked = []
|
|
2794
2845
|
for (const plugin of config.plugin) {
|
|
@@ -2860,6 +2911,14 @@ async function installPass(
|
|
|
2860
2911
|
// Legacy refs (npm shorthand, the old src/plugin-v2.ts file path) are
|
|
2861
2912
|
// recognized via managedPluginIdentity and already stripped above, so
|
|
2862
2913
|
// they migrate here.
|
|
2914
|
+
const stableRoot = resolveStablePantheonRoot()
|
|
2915
|
+
if (stableRoot.volatile) {
|
|
2916
|
+
warning(
|
|
2917
|
+
'This installer runs from the npx cache and no stable global install of ' +
|
|
2918
|
+
'pantheon-opencode was found; the plugin registration will point into the ' +
|
|
2919
|
+
'volatile cache and can break mid-session. Fix: npm install -g pantheon-opencode, then re-run init.',
|
|
2920
|
+
)
|
|
2921
|
+
}
|
|
2863
2922
|
const resolvedV2 = resolveInstalledPlugin(PANTHEON_V2_PLUGIN)
|
|
2864
2923
|
config.plugins = config.plugins.filter(
|
|
2865
2924
|
(plugin) => pluginReferenceIdentity(plugin) !== pluginReferenceIdentity(resolvedV2),
|
|
@@ -3067,6 +3126,8 @@ async function installPass(
|
|
|
3067
3126
|
for (const message of mcp.warnings ?? []) {
|
|
3068
3127
|
warning(message)
|
|
3069
3128
|
stats.warnings += 1
|
|
3129
|
+
if (!Array.isArray(stats.warningMessages)) stats.warningMessages = []
|
|
3130
|
+
stats.warningMessages.push(message)
|
|
3070
3131
|
}
|
|
3071
3132
|
}
|
|
3072
3133
|
|
|
@@ -3397,19 +3458,27 @@ async function installPass(
|
|
|
3397
3458
|
process.stdout.write(` [OK] ${created} component(s) installed\n`)
|
|
3398
3459
|
if (skipped > 0)
|
|
3399
3460
|
process.stdout.write(` ${colors.dim('\u2014')} ${skipped} already up-to-date\n`)
|
|
3400
|
-
|
|
3461
|
+
// The warning TEXT restates here — the count alone sent users to doctor to
|
|
3462
|
+
// learn what had already scrolled past.
|
|
3463
|
+
for (const message of stats.warningMessages ?? []) {
|
|
3464
|
+
process.stdout.write(` [WARN] ${message}\n`)
|
|
3465
|
+
}
|
|
3466
|
+
if (warnings > 0 && (stats.warningMessages ?? []).length === 0) {
|
|
3467
|
+
process.stdout.write(` [WARN] ${warnings} warning(s)\n`)
|
|
3468
|
+
}
|
|
3469
|
+
if (warnings > 0) {
|
|
3401
3470
|
process.stdout.write(
|
|
3402
|
-
`
|
|
3471
|
+
` ${colors.dim("Run 'pantheon-opencode doctor' for the full health check")}\n`,
|
|
3403
3472
|
)
|
|
3473
|
+
}
|
|
3404
3474
|
process.stdout.write('\n')
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
printWorktreeGuidance({ projectRoot: process.cwd(), interactive: true })
|
|
3475
|
+
// Worktree guidance is a project-install concept: a global install run
|
|
3476
|
+
// from $HOME derived a nonsense `<home>/.pantheon-worktrees/<user>` path.
|
|
3477
|
+
printWorktreeGuidance({
|
|
3478
|
+
projectRoot: process.cwd(),
|
|
3479
|
+
interactive: true,
|
|
3480
|
+
enabled: !(opts.global ?? isGlobalConfigDir(target)),
|
|
3481
|
+
})
|
|
3413
3482
|
}
|
|
3414
3483
|
|
|
3415
3484
|
// Beta 11 Setup phase 3: report whether this call APPLIED, so the caller can
|
|
@@ -3433,6 +3502,7 @@ async function installPass(
|
|
|
3433
3502
|
configAdvisories,
|
|
3434
3503
|
v2Capabilities: version === 'v2' ? v2Capabilities() : null,
|
|
3435
3504
|
decisionModelActivation,
|
|
3505
|
+
decisionModelDeferredSetup,
|
|
3436
3506
|
pluginOptions: v2PluginOptions,
|
|
3437
3507
|
}
|
|
3438
3508
|
: {
|
|
@@ -3440,6 +3510,7 @@ async function installPass(
|
|
|
3440
3510
|
applied: true,
|
|
3441
3511
|
reason: 'applied',
|
|
3442
3512
|
decisionModelActivation,
|
|
3513
|
+
decisionModelDeferredSetup,
|
|
3443
3514
|
target,
|
|
3444
3515
|
runtimeEffects,
|
|
3445
3516
|
openCodeVersion: version,
|