pantheon-opencode 1.6.0-beta.8 → 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.
Files changed (141) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +126 -346
  4. package/README.md +83 -608
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +366 -132
  7. package/commands/pantheon-audit.md +7 -1
  8. package/commands/pantheon-consolidate.md +1 -1
  9. package/commands/pantheon-deepwork.md +14 -3
  10. package/commands/pantheon-focus.md +17 -0
  11. package/commands/pantheon-vision.md +61 -12
  12. package/package.json +19 -11
  13. package/plugin.json +1 -1
  14. package/pyproject.toml +6 -2
  15. package/scripts/_pantheon_paths.py +24 -0
  16. package/scripts/build-agents-md.mjs +368 -69
  17. package/scripts/changelog-merge.mjs +161 -0
  18. package/scripts/check-plugin-v2-coverage.mjs +11 -8
  19. package/scripts/docs-check-changelog.mjs +204 -0
  20. package/scripts/docs-link-check.mjs +314 -0
  21. package/scripts/docs-media.mjs +157 -0
  22. package/scripts/doctor.mjs +828 -40
  23. package/scripts/install/agents-md.mjs +2 -2
  24. package/scripts/install/backup.mjs +648 -0
  25. package/scripts/install/cli-ui.mjs +303 -72
  26. package/scripts/install/component-selection.mjs +61 -0
  27. package/scripts/install/config-migration.mjs +583 -27
  28. package/scripts/install/exit-codes.mjs +26 -0
  29. package/scripts/install/file-inventory.mjs +555 -0
  30. package/scripts/install/health-check.mjs +31 -25
  31. package/scripts/install/interactive.mjs +78 -383
  32. package/scripts/install/migrate.mjs +49 -25
  33. package/scripts/install/model-picker.mjs +218 -250
  34. package/scripts/install/opencode-version.mjs +83 -21
  35. package/scripts/install/opencode.mjs +1465 -180
  36. package/scripts/install/plan-artifact.mjs +517 -0
  37. package/scripts/install/plan.mjs +475 -0
  38. package/scripts/install/plugin.mjs +251 -30
  39. package/scripts/install/prompt-result.mjs +2 -0
  40. package/scripts/install/shared.mjs +256 -99
  41. package/scripts/install/state.mjs +63 -8
  42. package/scripts/install/strings.mjs +60 -4
  43. package/scripts/install/venv.mjs +90 -47
  44. package/scripts/install/verify.mjs +128 -0
  45. package/scripts/install/vision-prompt.mjs +173 -0
  46. package/scripts/install-mcp.mjs +2 -2
  47. package/scripts/manifest-inventory.mjs +49 -3
  48. package/scripts/mcp_persistence.py +1535 -1050
  49. package/scripts/memory_mcp.py +12 -843
  50. package/scripts/node-engine-policy.mjs +85 -0
  51. package/scripts/package-evidence.mjs +10 -2
  52. package/scripts/postinstall.mjs +26 -26
  53. package/scripts/probe-pantheon-cost.mjs +118 -19
  54. package/scripts/prune.mjs +9 -3
  55. package/scripts/reconcile.mjs +325 -0
  56. package/scripts/release-gates.mjs +682 -0
  57. package/scripts/restore.mjs +222 -0
  58. package/scripts/run-node-tests.mjs +24 -8
  59. package/scripts/sync-artifacts.mjs +20 -7
  60. package/scripts/sync-tui.mjs +29 -4
  61. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  62. package/scripts/uninstall.mjs +369 -34
  63. package/scripts/update.mjs +164 -0
  64. package/scripts/validate-node-engine-policy.mjs +13 -0
  65. package/scripts/version-check.mjs +34 -1
  66. package/scripts/versioning.mjs +23 -3
  67. package/scripts/vision-status.mjs +682 -0
  68. package/skills-lock.json +8 -8
  69. package/src/agents/aphrodite.md +13 -10
  70. package/src/agents/apollo.md +4 -5
  71. package/src/agents/athena.md +74 -46
  72. package/src/agents/demeter.md +10 -7
  73. package/src/agents/gaia.md +0 -1
  74. package/src/agents/hephaestus.md +4 -3
  75. package/src/agents/hermes.md +10 -9
  76. package/src/agents/iris.md +6 -1
  77. package/src/agents/mnemosyne.md +14 -15
  78. package/src/agents/nyx.md +4 -4
  79. package/src/agents/prometheus.md +12 -11
  80. package/src/agents/talos.md +6 -0
  81. package/src/agents/zeus.md +84 -56
  82. package/src/instructions/agent-return-format.instructions.md +12 -41
  83. package/src/instructions/memory-protocol.instructions.md +5 -11
  84. package/src/instructions/test-economy.instructions.md +12 -0
  85. package/src/instructions/yagni.instructions.md +6 -15
  86. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  87. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  88. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  89. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  90. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  91. package/src/mcp/_pantheon_paths.py +24 -0
  92. package/src/mcp/mcp_codemap_module.py +86 -18
  93. package/src/mcp/mcp_persistence.py +1535 -1050
  94. package/src/mcp/memory_mcp.py +444 -94
  95. package/src/mcp/pantheon_vision.py +285 -41
  96. package/src/mcp/requirements-mcp.txt +5 -0
  97. package/src/pantheon/context-pruner.ts +541 -0
  98. package/src/pantheon/cost-command.ts +814 -60
  99. package/src/pantheon/goal-loop.ts +11 -8
  100. package/src/pantheon/memory-context.ts +1017 -0
  101. package/src/pantheon/model-agents.ts +19 -0
  102. package/src/pantheon/model-command.ts +218 -56
  103. package/src/pantheon/model-pricing.ts +536 -0
  104. package/src/pantheon/presets.mjs +2 -0
  105. package/src/pantheon/task-result-guard.ts +50 -14
  106. package/src/pantheon/v2-bounded-read.ts +640 -0
  107. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  108. package/src/pantheon/v2-execute-after.ts +135 -24
  109. package/src/pantheon/v2-model-overrides.ts +275 -0
  110. package/src/pantheon/v2-tools.ts +89 -35
  111. package/src/pantheon/v2-unsupported.mjs +2 -3
  112. package/src/pantheon/v2-vision.ts +622 -0
  113. package/src/pantheon/vision-local.ts +531 -0
  114. package/src/pantheon/vision.ts +1160 -115
  115. package/src/plugin-v2.ts +654 -162
  116. package/src/plugin.ts +15 -11
  117. package/src/plugins/tui/dist/tui-v2.d.ts +1036 -0
  118. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -0
  119. package/src/plugins/tui/dist/tui-v2.js +3808 -0
  120. package/src/plugins/tui/dist/tui-v2.js.map +1 -0
  121. package/src/plugins/tui/dist/tui.js +4 -4
  122. package/src/plugins/tui/index-v2.ts +6 -0
  123. package/src/plugins/tui/package-lock.json +5416 -1297
  124. package/src/plugins/tui/package.json +14 -10
  125. package/src/plugins/tui/src/index-v2.tsx +4372 -0
  126. package/src/plugins/tui/src/index.tsx +3 -3
  127. package/src/plugins/tui/src/opencode-v2.d.ts +13 -0
  128. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  129. package/src/plugins/tui/tsdown.config.ts +2 -2
  130. package/src/plugins/tui/tui-v2.ts +2 -0
  131. package/src/plugins/tui/tui.ts +3 -0
  132. package/src/routing.yml +50 -5
  133. package/src/skills/agent-coordination/SKILL.md +7 -2
  134. package/src/skills/artifact-management/SKILL.md +5 -1
  135. package/src/skills/auto-continue/SKILL.md +14 -6
  136. package/src/skills/codemap/SKILL.md +1 -1
  137. package/src/skills/memory-bank/SKILL.md +21 -13
  138. package/src/skills/session-goal/SKILL.md +14 -15
  139. package/src/skills/spec-driven-development/SKILL.md +3 -1
  140. package/src/skills/worktrees/SKILL.md +30 -11
  141. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -1,406 +1,101 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { emitKeypressEvents } from 'node:readline'
4
- import { colors } from './cli-ui.mjs'
3
+ import * as clack from '@clack/prompts'
4
+ import { PROMPT_CANCELED } from './prompt-result.mjs'
5
5
 
6
- const cursorHide = () => process.stdout.write('\x1b[?25l')
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 setupStdin() {
12
- if (!process.stdin.isTTY) return false
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 teardownStdin() {
25
- try {
26
- process.stdin.setRawMode(false)
27
- process.stdin.removeAllListeners('keypress')
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
- export async function promptMultiSelect(
35
- options,
36
- { title = '', selected = new Set(), pageSize = 6 } = {},
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 (options.length === 0) return new Set()
39
-
40
- const preSelected = selected instanceof Set ? selected : new Set(selected)
41
- const items = options.map((o) => ({
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
- })
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
156
33
  }
157
34
 
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
- })
209
- }
210
-
211
- export async function promptList(options, { title = '' } = {}) {
212
- if (options.length === 0) throw new Error('No options provided')
213
- if (options.length === 1) return options[0].value
214
-
215
- const items = options.map((o) => ({
216
- name: o.name,
217
- value: o.value,
218
- description: o.description || '',
219
- }))
220
-
221
- let cursor = 0
222
- const pageSize = Math.min(8, options.length)
223
- let scroll = 0
224
- const maxVisible = Math.min(pageSize, options.length)
225
- let previousLineCount = 0
226
-
227
- const isTTY = setupStdin()
228
- if (!isTTY) return items[0].value
229
- cursorHide()
230
-
231
- function render() {
232
- if (cursor < scroll) scroll = cursor
233
- if (cursor >= scroll + maxVisible) scroll = cursor - maxVisible + 1
234
-
235
- const visible = items.slice(scroll, scroll + maxVisible)
236
- const lines = []
237
-
238
- if (title) lines.push(colors.bold(title))
239
-
240
- const hasMoreAbove = scroll > 0
241
- const hasMoreBelow = scroll + maxVisible < options.length
242
-
243
- if (hasMoreAbove) lines.push(colors.dim(' ...'))
244
-
245
- for (let i = 0; i < visible.length; i++) {
246
- const item = visible[i]
247
- const idx = scroll + i
248
- const active = idx === cursor
249
- const ptr = active ? `${colors.cyan('>')} ` : ' '
250
- const name = active ? colors.cyan(item.name) : item.name
251
- const desc = item.description ? colors.dim(` — ${item.description}`) : ''
252
- lines.push(`${ptr}${colors.bold('◉')} ${name}${desc}`)
253
- }
254
-
255
- if (hasMoreBelow) lines.push(colors.dim(' ...'))
256
-
257
- lines.push(
258
- colors.dim(
259
- `(${colors.cyan('↑')}${colors.dim('/')}${colors.cyan('↓')} navigate · ${colors.cyan('Enter')}${colors.dim(' select')}`,
260
- ),
261
- )
262
-
263
- const lineCount = lines.length
264
- if (previousLineCount > 0) cursorUp(previousLineCount)
265
- clearDown()
266
- process.stdout.write(`${lines.join('\n')}\n`)
267
- previousLineCount = lineCount
268
- }
269
-
270
- return new Promise((resolve, reject) => {
271
- let settled = false
272
-
273
- function finalize(result) {
274
- if (settled) return
275
- settled = true
276
- cursorShow()
277
- teardownStdin()
278
- if (previousLineCount > 0) cursorUp(previousLineCount)
279
- clearDown()
280
- resolve(result)
281
- }
282
-
283
- function cancel() {
284
- if (settled) return
285
- settled = true
286
- cursorShow()
287
- teardownStdin()
288
- if (previousLineCount > 0) cursorUp(previousLineCount)
289
- clearDown()
290
- reject(new Error('Canceled'))
291
- }
292
-
293
- function handler(_str, key) {
294
- if (!key) return
295
- if ((key.ctrl && key.name === 'c') || key.name === 'escape') {
296
- cancel()
297
- return
298
- }
299
- if (key.name === 'return' || key.name === 'enter') {
300
- finalize(items[cursor].value)
301
- return
302
- }
303
- if (key.name === 'up') {
304
- cursor = (cursor - 1 + items.length) % items.length
305
- render()
306
- return
307
- }
308
- if (key.name === 'down') {
309
- cursor = (cursor + 1) % items.length
310
- render()
311
- return
312
- }
313
- }
314
-
315
- process.stdin.on('keypress', handler)
316
- render()
317
- })
318
- }
319
-
320
- export async function runInteractiveInstall({ components = [], defaultComponents = [] } = {}) {
321
- const defaultSet = new Set(defaultComponents.length > 0 ? defaultComponents : components)
35
+ /**
36
+ * Collect interactive setup choices before the installer begins any writes.
37
+ *
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 }>}
40
+ */
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')
322
57
 
323
58
  const componentOptions = [
324
- {
325
- name: 'agents',
326
- value: 'agents',
327
- description: `Agent configurations and routing (${14} agents)`,
328
- },
329
- {
330
- name: 'skills',
331
- value: 'skills',
332
- description: `Reusable skill workflows (${20} skills)`,
333
- },
334
- {
335
- name: 'instructions',
336
- value: 'instructions',
337
- description: 'AGENTS.md and instructional files',
338
- },
339
- {
340
- name: 'prompts',
341
- value: 'prompts',
342
- description: 'Prompt templates for agents',
343
- },
344
- {
345
- name: 'commands',
346
- value: 'commands',
347
- description: 'OpenCode command shortcuts',
348
- },
349
- {
350
- name: 'plugins',
351
- value: 'plugins',
352
- description: 'TUI sidebar plugin',
353
- },
354
- {
355
- name: 'runtime',
356
- value: 'runtime',
357
- description: 'Python venv + MCP server scripts',
358
- },
359
- ]
360
-
361
- process.stdout.write('\n')
362
- process.stdout.write(`${colors.bold(colors.cyan('📦 OpenCode Installer'))}\n\n`)
363
-
364
- const selectedComponents = await promptMultiSelect(componentOptions, {
365
- title: 'Select components to install:',
366
- selected: defaultSet,
367
- 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,
368
72
  })
73
+ if (cancelPrompt(prompts, chosen)) return { canceled: true }
369
74
 
370
- process.stdout.write('\n')
371
-
75
+ const selectedComponents = new Set(chosen.filter(isAllowed))
372
76
  if (selectedComponents.size === 0) {
373
- process.stdout.write(`${colors.yellow('No components selected — using defaults\n')}`)
374
- defaultSet.forEach((v) => {
375
- selectedComponents.add(v)
376
- })
77
+ prompts.cancel?.('No components selected. Installation canceled.')
78
+ return { canceled: true }
377
79
  }
378
80
 
379
- const targetOptions = [
380
- {
381
- name: 'Global directory',
382
- value: 'global',
383
- description: '~/.config/opencode (shared across projects)',
384
- },
385
- {
386
- name: 'Current project',
387
- value: 'project',
388
- description: './.opencode (scoped to this project)',
389
- },
390
- ]
391
-
392
- const target = await promptList(targetOptions, {
393
- 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
+ ],
394
91
  })
92
+ if (cancelPrompt(prompts, target)) return { canceled: true }
395
93
 
396
- process.stdout.write('\n')
397
-
398
- const confirmed = await promptConfirm(
399
- `Install ${selectedComponents.size} component(s) in ${target === 'global' ? 'global config' : 'current project'}?`,
400
- { default: true },
401
- )
402
-
403
- 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 }
404
99
 
405
100
  return { components: selectedComponents, target, confirmed }
406
101
  }
@@ -11,6 +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
+ import { ACTIONS, fingerprintOutput, recordChange } from './plan.mjs'
14
16
  import { createInitialState, readState, writeState } from './state.mjs'
15
17
 
16
18
  const __dirname = dirname(fileURLToPath(import.meta.url))
@@ -44,10 +46,14 @@ export function detectVersion(target) {
44
46
  *
45
47
  * @param {string} target - Installation directory
46
48
  * @param {string|null} currentVersion - Detected version (null = fresh install)
47
- * @param {{ dryRun?: boolean }} [options]
49
+ * @param {{ dryRun?: boolean, recorder?: (change: object) => void }} [options]
48
50
  * @returns {{ applied: number, messages: string[] }}
49
51
  */
50
- export function runMigrations(target, currentVersion, { dryRun = false } = {}) {
52
+ export function runMigrations(
53
+ target,
54
+ currentVersion,
55
+ { dryRun = false, recorder = null, updatedAt = new Date().toISOString() } = {},
56
+ ) {
51
57
  const applied = []
52
58
  const semver = parseSemver(currentVersion)
53
59
 
@@ -104,16 +110,18 @@ export function runMigrations(target, currentVersion, { dryRun = false } = {}) {
104
110
  }
105
111
 
106
112
  // ── Write updated state ───────────────────────────────────────────
107
- if (applied.length > 0 && !dryRun) {
113
+ if (applied.length > 0) {
114
+ const statePath = join(target, '.pantheon', 'install-state.json')
108
115
  const newVersion = formatSemver(semver)
109
116
  let state = readState(target)
110
- if (!state) state = createInitialState(newVersion)
117
+ const stateExisted = state !== null
118
+ if (!state) state = createInitialState(newVersion, updatedAt)
111
119
  state.pantheon_version = newVersion
112
120
  for (const m of applied) {
113
121
  state.applied_migrations.push({
114
122
  from: m.from,
115
123
  to: m.to,
116
- applied_at: new Date().toISOString(),
124
+ applied_at: updatedAt,
117
125
  status: 'completed',
118
126
  })
119
127
  }
@@ -125,12 +133,31 @@ export function runMigrations(target, currentVersion, { dryRun = false } = {}) {
125
133
  runtime: { version: 1, status: 'installed' },
126
134
  }
127
135
  }
128
- writeState(target, state)
136
+ state.updated_at = updatedAt
137
+ state.schema_version = 2
138
+ const stateContent = `${JSON.stringify(state, null, 2)}\n`
139
+ if (!dryRun) writeState(target, state, { updatedAt })
140
+ recordChange(
141
+ {
142
+ path: statePath,
143
+ action: stateExisted ? ACTIONS.UPDATE : ACTIONS.CREATE,
144
+ bytes: Buffer.byteLength(stateContent, 'utf8'),
145
+ outputFingerprint: fingerprintOutput(stateContent),
146
+ scored: false,
147
+ },
148
+ recorder,
149
+ )
150
+ return {
151
+ applied: applied.length,
152
+ messages: applied.map((m) => `${m.from} → ${m.to}: ${m.description}`),
153
+ plannedState: state,
154
+ }
129
155
  }
130
156
 
131
157
  return {
132
158
  applied: applied.length,
133
159
  messages: applied.map((m) => `${m.from} → ${m.to}: ${m.description}`),
160
+ plannedState: null,
134
161
  }
135
162
  }
136
163
 
@@ -238,26 +265,24 @@ export function resumePendingMigration(target) {
238
265
  export function rollbackMigration(target, version) {
239
266
  const state = readState(target)
240
267
  if (!state) {
241
- console.log(' \u26A0\uFE0F No install state found — nothing to roll back')
268
+ console.log(' [WARN] No install state found — nothing to roll back')
242
269
  return { success: false, reason: 'No install state' }
243
270
  }
244
271
 
245
272
  const migrations = state.applied_migrations || []
246
273
  const targetMigration = migrations.find((m) => m.to === version && m.status === 'completed')
247
274
  if (!targetMigration) {
248
- console.log(` \u26A0\uFE0F No completed migration found for version ${version}`)
275
+ console.log(` [WARN] No completed migration found for version ${version}`)
249
276
  return { success: false, reason: 'Migration not found' }
250
277
  }
251
278
 
252
- console.log(
253
- ` \u{1F504} Rolling back migration: ${targetMigration.from} \u2192 ${targetMigration.to}`,
254
- )
279
+ console.log(` Rolling back migration: ${targetMigration.from} -> ${targetMigration.to}`)
255
280
 
256
281
  targetMigration.status = 'rolled_back'
257
282
  state.pantheon_version = targetMigration.from
258
283
  writeState(target, state)
259
284
 
260
- console.log(` \u2705 Rolled back to ${targetMigration.from}`)
285
+ console.log(` [OK] Rolled back to ${targetMigration.from}`)
261
286
  return { success: true, migration: targetMigration }
262
287
  }
263
288
 
@@ -328,24 +353,23 @@ function main() {
328
353
  const dryRun = args.includes('--dry-run')
329
354
  const force = args.includes('--force')
330
355
  const list = args.includes('--list')
356
+ // One dry-run marker for the whole CLI: cli-ui's tag(). This file used to
357
+ // hardcode its own `[DRY-RUN]` prefix while other CLIs printed `[dry-run]`.
358
+ configureUi({ dryRun })
331
359
 
332
360
  if (list) {
333
361
  const history = listAppliedMigrations(target)
334
362
  if (!history.currentVersion) {
335
- console.log(` \u2139\uFE0F No install state found in: ${target}`)
363
+ console.log(` [INFO] No install state found in: ${target}`)
336
364
  return
337
365
  }
338
366
  console.log(` Current version: ${history.currentVersion}`)
339
367
  console.log(` Previous version: ${history.previousVersion || 'N/A'}`)
340
368
  console.log(` Applied migrations: ${history.migrations.length}`)
341
369
  for (const m of history.migrations) {
342
- const icon =
343
- m.status === 'completed'
344
- ? '\u2705'
345
- : m.status === 'rolled_back'
346
- ? '\u{1F504}'
347
- : '\u26A0\uFE0F'
348
- console.log(` ${icon} ${m.from} \u2192 ${m.to} [${m.status}] (${m.applied_at})`)
370
+ const status =
371
+ m.status === 'completed' ? '[OK]' : m.status === 'rolled_back' ? '[ROLLED BACK]' : '[WARN]'
372
+ console.log(` ${status} ${m.from} -> ${m.to} [${m.status}] (${m.applied_at})`)
349
373
  }
350
374
  return
351
375
  }
@@ -361,9 +385,9 @@ function main() {
361
385
  if (!dryRun) {
362
386
  const state = createInitialState(PANTHON_VERSION)
363
387
  writeState(target, state)
364
- console.log(` \u2705 Fresh install — state written (${PANTHON_VERSION})`)
388
+ console.log(` [OK] Fresh install — state written (${PANTHON_VERSION})`)
365
389
  } else {
366
- console.log(` \u2705 Fresh install — would write state (${PANTHON_VERSION})`)
390
+ console.log(` ${tag(`Fresh install — would write state (${PANTHON_VERSION})`)}`)
367
391
  }
368
392
  return
369
393
  }
@@ -371,19 +395,19 @@ function main() {
371
395
  console.log(` Current version: ${currentVersion}`)
372
396
 
373
397
  if (!force && currentVersion === PANTHON_VERSION) {
374
- console.log(' \u23ED\uFE0F Already at latest version — no migrations needed')
398
+ console.log(' [OK] Already at latest version — no migrations needed')
375
399
  return
376
400
  }
377
401
 
378
402
  const migration = runMigrations(target, currentVersion, { dryRun })
379
403
 
380
404
  if (migration.applied > 0) {
381
- console.log(` \u2705 Applied ${migration.applied} migration(s):`)
405
+ console.log(` [OK] Applied ${migration.applied} migration(s):`)
382
406
  for (const msg of migration.messages) {
383
407
  console.log(` \u2022 ${msg}`)
384
408
  }
385
409
  } else {
386
- console.log(' \u23ED\uFE0F No applicable migrations')
410
+ console.log(' [INFO] No applicable migrations')
387
411
  }
388
412
  }
389
413