pantheon-opencode 1.6.0-beta.12 → 1.6.0-beta.14
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 +40 -5
- package/README.md +30 -1
- package/README.pt-BR.md +3 -1
- package/bin/pantheon-init.mjs +41 -50
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/check-plugin-v2-coverage.mjs +4 -1
- package/scripts/install/agents-md.mjs +2 -2
- package/scripts/install/cli-ui.mjs +32 -71
- package/scripts/install/component-selection.mjs +61 -0
- package/scripts/install/health-check.mjs +3 -3
- package/scripts/install/interactive.mjs +75 -394
- package/scripts/install/migrate.mjs +13 -19
- package/scripts/install/model-picker.mjs +155 -228
- package/scripts/install/opencode.mjs +66 -27
- package/scripts/install/prompt-result.mjs +2 -0
- package/scripts/install/shared.mjs +11 -9
- package/scripts/install/strings.mjs +6 -6
- package/scripts/install/venv.mjs +5 -5
- package/scripts/node-engine-policy.mjs +11 -0
- package/scripts/postinstall.mjs +25 -24
- package/scripts/sync-tui.mjs +5 -1
- package/src/agents/apollo.md +3 -3
- package/src/plugins/tui/dist/tui-v2.js +2 -2
- 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
- package/src/routing.yml +45 -0
|
@@ -1,420 +1,101 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import * as clack from '@clack/prompts'
|
|
4
|
+
import { PROMPT_CANCELED } from './prompt-result.mjs'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const cursorShow = () => process.stdout.write('\x1b[?25h')
|
|
8
|
-
const cursorUp = (n) => process.stdout.write(`\x1b[${n}A`)
|
|
9
|
-
const clearDown = () => process.stdout.write('\x1b[J')
|
|
6
|
+
export { PROMPT_CANCELED }
|
|
10
7
|
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
if (!process.stdout.isTTY) return false
|
|
14
|
-
emitKeypressEvents(process.stdin)
|
|
15
|
-
try {
|
|
16
|
-
process.stdin.setRawMode(true)
|
|
17
|
-
} catch {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
process.stdin.resume()
|
|
21
|
-
return true
|
|
8
|
+
function isTerminal() {
|
|
9
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY)
|
|
22
10
|
}
|
|
23
11
|
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
process.stdin.pause()
|
|
29
|
-
} catch {
|
|
30
|
-
/* safe to ignore */
|
|
31
|
-
}
|
|
12
|
+
function cancelPrompt(prompts, value) {
|
|
13
|
+
if (!prompts.isCancel(value)) return false
|
|
14
|
+
prompts.cancel('Installation canceled.')
|
|
15
|
+
return true
|
|
32
16
|
}
|
|
33
17
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Prompt for authorization to apply a reviewed installer plan.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} planSummary Summary of the changes that require approval.
|
|
22
|
+
* @param {{ default?: boolean, prompts?: typeof clack, isTTY?: boolean }} [options]
|
|
23
|
+
* @returns {Promise<boolean | typeof PROMPT_CANCELED>} True if authorized, false if declined, or the cancellation sentinel.
|
|
24
|
+
*/
|
|
25
|
+
export async function promptReview(
|
|
26
|
+
planSummary,
|
|
27
|
+
{ default: defaultValue = false, prompts = clack, isTTY = isTerminal() } = {},
|
|
37
28
|
) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
name: o.name,
|
|
43
|
-
value: o.value,
|
|
44
|
-
description: o.description || '',
|
|
45
|
-
checked: o.checked || preSelected.has(o.value),
|
|
46
|
-
}))
|
|
47
|
-
|
|
48
|
-
let cursor = 0
|
|
49
|
-
let scroll = 0
|
|
50
|
-
const maxVisible = Math.min(pageSize, options.length)
|
|
51
|
-
let previousLineCount = 0
|
|
52
|
-
|
|
53
|
-
const isTTY = setupStdin()
|
|
54
|
-
if (!isTTY) {
|
|
55
|
-
return new Set(items.filter((i) => i.checked).map((i) => i.value))
|
|
56
|
-
}
|
|
57
|
-
cursorHide()
|
|
58
|
-
|
|
59
|
-
function render() {
|
|
60
|
-
if (cursor < scroll) scroll = cursor
|
|
61
|
-
if (cursor >= scroll + maxVisible) scroll = cursor - maxVisible + 1
|
|
62
|
-
|
|
63
|
-
const visible = items.slice(scroll, scroll + maxVisible)
|
|
64
|
-
const lines = []
|
|
65
|
-
|
|
66
|
-
if (title) lines.push(colors.bold(title))
|
|
67
|
-
|
|
68
|
-
const hasMoreAbove = scroll > 0
|
|
69
|
-
const hasMoreBelow = scroll + maxVisible < options.length
|
|
70
|
-
|
|
71
|
-
if (hasMoreAbove) lines.push(colors.dim(' ...'))
|
|
72
|
-
|
|
73
|
-
for (let i = 0; i < visible.length; i++) {
|
|
74
|
-
const item = visible[i]
|
|
75
|
-
const idx = scroll + i
|
|
76
|
-
const active = idx === cursor
|
|
77
|
-
const box = item.checked ? '[x]' : '[ ]'
|
|
78
|
-
const ptr = active ? `${colors.cyan('>')} ` : ' '
|
|
79
|
-
const name = active ? colors.cyan(item.name) : item.name
|
|
80
|
-
const desc = item.description ? colors.dim(` — ${item.description}`) : ''
|
|
81
|
-
lines.push(`${ptr}${colors.bold(box)} ${name}${desc}`)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (hasMoreBelow) lines.push(colors.dim(' ...'))
|
|
85
|
-
|
|
86
|
-
const count = items.filter((i) => i.checked).length
|
|
87
|
-
const total = items.length
|
|
88
|
-
const noun = count === 1 ? 'selected' : 'selected'
|
|
89
|
-
lines.push(
|
|
90
|
-
colors.dim(
|
|
91
|
-
`(${count}/${total} ${noun}) — ${colors.cyan('↑')}${colors.dim('/')}${colors.cyan('↓')} navigate · ${colors.cyan('Space')}${colors.dim(' toggle · ')}${colors.cyan('Enter')}${colors.dim(' confirm')}`,
|
|
92
|
-
),
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
const lineCount = lines.length
|
|
96
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
97
|
-
clearDown()
|
|
98
|
-
process.stdout.write(`${lines.join('\n')}\n`)
|
|
99
|
-
previousLineCount = lineCount
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
let settled = false
|
|
104
|
-
|
|
105
|
-
function finalize(result) {
|
|
106
|
-
if (settled) return
|
|
107
|
-
settled = true
|
|
108
|
-
cursorShow()
|
|
109
|
-
teardownStdin()
|
|
110
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
111
|
-
clearDown()
|
|
112
|
-
resolve(result)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function cancel() {
|
|
116
|
-
if (settled) return
|
|
117
|
-
settled = true
|
|
118
|
-
cursorShow()
|
|
119
|
-
teardownStdin()
|
|
120
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
121
|
-
clearDown()
|
|
122
|
-
reject(new Error('Canceled'))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function handler(_str, key) {
|
|
126
|
-
if (!key) return
|
|
127
|
-
if ((key.ctrl && key.name === 'c') || key.name === 'escape') {
|
|
128
|
-
cancel()
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
if (key.name === 'return' || key.name === 'enter') {
|
|
132
|
-
const result = new Set(items.filter((i) => i.checked).map((i) => i.value))
|
|
133
|
-
finalize(result)
|
|
134
|
-
return
|
|
135
|
-
}
|
|
136
|
-
if (key.name === 'up') {
|
|
137
|
-
cursor = (cursor - 1 + items.length) % items.length
|
|
138
|
-
render()
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
|
-
if (key.name === 'down') {
|
|
142
|
-
cursor = (cursor + 1) % items.length
|
|
143
|
-
render()
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
if (key.name === 'space') {
|
|
147
|
-
items[cursor].checked = !items[cursor].checked
|
|
148
|
-
render()
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
process.stdin.on('keypress', handler)
|
|
154
|
-
render()
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export async function promptConfirm(message, { default: def = true } = {}) {
|
|
159
|
-
const label = def ? 'Y/n' : 'y/N'
|
|
160
|
-
const isTTY = setupStdin()
|
|
161
|
-
if (!isTTY) return def
|
|
162
|
-
|
|
163
|
-
cursorHide()
|
|
164
|
-
process.stdout.write(`${colors.bold('?')} ${message} ${colors.cyan(label)} `)
|
|
165
|
-
|
|
166
|
-
return new Promise((resolve, reject) => {
|
|
167
|
-
let settled = false
|
|
168
|
-
|
|
169
|
-
function finalize(result) {
|
|
170
|
-
if (settled) return
|
|
171
|
-
settled = true
|
|
172
|
-
cursorShow()
|
|
173
|
-
teardownStdin()
|
|
174
|
-
process.stdout.write(`${result ? 'Yes' : 'No'}\n`)
|
|
175
|
-
resolve(result)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function cancel() {
|
|
179
|
-
if (settled) return
|
|
180
|
-
settled = true
|
|
181
|
-
cursorShow()
|
|
182
|
-
teardownStdin()
|
|
183
|
-
process.stdout.write('\n')
|
|
184
|
-
reject(new Error('Canceled'))
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function handler(str, key) {
|
|
188
|
-
if (!key) return
|
|
189
|
-
if ((key.ctrl && key.name === 'c') || key.name === 'escape') {
|
|
190
|
-
cancel()
|
|
191
|
-
return
|
|
192
|
-
}
|
|
193
|
-
if (key.name === 'return' || key.name === 'enter') {
|
|
194
|
-
finalize(def)
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
if (str) {
|
|
198
|
-
const ch = str.toLowerCase()
|
|
199
|
-
if (ch === 'y' || ch === 'yes') {
|
|
200
|
-
finalize(true)
|
|
201
|
-
} else if (ch === 'n' || ch === 'no') {
|
|
202
|
-
finalize(false)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
process.stdin.on('keypress', handler)
|
|
208
|
-
})
|
|
29
|
+
if (!isTTY) return false
|
|
30
|
+
const result = await prompts.confirm({ message: planSummary, initialValue: defaultValue })
|
|
31
|
+
if (cancelPrompt(prompts, result)) return PROMPT_CANCELED
|
|
32
|
+
return result === true
|
|
209
33
|
}
|
|
210
34
|
|
|
211
35
|
/**
|
|
212
|
-
*
|
|
213
|
-
* bare Enter never authorizes a write. In a non-TTY it returns the default
|
|
214
|
-
* (`false`) without blocking — callers that must not prompt at all should branch
|
|
215
|
-
* on TTY before calling.
|
|
36
|
+
* Collect interactive setup choices before the installer begins any writes.
|
|
216
37
|
*
|
|
217
|
-
* @param {string
|
|
218
|
-
* @
|
|
219
|
-
* @returns {Promise<boolean>}
|
|
38
|
+
* @param {{ components?: string[], defaultComponents?: string[], noMcp?: boolean, prompts?: typeof clack, isTTY?: boolean }} [options]
|
|
39
|
+
* @returns {Promise<{ components?: Set<string>, target?: string, confirmed?: boolean, canceled?: boolean }>}
|
|
220
40
|
*/
|
|
221
|
-
export async function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
let scroll = 0
|
|
238
|
-
const maxVisible = Math.min(pageSize, options.length)
|
|
239
|
-
let previousLineCount = 0
|
|
240
|
-
|
|
241
|
-
const isTTY = setupStdin()
|
|
242
|
-
if (!isTTY) return items[0].value
|
|
243
|
-
cursorHide()
|
|
244
|
-
|
|
245
|
-
function render() {
|
|
246
|
-
if (cursor < scroll) scroll = cursor
|
|
247
|
-
if (cursor >= scroll + maxVisible) scroll = cursor - maxVisible + 1
|
|
248
|
-
|
|
249
|
-
const visible = items.slice(scroll, scroll + maxVisible)
|
|
250
|
-
const lines = []
|
|
251
|
-
|
|
252
|
-
if (title) lines.push(colors.bold(title))
|
|
253
|
-
|
|
254
|
-
const hasMoreAbove = scroll > 0
|
|
255
|
-
const hasMoreBelow = scroll + maxVisible < options.length
|
|
256
|
-
|
|
257
|
-
if (hasMoreAbove) lines.push(colors.dim(' ...'))
|
|
258
|
-
|
|
259
|
-
for (let i = 0; i < visible.length; i++) {
|
|
260
|
-
const item = visible[i]
|
|
261
|
-
const idx = scroll + i
|
|
262
|
-
const active = idx === cursor
|
|
263
|
-
const ptr = active ? `${colors.cyan('>')} ` : ' '
|
|
264
|
-
const name = active ? colors.cyan(item.name) : item.name
|
|
265
|
-
const desc = item.description ? colors.dim(` — ${item.description}`) : ''
|
|
266
|
-
lines.push(`${ptr}${colors.bold('◉')} ${name}${desc}`)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (hasMoreBelow) lines.push(colors.dim(' ...'))
|
|
270
|
-
|
|
271
|
-
lines.push(
|
|
272
|
-
colors.dim(
|
|
273
|
-
`(${colors.cyan('↑')}${colors.dim('/')}${colors.cyan('↓')} navigate · ${colors.cyan('Enter')}${colors.dim(' select')}`,
|
|
274
|
-
),
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
const lineCount = lines.length
|
|
278
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
279
|
-
clearDown()
|
|
280
|
-
process.stdout.write(`${lines.join('\n')}\n`)
|
|
281
|
-
previousLineCount = lineCount
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return new Promise((resolve, reject) => {
|
|
285
|
-
let settled = false
|
|
286
|
-
|
|
287
|
-
function finalize(result) {
|
|
288
|
-
if (settled) return
|
|
289
|
-
settled = true
|
|
290
|
-
cursorShow()
|
|
291
|
-
teardownStdin()
|
|
292
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
293
|
-
clearDown()
|
|
294
|
-
resolve(result)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function cancel() {
|
|
298
|
-
if (settled) return
|
|
299
|
-
settled = true
|
|
300
|
-
cursorShow()
|
|
301
|
-
teardownStdin()
|
|
302
|
-
if (previousLineCount > 0) cursorUp(previousLineCount)
|
|
303
|
-
clearDown()
|
|
304
|
-
reject(new Error('Canceled'))
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function handler(_str, key) {
|
|
308
|
-
if (!key) return
|
|
309
|
-
if ((key.ctrl && key.name === 'c') || key.name === 'escape') {
|
|
310
|
-
cancel()
|
|
311
|
-
return
|
|
312
|
-
}
|
|
313
|
-
if (key.name === 'return' || key.name === 'enter') {
|
|
314
|
-
finalize(items[cursor].value)
|
|
315
|
-
return
|
|
316
|
-
}
|
|
317
|
-
if (key.name === 'up') {
|
|
318
|
-
cursor = (cursor - 1 + items.length) % items.length
|
|
319
|
-
render()
|
|
320
|
-
return
|
|
321
|
-
}
|
|
322
|
-
if (key.name === 'down') {
|
|
323
|
-
cursor = (cursor + 1) % items.length
|
|
324
|
-
render()
|
|
325
|
-
return
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
process.stdin.on('keypress', handler)
|
|
330
|
-
render()
|
|
331
|
-
})
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
export async function runInteractiveInstall({ components = [], defaultComponents = [] } = {}) {
|
|
335
|
-
const defaultSet = new Set(defaultComponents.length > 0 ? defaultComponents : components)
|
|
41
|
+
export async function runInteractiveInstall({
|
|
42
|
+
components = [],
|
|
43
|
+
defaultComponents = [],
|
|
44
|
+
noMcp = false,
|
|
45
|
+
prompts = clack,
|
|
46
|
+
isTTY = isTerminal(),
|
|
47
|
+
} = {}) {
|
|
48
|
+
const isAllowed = (component) => !noMcp || component !== 'runtime'
|
|
49
|
+
const defaults = (defaultComponents.length > 0 ? defaultComponents : components).filter(isAllowed)
|
|
50
|
+
const defaultSet = new Set(defaults)
|
|
51
|
+
|
|
52
|
+
// Preserve the prior no-TTY fallback (defaults, global target, and no apply
|
|
53
|
+
// authorization) without asking a terminal prompt library to access stdin.
|
|
54
|
+
if (!isTTY) return { components: defaultSet, target: 'global', confirmed: true }
|
|
55
|
+
|
|
56
|
+
prompts.intro?.('OpenCode Installer')
|
|
336
57
|
|
|
337
58
|
const componentOptions = [
|
|
338
|
-
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
description: 'AGENTS.md and instructional files',
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
name: 'prompts',
|
|
355
|
-
value: 'prompts',
|
|
356
|
-
description: 'Prompt templates for agents',
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
name: 'commands',
|
|
360
|
-
value: 'commands',
|
|
361
|
-
description: 'OpenCode command shortcuts',
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
name: 'plugins',
|
|
365
|
-
value: 'plugins',
|
|
366
|
-
description: 'TUI sidebar plugin',
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
name: 'runtime',
|
|
370
|
-
value: 'runtime',
|
|
371
|
-
description: 'Python venv + MCP server scripts',
|
|
372
|
-
},
|
|
373
|
-
]
|
|
374
|
-
|
|
375
|
-
process.stdout.write('\n')
|
|
376
|
-
process.stdout.write(`${colors.bold(colors.cyan('📦 OpenCode Installer'))}\n\n`)
|
|
377
|
-
|
|
378
|
-
const selectedComponents = await promptMultiSelect(componentOptions, {
|
|
379
|
-
title: 'Select components to install:',
|
|
380
|
-
selected: defaultSet,
|
|
381
|
-
pageSize: 7,
|
|
59
|
+
{ label: 'agents', value: 'agents', hint: 'Agent configurations and routing (14 agents)' },
|
|
60
|
+
{ label: 'skills', value: 'skills', hint: `Reusable skill workflows (${20} skills)` },
|
|
61
|
+
{ label: 'instructions', value: 'instructions', hint: 'AGENTS.md and instructional files' },
|
|
62
|
+
{ label: 'prompts', value: 'prompts', hint: 'Prompt templates for agents' },
|
|
63
|
+
{ label: 'commands', value: 'commands', hint: 'OpenCode command shortcuts' },
|
|
64
|
+
{ label: 'plugins', value: 'plugins', hint: 'TUI sidebar plugin' },
|
|
65
|
+
{ label: 'runtime', value: 'runtime', hint: 'Python venv + MCP server scripts' },
|
|
66
|
+
].filter((option) => isAllowed(option.value))
|
|
67
|
+
const chosen = await prompts.multiselect({
|
|
68
|
+
message: 'Select components to install:',
|
|
69
|
+
options: componentOptions,
|
|
70
|
+
initialValues: [...defaultSet],
|
|
71
|
+
required: false,
|
|
382
72
|
})
|
|
73
|
+
if (cancelPrompt(prompts, chosen)) return { canceled: true }
|
|
383
74
|
|
|
384
|
-
|
|
385
|
-
|
|
75
|
+
const selectedComponents = new Set(chosen.filter(isAllowed))
|
|
386
76
|
if (selectedComponents.size === 0) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
selectedComponents.add(v)
|
|
390
|
-
})
|
|
77
|
+
prompts.cancel?.('No components selected. Installation canceled.')
|
|
78
|
+
return { canceled: true }
|
|
391
79
|
}
|
|
392
80
|
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
value: 'project',
|
|
402
|
-
|
|
403
|
-
},
|
|
404
|
-
]
|
|
405
|
-
|
|
406
|
-
const target = await promptList(targetOptions, {
|
|
407
|
-
title: 'Install location:',
|
|
81
|
+
const target = await prompts.select({
|
|
82
|
+
message: 'Install location:',
|
|
83
|
+
options: [
|
|
84
|
+
{
|
|
85
|
+
label: 'Global directory',
|
|
86
|
+
value: 'global',
|
|
87
|
+
hint: '~/.config/opencode (shared across projects)',
|
|
88
|
+
},
|
|
89
|
+
{ label: 'Current project', value: 'project', hint: './.opencode (scoped to this project)' },
|
|
90
|
+
],
|
|
408
91
|
})
|
|
92
|
+
if (cancelPrompt(prompts, target)) return { canceled: true }
|
|
409
93
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
)
|
|
416
|
-
|
|
417
|
-
process.stdout.write('\n')
|
|
94
|
+
const confirmed = await prompts.confirm({
|
|
95
|
+
message: `Install ${selectedComponents.size} component(s) in ${target === 'global' ? 'global config' : 'current project'}?`,
|
|
96
|
+
initialValue: true,
|
|
97
|
+
})
|
|
98
|
+
if (cancelPrompt(prompts, confirmed)) return { canceled: true }
|
|
418
99
|
|
|
419
100
|
return { components: selectedComponents, target, confirmed }
|
|
420
101
|
}
|
|
@@ -264,26 +264,24 @@ export function resumePendingMigration(target) {
|
|
|
264
264
|
export function rollbackMigration(target, version) {
|
|
265
265
|
const state = readState(target)
|
|
266
266
|
if (!state) {
|
|
267
|
-
console.log('
|
|
267
|
+
console.log(' [WARN] No install state found — nothing to roll back')
|
|
268
268
|
return { success: false, reason: 'No install state' }
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
const migrations = state.applied_migrations || []
|
|
272
272
|
const targetMigration = migrations.find((m) => m.to === version && m.status === 'completed')
|
|
273
273
|
if (!targetMigration) {
|
|
274
|
-
console.log(`
|
|
274
|
+
console.log(` [WARN] No completed migration found for version ${version}`)
|
|
275
275
|
return { success: false, reason: 'Migration not found' }
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
console.log(
|
|
279
|
-
` \u{1F504} Rolling back migration: ${targetMigration.from} \u2192 ${targetMigration.to}`,
|
|
280
|
-
)
|
|
278
|
+
console.log(` Rolling back migration: ${targetMigration.from} -> ${targetMigration.to}`)
|
|
281
279
|
|
|
282
280
|
targetMigration.status = 'rolled_back'
|
|
283
281
|
state.pantheon_version = targetMigration.from
|
|
284
282
|
writeState(target, state)
|
|
285
283
|
|
|
286
|
-
console.log(`
|
|
284
|
+
console.log(` [OK] Rolled back to ${targetMigration.from}`)
|
|
287
285
|
return { success: true, migration: targetMigration }
|
|
288
286
|
}
|
|
289
287
|
|
|
@@ -358,20 +356,16 @@ function main() {
|
|
|
358
356
|
if (list) {
|
|
359
357
|
const history = listAppliedMigrations(target)
|
|
360
358
|
if (!history.currentVersion) {
|
|
361
|
-
console.log(`
|
|
359
|
+
console.log(` [INFO] No install state found in: ${target}`)
|
|
362
360
|
return
|
|
363
361
|
}
|
|
364
362
|
console.log(` Current version: ${history.currentVersion}`)
|
|
365
363
|
console.log(` Previous version: ${history.previousVersion || 'N/A'}`)
|
|
366
364
|
console.log(` Applied migrations: ${history.migrations.length}`)
|
|
367
365
|
for (const m of history.migrations) {
|
|
368
|
-
const
|
|
369
|
-
m.status === 'completed'
|
|
370
|
-
|
|
371
|
-
: m.status === 'rolled_back'
|
|
372
|
-
? '\u{1F504}'
|
|
373
|
-
: '\u26A0\uFE0F'
|
|
374
|
-
console.log(` ${icon} ${m.from} \u2192 ${m.to} [${m.status}] (${m.applied_at})`)
|
|
366
|
+
const status =
|
|
367
|
+
m.status === 'completed' ? '[OK]' : m.status === 'rolled_back' ? '[ROLLED BACK]' : '[WARN]'
|
|
368
|
+
console.log(` ${status} ${m.from} -> ${m.to} [${m.status}] (${m.applied_at})`)
|
|
375
369
|
}
|
|
376
370
|
return
|
|
377
371
|
}
|
|
@@ -387,9 +381,9 @@ function main() {
|
|
|
387
381
|
if (!dryRun) {
|
|
388
382
|
const state = createInitialState(PANTHON_VERSION)
|
|
389
383
|
writeState(target, state)
|
|
390
|
-
console.log(`
|
|
384
|
+
console.log(` [OK] Fresh install — state written (${PANTHON_VERSION})`)
|
|
391
385
|
} else {
|
|
392
|
-
console.log(`
|
|
386
|
+
console.log(` [DRY-RUN] Fresh install — would write state (${PANTHON_VERSION})`)
|
|
393
387
|
}
|
|
394
388
|
return
|
|
395
389
|
}
|
|
@@ -397,19 +391,19 @@ function main() {
|
|
|
397
391
|
console.log(` Current version: ${currentVersion}`)
|
|
398
392
|
|
|
399
393
|
if (!force && currentVersion === PANTHON_VERSION) {
|
|
400
|
-
console.log('
|
|
394
|
+
console.log(' [OK] Already at latest version — no migrations needed')
|
|
401
395
|
return
|
|
402
396
|
}
|
|
403
397
|
|
|
404
398
|
const migration = runMigrations(target, currentVersion, { dryRun })
|
|
405
399
|
|
|
406
400
|
if (migration.applied > 0) {
|
|
407
|
-
console.log(`
|
|
401
|
+
console.log(` [OK] Applied ${migration.applied} migration(s):`)
|
|
408
402
|
for (const msg of migration.messages) {
|
|
409
403
|
console.log(` \u2022 ${msg}`)
|
|
410
404
|
}
|
|
411
405
|
} else {
|
|
412
|
-
console.log('
|
|
406
|
+
console.log(' [INFO] No applicable migrations')
|
|
413
407
|
}
|
|
414
408
|
}
|
|
415
409
|
|