pantheon-opencode 1.6.0-beta.9 → 1.6.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 (140) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +144 -365
  4. package/README.md +124 -607
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +504 -141
  7. package/commands/pantheon-deepwork.md +14 -3
  8. package/commands/pantheon-vision.md +61 -12
  9. package/package.json +22 -13
  10. package/plugin.json +1 -1
  11. package/pyproject.toml +6 -2
  12. package/scripts/_pantheon_paths.py +24 -0
  13. package/scripts/build-agents-md.mjs +368 -69
  14. package/scripts/changelog-merge.mjs +161 -0
  15. package/scripts/check-plugin-v2-coverage.mjs +11 -8
  16. package/scripts/docs-check-changelog.mjs +204 -0
  17. package/scripts/docs-link-check.mjs +314 -0
  18. package/scripts/docs-media.mjs +157 -0
  19. package/scripts/doctor.mjs +850 -45
  20. package/scripts/install/agents-md.mjs +2 -2
  21. package/scripts/install/backup.mjs +648 -0
  22. package/scripts/install/cli-ui.mjs +303 -72
  23. package/scripts/install/component-selection.mjs +61 -0
  24. package/scripts/install/config-migration.mjs +583 -27
  25. package/scripts/install/exit-codes.mjs +26 -0
  26. package/scripts/install/file-inventory.mjs +555 -0
  27. package/scripts/install/health-check.mjs +31 -25
  28. package/scripts/install/interactive.mjs +99 -383
  29. package/scripts/install/interrupt.mjs +78 -0
  30. package/scripts/install/migrate.mjs +49 -25
  31. package/scripts/install/model-picker.mjs +218 -250
  32. package/scripts/install/opencode-state.mjs +91 -0
  33. package/scripts/install/opencode-version.mjs +83 -21
  34. package/scripts/install/opencode.mjs +1675 -187
  35. package/scripts/install/plan-artifact.mjs +517 -0
  36. package/scripts/install/plan.mjs +475 -0
  37. package/scripts/install/plugin.mjs +214 -27
  38. package/scripts/install/prompt-result.mjs +2 -0
  39. package/scripts/install/run-record.mjs +115 -0
  40. package/scripts/install/shared.mjs +256 -99
  41. package/scripts/install/state.mjs +63 -8
  42. package/scripts/install/strings.mjs +93 -8
  43. package/scripts/install/v2-capabilities.mjs +205 -0
  44. package/scripts/install/venv.mjs +90 -47
  45. package/scripts/install/verify.mjs +128 -0
  46. package/scripts/install/vision-prompt.mjs +173 -0
  47. package/scripts/install-mcp.mjs +2 -2
  48. package/scripts/manifest-inventory.mjs +49 -3
  49. package/scripts/mcp_persistence.py +1535 -1050
  50. package/scripts/memory_mcp.py +12 -843
  51. package/scripts/node-engine-policy.mjs +85 -0
  52. package/scripts/package-evidence.mjs +10 -2
  53. package/scripts/postinstall.mjs +26 -26
  54. package/scripts/probe-pantheon-cost.mjs +118 -19
  55. package/scripts/prune.mjs +9 -3
  56. package/scripts/reconcile.mjs +325 -0
  57. package/scripts/release-gates.mjs +687 -0
  58. package/scripts/restore.mjs +222 -0
  59. package/scripts/run-node-tests.mjs +24 -8
  60. package/scripts/sync-artifacts.mjs +19 -7
  61. package/scripts/sync-tui.mjs +5 -1
  62. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  63. package/scripts/uninstall.mjs +369 -34
  64. package/scripts/update.mjs +164 -0
  65. package/scripts/validate-node-engine-policy.mjs +13 -0
  66. package/scripts/version-check.mjs +34 -1
  67. package/scripts/versioning.mjs +23 -3
  68. package/scripts/vision-status.mjs +682 -0
  69. package/skills-lock.json +8 -8
  70. package/src/agents/aphrodite.md +13 -10
  71. package/src/agents/apollo.md +4 -5
  72. package/src/agents/athena.md +74 -46
  73. package/src/agents/demeter.md +10 -7
  74. package/src/agents/gaia.md +0 -1
  75. package/src/agents/hephaestus.md +4 -3
  76. package/src/agents/hermes.md +10 -9
  77. package/src/agents/iris.md +6 -1
  78. package/src/agents/mnemosyne.md +10 -4
  79. package/src/agents/nyx.md +4 -4
  80. package/src/agents/prometheus.md +12 -11
  81. package/src/agents/talos.md +6 -0
  82. package/src/agents/zeus.md +84 -56
  83. package/src/instructions/agent-return-format.instructions.md +12 -41
  84. package/src/instructions/memory-protocol.instructions.md +5 -11
  85. package/src/instructions/test-economy.instructions.md +12 -0
  86. package/src/instructions/yagni.instructions.md +6 -15
  87. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  88. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  89. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  90. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  91. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  92. package/src/mcp/_pantheon_paths.py +24 -0
  93. package/src/mcp/mcp_codemap_module.py +86 -18
  94. package/src/mcp/mcp_persistence.py +1535 -1050
  95. package/src/mcp/memory_mcp.py +444 -94
  96. package/src/mcp/pantheon_vision.py +285 -41
  97. package/src/mcp/requirements-mcp.txt +6 -1
  98. package/src/mcp/requirements-vision.txt +1 -1
  99. package/src/pantheon/context-pruner.ts +541 -0
  100. package/src/pantheon/cost-command.ts +901 -60
  101. package/src/pantheon/delegation-enforce.ts +160 -23
  102. package/src/pantheon/goal-loop.ts +11 -8
  103. package/src/pantheon/guard-path.ts +162 -0
  104. package/src/pantheon/memory-context.ts +1017 -0
  105. package/src/pantheon/model-agents.ts +19 -0
  106. package/src/pantheon/model-command.ts +218 -56
  107. package/src/pantheon/model-pricing.ts +536 -0
  108. package/src/pantheon/presets.mjs +2 -0
  109. package/src/pantheon/task-result-guard.ts +50 -14
  110. package/src/pantheon/v2-bounded-read.ts +654 -0
  111. package/src/pantheon/v2-bridge.ts +27 -0
  112. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  113. package/src/pantheon/v2-execute-after.ts +135 -24
  114. package/src/pantheon/v2-model-overrides.ts +275 -0
  115. package/src/pantheon/v2-shell-hooks.ts +260 -0
  116. package/src/pantheon/v2-tools.ts +89 -35
  117. package/src/pantheon/v2-unsupported.mjs +34 -7
  118. package/src/pantheon/v2-vision.ts +622 -0
  119. package/src/pantheon/vision-local.ts +531 -0
  120. package/src/pantheon/vision.ts +1166 -116
  121. package/src/plugin-v2.ts +1039 -171
  122. package/src/plugin.ts +37 -13
  123. package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
  124. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  125. package/src/plugins/tui/dist/tui-v2.js +3742 -85
  126. package/src/plugins/tui/dist/tui.js +1 -1
  127. package/src/plugins/tui/package-lock.json +15 -15
  128. package/src/plugins/tui/package.json +7 -5
  129. package/src/plugins/tui/src/index-v2.tsx +4314 -50
  130. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  131. package/src/routing.yml +50 -5
  132. package/src/skills/agent-coordination/SKILL.md +7 -2
  133. package/src/skills/artifact-management/SKILL.md +5 -1
  134. package/src/skills/auto-continue/SKILL.md +14 -6
  135. package/src/skills/codemap/SKILL.md +1 -1
  136. package/src/skills/memory-bank/SKILL.md +21 -13
  137. package/src/skills/session-goal/SKILL.md +12 -22
  138. package/src/skills/spec-driven-development/SKILL.md +3 -1
  139. package/src/skills/worktrees/SKILL.md +30 -11
  140. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -0,0 +1,222 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * restore.mjs — Pantheon exact-restore CLI (Beta 11 Setup, phase 2).
4
+ *
5
+ * Restores a backup set created by the installer back into the config dir,
6
+ * reproducing each file byte-for-byte and re-applying its recorded mode. The
7
+ * restore is itself reversible: the CURRENT state is backed up first.
8
+ *
9
+ * Safety contract:
10
+ * - the backup manifest is verified (hash of every backed-up file) before any
11
+ * restore; a tampered or incomplete set is refused outright;
12
+ * - the backup-vs-current diff is shown BY PATH ONLY (never file contents);
13
+ * - writing requires explicit authorization (`--yes`); a non-TTY run without
14
+ * `--yes` previews and exits without writing.
15
+ *
16
+ * Usage:
17
+ * pantheon-opencode restore [--project] [--from <dir>] [--dry-run] [--yes]
18
+ *
19
+ * Exit codes:
20
+ * 0 = restored (or preview shown with --dry-run)
21
+ * 1 = refused (missing/tampered backup, or no authorization)
22
+ * 2 = usage error
23
+ */
24
+
25
+ import { existsSync } from 'node:fs'
26
+ import { homedir } from 'node:os'
27
+ import { isAbsolute, join, resolve } from 'node:path'
28
+
29
+ import {
30
+ backupRoot,
31
+ createBackupSet,
32
+ isBackupDirName,
33
+ listBackupSets,
34
+ planRestore,
35
+ restoreBackupSet,
36
+ verifyBackupSet,
37
+ } from './install/backup.mjs'
38
+
39
+ /**
40
+ * Resolve the config dir whose `opencode.json` the installer manages.
41
+ * `--project` targets the CWD; otherwise XDG / PANTHEON_HOME.
42
+ * @param {{ project?: boolean }} opts
43
+ * @returns {string}
44
+ */
45
+ export function resolveConfigDir({ project = false } = {}) {
46
+ if (project) return resolve(process.cwd())
47
+ if (process.env.PANTHEON_HOME) return resolve(process.env.PANTHEON_HOME)
48
+ const base = process.env.XDG_CONFIG_HOME || join(homedir(), '.config')
49
+ return join(base, 'opencode')
50
+ }
51
+
52
+ export function parseArgs(argv) {
53
+ const args = { project: false, from: null, dryRun: false, yes: false, help: false }
54
+ for (let i = 0; i < argv.length; i++) {
55
+ const arg = argv[i]
56
+ switch (arg) {
57
+ case '--project':
58
+ args.project = true
59
+ break
60
+ case '--dry-run':
61
+ args.dryRun = true
62
+ break
63
+ case '--yes':
64
+ case '-y':
65
+ args.yes = true
66
+ break
67
+ case '--from':
68
+ args.from = argv[++i] ?? null
69
+ break
70
+ case '--help':
71
+ case '-h':
72
+ args.help = true
73
+ break
74
+ default:
75
+ break
76
+ }
77
+ }
78
+ return args
79
+ }
80
+
81
+ export function showHelp() {
82
+ console.log(`
83
+ pantheon-opencode restore — restore an exact installer backup
84
+
85
+ Usage:
86
+ pantheon-opencode restore restore newest backup (global config)
87
+ pantheon-opencode restore --project restore newest backup (project)
88
+ pantheon-opencode restore --from <dir> restore a specific backup set
89
+ pantheon-opencode restore --dry-run preview only (writes nothing)
90
+ pantheon-opencode restore --yes authorize the write (non-interactive)
91
+
92
+ A backup set lives under <config-dir>/.pantheon/backups/<timestamp>/.
93
+ Restore reproduces each file byte-for-byte and re-applies its recorded mode.
94
+ File contents are never printed.
95
+ `)
96
+ }
97
+
98
+ /**
99
+ * Choose the backup set to restore.
100
+ * @param {string} configDir
101
+ * @param {string|null} from
102
+ * @returns {{ dir: string, name: string } | null}
103
+ */
104
+ export function pickBackupSet(configDir, from) {
105
+ if (from) {
106
+ // Accept either a bare timestamp set name (resolved under the backups root)
107
+ // or an explicit directory path.
108
+ if (isBackupDirName(from)) {
109
+ const dir = join(backupRoot(configDir), from)
110
+ return existsSync(dir) ? { dir, name: from } : null
111
+ }
112
+ const dir = isAbsolute(from) ? from : resolve(process.cwd(), from)
113
+ if (!existsSync(dir)) return null
114
+ return { dir, name: dir.split(/[\\/]/).pop() }
115
+ }
116
+ return listBackupSets(configDir)[0] ?? null
117
+ }
118
+
119
+ /**
120
+ * @param {object} opts
121
+ * @param {string} opts.configDir
122
+ * @param {string} opts.backupDir
123
+ * @param {boolean} [opts.dryRun]
124
+ * @param {boolean} [opts.yes]
125
+ * @returns {Promise<{ ok: boolean, code: number, entries?: object[] }>}
126
+ */
127
+ export async function runRestore({ configDir, backupDir, dryRun = false, yes = false }) {
128
+ const verify = verifyBackupSet(backupDir)
129
+ if (!verify.ok) {
130
+ console.error(
131
+ `❌ Refusing to restore: backup failed integrity verification (${verify.reason ?? 'hash mismatch'}).`,
132
+ )
133
+ return { ok: false, code: 1 }
134
+ }
135
+
136
+ const plan = planRestore(backupDir, configDir)
137
+ if (plan.error) {
138
+ console.error(`❌ Refusing to restore: ${plan.error}.`)
139
+ return { ok: false, code: 1 }
140
+ }
141
+
142
+ const counts = { create: 0, update: 0, remove: 0, unchanged: 0 }
143
+ for (const entry of plan.entries) counts[entry.action] += 1
144
+
145
+ console.log('')
146
+ console.log(`Restore plan — ${configDir}`)
147
+ console.log(` from ${backupDir}`)
148
+ for (const entry of plan.entries) {
149
+ if (entry.action === 'unchanged') continue
150
+ console.log(` ${entry.action.padEnd(9)} ${entry.relativePath}`)
151
+ }
152
+ console.log(
153
+ ` ${counts.create} create · ${counts.update} update · ${counts.remove} remove · ${counts.unchanged} unchanged`,
154
+ )
155
+
156
+ if (dryRun) {
157
+ console.log(' (dry-run) No files were written.')
158
+ return { ok: true, code: 0, entries: plan.entries }
159
+ }
160
+
161
+ if (!yes) {
162
+ // Reuse the shared confirm semantics (default NO). An interactive TTY may
163
+ // authorize without --yes; a non-TTY run must never proceed silently.
164
+ const tty = Boolean(process.stdin.isTTY && process.stdout.isTTY)
165
+ if (!tty) {
166
+ console.error('❌ Refusing to restore without authorization. Re-run with --yes.')
167
+ return { ok: false, code: 1 }
168
+ }
169
+ const { promptReview } = await import('./install/interactive.mjs')
170
+ const accepted = await promptReview('Restore these changes?', { default: false })
171
+ if (!accepted) {
172
+ console.log(' Nothing restored.')
173
+ return { ok: true, code: 0, entries: plan.entries }
174
+ }
175
+ }
176
+
177
+ // Reversible: snapshot the CURRENT state of exactly the affected paths first.
178
+ // Retention is DISABLED here (`keep: 0`): a retention pass at this point could
179
+ // delete the very set being restored once 5 older sets already exist (the new
180
+ // snapshot would be the 6th, and pruning would drop the oldest two — including
181
+ // the source). Apply still prunes; restore never deletes backups.
182
+ const { dir: preDir } = createBackupSet({
183
+ configDir,
184
+ entries: plan.manifest.entries.map((e) => e.relativePath),
185
+ packageVersion: plan.manifest.packageVersion,
186
+ keep: 0,
187
+ })
188
+ console.log(` pre-restore backup: ${preDir}`)
189
+
190
+ restoreBackupSet(backupDir, configDir, { dryRun: false })
191
+ console.log(` ✅ Restored ${plan.entries.length} path(s).`)
192
+ return { ok: true, code: 0, entries: plan.entries }
193
+ }
194
+
195
+ async function main() {
196
+ const args = parseArgs(process.argv.slice(2))
197
+ if (args.help) {
198
+ showHelp()
199
+ return
200
+ }
201
+ const configDir = resolveConfigDir({ project: args.project })
202
+ const backup = pickBackupSet(configDir, args.from)
203
+ if (!backup) {
204
+ console.error(`❌ No backup set found under ${backupRoot(configDir)}`)
205
+ process.exitCode = 1
206
+ return
207
+ }
208
+ const result = await runRestore({
209
+ configDir,
210
+ backupDir: backup.dir,
211
+ dryRun: args.dryRun,
212
+ yes: args.yes,
213
+ })
214
+ if (!result.ok) process.exitCode = result.code
215
+ }
216
+
217
+ if (import.meta.url === `file://${process.argv[1]}`) {
218
+ main().catch((err) => {
219
+ console.error(`❌ Restore failed: ${err instanceof Error ? err.message : String(err)}`)
220
+ process.exitCode = 1
221
+ })
222
+ }
@@ -22,16 +22,23 @@
22
22
  * the TAP reporter is diverted to a scratch file that is read once and deleted.
23
23
  *
24
24
  * Usage:
25
- * node scripts/run-node-tests.mjs [--label <name>] [-- <node flags...>] <glob>...
25
+ * node scripts/run-node-tests.mjs [--label <name>] [--exclude <glob>]... \
26
+ * [-- <node flags...>] <glob>...
27
+ *
28
+ * `--exclude` removes files from the expanded set before the runner starts. It
29
+ * exists so a heavy tier (the real-install tests) can be kept out of the default
30
+ * suite without turning the default glob into a hand-maintained file list: a
31
+ * newly added test file is still collected automatically.
26
32
  *
27
33
  * Examples:
28
34
  * node scripts/run-node-tests.mjs 'tests/*.mjs' 'tests/pantheon/*.mjs'
35
+ * node scripts/run-node-tests.mjs --exclude 'tests/install-e2e.test.mjs' 'tests/*.mjs'
29
36
  * node scripts/run-node-tests.mjs -- --experimental-test-coverage 'tests/*.mjs'
30
37
  */
31
38
  import { spawnSync } from 'node:child_process'
32
39
  import { globSync, mkdtempSync, readFileSync, rmSync } from 'node:fs'
33
40
  import { tmpdir } from 'node:os'
34
- import { join } from 'node:path'
41
+ import { join, matchesGlob } from 'node:path'
35
42
  import { fileURLToPath } from 'node:url'
36
43
 
37
44
  const ROOT = join(fileURLToPath(new URL('.', import.meta.url)), '..')
@@ -39,12 +46,12 @@ const ROOT = join(fileURLToPath(new URL('.', import.meta.url)), '..')
39
46
  function usage(message) {
40
47
  console.error(`zero-test-guard: ${message}`)
41
48
  console.error(
42
- 'usage: node scripts/run-node-tests.mjs [--label <name>] [-- <node flags...>] <glob>...',
49
+ 'usage: node scripts/run-node-tests.mjs [--label <name>] [--exclude <glob>]... [-- <node flags...>] <glob>...',
43
50
  )
44
51
  process.exit(1)
45
52
  }
46
53
 
47
- /** Parse `[--label <name>] [-- <node flags...>] <glob>...`. */
54
+ /** Parse `[--label <name>] [--exclude <glob>]... [-- <node flags...>] <glob>...`. */
48
55
  function parseArgs(argv) {
49
56
  const separator = argv.indexOf('--')
50
57
  const own = separator === -1 ? argv : argv.slice(0, separator)
@@ -52,6 +59,7 @@ function parseArgs(argv) {
52
59
 
53
60
  let label = 'node tests'
54
61
  const globs = []
62
+ const excludes = []
55
63
  for (let i = 0; i < own.length; i++) {
56
64
  if (own[i] === '--label') {
57
65
  const value = own[i + 1]
@@ -60,11 +68,18 @@ function parseArgs(argv) {
60
68
  i += 1
61
69
  continue
62
70
  }
71
+ if (own[i] === '--exclude') {
72
+ const value = own[i + 1]
73
+ if (value === undefined) usage('--exclude requires a value')
74
+ excludes.push(value)
75
+ i += 1
76
+ continue
77
+ }
63
78
  if (own[i].startsWith('-')) usage(`unknown option ${own[i]}`)
64
79
  globs.push(own[i])
65
80
  }
66
81
  if (globs.length === 0) usage('at least one glob is required')
67
- return { label, globs, nodeFlags }
82
+ return { label, globs, excludes, nodeFlags }
68
83
  }
69
84
 
70
85
  /**
@@ -72,7 +87,7 @@ function parseArgs(argv) {
72
87
  * Order follows the positional order of the globs so that the suite runs in the same order
73
88
  * as the shell used to; within a glob, matches are sorted for determinism.
74
89
  */
75
- function expand(globs) {
90
+ function expand(globs, excludes = []) {
76
91
  const files = []
77
92
  const seen = new Set()
78
93
  for (const pattern of globs) {
@@ -81,6 +96,7 @@ function expand(globs) {
81
96
  .sort()
82
97
  for (const match of matches) {
83
98
  if (seen.has(match)) continue
99
+ if (excludes.some((exclude) => matchesGlob(match, exclude))) continue
84
100
  seen.add(match)
85
101
  files.push(match)
86
102
  }
@@ -136,8 +152,8 @@ function countCollectedTests(tapPath, files) {
136
152
  return collected
137
153
  }
138
154
 
139
- const { label, globs, nodeFlags } = parseArgs(process.argv.slice(2))
140
- const files = expand(globs)
155
+ const { label, globs, excludes, nodeFlags } = parseArgs(process.argv.slice(2))
156
+ const files = expand(globs, excludes)
141
157
 
142
158
  if (files.length === 0) {
143
159
  reportMissingFiles(label, globs)
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs'
21
21
  import { join } from 'node:path'
22
- import { copyAgentPrompts } from './build-agents-md.mjs'
22
+ import { copyAgentPrompts, writeAgentsMdManaged } from './build-agents-md.mjs'
23
23
 
24
24
  import {
25
25
  collectSkillNames,
@@ -83,15 +83,27 @@ export function syncCopyArtifacts(configDir) {
83
83
  result.errors.push(`skills: ${err.message}`)
84
84
  }
85
85
 
86
- // ── instructions (AGENTS.md) ──
86
+ // ── instructions (global AGENTS.md artifact) ──
87
+ // The config dir is GLOBAL context: it receives the repo-agnostic global
88
+ // artifact, never the repository artifact. Managed-region writer keeps any
89
+ // user content around the markers intact.
87
90
  try {
88
- const src = join(ROOT, 'AGENTS.md')
91
+ const src = join(ROOT, 'AGENTS.global.md')
89
92
  if (existsSync(src)) {
90
- if (
91
- writeIfChanged(join(configDir, 'AGENTS.md'), readFileSync(src, 'utf8'), false) === 'created'
92
- ) {
93
+ const status = writeAgentsMdManaged(
94
+ join(configDir, 'AGENTS.md'),
95
+ readFileSync(src, 'utf8'),
96
+ false,
97
+ )
98
+ if (status === 'skipped') result.skipped++
99
+ else {
93
100
  result.created++
94
- } else result.skipped++
101
+ if (status === 'merged') {
102
+ result.errors.push(
103
+ 'instructions: non-generated content found in AGENTS.md — preserved around the Pantheon managed region',
104
+ )
105
+ }
106
+ }
95
107
  }
96
108
  } catch (err) {
97
109
  result.errors.push(`instructions: ${err.message}`)
@@ -15,6 +15,7 @@ import { homedir } from 'node:os'
15
15
  import { join } from 'node:path'
16
16
  import { fileURLToPath, pathToFileURL } from 'node:url'
17
17
  import { resolveOpenCodeVersion } from './install/opencode-version.mjs'
18
+ import { isSupportedNodeVersion } from './node-engine-policy.mjs'
18
19
 
19
20
  const __dirname = fileURLToPath(new URL('.', import.meta.url))
20
21
  const ROOT = join(__dirname, '..')
@@ -257,7 +258,10 @@ async function main() {
257
258
  const isDirectRun =
258
259
  Boolean(process.argv[1]) && pathToFileURL(process.argv[1]).href === import.meta.url
259
260
 
260
- if (isDirectRun) {
261
+ if (isDirectRun && !isSupportedNodeVersion(process.versions.node)) {
262
+ // postinstall.mjs already reports the engine mismatch. Do not call npm ci or
263
+ // touch the user's config with an incompatible lifecycle runtime.
264
+ } else if (isDirectRun) {
261
265
  main().catch((err) => {
262
266
  console.error(`❌ TUI sync failed: ${err.message}`)
263
267
  process.exitCode = 1
@@ -15,7 +15,7 @@
15
15
  # `@opencode/plugin@2.0.18` SDK contract or compatibility across the full 2.x
16
16
  # line. This project is V2-exclusive, so there is a single host leg to validate.
17
17
  #
18
- # Modes (combinable):
18
+ # Modes (run sequentially; a failure stops later checks):
19
19
  # --prepare Build tarball, install pantheon-opencode + the OpenCode V2
20
20
  # binary in the sandbox prefix, headless init, and generate
21
21
  # the project config and sandbox run-test.sh.
@@ -23,7 +23,6 @@
23
23
  # regenerated first).
24
24
  # --prompts Prompt battery via `opencode run --format json`.
25
25
  # --cost Offline pantheon_cost probe.
26
- # --rehydrate Offline context_rehydrate + context_session_summary probe.
27
26
  # --hooks V2 hook canary: proves hook callbacks FIRE through the
28
27
  # sandbox's V2 binary (not merely that a plugin loaded).
29
28
  # This does not test transform callback effects or Pantheon
@@ -33,6 +32,11 @@
33
32
  #
34
33
  # Env overrides:
35
34
  # PANTHEON_SANDBOX_ROOT Sandbox root (default: ~/pantheon-sandbox)
35
+ # PANTHEON_SANDBOX_TARBALL Optional pre-built package tarball to install
36
+ # instead of running `npm pack` in the checkout. The
37
+ # release gate points this at its one immutable
38
+ # artifact so the sandbox validates the exact bytes
39
+ # that will be published.
36
40
  # OPENCODE_V2_SPEC npm spec providing the V2 binary
37
41
  # (default: @opencode/cli@latest). NOTE: this is an
38
42
  # install spec only — it is not a dependency of this
@@ -67,6 +71,12 @@ OPENCODE_V2_SPEC="${OPENCODE_V2_SPEC:-@opencode/cli@latest}"
67
71
  PANTHEON_SANDBOX_MODEL="${PANTHEON_SANDBOX_MODEL:-opencode-go/mimo-v2.5}"
68
72
  PANTHEON_PROMPT_TIMEOUT="${PANTHEON_PROMPT_TIMEOUT:-300}"
69
73
 
74
+ # Optional pre-built package tarball. The release gate sets this to the ONE
75
+ # immutable artifact it already packed and hashed, so the sandbox installs the
76
+ # exact bytes that will be published instead of packing a second tarball. When
77
+ # unset (developer use) --prepare keeps packing from the checkout.
78
+ SANDBOX_TARBALL="${PANTHEON_SANDBOX_TARBALL:-}"
79
+
70
80
  V2_BIN="${OPENCODE_V2_BIN:-opencode2}"
71
81
 
72
82
  # OpenCode V2's CLI talks to its background service for `mcp list`. Keep the
@@ -88,14 +98,12 @@ TARGET_VERSION="v2"
88
98
 
89
99
  REPORT_FILE="$SANDBOX_ROOT/prompts-report.md"
90
100
  COST_REPORT_FILE="$SANDBOX_ROOT/pantheon-cost-report.md"
91
- REHYDRATE_REPORT_FILE="$SANDBOX_ROOT/context-rehydrate-report.md"
92
101
  EXTRACT_PY="$SANDBOX_ROOT/.prompt-extract-json.py"
93
102
 
94
103
  MODE_PREPARE=0
95
104
  MODE_RESET=0
96
105
  MODE_PROMPTS=0
97
106
  MODE_COST=0
98
- MODE_REHYDRATE=0
99
107
  MODE_HOOKS=0
100
108
  RUN_VERSION=""
101
109
 
@@ -265,7 +273,10 @@ for record in records:
265
273
  if command != python_bin or cwd != runtime_dir or script not in expected:
266
274
  raise SystemExit(1)
267
275
  registered.add(script)
268
- if len(records) != len(expected) or registered != expected:
276
+ # OpenCode can initialize the same configured workspace more than once during
277
+ # service startup and `mcp list`. Count the logical server set here; the later
278
+ # `mcp list` assertion still requires exactly five connected MCP names.
279
+ if registered != expected:
269
280
  raise SystemExit(1)
270
281
  PY
271
282
  then
@@ -1109,14 +1120,26 @@ cmd_reset() {
1109
1120
  }
1110
1121
 
1111
1122
  install_binaries() {
1112
- log "--- Installing pantheon-opencode (from repo tarball) ---"
1113
- cd "$REPO_DIR"
1114
- npm pack --ignore-scripts 2>/dev/null || die "npm pack failed"
1115
- local tgz
1116
- tgz=$(ls -t pantheon-opencode-*.tgz | head -1)
1123
+ local tgz_path
1124
+ if [ -n "$SANDBOX_TARBALL" ]; then
1125
+ [ -f "$SANDBOX_TARBALL" ] \
1126
+ || die "PANTHEON_SANDBOX_TARBALL does not exist: $SANDBOX_TARBALL"
1127
+ tgz_path="$(cd "$(dirname "$SANDBOX_TARBALL")" && pwd)/$(basename "$SANDBOX_TARBALL")"
1128
+ log "--- Installing pantheon-opencode (from supplied release tarball) ---"
1129
+ else
1130
+ log "--- Installing pantheon-opencode (from repo tarball) ---"
1131
+ cd "$REPO_DIR"
1132
+ npm pack --ignore-scripts 2>/dev/null || die "npm pack failed"
1133
+ local tgz
1134
+ tgz=$(ls -t pantheon-opencode-*.tgz | head -1)
1135
+ tgz_path="$REPO_DIR/$tgz"
1136
+ fi
1117
1137
  npm rm -g pantheon-opencode 2>/dev/null || true
1118
- npm install -g "$REPO_DIR/$tgz" || die "install of $tgz failed"
1119
- if ! git -C "$REPO_DIR" ls-files --error-unmatch -- "$tgz" >/dev/null 2>&1; then rm -f -- "$tgz"; fi
1138
+ npm install -g "$tgz_path" || die "install of $(basename "$tgz_path") failed"
1139
+ if [ -z "$SANDBOX_TARBALL" ] \
1140
+ && ! git -C "$REPO_DIR" ls-files --error-unmatch -- "$tgz_path" >/dev/null 2>&1; then
1141
+ rm -f -- "$tgz_path"
1142
+ fi
1120
1143
  log "--- Installing OpenCode V2 ($OPENCODE_V2_SPEC) ---"
1121
1144
  npm install -g "$OPENCODE_V2_SPEC" || die "install of $OPENCODE_V2_SPEC failed"
1122
1145
  }
@@ -1535,45 +1558,6 @@ run_cost_probe() { # v
1535
1558
  record "$v" "pantheon-cost" "$status" "$detail"
1536
1559
  }
1537
1560
 
1538
- run_rehydrate_probe() { # v
1539
- local v="$1" package_root probe raw status detail
1540
- if ! package_root="$(installed_package_root)"; then
1541
- record "$v" "context-rehydrate" "FAIL" "sandbox package is not installed"
1542
- return 0
1543
- fi
1544
- probe="$package_root/scripts/probe-context-rehydrate.mjs"
1545
- if [ ! -f "$probe" ]; then
1546
- record "$v" "context-rehydrate" "FAIL" "installed package has no offline context probe"
1547
- return 0
1548
- fi
1549
- if ! command -v node >/dev/null 2>&1; then
1550
- record "$v" "context-rehydrate" "FAIL" "node runtime is not available"
1551
- return 0
1552
- fi
1553
- set +e
1554
- raw="$(timeout 30 node "$probe" --version "$v" --json 2>&1)"
1555
- local rc=$?
1556
- set -e
1557
- case "$raw" in
1558
- *'"status":"PASS"'*) status="PASS" ;;
1559
- *'"status":"NOT_TESTED"'*) status="FAIL" ;;
1560
- *'"status":"AMBIENTAL"'*) status="FAIL" ;;
1561
- *) status="FAIL" ;;
1562
- esac
1563
- detail="$(printf '%s' "$raw" | tr '\n' ' ' | cut -c1-400)"
1564
- if [ "$rc" -eq 124 ]; then
1565
- status="FAIL"
1566
- detail="context probe timed out after 30s"
1567
- elif [ "$rc" -ne 0 ] && [ "$status" = "PASS" ]; then
1568
- # A non-zero probe exit must never be reported as PASS.
1569
- status="FAIL"
1570
- detail="$detail (probe exit $rc)"
1571
- elif [ "$rc" -ne 0 ] && [ "$status" != "FAIL" ]; then
1572
- detail="$detail (probe exit $rc)"
1573
- fi
1574
- record "$v" "context-rehydrate" "$status" "$detail"
1575
- }
1576
-
1577
1561
  run_version_prompts() { # v
1578
1562
  local v="$1" bin
1579
1563
  if ! bin="$(sandbox_bin)"; then
@@ -1666,31 +1650,6 @@ write_cost_report() { # versions...
1666
1650
  log "Cost probe report written to $COST_REPORT_FILE"
1667
1651
  }
1668
1652
 
1669
- write_rehydrate_report() { # versions...
1670
- local versions=("$@") total_fail=0 total_pass=0
1671
- {
1672
- printf '# Pantheon Context Rehydration Probe Report\n\n'
1673
- printf -- '- **Date:** %s\n' "$(date -u '+%Y-%m-%d %H:%M UTC')"
1674
- printf -- '- **Sandbox:** %s\n\n' "$SANDBOX_ROOT"
1675
- printf '| Version | Probe | Result | Detail |\n|---|---|---|---|\n'
1676
- local v result
1677
- for v in "${versions[@]}"; do
1678
- result="${RESULTS["$v:context-rehydrate"]:-NOT_TESTED}"
1679
- case "$result" in
1680
- PASS) total_pass=$((total_pass + 1)) ;;
1681
- *) total_fail=$((total_fail + 1)) ;;
1682
- esac
1683
- printf '| %s | context_rehydrate + context_session_summary | %s | %s |\n' \
1684
- "$v" "$result" "${DETAILS["$v:context-rehydrate"]:-—}"
1685
- done
1686
- printf '\n## Summary\n\n'
1687
- printf -- '- PASS: %d\n- Not PASS (blocking): %d\n\n' \
1688
- "$total_pass" "$total_fail"
1689
- printf '**Verdict: %s**\n' "$(probe_verdict "$total_pass" "$((total_pass + total_fail))")"
1690
- } > "$REHYDRATE_REPORT_FILE"
1691
- log "Context probe report written to $REHYDRATE_REPORT_FILE"
1692
- }
1693
-
1694
1653
  run_cost() { # versions...
1695
1654
  local versions=("$@") v fail=0
1696
1655
  mkdir -p "$SANDBOX_ROOT"
@@ -1710,25 +1669,6 @@ run_cost() { # versions...
1710
1669
  log "Cost probe: PASS."
1711
1670
  }
1712
1671
 
1713
- run_rehydrate() { # versions...
1714
- local versions=("$@") v fail=0
1715
- mkdir -p "$SANDBOX_ROOT"
1716
- for v in "${versions[@]}"; do
1717
- log "[$v] context_rehydrate/session_summary offline probe ..."
1718
- run_rehydrate_probe "$v"
1719
- log "[$v] context probe → ${RESULTS["$v:context-rehydrate"]}"
1720
- done
1721
- write_rehydrate_report "${versions[@]}"
1722
- for v in "${versions[@]}"; do
1723
- [ "${RESULTS["$v:context-rehydrate"]:-}" = "PASS" ] || fail=$((fail + 1))
1724
- done
1725
- if [ "$fail" -gt 0 ]; then
1726
- log "Context probe: $fail check(s) without explicit PASS."
1727
- exit 1
1728
- fi
1729
- log "Context probe: PASS."
1730
- }
1731
-
1732
1672
  # ── Hook canary (proves callbacks FIRE, not just that a plugin loaded) ────────
1733
1673
 
1734
1674
  run_hooks() {
@@ -1813,7 +1753,6 @@ while [ $# -gt 0 ]; do
1813
1753
  --reset) MODE_RESET=1 ;;
1814
1754
  --prompts) MODE_PROMPTS=1 ;;
1815
1755
  --cost) MODE_COST=1 ;;
1816
- --rehydrate) MODE_REHYDRATE=1 ;;
1817
1756
  --hooks) MODE_HOOKS=1 ;;
1818
1757
  --run)
1819
1758
  shift
@@ -1839,7 +1778,7 @@ fi
1839
1778
 
1840
1779
  if [ "$MODE_PREPARE" -eq 0 ] && [ -z "$RUN_VERSION" ] \
1841
1780
  && [ "$MODE_PROMPTS" -eq 0 ] && [ "$MODE_COST" -eq 0 ] \
1842
- && [ "$MODE_REHYDRATE" -eq 0 ] && [ "$MODE_HOOKS" -eq 0 ]; then
1781
+ && [ "$MODE_HOOKS" -eq 0 ]; then
1843
1782
  usage
1844
1783
  fi
1845
1784
 
@@ -1859,10 +1798,6 @@ if [ -n "$RUN_VERSION" ]; then
1859
1798
  sandbox_env
1860
1799
  run_cost "$RUN_VERSION"
1861
1800
  fi
1862
- if [ "$MODE_REHYDRATE" -eq 1 ]; then
1863
- sandbox_env
1864
- run_rehydrate "$RUN_VERSION"
1865
- fi
1866
1801
  if [ "$MODE_HOOKS" -eq 1 ]; then
1867
1802
  sandbox_env
1868
1803
  run_hooks
@@ -1873,37 +1808,15 @@ elif [ "$MODE_PROMPTS" -eq 1 ]; then
1873
1808
  if [ "$MODE_COST" -eq 1 ]; then
1874
1809
  run_cost "$TARGET_VERSION"
1875
1810
  fi
1876
- if [ "$MODE_REHYDRATE" -eq 1 ]; then
1877
- run_rehydrate "$TARGET_VERSION"
1878
- fi
1879
1811
  if [ "$MODE_HOOKS" -eq 1 ]; then
1880
1812
  run_hooks
1881
1813
  fi
1882
1814
  elif [ "$MODE_COST" -eq 1 ]; then
1883
1815
  sandbox_env
1884
1816
  run_cost "$TARGET_VERSION"
1885
- if [ "$MODE_REHYDRATE" -eq 1 ]; then
1886
- run_rehydrate "$TARGET_VERSION"
1887
- fi
1888
1817
  if [ "$MODE_HOOKS" -eq 1 ]; then
1889
1818
  run_hooks
1890
1819
  fi
1891
- elif [ "$MODE_REHYDRATE" -eq 1 ]; then
1892
- sandbox_env
1893
- rehydrate_status=0
1894
- # run_rehydrate exits when its check fails; isolate it so the separately
1895
- # requested hook canary still runs, then return a failing status afterward.
1896
- (run_rehydrate "$TARGET_VERSION") || rehydrate_status=$?
1897
- hooks_status=0
1898
- if [ "$MODE_HOOKS" -eq 1 ]; then
1899
- (run_hooks) || hooks_status=$?
1900
- fi
1901
- if [ "$rehydrate_status" -ne 0 ]; then
1902
- exit "$rehydrate_status"
1903
- fi
1904
- if [ "$hooks_status" -ne 0 ]; then
1905
- exit "$hooks_status"
1906
- fi
1907
1820
  elif [ "$MODE_HOOKS" -eq 1 ]; then
1908
1821
  sandbox_env
1909
1822
  run_hooks