pantheon-opencode 1.5.0-beta.13 → 1.5.0-beta.15

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 (42) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/package.json +1 -1
  3. package/plugin.json +1 -1
  4. package/pyproject.toml +2 -5
  5. package/src/agents/zeus.md +4 -26
  6. package/src/pantheon/background-job-board.ts +4 -4
  7. package/src/pantheon/delegate-manager.ts +95 -10
  8. package/src/pantheon/delegation-classifier.ts +3 -4
  9. package/src/pantheon/delegation-finalize.ts +69 -7
  10. package/src/pantheon/delegation.ts +16 -4
  11. package/src/pantheon/presets.d.mts +0 -20
  12. package/src/pantheon/presets.mjs +0 -64
  13. package/src/pantheon/toon-codec.ts +1 -1
  14. package/src/plugin-v2.ts +4 -6
  15. package/src/plugin.ts +6 -6
  16. package/src/plugins/pantheon-hooks.ts +1 -1
  17. package/src/plugins/tui/dist/tui.d.ts +57 -40
  18. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  19. package/src/plugins/tui/dist/tui.js +145 -54
  20. package/src/plugins/tui/package-lock.json +2 -2
  21. package/src/plugins/tui/package.json +1 -1
  22. package/src/plugins/tui/src/index.tsx +245 -83
  23. package/src/routing.yml +0 -16
  24. package/scripts/hash_verify.py +0 -192
  25. package/scripts/test-context-compression.sh +0 -169
  26. package/src/pantheon/auto-wake.ts +0 -85
  27. package/src/pantheon/chat-reminders.ts +0 -9
  28. package/src/pantheon/comment-checker.ts +0 -48
  29. package/src/pantheon/compaction-assert.ts +0 -160
  30. package/src/pantheon/compaction-handoff.ts +0 -304
  31. package/src/pantheon/cost-tracker.ts +0 -108
  32. package/src/pantheon/dispatch-guard.ts +0 -109
  33. package/src/pantheon/permission-eval.ts +0 -284
  34. package/src/pantheon/preemptive-compact.ts +0 -76
  35. package/src/pantheon/provider-capabilities.ts +0 -221
  36. package/src/pantheon/provider-stream-tracker.ts +0 -182
  37. package/src/pantheon/retry-policy.ts +0 -212
  38. package/src/pantheon/token-opt.ts +0 -689
  39. package/src/pantheon/v2-events.ts +0 -148
  40. package/src/pantheon/v2-hooks.ts +0 -287
  41. package/src/pantheon/v2-tool-definitions.ts +0 -331
  42. package/src/pantheon/zeus-delegate-with-retry.ts +0 -406
@@ -1,331 +0,0 @@
1
- /**
2
- * V2 Tool Definitions — the 9 Pantheon orchestration tools adapted for the
3
- * V2 plugin API. Each tool wraps existing V1 infrastructure (delegation,
4
- * goal-loop, hashline, cost-command, model-command) into a unified
5
- * `{ name, description, input, execute }` shape compatible with V2's
6
- * `ctx.tool.transform()`.
7
- *
8
- * These definitions are PURE — they don't import any V1 plugin types.
9
- * The execute functions use a structural `ToolContextLike` surface that
10
- * both V1 and V2 can satisfy.
11
- *
12
- * @module pantheon/v2-tool-definitions
13
- */
14
-
15
- import type { z } from 'zod'
16
- import type { CostCommand } from './cost-command.ts'
17
- import type { DelegationToolset } from './delegation.ts'
18
- import type { GoalToolset } from './goal-loop.ts'
19
- import type { ModelToolset } from './model-command.ts'
20
-
21
- // ─── Structural Context ──────────────────────────────────────────────────
22
-
23
- /**
24
- * Minimal structural context passed to V2 tool execute functions.
25
- * Matches V1's ToolContextLike but avoids importing V1 types.
26
- */
27
- export interface V2ToolContext {
28
- sessionID: string
29
- directory?: string
30
- worktree?: string
31
- agent?: string
32
- }
33
-
34
- /**
35
- * A V2-compatible tool definition: name + description + JSON-Schema input
36
- * + async execute function.
37
- */
38
- export interface V2ToolDefinition {
39
- name: string
40
- description: string
41
- input: {
42
- type: 'object'
43
- properties: Record<string, unknown>
44
- required?: string[]
45
- }
46
- execute: (input: Record<string, unknown>, context: V2ToolContext) => Promise<string>
47
- }
48
-
49
- // ─── Zod → JSON-Schema Helpers ──────────────────────────────────────────
50
-
51
- /**
52
- * Convert a zod ZodRawShape to a minimal JSON-Schema properties object.
53
- * Uses safe introspection: checks for `.describe()` and basic shape keys.
54
- * Falls back to `{ type: "string" }` for unrecognizable schemas.
55
- */
56
- function zodShapeToJsonSchema(
57
- shape: z.ZodRawShape,
58
- required: string[] = [],
59
- ): { properties: Record<string, unknown>; required?: string[] } {
60
- const properties: Record<string, unknown> = {}
61
- for (const [key, schema] of Object.entries(shape)) {
62
- const prop: Record<string, unknown> = {}
63
-
64
- // Get description via .describe() if available
65
- try {
66
- const schemaAsObj = schema as unknown as Record<string, unknown>
67
- const describeFn = schemaAsObj.describe
68
- if (typeof describeFn === 'function') {
69
- const desc = (describeFn as () => string).call(schemaAsObj)
70
- if (typeof desc === 'string' && desc !== '') {
71
- prop.description = desc
72
- }
73
- }
74
- } catch {
75
- // Some zod types may throw on describe()
76
- }
77
-
78
- // Detect type from constructor name or _def.type (works across zod versions)
79
- const typeName = schema.constructor?.name ?? ''
80
- const defObj = (schema as unknown as { _def?: Record<string, unknown> })?._def
81
- const defType = (defObj?.typeName as string) ?? ''
82
-
83
- if (typeName.includes('ZodString') || defType === 'ZodString') {
84
- prop.type = 'string'
85
- } else if (typeName.includes('ZodNumber') || defType === 'ZodNumber') {
86
- prop.type = 'number'
87
- } else if (typeName.includes('ZodBoolean') || defType === 'ZodBoolean') {
88
- prop.type = 'boolean'
89
- } else if (typeName.includes('ZodEnum') || defType === 'ZodEnum') {
90
- prop.type = 'string'
91
- // Safely extract enum values
92
- try {
93
- const schemaObj = schema as unknown as Record<string, unknown>
94
- const defObj = schemaObj._def as Record<string, unknown> | undefined
95
- const values = (schemaObj.options ?? defObj?.values) as string[] | undefined
96
- if (Array.isArray(values)) prop.enum = values
97
- } catch {
98
- /* ignore */
99
- }
100
- } else if (typeName.includes('ZodArray') || defType === 'ZodArray') {
101
- prop.type = 'array'
102
- } else if (typeName.includes('ZodOptional') || defType === 'ZodOptional') {
103
- // Optional wrappers — treat as string by default
104
- prop.type = 'string'
105
- } else {
106
- prop.type = 'string'
107
- }
108
-
109
- properties[key] = prop
110
- }
111
-
112
- const result: { properties: Record<string, unknown>; required?: string[] } = { properties }
113
- if (required.length > 0) {
114
- result.required = required
115
- }
116
- return result
117
- }
118
-
119
- // ─── V2 Tool Factory ────────────────────────────────────────────────────
120
-
121
- export interface V2ToolFactoryDeps {
122
- delegation: DelegationToolset
123
- goalTools: GoalToolset
124
- costCommand: CostCommand
125
- modelCommand: ModelToolset
126
- }
127
-
128
- /**
129
- * Create all 9 V2 tool definitions from the V1 infrastructure.
130
- * These can be registered via `ctx.tool.transform()` or used directly.
131
- */
132
- export function createV2ToolDefinitions(deps: V2ToolFactoryDeps): V2ToolDefinition[] {
133
- const { delegation, goalTools, costCommand, modelCommand } = deps
134
-
135
- return [
136
- // 1. pantheon_delegate
137
- {
138
- name: 'pantheon_delegate',
139
- description: delegation.pantheon_delegate.description,
140
- input: {
141
- type: 'object',
142
- ...zodShapeToJsonSchema(delegation.pantheon_delegate.args as z.ZodRawShape, [
143
- 'prompt',
144
- 'agent',
145
- ]),
146
- },
147
- execute: async (input, ctx) => {
148
- return delegation.pantheon_delegate.execute(
149
- input as Parameters<typeof delegation.pantheon_delegate.execute>[0],
150
- ctx,
151
- )
152
- },
153
- },
154
-
155
- // 2. pantheon_delegation_read
156
- {
157
- name: 'pantheon_delegation_read',
158
- description: delegation.pantheon_delegation_read.description,
159
- input: {
160
- type: 'object',
161
- ...zodShapeToJsonSchema(delegation.pantheon_delegation_read.args as z.ZodRawShape, ['id']),
162
- },
163
- execute: async (input, ctx) => {
164
- return delegation.pantheon_delegation_read.execute(
165
- input as Parameters<typeof delegation.pantheon_delegation_read.execute>[0],
166
- ctx,
167
- )
168
- },
169
- },
170
-
171
- // 3. pantheon_delegation_list
172
- {
173
- name: 'pantheon_delegation_list',
174
- description: delegation.pantheon_delegation_list.description,
175
- input: {
176
- type: 'object',
177
- properties: {},
178
- },
179
- execute: async (input, ctx) => {
180
- return delegation.pantheon_delegation_list.execute(
181
- input as Parameters<typeof delegation.pantheon_delegation_list.execute>[0],
182
- ctx,
183
- )
184
- },
185
- },
186
-
187
- // 4. hashline_edit
188
- {
189
- name: 'hashline_edit',
190
- description:
191
- 'Edit a file anchored by hashline refs (LINE#TAG) instead of raw line numbers. ' +
192
- 'Ops: replace (ref..endRef or single ref → lines), append/prepend (anchor ref → content), ' +
193
- 'delete (ref..endRef). ALL refs must be validated against the ORIGINAL file before anything ' +
194
- 'is written; on mismatch the tool returns an error with a re-tagged excerpt and a ' +
195
- 'Did-you-mean suggestion, and nothing is modified.',
196
- input: {
197
- type: 'object',
198
- properties: {
199
- file: { type: 'string', description: 'Absolute path to the file to edit.' },
200
- edits: {
201
- type: 'array',
202
- description: 'List of edit operations to apply.',
203
- items: {
204
- type: 'object',
205
- properties: {
206
- op: {
207
- type: 'string',
208
- enum: ['replace', 'append', 'prepend', 'delete'],
209
- description: 'The edit operation.',
210
- },
211
- ref: {
212
- type: 'string',
213
- description: 'Anchor ref "LINE#TAG" against the ORIGINAL snapshot.',
214
- },
215
- endRef: {
216
- type: 'string',
217
- description: 'Optional range end for replace/delete ("LINE#TAG").',
218
- },
219
- lines: {
220
- type: 'array',
221
- items: { type: 'string' },
222
- description: 'Replacement lines (replace).',
223
- },
224
- content: {
225
- type: 'string',
226
- description: 'Text to insert (append/prepend; split on newlines).',
227
- },
228
- },
229
- required: ['op', 'ref'],
230
- },
231
- },
232
- },
233
- required: ['file', 'edits'],
234
- },
235
- execute: async (input, ctx) => {
236
- // hashline_edit uses a different execute signature — it takes (args, toolContext)
237
- // where toolContext includes sessionID, directory, worktree
238
- const { createHashlineEditTool } = await import('./hashline/tool.ts')
239
- const tool = createHashlineEditTool()
240
- const result = await tool.execute(
241
- input as Parameters<typeof tool.execute>[0],
242
- ctx as Parameters<typeof tool.execute>[1],
243
- )
244
- if (typeof result === 'string') return result
245
- return result.output
246
- },
247
- },
248
-
249
- // 5. pantheon_goal_create
250
- {
251
- name: 'pantheon_goal_create',
252
- description: goalTools.pantheon_goal_create.description,
253
- input: {
254
- type: 'object',
255
- ...zodShapeToJsonSchema(goalTools.pantheon_goal_create.args as z.ZodRawShape, [
256
- 'objective',
257
- ]),
258
- },
259
- execute: async (input, ctx) => {
260
- return goalTools.pantheon_goal_create.execute(
261
- input as Parameters<typeof goalTools.pantheon_goal_create.execute>[0],
262
- ctx,
263
- )
264
- },
265
- },
266
-
267
- // 6. pantheon_goal_get
268
- {
269
- name: 'pantheon_goal_get',
270
- description: goalTools.pantheon_goal_get.description,
271
- input: {
272
- type: 'object',
273
- properties: {},
274
- },
275
- execute: async (input, ctx) => {
276
- return goalTools.pantheon_goal_get.execute(
277
- input as Parameters<typeof goalTools.pantheon_goal_get.execute>[0],
278
- ctx,
279
- )
280
- },
281
- },
282
-
283
- // 7. pantheon_goal_update
284
- {
285
- name: 'pantheon_goal_update',
286
- description: goalTools.pantheon_goal_update.description,
287
- input: {
288
- type: 'object',
289
- ...zodShapeToJsonSchema(goalTools.pantheon_goal_update.args as z.ZodRawShape),
290
- },
291
- execute: async (input, ctx) => {
292
- return goalTools.pantheon_goal_update.execute(
293
- input as Parameters<typeof goalTools.pantheon_goal_update.execute>[0],
294
- ctx,
295
- )
296
- },
297
- },
298
-
299
- // 8. pantheon_cost
300
- {
301
- name: 'pantheon_cost',
302
- description: costCommand.pantheon_cost.description,
303
- input: {
304
- type: 'object',
305
- ...zodShapeToJsonSchema(costCommand.pantheon_cost.args as z.ZodRawShape),
306
- },
307
- execute: async (input, ctx) => {
308
- return costCommand.pantheon_cost.execute(
309
- input as Parameters<typeof costCommand.pantheon_cost.execute>[0],
310
- ctx,
311
- )
312
- },
313
- },
314
-
315
- // 9. pantheon_model
316
- {
317
- name: 'pantheon_model',
318
- description: modelCommand.pantheon_model.description,
319
- input: {
320
- type: 'object',
321
- ...zodShapeToJsonSchema(modelCommand.pantheon_model.args as z.ZodRawShape),
322
- },
323
- execute: async (input, ctx) => {
324
- return modelCommand.pantheon_model.execute(
325
- input as Parameters<typeof modelCommand.pantheon_model.execute>[0],
326
- ctx,
327
- )
328
- },
329
- },
330
- ]
331
- }