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
@@ -0,0 +1,85 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { join } from 'node:path'
3
+
4
+ export const MIN_SUPPORTED_NODE_VERSION = '26.4.0'
5
+ export const REQUIRED_NODE_ENGINE_RANGE = `>=${MIN_SUPPORTED_NODE_VERSION}`
6
+
7
+ /** Return actionable, user-managed upgrade guidance for an unsupported runtime. */
8
+ export function unsupportedNodeVersionMessage(version) {
9
+ return [
10
+ `❌ Pantheon requires Node.js >= ${MIN_SUPPORTED_NODE_VERSION} (current: ${version})`,
11
+ ' Install and switch with a user-managed Node version manager:',
12
+ ` nvm install ${MIN_SUPPORTED_NODE_VERSION} && nvm use ${MIN_SUPPORTED_NODE_VERSION}`,
13
+ ` fnm install ${MIN_SUPPORTED_NODE_VERSION} && fnm use ${MIN_SUPPORTED_NODE_VERSION}`,
14
+ ` volta install node@${MIN_SUPPORTED_NODE_VERSION}`,
15
+ ].join('\n')
16
+ }
17
+
18
+ function parseNodeVersion(version) {
19
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+([\w.-]+))?$/.exec(String(version))
20
+ if (!match) return null
21
+ return { parts: match.slice(1, 4).map(Number), prerelease: match[4] !== undefined }
22
+ }
23
+
24
+ /** Return whether a runtime version meets Pantheon's supported Node floor. */
25
+ export function isSupportedNodeVersion(version) {
26
+ const parsed = parseNodeVersion(version)
27
+ const minimum = parseNodeVersion(MIN_SUPPORTED_NODE_VERSION)
28
+ if (!parsed || !minimum || parsed.prerelease) return false
29
+ for (let index = 0; index < minimum.parts.length; index += 1) {
30
+ if (parsed.parts[index] !== minimum.parts[index]) {
31
+ return parsed.parts[index] > minimum.parts[index]
32
+ }
33
+ }
34
+ return true
35
+ }
36
+
37
+ function readJson(root, file, errors) {
38
+ try {
39
+ const document = JSON.parse(readFileSync(join(root, file), 'utf8'))
40
+ if (!document || typeof document !== 'object' || Array.isArray(document)) {
41
+ throw new Error('expected a JSON object')
42
+ }
43
+ return document
44
+ } catch (error) {
45
+ errors.push(`${file}: ${error.message}`)
46
+ return null
47
+ }
48
+ }
49
+
50
+ function checkEngineRange(value, label, errors) {
51
+ if (value !== REQUIRED_NODE_ENGINE_RANGE) {
52
+ errors.push(`${label} must declare engines.node as "${REQUIRED_NODE_ENGINE_RANGE}"`)
53
+ }
54
+ }
55
+
56
+ /** Validate Node support claims in package manifests and their npm locks. */
57
+ export function validateNodeEnginePolicy(root) {
58
+ const errors = []
59
+ const rootPackage = readJson(root, 'package.json', errors)
60
+ const tuiPackage = readJson(root, 'src/plugins/tui/package.json', errors)
61
+ const rootLock = readJson(root, 'package-lock.json', errors)
62
+ const tuiLock = readJson(root, 'src/plugins/tui/package-lock.json', errors)
63
+
64
+ if (rootPackage) checkEngineRange(rootPackage.engines?.node, 'package.json', errors)
65
+ if (tuiPackage) checkEngineRange(tuiPackage.engines?.node, 'src/plugins/tui/package.json', errors)
66
+
67
+ const rootLockPackage = rootLock?.packages?.['']
68
+ if (!rootLockPackage) errors.push('package-lock.json is missing packages[""]')
69
+ else checkEngineRange(rootLockPackage.engines?.node, 'package-lock.json packages[""]', errors)
70
+
71
+ const workspacePackage = rootLock?.packages?.['src/plugins/tui']
72
+ if (!workspacePackage) errors.push('package-lock.json is missing the TUI workspace package')
73
+ else checkEngineRange(workspacePackage.engines?.node, 'package-lock.json TUI workspace', errors)
74
+
75
+ const tuiLockPackage = tuiLock?.packages?.['']
76
+ if (!tuiLockPackage) errors.push('src/plugins/tui/package-lock.json is missing packages[""]')
77
+ else
78
+ checkEngineRange(
79
+ tuiLockPackage.engines?.node,
80
+ 'src/plugins/tui/package-lock.json packages[""]',
81
+ errors,
82
+ )
83
+
84
+ return errors
85
+ }
@@ -17,6 +17,7 @@ import {
17
17
  import { tmpdir } from 'node:os'
18
18
  import { isAbsolute, join } from 'node:path'
19
19
  import { validateInventory } from './manifest-inventory.mjs'
20
+ import { validateNodeEnginePolicy } from './node-engine-policy.mjs'
20
21
 
21
22
  const CI_ARGS = ['ci', '--ignore-scripts', '--omit=dev', '--no-audit', '--no-fund']
22
23
  const REQUIRED_PAYLOAD = [
@@ -32,6 +33,8 @@ const REQUIRED_PAYLOAD = [
32
33
  'package/src/plugins/tui/dist/server.js',
33
34
  'package/bin/pantheon-init.mjs',
34
35
  'package/scripts/doctor.mjs',
36
+ 'package/scripts/node-engine-policy.mjs',
37
+ 'package/scripts/validate-node-engine-policy.mjs',
35
38
  'package/.pantheon/code-mode/compress-inline.py',
36
39
  ]
37
40
 
@@ -67,13 +70,15 @@ function packOnce(root, outputDir) {
67
70
  } catch (error) {
68
71
  fail(`npm pack returned malformed JSON: ${error.message}`)
69
72
  }
70
- if (!Array.isArray(result) || result.length !== 1 || typeof result[0]?.filename !== 'string') {
73
+ // npm <=11 emits an array; npm 12 emits an object keyed by package name.
74
+ const entries = Array.isArray(result) ? result : Object.values(result ?? {})
75
+ if (entries.length !== 1 || typeof entries[0]?.filename !== 'string') {
71
76
  fail('npm pack must produce exactly one JSON result')
72
77
  }
73
78
  const tgzFiles = readdirSync(outputDir).filter((name) => name.endsWith('.tgz'))
74
79
  if (tgzFiles.length !== 1)
75
80
  fail(`package evidence requires exactly one .tgz, found ${tgzFiles.length}`)
76
- if (tgzFiles[0] !== result[0].filename)
81
+ if (tgzFiles[0] !== entries[0].filename)
77
82
  fail('npm pack result does not identify the sole .tgz artifact')
78
83
  return join(outputDir, tgzFiles[0])
79
84
  }
@@ -132,6 +137,7 @@ function validatePayload(packageRoot, inventory) {
132
137
  }
133
138
  for (const document of inventory.documents) {
134
139
  const { entry, path: sourcePath } = document
140
+ if (entry.role === 'metadata') continue
135
141
  const packagedPath = join(packageRoot, entry.file)
136
142
  if (entry.role === 'lock' && entry.file === 'package-lock.json' && !existsSync(packagedPath)) {
137
143
  // npm-packlist excludes the package root lockfile by policy. It remains
@@ -181,6 +187,8 @@ function sha256(path) {
181
187
 
182
188
  export function createPackageEvidence(root, { outputDir, targetSha } = {}) {
183
189
  const inventory = validateInventory(root)
190
+ const engineErrors = validateNodeEnginePolicy(root)
191
+ if (engineErrors.length) fail(engineErrors.join('; '))
184
192
  const sha = resolveTargetSha(root, targetSha)
185
193
  const output = createOutputDirectory(outputDir)
186
194
  let workDir
@@ -5,37 +5,37 @@
5
5
  * Runs after `npm install` completes. Validates environment and prints
6
6
  * setup instructions. Does NOT install Pantheon platform components.
7
7
  */
8
- const REQUIRED_NODE_MAJOR = 18
9
- const nodeMajor = parseInt(process.versions.node.split('.')[0], 10)
8
+ import { isSupportedNodeVersion, unsupportedNodeVersionMessage } from './node-engine-policy.mjs'
10
9
 
11
10
  try {
12
- // Validate Node.js version
13
- if (nodeMajor < REQUIRED_NODE_MAJOR) {
14
- console.error(
15
- `❌ Node.js >= ${REQUIRED_NODE_MAJOR} required (current: ${process.versions.node})`,
11
+ // npm may warn about `engines.node`, but must still finish installing so the
12
+ // bin can print the actionable hard-gate message. No Node-dependent setup is
13
+ // attempted from an incompatible lifecycle runtime.
14
+ if (!isSupportedNodeVersion(process.versions.node)) {
15
+ console.warn(
16
+ `⚠️ Pantheon postinstall skipped because this runtime is unsupported.\n${unsupportedNodeVersionMessage(process.versions.node)}\n Switch to Node.js >= 26.4.0 before running Pantheon setup.`,
16
17
  )
17
- process.exit(1)
18
- }
18
+ } else {
19
+ // Validate js-yaml is available
20
+ try {
21
+ await import('js-yaml')
22
+ } catch {
23
+ console.warn('⚠️ js-yaml not found — run `npm install` to install dependencies')
24
+ }
19
25
 
20
- // Validate js-yaml is available
21
- try {
22
- await import('js-yaml')
23
- } catch {
24
- console.warn('⚠️ js-yaml not found — run `npm install` to install dependencies')
26
+ console.log('')
27
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
28
+ console.log(' Pantheon OpenCode — npm dependencies installed ✅')
29
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
30
+ console.log('')
31
+ console.log(' Next steps:')
32
+ console.log(' 1. Configure Pantheon:')
33
+ console.log(' npm run setup')
34
+ console.log(' # or: npx pantheon-opencode init')
35
+ console.log(' 2. Verify installation:')
36
+ console.log(' npm run doctor')
37
+ console.log('')
25
38
  }
26
-
27
- console.log('')
28
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
29
- console.log(' Pantheon OpenCode — npm dependencies installed ✅')
30
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
31
- console.log('')
32
- console.log(' Next steps:')
33
- console.log(' 1. Configure Pantheon:')
34
- console.log(' npm run setup')
35
- console.log(' # or: npx pantheon-opencode init')
36
- console.log(' 2. Verify installation:')
37
- console.log(' npm run doctor')
38
- console.log('')
39
39
  } catch (err) {
40
40
  console.error(`❌ Post-install check failed: ${err.message}`)
41
41
  process.exit(1)
@@ -8,7 +8,7 @@
8
8
  * temporary synthetic opencode database. A missing fixture runtime is also
9
9
  * AMBIENTAL rather than a false PASS.
10
10
  */
11
- import { existsSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs'
11
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
12
12
  import { tmpdir } from 'node:os'
13
13
  import { join } from 'node:path'
14
14
 
@@ -70,6 +70,43 @@ function setEnvironment(values) {
70
70
  * is exactly how the stale V1 predicate in the CLI mirror stayed green — the
71
71
  * synthetic database agreed with the bug instead of contradicting it.
72
72
  */
73
+ /** USD per 1M tokens, chosen so a 10-token row costs exactly $1.00. */
74
+ const PRICE_PER_MTOK = 100_000
75
+
76
+ /** Priced by the synthetic catalog below. */
77
+ const PRICED_MODEL = { id: 'probe-model', providerID: 'probe' }
78
+
79
+ /** In no catalog at all, so its row must read — and never $0.00. */
80
+ const UNPRICED_MODEL = { id: 'ghost-model', providerID: 'ghost' }
81
+
82
+ /**
83
+ * Translate a fixture descriptor into the payload the selected family stores.
84
+ *
85
+ * V1 keeps the model at the TOP LEVEL (`modelID`/`providerID`) and marks the
86
+ * assistant turn inside `data.role`; V2 nests the model in `model` and marks the
87
+ * turn with the `type` COLUMN. Writing one family's shape under the other
88
+ * family's name is how a fixture starts agreeing with the reader instead of with
89
+ * the host, so the translation lives in one place.
90
+ */
91
+ function toLedgerPayload(row, version) {
92
+ const payload = { ...row }
93
+ const model = payload.model
94
+ delete payload.model
95
+ if (model !== undefined) {
96
+ if (version === 'v2') {
97
+ payload.model = model
98
+ } else {
99
+ payload.modelID = model.id
100
+ payload.providerID = model.providerID
101
+ }
102
+ }
103
+ if (version === 'v2') {
104
+ delete payload.role
105
+ delete payload.phase
106
+ }
107
+ return payload
108
+ }
109
+
73
110
  function createSyntheticDb(DatabaseSync, path, rows) {
74
111
  const db = new DatabaseSync(path)
75
112
  if (requestedVersion === 'v2') {
@@ -80,9 +117,6 @@ function createSyntheticDb(DatabaseSync, path, rows) {
80
117
  'INSERT INTO session_message (id, session_id, type, seq, time_created, time_updated, data) VALUES (?,?,?,?,?,?,?)',
81
118
  )
82
119
  rows.forEach((row, index) => {
83
- const payload = { ...row }
84
- delete payload.role
85
- delete payload.phase
86
120
  insert.run(
87
121
  `msg_${index + 1}`,
88
122
  'ses_probe',
@@ -90,13 +124,13 @@ function createSyntheticDb(DatabaseSync, path, rows) {
90
124
  index + 1,
91
125
  Date.now(),
92
126
  Date.now(),
93
- JSON.stringify(payload),
127
+ JSON.stringify(toLedgerPayload(row, 'v2')),
94
128
  )
95
129
  })
96
130
  } else {
97
131
  db.exec('CREATE TABLE message (data TEXT NOT NULL, time_created INTEGER NOT NULL)')
98
132
  const insert = db.prepare('INSERT INTO message (data, time_created) VALUES (?, ?)')
99
- for (const data of rows) insert.run(JSON.stringify(data), Date.now())
133
+ for (const row of rows) insert.run(JSON.stringify(toLedgerPayload(row, 'v1')), Date.now())
100
134
  }
101
135
  db.close()
102
136
  }
@@ -111,22 +145,41 @@ function requireOutput(output, fragment, label) {
111
145
  if (!output.includes(fragment)) throw new Error(`${label}: missing ${fragment}`)
112
146
  }
113
147
 
114
- function assertTokensOnly(output, expectedRows, total) {
115
- requireOutput(output, 'Tokens In | Tokens Out | Tokens Total', 'tokens-only header')
148
+ /**
149
+ * The money side of the report, asserted rather than trusted.
150
+ *
151
+ * Every assertion here is a way the cost feature can silently disappear: the
152
+ * column is dropped from the header, a row loses its cost cell, the two
153
+ * additive sections go away, the unpriced row is priced at zero, or the total
154
+ * stops saying it is partial. The unit suites cover the arithmetic; this probe
155
+ * covers the SHIPPED output shape of the installed package.
156
+ */
157
+ function assertCostReport(output, expectedRows, total, expectedTotalCell) {
158
+ requireOutput(
159
+ output,
160
+ 'Tokens In | Tokens Out | Tokens Total | Cost (USD) |',
161
+ 'cost column in the by-agent header',
162
+ )
116
163
  for (const row of expectedRows) {
117
164
  requireOutput(
118
165
  output,
119
- `| ${row.agent} | ${row.phase} | ${row.input} | ${row.output} | ${row.total} |`,
120
- 'token row',
166
+ `| ${row.agent} | ${row.phase} | ${row.input} | ${row.output} | ${row.total} | ${row.cost} |`,
167
+ 'row with its cost cell',
121
168
  )
122
169
  }
123
170
  requireOutput(
124
171
  output,
125
- `| **Total** | — | **${total.input}** | **${total.output}** | **${total.total}** |`,
126
- 'token total',
172
+ `| **Total** | — | **${total.input}** | **${total.output}** | **${total.total}** | ${expectedTotalCell} |`,
173
+ 'total with its cost cell',
127
174
  )
128
- if (/Cost \(USD\)|costUsd|\$\d|\bUSD\b/i.test(output)) {
129
- throw new Error('tokens-only output contains a monetary value')
175
+ requireOutput(output, '## Cost by model', 'by-model section')
176
+ requireOutput(output, '## Cost by session', 'by-session section')
177
+ requireOutput(output, 'Pricing:', 'pricing provenance')
178
+ if (output.includes('999.99')) {
179
+ throw new Error('the payload `cost` field was published as if it were a price')
180
+ }
181
+ if (output.includes('$0.00') && expectedRows.some((row) => row.cost === '—')) {
182
+ throw new Error('an unpriced row was reported as free')
130
183
  }
131
184
  }
132
185
 
@@ -175,9 +228,35 @@ async function main() {
175
228
  const explicitDb = join(root, 'explicit.db')
176
229
  const incompatibleDb = join(root, 'incompatible.db')
177
230
  const checks = []
231
+ // Pricing is pinned into the temp root: the probe asserts the report's money
232
+ // semantics, not whether models.dev is reachable today or what the developer's
233
+ // real cache happens to contain.
234
+ const configHome = join(root, 'config')
235
+ const priceCache = join(configHome, 'cache', 'models-dev.json')
236
+ // A synthetic cache plus an offline host is the only combination that keeps
237
+ // this probe deterministic: it must never reach the network, and it must not
238
+ // inherit whatever prices the running machine has cached. Set OUTSIDE the try
239
+ // so the finally block can always restore it.
240
+ const previousPricingEnv = {
241
+ PANTHEON_HOME: process.env.PANTHEON_HOME,
242
+ PANTHEON_COST_OFFLINE: process.env.PANTHEON_COST_OFFLINE,
243
+ }
244
+ process.env.PANTHEON_HOME = configHome
245
+ process.env.PANTHEON_COST_OFFLINE = '1'
178
246
 
179
247
  try {
180
248
  mkdirSync(opencodeDir, { recursive: true })
249
+ mkdirSync(join(configHome, 'cache'), { recursive: true })
250
+ writeFileSync(
251
+ priceCache,
252
+ JSON.stringify({
253
+ version: 1,
254
+ fetchedAt: Date.now(),
255
+ providers: {
256
+ probe: { 'probe-model': { inputPerMTok: PRICE_PER_MTOK, outputPerMTok: PRICE_PER_MTOK } },
257
+ },
258
+ }),
259
+ )
181
260
  // These rows intentionally include a monetary-looking field to prove it is
182
261
  // ignored; only input/output/total tokens may appear in the report. Every
183
262
  // V2 phase reads back as `unknown` because the V2 reader emits that literal:
@@ -189,6 +268,7 @@ async function main() {
189
268
  role: 'assistant',
190
269
  agent: 'aphrodite',
191
270
  phase: 'plan',
271
+ model: PRICED_MODEL,
192
272
  cost: 999.99,
193
273
  tokens: { input: 7, output: 8 },
194
274
  },
@@ -196,6 +276,7 @@ async function main() {
196
276
  role: 'assistant',
197
277
  agent: 'aphrodite',
198
278
  phase: 'plan',
279
+ model: PRICED_MODEL,
199
280
  cost: 999.99,
200
281
  tokens: { input: 1, output: 2 },
201
282
  },
@@ -203,6 +284,7 @@ async function main() {
203
284
  role: 'assistant',
204
285
  agent: 'zeus',
205
286
  phase: 'audit',
287
+ model: UNPRICED_MODEL,
206
288
  cost: 999.99,
207
289
  tokens: { input: 4, output: 6 },
208
290
  },
@@ -212,6 +294,7 @@ async function main() {
212
294
  role: 'assistant',
213
295
  agent: 'hermes',
214
296
  phase: 'plan',
297
+ model: PRICED_MODEL,
215
298
  cost: 999.99,
216
299
  tokens: { input: 10, output: 20 },
217
300
  },
@@ -219,6 +302,7 @@ async function main() {
219
302
  role: 'assistant',
220
303
  agent: 'hermes',
221
304
  phase: 'plan',
305
+ model: PRICED_MODEL,
222
306
  cost: 999.99,
223
307
  tokens: { input: 3, output: 4 },
224
308
  },
@@ -226,6 +310,7 @@ async function main() {
226
310
  role: 'assistant',
227
311
  agent: 'athena',
228
312
  phase: 'review',
313
+ model: UNPRICED_MODEL,
229
314
  cost: 999.99,
230
315
  tokens: { input: 2, output: 5 },
231
316
  },
@@ -262,20 +347,30 @@ async function main() {
262
347
  {},
263
348
  { sessionID: 'cost-probe' },
264
349
  )
265
- assertTokensOnly(
350
+ assertCostReport(
266
351
  selectedOutput,
267
352
  requestedVersion === 'v2'
268
353
  ? [
269
- { agent: 'aphrodite', phase: 'unknown', input: 8, output: 10, total: 18 },
270
- { agent: 'zeus', phase: 'unknown', input: 4, output: 6, total: 10 },
354
+ // 18 tokens × $0.10/token: priced from the synthetic catalog.
355
+ {
356
+ agent: 'aphrodite',
357
+ phase: 'unknown',
358
+ input: 8,
359
+ output: 10,
360
+ total: 18,
361
+ cost: '$1.80',
362
+ },
363
+ // In no catalog: — and excluded from the total, never $0.00.
364
+ { agent: 'zeus', phase: 'unknown', input: 4, output: 6, total: 10, cost: '—' },
271
365
  ]
272
366
  : [
273
- { agent: 'hermes', phase: 'plan', input: 13, output: 24, total: 37 },
274
- { agent: 'athena', phase: 'review', input: 2, output: 5, total: 7 },
367
+ { agent: 'hermes', phase: 'plan', input: 13, output: 24, total: 37, cost: '$3.70' },
368
+ { agent: 'athena', phase: 'review', input: 2, output: 5, total: 7, cost: '—' },
275
369
  ],
276
370
  requestedVersion === 'v2'
277
371
  ? { input: 12, output: 16, total: 28 }
278
372
  : { input: 15, output: 29, total: 44 },
373
+ requestedVersion === 'v2' ? '**$1.80** (partial)' : '**$3.70** (partial)',
279
374
  )
280
375
  checks.push('version-selected DB: PASS')
281
376
  } finally {
@@ -362,6 +457,10 @@ async function main() {
362
457
  } catch (error) {
363
458
  emit('FAIL', diagnostic(error), checks)
364
459
  } finally {
460
+ for (const [key, value] of Object.entries(previousPricingEnv)) {
461
+ if (value === undefined) delete process.env[key]
462
+ else process.env[key] = value
463
+ }
365
464
  rmSync(root, { recursive: true, force: true })
366
465
  }
367
466
  }
package/scripts/prune.mjs CHANGED
@@ -9,7 +9,10 @@
9
9
  * SAFETY: prune NEVER touches the active config, the active venv, the package
10
10
  * repo, or the installed package. It only:
11
11
  * - lists old global `pantheon` installs (suggests `npm uninstall -g pantheon`)
12
- * - removes stale `opencode.json.bak*` backups (age > threshold) with --apply
12
+ * - removes stale LEGACY `opencode.json.bak*` backups (age > threshold) with
13
+ * --apply. The modern installer no longer writes that sidecar — it creates an
14
+ * exact backup set under `.pantheon/backups/` (retained by the installer, not
15
+ * pruned here) — so this scan only cleans up pre-phase-2 installs.
13
16
  * - lists legacy directories whose opencode.json references dead/relative
14
17
  * paths (removal requires --apply --remove-dirs as explicit confirmation)
15
18
  *
@@ -102,8 +105,11 @@ export function findLegacyGlobalInstalls() {
102
105
  }
103
106
 
104
107
  // ---------------------------------------------------------------------------
105
- // (b) Stale opencode.json.bak* backups (age > threshold) in the config dir
106
- // → removable with --apply. Fresh backups are listed as kept.
108
+ // (b) Stale LEGACY opencode.json.bak* backups (age > threshold) in the config
109
+ // dir → removable with --apply. Fresh backups are listed as kept. The
110
+ // current installer does not create this sidecar (it keeps an exact,
111
+ // self-retaining backup set under .pantheon/backups/), so this only cleans
112
+ // up installs from before phase 2.
107
113
  // ---------------------------------------------------------------------------
108
114
 
109
115
  export function findStaleBackups(configDir, maxAgeDays = DEFAULT_BACKUP_AGE_DAYS) {