pantheon-opencode 1.6.2-beta.2 → 1.6.2-beta.4
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/CHANGELOG.md +48 -0
- package/README.md +56 -16
- package/bin/pantheon-init.mjs +68 -13
- package/package.json +10 -3
- package/plugin.json +1 -1
- package/prompts/README.md +58 -0
- package/prompts/debug-issue.prompt.md +46 -0
- package/prompts/dynamic/agora-generated.txt +38 -0
- package/prompts/dynamic/orchestrate-generated.txt +51 -0
- package/prompts/focus.prompt.md +42 -0
- package/prompts/implement-feature.prompt.md +39 -0
- package/prompts/optimize-database.prompt.md +58 -0
- package/prompts/orchestrate-with-zeus.prompt.md +441 -0
- package/prompts/plan-architecture.prompt.md +59 -0
- package/prompts/quick-discovery-large-codebase.prompt.md +294 -0
- package/prompts/quick-plan-large-feature.prompt.md +197 -0
- package/prompts/semantic-summarize.md +50 -0
- package/prompts/sketch.prompt.md +91 -0
- package/prompts/subtask.prompt.md +131 -0
- package/pyproject.toml +1 -1
- package/scripts/decision-router-budget.mjs +781 -0
- package/scripts/decision-router.mjs +297 -0
- package/scripts/install/component-selection.mjs +9 -4
- package/scripts/install/decision-router-config.mjs +432 -0
- package/scripts/install/health-check.mjs +20 -11
- package/scripts/install/interactive.mjs +78 -14
- package/scripts/install/interrupt.mjs +4 -3
- package/scripts/install/migrate.mjs +123 -72
- package/scripts/install/opencode.mjs +162 -114
- package/scripts/install/plan.mjs +8 -1
- package/scripts/install/state.mjs +12 -0
- package/scripts/install/strings.mjs +10 -0
- package/scripts/install/venv.mjs +34 -17
- package/scripts/restore.mjs +22 -10
- package/scripts/test-opencode-v2-sandbox.sh +10 -6
- package/src/agents/zeus.md +12 -0
- package/src/pantheon/local-decision-agents.ts +170 -0
- package/src/pantheon/local-decision-budget.ts +1043 -0
- package/src/pantheon/local-decision-egress-gate.ts +264 -0
- package/src/pantheon/local-decision-prompt.ts +123 -0
- package/src/pantheon/local-decision-provider-matrix.ts +92 -0
- package/src/pantheon/local-decision-provider-protocol.ts +335 -0
- package/src/pantheon/local-decision-provider.internal.ts +260 -0
- package/src/pantheon/local-decision-router.ts +225 -0
- package/src/pantheon/local-decision-skills.ts +171 -0
- package/src/pantheon/local-decision-tool.ts +126 -0
- package/src/pantheon/local-decision-turn.ts +338 -0
- package/src/pantheon/local-decision-usage-evidence.internal.ts +207 -0
- package/src/pantheon/local-orchestration.ts +322 -0
- package/src/pantheon/pantheon-decision-catalog.ts +101 -0
- package/src/pantheon/v2-tools.ts +15 -14
- package/src/plugin-v2.ts +52 -19
- package/src/plugin.ts +4 -0
- package/src/plugins/tui/dist/tui-v2.js +3 -3
- package/src/plugins/tui/dist/tui.js +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
12
12
|
import { dirname, join } from 'node:path'
|
|
13
13
|
import { fileURLToPath } from 'node:url'
|
|
14
|
-
import { configure as configureUi, tag } from './cli-ui.mjs'
|
|
15
14
|
import { ACTIONS, fingerprintOutput, recordChange } from './plan.mjs'
|
|
16
|
-
import { createInitialState, readState, writeState } from './state.mjs'
|
|
15
|
+
import { createInitialState, MIGRATION_SCHEMA_VERSION, readState, writeState } from './state.mjs'
|
|
17
16
|
|
|
18
17
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
19
18
|
const ROOT = join(__dirname, '..', '..')
|
|
@@ -47,76 +46,84 @@ export function detectVersion(target) {
|
|
|
47
46
|
* @param {string} target - Installation directory
|
|
48
47
|
* @param {string|null} currentVersion - Detected version (null = fresh install)
|
|
49
48
|
* @param {{ dryRun?: boolean, recorder?: (change: object) => void }} [options]
|
|
50
|
-
* @returns {{ applied: number, messages: string[] }}
|
|
49
|
+
* @returns {{ applied: number, messages: string[], plannedState: object|null, status?: 'invalid'|'unsupported', marker?: unknown, message?: string }}
|
|
51
50
|
*/
|
|
52
|
-
export function runMigrations(
|
|
53
|
-
target,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
export function runMigrations(target, options = {}, legacyOptions = {}) {
|
|
52
|
+
// Preserve the old `(target, version, options)` call shape for downstream
|
|
53
|
+
// callers while making the persisted migration marker authoritative.
|
|
54
|
+
const explicitVersion = typeof options === 'string' ? options : null
|
|
55
|
+
const {
|
|
56
|
+
dryRun = false,
|
|
57
|
+
recorder = null,
|
|
58
|
+
updatedAt = new Date().toISOString(),
|
|
59
|
+
} = typeof options === 'object' && options !== null ? options : legacyOptions
|
|
60
|
+
const state = readState(target)
|
|
61
|
+
if (!state) return { applied: 0, messages: [], plannedState: null }
|
|
62
|
+
|
|
63
|
+
const schemaMarker = state.migration_schema_version
|
|
64
|
+
if (schemaMarker !== null && schemaMarker !== undefined) {
|
|
65
|
+
const parsedMarker = parseSemver(schemaMarker)
|
|
66
|
+
if (!parsedMarker) return blockedMigration('invalid', schemaMarker)
|
|
67
|
+
if (compareSemver(parsedMarker, parseSemver(MIGRATION_SCHEMA_VERSION)) > 0) {
|
|
68
|
+
return blockedMigration('unsupported', schemaMarker)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const currentVersion =
|
|
73
|
+
state.migration_schema_version ?? explicitVersion ?? state.pantheon_version ?? null
|
|
57
74
|
const applied = []
|
|
58
|
-
|
|
75
|
+
let cursor = parseSemver(currentVersion)
|
|
59
76
|
|
|
60
77
|
// ── Migration: v3.10.0 → v3.18.0 ──────────────────────────────────
|
|
61
78
|
// Fix dangling references, add Memory Protocol
|
|
62
|
-
if (
|
|
79
|
+
if (cursor && compareSemver(cursor, parseSemver('3.18.0')) < 0) {
|
|
63
80
|
applied.push({
|
|
64
|
-
from: formatSemver(
|
|
81
|
+
from: formatSemver(cursor),
|
|
65
82
|
to: '3.18.0',
|
|
66
83
|
description: 'Fix dangling references, add Memory Protocol',
|
|
67
84
|
})
|
|
68
|
-
|
|
69
|
-
semver[1] = 18
|
|
70
|
-
semver[2] = 0
|
|
85
|
+
cursor = parseSemver('3.18.0')
|
|
71
86
|
}
|
|
72
87
|
|
|
73
88
|
// ── Migration: v3.18.0 → v3.19.0 ──────────────────────────────────
|
|
74
89
|
// Add runtime component, _pantheon_paths
|
|
75
|
-
if (
|
|
90
|
+
if (cursor && compareSemver(cursor, parseSemver('3.19.0')) < 0) {
|
|
76
91
|
applied.push({
|
|
77
|
-
from: formatSemver(
|
|
92
|
+
from: formatSemver(cursor),
|
|
78
93
|
to: '3.19.0',
|
|
79
94
|
description: 'Add runtime component, _pantheon_paths',
|
|
80
95
|
})
|
|
81
|
-
|
|
82
|
-
semver[1] = 19
|
|
83
|
-
semver[2] = 0
|
|
96
|
+
cursor = parseSemver('3.19.0')
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
// ── Migration: v3.19.0 → v3.19.1 ──────────────────────────────────
|
|
87
100
|
// Add persistence MCP, fix 157 dangling refs
|
|
88
|
-
if (
|
|
101
|
+
if (cursor && compareSemver(cursor, parseSemver('3.19.1')) < 0) {
|
|
89
102
|
applied.push({
|
|
90
|
-
from: formatSemver(
|
|
103
|
+
from: formatSemver(cursor),
|
|
91
104
|
to: '3.19.1',
|
|
92
105
|
description: 'Add persistence MCP, fix dangling refs',
|
|
93
106
|
})
|
|
94
|
-
|
|
95
|
-
semver[1] = 19
|
|
96
|
-
semver[2] = 1
|
|
107
|
+
cursor = parseSemver('3.19.1')
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
// ── Migration: v3.19.1 → v3.19.2 ──────────────────────────────────
|
|
100
111
|
// Upgrade state schema from v1 to v2
|
|
101
|
-
if (
|
|
112
|
+
if (cursor && compareSemver(cursor, parseSemver(MIGRATION_SCHEMA_VERSION)) < 0) {
|
|
102
113
|
applied.push({
|
|
103
|
-
from: formatSemver(
|
|
104
|
-
to:
|
|
114
|
+
from: formatSemver(cursor),
|
|
115
|
+
to: MIGRATION_SCHEMA_VERSION,
|
|
105
116
|
description: 'Upgrade install state schema to v2 with component tracking',
|
|
106
117
|
})
|
|
107
|
-
|
|
108
|
-
semver[1] = 19
|
|
109
|
-
semver[2] = 2
|
|
118
|
+
cursor = parseSemver(MIGRATION_SCHEMA_VERSION)
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
// ── Write updated state ───────────────────────────────────────────
|
|
113
|
-
|
|
122
|
+
const markerChanged = state.migration_schema_version !== MIGRATION_SCHEMA_VERSION
|
|
123
|
+
if (applied.length > 0 || markerChanged) {
|
|
114
124
|
const statePath = join(target, '.pantheon', 'install-state.json')
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const stateExisted = state !== null
|
|
118
|
-
if (!state) state = createInitialState(newVersion, updatedAt)
|
|
119
|
-
state.pantheon_version = newVersion
|
|
125
|
+
const stateExisted = true
|
|
126
|
+
state.applied_migrations ??= []
|
|
120
127
|
for (const m of applied) {
|
|
121
128
|
state.applied_migrations.push({
|
|
122
129
|
from: m.from,
|
|
@@ -133,6 +140,7 @@ export function runMigrations(
|
|
|
133
140
|
runtime: { version: 1, status: 'installed' },
|
|
134
141
|
}
|
|
135
142
|
}
|
|
143
|
+
state.migration_schema_version = MIGRATION_SCHEMA_VERSION
|
|
136
144
|
state.updated_at = updatedAt
|
|
137
145
|
state.schema_version = 2
|
|
138
146
|
const stateContent = `${JSON.stringify(state, null, 2)}\n`
|
|
@@ -155,12 +163,20 @@ export function runMigrations(
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
return {
|
|
158
|
-
applied:
|
|
166
|
+
applied: 0,
|
|
159
167
|
messages: applied.map((m) => `${m.from} → ${m.to}: ${m.description}`),
|
|
160
168
|
plannedState: null,
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
|
|
172
|
+
function blockedMigration(status, marker) {
|
|
173
|
+
const message =
|
|
174
|
+
status === 'unsupported'
|
|
175
|
+
? `Migration schema ${marker} is newer than supported ${MIGRATION_SCHEMA_VERSION}; refusing to downgrade or modify the installation.`
|
|
176
|
+
: 'Invalid migration schema marker; refusing to modify the installation.'
|
|
177
|
+
return { applied: 0, messages: [], plannedState: null, status, marker, message }
|
|
178
|
+
}
|
|
179
|
+
|
|
164
180
|
// ---------------------------------------------------------------------------
|
|
165
181
|
// Checkpoint system for crash recovery
|
|
166
182
|
// ---------------------------------------------------------------------------
|
|
@@ -279,7 +295,7 @@ export function rollbackMigration(target, version) {
|
|
|
279
295
|
console.log(` Rolling back migration: ${targetMigration.from} -> ${targetMigration.to}`)
|
|
280
296
|
|
|
281
297
|
targetMigration.status = 'rolled_back'
|
|
282
|
-
state.
|
|
298
|
+
state.migration_schema_version = targetMigration.from
|
|
283
299
|
writeState(target, state)
|
|
284
300
|
|
|
285
301
|
console.log(` [OK] Rolled back to ${targetMigration.from}`)
|
|
@@ -307,46 +323,69 @@ export function listAppliedMigrations(target) {
|
|
|
307
323
|
// Minimal semver helpers (no external deps)
|
|
308
324
|
// ---------------------------------------------------------------------------
|
|
309
325
|
|
|
310
|
-
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (!
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
/** Parse strict SemVer precedence, accepting an optional `v` and build metadata. */
|
|
327
|
+
export function parseSemver(value) {
|
|
328
|
+
if (typeof value !== 'string') return null
|
|
329
|
+
const match = value.match(
|
|
330
|
+
/^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,
|
|
331
|
+
)
|
|
332
|
+
if (!match) return null
|
|
333
|
+
const prerelease = match[4]
|
|
334
|
+
? match[4].split('.').map((identifier) => {
|
|
335
|
+
if (!/^\d+$/.test(identifier)) return identifier
|
|
336
|
+
if (identifier.length > 1 && identifier.startsWith('0')) return null
|
|
337
|
+
return Number(identifier)
|
|
338
|
+
})
|
|
339
|
+
: []
|
|
340
|
+
if (prerelease.includes(null)) return null
|
|
341
|
+
|
|
342
|
+
const parsed = {
|
|
343
|
+
major: Number(match[1]),
|
|
344
|
+
minor: Number(match[2]),
|
|
345
|
+
patch: Number(match[3]),
|
|
346
|
+
prerelease,
|
|
347
|
+
}
|
|
348
|
+
Object.defineProperty(parsed, 'compare', {
|
|
349
|
+
enumerable: false,
|
|
350
|
+
value: (other) => compareSemver(parsed, other),
|
|
351
|
+
})
|
|
352
|
+
return parsed
|
|
329
353
|
}
|
|
330
354
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
355
|
+
function compareSemver(left, right) {
|
|
356
|
+
for (const field of ['major', 'minor', 'patch']) {
|
|
357
|
+
if (left[field] !== right[field]) return left[field] < right[field] ? -1 : 1
|
|
358
|
+
}
|
|
359
|
+
const a = left.prerelease
|
|
360
|
+
const b = right.prerelease
|
|
361
|
+
if (a.length === 0 || b.length === 0) {
|
|
362
|
+
if (a.length === b.length) return 0
|
|
363
|
+
return a.length === 0 ? 1 : -1
|
|
364
|
+
}
|
|
365
|
+
const length = Math.min(a.length, b.length)
|
|
366
|
+
for (let index = 0; index < length; index += 1) {
|
|
367
|
+
if (a[index] === b[index]) continue
|
|
368
|
+
if (typeof a[index] === 'number' && typeof b[index] === 'number') {
|
|
369
|
+
return a[index] < b[index] ? -1 : 1
|
|
341
370
|
}
|
|
371
|
+
if (typeof a[index] === 'number') return -1
|
|
372
|
+
if (typeof b[index] === 'number') return 1
|
|
373
|
+
return a[index] < b[index] ? -1 : 1
|
|
342
374
|
}
|
|
343
|
-
return
|
|
375
|
+
if (a.length === b.length) return 0
|
|
376
|
+
return a.length < b.length ? -1 : 1
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function formatSemver(value) {
|
|
380
|
+
const core = `${value.major}.${value.minor}.${value.patch}`
|
|
381
|
+
return value.prerelease.length === 0 ? core : `${core}-${value.prerelease.join('.')}`
|
|
344
382
|
}
|
|
345
383
|
|
|
346
384
|
// ---------------------------------------------------------------------------
|
|
347
385
|
// CLI entry point
|
|
348
386
|
// ---------------------------------------------------------------------------
|
|
349
|
-
function main() {
|
|
387
|
+
async function main() {
|
|
388
|
+
const { configure: configureUi, tag } = await import('./cli-ui.mjs')
|
|
350
389
|
const args = process.argv.slice(2)
|
|
351
390
|
const targetIdx = args.indexOf('--target')
|
|
352
391
|
const target = targetIdx !== -1 ? args[targetIdx + 1] : process.cwd()
|
|
@@ -394,12 +433,21 @@ function main() {
|
|
|
394
433
|
|
|
395
434
|
console.log(` Current version: ${currentVersion}`)
|
|
396
435
|
|
|
397
|
-
|
|
436
|
+
const state = readState(target)
|
|
437
|
+
if (
|
|
438
|
+
!force &&
|
|
439
|
+
currentVersion === PANTHON_VERSION &&
|
|
440
|
+
state?.migration_schema_version === MIGRATION_SCHEMA_VERSION
|
|
441
|
+
) {
|
|
398
442
|
console.log(' [OK] Already at latest version — no migrations needed')
|
|
399
443
|
return
|
|
400
444
|
}
|
|
401
445
|
|
|
402
|
-
const migration = runMigrations(target,
|
|
446
|
+
const migration = runMigrations(target, { dryRun })
|
|
447
|
+
|
|
448
|
+
if (migration.status === 'unsupported' || migration.status === 'invalid') {
|
|
449
|
+
throw new Error(migration.message)
|
|
450
|
+
}
|
|
403
451
|
|
|
404
452
|
if (migration.applied > 0) {
|
|
405
453
|
console.log(` [OK] Applied ${migration.applied} migration(s):`)
|
|
@@ -412,5 +460,8 @@ function main() {
|
|
|
412
460
|
}
|
|
413
461
|
|
|
414
462
|
if (process.argv[1] && import.meta.url === `file://${process.argv[1]}`) {
|
|
415
|
-
main()
|
|
463
|
+
main().catch((error) => {
|
|
464
|
+
console.error(` [ERROR] ${error instanceof Error ? error.message : String(error)}`)
|
|
465
|
+
process.exitCode = 1
|
|
466
|
+
})
|
|
416
467
|
}
|