pantheon-opencode 1.5.0-beta.1 → 1.5.0-beta.3
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/README.md +44 -15
- package/README.pt-BR.md +39 -12
- package/package.json +7 -3
- package/plugin.json +1 -1
- package/pyproject.toml +57 -0
- package/scripts/code_mode_server.py +101 -36
- package/scripts/cost.mjs +30 -14
- package/scripts/install/opencode.mjs +6 -0
- package/scripts/install/plugin.mjs +3 -33
- package/scripts/manifest-inventory.mjs +410 -0
- package/scripts/mcp_persistence_server.py +518 -128
- package/scripts/package-evidence.mjs +242 -0
- package/scripts/probe-context-rehydrate.mjs +240 -0
- package/scripts/probe-pantheon-cost.mjs +304 -0
- package/scripts/release-beta-version.mjs +61 -60
- package/scripts/sync-tui.mjs +5 -27
- package/scripts/test-opencode-v1-v2-sandbox.sh +367 -96
- package/scripts/validation-policy.mjs +7 -7
- package/scripts/version-check.mjs +113 -108
- package/scripts/versioning.mjs +131 -88
- package/src/mcp/code_mode_server.py +101 -36
- package/src/mcp/mcp_persistence_server.py +518 -128
- package/src/pantheon/compaction-handoff.ts +304 -0
- package/src/pantheon/cost-command.ts +49 -32
- package/src/pantheon/delegate-manager.ts +285 -0
- package/src/pantheon/provider-capabilities.ts +221 -0
- package/src/pantheon/provider-stream-tracker.ts +182 -0
- package/src/pantheon/token-opt.ts +237 -11
- package/src/plugin-v2.ts +2 -14
- package/src/plugin.ts +3 -8
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/.pantheon/code-mode/.gitkeep +0 -0
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-1.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-10.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-11.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-2.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-3.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-4.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-5.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-6.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-7.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-8.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/checkpoint-9.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/heartbeat.json +0 -8
- package/.pantheon/code-mode/.pantheon/deepwork/initial-token-40k/session.json +0 -11
- package/src/pantheon/delegate-task-adapter.ts +0 -444
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Offline/ambiental probe for pantheon_cost.
|
|
4
|
+
*
|
|
5
|
+
* The probe never reads or writes a user's real database. Without --fixture it
|
|
6
|
+
* reports AMBIENTAL because a real dependency/database is intentionally not
|
|
7
|
+
* exercised. With --fixture it imports the installed command and creates a
|
|
8
|
+
* temporary synthetic opencode database. A missing fixture runtime is also
|
|
9
|
+
* AMBIENTAL rather than a false PASS.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs'
|
|
12
|
+
import { tmpdir } from 'node:os'
|
|
13
|
+
import { join } from 'node:path'
|
|
14
|
+
|
|
15
|
+
const requestedVersion = valueFor('--version')
|
|
16
|
+
const jsonOutput = process.argv.includes('--json')
|
|
17
|
+
const fixtureMode = process.argv.includes('--fixture')
|
|
18
|
+
|
|
19
|
+
function valueFor(name) {
|
|
20
|
+
const index = process.argv.indexOf(name)
|
|
21
|
+
return index >= 0 ? process.argv[index + 1] : undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function emit(status, detail, checks = []) {
|
|
25
|
+
const result = { status, version: requestedVersion, detail, checks }
|
|
26
|
+
if (jsonOutput) process.stdout.write(JSON.stringify(result))
|
|
27
|
+
else process.stdout.write(`${status}: ${detail}\n`)
|
|
28
|
+
if (status === 'FAIL') process.exitCode = 1
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ambiental(detail) {
|
|
32
|
+
emit('AMBIENTAL', detail)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function setEnvironment(values) {
|
|
36
|
+
const previous = new Map()
|
|
37
|
+
for (const [key, value] of Object.entries(values)) {
|
|
38
|
+
previous.set(key, process.env[key])
|
|
39
|
+
if (value === undefined) delete process.env[key]
|
|
40
|
+
else process.env[key] = value
|
|
41
|
+
}
|
|
42
|
+
return () => {
|
|
43
|
+
for (const [key, value] of previous) {
|
|
44
|
+
if (value === undefined) delete process.env[key]
|
|
45
|
+
else process.env[key] = value
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createSyntheticDb(DatabaseSync, path, rows) {
|
|
51
|
+
const db = new DatabaseSync(path)
|
|
52
|
+
db.exec('CREATE TABLE message (data TEXT NOT NULL, time_created INTEGER NOT NULL)')
|
|
53
|
+
const insert = db.prepare('INSERT INTO message (data, time_created) VALUES (?, ?)')
|
|
54
|
+
for (const data of rows) insert.run(JSON.stringify(data), Date.now())
|
|
55
|
+
db.close()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function createIncompatibleDb(DatabaseSync, path) {
|
|
59
|
+
const db = new DatabaseSync(path)
|
|
60
|
+
db.exec('CREATE TABLE not_message (value TEXT NOT NULL)')
|
|
61
|
+
db.close()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function requireOutput(output, fragment, label) {
|
|
65
|
+
if (!output.includes(fragment)) throw new Error(`${label}: missing ${fragment}`)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function assertTokensOnly(output, expectedRows, total) {
|
|
69
|
+
requireOutput(output, 'Tokens In | Tokens Out | Tokens Total', 'tokens-only header')
|
|
70
|
+
for (const row of expectedRows) {
|
|
71
|
+
requireOutput(
|
|
72
|
+
output,
|
|
73
|
+
`| ${row.agent} | ${row.phase} | ${row.input} | ${row.output} | ${row.total} |`,
|
|
74
|
+
'token row',
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
requireOutput(
|
|
78
|
+
output,
|
|
79
|
+
`| **Total** | — | **${total.input}** | **${total.output}** | **${total.total}** |`,
|
|
80
|
+
'token total',
|
|
81
|
+
)
|
|
82
|
+
if (/Cost \(USD\)|costUsd|\$\d|\bUSD\b/i.test(output)) {
|
|
83
|
+
throw new Error('tokens-only output contains a monetary value')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function main() {
|
|
88
|
+
if (requestedVersion !== 'v1' && requestedVersion !== 'v2') {
|
|
89
|
+
emit('FAIL', 'usage: --version v1|v2 [--fixture] [--json]')
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!fixtureMode) {
|
|
94
|
+
ambiental(
|
|
95
|
+
'real pantheon_cost dependency/database not exercised; use --fixture for synthetic checks',
|
|
96
|
+
)
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const source = new URL('../src/pantheon/cost-command.ts', import.meta.url)
|
|
101
|
+
if (!existsSync(source)) {
|
|
102
|
+
ambiental(
|
|
103
|
+
'pantheon_cost dependency is unavailable: installed package lacks src/pantheon/cost-command.ts',
|
|
104
|
+
)
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let DatabaseSync
|
|
109
|
+
let createCostCommand
|
|
110
|
+
try {
|
|
111
|
+
;({ DatabaseSync } = await import('node:sqlite'))
|
|
112
|
+
;({ createCostCommand } = await import(source.href))
|
|
113
|
+
} catch (error) {
|
|
114
|
+
ambiental(
|
|
115
|
+
`pantheon_cost fixture runtime unavailable: ${error instanceof Error ? error.message : String(error)}`,
|
|
116
|
+
)
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const root = mkdtempSync(join(tmpdir(), 'pantheon-cost-probe-'))
|
|
121
|
+
const dataHome = join(root, 'data')
|
|
122
|
+
const opencodeDir = join(dataHome, 'opencode')
|
|
123
|
+
const selectedDb = join(opencodeDir, requestedVersion === 'v2' ? 'opencode-v2.db' : 'opencode.db')
|
|
124
|
+
const otherDb = join(root, 'other.db')
|
|
125
|
+
const envDb = join(root, 'env.db')
|
|
126
|
+
const explicitDb = join(root, 'explicit.db')
|
|
127
|
+
const incompatibleDb = join(root, 'incompatible.db')
|
|
128
|
+
const checks = []
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
mkdirSync(opencodeDir, { recursive: true })
|
|
132
|
+
// These rows intentionally include a monetary-looking field to prove it is
|
|
133
|
+
// ignored; only input/output/total tokens may appear in the report.
|
|
134
|
+
const selectedRows =
|
|
135
|
+
requestedVersion === 'v2'
|
|
136
|
+
? [
|
|
137
|
+
{
|
|
138
|
+
role: 'assistant',
|
|
139
|
+
agent: 'aphrodite',
|
|
140
|
+
phase: 'plan',
|
|
141
|
+
cost: 999.99,
|
|
142
|
+
tokens: { input: 7, output: 8 },
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
role: 'assistant',
|
|
146
|
+
agent: 'aphrodite',
|
|
147
|
+
phase: 'plan',
|
|
148
|
+
cost: 999.99,
|
|
149
|
+
tokens: { input: 1, output: 2 },
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
role: 'assistant',
|
|
153
|
+
agent: 'zeus',
|
|
154
|
+
phase: 'audit',
|
|
155
|
+
cost: 999.99,
|
|
156
|
+
tokens: { input: 4, output: 6 },
|
|
157
|
+
},
|
|
158
|
+
]
|
|
159
|
+
: [
|
|
160
|
+
{
|
|
161
|
+
role: 'assistant',
|
|
162
|
+
agent: 'hermes',
|
|
163
|
+
phase: 'plan',
|
|
164
|
+
cost: 999.99,
|
|
165
|
+
tokens: { input: 10, output: 20 },
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
role: 'assistant',
|
|
169
|
+
agent: 'hermes',
|
|
170
|
+
phase: 'plan',
|
|
171
|
+
cost: 999.99,
|
|
172
|
+
tokens: { input: 3, output: 4 },
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
role: 'assistant',
|
|
176
|
+
agent: 'athena',
|
|
177
|
+
phase: 'review',
|
|
178
|
+
cost: 999.99,
|
|
179
|
+
tokens: { input: 2, output: 5 },
|
|
180
|
+
},
|
|
181
|
+
]
|
|
182
|
+
createSyntheticDb(DatabaseSync, selectedDb, selectedRows)
|
|
183
|
+
createSyntheticDb(DatabaseSync, otherDb, [
|
|
184
|
+
{
|
|
185
|
+
role: 'assistant',
|
|
186
|
+
agent: 'wrong-version',
|
|
187
|
+
phase: 'other',
|
|
188
|
+
tokens: { input: 90, output: 90 },
|
|
189
|
+
},
|
|
190
|
+
])
|
|
191
|
+
createSyntheticDb(DatabaseSync, envDb, [
|
|
192
|
+
{ role: 'assistant', agent: 'env-agent', phase: 'override', tokens: { input: 1, output: 2 } },
|
|
193
|
+
])
|
|
194
|
+
createSyntheticDb(DatabaseSync, explicitDb, [
|
|
195
|
+
{
|
|
196
|
+
role: 'assistant',
|
|
197
|
+
agent: 'explicit-agent',
|
|
198
|
+
phase: 'explicit',
|
|
199
|
+
tokens: { input: 9, output: 1 },
|
|
200
|
+
},
|
|
201
|
+
])
|
|
202
|
+
createIncompatibleDb(DatabaseSync, incompatibleDb)
|
|
203
|
+
|
|
204
|
+
const restore = setEnvironment({
|
|
205
|
+
XDG_DATA_HOME: dataHome,
|
|
206
|
+
PANTHEON_OPENCODE_VERSION: requestedVersion,
|
|
207
|
+
PANTHEON_COST_DB: undefined,
|
|
208
|
+
})
|
|
209
|
+
try {
|
|
210
|
+
const selectedOutput = await createCostCommand().pantheon_cost.execute(
|
|
211
|
+
{},
|
|
212
|
+
{ sessionID: 'cost-probe' },
|
|
213
|
+
)
|
|
214
|
+
assertTokensOnly(
|
|
215
|
+
selectedOutput,
|
|
216
|
+
requestedVersion === 'v2'
|
|
217
|
+
? [
|
|
218
|
+
{ agent: 'aphrodite', phase: 'plan', input: 8, output: 10, total: 18 },
|
|
219
|
+
{ agent: 'zeus', phase: 'audit', input: 4, output: 6, total: 10 },
|
|
220
|
+
]
|
|
221
|
+
: [
|
|
222
|
+
{ agent: 'hermes', phase: 'plan', input: 13, output: 24, total: 37 },
|
|
223
|
+
{ agent: 'athena', phase: 'review', input: 2, output: 5, total: 7 },
|
|
224
|
+
],
|
|
225
|
+
requestedVersion === 'v2'
|
|
226
|
+
? { input: 12, output: 16, total: 28 }
|
|
227
|
+
: { input: 15, output: 29, total: 44 },
|
|
228
|
+
)
|
|
229
|
+
checks.push('version-selected DB: PASS')
|
|
230
|
+
} finally {
|
|
231
|
+
restore()
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const envRestore = setEnvironment({
|
|
235
|
+
XDG_DATA_HOME: dataHome,
|
|
236
|
+
PANTHEON_OPENCODE_VERSION: requestedVersion,
|
|
237
|
+
PANTHEON_COST_DB: envDb,
|
|
238
|
+
})
|
|
239
|
+
try {
|
|
240
|
+
const output = await createCostCommand().pantheon_cost.execute(
|
|
241
|
+
{},
|
|
242
|
+
{ sessionID: 'cost-probe' },
|
|
243
|
+
)
|
|
244
|
+
requireOutput(output, '| env-agent | override | 1 | 2 | 3 |', 'PANTHEON_COST_DB')
|
|
245
|
+
if (output.includes('wrong-version') || output.includes('env-agent') === false) {
|
|
246
|
+
throw new Error('PANTHEON_COST_DB did not override the version-selected database')
|
|
247
|
+
}
|
|
248
|
+
checks.push('PANTHEON_COST_DB override: PASS')
|
|
249
|
+
} finally {
|
|
250
|
+
envRestore()
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const explicitRestore = setEnvironment({
|
|
254
|
+
XDG_DATA_HOME: dataHome,
|
|
255
|
+
PANTHEON_OPENCODE_VERSION: requestedVersion,
|
|
256
|
+
PANTHEON_COST_DB: envDb,
|
|
257
|
+
})
|
|
258
|
+
try {
|
|
259
|
+
const output = await createCostCommand({ dbPath: explicitDb }).pantheon_cost.execute(
|
|
260
|
+
{},
|
|
261
|
+
{ sessionID: 'cost-probe' },
|
|
262
|
+
)
|
|
263
|
+
requireOutput(output, '| explicit-agent | explicit | 9 | 1 | 10 |', 'explicit dbPath')
|
|
264
|
+
if (output.includes('env-agent')) throw new Error('explicit dbPath did not take precedence')
|
|
265
|
+
checks.push('explicit dbPath precedence: PASS')
|
|
266
|
+
} finally {
|
|
267
|
+
explicitRestore()
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const missingRestore = setEnvironment({
|
|
271
|
+
XDG_DATA_HOME: join(root, 'missing-data'),
|
|
272
|
+
PANTHEON_OPENCODE_VERSION: requestedVersion,
|
|
273
|
+
PANTHEON_COST_DB: undefined,
|
|
274
|
+
})
|
|
275
|
+
try {
|
|
276
|
+
const output = await createCostCommand().pantheon_cost.execute(
|
|
277
|
+
{},
|
|
278
|
+
{ sessionID: 'cost-probe' },
|
|
279
|
+
)
|
|
280
|
+
requireOutput(output, 'not found', 'missing DB')
|
|
281
|
+
requireOutput(
|
|
282
|
+
output,
|
|
283
|
+
requestedVersion === 'v2' ? 'opencode-v2.db' : 'opencode.db',
|
|
284
|
+
'selected missing DB path',
|
|
285
|
+
)
|
|
286
|
+
checks.push('missing DB: PASS')
|
|
287
|
+
} finally {
|
|
288
|
+
missingRestore()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const incompatibleOutput = await createCostCommand({
|
|
292
|
+
dbPath: incompatibleDb,
|
|
293
|
+
}).pantheon_cost.execute({}, { sessionID: 'cost-probe' })
|
|
294
|
+
requireOutput(incompatibleOutput, 'incompatible opencode.db schema', 'incompatible schema')
|
|
295
|
+
checks.push('incompatible schema: PASS')
|
|
296
|
+
emit('PASS', 'offline synthetic DB checks passed; no real DB was read', checks)
|
|
297
|
+
} catch (error) {
|
|
298
|
+
emit('FAIL', error instanceof Error ? error.message : String(error), checks)
|
|
299
|
+
} finally {
|
|
300
|
+
rmSync(root, { recursive: true, force: true })
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
await main()
|
|
@@ -1,80 +1,81 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* release-beta-version.mjs — beta version helpers.
|
|
4
|
+
*
|
|
5
|
+
* The beta version is committed in the manifests (package.json) and never
|
|
6
|
+
* computed at release time. `nextBetaVersion` advances the committed version:
|
|
7
|
+
*
|
|
8
|
+
* X.Y.Z-beta.N -> X.Y.Z-beta.(N+1) (stay on the current beta line)
|
|
9
|
+
* X.Y.Z -> X.Y.(Z+1)-beta.1 (start a fresh beta line)
|
|
10
|
+
*
|
|
11
|
+
* `applyBetaVersion` writes an already-decided beta version into every
|
|
12
|
+
* manifest and is retained for recovery tooling. The legacy PR+SHA scheme
|
|
13
|
+
* (`X.Y.Z-beta.<pr>.<sha7>`) is accepted by validation for backward
|
|
14
|
+
* compatibility only; it is no longer generated.
|
|
15
|
+
*/
|
|
3
16
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
17
|
+
import {
|
|
18
|
+
SEMVER_PATTERN,
|
|
19
|
+
validateInventory,
|
|
20
|
+
writeInventoryVersion,
|
|
21
|
+
} from './manifest-inventory.mjs'
|
|
6
22
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
const STABLE = /^(\d+)\.(\d+)\.(\d+)$/
|
|
23
|
+
const STABLE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
|
|
24
|
+
// Current committed sequential beta line.
|
|
25
|
+
const BETA_LINE = /^(\d+\.\d+\.\d+)-beta\.(\d+)$/
|
|
26
|
+
// Legacy PR+SHA beta scheme, accepted for recovery only.
|
|
27
|
+
const LEGACY_BETA =
|
|
28
|
+
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-beta\.[1-9]\d*\.[0-9a-f]{7}$/
|
|
29
|
+
const BETA_RELEASE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-beta\.[1-9]\d*$/
|
|
15
30
|
|
|
16
31
|
export function nextStableVersion(latest, intent = 'patch') {
|
|
17
|
-
const match = STABLE.exec(String(latest))
|
|
18
|
-
if (!match) throw new Error(`
|
|
19
|
-
const [major, minor, patch] = match.slice(1).map(Number)
|
|
32
|
+
const match = STABLE.exec(String(latest).trim())
|
|
33
|
+
if (!match) throw new Error(`latest is not a stable semver: "${latest}"`)
|
|
20
34
|
if (!['patch', 'minor', 'major'].includes(intent)) {
|
|
21
35
|
throw new Error(`release intent must be patch, minor, or major: "${intent}"`)
|
|
22
36
|
}
|
|
37
|
+
const [major, minor, patch] = match.slice(1).map(Number)
|
|
23
38
|
if (intent === 'major') return `${major + 1}.0.0`
|
|
24
39
|
if (intent === 'minor') return `${major}.${minor + 1}.0`
|
|
25
40
|
return `${major}.${minor}.${patch + 1}`
|
|
26
41
|
}
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Next beta version derived from the committed manifest version.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} current committed version (e.g. "1.5.0-beta.2")
|
|
47
|
+
* @returns {string} the next sequential beta (e.g. "1.5.0-beta.3")
|
|
48
|
+
*/
|
|
49
|
+
export function nextBetaVersion(current) {
|
|
50
|
+
const value = String(current).trim()
|
|
51
|
+
const line = BETA_LINE.exec(value)
|
|
52
|
+
if (line) return `${line[1]}-beta.${Number(line[2]) + 1}`
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const raw = readFileSync(path, 'utf8')
|
|
38
|
-
if (kind === 'toml') {
|
|
39
|
-
const updated = raw.replace(/^(version\s*=\s*")[^"]+("\s*)$/m, `$1${version}$2`)
|
|
40
|
-
if (updated === raw) throw new Error(`no version field in ${file}`)
|
|
41
|
-
writeFileSync(path, updated)
|
|
42
|
-
return
|
|
43
|
-
}
|
|
44
|
-
const content = JSON.parse(raw)
|
|
45
|
-
content.version = version
|
|
46
|
-
writeFileSync(path, `${JSON.stringify(content, null, 2)}\n`)
|
|
47
|
-
}
|
|
54
|
+
const stable = STABLE.exec(value)
|
|
55
|
+
if (stable) return `${nextStableVersion(value, 'patch')}-beta.1`
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const lock = JSON.parse(readFileSync(lockPath, 'utf8'))
|
|
54
|
-
lock.version = version
|
|
55
|
-
if (lock.packages?.['']) lock.packages[''].version = version
|
|
56
|
-
writeFileSync(lockPath, `${JSON.stringify(lock, null, 2)}\n`)
|
|
57
|
+
// Any other prerelease (e.g. 1.5.0-rc.1): beta the next patch of its base.
|
|
58
|
+
const base = /^(\d+\.\d+\.\d+)-[0-9A-Za-z.-]+$/.exec(value)
|
|
59
|
+
if (!base) throw new Error(`cannot derive a beta version from: "${current}"`)
|
|
60
|
+
return `${nextStableVersion(base[1], 'patch')}-beta.1`
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (args.has('latest')) {
|
|
67
|
-
try {
|
|
68
|
-
const version = betaVersion(
|
|
69
|
-
args.get('latest'),
|
|
70
|
-
args.get('intent') || 'patch',
|
|
71
|
-
args.get('pr'),
|
|
72
|
-
args.get('sha'),
|
|
63
|
+
function validateReleaseVersion(version) {
|
|
64
|
+
if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {
|
|
65
|
+
throw new Error(`invalid release semver: "${version}"`)
|
|
66
|
+
}
|
|
67
|
+
if (!BETA_RELEASE.test(version) && !LEGACY_BETA.test(version)) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`release version must be <base>-beta.<N> or legacy <base>-beta.<pr>.<7-char-sha>: "${version}"`,
|
|
73
70
|
)
|
|
74
|
-
if (args.has('apply')) applyBetaVersion(process.cwd(), version)
|
|
75
|
-
console.log(version)
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error(`release-beta-version: ${error.message}`)
|
|
78
|
-
process.exit(1)
|
|
79
71
|
}
|
|
80
72
|
}
|
|
73
|
+
|
|
74
|
+
/** Preflight all six entries, then update metadata only. */
|
|
75
|
+
export function applyBetaVersion(root, version) {
|
|
76
|
+
validateReleaseVersion(version)
|
|
77
|
+
const inventory = validateInventory(root, { allowVersionDivergence: true })
|
|
78
|
+
writeInventoryVersion(inventory, version)
|
|
79
|
+
const after = validateInventory(root)
|
|
80
|
+
if (after.sourceVersion !== version) throw new Error('beta version post-write validation failed')
|
|
81
|
+
}
|
package/scripts/sync-tui.mjs
CHANGED
|
@@ -124,8 +124,7 @@ try {
|
|
|
124
124
|
// Source: TUI plugin inside the installed package
|
|
125
125
|
const tuiSrcDir = join(ROOT, 'src', 'plugins', 'tui')
|
|
126
126
|
if (!existsSync(tuiSrcDir)) {
|
|
127
|
-
|
|
128
|
-
process.exit(0)
|
|
127
|
+
throw new Error(`TUI plugin source not found: ${tuiSrcDir}`)
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
// Compare versions before copy
|
|
@@ -135,28 +134,8 @@ try {
|
|
|
135
134
|
// Copy fresh files
|
|
136
135
|
const { created } = copyPluginFiles(tuiSrcDir, tuiCopyDir)
|
|
137
136
|
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
try {
|
|
141
|
-
execSync('npm ci --omit=dev --no-audit --no-fund', { cwd: tuiCopyDir, stdio: 'pipe' })
|
|
142
|
-
} catch (err) {
|
|
143
|
-
if (process.env.PANTHEON_ALLOW_NPM_INSTALL_FALLBACK === '1') {
|
|
144
|
-
console.warn(`⚠️ npm ci failed; explicit fallback enabled: ${err.message}`)
|
|
145
|
-
try {
|
|
146
|
-
execSync('npm install --omit=dev --no-audit --no-fund --package-lock=false', {
|
|
147
|
-
cwd: tuiCopyDir,
|
|
148
|
-
stdio: 'pipe',
|
|
149
|
-
})
|
|
150
|
-
} catch (fallbackError) {
|
|
151
|
-
console.warn(`⚠️ TUI dependency refresh skipped: ${fallbackError.message}`)
|
|
152
|
-
}
|
|
153
|
-
} else {
|
|
154
|
-
console.warn(
|
|
155
|
-
`⚠️ TUI dependency refresh skipped after npm ci failure. Set ` +
|
|
156
|
-
`PANTHEON_ALLOW_NPM_INSTALL_FALLBACK=1 to explicitly allow npm install: ${err.message}`,
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
137
|
+
// Lockfile installation is the only accepted dependency path.
|
|
138
|
+
execSync('npm ci --omit=dev --no-audit --no-fund', { cwd: tuiCopyDir, stdio: 'pipe' })
|
|
160
139
|
|
|
161
140
|
// Log result
|
|
162
141
|
if (installedVersion && sourceVersion && installedVersion === sourceVersion && created === 0) {
|
|
@@ -167,7 +146,6 @@ try {
|
|
|
167
146
|
)
|
|
168
147
|
}
|
|
169
148
|
} catch (err) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
process.exit(0)
|
|
149
|
+
console.error(`❌ TUI sync failed: ${err.message}`)
|
|
150
|
+
process.exitCode = 1
|
|
173
151
|
}
|