pantheon-opencode 1.6.0-beta.9 → 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 (131) hide show
  1. package/AGENTS.global.md +118 -0
  2. package/AGENTS.md +18 -168
  3. package/CHANGELOG.md +126 -376
  4. package/README.md +83 -610
  5. package/README.pt-BR.md +120 -345
  6. package/bin/pantheon-init.mjs +366 -132
  7. package/commands/pantheon-deepwork.md +14 -3
  8. package/commands/pantheon-vision.md +61 -12
  9. package/package.json +19 -11
  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 +828 -40
  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 +78 -383
  29. package/scripts/install/migrate.mjs +49 -25
  30. package/scripts/install/model-picker.mjs +218 -250
  31. package/scripts/install/opencode-version.mjs +83 -21
  32. package/scripts/install/opencode.mjs +1413 -154
  33. package/scripts/install/plan-artifact.mjs +517 -0
  34. package/scripts/install/plan.mjs +475 -0
  35. package/scripts/install/plugin.mjs +214 -27
  36. package/scripts/install/prompt-result.mjs +2 -0
  37. package/scripts/install/shared.mjs +256 -99
  38. package/scripts/install/state.mjs +63 -8
  39. package/scripts/install/strings.mjs +60 -4
  40. package/scripts/install/venv.mjs +90 -47
  41. package/scripts/install/verify.mjs +128 -0
  42. package/scripts/install/vision-prompt.mjs +173 -0
  43. package/scripts/install-mcp.mjs +2 -2
  44. package/scripts/manifest-inventory.mjs +49 -3
  45. package/scripts/mcp_persistence.py +1535 -1050
  46. package/scripts/memory_mcp.py +12 -843
  47. package/scripts/node-engine-policy.mjs +85 -0
  48. package/scripts/package-evidence.mjs +10 -2
  49. package/scripts/postinstall.mjs +26 -26
  50. package/scripts/probe-pantheon-cost.mjs +118 -19
  51. package/scripts/prune.mjs +9 -3
  52. package/scripts/reconcile.mjs +325 -0
  53. package/scripts/release-gates.mjs +682 -0
  54. package/scripts/restore.mjs +222 -0
  55. package/scripts/run-node-tests.mjs +24 -8
  56. package/scripts/sync-artifacts.mjs +19 -7
  57. package/scripts/sync-tui.mjs +5 -1
  58. package/scripts/test-opencode-v2-sandbox.sh +36 -123
  59. package/scripts/uninstall.mjs +369 -34
  60. package/scripts/update.mjs +164 -0
  61. package/scripts/validate-node-engine-policy.mjs +13 -0
  62. package/scripts/version-check.mjs +34 -1
  63. package/scripts/versioning.mjs +23 -3
  64. package/scripts/vision-status.mjs +682 -0
  65. package/skills-lock.json +8 -8
  66. package/src/agents/aphrodite.md +13 -10
  67. package/src/agents/apollo.md +4 -5
  68. package/src/agents/athena.md +74 -46
  69. package/src/agents/demeter.md +10 -7
  70. package/src/agents/gaia.md +0 -1
  71. package/src/agents/hephaestus.md +4 -3
  72. package/src/agents/hermes.md +10 -9
  73. package/src/agents/iris.md +6 -1
  74. package/src/agents/mnemosyne.md +10 -4
  75. package/src/agents/nyx.md +4 -4
  76. package/src/agents/prometheus.md +12 -11
  77. package/src/agents/talos.md +6 -0
  78. package/src/agents/zeus.md +84 -56
  79. package/src/instructions/agent-return-format.instructions.md +12 -41
  80. package/src/instructions/memory-protocol.instructions.md +5 -11
  81. package/src/instructions/test-economy.instructions.md +12 -0
  82. package/src/instructions/yagni.instructions.md +6 -15
  83. package/src/instructions/zeus-anti-stall.instructions.md +6 -6
  84. package/src/instructions/zeus-communication-rules.instructions.md +6 -6
  85. package/src/instructions/zeus-council-synthesis.instructions.md +11 -12
  86. package/src/instructions/zeus-memory-operations.instructions.md +13 -7
  87. package/src/instructions/zeus-timeout-retry.instructions.md +36 -10
  88. package/src/mcp/_pantheon_paths.py +24 -0
  89. package/src/mcp/mcp_codemap_module.py +86 -18
  90. package/src/mcp/mcp_persistence.py +1535 -1050
  91. package/src/mcp/memory_mcp.py +444 -94
  92. package/src/mcp/pantheon_vision.py +285 -41
  93. package/src/mcp/requirements-mcp.txt +5 -0
  94. package/src/pantheon/context-pruner.ts +541 -0
  95. package/src/pantheon/cost-command.ts +814 -60
  96. package/src/pantheon/goal-loop.ts +11 -8
  97. package/src/pantheon/memory-context.ts +1017 -0
  98. package/src/pantheon/model-agents.ts +19 -0
  99. package/src/pantheon/model-command.ts +218 -56
  100. package/src/pantheon/model-pricing.ts +536 -0
  101. package/src/pantheon/presets.mjs +2 -0
  102. package/src/pantheon/task-result-guard.ts +50 -14
  103. package/src/pantheon/v2-bounded-read.ts +640 -0
  104. package/src/pantheon/v2-delegation-enforce.ts +133 -6
  105. package/src/pantheon/v2-execute-after.ts +135 -24
  106. package/src/pantheon/v2-model-overrides.ts +275 -0
  107. package/src/pantheon/v2-tools.ts +89 -35
  108. package/src/pantheon/v2-unsupported.mjs +2 -3
  109. package/src/pantheon/v2-vision.ts +622 -0
  110. package/src/pantheon/vision-local.ts +531 -0
  111. package/src/pantheon/vision.ts +1160 -115
  112. package/src/plugin-v2.ts +654 -162
  113. package/src/plugin.ts +15 -11
  114. package/src/plugins/tui/dist/tui-v2.d.ts +1029 -2
  115. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  116. package/src/plugins/tui/dist/tui-v2.js +3742 -85
  117. package/src/plugins/tui/dist/tui.js +1 -1
  118. package/src/plugins/tui/package-lock.json +6 -6
  119. package/src/plugins/tui/package.json +5 -4
  120. package/src/plugins/tui/src/index-v2.tsx +4314 -50
  121. package/src/plugins/tui/tsconfig.typecheck.json +5 -0
  122. package/src/routing.yml +50 -5
  123. package/src/skills/agent-coordination/SKILL.md +7 -2
  124. package/src/skills/artifact-management/SKILL.md +5 -1
  125. package/src/skills/auto-continue/SKILL.md +14 -6
  126. package/src/skills/codemap/SKILL.md +1 -1
  127. package/src/skills/memory-bank/SKILL.md +21 -13
  128. package/src/skills/session-goal/SKILL.md +12 -22
  129. package/src/skills/spec-driven-development/SKILL.md +3 -1
  130. package/src/skills/worktrees/SKILL.md +30 -11
  131. package/scripts/probe-context-rehydrate.mjs +0 -263
@@ -2,7 +2,7 @@
2
2
  * V2 tool surface — the Pantheon tools that are self-sufficient on the
3
3
  * OpenCode V2 host, declared for `ctx.tool.transform`'s `draft.add`.
4
4
  *
5
- * ## Why only three tools
5
+ * ## Why only three unconditional tools
6
6
  *
7
7
  * A V2 tool can only be served here when it needs no V1 infrastructure. The
8
8
  * three goal tools (`pantheon_goal_create`, `pantheon_goal_get`,
@@ -18,6 +18,15 @@
18
18
  * `pantheon_model` (reads/writes `active-preset.json`) need none of that, so
19
19
  * they are wired to their real V1 implementations.
20
20
  *
21
+ * ## Three unconditional tools, up to two host-dependent ones
22
+ *
23
+ * The three above are always built. Two more exist on the V2 host and are
24
+ * conditional: `vision_describe` is added here when the caller supplies a
25
+ * vision runtime (the host model catalog), and `pantheon_bounded_read` is
26
+ * appended by the plugin when the host exposes its permission and session APIs
27
+ * (root Zeus sessions only). The effective count is therefore 3 unconditional
28
+ * plus up to 2 host-dependent — never a flat 3.
29
+ *
21
30
  * ## The output declaration is mandatory
22
31
  *
23
32
  * The host enforces a biconditional between a tool's declared `output` and the
@@ -40,6 +49,7 @@ import { createCostCommand } from './cost-command.ts'
40
49
  import { createHashlineEditTool, type HashlineToolResult } from './hashline/tool.ts'
41
50
  import { createModelCommand } from './model-command.ts'
42
51
  import type { ToolContextLike } from './tool-context.ts'
52
+ import { createV2VisionTool, type V2VisionRuntime } from './v2-vision.ts'
43
53
 
44
54
  // ─── Contract types ─────────────────────────────────────────────────────
45
55
 
@@ -283,6 +293,17 @@ const COST_INPUT: Record<string, unknown> = {
283
293
  maximum: 365,
284
294
  description: 'Reporting window in days (default 7).',
285
295
  },
296
+ session: {
297
+ type: 'string',
298
+ minLength: 1,
299
+ description:
300
+ 'Root session id. The report is scoped to that session plus every descendant session in its subtree.',
301
+ },
302
+ refreshPricing: {
303
+ type: 'boolean',
304
+ description:
305
+ 'Await a models.dev price refresh (bounded by a short timeout) instead of using the cached catalog. This is the only path that waits on the network.',
306
+ },
286
307
  },
287
308
  }
288
309
 
@@ -295,6 +316,28 @@ function coerceDays(value: unknown): { ok: true; days?: number } | { ok: false;
295
316
  return { ok: true, days: value }
296
317
  }
297
318
 
319
+ /** Validate `session` exactly as the V1 zod schema does; absent means no scope. */
320
+ function coerceSession(
321
+ value: unknown,
322
+ ): { ok: true; session?: string } | { ok: false; error: string } {
323
+ if (value === undefined) return { ok: true }
324
+ if (typeof value !== 'string' || value.length === 0) {
325
+ return { ok: false, error: 'pantheon_cost: "session" must be a non-empty string' }
326
+ }
327
+ return { ok: true, session: value }
328
+ }
329
+
330
+ /** Validate `refreshPricing` exactly as the V1 zod schema does; absent means cached. */
331
+ function coerceRefreshPricing(
332
+ value: unknown,
333
+ ): { ok: true; refreshPricing?: boolean } | { ok: false; error: string } {
334
+ if (value === undefined) return { ok: true }
335
+ if (typeof value !== 'boolean') {
336
+ return { ok: false, error: 'pantheon_cost: "refreshPricing" must be a boolean' }
337
+ }
338
+ return { ok: true, refreshPricing: value }
339
+ }
340
+
298
341
  const costCommand = createCostCommand()
299
342
 
300
343
  async function executeCost(
@@ -303,14 +346,29 @@ async function executeCost(
303
346
  ): Promise<V2ToolResult> {
304
347
  const days = coerceDays(input.days)
305
348
  if (!days.ok) return { output: days.error }
349
+ const session = coerceSession(input.session)
350
+ if (!session.ok) return { output: session.error }
351
+ const refreshPricing = coerceRefreshPricing(input.refreshPricing)
352
+ if (!refreshPricing.ok) return { output: refreshPricing.error }
353
+ // Every accepted option is forwarded: a schema the host validates but the
354
+ // wrapper drops would be a tool that silently ignores its own arguments.
306
355
  // The V1 tool already wraps its whole body and reports failures as text.
307
- const output = await costCommand.pantheon_cost.execute({ days: days.days }, toolContext(context))
356
+ const output = await costCommand.pantheon_cost.execute(
357
+ {
358
+ ...(days.days === undefined ? {} : { days: days.days }),
359
+ ...(session.session === undefined ? {} : { session: session.session }),
360
+ ...(refreshPricing.refreshPricing === undefined
361
+ ? {}
362
+ : { refreshPricing: refreshPricing.refreshPricing }),
363
+ },
364
+ toolContext(context),
365
+ )
308
366
  return { output }
309
367
  }
310
368
 
311
369
  // ─── pantheon_model ─────────────────────────────────────────────────────
312
370
 
313
- /** JSON Schema for `pantheon_model`, mirroring the V1 zod args. */
371
+ /** JSON Schema for V2 `pantheon_model`; global scope is intentionally absent. */
314
372
  const MODEL_INPUT: Record<string, unknown> = {
315
373
  type: 'object',
316
374
  additionalProperties: false,
@@ -329,39 +387,27 @@ const MODEL_INPUT: Record<string, unknown> = {
329
387
  },
330
388
  scope: {
331
389
  type: 'string',
332
- enum: ['project', 'global'],
333
- description: 'Scope for active-preset.json (default project).',
334
- },
335
- confirm: {
336
- type: 'boolean',
337
- description: 'Explicit confirmation for a mutating operation; required for global changes.',
338
- },
339
- authorize_global: {
340
- type: 'boolean',
341
- description: 'Separate authorization for global configuration; not implied by confirm.',
390
+ enum: ['project'],
391
+ description: 'Project scope only; global overrides are not supported in V2.',
342
392
  },
343
393
  },
344
394
  }
345
395
 
346
- const WIZARD_UNAVAILABLE =
347
- 'the interactive wizard has no user in the V2 tool surface — pass action="status" to read ' +
348
- 'the current overrides, or pass agent and model explicitly for action="set"'
349
-
350
- /**
351
- * The V1 command falls back to an interactive readline prompt when invoked
352
- * with no arguments. A tool call has no user at the terminal, so that fallback
353
- * would block the call until it timed out. `ask` is injected to refuse
354
- * deterministically instead, which routes through the command's own
355
- * `wizard canceled` error path rather than forking its logic.
356
- */
357
- const modelCommand = createModelCommand({
358
- ask: () => Promise.reject(new Error(WIZARD_UNAVAILABLE)),
359
- })
396
+ const modelCommand = createModelCommand({ v2Mode: true })
360
397
 
361
398
  async function executeModel(
362
399
  input: Record<string, unknown>,
363
400
  context: unknown,
364
401
  ): Promise<V2ToolResult> {
402
+ if (input.scope !== undefined && input.scope !== 'project') {
403
+ return { output: 'Error: V2 pantheon_model is project-only; global scope is not supported.' }
404
+ }
405
+ if (Object.hasOwn(input, 'confirm') || Object.hasOwn(input, 'authorize_global')) {
406
+ return {
407
+ output:
408
+ 'Error: V2 pantheon_model does not accept authorization flags; global authorization is not supported by this tool.',
409
+ }
410
+ }
365
411
  // The V1 tool validates its own args (zod) and reports failures as text.
366
412
  const output = await modelCommand.pantheon_model.execute(
367
413
  input as Parameters<typeof modelCommand.pantheon_model.execute>[0],
@@ -388,8 +434,8 @@ async function executeModel(
388
434
  * performs filesystem or database work at construction, so importing this
389
435
  * module stays side-effect free.
390
436
  */
391
- export function createV2ToolDefinitions(): V2ToolDef[] {
392
- return [
437
+ export function createV2ToolDefinitions(visionRuntime?: V2VisionRuntime): V2ToolDef[] {
438
+ const definitions: V2ToolDef[] = [
393
439
  {
394
440
  name: 'hashline_edit',
395
441
  description:
@@ -405,8 +451,13 @@ export function createV2ToolDefinitions(): V2ToolDef[] {
405
451
  {
406
452
  name: 'pantheon_cost',
407
453
  description:
408
- 'Report input, output, and total token usage by agent and phase over the last N days, ' +
409
- 'read from opencode.db (read-only, no monetary values).',
454
+ 'Report token usage and USD cost by agent and phase, by model, and by session, over the ' +
455
+ 'last N days from opencode.db (read-only). Costs come from the models.dev catalog cached ' +
456
+ 'on disk: a call reads that cache and never waits on the network unless refreshPricing is ' +
457
+ 'set, a stale cache is refreshed in the background and the report says so, and an unpriced ' +
458
+ 'model reads — and is excluded from the totals, which then say partial. Pass session=<root ' +
459
+ 'session id> to aggregate that session plus its descendant sessions. Phase may be unknown ' +
460
+ 'on V2; costs are catalog list prices, not an invoice.',
410
461
  input: COST_INPUT,
411
462
  output: {},
412
463
  execute: executeCost,
@@ -414,13 +465,16 @@ export function createV2ToolDefinitions(): V2ToolDef[] {
414
465
  {
415
466
  name: 'pantheon_model',
416
467
  description:
417
- 'Show, set, or reset per-agent model overrides in active-preset.json (project or global). ' +
418
- 'Overrides win over preset; env preset wins over file. Never writes .env or top-level ' +
419
- 'model/small_model. Pass action="status" to read the current overrides; unlike the V1 ' +
420
- 'command there is no interactive wizard on this surface.',
468
+ 'Show, set, or reset explicit per-agent project-scoped model overrides in active-preset.json. ' +
469
+ 'V2 ignores static preset names and PANTHEON_MODEL_PRESET; no wizard or implicit model ' +
470
+ 'selection. Global overrides are not read or written in V2; future global support requires ' +
471
+ 'separate explicit authorization. Pass action="status" to read project-scoped overrides. ' +
472
+ 'Never writes .env or top-level model/small_model.',
421
473
  input: MODEL_INPUT,
422
474
  output: {},
423
475
  execute: executeModel,
424
476
  },
425
477
  ]
478
+ if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime))
479
+ return definitions
426
480
  }
@@ -21,9 +21,8 @@
21
21
  * So a `.mjs` import is the only form all three consumers can share, and it
22
22
  * matches the existing `src/pantheon/presets.mjs` + `.d.mts` precedent.
23
23
  *
24
- * NOT the reason: type-stripping. `package.json#engines` admits
25
- * `^22.22.2 || ^24.15.0 || >=26.0.0`, every admitted version already defaults to
26
- * unflagged type-stripping (it landed in 22.18.0), so that argument would not
24
+ * NOT the reason: type-stripping. `package.json#engines` admits Node >=26.4.0,
25
+ * which defaults to unflagged type-stripping (it landed in 22.18.0), so that argument would not
27
26
  * have held on any admitted version. The live hazard is that `engines` is not
28
27
  * ENFORCED: a Node 20 user can run `doctor` and would get no type-stripping,
29
28
  * which is an argument for a runtime version check, not for this file's shape.