pantheon-opencode 1.7.0 → 2.0.0-beta.2

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 (173) hide show
  1. package/AGENTS.global.md +2 -2
  2. package/AGENTS.md +3 -3
  3. package/CHANGELOG.md +85 -59
  4. package/README.md +74 -48
  5. package/README.pt-BR.md +19 -19
  6. package/bin/pantheon-init.mjs +11 -48
  7. package/package.json +9 -13
  8. package/plugin.json +2 -2
  9. package/pyproject.toml +1 -1
  10. package/scripts/build-agents-md.mjs +7 -6
  11. package/scripts/{check-plugin-v2-coverage.mjs → check-plugin-coverage.mjs} +7 -7
  12. package/scripts/{decision-router-v2-budget.mjs → decision-router-budget-gates.mjs} +1 -1
  13. package/scripts/{decision-router-v2-egress.mjs → decision-router-egress.mjs} +1 -1
  14. package/scripts/decision-router.mjs +2 -2
  15. package/scripts/docs-media.mjs +1 -1
  16. package/scripts/doctor.mjs +225 -136
  17. package/scripts/install/behavior-overrides.bundle.mjs +123 -0
  18. package/scripts/install/{v2-capabilities.mjs → capabilities.mjs} +7 -7
  19. package/scripts/install/config-migration.mjs +60 -253
  20. package/scripts/install/file-inventory.mjs +6 -4
  21. package/scripts/install/interactive.mjs +1 -1
  22. package/scripts/install/opencode-state.mjs +13 -12
  23. package/scripts/install/opencode-version.mjs +97 -162
  24. package/scripts/install/opencode.mjs +271 -428
  25. package/scripts/install/plan.mjs +1 -9
  26. package/scripts/install/plugin.mjs +19 -35
  27. package/scripts/install/shared.mjs +40 -1
  28. package/scripts/package-evidence.mjs +1 -4
  29. package/scripts/probe-pantheon-cost.mjs +1 -1
  30. package/scripts/reconcile.mjs +5 -7
  31. package/scripts/release-gates.mjs +22 -61
  32. package/scripts/setup-v2-config.mjs +10 -8
  33. package/scripts/setup.mjs +12 -22
  34. package/scripts/sync-tui.mjs +9 -17
  35. package/scripts/{test-opencode-v2-sandbox.sh → test-opencode-sandbox.sh} +9 -9
  36. package/scripts/update-skills-lock.mjs +24 -12
  37. package/scripts/update.mjs +17 -1
  38. package/scripts/validate-routing.mjs +79 -4
  39. package/scripts/validate-sandbox-install.mjs +3 -3
  40. package/skills-lock.json +25 -8
  41. package/src/agents/zeus.md +1 -0
  42. package/src/pantheon/behavior-overrides.ts +191 -0
  43. package/src/pantheon/{v2-bounded-read.ts → bounded-read.ts} +1 -1
  44. package/src/pantheon/cost-command.ts +1 -1
  45. package/src/pantheon/{v2-decision-contracts.ts → decision-contracts.ts} +3 -3
  46. package/src/pantheon/{v2-decision-points → decision-points}/p1-agent.ts +3 -3
  47. package/src/pantheon/{v2-decision-points → decision-points}/p10-claims.ts +2 -2
  48. package/src/pantheon/{v2-decision-points → decision-points}/p11-catalog.ts +2 -2
  49. package/src/pantheon/{v2-decision-points → decision-points}/p2-skill.ts +3 -3
  50. package/src/pantheon/{v2-decision-points → decision-points}/p3-complexity.ts +6 -6
  51. package/src/pantheon/{v2-decision-points → decision-points}/p4-memory.ts +2 -2
  52. package/src/pantheon/{v2-decision-points → decision-points}/p5-themis-verify.ts +2 -2
  53. package/src/pantheon/{v2-decision-points → decision-points}/p6-council.ts +3 -3
  54. package/src/pantheon/{v2-decision-points → decision-points}/p7-loop.ts +5 -5
  55. package/src/pantheon/{v2-decision-points → decision-points}/p8-guardrail.ts +2 -2
  56. package/src/pantheon/{v2-decision-points → decision-points}/p9-memory-compaction.ts +2 -2
  57. package/src/pantheon/{v2-decision-points.ts → decision-points.ts} +5 -5
  58. package/src/pantheon/{v2-decision-policy.ts → decision-policy.ts} +2 -2
  59. package/src/pantheon/{v2-decision-prompt-surface.ts → decision-prompt-surface.ts} +3 -3
  60. package/src/pantheon/{v2-decision-registry.ts → decision-registry.ts} +10 -13
  61. package/src/pantheon/{v2-decision-resource-ids.ts → decision-resource-ids.ts} +1 -1
  62. package/src/pantheon/{v2-decision-shadow.ts → decision-shadow.ts} +1 -1
  63. package/src/pantheon/{v2-decision-telemetry.ts → decision-telemetry.ts} +1 -1
  64. package/src/pantheon/{v2-execute-after.ts → execute-after.ts} +4 -4
  65. package/src/pantheon/goal-store.ts +7 -0
  66. package/src/pantheon/{v2-hook-engine.ts → hook-engine.ts} +3 -3
  67. package/src/pantheon/jev-decision-tool.ts +3 -3
  68. package/src/pantheon/jev-decisions.ts +12 -6
  69. package/src/pantheon/jev-escalation.ts +6 -6
  70. package/src/pantheon/jev-quality-score.ts +2 -2
  71. package/src/pantheon/jev-rank-verify.ts +2 -2
  72. package/src/pantheon/jev-risk-gate.ts +4 -4
  73. package/src/pantheon/local-decision-agents.ts +1 -1
  74. package/src/pantheon/local-decision-router.ts +1 -1
  75. package/src/pantheon/local-decision-tool.ts +2 -2
  76. package/src/pantheon/local-orchestration.ts +1 -1
  77. package/src/pantheon/model-command.ts +1 -1
  78. package/src/pantheon/{v2-vision.ts → native-vision.ts} +12 -15
  79. package/src/pantheon/pantheon-decision-catalog.ts +12 -0
  80. package/src/pantheon/{v2-shell-hooks.ts → shell-hooks.ts} +4 -4
  81. package/src/pantheon/{v2-tools.ts → tools.ts} +4 -4
  82. package/src/pantheon/{v2-unsupported.d.mts → unsupported.d.mts} +3 -3
  83. package/src/pantheon/{v2-unsupported.mjs → unsupported.mjs} +8 -8
  84. package/src/pantheon/update-notifier.ts +101 -0
  85. package/src/pantheon/vision-local.ts +12 -3
  86. package/src/pantheon/vision.ts +120 -2
  87. package/src/{plugin-v2 → plugin}/index.ts +7 -7
  88. package/src/plugin.ts +2870 -500
  89. package/src/plugins/hook-runner.ts +3 -3
  90. package/src/plugins/tui/dist/server.d.ts +23 -9
  91. package/src/plugins/tui/dist/server.d.ts.map +1 -1
  92. package/src/plugins/tui/dist/server.js +25 -12
  93. package/src/plugins/tui/dist/server.js.map +1 -1
  94. package/src/plugins/tui/dist/tui.d.ts +1023 -494
  95. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  96. package/src/plugins/tui/dist/tui.js +5612 -2086
  97. package/src/plugins/tui/dist/tui.js.map +1 -1
  98. package/src/plugins/tui/{index-v2.ts → index.ts} +1 -1
  99. package/src/plugins/tui/package-lock.json +2 -42
  100. package/src/plugins/tui/package.json +4 -10
  101. package/src/plugins/tui/src/cost-data.ts +1 -1
  102. package/src/plugins/tui/src/decision-router-state.ts +242 -0
  103. package/src/plugins/tui/src/doctor-state.ts +198 -0
  104. package/src/plugins/tui/src/index.tsx +4222 -2822
  105. package/src/plugins/tui/src/j1-gate-status.ts +85 -0
  106. package/src/plugins/tui/src/pantheon-settings-state.ts +245 -0
  107. package/src/plugins/tui/src/pantheon-settings.tsx +442 -0
  108. package/src/plugins/tui/src/preset-state.ts +143 -0
  109. package/src/plugins/tui/src/server.ts +23 -10
  110. package/src/plugins/tui/src/update-notice.ts +90 -0
  111. package/src/plugins/tui/src/update-status.ts +98 -0
  112. package/src/plugins/tui/tsconfig.typecheck.json +9 -2
  113. package/src/plugins/tui/tsdown.config.ts +3 -5
  114. package/src/plugins/tui/tui.ts +1 -2
  115. package/src/routing.yml +36 -0
  116. package/src/skills/README.md +16 -1
  117. package/src/skills/artifact-management/SKILL.md +10 -67
  118. package/src/skills/artifact-management/references/artifact-templates.md +71 -0
  119. package/src/skills/auto-continue/SKILL.md +10 -0
  120. package/src/skills/code-review-checklist/SKILL.md +11 -44
  121. package/src/skills/code-review-checklist/references/review-checklists.md +54 -0
  122. package/src/skills/instruction-forge/SKILL.md +57 -0
  123. package/src/skills/instruction-forge/references/agents-md-doctrine.md +50 -0
  124. package/src/skills/instruction-forge/references/eval-doctrine.md +37 -0
  125. package/src/skills/instruction-forge/references/skill-doctrine.md +62 -0
  126. package/src/skills/memory-bank/SKILL.md +11 -90
  127. package/src/skills/memory-bank/references/anti-patterns.md +33 -0
  128. package/src/skills/memory-bank/references/product-adoption.md +19 -0
  129. package/src/skills/memory-bank/references/storage-model.md +21 -0
  130. package/src/skills/memory-bank/references/structure-and-frequency.md +44 -0
  131. package/src/skills/reflect/SKILL.md +1 -0
  132. package/src/skills/session-goal/SKILL.md +7 -54
  133. package/src/skills/session-goal/references/goal-format.md +26 -0
  134. package/src/skills/session-goal/references/session-reuse.md +44 -0
  135. package/src/skills/tdd-with-agents/SKILL.md +11 -101
  136. package/src/skills/tdd-with-agents/references/advanced-testing-patterns.md +58 -0
  137. package/src/skills/tdd-with-agents/references/testing-by-layer.md +60 -0
  138. package/src/skills/visual-review-pipeline/SKILL.md +11 -120
  139. package/src/skills/visual-review-pipeline/references/findings-schema.md +49 -0
  140. package/src/skills/visual-review-pipeline/references/workflow-steps.md +111 -0
  141. package/scripts/hooks/log-session-start.sh +0 -48
  142. package/scripts/hooks/validate-post-conditions.sh +0 -21
  143. package/scripts/hooks/validate-talos-scope.sh +0 -50
  144. package/scripts/hooks/validate-tool-safety.sh +0 -49
  145. package/src/pantheon/goal-loop.ts +0 -314
  146. package/src/pantheon/idle-continuation.ts +0 -52
  147. package/src/pantheon/todo-preserve.ts +0 -301
  148. package/src/pantheon/tool-ceiling.ts +0 -159
  149. package/src/pantheon/v2-bridge.ts +0 -153
  150. package/src/plugin-v2.ts +0 -2954
  151. package/src/plugins/pantheon-hooks.ts +0 -1433
  152. package/src/plugins/tui/dist/server-v2.d.ts +0 -30
  153. package/src/plugins/tui/dist/server-v2.d.ts.map +0 -1
  154. package/src/plugins/tui/dist/server-v2.js +0 -33
  155. package/src/plugins/tui/dist/server-v2.js.map +0 -1
  156. package/src/plugins/tui/dist/tui-v2.d.ts +0 -1039
  157. package/src/plugins/tui/dist/tui-v2.d.ts.map +0 -1
  158. package/src/plugins/tui/dist/tui-v2.js +0 -4597
  159. package/src/plugins/tui/dist/tui-v2.js.map +0 -1
  160. package/src/plugins/tui/src/index-v2.tsx +0 -4496
  161. package/src/plugins/tui/src/server-v2.ts +0 -28
  162. package/src/plugins/tui/tui-v2.ts +0 -2
  163. /package/src/pantheon/{v2-decision-budget.ts → decision-budget.ts} +0 -0
  164. /package/src/pantheon/{v2-decision-egress.ts → decision-egress.ts} +0 -0
  165. /package/src/pantheon/{v2-decision-events.ts → decision-events.ts} +0 -0
  166. /package/src/pantheon/{v2-decision-heuristic.ts → decision-heuristic.ts} +0 -0
  167. /package/src/pantheon/{v2-decision-premises.ts → decision-premises.ts} +0 -0
  168. /package/src/pantheon/{v2-decision-rank.ts → decision-rank.ts} +0 -0
  169. /package/src/pantheon/{v2-decision-verify.ts → decision-verify.ts} +0 -0
  170. /package/src/pantheon/{v2-delegation-enforce.ts → delegation-policy.ts} +0 -0
  171. /package/src/pantheon/{v2-model-overrides.ts → model-overrides.ts} +0 -0
  172. /package/src/pantheon/{v2-native-decisions.ts → native-decisions.ts} +0 -0
  173. /package/src/plugins/tui/src/{opencode-v2.d.ts → opencode.d.ts} +0 -0
@@ -28,12 +28,13 @@ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, statSync }
28
28
  import { homedir } from 'node:os'
29
29
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
30
30
  import { fileURLToPath } from 'node:url'
31
-
32
- import { listV2UnsupportedFeatures } from '../src/pantheon/v2-unsupported.mjs'
31
+ import { load } from 'js-yaml'
32
+ import { listV2UnsupportedFeatures } from '../src/pantheon/unsupported.mjs'
33
+ import { classifyOverrideFiles } from './install/behavior-overrides.bundle.mjs'
34
+ import { describePluginOptionsReachability } from './install/capabilities.mjs'
33
35
  import { classifyFileInventory } from './install/file-inventory.mjs'
34
36
  import { staleTuiRefs } from './install/plugin.mjs'
35
37
  import { readState } from './install/state.mjs'
36
- import { describePluginOptionsReachability } from './install/v2-capabilities.mjs'
37
38
  import { isSupportedNodeVersion, MIN_SUPPORTED_NODE_VERSION } from './node-engine-policy.mjs'
38
39
 
39
40
  // ---------------------------------------------------------------------------
@@ -578,11 +579,12 @@ function checkMcpConfig(args) {
578
579
  }
579
580
 
580
581
  // 3. Check for deprecated "tools" field format
581
- // In opencode.json, tools was deprecated in favor of "permission" field
582
- if (cfg.data.tools && !cfg.data.permission) {
583
- warn(`${cfg.label}: uses deprecated top-level "tools" field — migrate to "permission"`)
584
- } else if (cfg.data.tools && cfg.data.permission) {
585
- info(`${cfg.label}: has both "tools" and "permission" — verify "tools" is intentional`)
582
+ // In opencode.json, tools was deprecated in favor of the "permissions"
583
+ // rules array (the plural key is the only spelling this host reads).
584
+ if (cfg.data.tools && !cfg.data.permissions) {
585
+ warn(`${cfg.label}: uses deprecated top-level "tools" field — migrate to "permissions"`)
586
+ } else if (cfg.data.tools && cfg.data.permissions) {
587
+ info(`${cfg.label}: has both "tools" and "permissions" — verify "tools" is intentional`)
586
588
  }
587
589
 
588
590
  // 4. Check MCP servers list — verify tool references
@@ -1533,12 +1535,14 @@ export function resolveInstalledPackageRoot(pluginPath) {
1533
1535
  * Pantheon; anything else belongs to the user and is never checked here.
1534
1536
  */
1535
1537
  const MANAGED_PLUGIN_IDENTITIES = new Set([
1538
+ // Canonical plugin DIRECTORY (the loader contract: entries must be dirs).
1539
+ 'src/plugin',
1540
+ // The entry FILE: the directory shim re-exports it, and pre-directory-
1541
+ // contract installs registered it directly, so a config carrying it is ours.
1536
1542
  'src/plugin.ts',
1543
+ // The hooks plugin of the removed generation (stripped by the installer;
1544
+ // a surviving registration is stale residue).
1537
1545
  'src/plugins/pantheon-hooks.ts',
1538
- 'src/plugin-v2',
1539
- // Legacy V2 file ref from before the directory contract (still migrated by
1540
- // the installer, so a pre-migration config is ours too).
1541
- 'src/plugin-v2.ts',
1542
1546
  ])
1543
1547
 
1544
1548
  /**
@@ -1551,7 +1555,7 @@ const MANAGED_PLUGIN_IDENTITIES = new Set([
1551
1555
  * check rather than a basename test — an unrelated user plugin may legitimately
1552
1556
  * end in `src/plugin.ts`.
1553
1557
  *
1554
- * npm specs (`pantheon-opencode`, `pantheon-opencode/plugin-v2`) and
1558
+ * npm specs (`pantheon-opencode`, `pantheon-opencode/plugin`) and
1555
1559
  * third-party paths are NOT paths this installer owns, so they return null and
1556
1560
  * are never reported.
1557
1561
  *
@@ -1733,84 +1737,102 @@ export function checkPluginVersionDrift(args) {
1733
1737
  }
1734
1738
 
1735
1739
  // ---------------------------------------------------------------------------
1736
- // Check H4: V2 feature reduction (the surface a migrating user loses)
1740
+ // Check H4: feature reduction (the surface the plugin does not provide)
1737
1741
  // ---------------------------------------------------------------------------
1738
1742
 
1739
1743
  /**
1740
- * Whether an opencode.json registers the V2 generation of the Pantheon plugin.
1744
+ * Whether a plugin ref is a Pantheon-owned registration.
1741
1745
  *
1742
- * The V2 contract is the PLURAL `plugins` key; V1 is the singular `plugin` key.
1746
+ * The contract is the PLURAL `plugins` key; the singular `plugin` key is legacy.
1743
1747
  * So the key alone is not the test — a config can legitimately carry a
1744
- * third-party entry in `plugins`. What identifies the generation is a Pantheon
1745
- * V2 entry inside it. Matched on the `plugin-v2` marker so all three real
1746
- * spellings are recognised: the canonical DIRECTORY (`src/plugin-v2`), an
1747
- * absolute path to it, and the package export (`pantheon-opencode/plugin-v2`).
1748
+ * third-party entry in `plugins`. Ownership is decided by the installer's own
1749
+ * identity set: the canonical DIRECTORY (`src/plugin`), its file spelling
1750
+ * (`src/plugin.ts`, which the shim re-exports), the removed generation's hooks
1751
+ * path, an absolute path ending in one of those identities (any install
1752
+ * prefix), a path inside an installed `node_modules/pantheon-opencode` tree, or
1753
+ * the package export (`pantheon-opencode/plugin`). A substring test would read
1754
+ * every `*-plugin` entry as ours — exactly the false positive the identity set
1755
+ * exists to prevent.
1748
1756
  *
1749
1757
  * @param {unknown} ref
1750
1758
  * @returns {boolean}
1751
1759
  */
1752
- function isV2PluginRef(ref) {
1753
- // QA beta.20: the installer's V2 writer emits `{ package, options }` —
1754
- // `package` must be probed FIRST or a perfectly healthy config reads as
1755
- // "no V2 generation registered" (a false negative the field hit).
1760
+ function isManagedRegistrationRef(ref) {
1761
+ // The installer's writer emits `{ package, options }` — `package` must be
1762
+ // probed FIRST or a perfectly healthy config reads as unregistered.
1756
1763
  const candidate =
1757
1764
  typeof ref === 'string'
1758
1765
  ? ref
1759
1766
  : ref && typeof ref === 'object'
1760
1767
  ? (ref.package ?? ref.path ?? ref.source ?? ref.id ?? ref.name)
1761
1768
  : undefined
1762
- return typeof candidate === 'string' && candidate.includes('plugin-v2')
1769
+ if (typeof candidate !== 'string') return false
1770
+ const normalized = candidate.replaceAll('\\', '/').replace(/\/$/, '')
1771
+ if (MANAGED_PLUGIN_IDENTITIES.has(normalized)) return true
1772
+ if (pantheonPackageSpecifier(normalized) !== null) return true
1773
+ const marker = '/node_modules/pantheon-opencode/'
1774
+ if (normalized.toLowerCase().includes(marker)) {
1775
+ const suffix = normalized.slice(
1776
+ normalized.toLowerCase().lastIndexOf(marker) + marker.length - 1,
1777
+ )
1778
+ if (MANAGED_PLUGIN_IDENTITIES.has(suffix)) return true
1779
+ }
1780
+ return [...MANAGED_PLUGIN_IDENTITIES].some((identity) => normalized.endsWith(`/${identity}`))
1763
1781
  }
1764
1782
 
1765
1783
  /**
1766
- * Whether any reachable config registers the V2 generation of the Pantheon
1767
- * plugin. Split out of {@link collectV2UnsupportedFeatures} because "is the V2
1768
- * generation registered" and "does the seed list anything" are TWO facts: the
1769
- * first is about the user's config, the second about this repository's seed. A
1770
- * single `features.length === 0` cannot tell them apart, and conflating them
1771
- * let an emptied seed print "no V2 generation registered — nothing reduced".
1784
+ * Whether any reachable config registers the Pantheon plugin. Split out of
1785
+ * {@link collectUnsupportedFeatures} because "is the plugin registered" and
1786
+ * "does the seed list anything" are TWO facts: the first is about the user's
1787
+ * config, the second about this repository's seed. A single
1788
+ * `features.length === 0` cannot tell them apart, and conflating them let an
1789
+ * emptied seed print "no plugin registered — nothing reduced".
1772
1790
  *
1773
1791
  * @param {{path:string, data:object}[]} configs
1774
1792
  * @returns {boolean}
1775
1793
  */
1776
- export function isV2GenerationRegistered(configs) {
1794
+ export function isPantheonPluginRegistered(configs) {
1777
1795
  return configs.some((cfg) => {
1778
1796
  const list = cfg.data?.plugins
1779
- return Array.isArray(list) && list.some(isV2PluginRef)
1797
+ return Array.isArray(list) && list.some(isManagedRegistrationRef)
1780
1798
  })
1781
1799
  }
1782
1800
 
1783
1801
  /**
1784
- * The V2 feature-reduction markers to report for a set of collected configs.
1802
+ * The feature-reduction markers to report for a set of collected configs.
1785
1803
  *
1786
- * Returns the shared seed verbatim when ANY reachable config registers the V2
1787
- * generation, and an empty list otherwise. The strings come from
1788
- * `src/pantheon/v2-unsupported.mjs` — the same seed `getUnsupportedFeatures()`
1804
+ * Returns the shared seed verbatim when ANY reachable config registers the
1805
+ * plugin, and an empty list otherwise. The strings come from
1806
+ * `src/pantheon/unsupported.mjs` — the same seed `getUnsupportedFeatures()`
1789
1807
  * is built from — so doctor cannot report a reduction the plugin does not, or
1790
1808
  * miss one it does. Nothing is reworded here.
1791
1809
  *
1792
1810
  * An empty result is ambiguous on its own and deliberately not interpreted
1793
- * here: ask {@link isV2GenerationRegistered} for the registration fact, or
1794
- * {@link describeV2Reduction} to get both at once.
1811
+ * here: ask {@link isPantheonPluginRegistered} for the registration fact, or
1812
+ * {@link describeUnsupportedReduction} to get both at once.
1795
1813
  *
1796
1814
  * @param {{path:string, data:object}[]} configs
1797
1815
  * @returns {string[]}
1798
1816
  */
1799
- export function collectV2UnsupportedFeatures(configs) {
1800
- return isV2GenerationRegistered(configs) ? listV2UnsupportedFeatures() : []
1817
+ export function collectUnsupportedFeatures(configs) {
1818
+ return isPantheonPluginRegistered(configs) ? listV2UnsupportedFeatures() : []
1801
1819
  }
1802
1820
 
1803
1821
  /**
1804
1822
  * Decide what H4 prints, from the two distinct facts rather than from one list
1805
1823
  * length.
1806
1824
  *
1807
- * Three cases, and the middle one used to be silently reported as the first:
1825
+ * There is one generation: an UNREGISTERED config is not a quiet "supported
1826
+ * install" — it is a stale install whose registration the host will not load —
1827
+ * and it warns. Three cases, and the middle one used to be silently reported as
1828
+ * the first:
1808
1829
  *
1809
- * - not registered → info. A V1 install is a supported configuration with
1810
- * nothing to reduce, and saying so plainly is correct.
1830
+ * - not registered → warn. The host ignores the singular `plugin` key the
1831
+ * removed generation wrote, so this install runs with no Pantheon tool
1832
+ * surface at all.
1811
1833
  * - registered, seed EMPTY → warn. This is a packaging fault in THIS repo,
1812
- * not an absence of reduction: the V2 surface really is reduced and the
1813
- * report is missing. It must never claim "nothing reduced".
1834
+ * not an absence of reduction: the registered surface really is reduced and
1835
+ * the report is missing. It must never claim "nothing reduced".
1814
1836
  * - registered, seed populated → warn, listing every marker.
1815
1837
  *
1816
1838
  * Pure and exported so the empty-seed branch is testable without stubbing the
@@ -1818,14 +1840,17 @@ export function collectV2UnsupportedFeatures(configs) {
1818
1840
  * has to recover the case by matching on the message.
1819
1841
  *
1820
1842
  * @param {{registered:boolean, features:string[]}} input
1821
- * @returns {{status:'reported'|'empty-seed'|'no-v2-generation', level:'info'|'warn', message:string}}
1843
+ * @returns {{status:'reported'|'empty-seed'|'no-registration', level:'info'|'warn', message:string}}
1822
1844
  */
1823
- export function describeV2Reduction({ registered, features }) {
1845
+ export function describeUnsupportedReduction({ registered, features }) {
1824
1846
  if (!registered) {
1825
1847
  return {
1826
- status: 'no-v2-generation',
1827
- level: 'info',
1828
- message: 'No V2 plugin generation registered — nothing reduced',
1848
+ status: 'no-registration',
1849
+ level: 'warn',
1850
+ message:
1851
+ 'No Pantheon plugin registered — this looks like a stale install of the removed ' +
1852
+ 'generation: the host ignores the singular `plugin` key it wrote, so no Pantheon ' +
1853
+ 'plugin is loading. Run `npx pantheon-opencode init` to register the plugin.',
1829
1854
  }
1830
1855
  }
1831
1856
  if (features.length === 0) {
@@ -1833,54 +1858,82 @@ export function describeV2Reduction({ registered, features }) {
1833
1858
  status: 'empty-seed',
1834
1859
  level: 'warn',
1835
1860
  message:
1836
- 'Pantheon IS registered on the V2 plugin generation, but the shared ' +
1837
- 'unsupported-feature seed is empty, so the reduction cannot be reported. ' +
1838
- "That is a fault in this installation's reporting, not an absence of " +
1839
- 'reduction: the V2 surface still registers fewer tools than V1 (the three ' +
1840
- 'goal tools are absent), so a clean report would be false.',
1861
+ 'Pantheon IS registered, but the shared unsupported-feature seed is empty, so ' +
1862
+ "the reduction cannot be reported. That is a fault in this installation's " +
1863
+ 'reporting, not an absence of reduction: the registered surface is a reduced ' +
1864
+ 'tool set, so a clean report would be false.',
1841
1865
  }
1842
1866
  }
1843
1867
  return {
1844
1868
  status: 'reported',
1845
1869
  level: 'warn',
1846
1870
  message:
1847
- 'Pantheon is registered on the V2 plugin generation: 3 unconditional tools ' +
1871
+ 'Pantheon is registered: 3 unconditional tools ' +
1848
1872
  '(hashline_edit, pantheon_cost, pantheon_model) plus the host-dependent ones, and a ' +
1849
- "real hook/transform surface, against the V1 surface's 6 tools plus the " +
1850
- 'BackgroundJobBoard. Not provided on V2 (static seed — a live host can add runtime ' +
1851
- `markers on top): ${features.join(', ')}`,
1873
+ 'real hook/transform surface. Not provided (static seed — a live host can add ' +
1874
+ `runtime markers on top): ${features.join(', ')}`,
1852
1875
  }
1853
1876
  }
1854
1877
 
1855
1878
  /**
1856
- * Report the V2 feature reduction through doctor's own output shape
1879
+ * Whether a ref in the LEGACY singular `plugin` key is a Pantheon registration.
1880
+ * The installer never writes that key anymore and the host ignores it entirely,
1881
+ * so a hit is residue of an old install — drift worth naming, never a supported
1882
+ * configuration.
1883
+ * @param {unknown} ref
1884
+ * @returns {boolean}
1885
+ */
1886
+ export function isStaleSingularKeyRef(ref) {
1887
+ return isManagedRegistrationRef(ref)
1888
+ }
1889
+
1890
+ /**
1891
+ * Report the feature reduction through doctor's own output shape
1857
1892
  * (section + warn/info), so it lands in the health summary like every other
1858
- * finding and never changes the exit code: a V2 install is a supported
1893
+ * finding and never changes the exit code: a registered install is a supported
1859
1894
  * configuration, not a broken one.
1860
1895
  *
1896
+ * Pantheon refs in the legacy singular `plugin` key are named here too: that
1897
+ * key is dead on this host, so they are stale-install residue, never a
1898
+ * supported registration.
1899
+ *
1861
1900
  * @param {{target:string, env?:object}} args
1862
- * @returns {'reported'|'empty-seed'|'no-v2-generation'|'no-config'}
1901
+ * @returns {'reported'|'empty-seed'|'no-registration'|'no-config'}
1863
1902
  */
1864
- export function checkV2UnsupportedFeatures(args) {
1865
- section('H4. V2 Feature Reduction')
1903
+ export function checkUnsupportedFeatures(args) {
1904
+ section('H4. Feature Reduction')
1866
1905
 
1867
1906
  const configs = collectMcpConfigs(args)
1868
1907
  if (configs.length === 0) {
1869
- info('No opencode.json was found — V2 feature reduction check skipped')
1908
+ info('No opencode.json was found — feature reduction check skipped')
1870
1909
  return 'no-config'
1871
1910
  }
1872
1911
 
1873
1912
  // Branch on REGISTRATION, not on the marker count: an empty seed on a
1874
- // registered V2 generation is a reporting fault and must not be reported as
1875
- // the reassuring "nothing reduced".
1876
- const registered = isV2GenerationRegistered(configs)
1877
- const verdict = describeV2Reduction({
1913
+ // registered install is a reporting fault and must not be reported as the
1914
+ // reassuring "nothing reduced".
1915
+ const registered = isPantheonPluginRegistered(configs)
1916
+ const verdict = describeUnsupportedReduction({
1878
1917
  registered,
1879
- features: collectV2UnsupportedFeatures(configs),
1918
+ features: collectUnsupportedFeatures(configs),
1880
1919
  })
1881
1920
  if (verdict.level === 'info') info(verdict.message)
1882
1921
  else warn(verdict.message)
1883
1922
 
1923
+ // Stale-install residue: Pantheon refs in the singular key are ignored by
1924
+ // the host, so a config carrying them runs without those plugins. Named
1925
+ // explicitly (with or without a plural-key registration beside them).
1926
+ const legacyRefs = configs.flatMap((cfg) =>
1927
+ Array.isArray(cfg.data?.plugin) ? cfg.data.plugin.filter(isStaleSingularKeyRef) : [],
1928
+ )
1929
+ if (legacyRefs.length > 0) {
1930
+ warn(
1931
+ `${legacyRefs.length} Pantheon reference(s) sit in the legacy singular \`plugin\` key, ` +
1932
+ 'which the host ignores — stale-install residue. ' +
1933
+ 'Run `npx pantheon-opencode init` to clean them and register the plugin.',
1934
+ )
1935
+ }
1936
+
1884
1937
  // Whether the installed entry can receive plugin `options` at all: the host
1885
1938
  // passes them only from the object form, and `context_pruner` reads that bag.
1886
1939
  // A bare-string entry installs fine and silently leaves the opt-in
@@ -1969,12 +2022,11 @@ export async function checkTuiPlugin(args) {
1969
2022
  return 'missing-dir'
1970
2023
  }
1971
2024
 
1972
- const v1Bundle = join(copyDir, 'dist', 'tui.js')
1973
- const v2Bundle = join(copyDir, 'dist', 'tui-v2.js')
1974
- if (!existsSync(v1Bundle) && !existsSync(v2Bundle)) {
2025
+ const bundle = join(copyDir, 'dist', 'tui.js')
2026
+ if (!existsSync(bundle)) {
1975
2027
  error(
1976
2028
  `TUI bundle is missing under ${join(copyDir, 'dist')} — the copied plugin cannot be ` +
1977
- 'loaded by either host. Run `npx pantheon-opencode init` to reinstall it.',
2029
+ 'loaded by the host. Run `npx pantheon-opencode init` to reinstall it.',
1978
2030
  { code: 'tui_plugin_dist_missing', classification: 'missing' },
1979
2031
  )
1980
2032
  return 'missing-dist'
@@ -1983,20 +2035,20 @@ export async function checkTuiPlugin(args) {
1983
2035
  const tuiConfig = readJson(tuiJsonPath)
1984
2036
  const pluginRefs = Array.isArray(tuiConfig?.plugin) ? tuiConfig.plugin : []
1985
2037
  const registered = pluginRefs.some((ref) => samePath(ref, copyDir))
1986
- // V2 discovers local plugins from the plugins directory instead of tui.json;
1987
- // its payload is identified by the sibling index.ts server entrypoint plus a
1988
- // package export that resolves to the compiled V2 bundle.
1989
- const v2Target = tuiExportTarget(copyDir)
1990
- const v2Discovered =
2038
+ // The host discovers local plugins from the plugins directory instead of
2039
+ // tui.json; the payload is identified by the sibling index.ts server
2040
+ // entrypoint plus a package export that resolves to the compiled bundle.
2041
+ const exportTarget = tuiExportTarget(copyDir)
2042
+ const directoryDiscovered =
1991
2043
  existsSync(join(copyDir, 'index.ts')) &&
1992
- typeof v2Target === 'string' &&
1993
- v2Target.endsWith('tui-v2.js')
2044
+ typeof exportTarget === 'string' &&
2045
+ exportTarget.endsWith('tui.js')
1994
2046
 
1995
- if (!registered && !v2Discovered) {
2047
+ if (!registered && !directoryDiscovered) {
1996
2048
  error(
1997
2049
  `TUI plugin is copied to ${copyDir} but no host discovery finds it: ` +
1998
- `${tuiJsonPath} does not reference it and the V2 discovery files are incomplete. ` +
1999
- 'Run `npx pantheon-opencode init` to re-register it.',
2050
+ `${tuiJsonPath} does not reference it and the plugin-directory discovery files are ` +
2051
+ 'incomplete. Run `npx pantheon-opencode init` to re-register it.',
2000
2052
  { code: 'tui_plugin_not_registered', classification: 'ambiguous' },
2001
2053
  )
2002
2054
  return 'unregistered'
@@ -2294,15 +2346,14 @@ export function classifyNodeSqliteProbe(probe) {
2294
2346
  * These files are the surface the doctor already ships and can inspect without
2295
2347
  * importing or executing plugin code.
2296
2348
  *
2297
- * The V2 generation has TWO surfaces: `src/pantheon/v2-tools.ts` from beta.3
2298
- * and the 1.5.0+ entry `src/plugin-v2.ts`, which declares the tools itself.
2349
+ * The V2 generation has TWO surfaces: `src/pantheon/tools.ts` from beta.3
2350
+ * and the 1.5.0+ entry `src/plugin.ts`, which declares the tools itself.
2299
2351
  * Reading only the first reported a healthy 1.5 tree as "pantheon_cost is NOT
2300
2352
  * declared", so every declared surface of the generation is inspected and their
2301
2353
  * declarations are unioned.
2302
2354
  */
2303
2355
  const TOOL_SURFACE_FILES = Object.freeze({
2304
- v1: Object.freeze([join('src', 'plugin.ts')]),
2305
- v2: Object.freeze([join('src', 'plugin-v2.ts'), join('src', 'pantheon', 'v2-tools.ts')]),
2356
+ v2: Object.freeze([join('src', 'plugin.ts'), join('src', 'pantheon', 'tools.ts')]),
2306
2357
  })
2307
2358
 
2308
2359
  /** The published package name — the only package identity this installer owns. */
@@ -2313,53 +2364,31 @@ function stripSourceComments(source) {
2313
2364
  return source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '')
2314
2365
  }
2315
2366
 
2316
- /** Extract the first `key: { ... }` object-literal body, or null. */
2317
- function extractObjectLiteralBody(source, key) {
2318
- const match = new RegExp(`\\b${key}\\s*:\\s*\\{`).exec(source)
2319
- if (!match) return null
2320
- let depth = 0
2321
- const start = match.index + match[0].length - 1
2322
- for (let index = start; index < source.length; index++) {
2323
- if (source[index] === '{') depth++
2324
- else if (source[index] === '}') {
2325
- depth--
2326
- if (depth === 0) return source.slice(start + 1, index)
2327
- }
2328
- }
2329
- return null
2330
- }
2331
-
2332
2367
  /**
2333
- * Tool names declared by a plugin-generation source file.
2334
- *
2335
- * V2 declares each tool as `name: 'x'` in `createV2ToolDefinitions`, or — from
2336
- * the 1.5.0 entry — as quoted elements of a `toolNames` array. V1 keys the
2337
- * `tool:` object by tool name. Returns null when the generation's shape cannot
2338
- * be located (unverifiable), which the classifier treats as a failure rather
2339
- * than a pass: "cannot prove registration" is not "registered".
2368
+ * Tool names declared by the V2 plugin surface: each tool as `name: 'x'` in
2369
+ * `createV2ToolDefinitions`, or — from the 1.5.0 entry — as quoted elements of
2370
+ * a `toolNames` array. Returns null when the shape cannot be located
2371
+ * (unverifiable), which the classifier treats as a failure rather than a pass:
2372
+ * "cannot prove registration" is not "registered".
2340
2373
  *
2341
2374
  * @param {string} source
2342
- * @param {'v1'|'v2'} generation
2375
+ * @param {'v2'} generation
2343
2376
  * @returns {string[]|null}
2344
2377
  */
2345
2378
  export function readDeclaredToolNames(source, generation) {
2346
2379
  const body = stripSourceComments(source)
2347
- if (generation === 'v2') {
2348
- const names = new Set(
2349
- [...body.matchAll(/\bname:\s*['"]([A-Za-z0-9_-]+)['"]/g)].map((match) => match[1]),
2350
- )
2351
- for (const match of body.matchAll(/^\s*['"]([A-Za-z0-9_-]+)['"],?\s*$/gm)) names.add(match[1])
2352
- return [...names]
2353
- }
2354
- const toolBlock = extractObjectLiteralBody(body, 'tool')
2355
- if (toolBlock === null) return null
2356
- return [...toolBlock.matchAll(/^\s*([a-z][a-z0-9_]*)\s*:/gm)].map((match) => match[1])
2380
+ if (generation !== 'v2') return null
2381
+ const names = new Set(
2382
+ [...body.matchAll(/\bname:\s*['"]([A-Za-z0-9_-]+)['"]/g)].map((match) => match[1]),
2383
+ )
2384
+ for (const match of body.matchAll(/^\s*['"]([A-Za-z0-9_-]+)['"],?\s*$/gm)) names.add(match[1])
2385
+ return [...names]
2357
2386
  }
2358
2387
 
2359
2388
  /**
2360
2389
  * Return the Pantheon package specifier a ref names, or null when it is not
2361
2390
  * one. Covers `pantheon-opencode`, `pantheon-opencode@1.2.3` and an export
2362
- * subpath (`pantheon-opencode/plugin-v2`): the host resolves all of them
2391
+ * subpath (`pantheon-opencode/plugin`): the host resolves all of them
2363
2392
  * through its own module graph, not from a path this process can inspect.
2364
2393
  *
2365
2394
  * @param {unknown} refPath
@@ -2397,7 +2426,7 @@ export function resolveRegisteredPluginRoot(ref) {
2397
2426
 
2398
2427
  const normalized = absolute.replaceAll('\\', '/').replace(/\/+$/, '')
2399
2428
  const marker =
2400
- /^(.*?)\/src\/plugin-v2(?:\/index\.ts|\.ts)?$/.exec(normalized) ??
2429
+ /^(.*?)\/src\/plugin(?:\/index\.ts|\.ts)?$/.exec(normalized) ??
2401
2430
  /^(.*?)\/src\/plugin(?:-v2)?\.ts$/.exec(normalized)
2402
2431
  const root = marker ? marker[1] : normalized
2403
2432
  return existsSync(join(root, 'package.json')) ? root : null
@@ -2410,7 +2439,7 @@ export function resolveRegisteredPluginRoot(ref) {
2410
2439
  * writes (or a path inside an installed `pantheon-opencode` tree), or a
2411
2440
  * `package.json` naming this package. Everything else belongs to the user, so a
2412
2441
  * third-party plugin registered under `plugins` is ignored instead of being
2413
- * read as a Pantheon surface with a missing `src/pantheon/v2-tools.ts` (which
2442
+ * read as a Pantheon surface with a missing `src/pantheon/tools.ts` (which
2414
2443
  * failed a healthy installation as blocking).
2415
2444
  *
2416
2445
  * @param {{path:string, configPath:string}} ref
@@ -2442,7 +2471,7 @@ function describeSurface(surface) {
2442
2471
  * instead of being skipped or passed against the running package.
2443
2472
  *
2444
2473
  * @param {{target:string, env?:object}} args
2445
- * @returns {{generation:'v1'|'v2'|null, root:string|null, files:string[], declared:string[]|null, unverifiable?:string}[]}
2474
+ * @returns {{generation:'v2'|null, root:string|null, files:string[], declared:string[]|null, unverifiable?:string}[]}
2446
2475
  */
2447
2476
  export function resolveRegisteredToolSurfaces(args) {
2448
2477
  const refs = collectRegisteredPluginRefs(collectMcpConfigs(args))
@@ -2467,9 +2496,14 @@ export function resolveRegisteredToolSurfaces(args) {
2467
2496
  continue
2468
2497
  }
2469
2498
 
2499
+ // V2 is the only generation. A legacy V1 ref in the singular `plugin` key
2500
+ // is residue the host ignores ENTIRELY (H3/H4 name it), so it is not a
2501
+ // surface this tool check can verify anything about — reading it as one
2502
+ // failed a healthy checkout with "no tool surface" noise.
2503
+ if (ref.key !== 'plugins' && !ref.path?.includes('plugin')) continue
2470
2504
  const root = resolveRegisteredPluginRoot(ref)
2471
2505
  if (!root) continue
2472
- const generation = ref.path?.includes('plugin-v2') || ref.key === 'plugins' ? 'v2' : 'v1'
2506
+ const generation = 'v2'
2473
2507
  const key = `${generation}:${root}`
2474
2508
  if (seen.has(key)) continue
2475
2509
  seen.add(key)
@@ -2514,7 +2548,7 @@ export function resolveRegisteredToolSurfaces(args) {
2514
2548
  * `lite` is the only profile where no registration is expected: it describes a
2515
2549
  * checkout, not a managed OpenCode install.
2516
2550
  *
2517
- * @param {{profile:string, surfaces:{generation:string|null, files:string[], root:string|null, declared:string[]|null, unverifiable?:string}[], toolName:string}} input
2551
+ * @param {{profile:string, surfaces:{generation:'v2'|null, files:string[], root:string|null, declared:string[]|null, unverifiable?:string}[], toolName:string}} input
2518
2552
  * @returns {{status:'skip'|'unregistered'|'missing'|'registered'|'unverifiable'|'partially-verified', level:'info'|'error'|'pass', message:string}}
2519
2553
  */
2520
2554
  export function classifyToolRegistration({ profile, surfaces, toolName }) {
@@ -2715,7 +2749,7 @@ async function checkInstallerFileInventory(args) {
2715
2749
  try {
2716
2750
  const { installOpenCode, isGlobalConfigDir } = await import('./install/opencode.mjs')
2717
2751
  const preview = await installOpenCode(args.target, true, false, selectedComponents, {
2718
- version: 'auto',
2752
+ env: { ...process.env, OPENCODE_VERSION: 'v2' },
2719
2753
  quiet: true,
2720
2754
  quietPlan: true,
2721
2755
  planOnly: true,
@@ -2726,11 +2760,7 @@ async function checkInstallerFileInventory(args) {
2726
2760
  .filter((file) => typeof file.outputFingerprint === 'string')
2727
2761
  .map((file) => [file.path, { sha256: file.outputFingerprint }]),
2728
2762
  )
2729
- const layout = isGlobalConfigDir(args.target)
2730
- ? 'global'
2731
- : preview?.openCodeVersion === 'v2'
2732
- ? 'project-v2'
2733
- : 'project-v1'
2763
+ const layout = isGlobalConfigDir(args.target) ? 'global' : 'project-v2'
2734
2764
  selectedLayouts = Object.fromEntries(selectedComponents.map((component) => [component, layout]))
2735
2765
  desiredUnavailable = false
2736
2766
  } catch {
@@ -2798,6 +2828,64 @@ async function checkInstallerFileInventory(args) {
2798
2828
  }
2799
2829
  }
2800
2830
 
2831
+ // ─── Named-behavior overrides ───────────────────────────────────────────
2832
+
2833
+ /**
2834
+ * Validate the user's override files against the routing.yml behaviors
2835
+ * registry: schema errors and unknown behavior ids surface as warnings
2836
+ * (codes `override_schema_invalid` / `override_unknown_behavior`). With
2837
+ * `--fix`, an offending file is quarantined (renamed with a timestamp) so
2838
+ * the next install runs clean — never silently deleted.
2839
+ */
2840
+ function checkBehaviorOverrides(args) {
2841
+ section('K. Named-behavior overrides')
2842
+
2843
+ const readOptional = (path) => {
2844
+ try {
2845
+ return readFileSync(path, 'utf8')
2846
+ } catch {
2847
+ return undefined
2848
+ }
2849
+ }
2850
+ const projectPath = join(args.target, '.pantheon', 'overrides.json')
2851
+ const globalPath = join(args.target, 'pantheon-overrides.json')
2852
+ const projectRaw = readOptional(projectPath)
2853
+ const globalRaw = readOptional(globalPath)
2854
+ if (projectRaw === undefined && globalRaw === undefined) {
2855
+ info('no override files present (the default: every behavior ships as built)')
2856
+ return
2857
+ }
2858
+
2859
+ let registry = []
2860
+ try {
2861
+ const routing = load(readFileSync(join(ROOT, 'src', 'routing.yml'), 'utf8'))
2862
+ if (Array.isArray(routing?.behaviors)) registry = routing.behaviors
2863
+ } catch {
2864
+ // routing.yml unreadable: the classification still runs (registry empty,
2865
+ // every id warns) — never silently green.
2866
+ }
2867
+
2868
+ const { warnings } = classifyOverrideFiles(registry, projectRaw, globalRaw)
2869
+ for (const warning of warnings) {
2870
+ warn(`${warning.message} [${warning.code}]`)
2871
+ }
2872
+ if (warnings.length === 0) {
2873
+ pass('override files valid against the behaviors registry')
2874
+ return
2875
+ }
2876
+
2877
+ if (args.fix) {
2878
+ for (const path of [projectPath, globalPath]) {
2879
+ const raw = readOptional(path)
2880
+ if (raw === undefined) continue
2881
+ const quarantined = `${path}.quarantined-${Date.now()}`
2882
+ renameSync(path, quarantined)
2883
+ info(`quarantined ${path} -> ${quarantined} (review, fix, and rename back)`)
2884
+ }
2885
+ warn('override files quarantined — installs run on built-in defaults until reviewed')
2886
+ }
2887
+ }
2888
+
2801
2889
  async function main() {
2802
2890
  const args = parseArgs(process.argv)
2803
2891
  jsonMode = args.json
@@ -2887,12 +2975,13 @@ async function main() {
2887
2975
  await checkMcpRuntimeSmoke(args)
2888
2976
  }
2889
2977
  checkPermissionMismatches(args)
2978
+ checkBehaviorOverrides(args)
2890
2979
  checkSyncStatus(args)
2891
2980
  checkGitStatus(args)
2892
2981
  checkAgentsMdFreshness(args)
2893
2982
  checkSubagentDepthPlacement(args)
2894
2983
  checkPermissionTaskPresence(args)
2895
- checkV2UnsupportedFeatures(args)
2984
+ checkUnsupportedFeatures(args)
2896
2985
 
2897
2986
  printSummary(args.target)
2898
2987
  if (jsonMode) writeDoctorJson(createDoctorJsonReport(args), exitCode)