pantheon-opencode 1.6.0-beta.9 → 1.6.0
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 +126 -376
- package/README.md +83 -610
- package/README.pt-BR.md +120 -345
- package/bin/pantheon-init.mjs +366 -132
- package/commands/pantheon-deepwork.md +14 -3
- package/commands/pantheon-vision.md +61 -12
- package/package.json +19 -11
- 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 +828 -40
- 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 +78 -383
- package/scripts/install/migrate.mjs +49 -25
- package/scripts/install/model-picker.mjs +218 -250
- package/scripts/install/opencode-version.mjs +83 -21
- package/scripts/install/opencode.mjs +1413 -154
- 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/shared.mjs +256 -99
- package/scripts/install/state.mjs +63 -8
- package/scripts/install/strings.mjs +60 -4
- 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 +682 -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 +5 -0
- package/src/pantheon/context-pruner.ts +541 -0
- package/src/pantheon/cost-command.ts +814 -60
- package/src/pantheon/goal-loop.ts +11 -8
- 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 +640 -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-tools.ts +89 -35
- package/src/pantheon/v2-unsupported.mjs +2 -3
- package/src/pantheon/v2-vision.ts +622 -0
- package/src/pantheon/vision-local.ts +531 -0
- package/src/pantheon/vision.ts +1160 -115
- package/src/plugin-v2.ts +654 -162
- package/src/plugin.ts +15 -11
- 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 +6 -6
- package/src/plugins/tui/package.json +5 -4
- 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
package/bin/pantheon-init.mjs
CHANGED
|
@@ -20,14 +20,26 @@ import fs from 'node:fs'
|
|
|
20
20
|
import os from 'node:os'
|
|
21
21
|
import path from 'node:path'
|
|
22
22
|
import { fileURLToPath } from 'node:url'
|
|
23
|
+
import { configure as configureUi, tag } from '../scripts/install/cli-ui.mjs'
|
|
24
|
+
import { resolveComponentSelection } from '../scripts/install/component-selection.mjs'
|
|
25
|
+
import { resolveInstallExitCode } from '../scripts/install/exit-codes.mjs'
|
|
26
|
+
import {
|
|
27
|
+
createPlanArtifact,
|
|
28
|
+
loadPlanArtifact,
|
|
29
|
+
savePlanArtifact,
|
|
30
|
+
} from '../scripts/install/plan-artifact.mjs'
|
|
31
|
+
import { PROMPT_CANCELED } from '../scripts/install/prompt-result.mjs'
|
|
32
|
+
import {
|
|
33
|
+
isSupportedNodeVersion,
|
|
34
|
+
unsupportedNodeVersionMessage,
|
|
35
|
+
} from '../scripts/node-engine-policy.mjs'
|
|
36
|
+
import { runUpdate } from '../scripts/update.mjs'
|
|
23
37
|
|
|
24
38
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
25
39
|
const ROOT = path.resolve(__dirname, '..')
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.error(`❌ Node.js >= ${REQUIRED_NODE_MAJOR} required (current: ${process.versions.node})`)
|
|
30
|
-
console.error(' Install a newer Node via nvm: https://github.com/nvm-sh/nvm')
|
|
41
|
+
if (!isSupportedNodeVersion(process.versions.node)) {
|
|
42
|
+
console.error(unsupportedNodeVersionMessage(process.versions.node))
|
|
31
43
|
process.exit(1)
|
|
32
44
|
}
|
|
33
45
|
|
|
@@ -47,6 +59,10 @@ function printUsage() {
|
|
|
47
59
|
console.log(' npx pantheon-opencode init # Install globally')
|
|
48
60
|
console.log(' npx pantheon-opencode init --project # Install in project')
|
|
49
61
|
console.log(' npx pantheon-opencode init --dry-run # Preview only')
|
|
62
|
+
console.log(' npx pantheon-opencode init --dry-run --save-plan <file> # Save reviewed plan')
|
|
63
|
+
console.log(' npx pantheon-opencode init --apply-plan <file> [--yes] # Apply reviewed plan')
|
|
64
|
+
console.log(' npx pantheon-opencode init --dry-run --json # Versioned JSON preview')
|
|
65
|
+
console.log(' npx pantheon-opencode init --verbose # Step-by-step install detail')
|
|
50
66
|
console.log(' npx pantheon-opencode init --no-mcp # Skip MCP + venv')
|
|
51
67
|
console.log(' npx pantheon-opencode init --force # Overwrite + recreate venv')
|
|
52
68
|
console.log(' npx pantheon-opencode init --doctor # Run health check after install')
|
|
@@ -69,10 +85,35 @@ function printUsage() {
|
|
|
69
85
|
console.log(' npx pantheon-opencode prune # List legacy artifacts (dry-run)')
|
|
70
86
|
console.log(' npx pantheon-opencode prune --apply # Remove stale backups')
|
|
71
87
|
console.log(' npx pantheon-opencode doctor [--profile] # Run health check')
|
|
88
|
+
console.log(
|
|
89
|
+
' npx pantheon-opencode restore [--project] [--yes] # Restore an exact installer backup',
|
|
90
|
+
)
|
|
72
91
|
console.log(' npx pantheon-opencode uninstall --project # Remove project artifacts safely')
|
|
73
92
|
console.log(' npx pantheon-opencode uninstall --global # Remove global artifacts safely')
|
|
93
|
+
console.log(' npx pantheon-opencode reconcile --project # Review stale owned installer files')
|
|
74
94
|
console.log(' npx pantheon-opencode --version, -v # Print version and exit')
|
|
75
95
|
console.log(' npx pantheon-opencode --help # Show this help')
|
|
96
|
+
console.log('')
|
|
97
|
+
console.log('Apply authorization:')
|
|
98
|
+
console.log(' A non-interactive run without --yes prints the plan and applies NOTHING.')
|
|
99
|
+
console.log(' Re-run with --yes to apply; an interactive TTY run prompts (default: no).')
|
|
100
|
+
console.log('')
|
|
101
|
+
console.log('Exit codes:')
|
|
102
|
+
console.log(' 0 success, or plan/no-apply (declined)')
|
|
103
|
+
console.log(' 1 failure')
|
|
104
|
+
console.log(' 2 apply was requested without authorization (non-interactive, no --yes)')
|
|
105
|
+
console.log(' 3 drift detected (a planned file changed after the plan)')
|
|
106
|
+
console.log(' 130 canceled')
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function authorizeReviewedPlan(plan) {
|
|
110
|
+
const operations = plan.operations.filter((operation) => operation.action !== 'unchanged')
|
|
111
|
+
console.log(`Reviewed plan: ${plan.target.path} (${operations.length} change(s))`)
|
|
112
|
+
for (const operation of operations) {
|
|
113
|
+
console.log(` ${operation.action.padEnd(9)} ${operation.path}`)
|
|
114
|
+
}
|
|
115
|
+
const { promptReview } = await import('../scripts/install/interactive.mjs')
|
|
116
|
+
return promptReview('Apply this reviewed plan?', { default: false })
|
|
76
117
|
}
|
|
77
118
|
|
|
78
119
|
async function main() {
|
|
@@ -109,6 +150,27 @@ async function main() {
|
|
|
109
150
|
process.exit(result.status ?? 1)
|
|
110
151
|
}
|
|
111
152
|
|
|
153
|
+
if (command === 'reconcile') {
|
|
154
|
+
const { spawnSync } = await import('node:child_process')
|
|
155
|
+
const reconcileScript = path.join(ROOT, 'scripts', 'reconcile.mjs')
|
|
156
|
+
const result = spawnSync(process.execPath, [reconcileScript, ...args.slice(1)], {
|
|
157
|
+
stdio: 'inherit',
|
|
158
|
+
cwd: process.cwd(),
|
|
159
|
+
})
|
|
160
|
+
process.exit(result.status ?? 1)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// restore delegates to scripts/restore.mjs (same spawnSync pattern as prune).
|
|
164
|
+
if (command === 'restore') {
|
|
165
|
+
const { spawnSync } = await import('node:child_process')
|
|
166
|
+
const restoreScript = path.join(ROOT, 'scripts', 'restore.mjs')
|
|
167
|
+
const result = spawnSync(process.execPath, [restoreScript, ...args.slice(1)], {
|
|
168
|
+
stdio: 'inherit',
|
|
169
|
+
cwd: process.cwd(),
|
|
170
|
+
})
|
|
171
|
+
process.exit(result.status ?? 1)
|
|
172
|
+
}
|
|
173
|
+
|
|
112
174
|
// doctor delegates to scripts/doctor.mjs (same spawnSync pattern as prune).
|
|
113
175
|
// Forwarding the FULL args (profile, target, --fix, ...) keeps the packaged
|
|
114
176
|
// CLI a thin wrapper; the doctor banner reports the resolved profile.
|
|
@@ -125,72 +187,12 @@ async function main() {
|
|
|
125
187
|
// beta.5: one-command update — check npm dist-tag, install, re-init.
|
|
126
188
|
// Default channel is `beta` (the prerelease line); `--stable` uses `latest`.
|
|
127
189
|
if (command === 'update') {
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
console.log(`Pantheon OpenCode v${current} — checking the "${channel}" channel...`)
|
|
134
|
-
const view = spawnSync('npm', ['view', `pantheon-opencode@${channel}`, 'version'], {
|
|
135
|
-
encoding: 'utf8',
|
|
136
|
-
timeout: 30_000,
|
|
137
|
-
})
|
|
138
|
-
const latest = (view.stdout || '').trim().split('\n').filter(Boolean).pop()
|
|
139
|
-
if (view.status !== 0 || !latest) {
|
|
140
|
-
console.error(
|
|
141
|
-
`❌ Could not reach the npm registry: ${(view.stderr || view.stdout || '').trim() || 'no version returned'}`,
|
|
142
|
-
)
|
|
143
|
-
process.exit(1)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Prerelease-aware compare: core (major.minor.patch) first, then the
|
|
147
|
-
// beta counter; a stable release outranks any beta of the same core.
|
|
148
|
-
const parsePantheonVersion = (v) => {
|
|
149
|
-
const m = String(v)
|
|
150
|
-
.trim()
|
|
151
|
-
.match(/^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/)
|
|
152
|
-
if (!m) return null
|
|
153
|
-
return {
|
|
154
|
-
core: [+m[1], +m[2], +m[3]],
|
|
155
|
-
beta: m[4] === undefined ? Number.POSITIVE_INFINITY : +m[4],
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const cmp = (a, b) => {
|
|
159
|
-
const pa = parsePantheonVersion(a)
|
|
160
|
-
const pb = parsePantheonVersion(b)
|
|
161
|
-
if (!pa || !pb) return 0
|
|
162
|
-
for (let i = 0; i < 3; i++) {
|
|
163
|
-
if (pa.core[i] !== pb.core[i]) return pa.core[i] - pb.core[i]
|
|
164
|
-
}
|
|
165
|
-
return pa.beta - pb.beta
|
|
166
|
-
}
|
|
167
|
-
if (cmp(latest, current) <= 0) {
|
|
168
|
-
console.log(`✅ Already up to date (installed v${current}; ${channel} channel: v${latest}).`)
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
console.log(`Updating v${current} → v${latest} (channel: ${channel})...`)
|
|
173
|
-
const install = spawnSync('npm', ['install', '-g', `pantheon-opencode@${channel}`], {
|
|
174
|
-
stdio: 'inherit',
|
|
190
|
+
const status = runUpdate(args, {
|
|
191
|
+
root: ROOT,
|
|
192
|
+
currentVersion: readVersion(),
|
|
193
|
+
runningScript: process.argv[1],
|
|
175
194
|
})
|
|
176
|
-
if (
|
|
177
|
-
console.error('❌ npm install failed — the previous installation is untouched.')
|
|
178
|
-
process.exit(install.status ?? 1)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Refresh config/venv/MCP entries with the NEW package (resolved via
|
|
182
|
-
// PATH — the freshly installed global bin).
|
|
183
|
-
const init = spawnSync('pantheon-opencode', ['init', '--yes', '--headless'], {
|
|
184
|
-
stdio: 'inherit',
|
|
185
|
-
shell: process.platform === 'win32',
|
|
186
|
-
})
|
|
187
|
-
if (init.status !== 0 || init.error) {
|
|
188
|
-
console.error(
|
|
189
|
-
'⚠️ Updated, but the config refresh did not complete — run `npx pantheon-opencode init` manually.',
|
|
190
|
-
)
|
|
191
|
-
process.exit(init.status ?? 1)
|
|
192
|
-
}
|
|
193
|
-
console.log(`✅ Updated to v${latest}.`)
|
|
195
|
+
if (status !== 0) process.exit(status)
|
|
194
196
|
return
|
|
195
197
|
}
|
|
196
198
|
|
|
@@ -248,7 +250,8 @@ async function main() {
|
|
|
248
250
|
|
|
249
251
|
if (name === 'none') {
|
|
250
252
|
if (isDryRun) {
|
|
251
|
-
|
|
253
|
+
configureUi({ dryRun: true })
|
|
254
|
+
console.log(tag('Would clear model preset'))
|
|
252
255
|
} else {
|
|
253
256
|
if (fs.existsSync(filePath)) {
|
|
254
257
|
fs.mkdirSync(path.dirname(bakPath), { recursive: true })
|
|
@@ -274,15 +277,88 @@ async function main() {
|
|
|
274
277
|
}
|
|
275
278
|
|
|
276
279
|
if (command === 'init' || !command) {
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
+
const applyPlanIndex = args.indexOf('--apply-plan')
|
|
281
|
+
const inlineApplyPlan = args.find((arg) => arg.startsWith('--apply-plan='))
|
|
282
|
+
const applyPlanPath =
|
|
283
|
+
applyPlanIndex >= 0
|
|
284
|
+
? (args[applyPlanIndex + 1] ?? null)
|
|
285
|
+
: (inlineApplyPlan?.split('=', 2)[1] ?? null)
|
|
286
|
+
if (applyPlanIndex >= 0 && !applyPlanPath) {
|
|
287
|
+
console.error('❌ --apply-plan requires a plan file path')
|
|
288
|
+
process.exit(1)
|
|
289
|
+
}
|
|
290
|
+
let reviewedPlan = null
|
|
291
|
+
if (applyPlanPath !== null) {
|
|
292
|
+
const allowed = new Set(['init', '--apply-plan', applyPlanPath, '--yes', '-y', '--headless'])
|
|
293
|
+
const normalized = args.map((value) =>
|
|
294
|
+
value.startsWith('--apply-plan=') ? '--apply-plan' : value,
|
|
295
|
+
)
|
|
296
|
+
if (normalized.some((value) => !allowed.has(value))) {
|
|
297
|
+
console.error('❌ --apply-plan accepts only the plan path and fresh authorization flags')
|
|
298
|
+
process.exit(1)
|
|
299
|
+
}
|
|
300
|
+
reviewedPlan = loadPlanArtifact(applyPlanPath)
|
|
301
|
+
if (
|
|
302
|
+
reviewedPlan.artifact_path &&
|
|
303
|
+
path.resolve(applyPlanPath) !== reviewedPlan.artifact_path
|
|
304
|
+
) {
|
|
305
|
+
console.error('❌ The reviewed plan artifact was moved; use its original path')
|
|
306
|
+
process.exit(1)
|
|
307
|
+
}
|
|
308
|
+
const options = reviewedPlan.options
|
|
309
|
+
if (
|
|
310
|
+
!Array.isArray(options.components) ||
|
|
311
|
+
options.components.some(
|
|
312
|
+
(component) =>
|
|
313
|
+
!['agents', 'skills', 'instructions', 'commands', 'plugins', 'runtime'].includes(
|
|
314
|
+
component,
|
|
315
|
+
),
|
|
316
|
+
) ||
|
|
317
|
+
options.clean !== false ||
|
|
318
|
+
!['v1', 'v2', 'auto'].includes(options.version) ||
|
|
319
|
+
typeof options.isProject !== 'boolean'
|
|
320
|
+
) {
|
|
321
|
+
console.error('❌ Install-plan options are invalid or unsupported')
|
|
322
|
+
process.exit(1)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const isProject = reviewedPlan ? reviewedPlan.options.isProject : args.includes('--project')
|
|
326
|
+
const isDryRun = reviewedPlan ? false : args.includes('--dry-run')
|
|
280
327
|
// --clean is an alias of --force (both wipe component dirs + recreate venv).
|
|
281
|
-
const forceReinstall =
|
|
282
|
-
|
|
283
|
-
|
|
328
|
+
const forceReinstall = reviewedPlan
|
|
329
|
+
? reviewedPlan.options.clean
|
|
330
|
+
: args.includes('--force') || args.includes('--clean')
|
|
331
|
+
const runDoctor = !reviewedPlan && args.includes('--doctor')
|
|
332
|
+
const forceInteractive = !reviewedPlan && args.includes('--interactive')
|
|
284
333
|
const forceHeadless = args.includes('--headless')
|
|
285
|
-
|
|
334
|
+
let autoYes = args.includes('--yes') || args.includes('-y')
|
|
335
|
+
const isJson = args.includes('--json')
|
|
336
|
+
const savePlanIndex = args.indexOf('--save-plan')
|
|
337
|
+
const inlineSavePlan = args.find((arg) => arg.startsWith('--save-plan='))
|
|
338
|
+
const savePlanPath =
|
|
339
|
+
savePlanIndex >= 0
|
|
340
|
+
? (args[savePlanIndex + 1] ?? null)
|
|
341
|
+
: (inlineSavePlan?.split('=', 2)[1] ?? null)
|
|
342
|
+
if (savePlanIndex >= 0 && !savePlanPath) {
|
|
343
|
+
console.error('❌ --save-plan requires a plan file path')
|
|
344
|
+
process.exit(1)
|
|
345
|
+
}
|
|
346
|
+
if (savePlanPath !== null && (!isDryRun || reviewedPlan)) {
|
|
347
|
+
console.error('❌ --save-plan is available only with init --dry-run')
|
|
348
|
+
process.exit(1)
|
|
349
|
+
}
|
|
350
|
+
if (savePlanPath !== null && forceReinstall) {
|
|
351
|
+
console.error('❌ Saving a reviewed plan with --force/--clean is not supported safely')
|
|
352
|
+
process.exit(1)
|
|
353
|
+
}
|
|
354
|
+
if (isJson && (!isDryRun || reviewedPlan)) {
|
|
355
|
+
console.error('❌ --json is supported only with init --dry-run')
|
|
356
|
+
process.exit(1)
|
|
357
|
+
}
|
|
358
|
+
if (isJson && forceReinstall) {
|
|
359
|
+
console.error('❌ --force/--clean cleanup is not supported with --json')
|
|
360
|
+
process.exit(1)
|
|
361
|
+
}
|
|
286
362
|
|
|
287
363
|
// beta.5: warn on unrecognized flags instead of silently ignoring them.
|
|
288
364
|
const VALUE_FLAGS = new Set([
|
|
@@ -293,6 +369,8 @@ async function main() {
|
|
|
293
369
|
'--opencode-version',
|
|
294
370
|
'--components',
|
|
295
371
|
'--merge-dev-config',
|
|
372
|
+
'--apply-plan',
|
|
373
|
+
'--save-plan',
|
|
296
374
|
])
|
|
297
375
|
for (let i = 1; i < args.length; i++) {
|
|
298
376
|
const arg = args[i]
|
|
@@ -315,6 +393,8 @@ async function main() {
|
|
|
315
393
|
'--headless',
|
|
316
394
|
'--yes',
|
|
317
395
|
'-y',
|
|
396
|
+
'--json',
|
|
397
|
+
'--verbose',
|
|
318
398
|
].includes(bare)
|
|
319
399
|
) {
|
|
320
400
|
console.error(`⚠️ Unknown option ignored: ${arg}`)
|
|
@@ -322,20 +402,44 @@ async function main() {
|
|
|
322
402
|
}
|
|
323
403
|
|
|
324
404
|
const presetIndex = args.indexOf('--preset')
|
|
325
|
-
const
|
|
405
|
+
const inlinePreset = args.find((arg) => arg.startsWith('--preset='))
|
|
406
|
+
const hasPresetOption = presetIndex >= 0 || inlinePreset !== undefined
|
|
407
|
+
const parsedPreset =
|
|
408
|
+
presetIndex >= 0
|
|
409
|
+
? (args[presetIndex + 1] ?? null)
|
|
410
|
+
: (inlinePreset?.slice('--preset='.length) ?? null)
|
|
411
|
+
if (
|
|
412
|
+
hasPresetOption &&
|
|
413
|
+
(typeof parsedPreset !== 'string' ||
|
|
414
|
+
parsedPreset.trim() === '' ||
|
|
415
|
+
parsedPreset.startsWith('--'))
|
|
416
|
+
) {
|
|
417
|
+
console.error('❌ --preset requires a non-empty value')
|
|
418
|
+
process.exit(1)
|
|
419
|
+
}
|
|
420
|
+
const presetOpt = reviewedPlan ? (reviewedPlan.options.preset ?? null) : parsedPreset
|
|
326
421
|
// Explicit top-level model overrides for the generated config.
|
|
327
422
|
const modelIndex = args.indexOf('--model')
|
|
328
|
-
const modelOpt =
|
|
423
|
+
const modelOpt = reviewedPlan
|
|
424
|
+
? (reviewedPlan.options.model ?? null)
|
|
425
|
+
: modelIndex >= 0
|
|
426
|
+
? (args[modelIndex + 1] ?? null)
|
|
427
|
+
: null
|
|
329
428
|
const smallModelIndex = args.indexOf('--small-model')
|
|
330
|
-
const smallModelOpt =
|
|
429
|
+
const smallModelOpt = reviewedPlan
|
|
430
|
+
? (reviewedPlan.options.smallModel ?? null)
|
|
431
|
+
: smallModelIndex >= 0
|
|
432
|
+
? (args[smallModelIndex + 1] ?? null)
|
|
433
|
+
: null
|
|
331
434
|
// --version v1|v2|auto labels the install target. `auto` resolves the
|
|
332
435
|
// generation from the opencode binary at install time (see
|
|
333
436
|
// scripts/install/opencode-version.mjs). Invalid values fail fast.
|
|
334
437
|
const versionIndex = args.indexOf('--version')
|
|
335
438
|
const legacyVersionIndex = args.indexOf('--opencode-version')
|
|
336
439
|
const inlineVersion = args.find((arg) => arg.startsWith('--opencode-version='))
|
|
337
|
-
const versionOpt =
|
|
338
|
-
|
|
440
|
+
const versionOpt = reviewedPlan
|
|
441
|
+
? reviewedPlan.options.version
|
|
442
|
+
: versionIndex >= 0
|
|
339
443
|
? (args[versionIndex + 1] ?? null)
|
|
340
444
|
: legacyVersionIndex >= 0
|
|
341
445
|
? (args[legacyVersionIndex + 1] ?? null)
|
|
@@ -350,29 +454,18 @@ async function main() {
|
|
|
350
454
|
process.exit(1)
|
|
351
455
|
}
|
|
352
456
|
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (componentsOpt !== null) {
|
|
364
|
-
requestedComponents = componentsOpt
|
|
365
|
-
.split(',')
|
|
366
|
-
.map((c) => c.trim())
|
|
367
|
-
.filter(Boolean)
|
|
368
|
-
const unknown = requestedComponents.filter((c) => !KNOWN_COMPONENTS.includes(c))
|
|
369
|
-
if (requestedComponents.length === 0 || unknown.length > 0) {
|
|
370
|
-
console.error(
|
|
371
|
-
`❌ Invalid --components "${componentsOpt}" — expected comma-separated names from: ${KNOWN_COMPONENTS.join(', ')}`,
|
|
372
|
-
)
|
|
373
|
-
process.exit(1)
|
|
374
|
-
}
|
|
457
|
+
// Resolve the user's explicit selection separately from the defaults. An
|
|
458
|
+
// unscoped install gets runtime by default; explicit --components does not.
|
|
459
|
+
let componentSelection
|
|
460
|
+
try {
|
|
461
|
+
componentSelection = resolveComponentSelection(args, {
|
|
462
|
+
reviewedComponents: reviewedPlan?.options.components ?? null,
|
|
463
|
+
})
|
|
464
|
+
} catch (err) {
|
|
465
|
+
console.error(`❌ ${err.message}`)
|
|
466
|
+
process.exit(1)
|
|
375
467
|
}
|
|
468
|
+
const { components, requestedComponentsForPrompt, noMcp: skipMCP } = componentSelection
|
|
376
469
|
|
|
377
470
|
// --merge-dev-config <path> opts IN to merging a contributor's personal
|
|
378
471
|
// OpenCode config into the generated one. Only third-party plugin/provider/
|
|
@@ -381,8 +474,9 @@ async function main() {
|
|
|
381
474
|
// from the installer code, never from a dev checkout).
|
|
382
475
|
const mergeDevConfigIndex = args.indexOf('--merge-dev-config')
|
|
383
476
|
const inlineMergeDevConfig = args.find((arg) => arg.startsWith('--merge-dev-config='))
|
|
384
|
-
const mergeDevConfigOpt =
|
|
385
|
-
|
|
477
|
+
const mergeDevConfigOpt = reviewedPlan
|
|
478
|
+
? (reviewedPlan.options.mergeDevConfig ?? null)
|
|
479
|
+
: mergeDevConfigIndex >= 0
|
|
386
480
|
? (args[mergeDevConfigIndex + 1] ?? null)
|
|
387
481
|
: (inlineMergeDevConfig?.split('=', 2)[1] ?? null)
|
|
388
482
|
if (mergeDevConfigIndex >= 0 && mergeDevConfigOpt === null) {
|
|
@@ -390,17 +484,23 @@ async function main() {
|
|
|
390
484
|
process.exit(1)
|
|
391
485
|
}
|
|
392
486
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
487
|
+
if (reviewedPlan && !autoYes) {
|
|
488
|
+
if (!forceHeadless && process.stdin.isTTY && process.stdout.isTTY) {
|
|
489
|
+
const authorization = await authorizeReviewedPlan(reviewedPlan)
|
|
490
|
+
if (authorization === PROMPT_CANCELED) {
|
|
491
|
+
console.log('❌ Install canceled; no files were written.')
|
|
492
|
+
process.exitCode = 130
|
|
493
|
+
return
|
|
494
|
+
}
|
|
495
|
+
if (!authorization) {
|
|
496
|
+
console.log('❌ Install declined; no files were written.')
|
|
497
|
+
return
|
|
498
|
+
}
|
|
499
|
+
} else {
|
|
500
|
+
console.error('❌ Applying a reviewed plan requires --yes or an interactive TTY prompt.')
|
|
501
|
+
process.exit(2)
|
|
502
|
+
}
|
|
503
|
+
autoYes = true
|
|
404
504
|
}
|
|
405
505
|
|
|
406
506
|
// Version info
|
|
@@ -408,43 +508,177 @@ async function main() {
|
|
|
408
508
|
const { strings } = await import('../scripts/install/strings.mjs')
|
|
409
509
|
const S = strings()
|
|
410
510
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
511
|
+
const planTimestamp = reviewedPlan?.planned_at ?? new Date().toISOString()
|
|
512
|
+
const stdoutWrite = process.stdout.write
|
|
513
|
+
if (isJson) process.stdout.write = () => true
|
|
514
|
+
if (!isJson) {
|
|
414
515
|
console.log('')
|
|
516
|
+
if (!forceInteractive || isDryRun) {
|
|
517
|
+
console.log(`Pantheon OpenCode v${version} — ${isDryRun ? S.dryRun : S.installing}`)
|
|
518
|
+
console.log('')
|
|
519
|
+
}
|
|
415
520
|
}
|
|
416
521
|
|
|
522
|
+
let result
|
|
523
|
+
let installError = null
|
|
417
524
|
try {
|
|
418
525
|
const { installOpenCode } = await import('../scripts/install/opencode.mjs')
|
|
419
|
-
const target = isProject ? process.cwd() : undefined
|
|
420
|
-
await installOpenCode(target, isDryRun, forceReinstall, components, {
|
|
526
|
+
const target = reviewedPlan ? reviewedPlan.target.path : isProject ? process.cwd() : undefined
|
|
527
|
+
result = await installOpenCode(target, isDryRun, forceReinstall, components, {
|
|
421
528
|
interactive: forceInteractive,
|
|
422
|
-
headless: forceHeadless,
|
|
529
|
+
headless: reviewedPlan ? true : forceHeadless,
|
|
423
530
|
yes: autoYes,
|
|
424
531
|
model: modelOpt,
|
|
425
532
|
smallModel: smallModelOpt,
|
|
426
533
|
preset: presetOpt,
|
|
427
534
|
version: versionOpt ?? 'auto',
|
|
428
535
|
mergeDevConfig: mergeDevConfigOpt,
|
|
536
|
+
expectedPlan: reviewedPlan,
|
|
537
|
+
requestedComponents: requestedComponentsForPrompt,
|
|
538
|
+
noMcp: skipMCP,
|
|
539
|
+
planTimestamp,
|
|
540
|
+
quiet: isJson,
|
|
541
|
+
verbose: args.includes('--verbose') && !isJson,
|
|
429
542
|
})
|
|
430
543
|
} catch (err) {
|
|
431
|
-
|
|
544
|
+
installError = err
|
|
545
|
+
} finally {
|
|
546
|
+
if (isJson) process.stdout.write = stdoutWrite
|
|
547
|
+
}
|
|
548
|
+
if (installError) {
|
|
549
|
+
if (isJson) {
|
|
550
|
+
process.stdout.write(
|
|
551
|
+
`${JSON.stringify({
|
|
552
|
+
schema_version: 1,
|
|
553
|
+
command: 'init',
|
|
554
|
+
mode: 'dry-run',
|
|
555
|
+
status: 'error',
|
|
556
|
+
error: installError.message,
|
|
557
|
+
})}\n`,
|
|
558
|
+
)
|
|
559
|
+
console.error(`❌ Init dry-run failed: ${installError.message}`)
|
|
560
|
+
} else if (installError?.message === 'Canceled') {
|
|
432
561
|
console.error(S.canceled)
|
|
433
562
|
process.exit(130)
|
|
563
|
+
} else {
|
|
564
|
+
console.error(
|
|
565
|
+
`${S.installFailed(installError.message)}\n${S.failHintNoMcp}\n${S.failHintForce}`,
|
|
566
|
+
)
|
|
434
567
|
}
|
|
435
|
-
|
|
436
|
-
|
|
568
|
+
process.exitCode = 1
|
|
569
|
+
return
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
if (savePlanPath !== null && result?.reason === 'plan') {
|
|
573
|
+
try {
|
|
574
|
+
const artifact = createPlanArtifact({
|
|
575
|
+
target: result.target,
|
|
576
|
+
packageRoot: ROOT,
|
|
577
|
+
packageVersion: version,
|
|
578
|
+
plannedAt: planTimestamp,
|
|
579
|
+
artifactPath: savePlanPath,
|
|
580
|
+
options: {
|
|
581
|
+
clean: forceReinstall,
|
|
582
|
+
components,
|
|
583
|
+
version: result.openCodeVersion,
|
|
584
|
+
isProject,
|
|
585
|
+
model: modelOpt,
|
|
586
|
+
smallModel: smallModelOpt,
|
|
587
|
+
preset: presetOpt,
|
|
588
|
+
mergeDevConfig: mergeDevConfigOpt,
|
|
589
|
+
},
|
|
590
|
+
files: result.files,
|
|
591
|
+
snapshots: result.snapshots,
|
|
592
|
+
})
|
|
593
|
+
savePlanArtifact(savePlanPath, artifact)
|
|
594
|
+
} catch (error) {
|
|
595
|
+
if (!isJson) throw error
|
|
596
|
+
process.stdout.write(
|
|
597
|
+
`${JSON.stringify({
|
|
598
|
+
schema_version: 1,
|
|
599
|
+
command: 'init',
|
|
600
|
+
mode: 'dry-run',
|
|
601
|
+
status: 'error',
|
|
602
|
+
error: error.message,
|
|
603
|
+
})}\n`,
|
|
604
|
+
)
|
|
605
|
+
console.error(`❌ Could not save reviewed install plan: ${error.message}`)
|
|
606
|
+
process.exitCode = 1
|
|
607
|
+
return
|
|
608
|
+
}
|
|
609
|
+
if (!isJson) console.log(`Reviewed plan saved to ${path.resolve(savePlanPath)} (mode 0600).`)
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
if (isJson) {
|
|
613
|
+
const files = result.files ?? []
|
|
614
|
+
const totals = { create: 0, update: 0, remove: 0, unchanged: 0, conflict: 0 }
|
|
615
|
+
for (const file of files) {
|
|
616
|
+
if (Object.hasOwn(totals, file.action)) totals[file.action] += 1
|
|
617
|
+
}
|
|
618
|
+
const mcpServers = result.mcpServers ?? []
|
|
619
|
+
process.stdout.write(
|
|
620
|
+
`${JSON.stringify({
|
|
621
|
+
schema_version: 1,
|
|
622
|
+
command: 'init',
|
|
623
|
+
mode: 'dry-run',
|
|
624
|
+
status: 'planned',
|
|
625
|
+
target: result.target,
|
|
626
|
+
open_code_version: result.openCodeVersion,
|
|
627
|
+
advisories: result.versionAssumed
|
|
628
|
+
? [
|
|
629
|
+
'The OpenCode host generation could not be detected; this plan assumes V1 ' +
|
|
630
|
+
'and may diverge from the apply. Pass --opencode-version v1|v2 to pin it.',
|
|
631
|
+
]
|
|
632
|
+
: [],
|
|
633
|
+
totals,
|
|
634
|
+
mcp_servers: mcpServers,
|
|
635
|
+
mcp_server_count: mcpServers.length,
|
|
636
|
+
files: files.map(({ path: filePath, action, bytes }) => ({
|
|
637
|
+
path: path.relative(result.target, filePath) || '.',
|
|
638
|
+
action,
|
|
639
|
+
bytes,
|
|
640
|
+
})),
|
|
641
|
+
saved_plan: savePlanPath ? path.resolve(savePlanPath) : null,
|
|
642
|
+
})}\n`,
|
|
643
|
+
)
|
|
644
|
+
return
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// Beta 11 Setup phases 3-4: a run that did NOT apply (declined /
|
|
648
|
+
// unauthorized / drift) must never print a success banner. Exit codes:
|
|
649
|
+
// 0 ok / no-apply · 2 apply-requested-without-authorization · 3 drift
|
|
650
|
+
// 130 canceled · 1 failure (thrown above).
|
|
651
|
+
if (result?.applied === false) {
|
|
652
|
+
if (!isDryRun) {
|
|
653
|
+
if (result.reason === 'canceled') console.error(S.canceled)
|
|
654
|
+
process.exit(resolveInstallExitCode(result, isDryRun))
|
|
655
|
+
}
|
|
656
|
+
// Dry-run preview: report honestly instead of the "installed!" banner.
|
|
657
|
+
console.log('')
|
|
658
|
+
console.log(` ${S.dryRunNothingWritten}`)
|
|
659
|
+
return
|
|
437
660
|
}
|
|
438
661
|
|
|
439
662
|
if (runDoctor && !isDryRun) {
|
|
440
663
|
console.log('')
|
|
441
664
|
console.log(` ${S.runningHealthCheck}`)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
665
|
+
const doctorStartedAt = Date.now()
|
|
666
|
+
const { spawnSync } = await import('node:child_process')
|
|
667
|
+
const doctorScript = path.join(ROOT, 'scripts', 'doctor.mjs')
|
|
668
|
+
const doctor = spawnSync(process.execPath, [doctorScript], { stdio: 'inherit', cwd: ROOT })
|
|
669
|
+
const doctorSeconds = ((Date.now() - doctorStartedAt) / 1000).toFixed(1)
|
|
670
|
+
// Never leave "Running health check..." as the last word: report the
|
|
671
|
+
// outcome and duration, and propagate the child's exit code so CI sees
|
|
672
|
+
// the failure instead of a silent zero.
|
|
673
|
+
if (doctor.error) {
|
|
674
|
+
console.error(` ⚠️ Could not run doctor.mjs: ${doctor.error.message}`)
|
|
675
|
+
process.exitCode = 1
|
|
676
|
+
} else if (doctor.status === 0) {
|
|
677
|
+
console.log(` ${S.healthCheckFinished(doctorSeconds, 0)}`)
|
|
678
|
+
} else {
|
|
679
|
+
const status = doctor.status ?? 1
|
|
680
|
+
console.error(` ${S.healthCheckExit(doctorSeconds, status)}`)
|
|
681
|
+
process.exitCode = status
|
|
448
682
|
}
|
|
449
683
|
}
|
|
450
684
|
|
|
@@ -15,8 +15,15 @@ Structured, checkpointed workflow for complex multi-step tasks spanning multiple
|
|
|
15
15
|
## Workflow
|
|
16
16
|
|
|
17
17
|
```
|
|
18
|
-
Phase 0:
|
|
19
|
-
└─
|
|
18
|
+
Phase 0: PLAN AND APPROVAL
|
|
19
|
+
└─ @athena returns the complete, detailed Markdown plan to Zeus
|
|
20
|
+
└─ Zeus publishes the full plan as a normal message in the main conversation (not only in the child-agent transcript)
|
|
21
|
+
└─ GATE 1: open the approval UI only after that plan message is visible; never bundle or reverse the two
|
|
22
|
+
└─ If the runtime cannot guarantee that order, ask for approval in plain text after the plan and wait
|
|
23
|
+
└─ Wait for explicit approval or requested changes
|
|
24
|
+
└─ For requested changes, redisplay the entire revised plan and repeat Gate 1
|
|
25
|
+
└─ Do not start discovery or implementation before approval
|
|
26
|
+
└─ After approval, persist the approved plan as PLAN.md through the artifact workflow
|
|
20
27
|
|
|
21
28
|
Phase 1: DISCOVERY
|
|
22
29
|
└─ @apollo maps relevant codebase areas → DISCOVERY.md
|
|
@@ -44,7 +51,11 @@ Usage: --resume <slug> | --status <slug> | --list
|
|
|
44
51
|
|
|
45
52
|
## Full-Auto Mode (`--full-auto`)
|
|
46
53
|
|
|
47
|
-
> ⚠️
|
|
54
|
+
> ⚠️ Automates only eligible review gates. Gate 1 and commit/deploy gates still require approval.
|
|
55
|
+
|
|
56
|
+
`--full-auto` does not hide the plan or skip Gate 1: Zeus still displays the
|
|
57
|
+
complete plan in the main conversation and waits for explicit approval before
|
|
58
|
+
discovery or implementation. It only affects the later gates described below.
|
|
48
59
|
|
|
49
60
|
**Themis auto-approves non-blocking reviews** — only stops on **BLOCKING** verdict. No waiting between phases. Checkpoints saved at every boundary.
|
|
50
61
|
|