pantheon-opencode 1.6.1 → 1.6.2-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.
- package/AGENTS.global.md +11 -11
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +179 -0
- package/README.md +268 -20
- package/README.pt-BR.md +34 -11
- package/bin/pantheon-init.mjs +301 -32
- package/package.json +13 -4
- package/plugin.json +1 -1
- package/prompts/README.md +58 -0
- package/prompts/debug-issue.prompt.md +46 -0
- package/prompts/dynamic/agora-generated.txt +38 -0
- package/prompts/dynamic/orchestrate-generated.txt +51 -0
- package/prompts/focus.prompt.md +42 -0
- package/prompts/implement-feature.prompt.md +39 -0
- package/prompts/optimize-database.prompt.md +58 -0
- package/prompts/orchestrate-with-zeus.prompt.md +441 -0
- package/prompts/plan-architecture.prompt.md +59 -0
- package/prompts/quick-discovery-large-codebase.prompt.md +294 -0
- package/prompts/quick-plan-large-feature.prompt.md +197 -0
- package/prompts/semantic-summarize.md +50 -0
- package/prompts/sketch.prompt.md +91 -0
- package/prompts/subtask.prompt.md +131 -0
- package/pyproject.toml +1 -1
- package/scripts/build-agents-md.mjs +1 -1
- package/scripts/decision-router-budget.mjs +780 -0
- package/scripts/decision-router-v2-budget.mjs +218 -0
- package/scripts/decision-router-v2-egress.mjs +272 -0
- package/scripts/decision-router.mjs +758 -0
- package/scripts/docs-check-changelog.mjs +5 -3
- package/scripts/doctor.mjs +213 -45
- package/scripts/install/agents-md.mjs +2 -1
- package/scripts/install/component-selection.mjs +9 -4
- package/scripts/install/config-migration.mjs +344 -393
- package/scripts/install/config-paths.mjs +15 -0
- package/scripts/install/decision-layer-preview.mjs +376 -0
- package/scripts/install/decision-router-config.mjs +560 -0
- package/scripts/install/health-check.mjs +20 -11
- package/scripts/install/interactive.mjs +103 -14
- package/scripts/install/interrupt.mjs +4 -3
- package/scripts/install/mcp-permissions.mjs +164 -0
- package/scripts/install/migrate.mjs +123 -72
- package/scripts/install/opencode-version.mjs +31 -13
- package/scripts/install/opencode-wildcard.mjs +106 -0
- package/scripts/install/opencode.mjs +411 -184
- package/scripts/install/plan-artifact.mjs +12 -1
- package/scripts/install/plan.mjs +8 -1
- package/scripts/install/plugin.mjs +18 -1
- package/scripts/install/state.mjs +12 -0
- package/scripts/install/strings.mjs +22 -0
- package/scripts/install/v2-capabilities.mjs +5 -6
- package/scripts/install/venv.mjs +34 -17
- package/scripts/mcp_resources.py +11 -9
- package/scripts/package-evidence.mjs +1 -0
- package/scripts/release-notes.mjs +30 -7
- package/scripts/restore.mjs +22 -10
- package/scripts/sandbox-env.sh +174 -0
- package/scripts/setup-v2-config.mjs +1703 -0
- package/scripts/setup.mjs +415 -0
- package/scripts/sync-tui.mjs +9 -1
- package/scripts/test-opencode-v2-sandbox.sh +448 -157
- package/scripts/update-skills-lock.mjs +30 -0
- package/scripts/versioning.mjs +41 -5
- package/skills-lock.json +10 -10
- package/src/agents/aphrodite.md +11 -3
- package/src/agents/apollo.md +6 -0
- package/src/agents/athena.md +7 -1
- package/src/agents/demeter.md +6 -2
- package/src/agents/gaia.md +5 -0
- package/src/agents/hephaestus.md +7 -2
- package/src/agents/hermes.md +14 -13
- package/src/agents/iris.md +6 -2
- package/src/agents/mnemosyne.md +21 -50
- package/src/agents/nyx.md +6 -2
- package/src/agents/prometheus.md +5 -1
- package/src/agents/talos.md +10 -1
- package/src/agents/themis.md +5 -1
- package/src/agents/zeus.md +61 -65
- package/src/instructions/agent-return-format.instructions.md +1 -1
- package/src/instructions/memory-protocol.instructions.md +3 -3
- package/src/instructions/test-economy.instructions.md +6 -6
- package/src/mcp/eval_store.py +11 -4
- package/src/mcp/mcp_resources.py +11 -9
- package/src/mcp/memory_mcp.py +293 -150
- package/src/mcp/pantheon_vision.py +37 -36
- package/src/pantheon/cost-command.ts +30 -133
- package/src/pantheon/jev-decision-tool.ts +347 -0
- package/src/pantheon/jev-decisions.ts +625 -0
- package/src/pantheon/local-decision-agents.ts +170 -0
- package/src/pantheon/local-decision-budget.ts +1046 -0
- package/src/pantheon/local-decision-egress-gate.ts +144 -0
- package/src/pantheon/local-decision-prompt.ts +256 -0
- package/src/pantheon/local-decision-provider-matrix.ts +44 -0
- package/src/pantheon/local-decision-router.ts +225 -0
- package/src/pantheon/local-decision-skills.ts +281 -0
- package/src/pantheon/local-decision-tool.ts +160 -0
- package/src/pantheon/local-decision-turn.ts +101 -0
- package/src/pantheon/local-decision-usage-evidence.internal.ts +168 -0
- package/src/pantheon/local-orchestration.ts +322 -0
- package/src/pantheon/model-pricing.ts +1 -536
- package/src/pantheon/pantheon-decision-catalog.ts +101 -0
- package/src/pantheon/v2-decision-budget.ts +456 -0
- package/src/pantheon/v2-decision-contracts.ts +300 -0
- package/src/pantheon/v2-decision-egress.ts +203 -0
- package/src/pantheon/v2-decision-events.ts +180 -0
- package/src/pantheon/v2-decision-heuristic.ts +121 -0
- package/src/pantheon/v2-decision-points/p1-agent.ts +91 -0
- package/src/pantheon/v2-decision-points/p10-claims.ts +243 -0
- package/src/pantheon/v2-decision-points/p11-catalog.ts +220 -0
- package/src/pantheon/v2-decision-points/p2-skill.ts +83 -0
- package/src/pantheon/v2-decision-points/p3-complexity.ts +108 -0
- package/src/pantheon/v2-decision-points/p4-memory.ts +137 -0
- package/src/pantheon/v2-decision-points/p5-themis-verify.ts +190 -0
- package/src/pantheon/v2-decision-points/p6-council.ts +161 -0
- package/src/pantheon/v2-decision-points/p7-loop.ts +263 -0
- package/src/pantheon/v2-decision-points/p8-guardrail.ts +367 -0
- package/src/pantheon/v2-decision-points/p9-memory-compaction.ts +304 -0
- package/src/pantheon/v2-decision-points.ts +242 -0
- package/src/pantheon/v2-decision-policy.ts +166 -0
- package/src/pantheon/v2-decision-premises.ts +146 -0
- package/src/pantheon/v2-decision-prompt-surface.ts +115 -0
- package/src/pantheon/v2-decision-rank.ts +91 -0
- package/src/pantheon/v2-decision-registry.ts +391 -0
- package/src/pantheon/v2-decision-resource-ids.ts +127 -0
- package/src/pantheon/v2-decision-shadow.ts +123 -0
- package/src/pantheon/v2-decision-telemetry.ts +214 -0
- package/src/pantheon/v2-decision-verify.ts +51 -0
- package/src/pantheon/v2-hook-engine.ts +307 -0
- package/src/pantheon/v2-native-decisions.ts +365 -0
- package/src/pantheon/v2-shell-hooks.ts +66 -2
- package/src/pantheon/v2-tools.ts +38 -15
- package/src/pantheon/v2-vision.ts +34 -29
- package/src/pantheon/vision.ts +43 -10
- package/src/plugin-v2.ts +449 -79
- package/src/plugin.ts +4 -0
- package/src/plugins/tui/THIRD_PARTY_NOTICES.md +24 -0
- package/src/plugins/tui/dist/server-v2.d.ts +22 -0
- package/src/plugins/tui/dist/server-v2.d.ts.map +1 -0
- package/src/plugins/tui/dist/server-v2.js +26 -0
- package/src/plugins/tui/dist/server-v2.js.map +1 -0
- package/src/plugins/tui/dist/tui-v2.d.ts +54 -51
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +762 -529
- package/src/plugins/tui/dist/tui-v2.js.map +1 -1
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/index-v2.ts +3 -6
- package/src/plugins/tui/package-lock.json +17 -2
- package/src/plugins/tui/package.json +6 -3
- package/src/plugins/tui/src/context-gauge.ts +59 -0
- package/src/plugins/tui/src/cost-data.ts +607 -0
- package/src/plugins/tui/src/index-v2.tsx +360 -242
- package/src/plugins/tui/src/model-pricing.ts +536 -0
- package/src/plugins/tui/src/model-usage-limits.ts +4 -0
- package/src/plugins/tui/src/server-v2.ts +21 -0
- package/src/plugins/tui/src/sidebar-width.ts +129 -0
- package/src/plugins/tui/tsconfig.typecheck.json +1 -1
- package/src/plugins/tui/tsdown.config.ts +34 -5
- package/src/routing.yml +72 -13
- package/src/skills/README.md +4 -0
- package/src/skills/agent-coordination/SKILL.md +0 -3
- package/src/skills/artifact-management/SKILL.md +0 -3
- package/src/skills/auto-continue/SKILL.md +0 -3
- package/src/skills/code-review-checklist/SKILL.md +0 -3
- package/src/skills/context-compression/SKILL.md +0 -3
- package/src/skills/memory-bank/SKILL.md +6 -28
- package/src/skills/session-goal/SKILL.md +0 -3
- package/src/skills/simplify/SKILL.md +5 -4
- package/src/skills/tdd-with-agents/SKILL.md +0 -3
- package/src/skills/visual-review-pipeline/SKILL.md +0 -1
- package/src/pantheon/memory-context.ts +0 -1017
|
@@ -10,6 +10,7 @@ import { homedir } from 'node:os'
|
|
|
10
10
|
import { join, resolve } from 'node:path'
|
|
11
11
|
import { fileURLToPath } from 'node:url'
|
|
12
12
|
import { resolveActivePreset } from './presets.mjs'
|
|
13
|
+
import { isValidSessionId } from './session-guard.ts'
|
|
13
14
|
import {
|
|
14
15
|
describeImagesNative,
|
|
15
16
|
NATIVE_MAX_TOKENS,
|
|
@@ -93,10 +94,10 @@ function imageReference(uri: string, mime: string, name: string): string {
|
|
|
93
94
|
* tool's `prompt`. NOTE: the description cache keys on the full prompt, so the
|
|
94
95
|
* same image asked with a new question gets a fresh describe — same image +
|
|
95
96
|
* same question within the TTL reuses the stored description.
|
|
96
|
-
* `sessionID` (the V2 `prompt` hook event's live session id, when
|
|
97
|
-
* relayed as an MCP `session_id` instruction: the
|
|
98
|
-
* process the host hands no session id to, and the Zen
|
|
99
|
-
* sessionless call with HTTP 400 `MissingSessionID` (mirrors
|
|
97
|
+
* `sessionID` (the V2 `prompt` hook event's live session id, when valid under
|
|
98
|
+
* the host session guard) is relayed as an MCP `session_id` instruction: the
|
|
99
|
+
* MCP runs in a separate process the host hands no session id to, and the Zen
|
|
100
|
+
* gateway rejects a sessionless call with HTTP 400 `MissingSessionID` (mirrors
|
|
100
101
|
* `generateInjectionPrompt` on the V1 path).
|
|
101
102
|
* The question and the session id are never logged.
|
|
102
103
|
*/
|
|
@@ -144,10 +145,9 @@ export function buildV2VisionPromptContext(
|
|
|
144
145
|
}
|
|
145
146
|
// MCP session relay (see the doc comment above): JSON.stringify quotes the
|
|
146
147
|
// id so it cannot spoof the surrounding instruction layout; never logged.
|
|
147
|
-
|
|
148
|
-
if (session) {
|
|
148
|
+
if (isValidSessionId(sessionID)) {
|
|
149
149
|
lines.push(
|
|
150
|
-
`Prefira a ferramenta nativa \`vision_describe\` (ela já repassa a sessão automaticamente). Se usar o MCP pantheon-vision (\`vision_describe\`/\`vision_ocr\`/\`vision_analyze\`), repasse session_id=${JSON.stringify(
|
|
150
|
+
`Prefira a ferramenta nativa \`vision_describe\` (ela já repassa a sessão automaticamente). Se usar o MCP pantheon-vision (\`vision_describe\`/\`vision_ocr\`/\`vision_analyze\`), repasse session_id=${JSON.stringify(sessionID)} no parâmetro \`session_id\` — sem ele o gateway Zen rejeita a chamada com MissingSessionID.`,
|
|
151
151
|
)
|
|
152
152
|
}
|
|
153
153
|
return lines.join('\n')
|
|
@@ -241,14 +241,11 @@ function exactModelMatch(models: V2VisionModel[], requested: string): V2VisionMo
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
|
-
* Select a native transport model. An
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* (`-free` suffix / cost ≤ 0) applies ONLY to AUTOMATIC selection — discovery
|
|
250
|
-
* then the Go default — because the direct gateway rejects free-tier models
|
|
251
|
-
* with HTTP 403, so they cannot serve the native describe path unasked.
|
|
244
|
+
* Select a native transport model. An explicit pin must be eligible for the
|
|
245
|
+
* native Zen image path or selection fails; it is never silently substituted.
|
|
246
|
+
* Free-tier exclusion (`-free` suffix / cost ≤ 0) applies only to automatic
|
|
247
|
+
* discovery, preserving the user's choice when a free model is explicitly
|
|
248
|
+
* pinned (the gateway can then return its actionable 403).
|
|
252
249
|
*/
|
|
253
250
|
export function selectV2VisionModel(
|
|
254
251
|
available: unknown,
|
|
@@ -263,8 +260,7 @@ export function selectV2VisionModel(
|
|
|
263
260
|
)
|
|
264
261
|
const pinned = preferred?.trim()
|
|
265
262
|
if (pinned) {
|
|
266
|
-
|
|
267
|
-
if (configured) return configured
|
|
263
|
+
return exactModelMatch(capable, pinned)
|
|
268
264
|
}
|
|
269
265
|
const candidates = capable.filter((model) => !isFreeVisionModel(model))
|
|
270
266
|
const defaultModel = exactModelMatch(candidates, DEFAULT_MODEL)
|
|
@@ -314,21 +310,19 @@ async function configuredVisionModel(directory: string): Promise<string | undefi
|
|
|
314
310
|
return undefined
|
|
315
311
|
}
|
|
316
312
|
|
|
317
|
-
async function preferredVisionModel(directory: string): Promise<string> {
|
|
313
|
+
async function preferredVisionModel(directory: string): Promise<string | undefined> {
|
|
318
314
|
const envModel = process.env.PANTHEON_VISION_MODEL?.trim()
|
|
319
315
|
if (envModel) return envModel
|
|
320
316
|
const configModel = await configuredVisionModel(directory)
|
|
321
317
|
if (configModel) return configModel
|
|
322
318
|
try {
|
|
323
|
-
return (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
})?.vision?.model ?? DEFAULT_MODEL
|
|
329
|
-
)
|
|
319
|
+
return resolveActivePreset({
|
|
320
|
+
env: process.env,
|
|
321
|
+
candidates: activePresetCandidates(directory),
|
|
322
|
+
logger: { warn: () => undefined },
|
|
323
|
+
})?.vision?.model
|
|
330
324
|
} catch {
|
|
331
|
-
return
|
|
325
|
+
return undefined
|
|
332
326
|
}
|
|
333
327
|
}
|
|
334
328
|
|
|
@@ -551,17 +545,28 @@ export function createV2VisionTool(runtime: V2VisionRuntime): V2VisionToolDefini
|
|
|
551
545
|
},
|
|
552
546
|
output: {},
|
|
553
547
|
execute: async (input, rawContext) => {
|
|
554
|
-
let stage = '
|
|
548
|
+
let stage = 'validate OpenCode session'
|
|
555
549
|
try {
|
|
556
|
-
const pathValue = typeof input.path === 'string' ? input.path : ''
|
|
557
550
|
const call = (asRecord(rawContext) ?? {}) as V2VisionToolContext
|
|
551
|
+
if (!isValidSessionId(call.sessionID)) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
'a valid OpenCode session id is required; retry this tool from an active OpenCode session',
|
|
554
|
+
)
|
|
555
|
+
}
|
|
556
|
+
const pathValue = typeof input.path === 'string' ? input.path : ''
|
|
558
557
|
const directory = call.directory || process.cwd()
|
|
558
|
+
stage = 'load image'
|
|
559
559
|
const image = await imageAttachment(pathValue, directory, call.signal)
|
|
560
560
|
stage = 'read model catalog'
|
|
561
561
|
const preferred = await preferredVisionModel(directory)
|
|
562
562
|
const catalog = await runtime.model.list()
|
|
563
563
|
const model = selectV2VisionModel(catalog, preferred)
|
|
564
564
|
if (!model) {
|
|
565
|
+
if (preferred?.trim()) {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`explicitly configured Vision model "${preferred}" is unavailable or ineligible for the native OpenCode Zen image path; update or remove the explicit model pin (PANTHEON_VISION_MODEL, visionModel config, or active preset), or choose an enabled image-capable OpenCode Zen model`,
|
|
568
|
+
)
|
|
569
|
+
}
|
|
565
570
|
throw new Error(
|
|
566
571
|
'no available OpenCode Zen multimodal model accepts image input; connect OpenCode Zen and enable an image-capable model',
|
|
567
572
|
)
|
|
@@ -586,7 +591,7 @@ export function createV2VisionTool(runtime: V2VisionRuntime): V2VisionToolDefini
|
|
|
586
591
|
// header ONLY for Zen targets, never to a non-Zen provider.
|
|
587
592
|
const requestTarget: NativeVisionTarget = {
|
|
588
593
|
...target,
|
|
589
|
-
|
|
594
|
+
sessionID: call.sessionID,
|
|
590
595
|
}
|
|
591
596
|
let failure: NativeVisionFailure | undefined
|
|
592
597
|
const output = await describeImagesNative(
|
package/src/pantheon/vision.ts
CHANGED
|
@@ -2126,6 +2126,16 @@ function syntheticHistoryPart(message: VisionHistoryMessage, text: string): Text
|
|
|
2126
2126
|
}
|
|
2127
2127
|
}
|
|
2128
2128
|
|
|
2129
|
+
/**
|
|
2130
|
+
* Result of a recursive sanitize pass: the (possibly rebuilt) value plus
|
|
2131
|
+
* whether anything at or below it actually changed. Unchanged subtrees keep
|
|
2132
|
+
* the ORIGINAL value by reference so host-owned instances (objects carrying
|
|
2133
|
+
* methods like `.inline()`, class instances, etc.) are never replaced by
|
|
2134
|
+
* plain-object copies — deep-copying them strips prototypes and crashes the
|
|
2135
|
+
* host when it later calls methods on what should still be its own objects.
|
|
2136
|
+
*/
|
|
2137
|
+
type SanitizeResult = { value: unknown; changed: boolean }
|
|
2138
|
+
|
|
2129
2139
|
/**
|
|
2130
2140
|
* Remove image-bearing parts before a provider serializer can turn them into
|
|
2131
2141
|
* image_url content. This hook is deliberately synchronous in spirit: it only
|
|
@@ -2144,9 +2154,20 @@ export function sanitizeVisionHistory(
|
|
|
2144
2154
|
const sessionID = historyMessage.info?.sessionID ?? historyMessage.sessionID ?? ''
|
|
2145
2155
|
if (nativeVisionSessions.has(sessionID)) continue
|
|
2146
2156
|
const descriptions = sessionVisionText.get(sessionID)
|
|
2147
|
-
const sanitize = (value: unknown, inParts: boolean):
|
|
2148
|
-
|
|
2149
|
-
|
|
2157
|
+
const sanitize = (value: unknown, inParts: boolean): SanitizeResult => {
|
|
2158
|
+
// Lazily-copied array: the original array is returned by reference
|
|
2159
|
+
// until the first changed child forces a rebuild.
|
|
2160
|
+
if (Array.isArray(value)) {
|
|
2161
|
+
let items: unknown[] | null = null
|
|
2162
|
+
for (let i = 0; i < value.length; i++) {
|
|
2163
|
+
const result = sanitize(value[i], inParts)
|
|
2164
|
+
if (!result.changed && !items) continue
|
|
2165
|
+
items ??= value.slice(0, i)
|
|
2166
|
+
items.push(result.value)
|
|
2167
|
+
}
|
|
2168
|
+
return items ? { value: items, changed: true } : { value, changed: false }
|
|
2169
|
+
}
|
|
2170
|
+
if (!value || typeof value !== 'object') return { value, changed: false }
|
|
2150
2171
|
|
|
2151
2172
|
const raw = value as { type?: unknown; id?: unknown; mime?: unknown }
|
|
2152
2173
|
const isImageUrl = raw.type === 'image_url'
|
|
@@ -2164,18 +2185,30 @@ export function sanitizeVisionHistory(
|
|
|
2164
2185
|
const text =
|
|
2165
2186
|
descriptions?.get(partID) ??
|
|
2166
2187
|
'Imagem removida do histórico antes do envio ao provedor textual.'
|
|
2167
|
-
return
|
|
2188
|
+
return {
|
|
2189
|
+
value: inParts ? syntheticHistoryPart(historyMessage, text) : { type: 'text', text },
|
|
2190
|
+
changed: true,
|
|
2191
|
+
}
|
|
2168
2192
|
}
|
|
2169
2193
|
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2194
|
+
// Lazily-copied object: untouched subtrees keep their original value —
|
|
2195
|
+
// including host class instances and objects with methods — so nothing
|
|
2196
|
+
// loses its prototype unless a nested image part must be replaced.
|
|
2197
|
+
const entries = Object.entries(value)
|
|
2198
|
+
let copy: Record<string, unknown> | null = null
|
|
2199
|
+
for (let i = 0; i < entries.length; i++) {
|
|
2200
|
+
const [key, child] = entries[i] as [string, unknown]
|
|
2201
|
+
const result = sanitize(child, key === 'parts')
|
|
2202
|
+
if (!result.changed && !copy) continue
|
|
2203
|
+
copy ??= Object.fromEntries(entries.slice(0, i))
|
|
2204
|
+
copy[key] = result.value
|
|
2173
2205
|
}
|
|
2174
|
-
return copy
|
|
2206
|
+
return copy ? { value: copy, changed: true } : { value, changed: false }
|
|
2175
2207
|
}
|
|
2176
2208
|
|
|
2177
|
-
const sanitized = sanitize(historyMessage, false)
|
|
2178
|
-
|
|
2209
|
+
const sanitized = sanitize(historyMessage, false)
|
|
2210
|
+
if (!sanitized.changed) continue
|
|
2211
|
+
for (const [key, value] of Object.entries(sanitized.value as VisionHistoryMessage)) {
|
|
2179
2212
|
historyMessage[key] = value
|
|
2180
2213
|
}
|
|
2181
2214
|
}
|