pantheon-opencode 1.6.0-beta.9 → 1.6.1

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 (140) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +144 -365
  4. package/README.md +124 -607
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +504 -141
  7. package/commands/pantheon-deepwork.md +14 -3
  8. package/commands/pantheon-vision.md +61 -12
  9. package/package.json +22 -13
  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 +850 -45
  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 +99 -383
  29. package/scripts/install/interrupt.mjs +78 -0
  30. package/scripts/install/migrate.mjs +49 -25
  31. package/scripts/install/model-picker.mjs +218 -250
  32. package/scripts/install/opencode-state.mjs +91 -0
  33. package/scripts/install/opencode-version.mjs +83 -21
  34. package/scripts/install/opencode.mjs +1675 -187
  35. package/scripts/install/plan-artifact.mjs +517 -0
  36. package/scripts/install/plan.mjs +475 -0
  37. package/scripts/install/plugin.mjs +214 -27
  38. package/scripts/install/prompt-result.mjs +2 -0
  39. package/scripts/install/run-record.mjs +115 -0
  40. package/scripts/install/shared.mjs +256 -99
  41. package/scripts/install/state.mjs +63 -8
  42. package/scripts/install/strings.mjs +93 -8
  43. package/scripts/install/v2-capabilities.mjs +205 -0
  44. package/scripts/install/venv.mjs +90 -47
  45. package/scripts/install/verify.mjs +128 -0
  46. package/scripts/install/vision-prompt.mjs +173 -0
  47. package/scripts/install-mcp.mjs +2 -2
  48. package/scripts/manifest-inventory.mjs +49 -3
  49. package/scripts/mcp_persistence.py +1535 -1050
  50. package/scripts/memory_mcp.py +12 -843
  51. package/scripts/node-engine-policy.mjs +85 -0
  52. package/scripts/package-evidence.mjs +10 -2
  53. package/scripts/postinstall.mjs +26 -26
  54. package/scripts/probe-pantheon-cost.mjs +118 -19
  55. package/scripts/prune.mjs +9 -3
  56. package/scripts/reconcile.mjs +325 -0
  57. package/scripts/release-gates.mjs +687 -0
  58. package/scripts/restore.mjs +222 -0
  59. package/scripts/run-node-tests.mjs +24 -8
  60. package/scripts/sync-artifacts.mjs +19 -7
  61. package/scripts/sync-tui.mjs +5 -1
  62. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  63. package/scripts/uninstall.mjs +369 -34
  64. package/scripts/update.mjs +164 -0
  65. package/scripts/validate-node-engine-policy.mjs +13 -0
  66. package/scripts/version-check.mjs +34 -1
  67. package/scripts/versioning.mjs +23 -3
  68. package/scripts/vision-status.mjs +682 -0
  69. package/skills-lock.json +8 -8
  70. package/src/agents/aphrodite.md +13 -10
  71. package/src/agents/apollo.md +4 -5
  72. package/src/agents/athena.md +74 -46
  73. package/src/agents/demeter.md +10 -7
  74. package/src/agents/gaia.md +0 -1
  75. package/src/agents/hephaestus.md +4 -3
  76. package/src/agents/hermes.md +10 -9
  77. package/src/agents/iris.md +6 -1
  78. package/src/agents/mnemosyne.md +10 -4
  79. package/src/agents/nyx.md +4 -4
  80. package/src/agents/prometheus.md +12 -11
  81. package/src/agents/talos.md +6 -0
  82. package/src/agents/zeus.md +84 -56
  83. package/src/instructions/agent-return-format.instructions.md +12 -41
  84. package/src/instructions/memory-protocol.instructions.md +5 -11
  85. package/src/instructions/test-economy.instructions.md +12 -0
  86. package/src/instructions/yagni.instructions.md +6 -15
  87. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  88. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  89. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  90. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  91. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  92. package/src/mcp/_pantheon_paths.py +24 -0
  93. package/src/mcp/mcp_codemap_module.py +86 -18
  94. package/src/mcp/mcp_persistence.py +1535 -1050
  95. package/src/mcp/memory_mcp.py +444 -94
  96. package/src/mcp/pantheon_vision.py +285 -41
  97. package/src/mcp/requirements-mcp.txt +6 -1
  98. package/src/mcp/requirements-vision.txt +1 -1
  99. package/src/pantheon/context-pruner.ts +541 -0
  100. package/src/pantheon/cost-command.ts +901 -60
  101. package/src/pantheon/delegation-enforce.ts +160 -23
  102. package/src/pantheon/goal-loop.ts +11 -8
  103. package/src/pantheon/guard-path.ts +162 -0
  104. package/src/pantheon/memory-context.ts +1017 -0
  105. package/src/pantheon/model-agents.ts +19 -0
  106. package/src/pantheon/model-command.ts +218 -56
  107. package/src/pantheon/model-pricing.ts +536 -0
  108. package/src/pantheon/presets.mjs +2 -0
  109. package/src/pantheon/task-result-guard.ts +50 -14
  110. package/src/pantheon/v2-bounded-read.ts +654 -0
  111. package/src/pantheon/v2-bridge.ts +27 -0
  112. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  113. package/src/pantheon/v2-execute-after.ts +135 -24
  114. package/src/pantheon/v2-model-overrides.ts +275 -0
  115. package/src/pantheon/v2-shell-hooks.ts +260 -0
  116. package/src/pantheon/v2-tools.ts +89 -35
  117. package/src/pantheon/v2-unsupported.mjs +34 -7
  118. package/src/pantheon/v2-vision.ts +622 -0
  119. package/src/pantheon/vision-local.ts +531 -0
  120. package/src/pantheon/vision.ts +1166 -116
  121. package/src/plugin-v2.ts +1039 -171
  122. package/src/plugin.ts +37 -13
  123. package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
  124. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  125. package/src/plugins/tui/dist/tui-v2.js +3742 -85
  126. package/src/plugins/tui/dist/tui.js +1 -1
  127. package/src/plugins/tui/package-lock.json +15 -15
  128. package/src/plugins/tui/package.json +7 -5
  129. package/src/plugins/tui/src/index-v2.tsx +4314 -50
  130. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  131. package/src/routing.yml +50 -5
  132. package/src/skills/agent-coordination/SKILL.md +7 -2
  133. package/src/skills/artifact-management/SKILL.md +5 -1
  134. package/src/skills/auto-continue/SKILL.md +14 -6
  135. package/src/skills/codemap/SKILL.md +1 -1
  136. package/src/skills/memory-bank/SKILL.md +21 -13
  137. package/src/skills/session-goal/SKILL.md +12 -22
  138. package/src/skills/spec-driven-development/SKILL.md +3 -1
  139. package/src/skills/worktrees/SKILL.md +30 -11
  140. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -10,10 +10,13 @@
10
10
  */
11
11
 
12
12
  import { spawnSync } from 'node:child_process'
13
- import { existsSync, rmSync } from 'node:fs'
13
+ import { existsSync } from 'node:fs'
14
14
  import { dirname, join } from 'node:path'
15
15
  import { fileURLToPath } from 'node:url'
16
16
 
17
+ import { configure, info, step, success, warning } from './cli-ui.mjs'
18
+ import { ACTIONS, recordChange, recordRemovalTree, removeReviewedTree } from './plan.mjs'
19
+
17
20
  const __dirname = dirname(fileURLToPath(import.meta.url))
18
21
  const ROOT = join(__dirname, '..', '..')
19
22
 
@@ -40,37 +43,61 @@ export function venvPythonPath(target) {
40
43
  * Set up a Python virtual environment and install MCP dependencies.
41
44
  *
42
45
  * @param {string} target - Target installation directory (e.g. ~/.config/opencode)
43
- * @param {{ dryRun?: boolean, skipInstall?: boolean, force?: boolean }} [options]
46
+ * @param {{ dryRun?: boolean, skipInstall?: boolean, force?: boolean, recorder?: (change: object) => void, reviewedRemovals?: Set<string>|null, reviewedSnapshots?: Map<string, object>|null }} [options]
44
47
  * @returns {{ venvPath: string, python: string }}
45
48
  */
46
- export function setupVenv(target, { dryRun = false, skipInstall = false, force = false } = {}) {
49
+ export function setupVenv(
50
+ target,
51
+ {
52
+ dryRun = false,
53
+ skipInstall = false,
54
+ force = false,
55
+ recorder = null,
56
+ reviewedRemovals = null,
57
+ reviewedSnapshots = null,
58
+ } = {},
59
+ ) {
47
60
  const venvPath = join(target, '.venv')
48
61
  const pythonBin = venvPythonPath(target)
49
62
 
50
63
  // Step 1: Force recreate venv if --force
51
64
  if (force && existsSync(venvPath)) {
52
- if (!dryRun) {
53
- console.log(' Removing existing .venv (--force)...')
54
- rmSync(venvPath, { recursive: true })
65
+ if (dryRun) {
66
+ recordRemovalTree(venvPath, recorder)
67
+ info('.venv would be removed (--force)')
68
+ } else {
69
+ const removeStep = step('Removing existing .venv (--force)')
70
+ removeReviewedTree(venvPath, reviewedRemovals, reviewedSnapshots)
71
+ removeStep(true)
72
+ success('.venv removed')
55
73
  }
56
- console.log(' ✅ .venv removed')
57
74
  }
58
75
 
59
76
  // Step 1b: Create venv if not exists
60
- if (!existsSync(pythonBin)) {
61
- if (!dryRun) {
62
- console.log(' Creating .venv...')
77
+ const venvExists = existsSync(pythonBin)
78
+ if (!venvExists) {
79
+ if (dryRun) {
80
+ // Never claim a directory was created by a run that writes nothing.
81
+ info('.venv would be created')
82
+ } else {
83
+ const createStep = step('Creating .venv')
63
84
  const result = spawnSync('python3', ['-m', 'venv', venvPath], {
64
85
  stdio: 'inherit',
65
86
  timeout: 30_000,
66
87
  })
67
88
  if (result.status !== 0) {
89
+ createStep(false)
68
90
  throw new Error('Failed to create virtual environment')
69
91
  }
92
+ createStep(true)
93
+ success('.venv created')
70
94
  }
71
- console.log(' ✅ .venv created')
95
+ // A single synthetic entry for the venv directory — never enumerate its
96
+ // thousands of files. Unscored: the install summary does not count it.
97
+ recordChange({ path: venvPath, action: ACTIONS.CREATE, bytes: 0, scored: false }, recorder)
72
98
  } else {
73
- console.log(' ⏭️ .venv already exists')
99
+ info('.venv already exists')
100
+ recordChange({ path: venvPath, action: ACTIONS.UNCHANGED, bytes: 0, scored: false }, recorder)
74
101
  }
75
102
 
76
103
  // Step 2: Install MCP dependencies
@@ -82,49 +109,64 @@ export function setupVenv(target, { dryRun = false, skipInstall = false, force =
82
109
  throw new Error(`Requirements file not found: ${reqFile}`)
83
110
  }
84
111
 
85
- console.log(' Installing MCP dependencies...')
86
-
87
112
  if (!dryRun) {
88
- // Upgrade pip first (avoids resolver warnings)
89
- // Ensure PIP_USER=0 to install into venv, not user site-packages
90
- const pipEnv = { ...process.env, PIP_USER: '0' }
91
-
92
- spawnSync(pip, ['install', '--upgrade', 'pip'], {
93
- stdio: 'ignore',
94
- timeout: 30_000,
95
- env: pipEnv,
96
- })
97
-
98
- // Install requirements — attempt 1: normal
99
- const r = spawnSync(pip, ['install', '-r', reqFile], {
100
- stdio: 'inherit',
101
- timeout: 120_000,
102
- env: pipEnv,
103
- })
113
+ const depsStep = step('Installing MCP dependencies')
114
+ try {
115
+ // Upgrade pip first (avoids resolver warnings)
116
+ // Ensure PIP_USER=0 to install into venv, not user site-packages
117
+ const pipEnv = { ...process.env, PIP_USER: '0' }
118
+
119
+ // stdio is 'ignore' (pip is noisy here), so the step marker is the ONLY
120
+ // evidence this ran — report both start and outcome instead of a silent
121
+ // 30s pause.
122
+ const pipUpgradeStep = step('Upgrading pip')
123
+ const pipUpgrade = spawnSync(pip, ['install', '--upgrade', 'pip'], {
124
+ stdio: 'ignore',
125
+ timeout: 30_000,
126
+ env: pipEnv,
127
+ })
128
+ const upgraded = pipUpgrade.status === 0
129
+ pipUpgradeStep(upgraded)
130
+ if (!upgraded) warning('pip upgrade failed — continuing with the bundled version')
104
131
 
105
- if (r.status !== 0) {
106
- // Attempt 2: --break-system-packages (PEP 668 / externally-managed)
107
- console.log(' ⚠️ First attempt failed, retrying with --break-system-packages...')
108
- const r2 = spawnSync(pip, ['install', '-r', reqFile, '--break-system-packages'], {
132
+ // Install requirements — attempt 1: normal
133
+ const r = spawnSync(pip, ['install', '-r', reqFile], {
109
134
  stdio: 'inherit',
110
135
  timeout: 120_000,
111
136
  env: pipEnv,
112
137
  })
113
- if (r2.status !== 0) {
114
- throw new Error(
115
- 'Failed to install MCP dependencies. ' +
116
- 'Try: PIP_USER=0 ' +
117
- pip +
118
- ' install -r ' +
119
- reqFile +
120
- ' --break-system-packages',
121
- )
138
+
139
+ if (r.status !== 0) {
140
+ // Attempt 2: --break-system-packages (PEP 668 / externally-managed)
141
+ warning('First attempt failed, retrying with --break-system-packages...')
142
+ const r2 = spawnSync(pip, ['install', '-r', reqFile, '--break-system-packages'], {
143
+ stdio: 'inherit',
144
+ timeout: 120_000,
145
+ env: pipEnv,
146
+ })
147
+ if (r2.status !== 0) {
148
+ throw new Error(
149
+ 'Failed to install MCP dependencies. ' +
150
+ 'Try: PIP_USER=0 ' +
151
+ pip +
152
+ ' install -r ' +
153
+ reqFile +
154
+ ' --break-system-packages',
155
+ )
156
+ }
122
157
  }
158
+ depsStep(true)
159
+ success('MCP dependencies installed')
160
+ } catch (err) {
161
+ depsStep(false)
162
+ throw err
123
163
  }
164
+ } else {
165
+ // A dry run installs nothing: say so rather than reporting success.
166
+ info('MCP dependencies would be installed')
124
167
  }
125
- console.log(' ✅ MCP dependencies installed')
126
168
  } else {
127
- console.log(' ⏭️ Dependency install skipped (--skip-install)')
169
+ info('Dependency install skipped (--skip-install)')
128
170
  }
129
171
 
130
172
  return { venvPath, python: pythonBin }
@@ -140,12 +182,13 @@ function main() {
140
182
  const dryRun = args.includes('--dry-run')
141
183
  const skipInstall = args.includes('--skip-install')
142
184
  const force = args.includes('--force')
185
+ configure({ dryRun })
143
186
 
144
187
  try {
145
188
  const result = setupVenv(target, { dryRun, skipInstall, force })
146
- console.log(` 📍 Python: ${result.python}`)
189
+ info(`Python: ${result.python}`)
147
190
  } catch (err) {
148
- console.error(`\n ❌ ${err.message}`)
191
+ console.error(`\n [ERROR] ${err.message}`)
149
192
  process.exit(1)
150
193
  }
151
194
  }
@@ -0,0 +1,128 @@
1
+ import {
2
+ closeSync,
3
+ fsyncSync,
4
+ lstatSync,
5
+ openSync,
6
+ readFileSync,
7
+ renameSync,
8
+ unlinkSync,
9
+ writeFileSync,
10
+ } from 'node:fs'
11
+ import { isAbsolute, parse, relative, resolve, sep } from 'node:path'
12
+
13
+ /** Reject symlinked path components before a managed filesystem operation. */
14
+ export function assertNoSymlinkAncestors(filePath, { includeLeaf = true } = {}) {
15
+ const absolute = resolve(filePath)
16
+ const root = parse(absolute).root
17
+ const parts = absolute.slice(root.length).split(sep).filter(Boolean)
18
+ const checked = parts.slice(0, includeLeaf ? parts.length : Math.max(0, parts.length - 1))
19
+ let current = root
20
+ for (const [index, part] of checked.entries()) {
21
+ current = current ? `${current}${current.endsWith(sep) ? '' : sep}${part}` : part
22
+ let info
23
+ try {
24
+ info = lstatSync(current)
25
+ } catch (error) {
26
+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return true
27
+ throw error
28
+ }
29
+ if (info.isSymbolicLink()) throw new Error(`Path contains a symlink: ${current}`)
30
+ if (index < checked.length - 1 && !info.isDirectory()) {
31
+ throw new Error(`Path ancestor is not a directory: ${current}`)
32
+ }
33
+ }
34
+ return true
35
+ }
36
+
37
+ /** Require a destination to remain lexically inside its selected target. */
38
+ export function assertPathWithin(rootPath, destinationPath) {
39
+ const root = resolve(rootPath)
40
+ const destination = resolve(destinationPath)
41
+ const fromRoot = relative(root, destination)
42
+ if (fromRoot === '..' || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
43
+ throw new Error(`Path escapes selected target: ${destinationPath}`)
44
+ }
45
+ return true
46
+ }
47
+
48
+ /** Validate lexical containment and reject links before deleting a path. */
49
+ export function assertSafeRemoval(rootPath, destinationPath) {
50
+ assertPathWithin(rootPath, destinationPath)
51
+ assertNoSymlinkAncestors(destinationPath)
52
+ return true
53
+ }
54
+
55
+ /** Read back a regular-file write without ever including file contents in errors. */
56
+ export function verifyRegularFile(filePath, expected) {
57
+ const info = lstatSync(filePath)
58
+ if (!info.isFile() || info.isSymbolicLink()) {
59
+ throw new Error(`Managed-file write did not produce a regular file: ${filePath}`)
60
+ }
61
+ const actual = readFileSync(filePath)
62
+ const expectedBuffer = Buffer.isBuffer(expected) ? expected : Buffer.from(expected)
63
+ if (!actual.equals(expectedBuffer)) {
64
+ throw new Error(`Managed-file read-back verification failed: ${filePath}`)
65
+ }
66
+ return true
67
+ }
68
+
69
+ /**
70
+ * Atomically write a managed file using a private, exclusively-created temp.
71
+ * Existing destinations are replaced only after path checks and a temp read-back.
72
+ */
73
+ export function writeFileAtomically(filePath, content) {
74
+ const temporary = `${filePath}.tmp-${process.pid}`
75
+ assertNoSymlinkAncestors(filePath)
76
+ assertRegularFileOrMissing(filePath)
77
+ assertNoSymlinkAncestors(temporary)
78
+
79
+ let fd
80
+ let createdTemporary = false
81
+ try {
82
+ fd = openSync(temporary, 'wx', 0o600)
83
+ createdTemporary = true
84
+ writeFileSync(fd, content)
85
+ fsyncSync(fd)
86
+ closeSync(fd)
87
+ fd = undefined
88
+
89
+ verifyRegularFile(temporary, content)
90
+ assertNoSymlinkAncestors(filePath)
91
+ assertRegularFileOrMissing(filePath)
92
+ renameSync(temporary, filePath)
93
+ createdTemporary = false
94
+ verifyRegularFile(filePath, content)
95
+ } finally {
96
+ if (fd !== undefined) closeSync(fd)
97
+ if (createdTemporary) {
98
+ try {
99
+ assertNoSymlinkAncestors(temporary)
100
+ unlinkSync(temporary)
101
+ } catch {
102
+ // Preserve the write error; do not follow or remove an unsafe path.
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ function assertRegularFileOrMissing(filePath) {
109
+ try {
110
+ const info = lstatSync(filePath)
111
+ if (!info.isFile() || info.isSymbolicLink()) {
112
+ throw new Error(`Refusing to replace non-regular file: ${filePath}`)
113
+ }
114
+ } catch (error) {
115
+ if (error?.code !== 'ENOENT') throw error
116
+ }
117
+ }
118
+
119
+ /** Verify a managed path was removed, without following symlinks. */
120
+ export function verifyPathRemoved(filePath) {
121
+ try {
122
+ lstatSync(filePath)
123
+ } catch (error) {
124
+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return true
125
+ throw error
126
+ }
127
+ throw new Error(`Managed-path removal verification failed: ${filePath}`)
128
+ }
@@ -0,0 +1,173 @@
1
+ /**
2
+ * vision-prompt.mjs — optional vision step of `pantheon-opencode init`.
3
+ *
4
+ * After the model-preset wizard, an interactive TTY session is offered a
5
+ * three-way choice for the vision model:
6
+ * 1. automatic discovery (default, Enter) — writes nothing
7
+ * 2. pin a `provider/model` — merges `visionModel` into the
8
+ * GLOBAL vision config (~/.config/opencode/opencode-vision.json)
9
+ * 3. skip — writes nothing
10
+ *
11
+ * Non-interactive runs (no TTY, `--yes`, `--headless`, automated sandboxes)
12
+ * never reach this module: `installOpenCode` only calls it when
13
+ * `interactive && !dryRun && !autoYes`. Automatic discovery therefore stays
14
+ * the default in every non-interactive flow and no run blocks on stdin.
15
+ *
16
+ * The write mirrors the `/pantheon-vision` command: atomic, `.bak` backup,
17
+ * and a MERGE — existing keys are never overwritten.
18
+ */
19
+ import { copyFileSync, existsSync, mkdirSync, readFileSync } from 'node:fs'
20
+ import { homedir } from 'node:os'
21
+ import { dirname, join } from 'node:path'
22
+ import { writeConfigWithBackup } from './shared.mjs'
23
+ import { verifyRegularFile } from './verify.mjs'
24
+
25
+ const CONFIG_FILENAME = 'opencode-vision.json'
26
+ /** `provider/model` — exactly one slash, no surrounding whitespace. */
27
+ const MODEL_PATTERN = /^[^\s/]+\/[^\s/]+$/
28
+ const MAX_PIN_ATTEMPTS = 3
29
+
30
+ /** Global vision config path, honoring `XDG_CONFIG_HOME` (same rule as the plugin). */
31
+ export function globalVisionConfigPath(env = process.env) {
32
+ const home = env.HOME?.trim() || homedir()
33
+ const xdg = env.XDG_CONFIG_HOME?.trim() || join(home, '.config')
34
+ return join(xdg, 'opencode', CONFIG_FILENAME)
35
+ }
36
+
37
+ /** True when `value` looks like a `provider/model` id (one slash, no spaces). */
38
+ export function isValidVisionModel(value) {
39
+ return typeof value === 'string' && MODEL_PATTERN.test(value.trim())
40
+ }
41
+
42
+ /**
43
+ * Merge `visionModel` into a vision config, preserving every other key.
44
+ * Defaults to the GLOBAL config; pass `configPath` to target another file
45
+ * (e.g. the project config `.opencode/opencode-vision.json`). Creates the
46
+ * parent directory when missing; never overwrites existing keys. A corrupted
47
+ * JSON file is left byte-identical (the caller decides what to tell the user)
48
+ * rather than clobbered.
49
+ *
50
+ * A concurrent writer that changes the file between the read and the atomic
51
+ * swap makes `writeConfigWithBackup` return `'conflict'`: the write is aborted,
52
+ * `wrote` is `false`, and the newer content is left untouched.
53
+ *
54
+ * @param {object} [opts]
55
+ * @param {Record<string, string|undefined>} [opts.env]
56
+ * @param {boolean} [opts.dryRun]
57
+ * @param {string} [opts.configPath] - explicit target file (defaults to global)
58
+ * @param {(existing: string|null) => void} [opts.beforeRecheck] - test seam
59
+ * forwarded to `writeConfigWithBackup` to simulate a concurrent writer.
60
+ * @returns {{path: string, wrote: boolean, reason: 'created'|'skipped'|'conflict'|'corrupt'|'dry-run'}}
61
+ */
62
+ export function mergeVisionModel(
63
+ model,
64
+ { env = process.env, dryRun = false, beforeRecheck, configPath: target } = {},
65
+ ) {
66
+ const configPath = target ?? globalVisionConfigPath(env)
67
+ let parsed = {}
68
+ let existingRaw
69
+ if (existsSync(configPath)) {
70
+ existingRaw = readFileSync(configPath, 'utf8')
71
+ try {
72
+ const data = JSON.parse(existingRaw)
73
+ if (data && typeof data === 'object' && !Array.isArray(data)) parsed = data
74
+ } catch {
75
+ return { path: configPath, wrote: false, reason: 'corrupt' }
76
+ }
77
+ }
78
+ if (dryRun) return { path: configPath, wrote: false, reason: 'dry-run' }
79
+ const next = { ...parsed, visionModel: model }
80
+ const content = `${JSON.stringify(next, null, 2)}\n`
81
+ mkdirSync(dirname(configPath), { recursive: true })
82
+ const status = writeConfigWithBackup(configPath, content, false, {
83
+ expectedContent: existingRaw,
84
+ beforeRecheck,
85
+ // This file is GLOBAL and lives outside the config dir, so the target-scoped
86
+ // exact backup set never captures it. Keep its own `<file>.bak` recovery.
87
+ beforeSwap: (existing) => {
88
+ if (existing === null) return
89
+ try {
90
+ copyFileSync(configPath, `${configPath}.bak`)
91
+ verifyRegularFile(`${configPath}.bak`, readFileSync(configPath))
92
+ } catch {
93
+ // Best-effort: a backup failure must not block the write.
94
+ }
95
+ },
96
+ })
97
+ return { path: configPath, wrote: status === 'created', reason: status }
98
+ }
99
+
100
+ /**
101
+ * Ask the interactive vision question. `rl` may be injected (tests / an
102
+ * existing readline interface); otherwise a private one is created and closed.
103
+ * Returns `{action, visionModel?, wrote?, path?}` — never throws on bad input,
104
+ * and never writes for the default/skip paths.
105
+ *
106
+ * @param {{rl?: object, logger?: object, env?: Record<string, string|undefined>, dryRun?: boolean, beforeRecheck?: (existing: string|null) => void}} [opts]
107
+ */
108
+ export async function runVisionPrompt({
109
+ rl,
110
+ logger = console,
111
+ env = process.env,
112
+ dryRun = false,
113
+ beforeRecheck,
114
+ } = {}) {
115
+ let iface = rl
116
+ let closeAfter = false
117
+ if (!iface) {
118
+ const { createInterface } = await import('node:readline/promises')
119
+ iface = createInterface({ input: process.stdin, output: process.stdout })
120
+ closeAfter = true
121
+ }
122
+ try {
123
+ logger.log?.('')
124
+ logger.log?.('Vision — how should images be described?')
125
+ logger.log?.(
126
+ ' 1) Automatic discovery (default) — pick a vision-capable model from the host catalog',
127
+ )
128
+ logger.log?.(' 2) Pin a provider/model (e.g. opencode-go/mimo-v2.5)')
129
+ logger.log?.(' 3) Skip')
130
+ const answer = (await iface.question('Choice [1]: ')).trim().toLowerCase()
131
+
132
+ if (answer === '' || answer === '1' || answer === 'auto' || answer === 'discovery') {
133
+ logger.log?.('Vision: automatic discovery (no config written).')
134
+ return { action: 'auto' }
135
+ }
136
+ if (answer === '3' || answer === 'skip' || answer === 'no') {
137
+ logger.log?.('Vision: skipped (no config written).')
138
+ return { action: 'skip' }
139
+ }
140
+ if (answer === '2' || answer === 'pin') {
141
+ for (let attempt = 0; attempt < MAX_PIN_ATTEMPTS; attempt++) {
142
+ const raw = (await iface.question('provider/model (e.g. opencode-go/mimo-v2.5): ')).trim()
143
+ if (!isValidVisionModel(raw)) {
144
+ logger.warn?.(`Invalid model "${raw}" — expected provider/model (one slash, no spaces).`)
145
+ continue
146
+ }
147
+ const result = mergeVisionModel(raw, { env, dryRun, beforeRecheck })
148
+ if (result.reason === 'corrupt') {
149
+ logger.warn?.(
150
+ `Vision config at ${result.path} is not valid JSON — leaving it untouched; fix it and re-run.`,
151
+ )
152
+ return { action: 'pin', visionModel: raw, wrote: false, path: result.path }
153
+ }
154
+ if (result.reason === 'conflict') {
155
+ logger.warn?.(
156
+ `Vision: not saved — config at ${result.path} was modified concurrently; re-run to retry.`,
157
+ )
158
+ } else {
159
+ logger.log?.(`Vision: pinned ${raw} in ${result.path}.`)
160
+ }
161
+ return { action: 'pin', visionModel: raw, wrote: result.wrote, path: result.path }
162
+ }
163
+ logger.warn?.('Vision: no valid model entered — skipping (no config written).')
164
+ return { action: 'skip' }
165
+ }
166
+ logger.warn?.(
167
+ `Unknown choice "${answer}" — defaulting to automatic discovery (no config written).`,
168
+ )
169
+ return { action: 'auto' }
170
+ } finally {
171
+ if (closeAfter) iface.close()
172
+ }
173
+ }
@@ -238,7 +238,7 @@ export const MCPS = {
238
238
  tier: 1,
239
239
  name: 'Pantheon Memory',
240
240
  description:
241
- 'Pantheon Memory MCP Server — persistent memory with semantic search, recall, knowledge graph, compression, and verification',
241
+ 'Pantheon Memory MCP Server — persistent SQLite memory with FTS5/BM25 keyword search, exact-key recall, and explicit maintenance; no embedding/vector search',
242
242
  platforms: {
243
243
  opencode: {
244
244
  type: 'local',
@@ -259,7 +259,7 @@ export const MCPS = {
259
259
  tier: 1,
260
260
  name: 'Pantheon Persistence',
261
261
  description:
262
- 'Pantheon Persistence MCP Server — key-value store with FTS5 full-text search, TTL-based expiration, and namespace isolation',
262
+ 'Pantheon Persistence MCP Server — operational-state checkpoints via context_save/context_get and four manual session-scoped goal tools',
263
263
  env: [],
264
264
  platforms: {
265
265
  opencode: {
@@ -57,6 +57,18 @@ export const MANIFEST_INVENTORY = Object.freeze([
57
57
  name: 'pantheon-tui',
58
58
  valuePath: ['name'],
59
59
  }),
60
+ Object.freeze({
61
+ id: 'zenodo-release-metadata',
62
+ role: 'metadata',
63
+ file: '.zenodo.json',
64
+ kind: 'json',
65
+ }),
66
+ Object.freeze({
67
+ id: 'citation-release-metadata',
68
+ role: 'metadata',
69
+ file: 'CITATION.cff',
70
+ kind: 'cff',
71
+ }),
60
72
  Object.freeze({
61
73
  id: 'root-lock',
62
74
  role: 'lock',
@@ -76,7 +88,7 @@ export const MANIFEST_INVENTORY = Object.freeze([
76
88
  ])
77
89
 
78
90
  export const VERSION_MANIFEST_INVENTORY = Object.freeze(
79
- MANIFEST_INVENTORY.filter(({ role }) => role === 'manifest'),
91
+ MANIFEST_INVENTORY.filter(({ role }) => role !== 'lock'),
80
92
  )
81
93
 
82
94
  export const LOCK_INVENTORY = Object.freeze(
@@ -99,11 +111,18 @@ function readToml(file, text) {
99
111
  return parsed
100
112
  }
101
113
 
114
+ function readCff(file, text) {
115
+ const match = /^version:\s*([^\s#]+)\s*(?:#.*)?$/m.exec(text)
116
+ if (!match) throw new Error(`${file} is missing top-level version metadata`)
117
+ return { version: match[1] }
118
+ }
119
+
102
120
  function readDocument(root, entry) {
103
121
  const path = join(root, entry.file)
104
122
  if (!existsSync(path)) throw new Error(`manifest inventory file is missing: ${entry.file}`)
105
123
  const text = readFileSync(path, 'utf8')
106
124
  if (entry.kind === 'toml') return { entry, path, text, data: readToml(entry.file, text) }
125
+ if (entry.kind === 'cff') return { entry, path, text, data: readCff(entry.file, text) }
107
126
  let data
108
127
  try {
109
128
  data = JSON.parse(text)
@@ -175,6 +194,24 @@ function validateLock(document, manifestsByFile, allowVersionDivergence) {
175
194
  if (!allowVersionDivergence && rootPackage.version !== manifestVersionValue) {
176
195
  throw new Error(`${entry.file} packages[""] version diverges from ${entry.packageFile}`)
177
196
  }
197
+
198
+ if (entry.file === 'package-lock.json') {
199
+ const tuiManifest = manifestsByFile.get('src/plugins/tui/package.json')
200
+ const tuiWorkspace = data.packages?.['src/plugins/tui']
201
+ if (!tuiManifest) throw new Error('package-lock.json has no TUI workspace manifest partner')
202
+ if (!tuiWorkspace || typeof tuiWorkspace !== 'object' || Array.isArray(tuiWorkspace)) {
203
+ throw new Error('package-lock.json is missing packages["src/plugins/tui"]')
204
+ }
205
+ if (tuiWorkspace.name !== 'pantheon-tui') {
206
+ throw new Error('package-lock.json TUI workspace name must be pantheon-tui')
207
+ }
208
+ assertSemver(tuiWorkspace.version, 'package-lock.json TUI workspace version')
209
+ if (!allowVersionDivergence && tuiWorkspace.version !== manifestVersion(tuiManifest)) {
210
+ throw new Error(
211
+ 'package-lock.json TUI workspace version diverges from src/plugins/tui/package.json',
212
+ )
213
+ }
214
+ }
178
215
  }
179
216
 
180
217
  /** Read and validate every entry before a caller is allowed to write anything. */
@@ -186,7 +223,7 @@ export function validateInventory(root, { allowVersionDivergence = false } = {})
186
223
  .map((document) => [document.entry.file, document]),
187
224
  )
188
225
  const versions = documents
189
- .filter(({ entry }) => entry.role === 'manifest')
226
+ .filter(({ entry }) => entry.role === 'manifest' || entry.role === 'metadata')
190
227
  .map((document) => ({ file: document.entry.file, version: manifestVersion(document) }))
191
228
  documents.filter(({ entry }) => entry.role === 'manifest').forEach(manifestName)
192
229
  const sourceVersion = versions[0].version
@@ -309,8 +346,17 @@ function replaceTomlProjectVersion(text, version, file) {
309
346
 
310
347
  function prepareDocumentVersion(document, version) {
311
348
  const { entry, text } = document
349
+ if (entry.role === 'metadata') {
350
+ const current = manifestVersion(document)
351
+ return text.split(current).join(version)
352
+ }
312
353
  if (entry.kind === 'toml') return replaceTomlProjectVersion(text, version, entry.file)
313
- const paths = entry.role === 'lock' ? [['version'], ['packages', '', 'version']] : [['version']]
354
+ const paths =
355
+ entry.role === 'lock'
356
+ ? entry.file === 'package-lock.json'
357
+ ? [['version'], ['packages', '', 'version'], ['packages', 'src/plugins/tui', 'version']]
358
+ : [['version'], ['packages', '', 'version']]
359
+ : [['version']]
314
360
  return replaceJsonStringValues(text, paths, version, entry.file)
315
361
  }
316
362