pantheon-opencode 1.6.0-beta.9 → 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 (131) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +126 -376
  4. package/README.md +83 -610
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +366 -132
  7. package/commands/pantheon-deepwork.md +14 -3
  8. package/commands/pantheon-vision.md +61 -12
  9. package/package.json +19 -11
  10. package/plugin.json +1 -1
  11. package/pyproject.toml +6 -2
  12. package/scripts/_pantheon_paths.py +24 -0
  13. package/scripts/build-agents-md.mjs +368 -69
  14. package/scripts/changelog-merge.mjs +161 -0
  15. package/scripts/check-plugin-v2-coverage.mjs +11 -8
  16. package/scripts/docs-check-changelog.mjs +204 -0
  17. package/scripts/docs-link-check.mjs +314 -0
  18. package/scripts/docs-media.mjs +157 -0
  19. package/scripts/doctor.mjs +828 -40
  20. package/scripts/install/agents-md.mjs +2 -2
  21. package/scripts/install/backup.mjs +648 -0
  22. package/scripts/install/cli-ui.mjs +303 -72
  23. package/scripts/install/component-selection.mjs +61 -0
  24. package/scripts/install/config-migration.mjs +583 -27
  25. package/scripts/install/exit-codes.mjs +26 -0
  26. package/scripts/install/file-inventory.mjs +555 -0
  27. package/scripts/install/health-check.mjs +31 -25
  28. package/scripts/install/interactive.mjs +78 -383
  29. package/scripts/install/migrate.mjs +49 -25
  30. package/scripts/install/model-picker.mjs +218 -250
  31. package/scripts/install/opencode-version.mjs +83 -21
  32. package/scripts/install/opencode.mjs +1413 -154
  33. package/scripts/install/plan-artifact.mjs +517 -0
  34. package/scripts/install/plan.mjs +475 -0
  35. package/scripts/install/plugin.mjs +214 -27
  36. package/scripts/install/prompt-result.mjs +2 -0
  37. package/scripts/install/shared.mjs +256 -99
  38. package/scripts/install/state.mjs +63 -8
  39. package/scripts/install/strings.mjs +60 -4
  40. package/scripts/install/venv.mjs +90 -47
  41. package/scripts/install/verify.mjs +128 -0
  42. package/scripts/install/vision-prompt.mjs +173 -0
  43. package/scripts/install-mcp.mjs +2 -2
  44. package/scripts/manifest-inventory.mjs +49 -3
  45. package/scripts/mcp_persistence.py +1535 -1050
  46. package/scripts/memory_mcp.py +12 -843
  47. package/scripts/node-engine-policy.mjs +85 -0
  48. package/scripts/package-evidence.mjs +10 -2
  49. package/scripts/postinstall.mjs +26 -26
  50. package/scripts/probe-pantheon-cost.mjs +118 -19
  51. package/scripts/prune.mjs +9 -3
  52. package/scripts/reconcile.mjs +325 -0
  53. package/scripts/release-gates.mjs +682 -0
  54. package/scripts/restore.mjs +222 -0
  55. package/scripts/run-node-tests.mjs +24 -8
  56. package/scripts/sync-artifacts.mjs +19 -7
  57. package/scripts/sync-tui.mjs +5 -1
  58. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  59. package/scripts/uninstall.mjs +369 -34
  60. package/scripts/update.mjs +164 -0
  61. package/scripts/validate-node-engine-policy.mjs +13 -0
  62. package/scripts/version-check.mjs +34 -1
  63. package/scripts/versioning.mjs +23 -3
  64. package/scripts/vision-status.mjs +682 -0
  65. package/skills-lock.json +8 -8
  66. package/src/agents/aphrodite.md +13 -10
  67. package/src/agents/apollo.md +4 -5
  68. package/src/agents/athena.md +74 -46
  69. package/src/agents/demeter.md +10 -7
  70. package/src/agents/gaia.md +0 -1
  71. package/src/agents/hephaestus.md +4 -3
  72. package/src/agents/hermes.md +10 -9
  73. package/src/agents/iris.md +6 -1
  74. package/src/agents/mnemosyne.md +10 -4
  75. package/src/agents/nyx.md +4 -4
  76. package/src/agents/prometheus.md +12 -11
  77. package/src/agents/talos.md +6 -0
  78. package/src/agents/zeus.md +84 -56
  79. package/src/instructions/agent-return-format.instructions.md +12 -41
  80. package/src/instructions/memory-protocol.instructions.md +5 -11
  81. package/src/instructions/test-economy.instructions.md +12 -0
  82. package/src/instructions/yagni.instructions.md +6 -15
  83. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  84. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  85. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  86. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  87. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  88. package/src/mcp/_pantheon_paths.py +24 -0
  89. package/src/mcp/mcp_codemap_module.py +86 -18
  90. package/src/mcp/mcp_persistence.py +1535 -1050
  91. package/src/mcp/memory_mcp.py +444 -94
  92. package/src/mcp/pantheon_vision.py +285 -41
  93. package/src/mcp/requirements-mcp.txt +5 -0
  94. package/src/pantheon/context-pruner.ts +541 -0
  95. package/src/pantheon/cost-command.ts +814 -60
  96. package/src/pantheon/goal-loop.ts +11 -8
  97. package/src/pantheon/memory-context.ts +1017 -0
  98. package/src/pantheon/model-agents.ts +19 -0
  99. package/src/pantheon/model-command.ts +218 -56
  100. package/src/pantheon/model-pricing.ts +536 -0
  101. package/src/pantheon/presets.mjs +2 -0
  102. package/src/pantheon/task-result-guard.ts +50 -14
  103. package/src/pantheon/v2-bounded-read.ts +640 -0
  104. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  105. package/src/pantheon/v2-execute-after.ts +135 -24
  106. package/src/pantheon/v2-model-overrides.ts +275 -0
  107. package/src/pantheon/v2-tools.ts +89 -35
  108. package/src/pantheon/v2-unsupported.mjs +2 -3
  109. package/src/pantheon/v2-vision.ts +622 -0
  110. package/src/pantheon/vision-local.ts +531 -0
  111. package/src/pantheon/vision.ts +1160 -115
  112. package/src/plugin-v2.ts +654 -162
  113. package/src/plugin.ts +15 -11
  114. package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
  115. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  116. package/src/plugins/tui/dist/tui-v2.js +3742 -85
  117. package/src/plugins/tui/dist/tui.js +1 -1
  118. package/src/plugins/tui/package-lock.json +6 -6
  119. package/src/plugins/tui/package.json +5 -4
  120. package/src/plugins/tui/src/index-v2.tsx +4314 -50
  121. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  122. package/src/routing.yml +50 -5
  123. package/src/skills/agent-coordination/SKILL.md +7 -2
  124. package/src/skills/artifact-management/SKILL.md +5 -1
  125. package/src/skills/auto-continue/SKILL.md +14 -6
  126. package/src/skills/codemap/SKILL.md +1 -1
  127. package/src/skills/memory-bank/SKILL.md +21 -13
  128. package/src/skills/session-goal/SKILL.md +12 -22
  129. package/src/skills/spec-driven-development/SKILL.md +3 -1
  130. package/src/skills/worktrees/SKILL.md +30 -11
  131. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -4,8 +4,61 @@
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'
19
+
20
+ /**
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
+ }
9
62
 
10
63
  /**
11
64
  * Copy a plugin's runtime payload (the root TUI loader, bundled dist/*,
@@ -17,18 +70,50 @@ import { ROOT, writeIfChanged } from './shared.mjs'
17
70
  * @param {object} [options]
18
71
  * @param {boolean} [options.dryRun=false] - If true, don't write files
19
72
  * @param {'v1'|'v2'} [options.version='v1'] - Host plugin generation
20
- * @returns {{ created: number, skipped: number }}
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[] }}
21
77
  */
22
- export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1' } = {}) {
23
- 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
+ }
24
103
 
25
- if (!dryRun) mkdirSync(dstDir, { recursive: true })
26
- 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
+ }
27
113
 
28
114
  // Drop legacy raw copies from previous installs (root index.tsx + dist/tui.tsx).
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, version = 'v1'
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
  }
@@ -53,6 +140,7 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
53
140
  join(dstDir, 'package.json'),
54
141
  `${JSON.stringify(packageJson, null, 2)}\n`,
55
142
  dryRun,
143
+ { recorder },
56
144
  )
57
145
  if (pkgStatus === 'created') result.created++
58
146
  else result.skipped++
@@ -60,11 +148,17 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
60
148
 
61
149
  // Each host generation receives its own root loader and compiled bundle.
62
150
  const tuiEntrySrc = join(srcDir, version === 'v2' ? 'tui-v2.ts' : 'tui.ts')
63
- if (existsSync(tuiEntrySrc)) {
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) {
64
157
  const entryStatus = writeIfChanged(
65
158
  join(dstDir, 'tui.ts'),
66
159
  readFileSync(tuiEntrySrc, 'utf8'),
67
160
  dryRun,
161
+ { recorder },
68
162
  )
69
163
  if (entryStatus === 'created') result.created++
70
164
  else result.skipped++
@@ -77,11 +171,17 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
77
171
  v2ServerDestination,
78
172
  readFileSync(v2ServerEntry, 'utf8'),
79
173
  dryRun,
174
+ { recorder },
80
175
  )
81
176
  if (entryStatus === 'created') result.created++
82
177
  else result.skipped++
83
- } else if (!dryRun) {
84
- rmSync(v2ServerDestination, { force: true })
178
+ } else {
179
+ removeLegacyFile(v2ServerDestination, dstDir, {
180
+ dryRun,
181
+ recorder,
182
+ reviewedRemovals,
183
+ reviewedSnapshots,
184
+ })
85
185
  }
86
186
 
87
187
  // Copy the lockfile so dependency installation is reproducible. A missing
@@ -92,6 +192,7 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
92
192
  join(dstDir, 'package-lock.json'),
93
193
  readFileSync(lockSrc, 'utf8'),
94
194
  dryRun,
195
+ { recorder },
95
196
  )
96
197
  if (lockStatus === 'created') result.created++
97
198
  else result.skipped++
@@ -100,6 +201,45 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
100
201
  return result
101
202
  }
102
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
+
103
243
  /**
104
244
  * Install a plugin from source to destination.
105
245
  * @param {string} srcDir - Source plugin directory (e.g. ROOT/src/plugins/tui)
@@ -107,27 +247,70 @@ export function copyPluginFiles(srcDir, dstDir, { dryRun = false, version = 'v1'
107
247
  * @param {object} [options]
108
248
  * @param {boolean} [options.dryRun=false] - If true, don't write files
109
249
  * @param {boolean} [options.clean=false] - If true, remove existing before install
110
- * @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[] }}
111
252
  */
112
253
  export function installPlugin(
113
254
  srcDir,
114
255
  dstDir,
115
- { dryRun = false, clean = false, version = 'v1' } = {},
256
+ {
257
+ dryRun = false,
258
+ clean = false,
259
+ version = 'v1',
260
+ recorder = null,
261
+ reviewedRemovals = null,
262
+ reviewedSnapshots = null,
263
+ } = {},
116
264
  ) {
117
- const result = { created: 0, skipped: 0, errors: 0 }
265
+ const result = { created: 0, skipped: 0, errors: 0, problems: [] }
266
+ const cleanTargetExisted = clean && existsSync(dstDir)
118
267
 
119
- if (clean && existsSync(dstDir) && !dryRun) {
120
- 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
+ }
121
276
  }
122
277
 
123
- const copyResult = copyPluginFiles(srcDir, dstDir, { dryRun, version })
278
+ const copyResult = copyPluginFiles(srcDir, dstDir, {
279
+ dryRun,
280
+ version,
281
+ recorder,
282
+ reviewedRemovals,
283
+ reviewedSnapshots,
284
+ })
124
285
  result.created += copyResult.created
125
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
+ }
126
301
 
127
302
  // Install plugin dependencies (@opentui/core, @opentui/solid, solid-js).
128
- // Lockfile installation is the only accepted dependency path.
129
- if (!dryRun) {
130
- 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)
131
314
  }
132
315
 
133
316
  return result
@@ -141,7 +324,7 @@ export function installPlugin(
141
324
  */
142
325
  export function installPluginDependencies(pluginDir, { dryRun = false } = {}) {
143
326
  if (dryRun) return
144
- execSync('npm ci --omit=dev --no-audit --no-fund', { cwd: pluginDir, stdio: 'pipe' })
327
+ runNpmCi(pluginDir)
145
328
  }
146
329
 
147
330
  /**
@@ -150,9 +333,10 @@ export function installPluginDependencies(pluginDir, { dryRun = false } = {}) {
150
333
  * @param {string} pluginId - Plugin identifier string
151
334
  * @param {object} [options]
152
335
  * @param {boolean} [options.dryRun=false]
336
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
153
337
  * @returns {'created'|'skipped'}
154
338
  */
155
- export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false } = {}) {
339
+ export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false, recorder = null } = {}) {
156
340
  let tuiConfig = { plugin: [] }
157
341
  if (existsSync(tuiJsonPath)) {
158
342
  try {
@@ -168,7 +352,7 @@ export function registerPlugin(tuiJsonPath, pluginId, { dryRun = false } = {}) {
168
352
  tuiConfig.plugin.push(pluginId)
169
353
  }
170
354
  const tuiContent = `${JSON.stringify(tuiConfig, null, 2)}\n`
171
- return writeIfChanged(tuiJsonPath, tuiContent, dryRun)
355
+ return writeIfChanged(tuiJsonPath, tuiContent, dryRun, { recorder })
172
356
  }
173
357
 
174
358
  /**
@@ -256,12 +440,14 @@ export function staleTuiRefs(pluginArray, knownPantheonPaths = []) {
256
440
  * @param {string} pluginId - Plugin to unregister
257
441
  * @param {object} [options]
258
442
  * @param {boolean} [options.dryRun=false]
443
+ * @param {string[]} [options.knownPantheonPaths=[]]
444
+ * @param {(change: object) => void} [options.recorder] - optional change recorder for preview
259
445
  * @returns {'created'|'skipped'}
260
446
  */
261
447
  export function unregisterPlugin(
262
448
  tuiJsonPath,
263
449
  pluginId,
264
- { dryRun = false, knownPantheonPaths = [] } = {},
450
+ { dryRun = false, knownPantheonPaths = [], recorder = null } = {},
265
451
  ) {
266
452
  if (!existsSync(tuiJsonPath)) {
267
453
  // Nothing to clean — and never create an empty tui.json in a location
@@ -292,5 +478,6 @@ export function unregisterPlugin(
292
478
  return !isPantheonTuiRef(ref, knownPantheonPaths)
293
479
  })
294
480
  const tuiContent = `${JSON.stringify(tuiConfig, null, 2)}\n`
295
- 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 })
296
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')