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
@@ -1,6 +1,9 @@
1
1
  /** OpenCode major-version selection shared by the CLI and installer. */
2
2
 
3
3
  import { spawnSync } from 'node:child_process'
4
+ import { mkdtempSync, rmSync } from 'node:fs'
5
+ import { tmpdir } from 'node:os'
6
+ import { join } from 'node:path'
4
7
 
5
8
  import { warning } from './cli-ui.mjs'
6
9
 
@@ -31,27 +34,65 @@ function normalize(value) {
31
34
  return value
32
35
  }
33
36
 
37
+ /**
38
+ * Budget for `opencode --version` during a real install. A hung host binary
39
+ * must not block the installer forever.
40
+ */
41
+ const HOST_PROBE_TIMEOUT_MS = 5000
42
+
43
+ /**
44
+ * Budget for the same probe during a DRY RUN. A preview is bounded: the dry
45
+ * run now probes the host (it used to skip the probe and assume V1, which made
46
+ * the plan describe a different generation than the apply), so its latency
47
+ * must stay small even on a host that hangs.
48
+ */
49
+ export const DRY_RUN_PROBE_TIMEOUT_MS = 2000
50
+
34
51
  /**
35
52
  * Ask the host binary for its version. Throws on any spawn failure so the
36
53
  * caller can fail soft in one place.
37
54
  *
55
+ * The probe RUNS THE HOST, and a host is not a pure function of its `--version`
56
+ * flag: OpenCode 2.x creates `~/.cache/opencode`, `~/.local/share/opencode/log`
57
+ * and `~/.local/state/opencode` before printing. A dry run promises "no files
58
+ * were written", so the probe runs inside a throwaway HOME/XDG sandbox that is
59
+ * deleted before returning. The same isolation is used for the install path:
60
+ * plan and apply must make the SAME decision, and a HOME-sensitive wrapper
61
+ * would otherwise let them disagree — the exact divergence the shared probe
62
+ * exists to prevent.
63
+ *
38
64
  * stderr is captured alongside stdout. A host that prints its version banner to
39
65
  * stderr and nothing to stdout would otherwise soft-fail to V1 — a wrong
40
66
  * answer whose cause has nothing to do with the host's generation.
41
67
  * @param {string} binary
68
+ * @param {number} [timeoutMs=HOST_PROBE_TIMEOUT_MS]
42
69
  * @returns {{stdout: string, stderr: string}}
43
70
  */
44
- function probeHostVersion(binary) {
45
- const result = spawnSync(binary, ['--version'], {
46
- encoding: 'utf8',
47
- timeout: 5000,
48
- stdio: ['ignore', 'pipe', 'pipe'],
49
- })
50
- if (result.error) throw result.error
51
- if (result.status !== 0) {
52
- throw new Error(`"${binary} --version" exited with status ${result.status}`)
71
+ function probeHostVersion(binary, timeoutMs = HOST_PROBE_TIMEOUT_MS) {
72
+ const sandbox = mkdtempSync(join(tmpdir(), 'pantheon-host-probe-'))
73
+ const env = {
74
+ ...process.env,
75
+ HOME: sandbox,
76
+ XDG_CONFIG_HOME: join(sandbox, '.config'),
77
+ XDG_CACHE_HOME: join(sandbox, '.cache'),
78
+ XDG_DATA_HOME: join(sandbox, '.local', 'share'),
79
+ XDG_STATE_HOME: join(sandbox, '.local', 'state'),
80
+ }
81
+ try {
82
+ const result = spawnSync(binary, ['--version'], {
83
+ encoding: 'utf8',
84
+ timeout: timeoutMs,
85
+ env,
86
+ stdio: ['ignore', 'pipe', 'pipe'],
87
+ })
88
+ if (result.error) throw result.error
89
+ if (result.status !== 0) {
90
+ throw new Error(`"${binary} --version" exited with status ${result.status}`)
91
+ }
92
+ return { stdout: result.stdout ?? '', stderr: result.stderr ?? '' }
93
+ } finally {
94
+ rmSync(sandbox, { recursive: true, force: true })
53
95
  }
54
- return { stdout: result.stdout ?? '', stderr: result.stderr ?? '' }
55
96
  }
56
97
 
57
98
  // A version-SHAPED token: optional "v", a major, a dot, a minor. The lookbehind
@@ -204,10 +245,22 @@ function parseHostMajor(text) {
204
245
  * worse than the V1 default, which at least still works. The fallback is only
205
246
  * tolerable because it warns; a silent v1 is what made this a silent failure.
206
247
  *
248
+ * Every fallback also reports through `onFallback`, so a caller (the dry-run
249
+ * preview) can tell the user its plan ASSUMED V1 instead of detecting it. A
250
+ * probe that succeeds never reports: only an unknown host does.
251
+ *
252
+ * A dry run probes too. It used to pass `skipProbe` and assume V1, which made
253
+ * `init --dry-run` describe the V1 plan on a V2 host (a target `tui.json` and a
254
+ * removed `index.ts`) while the apply wrote `index.ts` and no `tui.json`. The
255
+ * probe is `opencode --version` run inside a throwaway state directory (see
256
+ * `probeHostVersion`), and `probeTimeoutMs` bounds it.
257
+ *
207
258
  * @param {'v1'|'v2'|'auto'|null|undefined} requested
208
259
  * @param {{env?: Record<string, string|undefined>, binary?: string,
209
260
  * probe?: () => string|{stdout?: string, stderr?: string},
210
- * warn?: (message: string) => void}} [options]
261
+ * probeTimeoutMs?: number,
262
+ * warn?: (message: string) => void,
263
+ * onFallback?: (reason: 'probe-failed'|'unparseable'|'unreadable'|'ambiguous') => void}} [options]
211
264
  * @returns {'v1'|'v2'}
212
265
  */
213
266
  export function resolveOpenCodeVersion(requested = 'auto', options = {}) {
@@ -220,20 +273,29 @@ export function resolveOpenCodeVersion(requested = 'auto', options = {}) {
220
273
  return env.OPENCODE_VERSION
221
274
  }
222
275
  const binary = options.binary ?? env.OPENCODE_BIN ?? ''
276
+ const warn = options.warn ?? warning
223
277
  if (/(?:^|[\\/])opencode2(?:\.exe)?$/i.test(binary)) return 'v2'
224
278
 
225
- const probe = options.probe ?? (() => probeHostVersion(binary || 'opencode'))
226
- const warn = options.warn ?? warning
279
+ // One exit for every "we could not read the host" path: the warning and the
280
+ // caller notification can never drift apart.
281
+ const fallbackToV1 = (reason, message) => {
282
+ warn(message)
283
+ options.onFallback?.(reason)
284
+ return 'v1'
285
+ }
286
+
287
+ const probe =
288
+ options.probe ?? (() => probeHostVersion(binary || 'opencode', options.probeTimeoutMs))
227
289
  let raw
228
290
  try {
229
291
  raw = probe()
230
292
  } catch (err) {
231
- warn(
293
+ return fallbackToV1(
294
+ 'probe-failed',
232
295
  `Could not read the host OpenCode version (${err.message}). Falling back to the V1 ` +
233
296
  `configuration; if this host is OpenCode 2.x re-run with --opencode-version v2 ` +
234
297
  `(or v1 to force V1).`,
235
298
  )
236
- return 'v1'
237
299
  }
238
300
 
239
301
  // Accept both the real probe's {stdout, stderr} shape and a bare string, so a
@@ -252,38 +314,38 @@ export function resolveOpenCodeVersion(requested = 'auto', options = {}) {
252
314
  // A probe that RAN but whose output we cannot read is just as dangerous as
253
315
  // one that failed: silently landing on V1 is the bug this gate exists to
254
316
  // fix, so it gets the same visible warning.
255
- warn(
317
+ return fallbackToV1(
318
+ 'unparseable',
256
319
  `Could not parse the host OpenCode version from ` +
257
320
  `${JSON.stringify(`${streams.stdout}${streams.stderr}`.trim())}. ` +
258
321
  `Falling back to the V1 configuration; if this host is OpenCode 2.x re-run with ` +
259
322
  `--opencode-version v2 (or v1 to force V1).`,
260
323
  )
261
- return 'v1'
262
324
  }
263
325
  if (parsed.unreadable !== undefined) {
264
326
  // The host named itself and reported a major this gate refuses to read (0,
265
327
  // or a calendar year). That is not noise like a trailing build date — it is
266
328
  // the host's own version, so letting a surviving runtime token decide would
267
329
  // be a silent guess. Say what we saw and fall back loudly.
268
- warn(
330
+ return fallbackToV1(
331
+ 'unreadable',
269
332
  `The host OpenCode version output reports major ${parsed.unreadable}, which is ` +
270
333
  `not a release number this gate can interpret (a prerelease placeholder or a ` +
271
334
  `calendar year). Falling back to the V1 configuration; pass --opencode-version v2 ` +
272
335
  `if this host is OpenCode 2.x (or v1 to force V1).`,
273
336
  )
274
- return 'v1'
275
337
  }
276
338
  if (parsed.ambiguous) {
277
339
  // Version-shaped tokens that disagree, with no tool name to break the tie.
278
340
  // The reviewer accepted "wrong but loud" here; guessing silently is the
279
341
  // defect this branch exists to prevent.
280
- warn(
342
+ return fallbackToV1(
343
+ 'ambiguous',
281
344
  `The host OpenCode version output has contradictory versions ` +
282
345
  `(${parsed.ambiguous.map((major) => `major ${major}`).join(', ')}) and does not say ` +
283
346
  `which is the host's. Falling back to the V1 configuration; pass ` +
284
347
  `--opencode-version v2 if this host is OpenCode 2.x (or v1 to force V1).`,
285
348
  )
286
- return 'v1'
287
349
  }
288
350
  return parsed.major >= 2 ? 'v2' : 'v1'
289
351
  }