pantheon-opencode 1.7.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.global.md +2 -2
- package/AGENTS.md +3 -3
- package/CHANGELOG.md +85 -59
- package/README.md +74 -48
- package/README.pt-BR.md +19 -19
- package/bin/pantheon-init.mjs +11 -48
- package/package.json +9 -13
- package/plugin.json +2 -2
- package/pyproject.toml +1 -1
- package/scripts/build-agents-md.mjs +7 -6
- package/scripts/{check-plugin-v2-coverage.mjs → check-plugin-coverage.mjs} +7 -7
- package/scripts/{decision-router-v2-budget.mjs → decision-router-budget-gates.mjs} +1 -1
- package/scripts/{decision-router-v2-egress.mjs → decision-router-egress.mjs} +1 -1
- package/scripts/decision-router.mjs +2 -2
- package/scripts/docs-media.mjs +1 -1
- package/scripts/doctor.mjs +225 -136
- package/scripts/install/behavior-overrides.bundle.mjs +123 -0
- package/scripts/install/{v2-capabilities.mjs → capabilities.mjs} +7 -7
- package/scripts/install/config-migration.mjs +60 -253
- package/scripts/install/file-inventory.mjs +6 -4
- package/scripts/install/interactive.mjs +1 -1
- package/scripts/install/opencode-state.mjs +13 -12
- package/scripts/install/opencode-version.mjs +97 -162
- package/scripts/install/opencode.mjs +271 -428
- package/scripts/install/plan.mjs +1 -9
- package/scripts/install/plugin.mjs +19 -35
- package/scripts/install/shared.mjs +40 -1
- package/scripts/package-evidence.mjs +1 -4
- package/scripts/probe-pantheon-cost.mjs +1 -1
- package/scripts/reconcile.mjs +5 -7
- package/scripts/release-gates.mjs +22 -61
- package/scripts/setup-v2-config.mjs +10 -8
- package/scripts/setup.mjs +12 -22
- package/scripts/sync-tui.mjs +9 -17
- package/scripts/{test-opencode-v2-sandbox.sh → test-opencode-sandbox.sh} +9 -9
- package/scripts/update-skills-lock.mjs +24 -12
- package/scripts/update.mjs +17 -1
- package/scripts/validate-routing.mjs +79 -4
- package/scripts/validate-sandbox-install.mjs +3 -3
- package/skills-lock.json +25 -8
- package/src/agents/zeus.md +1 -0
- package/src/pantheon/behavior-overrides.ts +191 -0
- package/src/pantheon/{v2-bounded-read.ts → bounded-read.ts} +1 -1
- package/src/pantheon/cost-command.ts +1 -1
- package/src/pantheon/{v2-decision-contracts.ts → decision-contracts.ts} +3 -3
- package/src/pantheon/{v2-decision-points → decision-points}/p1-agent.ts +3 -3
- package/src/pantheon/{v2-decision-points → decision-points}/p10-claims.ts +2 -2
- package/src/pantheon/{v2-decision-points → decision-points}/p11-catalog.ts +2 -2
- package/src/pantheon/{v2-decision-points → decision-points}/p2-skill.ts +3 -3
- package/src/pantheon/{v2-decision-points → decision-points}/p3-complexity.ts +6 -6
- package/src/pantheon/{v2-decision-points → decision-points}/p4-memory.ts +2 -2
- package/src/pantheon/{v2-decision-points → decision-points}/p5-themis-verify.ts +2 -2
- package/src/pantheon/{v2-decision-points → decision-points}/p6-council.ts +3 -3
- package/src/pantheon/{v2-decision-points → decision-points}/p7-loop.ts +5 -5
- package/src/pantheon/{v2-decision-points → decision-points}/p8-guardrail.ts +2 -2
- package/src/pantheon/{v2-decision-points → decision-points}/p9-memory-compaction.ts +2 -2
- package/src/pantheon/{v2-decision-points.ts → decision-points.ts} +5 -5
- package/src/pantheon/{v2-decision-policy.ts → decision-policy.ts} +2 -2
- package/src/pantheon/{v2-decision-prompt-surface.ts → decision-prompt-surface.ts} +3 -3
- package/src/pantheon/{v2-decision-registry.ts → decision-registry.ts} +10 -13
- package/src/pantheon/{v2-decision-resource-ids.ts → decision-resource-ids.ts} +1 -1
- package/src/pantheon/{v2-decision-shadow.ts → decision-shadow.ts} +1 -1
- package/src/pantheon/{v2-decision-telemetry.ts → decision-telemetry.ts} +1 -1
- package/src/pantheon/{v2-execute-after.ts → execute-after.ts} +4 -4
- package/src/pantheon/goal-store.ts +7 -0
- package/src/pantheon/{v2-hook-engine.ts → hook-engine.ts} +3 -3
- package/src/pantheon/jev-decision-tool.ts +3 -3
- package/src/pantheon/jev-decisions.ts +12 -6
- package/src/pantheon/jev-escalation.ts +6 -6
- package/src/pantheon/jev-quality-score.ts +2 -2
- package/src/pantheon/jev-rank-verify.ts +2 -2
- package/src/pantheon/jev-risk-gate.ts +4 -4
- package/src/pantheon/local-decision-agents.ts +1 -1
- package/src/pantheon/local-decision-router.ts +1 -1
- package/src/pantheon/local-decision-tool.ts +2 -2
- package/src/pantheon/local-orchestration.ts +1 -1
- package/src/pantheon/model-command.ts +1 -1
- package/src/pantheon/{v2-vision.ts → native-vision.ts} +12 -15
- package/src/pantheon/pantheon-decision-catalog.ts +12 -0
- package/src/pantheon/{v2-shell-hooks.ts → shell-hooks.ts} +4 -4
- package/src/pantheon/{v2-tools.ts → tools.ts} +4 -4
- package/src/pantheon/{v2-unsupported.d.mts → unsupported.d.mts} +3 -3
- package/src/pantheon/{v2-unsupported.mjs → unsupported.mjs} +8 -8
- package/src/pantheon/update-notifier.ts +101 -0
- package/src/pantheon/vision-local.ts +12 -3
- package/src/pantheon/vision.ts +120 -2
- package/src/{plugin-v2 → plugin}/index.ts +7 -7
- package/src/plugin.ts +2870 -500
- package/src/plugins/hook-runner.ts +3 -3
- package/src/plugins/tui/dist/server.d.ts +23 -9
- package/src/plugins/tui/dist/server.d.ts.map +1 -1
- package/src/plugins/tui/dist/server.js +25 -12
- package/src/plugins/tui/dist/server.js.map +1 -1
- package/src/plugins/tui/dist/tui.d.ts +1023 -494
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +5612 -2086
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/{index-v2.ts → index.ts} +1 -1
- package/src/plugins/tui/package-lock.json +2 -42
- package/src/plugins/tui/package.json +4 -10
- package/src/plugins/tui/src/cost-data.ts +1 -1
- package/src/plugins/tui/src/decision-router-state.ts +242 -0
- package/src/plugins/tui/src/doctor-state.ts +198 -0
- package/src/plugins/tui/src/index.tsx +4222 -2822
- package/src/plugins/tui/src/j1-gate-status.ts +85 -0
- package/src/plugins/tui/src/pantheon-settings-state.ts +245 -0
- package/src/plugins/tui/src/pantheon-settings.tsx +442 -0
- package/src/plugins/tui/src/preset-state.ts +143 -0
- package/src/plugins/tui/src/server.ts +23 -10
- package/src/plugins/tui/src/update-notice.ts +90 -0
- package/src/plugins/tui/src/update-status.ts +98 -0
- package/src/plugins/tui/tsconfig.typecheck.json +9 -2
- package/src/plugins/tui/tsdown.config.ts +3 -5
- package/src/plugins/tui/tui.ts +1 -2
- package/src/routing.yml +36 -0
- package/src/skills/README.md +16 -1
- package/src/skills/artifact-management/SKILL.md +10 -67
- package/src/skills/artifact-management/references/artifact-templates.md +71 -0
- package/src/skills/auto-continue/SKILL.md +10 -0
- package/src/skills/code-review-checklist/SKILL.md +11 -44
- package/src/skills/code-review-checklist/references/review-checklists.md +54 -0
- package/src/skills/instruction-forge/SKILL.md +57 -0
- package/src/skills/instruction-forge/references/agents-md-doctrine.md +50 -0
- package/src/skills/instruction-forge/references/eval-doctrine.md +37 -0
- package/src/skills/instruction-forge/references/skill-doctrine.md +62 -0
- package/src/skills/memory-bank/SKILL.md +11 -90
- package/src/skills/memory-bank/references/anti-patterns.md +33 -0
- package/src/skills/memory-bank/references/product-adoption.md +19 -0
- package/src/skills/memory-bank/references/storage-model.md +21 -0
- package/src/skills/memory-bank/references/structure-and-frequency.md +44 -0
- package/src/skills/reflect/SKILL.md +1 -0
- package/src/skills/session-goal/SKILL.md +7 -54
- package/src/skills/session-goal/references/goal-format.md +26 -0
- package/src/skills/session-goal/references/session-reuse.md +44 -0
- package/src/skills/tdd-with-agents/SKILL.md +11 -101
- package/src/skills/tdd-with-agents/references/advanced-testing-patterns.md +58 -0
- package/src/skills/tdd-with-agents/references/testing-by-layer.md +60 -0
- package/src/skills/visual-review-pipeline/SKILL.md +11 -120
- package/src/skills/visual-review-pipeline/references/findings-schema.md +49 -0
- package/src/skills/visual-review-pipeline/references/workflow-steps.md +111 -0
- package/scripts/hooks/log-session-start.sh +0 -48
- package/scripts/hooks/validate-post-conditions.sh +0 -21
- package/scripts/hooks/validate-talos-scope.sh +0 -50
- package/scripts/hooks/validate-tool-safety.sh +0 -49
- package/src/pantheon/goal-loop.ts +0 -314
- package/src/pantheon/idle-continuation.ts +0 -52
- package/src/pantheon/todo-preserve.ts +0 -301
- package/src/pantheon/tool-ceiling.ts +0 -159
- package/src/pantheon/v2-bridge.ts +0 -153
- package/src/plugin-v2.ts +0 -2954
- package/src/plugins/pantheon-hooks.ts +0 -1433
- package/src/plugins/tui/dist/server-v2.d.ts +0 -30
- package/src/plugins/tui/dist/server-v2.d.ts.map +0 -1
- package/src/plugins/tui/dist/server-v2.js +0 -33
- package/src/plugins/tui/dist/server-v2.js.map +0 -1
- package/src/plugins/tui/dist/tui-v2.d.ts +0 -1039
- package/src/plugins/tui/dist/tui-v2.d.ts.map +0 -1
- package/src/plugins/tui/dist/tui-v2.js +0 -4597
- package/src/plugins/tui/dist/tui-v2.js.map +0 -1
- package/src/plugins/tui/src/index-v2.tsx +0 -4496
- package/src/plugins/tui/src/server-v2.ts +0 -28
- package/src/plugins/tui/tui-v2.ts +0 -2
- /package/src/pantheon/{v2-decision-budget.ts → decision-budget.ts} +0 -0
- /package/src/pantheon/{v2-decision-egress.ts → decision-egress.ts} +0 -0
- /package/src/pantheon/{v2-decision-events.ts → decision-events.ts} +0 -0
- /package/src/pantheon/{v2-decision-heuristic.ts → decision-heuristic.ts} +0 -0
- /package/src/pantheon/{v2-decision-premises.ts → decision-premises.ts} +0 -0
- /package/src/pantheon/{v2-decision-rank.ts → decision-rank.ts} +0 -0
- /package/src/pantheon/{v2-decision-verify.ts → decision-verify.ts} +0 -0
- /package/src/pantheon/{v2-delegation-enforce.ts → delegation-policy.ts} +0 -0
- /package/src/pantheon/{v2-model-overrides.ts → model-overrides.ts} +0 -0
- /package/src/pantheon/{v2-native-decisions.ts → native-decisions.ts} +0 -0
- /package/src/plugins/tui/src/{opencode-v2.d.ts → opencode.d.ts} +0 -0
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* opencode.mjs — OpenCode platform installer
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the
|
|
15
|
-
*
|
|
5
|
+
* Single-generation install: the host must be OpenCode 2.x (`opencode --version`
|
|
6
|
+
* prints "opencode v2.0.22"; the gate in scripts/install/opencode-version.mjs
|
|
7
|
+
* refuses any host it cannot confirm as 2.x BEFORE any write). The registry this
|
|
8
|
+
* installer writes is
|
|
9
|
+
* the plural `plugins` array with the plugin DIRECTORY `src/plugin` in
|
|
10
|
+
* `{ package, options }` form. A singular `plugin` key is legacy: Pantheon refs
|
|
11
|
+
* found there are stripped, third-party loadable entries are carried over to
|
|
12
|
+
* `plugins`, and the (emptied) key is dropped. Legacy V1-shaped config keys
|
|
13
|
+
* (`agent`, `permission`, flat `mcp`, …) are normalized to the V2 shape by
|
|
14
|
+
* normalizeLegacyV1Config before the config is written. Known V2 gaps handled
|
|
15
|
+
* here: top-level `subagent_depth` is migrated to `experimental.subagent_depth`,
|
|
16
|
+
* and the instruction content is consolidated into AGENTS.md, which the host
|
|
17
|
+
* loads.
|
|
16
18
|
*
|
|
17
|
-
* Nothing here isolates host STATE:
|
|
18
|
-
*
|
|
19
|
-
*
|
|
19
|
+
* Nothing here isolates host STATE: one OpenCode store is shared, and the
|
|
20
|
+
* resolver in scripts/install/opencode-state.mjs (not a literal in this file)
|
|
21
|
+
* is what the V2 notice reports.
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
import { createHash } from 'node:crypto'
|
|
@@ -25,6 +27,11 @@ import { homedir } from 'node:os'
|
|
|
25
27
|
import { dirname, isAbsolute, join, relative, resolve } from 'node:path'
|
|
26
28
|
import { copyAgentPrompts, writeAgentsMdManaged } from '../build-agents-md.mjs'
|
|
27
29
|
import { backupWarning, createBackupSet, previewBackupSet } from './backup.mjs'
|
|
30
|
+
import {
|
|
31
|
+
describePluginOptionsReachability,
|
|
32
|
+
formatV2CapabilityNotice,
|
|
33
|
+
v2Capabilities,
|
|
34
|
+
} from './capabilities.mjs'
|
|
28
35
|
import {
|
|
29
36
|
bullet,
|
|
30
37
|
colors,
|
|
@@ -44,9 +51,10 @@ import {
|
|
|
44
51
|
warning,
|
|
45
52
|
} from './cli-ui.mjs'
|
|
46
53
|
import {
|
|
54
|
+
convertLegacyPermissionsToV2,
|
|
47
55
|
mergeContextSandboxBlocks,
|
|
48
56
|
migrateMcpEntrypointPaths,
|
|
49
|
-
|
|
57
|
+
normalizeLegacyV1Config,
|
|
50
58
|
validateMcpV1toV2Source,
|
|
51
59
|
} from './config-migration.mjs'
|
|
52
60
|
import { resolveGlobalConfigDirectory } from './config-paths.mjs'
|
|
@@ -79,7 +87,7 @@ import {
|
|
|
79
87
|
summarizeChanges,
|
|
80
88
|
} from './plan.mjs'
|
|
81
89
|
import { findPlanDrift } from './plan-artifact.mjs'
|
|
82
|
-
import { copyPluginFiles, installPlugin,
|
|
90
|
+
import { copyPluginFiles, installPlugin, unregisterPlugin } from './plugin.mjs'
|
|
83
91
|
import { PROMPT_CANCELED } from './prompt-result.mjs'
|
|
84
92
|
import {
|
|
85
93
|
checkRuntimePrerequisites,
|
|
@@ -95,11 +103,6 @@ import {
|
|
|
95
103
|
} from './shared.mjs'
|
|
96
104
|
import { createInitialState, hasState, readState, setComponentState, writeState } from './state.mjs'
|
|
97
105
|
import { strings } from './strings.mjs'
|
|
98
|
-
import {
|
|
99
|
-
describePluginOptionsReachability,
|
|
100
|
-
formatV2CapabilityNotice,
|
|
101
|
-
v2Capabilities,
|
|
102
|
-
} from './v2-capabilities.mjs'
|
|
103
106
|
import { setupVenv, venvPythonPath } from './venv.mjs'
|
|
104
107
|
import { assertNoSymlinkAncestors, assertPathWithin, assertSafeRemoval } from './verify.mjs'
|
|
105
108
|
|
|
@@ -184,11 +187,10 @@ function walkFiles(root, base = root, out = []) {
|
|
|
184
187
|
*
|
|
185
188
|
* @param {string} target
|
|
186
189
|
* @param {Set<string>} componentSet
|
|
187
|
-
* @param {string} version
|
|
188
190
|
* @param {boolean} isGlobal
|
|
189
191
|
* @returns {{ entries: string[], notRevertible: string[] }}
|
|
190
192
|
*/
|
|
191
|
-
function collectInstallBackupEntries(target, componentSet,
|
|
193
|
+
function collectInstallBackupEntries(target, componentSet, isGlobal) {
|
|
192
194
|
const entries = []
|
|
193
195
|
const notRevertible = []
|
|
194
196
|
const rel = (abs) => relative(target, abs)
|
|
@@ -219,7 +221,9 @@ function collectInstallBackupEntries(target, componentSet, version, isGlobal) {
|
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
const baseDir = isGlobal ? target : join(target, '.opencode')
|
|
222
|
-
|
|
224
|
+
// V2 layout: the host's agent loader scans <config-dir>/{agent,agents}/**, so
|
|
225
|
+
// project agents live at ./agents; global installs are flat.
|
|
226
|
+
const agentPrefix = 'agents'
|
|
223
227
|
const agentDir = join(target, agentPrefix)
|
|
224
228
|
|
|
225
229
|
// Always touched.
|
|
@@ -254,7 +258,7 @@ function collectInstallBackupEntries(target, componentSet, version, isGlobal) {
|
|
|
254
258
|
addSource(join(ROOT, 'prompts'), join(target, 'prompts'))
|
|
255
259
|
}
|
|
256
260
|
if (componentSet.has('commands')) {
|
|
257
|
-
const commandDir =
|
|
261
|
+
const commandDir = 'commands'
|
|
258
262
|
addExisting(join(target, commandDir))
|
|
259
263
|
addSource(join(ROOT, 'commands'), join(target, commandDir), (r) => r.endsWith('.md'))
|
|
260
264
|
}
|
|
@@ -273,18 +277,19 @@ function collectInstallBackupEntries(target, componentSet, version, isGlobal) {
|
|
|
273
277
|
addFile(join(dstPluginDir, 'tui.ts'))
|
|
274
278
|
addFile(join(dstPluginDir, 'index.ts'))
|
|
275
279
|
notRevertible.push(rel(join(dstPluginDir, 'node_modules')))
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
//
|
|
280
|
+
// tui.json is legacy cleanup: this install may strip stale Pantheon refs
|
|
281
|
+
// from EVERY location the loader reads, so the target's own tui.json is
|
|
282
|
+
// captured and the out-of-target global copies are recorded (not copied).
|
|
283
|
+
const projectTui = join(baseDir, 'tui.json')
|
|
284
|
+
addFile(projectTui)
|
|
285
|
+
for (const loc of tuiConfigLocations(target)) {
|
|
286
|
+
if (resolve(loc) !== resolve(projectTui)) notRevertible.push(loc)
|
|
287
|
+
}
|
|
288
|
+
// The single terminal-client config, which this install also edits (it
|
|
285
289
|
// cancels the builtin Context sidebar block). Captured so `restore` reverts
|
|
286
|
-
// it byte-for-byte like every other file we touch.
|
|
287
|
-
|
|
290
|
+
// it byte-for-byte like every other file we touch. It exists only in a
|
|
291
|
+
// global config dir (V2 has no project-local client config).
|
|
292
|
+
if (isGlobal) addFile(join(baseDir, V2_CLI_CONFIG_FILENAME))
|
|
288
293
|
}
|
|
289
294
|
if (componentSet.has('runtime')) {
|
|
290
295
|
const runtimeTarget = isGlobal ? target : join(target, '.opencode')
|
|
@@ -352,22 +357,17 @@ const PRODUCT_CONFIG_DEFAULTS = Object.freeze({
|
|
|
352
357
|
* new agent they are the seed. Everything else on an existing entry is the
|
|
353
358
|
* user's and is left alone.
|
|
354
359
|
*
|
|
355
|
-
* `
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* KNOWN DEBT: `permission` is the V1 spelling. V2 reads `permissions`, so an
|
|
361
|
-
* agent can carry both keys after an install and the V1 one becomes dead weight.
|
|
362
|
-
* Tracked for the next slice; changing it here would change what an install
|
|
363
|
-
* writes.
|
|
360
|
+
* `permissions` is the V2 spelling (a rule array). The canonical agent sources
|
|
361
|
+
* and this installer write ONLY that spelling; a legacy `permission` object on
|
|
362
|
+
* an existing entry is the user's data and is normalized by
|
|
363
|
+
* normalizeLegacyV1Config, never rewritten here.
|
|
364
364
|
*
|
|
365
365
|
* @type {readonly string[]}
|
|
366
366
|
*/
|
|
367
367
|
export const MANAGED_FIELDS = Object.freeze([
|
|
368
368
|
'temperature',
|
|
369
369
|
'color',
|
|
370
|
-
'
|
|
370
|
+
'permissions',
|
|
371
371
|
'mode',
|
|
372
372
|
'hidden',
|
|
373
373
|
'disable_model_invocation',
|
|
@@ -397,11 +397,10 @@ const PANTHEON_MCP_SERVERS = Object.freeze(PANTHEON_MCP_SERVER_ENTRIES.map((entr
|
|
|
397
397
|
export { normalizeMcpPermissionSegment, PANTHEON_MCP_SERVERS }
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
|
-
* Translate an agent's `mcp_tools` frontmatter into per-tool native
|
|
401
|
-
*
|
|
402
|
-
* punctuation
|
|
403
|
-
*
|
|
404
|
-
* deny; unrelated user MCP servers are not touched.
|
|
400
|
+
* Translate an agent's `mcp_tools` frontmatter into per-tool native permission
|
|
401
|
+
* action names. Server and tool names emit both the original and the
|
|
402
|
+
* punctuation-normalized alias spelling. Unlisted bundled Pantheon servers
|
|
403
|
+
* default to deny; unrelated user MCP servers are not touched.
|
|
405
404
|
*
|
|
406
405
|
* @param {Record<string, 'all' | string[]>} mcpTools
|
|
407
406
|
* @returns {Record<string, 'allow' | 'deny'>}
|
|
@@ -642,7 +641,7 @@ export function resolveStablePantheonRoot(root = ROOT) {
|
|
|
642
641
|
'node_modules',
|
|
643
642
|
'pantheon-opencode',
|
|
644
643
|
)
|
|
645
|
-
if (existsSync(join(globalCandidate, 'src', 'plugin
|
|
644
|
+
if (existsSync(join(globalCandidate, 'src', 'plugin', 'index.ts'))) {
|
|
646
645
|
return { root: globalCandidate, volatile: false }
|
|
647
646
|
}
|
|
648
647
|
return { root, volatile: true }
|
|
@@ -653,9 +652,10 @@ export function resolveInstalledPlugin(plugin) {
|
|
|
653
652
|
const normalized = normalizePluginRef(plugin)
|
|
654
653
|
const stable = resolveStablePantheonRoot()
|
|
655
654
|
if (PANTHEON_PLUGIN_IDENTITIES.has(normalized)) return join(stable.root, normalized)
|
|
656
|
-
//
|
|
657
|
-
// plugin
|
|
658
|
-
|
|
655
|
+
// The file spelling of the entry (pre-directory-contract installs and the
|
|
656
|
+
// `./plugin` package export target) resolves to the installed plugin
|
|
657
|
+
// DIRECTORY so the loader accepts it.
|
|
658
|
+
if (normalized === PANTHEON_PLUGIN_FILE) return join(stable.root, PANTHEON_PLUGIN)
|
|
659
659
|
const identity = managedPluginIdentity(plugin)
|
|
660
660
|
if (identity !== null && isAbsolute(normalized)) {
|
|
661
661
|
return INSTALLED_PANTHEON_PLUGIN_PATHS.get(identity) ?? plugin
|
|
@@ -689,7 +689,7 @@ function looksLikePluginPath(value) {
|
|
|
689
689
|
* This is the gate for the V1→V2 migration: the V1 singular `plugin` list is
|
|
690
690
|
* ignored by the V2 host, but moving an entry there into `plugins` only helps
|
|
691
691
|
* when the loader accepts it. The loader's contract (documented on
|
|
692
|
-
*
|
|
692
|
+
* PANTHEON_PLUGIN and proven by sandbox probes) is:
|
|
693
693
|
* - a DIRECTORY containing a real index.ts/index.js loads;
|
|
694
694
|
* - a file path is rejected ("must be a directory");
|
|
695
695
|
* - a package shorthand is resolved through `npm install` and dies with
|
|
@@ -701,7 +701,7 @@ function looksLikePluginPath(value) {
|
|
|
701
701
|
* @param {string} configDir the config directory the loader resolves against
|
|
702
702
|
* @returns {{ loadable: boolean, reason: 'directory'|'file'|'missing'|'npm-spec'|'unverifiable', resolved: string|null }}
|
|
703
703
|
*/
|
|
704
|
-
export function
|
|
704
|
+
export function pluginEntryLoadability(entry, configDir) {
|
|
705
705
|
if (typeof entry !== 'string' || entry.trim() === '') {
|
|
706
706
|
return { loadable: false, reason: 'unverifiable', resolved: null }
|
|
707
707
|
}
|
|
@@ -739,29 +739,27 @@ function describePluginEntry(entry) {
|
|
|
739
739
|
return typeof entry === 'string' ? entry : JSON.stringify(entry)
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
//
|
|
742
|
+
// The removed single-file generation registered `src/plugin.ts` (today the
|
|
743
|
+
// real entry FILE that the directory shim re-exports) and
|
|
744
|
+
// `src/plugins/pantheon-hooks.ts` (gone from this package). The hooks identity
|
|
745
|
+
// survives ONLY so stale refs can be stripped from a config (cleanup of an old
|
|
746
|
+
// install); the installer NEVER registers it. The file spelling is an ALIAS of
|
|
747
|
+
// the directory identity below, never a registration of its own.
|
|
748
|
+
const PANTHEON_PLUGIN_FILE = 'src/plugin.ts'
|
|
749
|
+
const PANTHEON_LEGACY_HOOKS = 'src/plugins/pantheon-hooks.ts'
|
|
750
|
+
// Canonical entry is the plugin DIRECTORY (host loader contract: entries
|
|
745
751
|
// must be dirs with a real index.ts — file paths warn "must be a directory",
|
|
746
|
-
// symlinks are ignored). The shim at src/plugin
|
|
747
|
-
// real entry src/plugin
|
|
748
|
-
const
|
|
749
|
-
//
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
const
|
|
753
|
-
const PANTHEON_V2_EXPORT = 'pantheon-opencode/plugin-v2'
|
|
754
|
-
const PANTHEON_PACKAGE_REF = /^pantheon-opencode(?:@[^/]+)?(?:\/(plugin|plugin-v2))?$/
|
|
755
|
-
const PANTHEON_PLUGIN_IDENTITIES = new Set([
|
|
756
|
-
PANTHEON_V1_PLUGIN,
|
|
757
|
-
PANTHEON_V1_HOOKS,
|
|
758
|
-
PANTHEON_V2_PLUGIN,
|
|
759
|
-
])
|
|
752
|
+
// symlinks are ignored). The shim at src/plugin/index.ts re-exports the
|
|
753
|
+
// real entry src/plugin.ts (single source of truth).
|
|
754
|
+
const PANTHEON_PLUGIN = 'src/plugin'
|
|
755
|
+
// Package export spelling; recognized as the same plugin for dedup/cleanup.
|
|
756
|
+
const PANTHEON_EXPORT = 'pantheon-opencode/plugin'
|
|
757
|
+
const PANTHEON_PACKAGE_REF = /^pantheon-opencode(?:@[^/]+)?(?:\/(plugin|plugin))?$/
|
|
758
|
+
const PANTHEON_PLUGIN_IDENTITIES = new Set([PANTHEON_LEGACY_HOOKS, PANTHEON_PLUGIN])
|
|
760
759
|
|
|
761
760
|
const INSTALLED_PANTHEON_PLUGIN_PATHS = new Map([
|
|
762
|
-
[
|
|
763
|
-
[
|
|
764
|
-
[PANTHEON_V2_PLUGIN, resolve(ROOT, PANTHEON_V2_PLUGIN)],
|
|
761
|
+
[PANTHEON_LEGACY_HOOKS, resolve(ROOT, PANTHEON_LEGACY_HOOKS)],
|
|
762
|
+
[PANTHEON_PLUGIN, resolve(ROOT, PANTHEON_PLUGIN)],
|
|
765
763
|
])
|
|
766
764
|
|
|
767
765
|
function normalizePluginPath(ref) {
|
|
@@ -786,18 +784,14 @@ function managedPluginIdentity(ref) {
|
|
|
786
784
|
// copy before registering the current package path. Do not match similarly
|
|
787
785
|
// named third-party packages such as `pantheon-opencode-fork`.
|
|
788
786
|
const packageRef = normalized.match(PANTHEON_PACKAGE_REF)
|
|
789
|
-
if (packageRef !== null)
|
|
790
|
-
if (packageRef[1] === 'plugin') return PANTHEON_V1_PLUGIN
|
|
791
|
-
return PANTHEON_V2_PLUGIN
|
|
792
|
-
}
|
|
787
|
+
if (packageRef !== null) return PANTHEON_PLUGIN
|
|
793
788
|
|
|
794
789
|
if (PANTHEON_PLUGIN_IDENTITIES.has(normalized)) return normalized
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
return PANTHEON_V2_PLUGIN
|
|
790
|
+
// The entry FILE and the package export are spellings of the directory
|
|
791
|
+
// identity, so dedup and cleanup treat them as one plugin.
|
|
792
|
+
if (normalized === PANTHEON_PLUGIN_FILE) return PANTHEON_PLUGIN
|
|
793
|
+
if (normalized === PANTHEON_EXPORT || normalized.startsWith(`${PANTHEON_EXPORT}@`)) {
|
|
794
|
+
return PANTHEON_PLUGIN
|
|
801
795
|
}
|
|
802
796
|
|
|
803
797
|
if (isAbsolute(normalized)) {
|
|
@@ -805,11 +799,11 @@ function managedPluginIdentity(ref) {
|
|
|
805
799
|
for (const [identity, installedPath] of INSTALLED_PANTHEON_PLUGIN_PATHS) {
|
|
806
800
|
if (absolutePath === normalizePluginPath(installedPath)) return identity
|
|
807
801
|
}
|
|
808
|
-
//
|
|
809
|
-
//
|
|
810
|
-
// ROOT-scoped: third-party paths ending in src/plugin
|
|
811
|
-
if (absolutePath === normalizePluginPath(resolve(ROOT,
|
|
812
|
-
return
|
|
802
|
+
// A file path inside OUR installed package (pre-directory-contract
|
|
803
|
+
// installs registered src/plugin.ts) migrates to the directory identity.
|
|
804
|
+
// ROOT-scoped: third-party paths ending in src/plugin.ts stay theirs.
|
|
805
|
+
if (absolutePath === normalizePluginPath(resolve(ROOT, PANTHEON_PLUGIN_FILE))) {
|
|
806
|
+
return PANTHEON_PLUGIN
|
|
813
807
|
}
|
|
814
808
|
// beta.5: stale refs from OTHER installed copies of this package (older
|
|
815
809
|
// nvm prefixes, npx cache hashes). Only paths inside
|
|
@@ -821,10 +815,9 @@ function managedPluginIdentity(ref) {
|
|
|
821
815
|
const markerIndex = withSlashes.lastIndexOf(installedMarker)
|
|
822
816
|
if (markerIndex !== -1) {
|
|
823
817
|
const suffix = withSlashes.slice(markerIndex + installedMarker.length)
|
|
824
|
-
if (suffix ===
|
|
825
|
-
if (suffix ===
|
|
826
|
-
if (suffix ===
|
|
827
|
-
if (suffix === PANTHEON_V2_LEGACY_FILE) return PANTHEON_V2_PLUGIN
|
|
818
|
+
if (suffix === PANTHEON_LEGACY_HOOKS) return PANTHEON_LEGACY_HOOKS
|
|
819
|
+
if (suffix === PANTHEON_PLUGIN) return PANTHEON_PLUGIN
|
|
820
|
+
if (suffix === PANTHEON_PLUGIN_FILE) return PANTHEON_PLUGIN
|
|
828
821
|
}
|
|
829
822
|
}
|
|
830
823
|
|
|
@@ -925,10 +918,10 @@ export function ensureTuiCopyRegistered(config, { tuiCopyDir }) {
|
|
|
925
918
|
* @throws {Error} when the legacy block or the existing V2 option is null or
|
|
926
919
|
* type-invalid (checked before any config write)
|
|
927
920
|
*/
|
|
928
|
-
export function
|
|
921
|
+
export function applyContextSandboxToPluginEntry(plugins, legacySandbox) {
|
|
929
922
|
if (!Array.isArray(plugins)) return plugins
|
|
930
923
|
|
|
931
|
-
const index = plugins.findIndex((ref) => pluginReferenceIdentity(ref) ===
|
|
924
|
+
const index = plugins.findIndex((ref) => pluginReferenceIdentity(ref) === PANTHEON_PLUGIN)
|
|
932
925
|
if (index === -1) return plugins
|
|
933
926
|
|
|
934
927
|
const entry = plugins[index]
|
|
@@ -963,7 +956,7 @@ export function applyContextSandboxToV2Plugins(plugins, legacySandbox) {
|
|
|
963
956
|
return plugins
|
|
964
957
|
}
|
|
965
958
|
|
|
966
|
-
export {
|
|
959
|
+
export { resolveOpenCodeVersion, unsupportedHostMessage } from './opencode-version.mjs'
|
|
967
960
|
|
|
968
961
|
/**
|
|
969
962
|
* Detect whether `target` is the user's global OpenCode installation directory
|
|
@@ -993,9 +986,8 @@ export function isGlobalConfigDir(target) {
|
|
|
993
986
|
*
|
|
994
987
|
* <configDir>/plugins/pantheon-tui (tui.ts + dist/ + package manifests)
|
|
995
988
|
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
-
* dist/tui-v2.js.
|
|
989
|
+
* The copy is loaded only through the `plugins` entry (see
|
|
990
|
+
* ensureTuiCopyRegistered); its local shim re-exports dist/tui.js.
|
|
999
991
|
*
|
|
1000
992
|
* @param {string} configDir - OpenCode config directory (target for global
|
|
1001
993
|
* installs, <target>/.opencode for project installs)
|
|
@@ -1048,7 +1040,7 @@ export const CONTEXT_SIDEBAR_NEGATION = '-opencode.sidebar.context'
|
|
|
1048
1040
|
* i.e. the copy under the config dir — never the in-package build artifact,
|
|
1049
1041
|
* which a package upgrade replaces independently of what was deployed.
|
|
1050
1042
|
*/
|
|
1051
|
-
export const
|
|
1043
|
+
export const TUI_BUNDLE_RELATIVE_PATH = 'dist/tui.js'
|
|
1052
1044
|
|
|
1053
1045
|
/**
|
|
1054
1046
|
* Stable marker proving the deployed TUI bundle renders Pantheon's own Context
|
|
@@ -1059,7 +1051,7 @@ export const TUI_V2_BUNDLE_RELATIVE_PATH = 'dist/tui-v2.js'
|
|
|
1059
1051
|
* tsdown/rolldown (or any minifier): mangling renames only non-exported
|
|
1060
1052
|
* bindings, because consumers resolve exports by name. The bundle also cannot
|
|
1061
1053
|
* tree-shake it away — the sidebar imports it, and
|
|
1062
|
-
* `tests/tui-
|
|
1054
|
+
* `tests/tui-sidebar.test.mjs` imports it from `dist/tui.js`, so a build
|
|
1063
1055
|
* that drops the export fails the suite.
|
|
1064
1056
|
*
|
|
1065
1057
|
* A rebuild that changes the block's user-facing copy or internals keeps the
|
|
@@ -1069,13 +1061,13 @@ export const TUI_V2_BUNDLE_RELATIVE_PATH = 'dist/tui-v2.js'
|
|
|
1069
1061
|
export const CONTEXT_BLOCK_BUNDLE_MARKER = 'contextBlockRows'
|
|
1070
1062
|
|
|
1071
1063
|
/**
|
|
1072
|
-
* Path of the
|
|
1064
|
+
* Path of the TUI bundle inside an installed config dir.
|
|
1073
1065
|
*
|
|
1074
1066
|
* @param {string} configDir - OpenCode config directory
|
|
1075
|
-
* @returns {string} absolute path of the copied `dist/tui
|
|
1067
|
+
* @returns {string} absolute path of the copied `dist/tui.js`
|
|
1076
1068
|
*/
|
|
1077
1069
|
export function resolveInstalledTuiBundlePath(configDir) {
|
|
1078
|
-
return join(resolveTuiCopyTarget(configDir),
|
|
1070
|
+
return join(resolveTuiCopyTarget(configDir), TUI_BUNDLE_RELATIVE_PATH)
|
|
1079
1071
|
}
|
|
1080
1072
|
|
|
1081
1073
|
/**
|
|
@@ -1084,7 +1076,7 @@ export function resolveInstalledTuiBundlePath(configDir) {
|
|
|
1084
1076
|
* Deliberately a plain byte scan: the answer must not depend on importing the
|
|
1085
1077
|
* bundle (the host API it needs is absent while installing).
|
|
1086
1078
|
*
|
|
1087
|
-
* @param {unknown} bundleText - contents of the deployed `dist/tui
|
|
1079
|
+
* @param {unknown} bundleText - contents of the deployed `dist/tui.js`
|
|
1088
1080
|
* @returns {{ ok: boolean, reason: string }} `reason` is empty when `ok`
|
|
1089
1081
|
*/
|
|
1090
1082
|
export function bundleProvidesContextBlock(bundleText) {
|
|
@@ -1117,7 +1109,7 @@ export function bundleProvidesContextBlock(bundleText) {
|
|
|
1117
1109
|
*/
|
|
1118
1110
|
export function inspectContextBlockCapability(configDir, { dryRun = false } = {}) {
|
|
1119
1111
|
const installedPath = resolveInstalledTuiBundlePath(configDir)
|
|
1120
|
-
const sourcePath = join(ROOT, 'src', 'plugins', 'tui',
|
|
1112
|
+
const sourcePath = join(ROOT, 'src', 'plugins', 'tui', TUI_BUNDLE_RELATIVE_PATH)
|
|
1121
1113
|
const bundlePath = dryRun && !existsSync(installedPath) ? sourcePath : installedPath
|
|
1122
1114
|
let bundleText
|
|
1123
1115
|
try {
|
|
@@ -1266,43 +1258,39 @@ export function applyContextSidebarNegation(
|
|
|
1266
1258
|
}
|
|
1267
1259
|
|
|
1268
1260
|
/**
|
|
1269
|
-
* Sync the Pantheon TUI plugin payload
|
|
1270
|
-
*
|
|
1261
|
+
* Sync the Pantheon TUI plugin payload. The host does not discover the copy
|
|
1262
|
+
* through a tui.json; it loads the copy's server ONLY through the config
|
|
1271
1263
|
* `plugins` entry written by ensureTuiCopyRegistered().
|
|
1272
1264
|
*
|
|
1273
1265
|
* Contract (single source of truth):
|
|
1274
1266
|
* 1. ALWAYS copy src/plugins/tui → <configDir>/plugins/pantheon-tui with the
|
|
1275
|
-
*
|
|
1267
|
+
* host entrypoints and compiled bundle. The copy is idempotent.
|
|
1276
1268
|
* 2. Clean stale Pantheon TUI refs from ALL tui.json locations OpenCode
|
|
1277
1269
|
* loads — ~/.opencode, $XDG_CONFIG_HOME/opencode and
|
|
1278
1270
|
* <target>/.opencode — covering every old reference shape: dist file
|
|
1279
1271
|
* paths, in-package src/plugins/tui dirs, bare plugins/pantheon-tui
|
|
1280
1272
|
* copies, and npx paths. A stale ref left in the non-target location
|
|
1281
|
-
* would still be loaded and break the TUI.
|
|
1282
|
-
*
|
|
1283
|
-
* write a project tui.json entry; its `plugins` registration is written
|
|
1284
|
-
* by the config merge (ensureTuiCopyRegistered).
|
|
1273
|
+
* would still be loaded and break the TUI. tui.json is the legacy
|
|
1274
|
+
* discovery file of the removed generation: cleaned, never written.
|
|
1285
1275
|
*
|
|
1286
1276
|
* @param {string} target - install target directory
|
|
1287
1277
|
* @param {object} [opts]
|
|
1288
1278
|
* @param {boolean} [opts.isGlobal=false] - flat global layout vs .opencode/
|
|
1289
1279
|
* @param {boolean} [opts.dryRun=false]
|
|
1290
1280
|
* @param {(change: object) => void} [opts.recorder] - optional change recorder for preview
|
|
1291
|
-
* @returns {'
|
|
1281
|
+
* @returns {'skipped'} always — no tui.json registration is written
|
|
1292
1282
|
*/
|
|
1293
1283
|
export function syncTuiRegistration(
|
|
1294
1284
|
target,
|
|
1295
1285
|
{
|
|
1296
1286
|
isGlobal = false,
|
|
1297
1287
|
dryRun = false,
|
|
1298
|
-
version = 'v1',
|
|
1299
1288
|
recorder = null,
|
|
1300
1289
|
reviewedRemovals = null,
|
|
1301
1290
|
reviewedSnapshots = null,
|
|
1302
1291
|
} = {},
|
|
1303
1292
|
) {
|
|
1304
1293
|
const configDir = isGlobal ? target : join(target, '.opencode')
|
|
1305
|
-
const targetTuiConfigPath = join(configDir, 'tui.json')
|
|
1306
1294
|
|
|
1307
1295
|
// 1. Copy the host-specific plugin into the target config's
|
|
1308
1296
|
// plugins/pantheon-tui. This keeps the installed entry hermetic.
|
|
@@ -1319,7 +1307,6 @@ export function syncTuiRegistration(
|
|
|
1319
1307
|
}
|
|
1320
1308
|
const copyResult = copyPluginFiles(tuiSrcDir, tuiCopyDir, {
|
|
1321
1309
|
dryRun,
|
|
1322
|
-
version,
|
|
1323
1310
|
recorder,
|
|
1324
1311
|
reviewedRemovals,
|
|
1325
1312
|
reviewedSnapshots,
|
|
@@ -1344,14 +1331,10 @@ export function syncTuiRegistration(
|
|
|
1344
1331
|
})
|
|
1345
1332
|
}
|
|
1346
1333
|
|
|
1347
|
-
// The
|
|
1348
|
-
//
|
|
1349
|
-
//
|
|
1350
|
-
|
|
1351
|
-
if (version === 'v2') return 'skipped'
|
|
1352
|
-
|
|
1353
|
-
// 3. Register the copied directory in the selected target only.
|
|
1354
|
-
return registerPlugin(targetTuiConfigPath, tuiCopyDir, { dryRun, recorder })
|
|
1334
|
+
// The host loads the copy's server-side RPC only from the config `plugins`
|
|
1335
|
+
// list — ensureTuiCopyRegistered writes that entry during the config merge,
|
|
1336
|
+
// so no tui.json is written here.
|
|
1337
|
+
return 'skipped'
|
|
1355
1338
|
}
|
|
1356
1339
|
|
|
1357
1340
|
/**
|
|
@@ -1470,30 +1453,24 @@ export function setupRuntimePhase(
|
|
|
1470
1453
|
* config in place — the migration that makes the rename non-breaking.
|
|
1471
1454
|
*
|
|
1472
1455
|
* @param {object} config - full config object (mutated in place)
|
|
1473
|
-
* @param {{ runtimeTarget: string, venvPython: string
|
|
1456
|
+
* @param {{ runtimeTarget: string, venvPython: string }} ctx
|
|
1474
1457
|
* @returns {{ healed: number, warnings: string[], servers: string[] }} number of
|
|
1475
1458
|
* stale path strings rewritten, one warning per MCP permission the host
|
|
1476
1459
|
* cannot enforce, and the server names this call actually seeded (write
|
|
1477
1460
|
* order) — the dry-run preview reports exactly these
|
|
1478
1461
|
*/
|
|
1479
|
-
export function applyMcpServerEntries(config, { runtimeTarget, venvPython
|
|
1480
|
-
if (
|
|
1481
|
-
|
|
1482
|
-
else config.mcp = {}
|
|
1483
|
-
} else {
|
|
1484
|
-
config.mcp = config.mcp || {}
|
|
1485
|
-
}
|
|
1462
|
+
export function applyMcpServerEntries(config, { runtimeTarget, venvPython }) {
|
|
1463
|
+
if (Object.hasOwn(config, 'mcp')) validateMcpV1toV2Source(config.mcp)
|
|
1464
|
+
else config.mcp = {}
|
|
1486
1465
|
let serverMap = config.mcp
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
config.mcp = { servers: serverMap }
|
|
1496
|
-
}
|
|
1466
|
+
const { hasV2ServersMap, legacyServersToggle } = validateMcpV1toV2Source(config.mcp)
|
|
1467
|
+
const existingServers = config.mcp.servers
|
|
1468
|
+
if (hasV2ServersMap) {
|
|
1469
|
+
serverMap = existingServers
|
|
1470
|
+
} else {
|
|
1471
|
+
serverMap = { ...config.mcp }
|
|
1472
|
+
if (legacyServersToggle) delete serverMap.servers
|
|
1473
|
+
config.mcp = { servers: serverMap }
|
|
1497
1474
|
}
|
|
1498
1475
|
const healed = migrateMcpEntrypointPaths(serverMap)
|
|
1499
1476
|
|
|
@@ -1505,53 +1482,25 @@ export function applyMcpServerEntries(config, { runtimeTarget, venvPython, versi
|
|
|
1505
1482
|
type: 'local',
|
|
1506
1483
|
cwd: runtimeTarget,
|
|
1507
1484
|
command: [venvPython, entry.script],
|
|
1508
|
-
...(version === 'v1' ? { enabled: true } : {}),
|
|
1509
1485
|
}
|
|
1510
1486
|
servers.push(entry.name)
|
|
1511
1487
|
}
|
|
1512
1488
|
|
|
1513
|
-
//
|
|
1514
|
-
//
|
|
1515
|
-
//
|
|
1516
|
-
//
|
|
1517
|
-
// absent a rule, MCP servers remain accessible without a prompt.
|
|
1518
|
-
if (version === 'v1') {
|
|
1519
|
-
config.permission = config.permission || {}
|
|
1520
|
-
config.permission.mcp = config.permission.mcp || {}
|
|
1521
|
-
if (!config.permission.mcp['pantheon-resources']) {
|
|
1522
|
-
config.permission.mcp['pantheon-resources'] = 'allow'
|
|
1523
|
-
}
|
|
1524
|
-
if (!config.permission.mcp['pantheon-code-mode']) {
|
|
1525
|
-
config.permission.mcp['pantheon-code-mode'] = 'ask'
|
|
1526
|
-
}
|
|
1527
|
-
if (!config.permission.mcp['pantheon-memory']) {
|
|
1528
|
-
config.permission.mcp['pantheon-memory'] = 'allow'
|
|
1529
|
-
}
|
|
1530
|
-
if (!config.permission.mcp['pantheon-persistence']) {
|
|
1531
|
-
config.permission.mcp['pantheon-persistence'] = 'allow'
|
|
1532
|
-
}
|
|
1533
|
-
if (!config.permission.mcp['pantheon-vision']) {
|
|
1534
|
-
config.permission.mcp['pantheon-vision'] = 'ask'
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
// Report every `ask` entry, whether just seeded or left by a previous
|
|
1539
|
-
// install: the config claims a gate the host does not apply. V1's MCP
|
|
1540
|
-
// permission semantics were not measured, so the warning is V2-only.
|
|
1489
|
+
// Report every legacy `permission.mcp.<server>: ask` entry still sitting in
|
|
1490
|
+
// the config, whether or not this pass converts it: the config claims a gate
|
|
1491
|
+
// the host does not apply. Seeding no legacy MCP defaults — absent an
|
|
1492
|
+
// explicit rule, MCP servers remain accessible without a prompt.
|
|
1541
1493
|
const askCount = Object.values(config.permission?.mcp ?? {}).filter(
|
|
1542
1494
|
(effect) => effect === 'ask',
|
|
1543
1495
|
).length
|
|
1544
|
-
const warnings =
|
|
1545
|
-
|
|
1496
|
+
const warnings = [
|
|
1497
|
+
...(askCount > 0
|
|
1546
1498
|
? [
|
|
1547
|
-
|
|
1548
|
-
? [
|
|
1549
|
-
`${askCount} legacy MCP ask rule(s) cannot be enforced; run setup for an explicit policy choice.`,
|
|
1550
|
-
]
|
|
1551
|
-
: []),
|
|
1552
|
-
'V2 Pantheon MCP servers without an explicit permission rule remain accessible without a prompt.',
|
|
1499
|
+
`${askCount} legacy MCP ask rule(s) cannot be enforced; run setup for an explicit policy choice.`,
|
|
1553
1500
|
]
|
|
1554
|
-
: []
|
|
1501
|
+
: []),
|
|
1502
|
+
'V2 Pantheon MCP servers without an explicit permission rule remain accessible without a prompt.',
|
|
1503
|
+
]
|
|
1555
1504
|
|
|
1556
1505
|
return { healed, warnings, servers }
|
|
1557
1506
|
}
|
|
@@ -1696,10 +1645,10 @@ async function installPass(
|
|
|
1696
1645
|
let reviewedSnapshots = null
|
|
1697
1646
|
const S = strings()
|
|
1698
1647
|
|
|
1699
|
-
// Configure the UI channel BEFORE any output: the
|
|
1700
|
-
//
|
|
1701
|
-
//
|
|
1702
|
-
// much later, so
|
|
1648
|
+
// Configure the UI channel BEFORE any output: the host gate below refuses an
|
|
1649
|
+
// unconfirmable host, and a quiet preview (doctor's internal preflight,
|
|
1650
|
+
// --json) must not print anything before its caller decides. Quiet used to be
|
|
1651
|
+
// applied much later, so warnings escaped every silent preview.
|
|
1703
1652
|
configure({ dryRun, quiet: opts.quiet === true })
|
|
1704
1653
|
|
|
1705
1654
|
// Beta 11 (Setup phase 1): a dry pass records every writer's intended change
|
|
@@ -1745,48 +1694,35 @@ async function installPass(
|
|
|
1745
1694
|
_lastRun = { target, entries: ownRecorder?.entries ?? [], backupDir: null, applied: false }
|
|
1746
1695
|
}
|
|
1747
1696
|
|
|
1748
|
-
//
|
|
1749
|
-
//
|
|
1750
|
-
//
|
|
1751
|
-
//
|
|
1752
|
-
//
|
|
1753
|
-
// literal, and claims no service port because nothing binds one.
|
|
1754
|
-
// Default to 'auto' so a flagless run resolves against the actual host. A
|
|
1755
|
-
// hardcoded 'v1' here (or in bin/pantheon-init.mjs) is what shipped the bug:
|
|
1756
|
-
// the V1 branch writes .ts file paths that a 2.x host drops from the config.
|
|
1757
|
-
// `opts` is forwarded as the resolver's options bag so a caller (and CI) can
|
|
1758
|
-
// pin env/probe instead of spawning a real host binary.
|
|
1697
|
+
// Single-generation gate: the host must be OpenCode 2.x. Any host the probe
|
|
1698
|
+
// cannot CONFIRM as 2.x throws HERE, before any file is written — there is
|
|
1699
|
+
// no generation to fall back to and no assumed-version plan. The resolver's
|
|
1700
|
+
// seam (env/probe/binary) is forwarded explicitly so unrelated installer
|
|
1701
|
+
// options can never leak into the probe input.
|
|
1759
1702
|
//
|
|
1760
|
-
// A DRY RUN probes the host too
|
|
1761
|
-
//
|
|
1762
|
-
//
|
|
1763
|
-
// a preview
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
let versionFallback = null
|
|
1769
|
-
const version = resolveOpenCodeVersion(opts.version ?? 'auto', {
|
|
1770
|
-
...opts,
|
|
1703
|
+
// A DRY RUN probes the host too: plan and apply must make the SAME
|
|
1704
|
+
// decision. The probe runs in a throwaway state directory, and the dry run
|
|
1705
|
+
// bounds it with the shorter DRY_RUN_PROBE_TIMEOUT_MS so a hanging host
|
|
1706
|
+
// cannot stall a preview.
|
|
1707
|
+
const version = resolveOpenCodeVersion({
|
|
1708
|
+
env: opts.env,
|
|
1709
|
+
binary: opts.binary,
|
|
1710
|
+
probe: opts.probe,
|
|
1771
1711
|
probeTimeoutMs: dryRun ? DRY_RUN_PROBE_TIMEOUT_MS : undefined,
|
|
1772
|
-
onFallback: (reason) => {
|
|
1773
|
-
versionFallback = reason
|
|
1774
|
-
},
|
|
1775
1712
|
})
|
|
1776
|
-
if (
|
|
1713
|
+
if (opts.preset) {
|
|
1777
1714
|
throw new Error(
|
|
1778
|
-
'--preset is not supported
|
|
1779
|
-
'Configure models using
|
|
1715
|
+
'--preset is not supported because the legacy active-preset marker is not read. ' +
|
|
1716
|
+
'Configure models using native OpenCode configuration instead.',
|
|
1780
1717
|
)
|
|
1781
1718
|
}
|
|
1782
|
-
const versionAssumed = dryRun && versionFallback !== null
|
|
1783
1719
|
// Both V2 notices belong to the run the USER started, not to the internal
|
|
1784
1720
|
// plan pass the gate spawns. That pass runs with the same output channel, so
|
|
1785
1721
|
// an ungated notice printed twice on the unauthorized-preview path (`init`
|
|
1786
1722
|
// without --yes: plan pass, then the outer apply pass, both loud). The
|
|
1787
1723
|
// sibling `warning()` for a sibling opencode.jsonc is gated the same way;
|
|
1788
1724
|
// a real --dry-run is not a plan pass, so it still prints them once.
|
|
1789
|
-
if (
|
|
1725
|
+
if (!opts.planOnly) {
|
|
1790
1726
|
// The notice states only what this installer actually does and what the
|
|
1791
1727
|
// host actually reads. It previously claimed an isolated state database and
|
|
1792
1728
|
// a dedicated service port: nothing in this package sets OPENCODE_DB, no
|
|
@@ -1902,7 +1838,7 @@ async function installPass(
|
|
|
1902
1838
|
// files to disagree silently.
|
|
1903
1839
|
const siblingJsonc = join(target, 'opencode.jsonc')
|
|
1904
1840
|
const configAdvisories = []
|
|
1905
|
-
if (
|
|
1841
|
+
if (existsSync(siblingJsonc)) {
|
|
1906
1842
|
configAdvisories.push(
|
|
1907
1843
|
`Both ${targetConfigPath} and ${siblingJsonc} exist and an OpenCode V2 host merges ` +
|
|
1908
1844
|
'them (scalars from the .jsonc win, arrays are unioned). The installer reads and ' +
|
|
@@ -1929,7 +1865,7 @@ async function installPass(
|
|
|
1929
1865
|
// Validate the original MCP shape before runtime entries can be seeded or a
|
|
1930
1866
|
// flat map can be wrapped. Seeding first can turn malformed nested input into
|
|
1931
1867
|
// an apparently valid wrapper and let migration silently discard user data.
|
|
1932
|
-
if (
|
|
1868
|
+
if (Object.hasOwn(config, 'mcp')) {
|
|
1933
1869
|
validateMcpV1toV2Source(config.mcp)
|
|
1934
1870
|
}
|
|
1935
1871
|
const pantheonConfig =
|
|
@@ -1948,13 +1884,12 @@ async function installPass(
|
|
|
1948
1884
|
}
|
|
1949
1885
|
}
|
|
1950
1886
|
|
|
1951
|
-
//
|
|
1952
|
-
//
|
|
1953
|
-
//
|
|
1954
|
-
// Global installs are flat for both versions.
|
|
1887
|
+
// V2 layout: the active config directory is the project root and the host's
|
|
1888
|
+
// agent loader scans <config-dir>/{agent,agents}/**, so project agents live
|
|
1889
|
+
// at ./agents. Global installs are flat.
|
|
1955
1890
|
const isGlobal = opts.global ?? isGlobalConfigDir(target)
|
|
1956
1891
|
const _subDir = isGlobal ? '' : '.opencode'
|
|
1957
|
-
const agentPrefix =
|
|
1892
|
+
const agentPrefix = 'agents'
|
|
1958
1893
|
|
|
1959
1894
|
// -----------------------------------------------------------------------
|
|
1960
1895
|
// Plan pass + apply gate + drift check (Beta 11 Setup phases 3-4).
|
|
@@ -1976,11 +1911,6 @@ async function installPass(
|
|
|
1976
1911
|
// suppresses prompts, not the summary or integrity/drift checks.
|
|
1977
1912
|
planned = await installOpenCode(target, true, clean, [...componentSet], {
|
|
1978
1913
|
...opts,
|
|
1979
|
-
// Hand the RESOLVED generation to the plan pass. Re-resolving would
|
|
1980
|
-
// probe the host a second time and could land on a different answer
|
|
1981
|
-
// (a transient probe failure), making the plan disagree with the
|
|
1982
|
-
// apply it is about to authorize.
|
|
1983
|
-
version,
|
|
1984
1914
|
planTimestamp,
|
|
1985
1915
|
planOnly: true,
|
|
1986
1916
|
quiet: autoYes,
|
|
@@ -2002,7 +1932,6 @@ async function installPass(
|
|
|
2002
1932
|
options: {
|
|
2003
1933
|
clean,
|
|
2004
1934
|
components: [...components],
|
|
2005
|
-
version,
|
|
2006
1935
|
isProject: opts.isProject === true,
|
|
2007
1936
|
model: opts.model ?? null,
|
|
2008
1937
|
smallModel: opts.smallModel ?? null,
|
|
@@ -2113,7 +2042,7 @@ async function installPass(
|
|
|
2113
2042
|
assertPathWithin(target, skillsTarget)
|
|
2114
2043
|
assertNoSymlinkAncestors(skillsTarget)
|
|
2115
2044
|
}
|
|
2116
|
-
const backupPlan = collectInstallBackupEntries(target, componentSet,
|
|
2045
|
+
const backupPlan = collectInstallBackupEntries(target, componentSet, isGlobal)
|
|
2117
2046
|
const pkgVersion = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version
|
|
2118
2047
|
if (dryRun) {
|
|
2119
2048
|
const preview = previewBackupSet({
|
|
@@ -2340,9 +2269,8 @@ async function installPass(
|
|
|
2340
2269
|
section('Commands')
|
|
2341
2270
|
const srcCmds = join(ROOT, 'commands')
|
|
2342
2271
|
// V2 project sandboxes use OPENCODE_CONFIG_DIR=<project root>, so OpenCode
|
|
2343
|
-
// discovers custom commands from <target>/commands
|
|
2344
|
-
|
|
2345
|
-
const commandDir = isGlobal || version === 'v2' ? 'commands' : '.opencode/commands'
|
|
2272
|
+
// discovers custom commands from <target>/commands; global installs are flat.
|
|
2273
|
+
const commandDir = 'commands'
|
|
2346
2274
|
const dstCmds = join(target, commandDir)
|
|
2347
2275
|
if (existsSync(srcCmds)) {
|
|
2348
2276
|
const cmdResult = syncDir(
|
|
@@ -2381,7 +2309,6 @@ async function installPass(
|
|
|
2381
2309
|
const pluginStats = installPlugin(srcPluginDir, dstPluginDir, {
|
|
2382
2310
|
dryRun,
|
|
2383
2311
|
clean,
|
|
2384
|
-
version,
|
|
2385
2312
|
recorder,
|
|
2386
2313
|
reviewedRemovals,
|
|
2387
2314
|
reviewedSnapshots,
|
|
@@ -2401,7 +2328,6 @@ async function installPass(
|
|
|
2401
2328
|
tuiStatus = syncTuiRegistration(target, {
|
|
2402
2329
|
isGlobal,
|
|
2403
2330
|
dryRun,
|
|
2404
|
-
version,
|
|
2405
2331
|
recorder,
|
|
2406
2332
|
reviewedRemovals,
|
|
2407
2333
|
reviewedSnapshots,
|
|
@@ -2422,7 +2348,7 @@ async function installPass(
|
|
|
2422
2348
|
// create one. Keeping it in the installer is what makes the de-duplication
|
|
2423
2349
|
// durable: a hand edit in ~/.config/opencode/cli.json would be lost as soon as
|
|
2424
2350
|
// the user re-runs init, and the Context block would render twice again.
|
|
2425
|
-
if (componentSet.has('plugins') &&
|
|
2351
|
+
if (componentSet.has('plugins') && isGlobal) {
|
|
2426
2352
|
try {
|
|
2427
2353
|
const cliStatus = applyContextSidebarNegation(target, { dryRun, recorder })
|
|
2428
2354
|
if (cliStatus === 'created') stats.created++
|
|
@@ -2627,7 +2553,9 @@ async function installPass(
|
|
|
2627
2553
|
else if (fm.disable_model_invocation !== undefined)
|
|
2628
2554
|
agent.disable_model_invocation = fm.disable_model_invocation
|
|
2629
2555
|
|
|
2630
|
-
// Build
|
|
2556
|
+
// Build permissions from frontmatter. The canonical `permission:` YAML
|
|
2557
|
+
// key is the V1 object spelling; the written agent entry carries the V2
|
|
2558
|
+
// `permissions` rule array, produced at the end of this loop.
|
|
2631
2559
|
if (fm.permission) {
|
|
2632
2560
|
agent.permission = JSON.parse(JSON.stringify(fm.permission))
|
|
2633
2561
|
}
|
|
@@ -2641,6 +2569,10 @@ async function installPass(
|
|
|
2641
2569
|
configuredMcpServersForPolicies,
|
|
2642
2570
|
)
|
|
2643
2571
|
}
|
|
2572
|
+
if (agent.permission !== undefined) {
|
|
2573
|
+
agent.permissions = convertLegacyPermissionsToV2(agent.permission)
|
|
2574
|
+
delete agent.permission
|
|
2575
|
+
}
|
|
2644
2576
|
|
|
2645
2577
|
config[name] = agent
|
|
2646
2578
|
}
|
|
@@ -2649,11 +2581,7 @@ async function installPass(
|
|
|
2649
2581
|
|
|
2650
2582
|
// Provenance prefix per install shape (D3-scoped: project installs write it;
|
|
2651
2583
|
// global installs NEVER do — the cwd-relative path vanishes agents there).
|
|
2652
|
-
const agentPrefixForSource = isGlobalConfigDir(target)
|
|
2653
|
-
? null
|
|
2654
|
-
: version === 'v2'
|
|
2655
|
-
? 'agents'
|
|
2656
|
-
: '.opencode/agents'
|
|
2584
|
+
const agentPrefixForSource = isGlobalConfigDir(target) ? null : 'agents'
|
|
2657
2585
|
const agentSources = {}
|
|
2658
2586
|
if (agentPrefixForSource !== null) {
|
|
2659
2587
|
const agentsDir = join(ROOT, 'src', 'agents')
|
|
@@ -2669,20 +2597,19 @@ async function installPass(
|
|
|
2669
2597
|
}
|
|
2670
2598
|
const isGlobalTarget = isGlobalConfigDir(target)
|
|
2671
2599
|
|
|
2672
|
-
const configuredMcpServersForPolicies =
|
|
2673
|
-
version === 'v2' ? configuredMcpServerNames(config.mcp) : []
|
|
2600
|
+
const configuredMcpServersForPolicies = configuredMcpServerNames(config.mcp)
|
|
2674
2601
|
const canonicalAgentConfig = readAgentConfigFromCanonical()
|
|
2675
|
-
if (config.
|
|
2602
|
+
if (config.agents === undefined) config.agents = {}
|
|
2676
2603
|
|
|
2677
|
-
if (config.
|
|
2604
|
+
if (config.agents && typeof config.agents === 'object' && !Array.isArray(config.agents)) {
|
|
2678
2605
|
for (const [agentName, agentCfg] of Object.entries(canonicalAgentConfig)) {
|
|
2679
2606
|
if (!agentCfg || typeof agentCfg !== 'object') continue
|
|
2680
2607
|
|
|
2681
|
-
if (Object.hasOwn(config.
|
|
2608
|
+
if (Object.hasOwn(config.agents, agentName)) {
|
|
2682
2609
|
// ── Agent exists in target config ──
|
|
2683
2610
|
// Update framework-managed fields from canonical source
|
|
2684
2611
|
// Preserve user-customized fields (model, provider, mcp, etc.)
|
|
2685
|
-
const existing = config.
|
|
2612
|
+
const existing = config.agents[agentName]
|
|
2686
2613
|
if (!existing || typeof existing !== 'object' || Array.isArray(existing)) continue
|
|
2687
2614
|
// HEAL + provenance (field beta.14→26): `source` is cwd-relative and
|
|
2688
2615
|
// host 2.2.5 resolves it against the SESSION cwd — so it is written
|
|
@@ -2737,15 +2664,13 @@ async function installPass(
|
|
|
2737
2664
|
}
|
|
2738
2665
|
}
|
|
2739
2666
|
|
|
2740
|
-
//
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
if (newAgent.permission.bash === undefined && agentCfg.permission?.bash) {
|
|
2745
|
-
newAgent.permission.bash = JSON.parse(JSON.stringify(agentCfg.permission.bash))
|
|
2667
|
+
// An agent without any permission frontmatter still gets an explicit
|
|
2668
|
+
// (empty) policy so the entry shape never depends on the agent's YAML.
|
|
2669
|
+
if (newAgent.permissions === undefined) {
|
|
2670
|
+
newAgent.permissions = []
|
|
2746
2671
|
}
|
|
2747
2672
|
|
|
2748
|
-
config.
|
|
2673
|
+
config.agents[agentName] = newAgent
|
|
2749
2674
|
}
|
|
2750
2675
|
}
|
|
2751
2676
|
|
|
@@ -2818,51 +2743,21 @@ async function installPass(
|
|
|
2818
2743
|
// The source opencode.json keeps its dev path for local development; the
|
|
2819
2744
|
// transform happens at install/sync time only.
|
|
2820
2745
|
|
|
2821
|
-
|
|
2822
|
-
//
|
|
2823
|
-
//
|
|
2824
|
-
//
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
}
|
|
2828
|
-
if (config.plugin === undefined) config.plugin = []
|
|
2829
|
-
if (Array.isArray(config.plugin)) {
|
|
2830
|
-
config.plugin = removePantheonPluginReferences(config.plugin)
|
|
2831
|
-
if (Array.isArray(pantheonConfig?.plugin)) {
|
|
2832
|
-
for (const plugin of pantheonConfig.plugin) {
|
|
2833
|
-
if (!isPantheonPluginReference(plugin) && !hasPluginReference(config.plugin, plugin)) {
|
|
2834
|
-
config.plugin.push(deepClone(plugin))
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
|
|
2839
|
-
const ensurePantheonPlugin = (ref) => {
|
|
2840
|
-
const resolved = resolveInstalledPlugin(ref)
|
|
2841
|
-
config.plugin = config.plugin.filter(
|
|
2842
|
-
(plugin) => pluginReferenceIdentity(plugin) !== pluginReferenceIdentity(resolved),
|
|
2843
|
-
)
|
|
2844
|
-
config.plugin.push(resolved)
|
|
2845
|
-
}
|
|
2846
|
-
// Root-level delegation plugin remains a V1-only registration.
|
|
2847
|
-
ensurePantheonPlugin('src/plugin.ts')
|
|
2848
|
-
ensurePantheonPlugin('src/plugins/pantheon-hooks.ts')
|
|
2849
|
-
}
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
if (version === 'v2') {
|
|
2853
|
-
// V2 loads the plural `plugins` list, and the singular `plugin` key is dead
|
|
2854
|
-
// on this host. Migrating a V1 config therefore means deciding, entry by
|
|
2855
|
-
// entry, whether the V2 loader can load it AT ALL: a directory can, a file
|
|
2856
|
-
// path is rejected ("must be a directory") and a package shorthand dies in
|
|
2746
|
+
{
|
|
2747
|
+
// The registry is the plural `plugins` list; the singular `plugin` key is
|
|
2748
|
+
// dead on this host and is treated as legacy data: Pantheon refs are
|
|
2749
|
+
// stripped, and third-party entries are decided, one by one, on whether
|
|
2750
|
+
// the V2 loader can load them AT ALL: a directory can, a file path is
|
|
2751
|
+
// rejected ("must be a directory") and a package shorthand dies in
|
|
2857
2752
|
// `npm install`. Copying every entry across would turn "silently ignored"
|
|
2858
|
-
// into "config fails to load", so only loadable entries move; the rest
|
|
2859
|
-
// where they are and the warning names the exact failure mode.
|
|
2860
|
-
// Preflight (runs for
|
|
2861
|
-
// registration must be named even when the singular
|
|
2862
|
-
// gone). Field report beta.13 §2: an EXISTING `_npx`
|
|
2863
|
-
// missing one — it passes the existsSync check at
|
|
2864
|
-
// intermittently later, so volatility is named and
|
|
2865
|
-
// below repoints to the stable tree.
|
|
2753
|
+
// into "config fails to load", so only loadable entries move; the rest
|
|
2754
|
+
// stay where they are and the warning names the exact failure mode.
|
|
2755
|
+
// Preflight (runs for configs without a singular key too — a stale or
|
|
2756
|
+
// volatile Pantheon registration must be named even when the singular
|
|
2757
|
+
// `plugin` key is long gone). Field report beta.13 §2: an EXISTING `_npx`
|
|
2758
|
+
// path is worse than a missing one — it passes the existsSync check at
|
|
2759
|
+
// install time and dies intermittently later, so volatility is named and
|
|
2760
|
+
// the re-registration below repoints to the stable tree.
|
|
2866
2761
|
if (Array.isArray(config.plugins)) {
|
|
2867
2762
|
for (const ref of config.plugins) {
|
|
2868
2763
|
const refPath = typeof ref === 'string' ? ref : ref?.package
|
|
@@ -2885,15 +2780,15 @@ async function installPass(
|
|
|
2885
2780
|
}
|
|
2886
2781
|
}
|
|
2887
2782
|
if (Array.isArray(config.plugin)) {
|
|
2888
|
-
// Strip Pantheon refs FIRST
|
|
2889
|
-
//
|
|
2783
|
+
// Strip Pantheon refs FIRST: a stale V1 .ts path is not a registrable
|
|
2784
|
+
// entry on this host and must not be moved.
|
|
2890
2785
|
config.plugin = removePantheonPluginReferences(config.plugin)
|
|
2891
2786
|
if (!Array.isArray(config.plugins)) config.plugins = []
|
|
2892
2787
|
|
|
2893
2788
|
const migrated = []
|
|
2894
2789
|
const blocked = []
|
|
2895
2790
|
for (const plugin of config.plugin) {
|
|
2896
|
-
const verdict =
|
|
2791
|
+
const verdict = pluginEntryLoadability(plugin, target)
|
|
2897
2792
|
if (!verdict.loadable) {
|
|
2898
2793
|
blocked.push({ plugin, reason: verdict.reason })
|
|
2899
2794
|
continue
|
|
@@ -2905,7 +2800,7 @@ async function installPass(
|
|
|
2905
2800
|
}
|
|
2906
2801
|
if (migrated.length > 0) {
|
|
2907
2802
|
warning(
|
|
2908
|
-
`
|
|
2803
|
+
`The host ignores the singular "plugin" key; also registered ${migrated.length} ` +
|
|
2909
2804
|
`third-party entr${migrated.length === 1 ? 'y' : 'ies'} under "plugins" so ` +
|
|
2910
2805
|
`they keep loading: ${migrated.map(describePluginEntry).join(', ')}. ` +
|
|
2911
2806
|
'Remove any that only support the V1 plugin API.',
|
|
@@ -2913,7 +2808,7 @@ async function installPass(
|
|
|
2913
2808
|
}
|
|
2914
2809
|
if (blocked.length > 0) {
|
|
2915
2810
|
warning(
|
|
2916
|
-
'
|
|
2811
|
+
'The host ignores the singular "plugin" key; these entries were left in it ' +
|
|
2917
2812
|
`because the V2 loader cannot load them, so they will NOT be active: ${blocked
|
|
2918
2813
|
.map(
|
|
2919
2814
|
({ plugin, reason }) =>
|
|
@@ -2924,8 +2819,8 @@ async function installPass(
|
|
|
2924
2819
|
}
|
|
2925
2820
|
// Pantheon refs are already gone. An emptied array is not configuration:
|
|
2926
2821
|
// drop the dead key entirely so the written config points at the list the
|
|
2927
|
-
//
|
|
2928
|
-
//
|
|
2822
|
+
// host actually reads. A surviving list is the user's own data and is
|
|
2823
|
+
// left in place.
|
|
2929
2824
|
if (config.plugin.length === 0) delete config.plugin
|
|
2930
2825
|
}
|
|
2931
2826
|
if (!Array.isArray(config.plugins)) config.plugins = []
|
|
@@ -2935,7 +2830,7 @@ async function installPass(
|
|
|
2935
2830
|
// option the user chose. Only the object form can carry options.
|
|
2936
2831
|
const existingV2Options =
|
|
2937
2832
|
config.plugins
|
|
2938
|
-
.filter((ref) => pluginReferenceIdentity(ref) ===
|
|
2833
|
+
.filter((ref) => pluginReferenceIdentity(ref) === PANTHEON_PLUGIN)
|
|
2939
2834
|
.map((ref) =>
|
|
2940
2835
|
typeof ref === 'object' && ref !== null && !Array.isArray(ref) ? ref.options : null,
|
|
2941
2836
|
)
|
|
@@ -2949,18 +2844,17 @@ async function installPass(
|
|
|
2949
2844
|
}
|
|
2950
2845
|
}
|
|
2951
2846
|
}
|
|
2952
|
-
// The
|
|
2953
|
-
// `a/b` shorthand (e.g. the published `pantheon-opencode/plugin
|
|
2847
|
+
// The host resolves every `plugins` entry through npm install, so an
|
|
2848
|
+
// `a/b` shorthand (e.g. the published `pantheon-opencode/plugin`
|
|
2954
2849
|
// export) is treated as a GitHub repo and dies with NpmInstallFailedError
|
|
2955
|
-
// (beta log evidence). The
|
|
2850
|
+
// (beta log evidence). The loader additionally requires each entry
|
|
2956
2851
|
// to be a DIRECTORY with a real index.js/index.ts — a file path warns
|
|
2957
2852
|
// "must be a directory" and a symlink is ignored (sandbox probe
|
|
2958
|
-
// evidence). Register the
|
|
2959
|
-
// package
|
|
2960
|
-
//
|
|
2961
|
-
//
|
|
2962
|
-
//
|
|
2963
|
-
// they migrate here.
|
|
2853
|
+
// evidence). Register the plugin DIRECTORY inside the INSTALLED
|
|
2854
|
+
// package, pointing at src/plugin whose index.ts shim re-exports the
|
|
2855
|
+
// real entry. Legacy refs (npm shorthand, the old src/plugin.ts file
|
|
2856
|
+
// path, the removed V1 files) are recognized via managedPluginIdentity
|
|
2857
|
+
// and already stripped above, so they never come back here.
|
|
2964
2858
|
const stableRoot = resolveStablePantheonRoot()
|
|
2965
2859
|
if (stableRoot.volatile) {
|
|
2966
2860
|
warning(
|
|
@@ -2969,16 +2863,16 @@ async function installPass(
|
|
|
2969
2863
|
'volatile cache and can break mid-session. Fix: npm install -g pantheon-opencode, then re-run init.',
|
|
2970
2864
|
)
|
|
2971
2865
|
}
|
|
2972
|
-
const
|
|
2866
|
+
const resolvedPlugin = resolveInstalledPlugin(PANTHEON_PLUGIN)
|
|
2973
2867
|
config.plugins = config.plugins.filter(
|
|
2974
|
-
(plugin) => pluginReferenceIdentity(plugin) !== pluginReferenceIdentity(
|
|
2868
|
+
(plugin) => pluginReferenceIdentity(plugin) !== pluginReferenceIdentity(resolvedPlugin),
|
|
2975
2869
|
)
|
|
2976
2870
|
// Always use object form, even on a fresh install. The host passes plugin
|
|
2977
2871
|
// options only from `{ package, options }`, and `context_pruner` reads
|
|
2978
2872
|
// `ctx.options`. A bare string left the option unreachable; an empty object
|
|
2979
2873
|
// keeps the contract visible and preserves user-added keys on re-run.
|
|
2980
2874
|
config.plugins.push({
|
|
2981
|
-
package:
|
|
2875
|
+
package: resolvedPlugin,
|
|
2982
2876
|
options: existingV2Options === null ? {} : deepClone(existingV2Options),
|
|
2983
2877
|
})
|
|
2984
2878
|
|
|
@@ -2999,12 +2893,12 @@ async function installPass(
|
|
|
2999
2893
|
(ref) =>
|
|
3000
2894
|
!isPantheonPluginReference(ref) &&
|
|
3001
2895
|
pluginMetadataReferences(ref).some((reference) =>
|
|
3002
|
-
/(^|\/)plugin
|
|
2896
|
+
/(^|\/)plugin(?:\.ts)?$/.test(normalizePluginRef(reference)),
|
|
3003
2897
|
),
|
|
3004
2898
|
)
|
|
3005
2899
|
if (lookalikes.length > 0) {
|
|
3006
2900
|
warning(
|
|
3007
|
-
'This config also points at another copy of the Pantheon
|
|
2901
|
+
'This config also points at another copy of the Pantheon plugin, which this ' +
|
|
3008
2902
|
'installer cannot prove it owns: ' +
|
|
3009
2903
|
`${lookalikes.map(describePluginEntry).join(', ')}. With the entry registered in ` +
|
|
3010
2904
|
'this install, BOTH copies would load and their hooks would run twice. Remove that ' +
|
|
@@ -3017,10 +2911,9 @@ async function installPass(
|
|
|
3017
2911
|
// Report whether the entry the host will read can actually carry options.
|
|
3018
2912
|
// Computed here, from the config this pass is about to write, so it answers
|
|
3019
2913
|
// the installed state rather than an assumption.
|
|
3020
|
-
const
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
warning(`Pantheon V2 plugin options are not reachable: ${v2PluginOptions.detail}`)
|
|
2914
|
+
const pluginOptions = describePluginOptionsReachability(config.plugins)
|
|
2915
|
+
if (!pluginOptions.reachable && !opts.planOnly) {
|
|
2916
|
+
warning(`Pantheon plugin options are not reachable: ${pluginOptions.detail}`)
|
|
3024
2917
|
}
|
|
3025
2918
|
|
|
3026
2919
|
if (pantheonConfig !== null) {
|
|
@@ -3042,8 +2935,10 @@ async function installPass(
|
|
|
3042
2935
|
// --------------------------------------------------------------------
|
|
3043
2936
|
// A native V2 array is an explicit policy, including an empty one. Do not
|
|
3044
2937
|
// append legacy defaults to it: reruns would duplicate rules, and custom V2
|
|
3045
|
-
// configs would gain grants the user did not choose.
|
|
3046
|
-
|
|
2938
|
+
// configs would gain grants the user did not choose. The seeds below are
|
|
2939
|
+
// written in the legacy object spelling and normalized to the V2 rule array
|
|
2940
|
+
// by normalizeLegacyV1Config right before the write.
|
|
2941
|
+
const hasNativeV2Permissions = Array.isArray(config.permissions)
|
|
3047
2942
|
if (config.permission === undefined) config.permission = {}
|
|
3048
2943
|
if (
|
|
3049
2944
|
typeof config.permission === 'object' &&
|
|
@@ -3107,12 +3002,11 @@ async function installPass(
|
|
|
3107
3002
|
// --------------------------------------------------------------------
|
|
3108
3003
|
// D. Merge instructions paths
|
|
3109
3004
|
// --------------------------------------------------------------------
|
|
3110
|
-
// AGENTS.md is the single instruction file
|
|
3111
|
-
//
|
|
3112
|
-
//
|
|
3113
|
-
//
|
|
3114
|
-
//
|
|
3115
|
-
// and is ignored under V2 anyway. Only ensure AGENTS.md is present.
|
|
3005
|
+
// AGENTS.md is the single instruction file the host loads explicitly. The
|
|
3006
|
+
// generated AGENTS.md contains shared rules; agent-scoped rules are in the
|
|
3007
|
+
// installed agent prompts. The `instructions/*.md`
|
|
3008
|
+
// glob is no longer needed — keeping it would duplicate content. Only
|
|
3009
|
+
// ensure AGENTS.md is present.
|
|
3116
3010
|
const pantheonInstructions = ['AGENTS.md']
|
|
3117
3011
|
if (config.instructions === undefined) {
|
|
3118
3012
|
config.instructions = [...pantheonInstructions]
|
|
@@ -3120,8 +3014,8 @@ async function installPass(
|
|
|
3120
3014
|
// Strip stale per-file instruction globs from PREVIOUS installs
|
|
3121
3015
|
// (e.g. `instructions/*.instructions.md` / `src/instructions/*.md`).
|
|
3122
3016
|
// The merge is additive-only otherwise, so without this filter existing
|
|
3123
|
-
// configs would keep loading instruction content twice
|
|
3124
|
-
//
|
|
3017
|
+
// configs would keep loading instruction content twice (generated
|
|
3018
|
+
// AGENTS.md + individual files). User entries that are not
|
|
3125
3019
|
// *.instructions.md globs are preserved.
|
|
3126
3020
|
config.instructions = config.instructions.filter(
|
|
3127
3021
|
(instr) => typeof instr !== 'string' || !instr.endsWith('.instructions.md'),
|
|
@@ -3140,16 +3034,6 @@ async function installPass(
|
|
|
3140
3034
|
config.$schema = 'https://opencode.ai/config.json'
|
|
3141
3035
|
}
|
|
3142
3036
|
|
|
3143
|
-
// --------------------------------------------------------------------
|
|
3144
|
-
// F. Compatibility cleanup (OpenCode V1 >= 1.15.7)
|
|
3145
|
-
// --------------------------------------------------------------------
|
|
3146
|
-
// Recent V1 releases reject the legacy `todoContinuation` setting. Remove
|
|
3147
|
-
// it from the merged V1 config, while leaving the V2-shaped configuration
|
|
3148
|
-
// untouched.
|
|
3149
|
-
if (version === 'v1' && Object.hasOwn(config, 'todoContinuation')) {
|
|
3150
|
-
delete config.todoContinuation
|
|
3151
|
-
}
|
|
3152
|
-
|
|
3153
3037
|
// --------------------------------------------------------------------
|
|
3154
3038
|
// F.5 MCP server entries (for runtime-deployed scripts)
|
|
3155
3039
|
// beta.5: skipped when the Python runtime setup failed — entries pointing
|
|
@@ -3167,7 +3051,6 @@ async function installPass(
|
|
|
3167
3051
|
const mcp = applyMcpServerEntries(config, {
|
|
3168
3052
|
runtimeTarget,
|
|
3169
3053
|
venvPython: venvPythonPath(target),
|
|
3170
|
-
version,
|
|
3171
3054
|
})
|
|
3172
3055
|
mcpServers = mcp.servers
|
|
3173
3056
|
// `permission.mcp.<server>: ask` is inert on OpenCode 2.x. Never leave the
|
|
@@ -3181,44 +3064,42 @@ async function installPass(
|
|
|
3181
3064
|
}
|
|
3182
3065
|
}
|
|
3183
3066
|
|
|
3184
|
-
// ── V2
|
|
3185
|
-
//
|
|
3186
|
-
//
|
|
3067
|
+
// ── V2 normalization before the write ──
|
|
3068
|
+
// The merge above still holds legacy-spelled keys (permission seeds, a flat
|
|
3069
|
+
// mcp block, whatever the user's old config carried). Normalize the whole
|
|
3070
|
+
// config to the V2 shape the host reads before writing. This can emit raw
|
|
3071
|
+
// console warnings (ambiguous legacy values), so close the gauge line first
|
|
3072
|
+
// so they are not printed on top of it and then erased by the next `\r`
|
|
3073
|
+
// clear.
|
|
3187
3074
|
let configToWrite = config
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
// A null/type-invalid block throws HERE, before any config write.
|
|
3217
|
-
configToWrite.plugins = applyContextSandboxToV2Plugins(
|
|
3218
|
-
configToWrite.plugins,
|
|
3219
|
-
config.context_sandbox,
|
|
3220
|
-
)
|
|
3221
|
-
}
|
|
3075
|
+
endGaugeLine()
|
|
3076
|
+
info(S.v2Migrating)
|
|
3077
|
+
configToWrite = normalizeLegacyV1Config(config)
|
|
3078
|
+
|
|
3079
|
+
// Pantheon no longer sets a step ceiling. Any `steps` sitting on a managed
|
|
3080
|
+
// agent was written by an earlier install and never chosen by the user —
|
|
3081
|
+
// the merge above is additive by design (no delete path), so drop it here
|
|
3082
|
+
// and let the host default apply. This runs after the normalization because
|
|
3083
|
+
// normalizeLegacyV1Config copies a legacy `agent` block across verbatim
|
|
3084
|
+
// (including any stale `steps`), which is exactly how the value reappears.
|
|
3085
|
+
// User-defined agents are out of scope and keep their value.
|
|
3086
|
+
const v2Agents = configToWrite.agents
|
|
3087
|
+
if (v2Agents && typeof v2Agents === 'object' && !Array.isArray(v2Agents)) {
|
|
3088
|
+
for (const name of Object.keys(canonicalAgentConfig)) {
|
|
3089
|
+
const entry = v2Agents[name]
|
|
3090
|
+
if (entry && typeof entry === 'object' && !Array.isArray(entry)) delete entry.steps
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
// Carry the legacy top-level `context_sandbox` into the exact Pantheon V2
|
|
3095
|
+
// plugin entry's `options` — V2.0.25 silently drops the top-level key, so
|
|
3096
|
+
// without this the user's enabled/limits choice is lost on an upgrade.
|
|
3097
|
+
// The legacy block itself is preserved for reference.
|
|
3098
|
+
// A null/type-invalid block throws HERE, before any config write.
|
|
3099
|
+
configToWrite.plugins = applyContextSandboxToPluginEntry(
|
|
3100
|
+
configToWrite.plugins,
|
|
3101
|
+
config.context_sandbox,
|
|
3102
|
+
)
|
|
3222
3103
|
|
|
3223
3104
|
const configContent = `${JSON.stringify(configToWrite, null, 2)}\n`
|
|
3224
3105
|
const configStep = step(S.writingConfig)
|
|
@@ -3270,17 +3151,6 @@ async function installPass(
|
|
|
3270
3151
|
}
|
|
3271
3152
|
advancePhase()
|
|
3272
3153
|
|
|
3273
|
-
if (opts.preset && dryRun) {
|
|
3274
|
-
const { writeActivePreset } = await import('./model-picker.mjs')
|
|
3275
|
-
writeActivePreset(target, opts.preset, {
|
|
3276
|
-
dryRun: true,
|
|
3277
|
-
source: 'cli',
|
|
3278
|
-
updatedAt: planTimestamp,
|
|
3279
|
-
recorder,
|
|
3280
|
-
logger: { log() {} },
|
|
3281
|
-
})
|
|
3282
|
-
}
|
|
3283
|
-
|
|
3284
3154
|
// -----------------------------------------------------------------------
|
|
3285
3155
|
// 3.75 Preview summary (Beta 11 Setup phase 1): print the REAL per-file
|
|
3286
3156
|
// change set this same pass would apply. Paths + action + byte size
|
|
@@ -3331,7 +3201,6 @@ async function installPass(
|
|
|
3331
3201
|
// when the runtime component is not selected or failed its prerequisites).
|
|
3332
3202
|
plan.mcpServers = mcpServers
|
|
3333
3203
|
if (componentSet.has('runtime')) plan.runtimeEffects = runtimeEffects
|
|
3334
|
-
plan.versionAssumed = versionAssumed
|
|
3335
3204
|
planFiles = plan.files
|
|
3336
3205
|
planTotals = plan.totals
|
|
3337
3206
|
plannedChanges = plan.totals.create + plan.totals.update + plan.totals.remove
|
|
@@ -3393,31 +3262,6 @@ async function installPass(
|
|
|
3393
3262
|
// entries are only added when the Python runtime is actually healthy)
|
|
3394
3263
|
// -----------------------------------------------------------------------
|
|
3395
3264
|
|
|
3396
|
-
// -----------------------------------------------------------------------
|
|
3397
|
-
// 5. V1 model preset selection (--components agents). V2 ignores the legacy
|
|
3398
|
-
// active-preset marker, so it has no profile wizard or --preset support.
|
|
3399
|
-
// The V1 interactive wizard runs unless autoYes or an explicit preset was given.
|
|
3400
|
-
// Q1 default "herdar do chat" (inherit) writes no active-preset.json —
|
|
3401
|
-
// delegates inherit the parent chat model (native inheritance).
|
|
3402
|
-
// -----------------------------------------------------------------------
|
|
3403
|
-
if (
|
|
3404
|
-
interactive &&
|
|
3405
|
-
stdinTTY &&
|
|
3406
|
-
version === 'v1' &&
|
|
3407
|
-
!dryRun &&
|
|
3408
|
-
!autoYes &&
|
|
3409
|
-
!opts.preset &&
|
|
3410
|
-
stats.errors === 0
|
|
3411
|
-
) {
|
|
3412
|
-
const { runInitWizard } = await import('./model-picker.mjs')
|
|
3413
|
-
await runInitWizard({ presetDir: target, logger: console, prompts: opts.deps?.prompts })
|
|
3414
|
-
}
|
|
3415
|
-
|
|
3416
|
-
if (opts.preset && !dryRun && stats.errors === 0) {
|
|
3417
|
-
const { writeActivePreset } = await import('./model-picker.mjs')
|
|
3418
|
-
writeActivePreset(target, opts.preset, { source: 'cli', updatedAt: planTimestamp, recorder })
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
3265
|
// -----------------------------------------------------------------------
|
|
3422
3266
|
// 5.5 Optional vision prompt (interactive TTY only). The default — automatic
|
|
3423
3267
|
// discovery — writes nothing, and non-interactive flows (no TTY, --yes,
|
|
@@ -3459,7 +3303,7 @@ async function installPass(
|
|
|
3459
3303
|
const verifiedFiles = summarizeChanges(ownRecorder?.entries ?? []).files.flatMap((file) => {
|
|
3460
3304
|
if (!['create', 'update', 'unchanged'].includes(file.action) || !file.outputFingerprint)
|
|
3461
3305
|
return []
|
|
3462
|
-
const owner = componentForInstalledPath(target, file.path, { isGlobal
|
|
3306
|
+
const owner = componentForInstalledPath(target, file.path, { isGlobal })
|
|
3463
3307
|
if (!owner) return []
|
|
3464
3308
|
return [
|
|
3465
3309
|
{
|
|
@@ -3548,12 +3392,11 @@ async function installPass(
|
|
|
3548
3392
|
removals: removalPaths,
|
|
3549
3393
|
target,
|
|
3550
3394
|
openCodeVersion: version,
|
|
3551
|
-
versionAssumed,
|
|
3552
3395
|
configAdvisories,
|
|
3553
|
-
v2Capabilities:
|
|
3396
|
+
v2Capabilities: v2Capabilities(),
|
|
3554
3397
|
decisionModelActivation,
|
|
3555
3398
|
decisionModelDeferredSetup,
|
|
3556
|
-
pluginOptions
|
|
3399
|
+
pluginOptions,
|
|
3557
3400
|
}
|
|
3558
3401
|
: {
|
|
3559
3402
|
...stats,
|
|
@@ -3565,7 +3408,7 @@ async function installPass(
|
|
|
3565
3408
|
runtimeEffects,
|
|
3566
3409
|
openCodeVersion: version,
|
|
3567
3410
|
configAdvisories,
|
|
3568
|
-
v2Capabilities:
|
|
3569
|
-
pluginOptions
|
|
3411
|
+
v2Capabilities: v2Capabilities(),
|
|
3412
|
+
pluginOptions,
|
|
3570
3413
|
}
|
|
3571
3414
|
}
|