pantheon-opencode 1.7.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/AGENTS.global.md +2 -2
  2. package/AGENTS.md +3 -3
  3. package/CHANGELOG.md +64 -60
  4. package/README.md +52 -45
  5. package/README.pt-BR.md +19 -19
  6. package/bin/pantheon-init.mjs +11 -48
  7. package/package.json +9 -13
  8. package/plugin.json +2 -2
  9. package/pyproject.toml +1 -1
  10. package/scripts/build-agents-md.mjs +7 -6
  11. package/scripts/{check-plugin-v2-coverage.mjs → check-plugin-coverage.mjs} +7 -7
  12. package/scripts/{decision-router-v2-budget.mjs → decision-router-budget-gates.mjs} +1 -1
  13. package/scripts/{decision-router-v2-egress.mjs → decision-router-egress.mjs} +1 -1
  14. package/scripts/decision-router.mjs +2 -2
  15. package/scripts/docs-media.mjs +1 -1
  16. package/scripts/doctor.mjs +225 -136
  17. package/scripts/install/behavior-overrides.bundle.mjs +123 -0
  18. package/scripts/install/{v2-capabilities.mjs → capabilities.mjs} +7 -7
  19. package/scripts/install/config-migration.mjs +60 -253
  20. package/scripts/install/file-inventory.mjs +6 -4
  21. package/scripts/install/interactive.mjs +1 -1
  22. package/scripts/install/opencode-state.mjs +13 -12
  23. package/scripts/install/opencode-version.mjs +97 -162
  24. package/scripts/install/opencode.mjs +271 -428
  25. package/scripts/install/plan.mjs +1 -9
  26. package/scripts/install/plugin.mjs +19 -35
  27. package/scripts/install/shared.mjs +40 -1
  28. package/scripts/package-evidence.mjs +1 -4
  29. package/scripts/probe-pantheon-cost.mjs +1 -1
  30. package/scripts/reconcile.mjs +5 -7
  31. package/scripts/release-gates.mjs +22 -61
  32. package/scripts/setup-v2-config.mjs +10 -8
  33. package/scripts/setup.mjs +12 -22
  34. package/scripts/sync-tui.mjs +9 -17
  35. package/scripts/{test-opencode-v2-sandbox.sh → test-opencode-sandbox.sh} +9 -9
  36. package/scripts/update-skills-lock.mjs +24 -12
  37. package/scripts/update.mjs +17 -1
  38. package/scripts/validate-routing.mjs +79 -4
  39. package/scripts/validate-sandbox-install.mjs +3 -3
  40. package/skills-lock.json +25 -8
  41. package/src/agents/zeus.md +1 -0
  42. package/src/pantheon/behavior-overrides.ts +191 -0
  43. package/src/pantheon/{v2-bounded-read.ts → bounded-read.ts} +1 -1
  44. package/src/pantheon/cost-command.ts +1 -1
  45. package/src/pantheon/{v2-decision-contracts.ts → decision-contracts.ts} +3 -3
  46. package/src/pantheon/{v2-decision-points → decision-points}/p1-agent.ts +3 -3
  47. package/src/pantheon/{v2-decision-points → decision-points}/p10-claims.ts +2 -2
  48. package/src/pantheon/{v2-decision-points → decision-points}/p11-catalog.ts +2 -2
  49. package/src/pantheon/{v2-decision-points → decision-points}/p2-skill.ts +3 -3
  50. package/src/pantheon/{v2-decision-points → decision-points}/p3-complexity.ts +6 -6
  51. package/src/pantheon/{v2-decision-points → decision-points}/p4-memory.ts +2 -2
  52. package/src/pantheon/{v2-decision-points → decision-points}/p5-themis-verify.ts +2 -2
  53. package/src/pantheon/{v2-decision-points → decision-points}/p6-council.ts +3 -3
  54. package/src/pantheon/{v2-decision-points → decision-points}/p7-loop.ts +5 -5
  55. package/src/pantheon/{v2-decision-points → decision-points}/p8-guardrail.ts +2 -2
  56. package/src/pantheon/{v2-decision-points → decision-points}/p9-memory-compaction.ts +2 -2
  57. package/src/pantheon/{v2-decision-points.ts → decision-points.ts} +5 -5
  58. package/src/pantheon/{v2-decision-policy.ts → decision-policy.ts} +2 -2
  59. package/src/pantheon/{v2-decision-prompt-surface.ts → decision-prompt-surface.ts} +3 -3
  60. package/src/pantheon/{v2-decision-registry.ts → decision-registry.ts} +10 -13
  61. package/src/pantheon/{v2-decision-resource-ids.ts → decision-resource-ids.ts} +1 -1
  62. package/src/pantheon/{v2-decision-shadow.ts → decision-shadow.ts} +1 -1
  63. package/src/pantheon/{v2-decision-telemetry.ts → decision-telemetry.ts} +1 -1
  64. package/src/pantheon/{v2-execute-after.ts → execute-after.ts} +4 -4
  65. package/src/pantheon/goal-store.ts +7 -0
  66. package/src/pantheon/{v2-hook-engine.ts → hook-engine.ts} +3 -3
  67. package/src/pantheon/jev-decision-tool.ts +3 -3
  68. package/src/pantheon/jev-decisions.ts +12 -6
  69. package/src/pantheon/jev-escalation.ts +6 -6
  70. package/src/pantheon/jev-quality-score.ts +2 -2
  71. package/src/pantheon/jev-rank-verify.ts +2 -2
  72. package/src/pantheon/jev-risk-gate.ts +4 -4
  73. package/src/pantheon/local-decision-agents.ts +1 -1
  74. package/src/pantheon/local-decision-router.ts +1 -1
  75. package/src/pantheon/local-decision-tool.ts +2 -2
  76. package/src/pantheon/local-orchestration.ts +1 -1
  77. package/src/pantheon/model-command.ts +1 -1
  78. package/src/pantheon/{v2-vision.ts → native-vision.ts} +12 -15
  79. package/src/pantheon/pantheon-decision-catalog.ts +12 -0
  80. package/src/pantheon/{v2-shell-hooks.ts → shell-hooks.ts} +4 -4
  81. package/src/pantheon/{v2-tools.ts → tools.ts} +4 -4
  82. package/src/pantheon/{v2-unsupported.d.mts → unsupported.d.mts} +3 -3
  83. package/src/pantheon/{v2-unsupported.mjs → unsupported.mjs} +8 -8
  84. package/src/pantheon/update-notifier.ts +101 -0
  85. package/src/pantheon/vision-local.ts +12 -3
  86. package/src/pantheon/vision.ts +120 -2
  87. package/src/{plugin-v2 → plugin}/index.ts +7 -7
  88. package/src/plugin.ts +2875 -500
  89. package/src/plugins/hook-runner.ts +3 -3
  90. package/src/plugins/tui/dist/server.d.ts +23 -9
  91. package/src/plugins/tui/dist/server.d.ts.map +1 -1
  92. package/src/plugins/tui/dist/server.js +25 -12
  93. package/src/plugins/tui/dist/server.js.map +1 -1
  94. package/src/plugins/tui/dist/tui.d.ts +1023 -494
  95. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  96. package/src/plugins/tui/dist/tui.js +4841 -2066
  97. package/src/plugins/tui/dist/tui.js.map +1 -1
  98. package/src/plugins/tui/{index-v2.ts → index.ts} +1 -1
  99. package/src/plugins/tui/package-lock.json +2 -42
  100. package/src/plugins/tui/package.json +4 -10
  101. package/src/plugins/tui/src/cost-data.ts +1 -1
  102. package/src/plugins/tui/src/index.tsx +4222 -2822
  103. package/src/plugins/tui/src/pantheon-settings-state.ts +111 -0
  104. package/src/plugins/tui/src/pantheon-settings.tsx +236 -0
  105. package/src/plugins/tui/src/server.ts +23 -10
  106. package/src/plugins/tui/src/update-notice.ts +86 -0
  107. package/src/plugins/tui/tsconfig.typecheck.json +1 -1
  108. package/src/plugins/tui/tsdown.config.ts +3 -5
  109. package/src/plugins/tui/tui.ts +1 -2
  110. package/src/routing.yml +36 -0
  111. package/src/skills/README.md +16 -1
  112. package/src/skills/artifact-management/SKILL.md +10 -67
  113. package/src/skills/artifact-management/references/artifact-templates.md +71 -0
  114. package/src/skills/auto-continue/SKILL.md +10 -0
  115. package/src/skills/code-review-checklist/SKILL.md +11 -44
  116. package/src/skills/code-review-checklist/references/review-checklists.md +54 -0
  117. package/src/skills/instruction-forge/SKILL.md +57 -0
  118. package/src/skills/instruction-forge/references/agents-md-doctrine.md +50 -0
  119. package/src/skills/instruction-forge/references/eval-doctrine.md +37 -0
  120. package/src/skills/instruction-forge/references/skill-doctrine.md +62 -0
  121. package/src/skills/memory-bank/SKILL.md +11 -90
  122. package/src/skills/memory-bank/references/anti-patterns.md +33 -0
  123. package/src/skills/memory-bank/references/product-adoption.md +19 -0
  124. package/src/skills/memory-bank/references/storage-model.md +21 -0
  125. package/src/skills/memory-bank/references/structure-and-frequency.md +44 -0
  126. package/src/skills/reflect/SKILL.md +1 -0
  127. package/src/skills/session-goal/SKILL.md +7 -54
  128. package/src/skills/session-goal/references/goal-format.md +26 -0
  129. package/src/skills/session-goal/references/session-reuse.md +44 -0
  130. package/src/skills/tdd-with-agents/SKILL.md +11 -101
  131. package/src/skills/tdd-with-agents/references/advanced-testing-patterns.md +58 -0
  132. package/src/skills/tdd-with-agents/references/testing-by-layer.md +60 -0
  133. package/src/skills/visual-review-pipeline/SKILL.md +11 -120
  134. package/src/skills/visual-review-pipeline/references/findings-schema.md +49 -0
  135. package/src/skills/visual-review-pipeline/references/workflow-steps.md +111 -0
  136. package/scripts/hooks/log-session-start.sh +0 -48
  137. package/scripts/hooks/validate-post-conditions.sh +0 -21
  138. package/scripts/hooks/validate-talos-scope.sh +0 -50
  139. package/scripts/hooks/validate-tool-safety.sh +0 -49
  140. package/src/pantheon/goal-loop.ts +0 -314
  141. package/src/pantheon/idle-continuation.ts +0 -52
  142. package/src/pantheon/todo-preserve.ts +0 -301
  143. package/src/pantheon/tool-ceiling.ts +0 -159
  144. package/src/pantheon/v2-bridge.ts +0 -153
  145. package/src/plugin-v2.ts +0 -2954
  146. package/src/plugins/pantheon-hooks.ts +0 -1433
  147. package/src/plugins/tui/dist/server-v2.d.ts +0 -30
  148. package/src/plugins/tui/dist/server-v2.d.ts.map +0 -1
  149. package/src/plugins/tui/dist/server-v2.js +0 -33
  150. package/src/plugins/tui/dist/server-v2.js.map +0 -1
  151. package/src/plugins/tui/dist/tui-v2.d.ts +0 -1039
  152. package/src/plugins/tui/dist/tui-v2.d.ts.map +0 -1
  153. package/src/plugins/tui/dist/tui-v2.js +0 -4597
  154. package/src/plugins/tui/dist/tui-v2.js.map +0 -1
  155. package/src/plugins/tui/src/index-v2.tsx +0 -4496
  156. package/src/plugins/tui/src/server-v2.ts +0 -28
  157. package/src/plugins/tui/tui-v2.ts +0 -2
  158. /package/src/pantheon/{v2-decision-budget.ts → decision-budget.ts} +0 -0
  159. /package/src/pantheon/{v2-decision-egress.ts → decision-egress.ts} +0 -0
  160. /package/src/pantheon/{v2-decision-events.ts → decision-events.ts} +0 -0
  161. /package/src/pantheon/{v2-decision-heuristic.ts → decision-heuristic.ts} +0 -0
  162. /package/src/pantheon/{v2-decision-premises.ts → decision-premises.ts} +0 -0
  163. /package/src/pantheon/{v2-decision-rank.ts → decision-rank.ts} +0 -0
  164. /package/src/pantheon/{v2-decision-verify.ts → decision-verify.ts} +0 -0
  165. /package/src/pantheon/{v2-delegation-enforce.ts → delegation-policy.ts} +0 -0
  166. /package/src/pantheon/{v2-model-overrides.ts → model-overrides.ts} +0 -0
  167. /package/src/pantheon/{v2-native-decisions.ts → native-decisions.ts} +0 -0
  168. /package/src/plugins/tui/src/{opencode-v2.d.ts → opencode.d.ts} +0 -0
@@ -228,11 +228,9 @@ export function displayPath(target, filePath) {
228
228
  * * `mcpServers` — the MCP servers this pass seeds into opencode.json, in
229
229
  * write order, with their count. Derived from the write path, never a
230
230
  * separate hand-maintained list.
231
- * * `versionAssumed` — the host generation could not be probed, so the plan
232
- * assumes V1 and may diverge from an apply on a 2.x host.
233
231
  *
234
232
  * @param {string} target - install target (used to relativize paths)
235
- * @param {{ files: object[], totals: object, mcpServers?: string[], runtimeEffects?: { venv: string, dependencies: string }, versionAssumed?: boolean }} plan
233
+ * @param {{ files: object[], totals: object, mcpServers?: string[], runtimeEffects?: { venv: string, dependencies: string } }} plan
236
234
  * @param {{ perFile?: boolean }} [options] - `perFile: false` renders the
237
235
  * summary (totals + MCP servers + "No files were written.") without the
238
236
  * per-file list. That is the DEFAULT dry-run surface; the per-file list is
@@ -268,12 +266,6 @@ export function formatChangePlan(target, plan, { perFile = true } = {}) {
268
266
  ` MCP dependencies: ${dependencies === 'install' ? 'install (may download packages)' : dependencies}`,
269
267
  )
270
268
  }
271
- if (plan.versionAssumed) {
272
- lines.push(
273
- ' OpenCode host generation unknown — this plan assumes V1 and may diverge from the ' +
274
- 'apply. Pass --opencode-version v1|v2 to pin it.',
275
- )
276
- }
277
269
  lines.push(' No files were written.')
278
270
  return lines.join('\n')
279
271
  }
@@ -69,7 +69,6 @@ export function runNpmCi(cwd, { timeoutMs = NPM_CI_TIMEOUT_MS, env = sanitizeNpm
69
69
  * @param {string} dstDir - Destination plugin directory
70
70
  * @param {object} [options]
71
71
  * @param {boolean} [options.dryRun=false] - If true, don't write files
72
- * @param {'v1'|'v2'} [options.version='v1'] - Host plugin generation
73
72
  * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
74
73
  * @param {Set<string>|null} [options.reviewedRemovals] - paths approved by the current plan
75
74
  * @param {Map<string, object>|null} [options.reviewedSnapshots] - pre-apply path snapshots
@@ -78,20 +77,15 @@ export function runNpmCi(cwd, { timeoutMs = NPM_CI_TIMEOUT_MS, env = sanitizeNpm
78
77
  export function copyPluginFiles(
79
78
  srcDir,
80
79
  dstDir,
81
- {
82
- dryRun = false,
83
- version = 'v1',
84
- recorder = null,
85
- reviewedRemovals = null,
86
- reviewedSnapshots = null,
87
- } = {},
80
+ { dryRun = false, recorder = null, reviewedRemovals = null, reviewedSnapshots = null } = {},
88
81
  ) {
89
82
  const result = { created: 0, skipped: 0, errors: 0, problems: [] }
90
83
  const distDir = join(dstDir, 'dist')
91
- // The root loader (tui.ts / tui-v2.ts) is only a re-export of the compiled
92
- // bundle. Writing it while the bundle is missing installs a plugin the host
93
- // loads and then fails to resolve — a silent broken install, so refuse.
94
- const requiredBundle = join(srcDir, 'dist', version === 'v2' ? 'tui-v2.js' : 'tui.js')
84
+ // The root loader (tui.ts) is only a re-export of the compiled bundle, and
85
+ // the local plugin entry (index.ts) re-exports the server bundle the host
86
+ // attaches. Writing either while its bundle is missing installs a plugin the
87
+ // host loads and then fails to resolve — a silent broken install, so refuse.
88
+ const requiredBundle = join(srcDir, 'dist', 'tui.js')
95
89
  const bundleAvailable = existsSync(requiredBundle)
96
90
  if (!bundleAvailable) {
97
91
  result.errors++
@@ -100,8 +94,8 @@ export function copyPluginFiles(
100
94
  'plugin entrypoint that re-exports a missing bundle. Reinstall pantheon-opencode.',
101
95
  )
102
96
  }
103
- const requiredServerBundle = join(srcDir, 'dist', 'server-v2.js')
104
- const serverBundleAvailable = version !== 'v2' || existsSync(requiredServerBundle)
97
+ const requiredServerBundle = join(srcDir, 'dist', 'server.js')
98
+ const serverBundleAvailable = existsSync(requiredServerBundle)
105
99
  if (!serverBundleAvailable) {
106
100
  result.errors++
107
101
  result.problems.push(
@@ -142,17 +136,9 @@ export function copyPluginFiles(
142
136
  const pkgSrc = join(srcDir, 'package.json')
143
137
  if (existsSync(pkgSrc)) {
144
138
  const packageJson = JSON.parse(readFileSync(pkgSrc, 'utf8'))
145
- if (version === 'v2' && packageJson.exports?.['./tui-v2']) {
146
- packageJson.exports['./tui'] = packageJson.exports['./tui-v2']
147
- }
148
- // The OpenCode host resolves the plugin server through the `./server` export.
149
- // In the V2 copy it must point at the V2 server entry so the host attaches
150
- // the copy's V2 server half (the TUI reactive channel depends on it);
151
- // otherwise the host loads the V1 server stub of the previous generation's
152
- // payload.
153
- if (version === 'v2' && packageJson.exports?.['./server-v2']) {
154
- packageJson.exports['./server'] = packageJson.exports['./server-v2']
155
- }
139
+ // The host resolves the plugin server through the `./server` export, so
140
+ // the copy carries the manifest verbatim: `./server` points at the server
141
+ // bundle whose attachment the TUI reactive channel depends on.
156
142
  const pkgStatus = writeIfChanged(
157
143
  join(dstDir, 'package.json'),
158
144
  `${JSON.stringify(packageJson, null, 2)}\n`,
@@ -163,8 +149,8 @@ export function copyPluginFiles(
163
149
  else result.skipped++
164
150
  }
165
151
 
166
- // Each host generation receives its own root loader and compiled bundle.
167
- const tuiEntrySrc = join(srcDir, version === 'v2' ? 'tui-v2.ts' : 'tui.ts')
152
+ // The root loader is a re-export of the compiled bundle.
153
+ const tuiEntrySrc = join(srcDir, 'tui.ts')
168
154
  if (!existsSync(tuiEntrySrc)) {
169
155
  result.errors++
170
156
  result.problems.push(
@@ -181,19 +167,19 @@ export function copyPluginFiles(
181
167
  else result.skipped++
182
168
  }
183
169
 
184
- const v2ServerEntry = join(srcDir, 'index-v2.ts')
185
- const v2ServerDestination = join(dstDir, 'index.ts')
186
- if (version === 'v2' && serverBundleAvailable && existsSync(v2ServerEntry)) {
170
+ const serverEntry = join(srcDir, 'index.ts')
171
+ const serverDestination = join(dstDir, 'index.ts')
172
+ if (serverBundleAvailable && existsSync(serverEntry)) {
187
173
  const entryStatus = writeIfChanged(
188
- v2ServerDestination,
189
- readFileSync(v2ServerEntry, 'utf8'),
174
+ serverDestination,
175
+ readFileSync(serverEntry, 'utf8'),
190
176
  dryRun,
191
177
  { recorder },
192
178
  )
193
179
  if (entryStatus === 'created') result.created++
194
180
  else result.skipped++
195
181
  } else {
196
- removeLegacyFile(v2ServerDestination, dstDir, {
182
+ removeLegacyFile(serverDestination, dstDir, {
197
183
  dryRun,
198
184
  recorder,
199
185
  reviewedRemovals,
@@ -290,7 +276,6 @@ export function installPlugin(
290
276
  {
291
277
  dryRun = false,
292
278
  clean = false,
293
- version = 'v1',
294
279
  recorder = null,
295
280
  reviewedRemovals = null,
296
281
  reviewedSnapshots = null,
@@ -311,7 +296,6 @@ export function installPlugin(
311
296
 
312
297
  const copyResult = copyPluginFiles(srcDir, dstDir, {
313
298
  dryRun,
314
- version,
315
299
  recorder,
316
300
  reviewedRemovals,
317
301
  reviewedSnapshots,
@@ -31,6 +31,7 @@ if (!isSupportedNodeVersion(process.versions.node)) {
31
31
  }
32
32
 
33
33
  import { dump, load } from 'js-yaml'
34
+ import { installDecision, mergeOverrides } from './behavior-overrides.bundle.mjs'
34
35
 
35
36
  import {
36
37
  ACTIONS,
@@ -530,6 +531,34 @@ function recordDirectoryOutcomes(srcDir, dstDir, recorder) {
530
531
  }
531
532
  }
532
533
 
534
+ function readOptionalFile(path) {
535
+ try {
536
+ return readFileSync(path, 'utf8')
537
+ } catch {
538
+ return undefined
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Named-behavior overrides for one install target: the registry comes from
544
+ * routing.yml; the override file lives beside the install target (project:
545
+ * `.pantheon/overrides.json`; global config dir: `pantheon-overrides.json`).
546
+ * Override FILES are inputs — never inventoried, never written.
547
+ */
548
+ function loadSkillsOverrideContext(target) {
549
+ let registry = []
550
+ try {
551
+ const routing = load(readFileSync(join(ROOT, 'src', 'routing.yml'), 'utf8'))
552
+ if (Array.isArray(routing?.behaviors)) registry = routing.behaviors
553
+ } catch {
554
+ registry = []
555
+ }
556
+ const globalRaw = readOptionalFile(join(target, 'pantheon-overrides.json'))
557
+ const projectRaw = readOptionalFile(join(target, '.pantheon', 'overrides.json'))
558
+ const { entries: effective } = mergeOverrides(globalRaw, projectRaw)
559
+ return { registry, effective }
560
+ }
561
+
533
562
  export function installSkills(
534
563
  skills,
535
564
  target,
@@ -547,7 +576,14 @@ export function installSkills(
547
576
  let created = 0
548
577
  let skipped = 0
549
578
 
579
+ const { registry, effective } = loadSkillsOverrideContext(target)
550
580
  for (const skill of skills) {
581
+ const decision = installDecision(effective, registry, `skill-${skill}`)
582
+ if (decision === 'skip') continue
583
+ const contentOverride =
584
+ decision && typeof decision === 'object' && 'content' in decision
585
+ ? decision.content
586
+ : undefined
551
587
  const src = join(srcSkillsDir, skill)
552
588
  const dst = join(dstSkillsDir, skill)
553
589
 
@@ -572,7 +608,10 @@ export function installSkills(
572
608
  }
573
609
  copyDirRecursive(srcPath, dstPath)
574
610
  } else {
575
- const content = readFileSync(srcPath, 'utf8')
611
+ const content =
612
+ entry === 'SKILL.md' && from === src && contentOverride !== undefined
613
+ ? contentOverride
614
+ : readFileSync(srcPath, 'utf8')
576
615
  const dstStat = lstatOrNull(dstPath)
577
616
  if (dstStat?.isSymbolicLink()) {
578
617
  throw new Error(`Refusing to read through symlink: ${dstPath}`)
@@ -26,12 +26,9 @@ const REQUIRED_PAYLOAD = [
26
26
  'package/pyproject.toml',
27
27
  'package/src/plugins/tui/package.json',
28
28
  'package/src/plugins/tui/package-lock.json',
29
- 'package/src/plugin.ts',
30
- 'package/src/plugin-v2.ts',
31
- 'package/src/pantheon/v2-bridge.ts',
32
29
  'package/src/plugins/tui/dist/tui.js',
33
30
  'package/src/plugins/tui/dist/server.js',
34
- 'package/src/plugins/tui/dist/server-v2.js',
31
+ 'package/src/plugins/tui/dist/server.js',
35
32
  'package/bin/pantheon-init.mjs',
36
33
  'package/scripts/doctor.mjs',
37
34
  'package/scripts/node-engine-policy.mjs',
@@ -220,7 +220,7 @@ async function main() {
220
220
  const dataHome = join(root, 'data')
221
221
  const opencodeDir = join(dataHome, 'opencode')
222
222
  // Every real installation writes `opencode.db`; the v1/v2 distinction is the
223
- // SCHEMA of that file, never its name. Deriving `opencode-v2.db` here made the
223
+ // SCHEMA of that file, never its name. Deriving `opencode.db` here made the
224
224
  // probe assert a path that exists on no real machine.
225
225
  const selectedDb = join(opencodeDir, 'opencode.db')
226
226
  const otherDb = join(root, 'other.db')
@@ -118,12 +118,11 @@ function resolveTarget(args) {
118
118
  return resolve(join(homedir(), '.config', 'opencode'))
119
119
  }
120
120
 
121
- function layoutFor({ global, version }) {
121
+ function layoutFor({ global }) {
122
+ // V2-only: a project target is always the project-v2 layout; the V1
123
+ // project-v1 layout no longer exists.
122
124
  return Object.fromEntries(
123
- VALID_COMPONENTS.map((component) => [
124
- component,
125
- global ? 'global' : version === 'v2' ? 'project-v2' : 'project-v1',
126
- ]),
125
+ VALID_COMPONENTS.map((component) => [component, global ? 'global' : 'project-v2']),
127
126
  )
128
127
  }
129
128
 
@@ -134,7 +133,6 @@ async function buildReview(target, components, global) {
134
133
  throw new Error('No readable installer state found; unowned legacy files will not be removed')
135
134
  const { installOpenCode } = await import('./install/opencode.mjs')
136
135
  const desired = await installOpenCode(target, true, false, components, {
137
- version: 'auto',
138
136
  global,
139
137
  quiet: true,
140
138
  quietPlan: true,
@@ -146,7 +144,7 @@ async function buildReview(target, components, global) {
146
144
  .filter((file) => typeof file.outputFingerprint === 'string')
147
145
  .map((file) => [file.path, { sha256: file.outputFingerprint }]),
148
146
  )
149
- const selectedLayouts = layoutFor({ global, version: desired?.openCodeVersion })
147
+ const selectedLayouts = layoutFor({ global })
150
148
  const report = classifyFileInventory(target, state, {
151
149
  desiredFiles,
152
150
  selectedComponents: components,
@@ -56,8 +56,8 @@ const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
56
56
 
57
57
  const GATE_NAMES = ['host', 'install', 'package', 'changelog', 'metadata']
58
58
 
59
- /** Support is family-level: these are the families this release supports. */
60
- export const SUPPORTED_FAMILIES = Object.freeze(['1.19.x', '2.x'])
59
+ /** Support is family-level: this is the family this release supports. */
60
+ export const SUPPORTED_FAMILIES = Object.freeze(['2.x'])
61
61
 
62
62
  /** Known-broken hosts. Every other member of a supported family is supported. */
63
63
  export const KNOWN_BROKEN_HOSTS = Object.freeze(['2.0.22'])
@@ -78,9 +78,11 @@ const REQUIRED_TARBALL_PAYLOAD = [
78
78
  'package/package.json',
79
79
  'package/plugin.json',
80
80
  'package/pyproject.toml',
81
+ // The plugin export target and its directory shim (the registered entry).
81
82
  'package/src/plugin.ts',
82
- 'package/src/plugin-v2.ts',
83
+ 'package/src/plugin/index.ts',
83
84
  'package/src/plugins/tui/dist/tui.js',
85
+ 'package/src/plugins/tui/dist/server.js',
84
86
  'package/src/plugins/tui/package.json',
85
87
  'package/src/plugins/tui/package-lock.json',
86
88
  'package/bin/pantheon-init.mjs',
@@ -271,21 +273,12 @@ export function validateMatrix(matrix) {
271
273
  `matrix row ${row.host} has an undeclared family: ${JSON.stringify(row.line)}`,
272
274
  )
273
275
  }
274
- if (row.line === '1.19.x' && !row.host.startsWith('1.19.')) {
275
- throw new Error(`host ${row.host} does not belong to the 1.19.x family`)
276
- }
277
- if (row.line === '2.x' && !row.host.startsWith('2.')) {
276
+ if (!row.host.startsWith('2.')) {
278
277
  throw new Error(`host ${row.host} does not belong to the 2.x family`)
279
278
  }
280
- if (row.line === '1.19.x' && row.kind !== 'v1-permission') {
281
- throw new Error(`kind ${row.kind} cannot run on the 1.19.x family`)
282
- }
283
- if (row.line === '2.x' && row.kind !== 'sandbox-v2') {
279
+ if (row.kind !== 'sandbox-v2') {
284
280
  throw new Error(`kind ${row.kind} cannot run on the 2.x family`)
285
281
  }
286
- if (!['sandbox-v2', 'v1-permission'].includes(row.kind)) {
287
- throw new Error(`matrix row ${row.host} has an unknown kind: ${JSON.stringify(row.kind)}`)
288
- }
289
282
  }
290
283
  }
291
284
 
@@ -295,34 +288,6 @@ export function hostEvidenceWarning(checks) {
295
288
  : null
296
289
  }
297
290
 
298
- function v1Proof(root, row) {
299
- rmSync(root, { recursive: true, force: true })
300
- const prefix = join(root, 'prefix')
301
- const home = join(root, 'home')
302
- mkdirSync(prefix, { recursive: true })
303
- mkdirSync(home, { recursive: true })
304
- run(
305
- `host-${row.host}-install`,
306
- 'npm',
307
- ['install', '--global', '--prefix', prefix, `opencode-ai@${row.host}`],
308
- {
309
- env: { HOME: home, npm_config_cache: join(root, 'npm-cache') },
310
- },
311
- )
312
- const binary = join(prefix, 'bin', 'opencode')
313
- return run(`host-${row.host}`, 'bash', ['tests/canary/run-v1-permission-proof.sh'], {
314
- env: {
315
- HOME: home,
316
- XDG_CONFIG_HOME: join(root, 'config'),
317
- XDG_DATA_HOME: join(root, 'data'),
318
- XDG_STATE_HOME: join(root, 'state'),
319
- XDG_CACHE_HOME: join(root, 'cache'),
320
- PATH: `${join(prefix, 'bin')}:${process.env.PATH ?? ''}`,
321
- PANTHEON_V1_CANARY_BIN: binary,
322
- },
323
- })
324
- }
325
-
326
291
  function hostGate(options) {
327
292
  const tarball = singleTarball(options)
328
293
  const matrix = matrixFromEnv()
@@ -330,21 +295,17 @@ function hostGate(options) {
330
295
  const checks = []
331
296
  matrix.forEach((row, index) => {
332
297
  const root = join(runnerTemp(), `pantheon-release-host-${safeName(row.host)}`)
333
- if (row.kind === 'sandbox-v2') {
334
- rmSync(root, { recursive: true, force: true })
335
- checks.push(
336
- run(
337
- `host-${row.host}`,
338
- 'bash',
339
- ['scripts/test-opencode-v2-sandbox.sh', '--prepare', '--run', 'v2'],
340
- {
341
- env: sandboxEnv(root, row.host, tarball, 49380 + index),
342
- },
343
- ),
344
- )
345
- return
346
- }
347
- checks.push(v1Proof(root, row))
298
+ rmSync(root, { recursive: true, force: true })
299
+ checks.push(
300
+ run(
301
+ `host-${row.host}`,
302
+ 'bash',
303
+ ['scripts/test-opencode-sandbox.sh', '--prepare', '--run', 'v2'],
304
+ {
305
+ env: sandboxEnv(root, row.host, tarball, 49380 + index),
306
+ },
307
+ ),
308
+ )
348
309
  })
349
310
  const measuredFamilies = [...new Set(matrix.map((row) => row.line))]
350
311
  const unmeasuredFamilies = SUPPORTED_FAMILIES.filter(
@@ -380,7 +341,7 @@ function installGate(options) {
380
341
  const sandbox = run(
381
342
  'sandbox-install',
382
343
  'bash',
383
- ['scripts/test-opencode-v2-sandbox.sh', '--prepare', '--run', 'v2'],
344
+ ['scripts/test-opencode-sandbox.sh', '--prepare', '--run', 'v2'],
384
345
  { env: sandboxEnv(root, host, tarball, port) },
385
346
  )
386
347
  const version = installedVersion(root)
@@ -459,19 +420,19 @@ function packageGate(options) {
459
420
  const validate = run('package-validate', 'npm', ['run', 'package:validate'])
460
421
 
461
422
  // TUI dist stamp gate (QA beta.20 "O artefato TUI"): the sidebar version is
462
- // build-time baked into tui-v2.js — a stale embed ships a footer lying about
423
+ // build-time baked into tui.js — a stale embed ships a footer lying about
463
424
  // the running version. Extract the dist from THIS tarball and require the
464
425
  // release version string to be present.
465
426
  const stamp = run(
466
427
  'tui-dist-read',
467
428
  'tar',
468
- ['-xzOf', tarball, 'package/src/plugins/tui/dist/tui-v2.js'],
429
+ ['-xzOf', tarball, 'package/src/plugins/tui/dist/tui.js'],
469
430
  { echo: false },
470
431
  )
471
432
  const distText = stamp.output
472
433
  if (!distText.includes(options.version)) {
473
434
  throw new Error(
474
- `TUI dist embed is stale: ${options.version} not found in the packaged tui-v2.js — ` +
435
+ `TUI dist embed is stale: ${options.version} not found in the packaged tui.js — ` +
475
436
  'rebuild the TUI workspace (npm run build --workspace=src/plugins/tui) at the release version and repack',
476
437
  )
477
438
  }
@@ -4,8 +4,9 @@ import { isDeepStrictEqual } from 'node:util'
4
4
  import * as clack from '@clack/prompts'
5
5
  import { createBackupSet } from './install/backup.mjs'
6
6
  import {
7
+ convertLegacyPermissionsToV2,
7
8
  MCP_ENTRYPOINT_RENAMES,
8
- migrateV1toV2,
9
+ normalizeMcpConfigToV2,
9
10
  PANTHEON_MCP_ENTRYPOINTS,
10
11
  validateMcpV1toV2Source,
11
12
  } from './install/config-migration.mjs'
@@ -481,7 +482,7 @@ function inspectInstallerEntries(config) {
481
482
  const plugins = new Set()
482
483
  if (Array.isArray(config.plugins)) {
483
484
  for (const entry of config.plugins) {
484
- if (pluginReferenceIdentity(entry) === 'src/plugin-v2') plugins.add('V2 plugin')
485
+ if (pluginReferenceIdentity(entry) === 'src/plugin') plugins.add('V2 plugin')
485
486
  }
486
487
  }
487
488
 
@@ -593,7 +594,7 @@ function managedEntryMovePlan(files) {
593
594
  const sourcePlugins = sourcePluginsProperty?.valueNode
594
595
  if (sourcePlugins?.type === 'array') {
595
596
  const pluginItems = sourcePlugins.items.filter(
596
- (item) => pluginReferenceIdentity(item.value) === 'src/plugin-v2',
597
+ (item) => pluginReferenceIdentity(item.value) === 'src/plugin',
597
598
  )
598
599
  if (pluginItems.length > 0) {
599
600
  const targetPlugins = target.config?.plugins
@@ -606,7 +607,7 @@ function managedEntryMovePlan(files) {
606
607
  const prefixCount = pluginItems.length
607
608
  const prefixSafe = pluginItems.every((item, index) => sourcePlugins.items[index] === item)
608
609
  const targetManagedPlugins = Array.isArray(targetPlugins)
609
- ? targetPlugins.filter((plugin) => pluginReferenceIdentity(plugin) === 'src/plugin-v2')
610
+ ? targetPlugins.filter((plugin) => pluginReferenceIdentity(plugin) === 'src/plugin')
610
611
  : []
611
612
  if (targetManagedPlugins.length > 0) {
612
613
  const exactDuplicate =
@@ -632,7 +633,7 @@ function managedEntryMovePlan(files) {
632
633
  const targetSafe =
633
634
  targetPlugins === undefined ||
634
635
  (Array.isArray(targetPlugins) &&
635
- !targetPlugins.some((plugin) => pluginReferenceIdentity(plugin) === 'src/plugin-v2'))
636
+ !targetPlugins.some((plugin) => pluginReferenceIdentity(plugin) === 'src/plugin'))
636
637
  const canMove =
637
638
  prefixSafe &&
638
639
  exactSourceDuplicates &&
@@ -716,7 +717,7 @@ function addManagedEntriesToJson(config, moves, disabledMcpServers = []) {
716
717
  if (!isRecord(config.mcp)) throw new Error('Target MCP map is unsupported.')
717
718
  let targetShape = validateMcpV1toV2Source(config.mcp)
718
719
  if (move.nested && !targetShape.hasV2ServersMap && Object.hasOwn(config.mcp, 'servers')) {
719
- config.mcp = migrateV1toV2({ mcp: config.mcp }).mcp
720
+ config.mcp = normalizeMcpConfigToV2(config.mcp)
720
721
  targetShape = validateMcpV1toV2Source(config.mcp)
721
722
  }
722
723
  const nested = move.nested || targetShape.hasV2ServersMap
@@ -855,8 +856,9 @@ function makeV2Policy(source, askChoices) {
855
856
  if (source.key === 'permission') {
856
857
  validateLegacyPolicy(source.value)
857
858
  const permission = applyAskChoices(source, askChoices)
858
- const converted = migrateV1toV2({ permission }, { mcpServerNames: source.mcpServers ?? [] })
859
- const policy = converted.permissions ?? []
859
+ const policy = convertLegacyPermissionsToV2(permission, {
860
+ mcpServerNames: source.mcpServers ?? [],
861
+ })
860
862
  validateV2Policy(policy)
861
863
  return policy
862
864
  }
package/scripts/setup.mjs CHANGED
@@ -5,7 +5,7 @@ import path from 'node:path'
5
5
  import { fileURLToPath } from 'node:url'
6
6
  import { isDeepStrictEqual } from 'node:util'
7
7
  import * as clack from '@clack/prompts'
8
- import { parseOpenCodeVersion, resolveOpenCodeVersion } from './install/opencode-version.mjs'
8
+ import { resolveOpenCodeVersion } from './install/opencode-version.mjs'
9
9
  import { planArtifactDigest } from './install/plan-artifact.mjs'
10
10
  import {
11
11
  applyConfigChanges,
@@ -157,7 +157,11 @@ function safeOperationPath(value) {
157
157
  return parts.join('/')
158
158
  }
159
159
 
160
- /** Review and apply the opt-in V2 migration before allowing init to write. */
160
+ /**
161
+ * Review and apply the opt-in config migration before allowing init to write.
162
+ * V2-only: setup exists for OpenCode 2.x hosts, and the generation gate refuses
163
+ * a confirmed 1.x host before anything runs.
164
+ */
161
165
  export async function runSetup({
162
166
  args = process.argv.slice(2),
163
167
  env = process.env,
@@ -196,33 +200,19 @@ export async function runSetup({
196
200
  return helpResult?.status ?? helpResult?.code ?? 0
197
201
  }
198
202
 
199
- let detectionFallback = false
200
- const warnings = []
201
- let generation
202
203
  try {
203
- const requested = parseOpenCodeVersion(args) ?? 'auto'
204
- generation = resolveVersion(requested, {
205
- env,
206
- warn: () =>
207
- warnings.push('OpenCode version detection was inconclusive; pass --version v1 or v2.'),
208
- onFallback: () => {
209
- detectionFallback = true
210
- },
211
- })
204
+ // Single-generation gate: refuse a confirmed 1.x host (and an explicit
205
+ // OPENCODE_VERSION=v1 pin) before any config review or init can run.
206
+ resolveVersion({ env })
212
207
  } catch (error) {
213
208
  writeOutput(
214
209
  output,
215
- `${error instanceof Error ? error.message : 'OpenCode generation selection is invalid; pass --version v1, v2, or auto.'}\n`,
210
+ `${error instanceof Error ? error.message : 'OpenCode generation could not be resolved; install OpenCode 2.x and re-run setup.'}\n`,
216
211
  )
217
212
  return 1
218
213
  }
219
- for (const warning of warnings) writeOutput(output, `${warning}\n`)
220
214
 
221
- const migrationEnabled =
222
- generation === 'v2' &&
223
- !detectionFallback &&
224
- !args.includes('--project') &&
225
- !args.includes('--help')
215
+ const migrationEnabled = !args.includes('--project') && !args.includes('--help')
226
216
  const dryRun = args.includes('--dry-run')
227
217
  let initEnv = env
228
218
  let prepared = { status: 'unchanged', changes: [] }
@@ -265,7 +255,7 @@ export async function runSetup({
265
255
  initEnv = { ...env, PANTHEON_SETUP_TARGET: configDir }
266
256
  }
267
257
 
268
- const pinnedArgs = [...passthroughArgs(args), `--version=${generation}`]
258
+ const pinnedArgs = [...passthroughArgs(args)]
269
259
  const previewArgs = [
270
260
  'init',
271
261
  '--dry-run',
@@ -14,7 +14,6 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync
14
14
  import { homedir } from 'node:os'
15
15
  import { join } from 'node:path'
16
16
  import { fileURLToPath, pathToFileURL } from 'node:url'
17
- import { resolveOpenCodeVersion } from './install/opencode-version.mjs'
18
17
  import { isSupportedNodeVersion } from './node-engine-policy.mjs'
19
18
 
20
19
  const __dirname = fileURLToPath(new URL('.', import.meta.url))
@@ -65,7 +64,7 @@ function resolveConfigDir() {
65
64
  * The raw TSX source is never copied — the loader consumes only the bundle.
66
65
  * @returns {{ created: number, skipped: number }}
67
66
  */
68
- export function copyPluginFiles(srcDir, dstDir, version) {
67
+ export function copyPluginFiles(srcDir, dstDir) {
69
68
  const result = { created: 0, skipped: 0 }
70
69
 
71
70
  mkdirSync(dstDir, { recursive: true })
@@ -90,17 +89,11 @@ export function copyPluginFiles(srcDir, dstDir, version) {
90
89
  const pkgSrc = join(srcDir, 'package.json')
91
90
  if (existsSync(pkgSrc)) {
92
91
  const packageJson = JSON.parse(readFileSync(pkgSrc, 'utf8'))
93
- if (version === 'v2' && packageJson.exports?.['./tui-v2']) {
94
- packageJson.exports['./tui'] = packageJson.exports['./tui-v2']
95
- }
96
92
  // Mirror of scripts/install/plugin.mjs: the OpenCode host resolves the
97
93
  // plugin server through the `./server` export. In the V2 copy it must
98
94
  // point at the V2 server entry so the host attaches the copy's V2 server
99
95
  // half (the TUI reactive channel depends on it); otherwise the host loads
100
96
  // the V1 server stub of the previous generation's payload.
101
- if (version === 'v2' && packageJson.exports?.['./server-v2']) {
102
- packageJson.exports['./server'] = packageJson.exports['./server-v2']
103
- }
104
97
  const content = `${JSON.stringify(packageJson, null, 2)}\n`
105
98
  if (writeIfChanged(join(dstDir, 'package.json'), content)) result.created++
106
99
  else result.skipped++
@@ -117,19 +110,19 @@ export function copyPluginFiles(srcDir, dstDir, version) {
117
110
  } else result.skipped++
118
111
  }
119
112
 
120
- const tuiEntry = join(srcDir, version === 'v2' ? 'tui-v2.ts' : 'tui.ts')
113
+ const tuiEntry = join(srcDir, 'tui.ts')
121
114
  if (existsSync(tuiEntry)) {
122
115
  if (writeIfChanged(join(dstDir, 'tui.ts'), readFileSync(tuiEntry, 'utf8'))) result.created++
123
116
  else result.skipped++
124
117
  }
125
118
 
126
- const v2ServerEntry = join(srcDir, 'index-v2.ts')
127
- const v2ServerDestination = join(dstDir, 'index.ts')
128
- if (version === 'v2' && existsSync(v2ServerEntry)) {
129
- if (writeIfChanged(v2ServerDestination, readFileSync(v2ServerEntry, 'utf8'))) result.created++
119
+ const serverEntry = join(srcDir, 'index.ts')
120
+ const serverDestination = join(dstDir, 'index.ts')
121
+ if (existsSync(serverEntry)) {
122
+ if (writeIfChanged(serverDestination, readFileSync(serverEntry, 'utf8'))) result.created++
130
123
  else result.skipped++
131
- } else if (existsSync(v2ServerDestination)) {
132
- rmSync(v2ServerDestination, { force: true })
124
+ } else if (existsSync(serverDestination)) {
125
+ rmSync(serverDestination, { force: true })
133
126
  }
134
127
 
135
128
  // Keep the copied plugin installable with deterministic npm ci.
@@ -209,8 +202,7 @@ async function main() {
209
202
  const sourceVersion = readVersion(join(tuiSrcDir, 'package.json'))
210
203
 
211
204
  // Copy fresh files
212
- const version = resolveOpenCodeVersion('auto', { warn: (message) => console.warn(message) })
213
- const { created } = copyPluginFiles(tuiSrcDir, tuiCopyDir, version)
205
+ const { created } = copyPluginFiles(tuiSrcDir, tuiCopyDir)
214
206
 
215
207
  // Lockfile installation is the only accepted dependency path. Strip
216
208
  // global-context npm vars so a global postinstall can't trigger ECIGLOBAL.