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
@@ -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