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.
- package/AGENTS.global.md +118 -0
- package/AGENTS.md +18 -168
- package/CHANGELOG.md +144 -365
- package/README.md +124 -607
- package/README.pt-BR.md +120 -345
- package/bin/pantheon-init.mjs +504 -141
- package/commands/pantheon-deepwork.md +14 -3
- package/commands/pantheon-vision.md +61 -12
- package/package.json +22 -13
- package/plugin.json +1 -1
- package/pyproject.toml +6 -2
- package/scripts/_pantheon_paths.py +24 -0
- package/scripts/build-agents-md.mjs +368 -69
- package/scripts/changelog-merge.mjs +161 -0
- package/scripts/check-plugin-v2-coverage.mjs +11 -8
- package/scripts/docs-check-changelog.mjs +204 -0
- package/scripts/docs-link-check.mjs +314 -0
- package/scripts/docs-media.mjs +157 -0
- package/scripts/doctor.mjs +850 -45
- package/scripts/install/agents-md.mjs +2 -2
- package/scripts/install/backup.mjs +648 -0
- package/scripts/install/cli-ui.mjs +303 -72
- package/scripts/install/component-selection.mjs +61 -0
- package/scripts/install/config-migration.mjs +583 -27
- package/scripts/install/exit-codes.mjs +26 -0
- package/scripts/install/file-inventory.mjs +555 -0
- package/scripts/install/health-check.mjs +31 -25
- package/scripts/install/interactive.mjs +99 -383
- package/scripts/install/interrupt.mjs +78 -0
- package/scripts/install/migrate.mjs +49 -25
- package/scripts/install/model-picker.mjs +218 -250
- package/scripts/install/opencode-state.mjs +91 -0
- package/scripts/install/opencode-version.mjs +83 -21
- package/scripts/install/opencode.mjs +1675 -187
- package/scripts/install/plan-artifact.mjs +517 -0
- package/scripts/install/plan.mjs +475 -0
- package/scripts/install/plugin.mjs +214 -27
- package/scripts/install/prompt-result.mjs +2 -0
- package/scripts/install/run-record.mjs +115 -0
- package/scripts/install/shared.mjs +256 -99
- package/scripts/install/state.mjs +63 -8
- package/scripts/install/strings.mjs +93 -8
- package/scripts/install/v2-capabilities.mjs +205 -0
- package/scripts/install/venv.mjs +90 -47
- package/scripts/install/verify.mjs +128 -0
- package/scripts/install/vision-prompt.mjs +173 -0
- package/scripts/install-mcp.mjs +2 -2
- package/scripts/manifest-inventory.mjs +49 -3
- package/scripts/mcp_persistence.py +1535 -1050
- package/scripts/memory_mcp.py +12 -843
- package/scripts/node-engine-policy.mjs +85 -0
- package/scripts/package-evidence.mjs +10 -2
- package/scripts/postinstall.mjs +26 -26
- package/scripts/probe-pantheon-cost.mjs +118 -19
- package/scripts/prune.mjs +9 -3
- package/scripts/reconcile.mjs +325 -0
- package/scripts/release-gates.mjs +687 -0
- package/scripts/restore.mjs +222 -0
- package/scripts/run-node-tests.mjs +24 -8
- package/scripts/sync-artifacts.mjs +19 -7
- package/scripts/sync-tui.mjs +5 -1
- package/scripts/test-opencode-v2-sandbox.sh +36 -123
- package/scripts/uninstall.mjs +369 -34
- package/scripts/update.mjs +164 -0
- package/scripts/validate-node-engine-policy.mjs +13 -0
- package/scripts/version-check.mjs +34 -1
- package/scripts/versioning.mjs +23 -3
- package/scripts/vision-status.mjs +682 -0
- package/skills-lock.json +8 -8
- package/src/agents/aphrodite.md +13 -10
- package/src/agents/apollo.md +4 -5
- package/src/agents/athena.md +74 -46
- package/src/agents/demeter.md +10 -7
- package/src/agents/gaia.md +0 -1
- package/src/agents/hephaestus.md +4 -3
- package/src/agents/hermes.md +10 -9
- package/src/agents/iris.md +6 -1
- package/src/agents/mnemosyne.md +10 -4
- package/src/agents/nyx.md +4 -4
- package/src/agents/prometheus.md +12 -11
- package/src/agents/talos.md +6 -0
- package/src/agents/zeus.md +84 -56
- package/src/instructions/agent-return-format.instructions.md +12 -41
- package/src/instructions/memory-protocol.instructions.md +5 -11
- package/src/instructions/test-economy.instructions.md +12 -0
- package/src/instructions/yagni.instructions.md +6 -15
- package/src/instructions/zeus-anti-stall.instructions.md +6 -6
- package/src/instructions/zeus-communication-rules.instructions.md +6 -6
- package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
- package/src/instructions/zeus-memory-operations.instructions.md +13 -7
- package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
- package/src/mcp/_pantheon_paths.py +24 -0
- package/src/mcp/mcp_codemap_module.py +86 -18
- package/src/mcp/mcp_persistence.py +1535 -1050
- package/src/mcp/memory_mcp.py +444 -94
- package/src/mcp/pantheon_vision.py +285 -41
- package/src/mcp/requirements-mcp.txt +6 -1
- package/src/mcp/requirements-vision.txt +1 -1
- package/src/pantheon/context-pruner.ts +541 -0
- package/src/pantheon/cost-command.ts +901 -60
- package/src/pantheon/delegation-enforce.ts +160 -23
- package/src/pantheon/goal-loop.ts +11 -8
- package/src/pantheon/guard-path.ts +162 -0
- package/src/pantheon/memory-context.ts +1017 -0
- package/src/pantheon/model-agents.ts +19 -0
- package/src/pantheon/model-command.ts +218 -56
- package/src/pantheon/model-pricing.ts +536 -0
- package/src/pantheon/presets.mjs +2 -0
- package/src/pantheon/task-result-guard.ts +50 -14
- package/src/pantheon/v2-bounded-read.ts +654 -0
- package/src/pantheon/v2-bridge.ts +27 -0
- package/src/pantheon/v2-delegation-enforce.ts +133 -6
- package/src/pantheon/v2-execute-after.ts +135 -24
- package/src/pantheon/v2-model-overrides.ts +275 -0
- package/src/pantheon/v2-shell-hooks.ts +260 -0
- package/src/pantheon/v2-tools.ts +89 -35
- package/src/pantheon/v2-unsupported.mjs +34 -7
- package/src/pantheon/v2-vision.ts +622 -0
- package/src/pantheon/vision-local.ts +531 -0
- package/src/pantheon/vision.ts +1166 -116
- package/src/plugin-v2.ts +1039 -171
- package/src/plugin.ts +37 -13
- package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
- package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui-v2.js +3742 -85
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +15 -15
- package/src/plugins/tui/package.json +7 -5
- package/src/plugins/tui/src/index-v2.tsx +4314 -50
- package/src/plugins/tui/tsconfig.typecheck.json +5 -0
- package/src/routing.yml +50 -5
- package/src/skills/agent-coordination/SKILL.md +7 -2
- package/src/skills/artifact-management/SKILL.md +5 -1
- package/src/skills/auto-continue/SKILL.md +14 -6
- package/src/skills/codemap/SKILL.md +1 -1
- package/src/skills/memory-bank/SKILL.md +21 -13
- package/src/skills/session-goal/SKILL.md +12 -22
- package/src/skills/spec-driven-development/SKILL.md +3 -1
- package/src/skills/worktrees/SKILL.md +30 -11
- package/scripts/probe-context-rehydrate.mjs +0 -263
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* release-gates.mjs — the six release gates, fail-closed.
|
|
4
|
+
*
|
|
5
|
+
* ADR-0014 requires every applicable gate to end in an explicit `PASS` on the
|
|
6
|
+
* frozen candidate. This script turns each gate into a binary result and one
|
|
7
|
+
* named evidence file:
|
|
8
|
+
*
|
|
9
|
+
* tests Python/Node/TypeScript suites, the mandatory heavy install tier,
|
|
10
|
+
* and the required coverage thresholds.
|
|
11
|
+
* host The measured OpenCode host evidence, installed and exercised in
|
|
12
|
+
* an isolated sandbox. Support is family-level: a measured row
|
|
13
|
+
* must PASS, an unmeasured supported family is reported as such,
|
|
14
|
+
* and a known-broken host is a failure.
|
|
15
|
+
* install The one immutable .tgz installed as a real user, initialized
|
|
16
|
+
* headlessly, driven through a live host, and compared file-by-file
|
|
17
|
+
* against the checkout.
|
|
18
|
+
* package The same .tgz re-hashed and inspected. No second `npm pack`.
|
|
19
|
+
* changelog The committed `[version]` section exists and is non-empty.
|
|
20
|
+
* metadata Version manifests and the Node engine policy agree.
|
|
21
|
+
*
|
|
22
|
+
* Usage:
|
|
23
|
+
* node scripts/release-gates.mjs <gate> --evidence-dir <dir> [options]
|
|
24
|
+
*
|
|
25
|
+
* Options:
|
|
26
|
+
* --artifact-dir <dir> Directory holding the single .tgz + metadata.json
|
|
27
|
+
* (required by host/install/package).
|
|
28
|
+
* --version <x.y.z> Candidate version (default: package.json version).
|
|
29
|
+
* --target-sha <sha> Full 40-hex candidate SHA (default: TARGET_SHA).
|
|
30
|
+
* --channel stable|beta Release channel (default: RELEASE_CHANNEL|stable).
|
|
31
|
+
* --recovery Recovery dispatch: changelog is the static note.
|
|
32
|
+
*
|
|
33
|
+
* Host evidence: PANTHEON_RELEASE_MATRIX overrides the built-in JSON array. The
|
|
34
|
+
* override is still validated: rows must name a supported family and may not
|
|
35
|
+
* name a known-broken host. A supported family with no row is reported as
|
|
36
|
+
* "supported, unmeasured", not treated as a failure. A measured row that cannot
|
|
37
|
+
* run is a FAIL — this script has no SKIP path on purpose.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { spawnSync } from 'node:child_process'
|
|
41
|
+
import { createHash } from 'node:crypto'
|
|
42
|
+
import {
|
|
43
|
+
accessSync,
|
|
44
|
+
existsSync,
|
|
45
|
+
constants as fsConstants,
|
|
46
|
+
mkdirSync,
|
|
47
|
+
readdirSync,
|
|
48
|
+
readFileSync,
|
|
49
|
+
rmSync,
|
|
50
|
+
statSync,
|
|
51
|
+
writeFileSync,
|
|
52
|
+
} from 'node:fs'
|
|
53
|
+
import { tmpdir } from 'node:os'
|
|
54
|
+
import { basename, dirname, join, resolve } from 'node:path'
|
|
55
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
56
|
+
|
|
57
|
+
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
58
|
+
|
|
59
|
+
const GATE_NAMES = ['tests', 'host', 'install', 'package', 'changelog', 'metadata']
|
|
60
|
+
|
|
61
|
+
/** Support is family-level: these are the families this release supports. */
|
|
62
|
+
export const SUPPORTED_FAMILIES = Object.freeze(['1.19.x', '2.x'])
|
|
63
|
+
|
|
64
|
+
/** Known-broken hosts. Every other member of a supported family is supported. */
|
|
65
|
+
export const KNOWN_BROKEN_HOSTS = Object.freeze(['2.0.22'])
|
|
66
|
+
const UNSUPPORTED_HOSTS = new Set(KNOWN_BROKEN_HOSTS)
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The measured hosts at the time of freezing. Rows are evidence, not the
|
|
70
|
+
* boundary of support: `PANTHEON_RELEASE_MATRIX` overrides them when a release
|
|
71
|
+
* needs to exercise a different host.
|
|
72
|
+
*/
|
|
73
|
+
const DEFAULT_MATRIX = [
|
|
74
|
+
{ host: '2.0.29', line: '2.x', kind: 'sandbox-v2' },
|
|
75
|
+
{ host: '2.0.30', line: '2.x', kind: 'sandbox-v2' },
|
|
76
|
+
{ host: '2.1.0', line: '2.x', kind: 'sandbox-v2' },
|
|
77
|
+
{ host: '2.1.3', line: '2.x', kind: 'sandbox-v2' },
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
const REQUIRED_TARBALL_PAYLOAD = [
|
|
81
|
+
'package/package.json',
|
|
82
|
+
'package/plugin.json',
|
|
83
|
+
'package/pyproject.toml',
|
|
84
|
+
'package/src/plugin.ts',
|
|
85
|
+
'package/src/plugin-v2.ts',
|
|
86
|
+
'package/src/plugins/tui/dist/tui.js',
|
|
87
|
+
'package/src/plugins/tui/package.json',
|
|
88
|
+
'package/src/plugins/tui/package-lock.json',
|
|
89
|
+
'package/bin/pantheon-init.mjs',
|
|
90
|
+
'package/scripts/doctor.mjs',
|
|
91
|
+
'package/.pantheon/code-mode/compress-inline.py',
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
function usage(message) {
|
|
95
|
+
console.error(`release-gates: ${message}`)
|
|
96
|
+
console.error(
|
|
97
|
+
'usage: node scripts/release-gates.mjs <gate> --evidence-dir <dir> [--artifact-dir <dir>] [--version <v>] [--target-sha <sha>] [--channel stable|beta] [--recovery]',
|
|
98
|
+
)
|
|
99
|
+
process.exit(2)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function parseArgs(argv) {
|
|
103
|
+
const options = {
|
|
104
|
+
evidenceDir: undefined,
|
|
105
|
+
artifactDir: undefined,
|
|
106
|
+
version: undefined,
|
|
107
|
+
targetSha: process.env.TARGET_SHA,
|
|
108
|
+
channel: process.env.RELEASE_CHANNEL ?? 'stable',
|
|
109
|
+
recovery: false,
|
|
110
|
+
}
|
|
111
|
+
const positional = []
|
|
112
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
113
|
+
const arg = argv[i]
|
|
114
|
+
if (arg === '--recovery') {
|
|
115
|
+
options.recovery = true
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
if (
|
|
119
|
+
['--evidence-dir', '--artifact-dir', '--version', '--target-sha', '--channel'].includes(arg)
|
|
120
|
+
) {
|
|
121
|
+
const value = argv[i + 1]
|
|
122
|
+
if (value === undefined) usage(`${arg} requires a value`)
|
|
123
|
+
const key = arg.slice(2).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())
|
|
124
|
+
options[key] = value
|
|
125
|
+
i += 1
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
if (arg.startsWith('-')) usage(`unknown option ${arg}`)
|
|
129
|
+
positional.push(arg)
|
|
130
|
+
}
|
|
131
|
+
if (positional.length !== 1) usage('exactly one gate name is required')
|
|
132
|
+
options.gate = positional[0]
|
|
133
|
+
if (!GATE_NAMES.includes(options.gate)) {
|
|
134
|
+
usage(`unknown gate ${options.gate} (expected: ${GATE_NAMES.join(', ')})`)
|
|
135
|
+
}
|
|
136
|
+
options.evidenceDir = resolve(options.evidenceDir ?? join(runnerTemp(), 'release-gate-evidence'))
|
|
137
|
+
if (options.artifactDir) options.artifactDir = resolve(options.artifactDir)
|
|
138
|
+
if (options.targetSha) options.targetSha = String(options.targetSha).toLowerCase()
|
|
139
|
+
options.version = options.version ?? readPackageVersion()
|
|
140
|
+
return options
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function readPackageVersion() {
|
|
144
|
+
return JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function runnerTemp() {
|
|
148
|
+
return process.env.RUNNER_TEMP ?? tmpdir()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function sha256(buffer) {
|
|
152
|
+
return createHash('sha256').update(buffer).digest('hex')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function tail(text, limit = 4000) {
|
|
156
|
+
const value = String(text ?? '')
|
|
157
|
+
return value.length > limit ? value.slice(-limit) : value
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Run one command and fail on any non-zero exit. Output is echoed so the CI log
|
|
162
|
+
* keeps the real failure; `echo: false` is for probes whose stdout is data.
|
|
163
|
+
*/
|
|
164
|
+
function run(name, command, args = [], options = {}) {
|
|
165
|
+
const started = Date.now()
|
|
166
|
+
const result = spawnSync(command, args, {
|
|
167
|
+
cwd: ROOT,
|
|
168
|
+
env: { ...process.env, ...options.env },
|
|
169
|
+
encoding: 'utf8',
|
|
170
|
+
maxBuffer: 128 * 1024 * 1024,
|
|
171
|
+
})
|
|
172
|
+
const durationMs = Date.now() - started
|
|
173
|
+
const output = `${result.stdout ?? ''}${result.stderr ?? ''}`
|
|
174
|
+
if (options.echo !== false && output) process.stdout.write(output)
|
|
175
|
+
if (result.error) {
|
|
176
|
+
throw new Error(`${name}: could not start ${command}: ${result.error.message}`)
|
|
177
|
+
}
|
|
178
|
+
if (result.signal) throw new Error(`${name}: ${command} was killed by ${result.signal}`)
|
|
179
|
+
if (result.status !== 0) {
|
|
180
|
+
throw new Error(`${name}: ${command} exited ${result.status}\n${tail(output)}`)
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
name,
|
|
184
|
+
status: 'PASS',
|
|
185
|
+
command: [command, ...args].join(' '),
|
|
186
|
+
durationMs,
|
|
187
|
+
output,
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function requireArtifactDir(options) {
|
|
192
|
+
if (!options.artifactDir) throw new Error('--artifact-dir is required for this gate')
|
|
193
|
+
if (!existsSync(options.artifactDir)) {
|
|
194
|
+
throw new Error(`artifact directory does not exist: ${options.artifactDir}`)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function singleTarball(options) {
|
|
199
|
+
requireArtifactDir(options)
|
|
200
|
+
const tarballs = readdirSync(options.artifactDir).filter((name) => name.endsWith('.tgz'))
|
|
201
|
+
if (tarballs.length !== 1) {
|
|
202
|
+
throw new Error(`artifact directory must hold exactly one .tgz, found ${tarballs.length}`)
|
|
203
|
+
}
|
|
204
|
+
const tarball = join(options.artifactDir, tarballs[0])
|
|
205
|
+
if (!statSync(tarball).isFile()) throw new Error(`not a file: ${tarball}`)
|
|
206
|
+
return tarball
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function sandboxEnv(root, host, tarball, port) {
|
|
210
|
+
return {
|
|
211
|
+
PANTHEON_SANDBOX_ROOT: root,
|
|
212
|
+
PANTHEON_SANDBOX_TARBALL: tarball,
|
|
213
|
+
OPENCODE_V2_SPEC: `@opencode/cli@${host}`,
|
|
214
|
+
OPENCODE_V2_BIN: 'opencode',
|
|
215
|
+
PANTHEON_V2_PORT: String(port),
|
|
216
|
+
PORT: String(port),
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function safeName(value) {
|
|
221
|
+
return String(value).replace(/[^0-9A-Za-z.-]/g, '-')
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function installedVersion(root) {
|
|
225
|
+
const manifest = join(
|
|
226
|
+
root,
|
|
227
|
+
'home',
|
|
228
|
+
'.npm-global',
|
|
229
|
+
'lib',
|
|
230
|
+
'node_modules',
|
|
231
|
+
'pantheon-opencode',
|
|
232
|
+
'package.json',
|
|
233
|
+
)
|
|
234
|
+
if (!existsSync(manifest)) throw new Error(`installed package manifest is missing: ${manifest}`)
|
|
235
|
+
return JSON.parse(readFileSync(manifest, 'utf8')).version
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function assertCandidateSha(options) {
|
|
239
|
+
const sha = String(options.targetSha ?? '').toLowerCase()
|
|
240
|
+
if (!/^[0-9a-f]{40}$/.test(sha)) {
|
|
241
|
+
throw new Error('--target-sha must be the full 40-character hexadecimal candidate SHA')
|
|
242
|
+
}
|
|
243
|
+
return sha
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ── Gate (a): tests ──────────────────────────────────────────────────────────
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The Python interpreter used by gate (a).
|
|
250
|
+
*
|
|
251
|
+
* The suite imports `fastmcp`/`mcp` at collection time, so it only means
|
|
252
|
+
* anything when run against the exact pins in `src/mcp/requirements-mcp.txt`.
|
|
253
|
+
* `PANTHEON_PYTHON` (the same variable `scripts/doctor.mjs` honours) points at
|
|
254
|
+
* the isolated venv prepared from those pins. When it is set, a missing or
|
|
255
|
+
* non-executable path is a hard failure: falling back to the ambient `python3`
|
|
256
|
+
* is what produced environment-only collection errors instead of a real
|
|
257
|
+
* verdict. Only an unset variable keeps the developer default.
|
|
258
|
+
*/
|
|
259
|
+
function gatePython() {
|
|
260
|
+
const configured = String(process.env.PANTHEON_PYTHON ?? '').trim()
|
|
261
|
+
if (!configured) return 'python3'
|
|
262
|
+
const resolved = resolve(configured)
|
|
263
|
+
if (!existsSync(resolved)) {
|
|
264
|
+
throw new Error(`PANTHEON_PYTHON does not exist: ${resolved}`)
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
accessSync(resolved, fsConstants.X_OK)
|
|
268
|
+
} catch {
|
|
269
|
+
throw new Error(`PANTHEON_PYTHON is not executable: ${resolved}`)
|
|
270
|
+
}
|
|
271
|
+
return resolved
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function testsGate() {
|
|
275
|
+
const python = gatePython()
|
|
276
|
+
const pythonVersion = run('python-version', python, ['--version'], { echo: false }).output.trim()
|
|
277
|
+
const checks = [
|
|
278
|
+
run('python-tests-coverage', python, [
|
|
279
|
+
'-m',
|
|
280
|
+
'coverage',
|
|
281
|
+
'run',
|
|
282
|
+
'--branch',
|
|
283
|
+
'--source=src/mcp',
|
|
284
|
+
'-m',
|
|
285
|
+
'pytest',
|
|
286
|
+
'-q',
|
|
287
|
+
'--tb=short',
|
|
288
|
+
]),
|
|
289
|
+
run('python-coverage-threshold', python, ['-m', 'coverage', 'report', '--fail-under=80']),
|
|
290
|
+
run('node-tests', 'npm', ['run', 'test:node']),
|
|
291
|
+
run('typescript-tests', 'npm', ['run', 'test:ts']),
|
|
292
|
+
run('plugin-v2-line-coverage', 'npm', ['run', 'coverage:plugin-v2']),
|
|
293
|
+
// Mandatory here and optional in the developer loop: the release gate may
|
|
294
|
+
// not publish without the real-install tier.
|
|
295
|
+
run('install-tier', 'npm', ['run', 'test:install'], {
|
|
296
|
+
env: { PANTHEON_RUN_INSTALL_TESTS: '1' },
|
|
297
|
+
}),
|
|
298
|
+
]
|
|
299
|
+
return {
|
|
300
|
+
checks,
|
|
301
|
+
details: {
|
|
302
|
+
pythonInterpreter: python,
|
|
303
|
+
pythonVersion,
|
|
304
|
+
pinnedRequirements: ['src/mcp/requirements-mcp.txt', 'src/mcp/requirements-vision.txt'],
|
|
305
|
+
requiredCoverage: [
|
|
306
|
+
'python: src/mcp branch coverage >= 80% (coverage report --fail-under=80)',
|
|
307
|
+
'typescript: src/plugin-v2.ts line coverage (coverage:plugin-v2)',
|
|
308
|
+
],
|
|
309
|
+
notPass: [
|
|
310
|
+
'Node coverage (`npm run coverage`) is report-only and is NOT a PASS signal.',
|
|
311
|
+
'TypeScript under src/ outside the plugin-v2 measurement is unmeasured, NOT PASS.',
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ── Gate (b): host compatibility ─────────────────────────────────────────────
|
|
318
|
+
|
|
319
|
+
function matrixFromEnv() {
|
|
320
|
+
const raw = process.env.PANTHEON_RELEASE_MATRIX
|
|
321
|
+
if (!raw) return DEFAULT_MATRIX
|
|
322
|
+
let parsed
|
|
323
|
+
try {
|
|
324
|
+
parsed = JSON.parse(raw)
|
|
325
|
+
} catch (error) {
|
|
326
|
+
throw new Error(`PANTHEON_RELEASE_MATRIX is not valid JSON: ${error.message}`)
|
|
327
|
+
}
|
|
328
|
+
if (!Array.isArray(parsed)) {
|
|
329
|
+
throw new Error('PANTHEON_RELEASE_MATRIX must be a JSON array')
|
|
330
|
+
}
|
|
331
|
+
return parsed
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function validateMatrix(matrix) {
|
|
335
|
+
if (!Array.isArray(matrix)) throw new Error('host evidence must be an array')
|
|
336
|
+
for (const row of matrix) {
|
|
337
|
+
if (!row || typeof row !== 'object') throw new Error('matrix rows must be objects')
|
|
338
|
+
if (!/^\d+\.\d+\.\d+$/.test(String(row.host ?? ''))) {
|
|
339
|
+
throw new Error(`matrix row has an invalid host: ${JSON.stringify(row.host)}`)
|
|
340
|
+
}
|
|
341
|
+
if (UNSUPPORTED_HOSTS.has(row.host)) {
|
|
342
|
+
throw new Error(`host ${row.host} is known broken and may not be measured as supported`)
|
|
343
|
+
}
|
|
344
|
+
if (!SUPPORTED_FAMILIES.includes(row.line)) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`matrix row ${row.host} has an undeclared family: ${JSON.stringify(row.line)}`,
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
if (row.line === '1.19.x' && !row.host.startsWith('1.19.')) {
|
|
350
|
+
throw new Error(`host ${row.host} does not belong to the 1.19.x family`)
|
|
351
|
+
}
|
|
352
|
+
if (row.line === '2.x' && !row.host.startsWith('2.')) {
|
|
353
|
+
throw new Error(`host ${row.host} does not belong to the 2.x family`)
|
|
354
|
+
}
|
|
355
|
+
if (row.line === '1.19.x' && row.kind !== 'v1-permission') {
|
|
356
|
+
throw new Error(`kind ${row.kind} cannot run on the 1.19.x family`)
|
|
357
|
+
}
|
|
358
|
+
if (row.line === '2.x' && row.kind !== 'sandbox-v2') {
|
|
359
|
+
throw new Error(`kind ${row.kind} cannot run on the 2.x family`)
|
|
360
|
+
}
|
|
361
|
+
if (!['sandbox-v2', 'v1-permission'].includes(row.kind)) {
|
|
362
|
+
throw new Error(`matrix row ${row.host} has an unknown kind: ${JSON.stringify(row.kind)}`)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function hostEvidenceWarning(checks) {
|
|
368
|
+
return checks.length === 0
|
|
369
|
+
? 'no measured hosts; supported families are reported as unmeasured'
|
|
370
|
+
: null
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function v1Proof(root, row) {
|
|
374
|
+
rmSync(root, { recursive: true, force: true })
|
|
375
|
+
const prefix = join(root, 'prefix')
|
|
376
|
+
const home = join(root, 'home')
|
|
377
|
+
mkdirSync(prefix, { recursive: true })
|
|
378
|
+
mkdirSync(home, { recursive: true })
|
|
379
|
+
run(
|
|
380
|
+
`host-${row.host}-install`,
|
|
381
|
+
'npm',
|
|
382
|
+
['install', '--global', '--prefix', prefix, `opencode-ai@${row.host}`],
|
|
383
|
+
{
|
|
384
|
+
env: { HOME: home, npm_config_cache: join(root, 'npm-cache') },
|
|
385
|
+
},
|
|
386
|
+
)
|
|
387
|
+
const binary = join(prefix, 'bin', 'opencode')
|
|
388
|
+
return run(`host-${row.host}`, 'bash', ['tests/canary/run-v1-permission-proof.sh'], {
|
|
389
|
+
env: {
|
|
390
|
+
HOME: home,
|
|
391
|
+
XDG_CONFIG_HOME: join(root, 'config'),
|
|
392
|
+
XDG_DATA_HOME: join(root, 'data'),
|
|
393
|
+
XDG_STATE_HOME: join(root, 'state'),
|
|
394
|
+
XDG_CACHE_HOME: join(root, 'cache'),
|
|
395
|
+
PATH: `${join(prefix, 'bin')}:${process.env.PATH ?? ''}`,
|
|
396
|
+
PANTHEON_V1_CANARY_BIN: binary,
|
|
397
|
+
},
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function hostGate(options) {
|
|
402
|
+
const tarball = singleTarball(options)
|
|
403
|
+
const matrix = matrixFromEnv()
|
|
404
|
+
validateMatrix(matrix)
|
|
405
|
+
const checks = []
|
|
406
|
+
matrix.forEach((row, index) => {
|
|
407
|
+
const root = join(runnerTemp(), `pantheon-release-host-${safeName(row.host)}`)
|
|
408
|
+
if (row.kind === 'sandbox-v2') {
|
|
409
|
+
rmSync(root, { recursive: true, force: true })
|
|
410
|
+
checks.push(
|
|
411
|
+
run(
|
|
412
|
+
`host-${row.host}`,
|
|
413
|
+
'bash',
|
|
414
|
+
['scripts/test-opencode-v2-sandbox.sh', '--prepare', '--run', 'v2'],
|
|
415
|
+
{
|
|
416
|
+
env: sandboxEnv(root, row.host, tarball, 49380 + index),
|
|
417
|
+
},
|
|
418
|
+
),
|
|
419
|
+
)
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
checks.push(v1Proof(root, row))
|
|
423
|
+
})
|
|
424
|
+
const measuredFamilies = [...new Set(matrix.map((row) => row.line))]
|
|
425
|
+
const unmeasuredFamilies = SUPPORTED_FAMILIES.filter(
|
|
426
|
+
(family) => !measuredFamilies.includes(family),
|
|
427
|
+
)
|
|
428
|
+
return {
|
|
429
|
+
checks,
|
|
430
|
+
details: {
|
|
431
|
+
supportLevel: 'family',
|
|
432
|
+
supportedFamilies: [...SUPPORTED_FAMILIES],
|
|
433
|
+
measuredFamilies,
|
|
434
|
+
unmeasuredFamilies,
|
|
435
|
+
matrix: matrix.map((row) => ({
|
|
436
|
+
host: row.host,
|
|
437
|
+
line: row.line,
|
|
438
|
+
kind: row.kind,
|
|
439
|
+
status: 'PASS',
|
|
440
|
+
})),
|
|
441
|
+
unsupportedExcluded: [...UNSUPPORTED_HOSTS],
|
|
442
|
+
},
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ── Gate (c): install ────────────────────────────────────────────────────────
|
|
447
|
+
|
|
448
|
+
function installGate(options) {
|
|
449
|
+
const tarball = singleTarball(options)
|
|
450
|
+
const host = process.env.PANTHEON_RELEASE_INSTALL_HOST ?? '2.0.30'
|
|
451
|
+
const root = join(runnerTemp(), `pantheon-release-install-${safeName(host)}`)
|
|
452
|
+
const port = Number(process.env.PANTHEON_RELEASE_INSTALL_PORT ?? 49390)
|
|
453
|
+
rmSync(root, { recursive: true, force: true })
|
|
454
|
+
|
|
455
|
+
const sandbox = run(
|
|
456
|
+
'sandbox-install',
|
|
457
|
+
'bash',
|
|
458
|
+
['scripts/test-opencode-v2-sandbox.sh', '--prepare', '--run', 'v2'],
|
|
459
|
+
{ env: sandboxEnv(root, host, tarball, port) },
|
|
460
|
+
)
|
|
461
|
+
const version = installedVersion(root)
|
|
462
|
+
if (version !== options.version) {
|
|
463
|
+
throw new Error(
|
|
464
|
+
`installed package version ${version} does not match candidate ${options.version}`,
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const binary = join(root, 'home', '.npm-global', 'bin', 'opencode')
|
|
469
|
+
const packageRoot = join(root, 'home', '.npm-global', 'lib', 'node_modules', 'pantheon-opencode')
|
|
470
|
+
const canary = run('tool-canary', 'npm', ['run', 'test:tool-canary'], {
|
|
471
|
+
env: {
|
|
472
|
+
PANTHEON_TOOL_CANARY_BIN: binary,
|
|
473
|
+
PANTHEON_TOOL_CANARY_PACKAGE_ROOT: packageRoot,
|
|
474
|
+
PANTHEON_TOOL_CANARY_EXPECT_HOST: host,
|
|
475
|
+
PANTHEON_TOOL_CANARY_EXPECT_PACKAGE_VERSION: options.version,
|
|
476
|
+
},
|
|
477
|
+
})
|
|
478
|
+
// The canary itself skips when no binary is found. In release context that
|
|
479
|
+
// skip is not a PASS, so a skip marker fails the gate.
|
|
480
|
+
if (/\(skipped\)/.test(canary.output)) {
|
|
481
|
+
throw new Error('host-backed tool canary was skipped; release context requires a real host')
|
|
482
|
+
}
|
|
483
|
+
writeFileSync(join(options.evidenceDir, 'install-canary.log'), canary.output)
|
|
484
|
+
|
|
485
|
+
return {
|
|
486
|
+
checks: [sandbox, canary],
|
|
487
|
+
details: {
|
|
488
|
+
host,
|
|
489
|
+
version,
|
|
490
|
+
tarball: basename(tarball),
|
|
491
|
+
tarballSha256: sha256(readFileSync(tarball)),
|
|
492
|
+
},
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// ── Gate (d): package ────────────────────────────────────────────────────────
|
|
497
|
+
|
|
498
|
+
function packageGate(options) {
|
|
499
|
+
const tarball = singleTarball(options)
|
|
500
|
+
const metadataPath = join(options.artifactDir, 'metadata.json')
|
|
501
|
+
if (!existsSync(metadataPath)) throw new Error(`artifact metadata is missing: ${metadataPath}`)
|
|
502
|
+
const metadata = JSON.parse(readFileSync(metadataPath, 'utf8'))
|
|
503
|
+
const actualSha = sha256(readFileSync(tarball))
|
|
504
|
+
|
|
505
|
+
if (metadata.targetSha !== options.targetSha) {
|
|
506
|
+
throw new Error('artifact metadata target SHA does not match --target-sha')
|
|
507
|
+
}
|
|
508
|
+
if (metadata.version !== options.version) {
|
|
509
|
+
throw new Error('artifact metadata version does not match --version')
|
|
510
|
+
}
|
|
511
|
+
if (metadata.tarball !== basename(tarball)) {
|
|
512
|
+
throw new Error('artifact metadata does not name the sole .tgz')
|
|
513
|
+
}
|
|
514
|
+
if (metadata.tarballSha256 !== actualSha) {
|
|
515
|
+
throw new Error('artifact SHA-256 does not match metadata')
|
|
516
|
+
}
|
|
517
|
+
const expectedName = `pantheon-opencode-${options.version}.tgz`
|
|
518
|
+
if (basename(tarball) !== expectedName) {
|
|
519
|
+
throw new Error(`artifact must be named ${expectedName}, found ${basename(tarball)}`)
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const listing = run('tarball-contents', 'tar', ['-tzf', tarball], { echo: false }).output
|
|
523
|
+
const entries = new Set(
|
|
524
|
+
listing
|
|
525
|
+
.split('\n')
|
|
526
|
+
.map((line) => line.trim())
|
|
527
|
+
.filter(Boolean),
|
|
528
|
+
)
|
|
529
|
+
const missing = REQUIRED_TARBALL_PAYLOAD.filter((entry) => !entries.has(entry))
|
|
530
|
+
if (missing.length > 0) {
|
|
531
|
+
throw new Error(`tarball is missing required payload: ${missing.join(', ')}`)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const validate = run('package-validate', 'npm', ['run', 'package:validate'])
|
|
535
|
+
return {
|
|
536
|
+
checks: [validate],
|
|
537
|
+
details: {
|
|
538
|
+
tarball: basename(tarball),
|
|
539
|
+
tarballSha256: actualSha,
|
|
540
|
+
targetSha: options.targetSha,
|
|
541
|
+
payloadEntries: entries.size,
|
|
542
|
+
},
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// ── Gate (e): changelog ──────────────────────────────────────────────────────
|
|
547
|
+
|
|
548
|
+
function changelogGate(options) {
|
|
549
|
+
if (options.recovery) {
|
|
550
|
+
const tag = run('recovery-tag', 'git', ['tag', '-l', `v${options.version}`], { echo: false })
|
|
551
|
+
if (tag.output.trim() !== `v${options.version}`) {
|
|
552
|
+
throw new Error(`recovery tag v${options.version} does not exist on this checkout`)
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
checks: [
|
|
556
|
+
{ name: 'recovery-tag', status: 'PASS', command: 'git tag -l', durationMs: tag.durationMs },
|
|
557
|
+
],
|
|
558
|
+
details: { mode: 'recovery-static', version: options.version },
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
const extraction = run(
|
|
562
|
+
'changelog-section',
|
|
563
|
+
'node',
|
|
564
|
+
['scripts/changelog-extract.mjs', options.version],
|
|
565
|
+
{
|
|
566
|
+
echo: false,
|
|
567
|
+
},
|
|
568
|
+
)
|
|
569
|
+
if (!extraction.output.trim()) {
|
|
570
|
+
throw new Error(`CHANGELOG.md has no non-empty [${options.version}] section`)
|
|
571
|
+
}
|
|
572
|
+
writeFileSync(join(options.evidenceDir, 'changelog.md'), extraction.output)
|
|
573
|
+
return {
|
|
574
|
+
checks: [{ ...extraction, output: undefined, sha256: sha256(extraction.output) }],
|
|
575
|
+
details: {
|
|
576
|
+
mode: 'committed-section',
|
|
577
|
+
version: options.version,
|
|
578
|
+
bytes: extraction.output.length,
|
|
579
|
+
},
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
// ── Gate (f): metadata ───────────────────────────────────────────────────────
|
|
584
|
+
|
|
585
|
+
function metadataGate(options) {
|
|
586
|
+
const targetSha = assertCandidateSha(options)
|
|
587
|
+
if (options.version !== readPackageVersion()) {
|
|
588
|
+
throw new Error(`--version ${options.version} does not match package.json`)
|
|
589
|
+
}
|
|
590
|
+
const stable = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
591
|
+
const beta = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-beta\.[1-9]\d*$/
|
|
592
|
+
if (!['stable', 'beta'].includes(options.channel)) {
|
|
593
|
+
throw new Error(`unknown channel ${options.channel}`)
|
|
594
|
+
}
|
|
595
|
+
if (options.channel === 'stable' && !stable.test(options.version)) {
|
|
596
|
+
throw new Error(`stable channel requires X.Y.Z, found ${options.version}`)
|
|
597
|
+
}
|
|
598
|
+
if (options.channel === 'beta' && !beta.test(options.version)) {
|
|
599
|
+
throw new Error(`beta channel requires X.Y.Z-beta.N, found ${options.version}`)
|
|
600
|
+
}
|
|
601
|
+
const checks = [
|
|
602
|
+
run('version-manifests', 'node', ['scripts/version-check.mjs']),
|
|
603
|
+
run('node-engine-policy', 'node', ['scripts/validate-node-engine-policy.mjs']),
|
|
604
|
+
]
|
|
605
|
+
return {
|
|
606
|
+
checks,
|
|
607
|
+
details: {
|
|
608
|
+
version: options.version,
|
|
609
|
+
channel: options.channel,
|
|
610
|
+
targetSha,
|
|
611
|
+
recovery: options.recovery,
|
|
612
|
+
},
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const GATES = {
|
|
617
|
+
tests: testsGate,
|
|
618
|
+
host: hostGate,
|
|
619
|
+
install: installGate,
|
|
620
|
+
package: packageGate,
|
|
621
|
+
changelog: changelogGate,
|
|
622
|
+
metadata: metadataGate,
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function evidenceCheck(check) {
|
|
626
|
+
const { output, ...rest } = check
|
|
627
|
+
if (typeof output === 'string') {
|
|
628
|
+
rest.outputBytes = Buffer.byteLength(output)
|
|
629
|
+
rest.outputSha256 = sha256(output)
|
|
630
|
+
}
|
|
631
|
+
return rest
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
function writeEvidence(options, record) {
|
|
635
|
+
mkdirSync(options.evidenceDir, { recursive: true })
|
|
636
|
+
const path = join(options.evidenceDir, `${options.gate}.json`)
|
|
637
|
+
const serializable = { ...record, checks: record.checks.map(evidenceCheck) }
|
|
638
|
+
writeFileSync(path, `${JSON.stringify(serializable, null, 2)}\n`)
|
|
639
|
+
return path
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function main() {
|
|
643
|
+
const options = parseArgs(process.argv.slice(2))
|
|
644
|
+
mkdirSync(options.evidenceDir, { recursive: true })
|
|
645
|
+
const record = {
|
|
646
|
+
gate: options.gate,
|
|
647
|
+
status: 'PASS',
|
|
648
|
+
version: options.version,
|
|
649
|
+
targetSha: options.targetSha,
|
|
650
|
+
channel: options.channel,
|
|
651
|
+
recovery: options.recovery,
|
|
652
|
+
generatedAt: new Date().toISOString(),
|
|
653
|
+
checks: [],
|
|
654
|
+
details: {},
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
try {
|
|
658
|
+
const result = GATES[options.gate](options)
|
|
659
|
+
record.checks = result.checks ?? []
|
|
660
|
+
record.details = result.details ?? {}
|
|
661
|
+
const warning = options.gate === 'host' ? hostEvidenceWarning(record.checks) : null
|
|
662
|
+
if (warning) {
|
|
663
|
+
record.details.hostEvidenceWarning = warning
|
|
664
|
+
console.warn(`GATE host: WARNING — ${warning}`)
|
|
665
|
+
}
|
|
666
|
+
} catch (error) {
|
|
667
|
+
record.status = 'FAIL'
|
|
668
|
+
record.error = error.message
|
|
669
|
+
const path = writeEvidence(options, record)
|
|
670
|
+
console.error(`GATE ${options.gate}: FAIL — ${error.message}`)
|
|
671
|
+
if (process.env.GITHUB_ACTIONS === 'true') {
|
|
672
|
+
console.error(`::error title=Gate ${options.gate}::FAIL — ${tail(error.message, 500)}`)
|
|
673
|
+
}
|
|
674
|
+
console.error(`evidence: ${path}`)
|
|
675
|
+
process.exit(1)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
const path = writeEvidence(options, record)
|
|
679
|
+
console.log(`GATE ${options.gate}: PASS`)
|
|
680
|
+
if (process.env.GITHUB_ACTIONS === 'true') {
|
|
681
|
+
console.log(`::notice title=Gate ${options.gate}::PASS`)
|
|
682
|
+
}
|
|
683
|
+
console.log(`evidence: ${path}`)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const isDirectRun = process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href
|
|
687
|
+
if (isDirectRun) main()
|