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
@@ -0,0 +1,198 @@
1
+ /**
2
+ * doctor-state.ts — the Doctor section of the settings window (read-only).
3
+ *
4
+ * TUI-local replica (the bundle must stay self-contained — the installed copy
5
+ * physically lacks the repo tree, so doctor.mjs itself is unreachable). Only
6
+ * the FILE-DERIVABLE checks are mirrored here; everything that spawns
7
+ * processes, reads the network, or writes (MCP smoke, python validators, git,
8
+ * venv pins, --fix quarantines) stays in the CLI and the section says so.
9
+ *
10
+ * The install-state path mirrors doctor's checkInstallVersionDrift
11
+ * (`<config>/opencode/.pantheon/install-state.json`); the Node floor is
12
+ * drift-pinned against scripts/node-engine-policy.mjs by
13
+ * tests/tui-doctor-state.test.mjs.
14
+ */
15
+ import { existsSync, readFileSync } from 'node:fs'
16
+ import { join } from 'node:path'
17
+ import { readDecisionRouterConfig } from './decision-router-state.ts'
18
+ import type { OverridesLoad } from './pantheon-settings-state.ts'
19
+ import {
20
+ SETTINGS_BEHAVIORS,
21
+ type SettingsRow,
22
+ type SettingsSection,
23
+ } from './pantheon-settings-state.ts'
24
+ import { comparePantheonVersions } from './update-notice.ts'
25
+
26
+ /** Drift-pinned against scripts/node-engine-policy.mjs MIN_SUPPORTED_NODE_VERSION. */
27
+ export const MIN_SUPPORTED_NODE_VERSION = '26.4.0'
28
+
29
+ export function opencodePantheonDir(env: Record<string, string | undefined> = process.env) {
30
+ const xdg = env.XDG_CONFIG_HOME
31
+ const home = env.HOME ?? ''
32
+ const root = xdg ?? join(home, '.config')
33
+ return join(root, 'opencode', '.pantheon')
34
+ }
35
+
36
+ export interface InstallVersionHealth {
37
+ status: 'ok' | 'older' | 'newer' | 'unknown'
38
+ installed: string | null
39
+ }
40
+
41
+ /**
42
+ * H2: the installed package version (install-state) vs the running one.
43
+ * Fail-open: a missing/unreadable state file means "unknown", not a failure —
44
+ * pre-2.0 installs may not have one.
45
+ */
46
+ export function classifyInstallVersion(
47
+ runningVersion: string,
48
+ env: Record<string, string | undefined> = process.env,
49
+ ): InstallVersionHealth {
50
+ let installed: string | null = null
51
+ try {
52
+ const path = join(opencodePantheonDir(env), 'install-state.json')
53
+ const raw = JSON.parse(readFileSync(path, 'utf8')) as { pantheon_version?: unknown }
54
+ if (typeof raw?.pantheon_version === 'string' && raw.pantheon_version !== '') {
55
+ installed = raw.pantheon_version
56
+ }
57
+ } catch {
58
+ installed = null
59
+ }
60
+ if (installed === null) return { status: 'unknown', installed: null }
61
+ const compared = comparePantheonVersions(installed, runningVersion)
62
+ if (compared === 0) return { status: 'ok', installed }
63
+ return { status: compared < 0 ? 'older' : 'newer', installed }
64
+ }
65
+
66
+ export function isSupportedNodeFloor(version: string): boolean {
67
+ // Same shape as the canonical parser: a prerelease is outside the floor.
68
+ const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?(?:\+([\w.-]+))?$/.exec(String(version))
69
+ const minimum = /^v?(\d+)\.(\d+)\.(\d+)/.exec(MIN_SUPPORTED_NODE_VERSION)
70
+ if (!match || !minimum) return false
71
+ const [, major = '', minor = '', patch = '', prerelease = ''] = match
72
+ if (prerelease !== '') return false
73
+ const [, minMajor = '0', minMinor = '0', minPatch = '0'] = minimum
74
+ const currentParts = [+major, +minor, +patch]
75
+ const minimumParts = [+minMajor, +minMinor, +minPatch]
76
+ for (let index = 0; index < 3; index += 1) {
77
+ const currentPart = currentParts[index] ?? 0
78
+ const minimumPart = minimumParts[index] ?? 0
79
+ if (currentPart !== minimumPart) return currentPart > minimumPart
80
+ }
81
+ return true
82
+ }
83
+
84
+ export interface OverridesHealth {
85
+ status: 'clean' | 'unknown-ids' | 'corrupt'
86
+ unknownIds: string[]
87
+ }
88
+
89
+ /** K: validate both overrides files against the window's registry. */
90
+ export function classifyOverridesHealth(load: OverridesLoad): OverridesHealth {
91
+ if (load.corruptGlobal) return { status: 'corrupt', unknownIds: [] }
92
+ const known = new Set(SETTINGS_BEHAVIORS.map((behavior) => behavior.id))
93
+ const unknownIds = Object.keys({ ...load.global, ...load.project }).filter((id) => !known.has(id))
94
+ return { status: unknownIds.length > 0 ? 'unknown-ids' : 'clean', unknownIds }
95
+ }
96
+
97
+ export interface DecisionConfigHealth {
98
+ status: 'ok' | 'corrupt' | 'absent'
99
+ }
100
+
101
+ export function classifyDecisionConfigHealth(
102
+ env: Record<string, string | undefined> = process.env,
103
+ ): DecisionConfigHealth {
104
+ if (
105
+ !existsSync(
106
+ join(
107
+ env.XDG_CONFIG_HOME ?? join(env.HOME ?? '', '.config'),
108
+ 'pantheon',
109
+ 'decision-router.json',
110
+ ),
111
+ )
112
+ ) {
113
+ return { status: 'absent' }
114
+ }
115
+ return readDecisionRouterConfig(env).corrupt ? { status: 'corrupt' } : { status: 'ok' }
116
+ }
117
+
118
+ export interface DoctorSectionInput {
119
+ runningVersion: string
120
+ nodeVersion: string
121
+ load: OverridesLoad
122
+ env?: Record<string, string | undefined>
123
+ }
124
+
125
+ export function buildDoctorSection(input: DoctorSectionInput): SettingsSection {
126
+ const env = input.env ?? process.env
127
+ const rows: SettingsRow[] = []
128
+
129
+ const version = classifyInstallVersion(input.runningVersion, env)
130
+ rows.push({
131
+ id: 'doctor.version',
132
+ title:
133
+ version.status === 'ok'
134
+ ? `Installed version: v${version.installed} — matches`
135
+ : version.status === 'older'
136
+ ? `Installed v${version.installed} is older than the runtime v${input.runningVersion}`
137
+ : version.status === 'newer'
138
+ ? `Installed v${version.installed} is newer than the runtime v${input.runningVersion}`
139
+ : 'Installed version: unknown (no install-state)',
140
+ description:
141
+ version.status === 'older'
142
+ ? 'refresh with `pantheon-opencode update`'
143
+ : 'read from <config>/opencode/.pantheon/install-state.json',
144
+ marker: version.status === 'ok' ? '[✓]' : version.status === 'older' ? '[!]' : '[i]',
145
+ selectable: false,
146
+ })
147
+
148
+ const nodeOk = isSupportedNodeFloor(input.nodeVersion)
149
+ rows.push({
150
+ id: 'doctor.node',
151
+ title: `Node runtime: ${input.nodeVersion.replace(/^v/, '')}`,
152
+ description: nodeOk
153
+ ? `meets the >= ${MIN_SUPPORTED_NODE_VERSION} floor`
154
+ : `below the >= ${MIN_SUPPORTED_NODE_VERSION} floor — tooling may refuse`,
155
+ marker: nodeOk ? '[✓]' : '[!]',
156
+ selectable: false,
157
+ })
158
+
159
+ const overrides = classifyOverridesHealth(input.load)
160
+ rows.push({
161
+ id: 'doctor.overrides',
162
+ title:
163
+ overrides.status === 'clean'
164
+ ? 'Overrides: valid'
165
+ : overrides.status === 'corrupt'
166
+ ? 'Overrides: global file unreadable'
167
+ : `Overrides: ${overrides.unknownIds.length} unknown id(s)`,
168
+ description:
169
+ overrides.status === 'unknown-ids'
170
+ ? `${overrides.unknownIds.join(', ')} — harmless; repair with doctor --fix`
171
+ : overrides.status === 'corrupt'
172
+ ? 'writes are refused until repaired (doctor --fix)'
173
+ : 'both files parse against the behavior registry',
174
+ marker: overrides.status === 'clean' ? '[✓]' : overrides.status === 'corrupt' ? '[✗]' : '[!]',
175
+ selectable: false,
176
+ })
177
+
178
+ const decision = classifyDecisionConfigHealth(env)
179
+ rows.push({
180
+ id: 'doctor.decision',
181
+ title:
182
+ decision.status === 'ok'
183
+ ? 'Decision config: valid'
184
+ : decision.status === 'corrupt'
185
+ ? 'Decision config: unreadable — runtime fail-closes'
186
+ : 'Decision config: absent (local defaults)',
187
+ description: 'read from <config>/pantheon/decision-router.json',
188
+ marker: decision.status === 'corrupt' ? '[✗]' : '[✓]',
189
+ selectable: false,
190
+ })
191
+
192
+ return {
193
+ id: 'doctor',
194
+ title: 'Doctor',
195
+ rows,
196
+ hint: 'file checks only — the full doctor (MCP smoke, venv, git) is `pantheon-opencode doctor`',
197
+ }
198
+ }