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
@@ -4,31 +4,116 @@
4
4
 
5
5
  import { execSync } from 'node:child_process'
6
6
  import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs'
7
- import { isAbsolute, join, resolve } from 'node:path'
7
+ import { dirname, isAbsolute, join, resolve } from 'node:path'
8
+ import { sanitizeNpmEnv } from '../sync-tui.mjs'
9
+ import { step } from './cli-ui.mjs'
10
+ import { ACTIONS, recordChange, recordRemovalTree, removeReviewedTree, snapshot } from './plan.mjs'
8
11
  import { ROOT, writeIfChanged } from './shared.mjs'
12
+ import { strings } from './strings.mjs'
13
+ import {
14
+ assertNoSymlinkAncestors,
15
+ assertPathWithin,
16
+ assertSafeRemoval,
17
+ verifyPathRemoved,
18
+ } from './verify.mjs'
9
19
 
10
20
  /**
11
- * Copy a plugin's runtime payload (the bundled dist/*, package.json and
12
- * package-lock.json) from source to destination. Only the bundle is copied —
13
- * the raw TSX source is never shipped to the destination, so the plugin can
14
- * be modularized without the loader needing relative imports.
21
+ * Upper bound for the copied plugin's `npm ci`. Dependency installation is a
22
+ * bounded operation; without a timeout a hung registry leaves `init` blocked
23
+ * forever with no output to explain it.
24
+ */
25
+ export const NPM_CI_TIMEOUT_MS = 180_000
26
+
27
+ /**
28
+ * Run `npm ci` for a copied plugin directory.
29
+ *
30
+ * Two guarantees the install path needs and a bare `execSync` does not give:
31
+ * - the npm environment is sanitized. When Pantheon itself is installed with
32
+ * `npm install -g`, npm injects `npm_config_global`/`npm_config_prefix` into
33
+ * the lifecycle env and a nested `npm ci` aborts with ECIGLOBAL;
34
+ * - the call is bounded by {@link NPM_CI_TIMEOUT_MS} and reports a timeout as
35
+ * an actionable error instead of a silent hang.
36
+ *
37
+ * @param {string} cwd - directory holding the copied package.json + lockfile
38
+ * @param {{ timeoutMs?: number, env?: NodeJS.ProcessEnv }} [options]
39
+ */
40
+ export function runNpmCi(cwd, { timeoutMs = NPM_CI_TIMEOUT_MS, env = sanitizeNpmEnv() } = {}) {
41
+ try {
42
+ execSync('npm ci --omit=dev --no-audit --no-fund', {
43
+ cwd,
44
+ stdio: 'pipe',
45
+ env,
46
+ timeout: timeoutMs,
47
+ })
48
+ } catch (err) {
49
+ if (err?.signal || err?.code === 'ETIMEDOUT') {
50
+ throw new Error(
51
+ `TUI dependency install timed out after ${Math.round(timeoutMs / 1000)}s in ${cwd}. ` +
52
+ 'Run `npm ci --omit=dev` there manually and re-run init.',
53
+ { cause: err },
54
+ )
55
+ }
56
+ const detail = err?.stderr?.toString?.().trim()
57
+ throw new Error(`TUI dependency install failed in ${cwd}${detail ? `: ${detail}` : ''}`, {
58
+ cause: err,
59
+ })
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Copy a plugin's runtime payload (the root TUI loader, bundled dist/*,
65
+ * package.json and package-lock.json) from source to destination. The raw TSX
66
+ * implementation is never shipped to the destination; tui.ts only re-exports
67
+ * the host-specific bundle so the local plugin stays hermetic.
15
68
  * @param {string} srcDir - Source plugin directory (e.g. ROOT/src/plugins/tui)
16
69
  * @param {string} dstDir - Destination plugin directory
17
70
  * @param {object} [options]
18
71
  * @param {boolean} [options.dryRun=false] - If true, don't write files
19
- * @returns {{ created: number, skipped: number }}
72
+ * @param {'v1'|'v2'} [options.version='v1'] - Host plugin generation
73
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
74
+ * @param {Set<string>|null} [options.reviewedRemovals] - paths approved by the current plan
75
+ * @param {Map<string, object>|null} [options.reviewedSnapshots] - pre-apply path snapshots
76
+ * @returns {{ created: number, skipped: number, errors: number, problems: string[] }}
20
77
  */
21
- export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
22
- const result = { created: 0, skipped: 0 }
78
+ export function copyPluginFiles(
79
+ srcDir,
80
+ dstDir,
81
+ {
82
+ dryRun = false,
83
+ version = 'v1',
84
+ recorder = null,
85
+ reviewedRemovals = null,
86
+ reviewedSnapshots = null,
87
+ } = {},
88
+ ) {
89
+ const result = { created: 0, skipped: 0, errors: 0, problems: [] }
90
+ const distDir = join(dstDir, 'dist')
91
+ // The root loader (tui.ts / tui-v2.ts) is only a re-export of the compiled
92
+ // bundle. Writing it while the bundle is missing installs a plugin the host
93
+ // loads and then fails to resolve — a silent broken install, so refuse.
94
+ const requiredBundle = join(srcDir, 'dist', version === 'v2' ? 'tui-v2.js' : 'tui.js')
95
+ const bundleAvailable = existsSync(requiredBundle)
96
+ if (!bundleAvailable) {
97
+ result.errors++
98
+ result.problems.push(
99
+ `TUI bundle not found in the package: ${requiredBundle} — refusing to install a ` +
100
+ 'plugin entrypoint that re-exports a missing bundle. Reinstall pantheon-opencode.',
101
+ )
102
+ }
23
103
 
24
- if (!dryRun) mkdirSync(dstDir, { recursive: true })
25
- if (!dryRun) mkdirSync(join(dstDir, 'dist'), { recursive: true })
104
+ if (!dryRun) {
105
+ assertNoSymlinkAncestors(dstDir)
106
+ mkdirSync(dstDir, { recursive: true })
107
+ assertNoSymlinkAncestors(dstDir)
108
+ assertPathWithin(dstDir, distDir)
109
+ assertNoSymlinkAncestors(distDir)
110
+ mkdirSync(distDir, { recursive: true })
111
+ assertNoSymlinkAncestors(distDir)
112
+ }
26
113
 
27
114
  // Drop legacy raw copies from previous installs (root index.tsx + dist/tui.tsx).
28
- // The loader consumes only the bundle, so stale raws must not linger.
29
- if (!dryRun) {
30
- rmSync(join(dstDir, 'index.tsx'), { force: true })
31
- rmSync(join(dstDir, 'dist', 'tui.tsx'), { force: true })
115
+ for (const legacyPath of [join(dstDir, 'index.tsx'), join(distDir, 'tui.tsx')]) {
116
+ removeLegacyFile(legacyPath, dstDir, { dryRun, recorder, reviewedRemovals, reviewedSnapshots })
32
117
  }
33
118
 
34
119
  // Copy dist/* files
@@ -36,7 +121,9 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
36
121
  if (existsSync(distSrc)) {
37
122
  for (const f of readdirSync(distSrc)) {
38
123
  const c = readFileSync(join(distSrc, f), 'utf8')
39
- const status = writeIfChanged(join(dstDir, 'dist', f), c, dryRun)
124
+ const destination = join(distDir, f)
125
+ assertPathWithin(dstDir, destination)
126
+ const status = writeIfChanged(destination, c, dryRun, { recorder })
40
127
  if (status === 'created') result.created++
41
128
  else result.skipped++
42
129
  }
@@ -45,15 +132,58 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
45
132
  // Copy package.json
46
133
  const pkgSrc = join(srcDir, 'package.json')
47
134
  if (existsSync(pkgSrc)) {
135
+ const packageJson = JSON.parse(readFileSync(pkgSrc, 'utf8'))
136
+ if (version === 'v2' && packageJson.exports?.['./tui-v2']) {
137
+ packageJson.exports['./tui'] = packageJson.exports['./tui-v2']
138
+ }
48
139
  const pkgStatus = writeIfChanged(
49
140
  join(dstDir, 'package.json'),
50
- readFileSync(pkgSrc, 'utf8'),
141
+ `${JSON.stringify(packageJson, null, 2)}\n`,
51
142
  dryRun,
143
+ { recorder },
52
144
  )
53
145
  if (pkgStatus === 'created') result.created++
54
146
  else result.skipped++
55
147
  }
56
148
 
149
+ // Each host generation receives its own root loader and compiled bundle.
150
+ const tuiEntrySrc = join(srcDir, version === 'v2' ? 'tui-v2.ts' : 'tui.ts')
151
+ if (!existsSync(tuiEntrySrc)) {
152
+ result.errors++
153
+ result.problems.push(
154
+ `TUI entrypoint not found in the package: ${tuiEntrySrc} — reinstall pantheon-opencode.`,
155
+ )
156
+ } else if (bundleAvailable) {
157
+ const entryStatus = writeIfChanged(
158
+ join(dstDir, 'tui.ts'),
159
+ readFileSync(tuiEntrySrc, 'utf8'),
160
+ dryRun,
161
+ { recorder },
162
+ )
163
+ if (entryStatus === 'created') result.created++
164
+ else result.skipped++
165
+ }
166
+
167
+ const v2ServerEntry = join(srcDir, 'index-v2.ts')
168
+ const v2ServerDestination = join(dstDir, 'index.ts')
169
+ if (version === 'v2' && existsSync(v2ServerEntry)) {
170
+ const entryStatus = writeIfChanged(
171
+ v2ServerDestination,
172
+ readFileSync(v2ServerEntry, 'utf8'),
173
+ dryRun,
174
+ { recorder },
175
+ )
176
+ if (entryStatus === 'created') result.created++
177
+ else result.skipped++
178
+ } else {
179
+ removeLegacyFile(v2ServerDestination, dstDir, {
180
+ dryRun,
181
+ recorder,
182
+ reviewedRemovals,
183
+ reviewedSnapshots,
184
+ })
185
+ }
186
+
57
187
  // Copy the lockfile so dependency installation is reproducible. A missing
58
188
  // lockfile is intentionally not synthesized by the installer.
59
189
  const lockSrc = join(srcDir, 'package-lock.json')
@@ -62,6 +192,7 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
62
192
  join(dstDir, 'package-lock.json'),
63
193
  readFileSync(lockSrc, 'utf8'),
64
194
  dryRun,
195
+ { recorder },
65
196
  )
66
197
  if (lockStatus === 'created') result.created++
67
198
  else result.skipped++
@@ -70,6 +201,45 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
70
201
  return result
71
202
  }
72
203
 
204
+ function removeLegacyFile(
205
+ filePath,
206
+ rootDir,
207
+ { dryRun, recorder, reviewedRemovals, reviewedSnapshots },
208
+ ) {
209
+ assertSafeRemoval(rootDir, filePath)
210
+ const present = existsSync(filePath)
211
+ // A legacy path absent from BOTH source and target is not an operation: the
212
+ // apply skips it silently, so the preview must not invent an entry for it.
213
+ // Recording `unchanged` here listed phantom paths (`index.tsx`,
214
+ // `dist/tui.tsx`, the V1 `index.ts` shim) with `before.exists: false`.
215
+ if (!present) return
216
+ if (dryRun) {
217
+ recordChange({ path: filePath, action: ACTIONS.REMOVE, bytes: 0, scored: false }, recorder)
218
+ return
219
+ }
220
+
221
+ const normalizedPath = resolve(filePath)
222
+ if (reviewedRemovals && !reviewedRemovals.has(normalizedPath)) {
223
+ throw new Error(`Refusing unreviewed plugin removal: ${filePath}`)
224
+ }
225
+ const expected = reviewedSnapshots?.get(normalizedPath)
226
+ if (reviewedSnapshots && (!expected || !sameSnapshot(snapshot(filePath), expected))) {
227
+ throw new Error(`Plugin removal target drifted after review: ${filePath}`)
228
+ }
229
+ rmSync(filePath, { force: true })
230
+ verifyPathRemoved(filePath)
231
+ recordChange({ path: filePath, action: ACTIONS.REMOVE, bytes: 0, scored: false }, recorder)
232
+ }
233
+
234
+ function sameSnapshot(left, right) {
235
+ return (
236
+ left.exists === right.exists &&
237
+ left.sha256 === right.sha256 &&
238
+ left.size === right.size &&
239
+ left.mode === right.mode
240
+ )
241
+ }
242
+
73
243
  /**
74
244
  * Install a plugin from source to destination.
75
245
  * @param {string} srcDir - Source plugin directory (e.g. ROOT/src/plugins/tui)
@@ -77,23 +247,70 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false } = {}) {
77
247
  * @param {object} [options]
78
248
  * @param {boolean} [options.dryRun=false] - If true, don't write files
79
249
  * @param {boolean} [options.clean=false] - If true, remove existing before install
80
- * @returns {{ created: number, skipped: number, errors: number }}
250
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
251
+ * @returns {{ created: number, skipped: number, errors: number, problems: string[] }}
81
252
  */
82
- export function installPlugin(srcDir, dstDir, { dryRun = false, clean = false } = {}) {
83
- const result = { created: 0, skipped: 0, errors: 0 }
253
+ export function installPlugin(
254
+ srcDir,
255
+ dstDir,
256
+ {
257
+ dryRun = false,
258
+ clean = false,
259
+ version = 'v1',
260
+ recorder = null,
261
+ reviewedRemovals = null,
262
+ reviewedSnapshots = null,
263
+ } = {},
264
+ ) {
265
+ const result = { created: 0, skipped: 0, errors: 0, problems: [] }
266
+ const cleanTargetExisted = clean && existsSync(dstDir)
84
267
 
85
- if (clean && existsSync(dstDir) && !dryRun) {
86
- rmSync(dstDir, { recursive: true, force: true })
268
+ assertNoSymlinkAncestors(dstDir)
269
+ if (cleanTargetExisted) {
270
+ assertSafeRemoval(dirname(dstDir), dstDir)
271
+ if (dryRun) {
272
+ recordRemovalTree(dstDir, recorder)
273
+ } else {
274
+ removeReviewedTree(dstDir, reviewedRemovals, reviewedSnapshots)
275
+ }
87
276
  }
88
277
 
89
- const copyResult = copyPluginFiles(srcDir, dstDir, { dryRun })
278
+ const copyResult = copyPluginFiles(srcDir, dstDir, {
279
+ dryRun,
280
+ version,
281
+ recorder,
282
+ reviewedRemovals,
283
+ reviewedSnapshots,
284
+ })
90
285
  result.created += copyResult.created
91
286
  result.skipped += copyResult.skipped
287
+ result.errors += copyResult.errors
288
+ result.problems.push(...copyResult.problems)
289
+ if (cleanTargetExisted) {
290
+ // The clean pass removes these directories before rebuilding their files;
291
+ // keep the net plan truthful while the separate removal review still lists
292
+ // every path actually cleared.
293
+ recordChange({ path: dstDir, action: ACTIONS.UNCHANGED, bytes: 0, scored: false }, recorder)
294
+ if (existsSync(join(srcDir, 'dist'))) {
295
+ recordChange(
296
+ { path: join(dstDir, 'dist'), action: ACTIONS.UNCHANGED, bytes: 0, scored: false },
297
+ recorder,
298
+ )
299
+ }
300
+ }
92
301
 
93
302
  // Install plugin dependencies (@opentui/core, @opentui/solid, solid-js).
94
- // Lockfile installation is the only accepted dependency path.
95
- if (!dryRun) {
96
- execSync('npm ci --omit=dev --no-audit --no-fund', { cwd: dstDir, stdio: 'pipe' })
303
+ // Lockfile installation is the only accepted dependency path. A copy that
304
+ // already failed its bundle check is not worth installing dependencies for.
305
+ if (!dryRun && result.errors === 0) {
306
+ const depsStep = step(strings().installingTuiDeps)
307
+ try {
308
+ runNpmCi(dstDir)
309
+ } catch (err) {
310
+ depsStep(false)
311
+ throw err
312
+ }
313
+ depsStep(true)
97
314
  }
98
315
 
99
316
  return result
@@ -107,7 +324,7 @@ export function installPlugin(srcDir, dstDir, { dryRun = false, clean = false }
107
324
  */
108
325
  export function installPluginDependencies(pluginDir, { dryRun = false } = {}) {
109
326
  if (dryRun) return
110
- execSync('npm ci --omit=dev --no-audit --no-fund', { cwd: pluginDir, stdio: 'pipe' })
327
+ runNpmCi(pluginDir)
111
328
  }
112
329
 
113
330
  /**
@@ -116,9 +333,10 @@ export function installPluginDependencies(pluginDir, { dryRun = false } = {}) {
116
333
  * @param {string} pluginId - Plugin identifier string
117
334
  * @param {object} [options]
118
335
  * @param {boolean} [options.dryRun=false]
336
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
119
337
  * @returns {'created'|'skipped'}
120
338
  */
121
- export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false } = {}) {
339
+ export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false, recorder = null } = {}) {
122
340
  let tuiConfig = { plugin: [] }
123
341
  if (existsSync(tuiJsonPath)) {
124
342
  try {
@@ -134,7 +352,7 @@ export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false } = {}) {
134
352
  tuiConfig.plugin.push(pluginId)
135
353
  }
136
354
  const tuiContent = `${JSON.stringify(tuiConfig, null, 2)}\n`
137
- return writeIfChanged(tuiJsonPath, tuiContent, dryRun)
355
+ return writeIfChanged(tuiJsonPath, tuiContent, dryRun, { recorder })
138
356
  }
139
357
 
140
358
  /**
@@ -222,12 +440,14 @@ export function staleTuiRefs(pluginArray, knownPantheonPaths = []) {
222
440
  * @param {string} pluginId - Plugin to unregister
223
441
  * @param {object} [options]
224
442
  * @param {boolean} [options.dryRun=false]
443
+ * @param {string[]} [options.knownPantheonPaths=[]]
444
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
225
445
  * @returns {'created'|'skipped'}
226
446
  */
227
447
  export function unregisterPlugin(
228
448
  tuiJsonPath,
229
449
  pluginId,
230
- { dryRun = false, knownPantheonPaths = [] } = {},
450
+ { dryRun = false, knownPantheonPaths = [], recorder = null } = {},
231
451
  ) {
232
452
  if (!existsSync(tuiJsonPath)) {
233
453
  // Nothing to clean — and never create an empty tui.json in a location
@@ -258,5 +478,6 @@ export function unregisterPlugin(
258
478
  return !isPantheonTuiRef(ref, knownPantheonPaths)
259
479
  })
260
480
  const tuiContent = `${JSON.stringify(tuiConfig, null, 2)}\n`
261
- return writeIfChanged(tuiJsonPath, tuiContent, dryRun)
481
+ // Stale-ref cleanup is not part of the install summary, so record it unscored.
482
+ return writeIfChanged(tuiJsonPath, tuiContent, dryRun, { recorder, scored: false })
262
483
  }
@@ -0,0 +1,2 @@
1
+ /** Sentinel returned when the user cancels an interactive authorization prompt. */
2
+ export const PROMPT_CANCELED = Symbol('pantheon-prompt-canceled')