pantheon-opencode 2.1.4 → 2.1.6
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.
- package/AGENTS.global.md +6 -6
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +52 -0
- package/README.md +60 -233
- package/README.pt-BR.md +64 -220
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/pyproject.toml +1 -1
- package/scripts/install/opencode.mjs +12 -0
- package/scripts/test-slice.mjs +34 -2
- package/skills-lock.json +1 -1
- package/src/agents/aphrodite.md +3 -1
- package/src/agents/apollo.md +1 -0
- package/src/agents/athena.md +1 -0
- package/src/agents/demeter.md +2 -0
- package/src/agents/gaia.md +1 -0
- package/src/agents/hephaestus.md +1 -0
- package/src/agents/hermes.md +2 -1
- package/src/agents/iris.md +1 -0
- package/src/agents/mnemosyne.md +1 -0
- package/src/agents/nyx.md +1 -0
- package/src/agents/prometheus.md +1 -0
- package/src/agents/talos.md +1 -0
- package/src/agents/themis.md +1 -0
- package/src/agents/zeus.md +8 -2
- package/src/instructions/backend-standards.instructions.md +5 -0
- package/src/instructions/test-economy.instructions.md +6 -6
- package/src/mcp/pantheon_vision.py +4 -1
- package/src/pantheon/auto-permissions.ts +4 -3
- package/src/pantheon/deepwork/deepwork-tool.ts +23 -75
- package/src/pantheon/deepwork/plan-schema.ts +4 -2
- package/src/pantheon/deepwork/plan-tracker.ts +380 -90
- package/src/pantheon/jev-decision-tool.ts +1 -7
- package/src/pantheon/local-decision-tool.ts +1 -1
- package/src/pantheon/native-vision.ts +1 -1
- package/src/pantheon/skill-search-tool.ts +241 -47
- package/src/pantheon/tool-context.ts +23 -0
- package/src/pantheon/tools.ts +46 -41
- package/src/plugin/index.js +521 -222
- package/src/plugin.ts +1 -0
- package/src/plugins/tui/dist/tui.d.ts +7 -6
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +198 -269
- package/src/plugins/tui/dist/tui.js.map +1 -1
- package/src/plugins/tui/package-lock.json +2 -2
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index.tsx +7 -45
- package/src/plugins/tui/src/tui-prefs.ts +3 -9
- package/src/skills/test-slicing/SKILL.md +14 -8
|
@@ -14,9 +14,13 @@
|
|
|
14
14
|
* @module pantheon/skill-search-tool
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
18
|
+
import { homedir } from 'node:os'
|
|
19
|
+
import { join } from 'node:path'
|
|
17
20
|
// @ts-expect-error scripts/skill-search.mjs is a plain Node ESM script without bundled .d.ts
|
|
18
21
|
import { searchSkillSources } from '../../scripts/skill-search.mjs'
|
|
19
22
|
import { PANTHEON_SKILL_CATALOG } from './pantheon-decision-catalog.ts'
|
|
23
|
+
import { resolveToolCwd } from './tool-context.ts'
|
|
20
24
|
import type { V2ToolDef } from './tools.ts'
|
|
21
25
|
|
|
22
26
|
export interface SkillSearchResult {
|
|
@@ -27,6 +31,101 @@ export interface SkillSearchResult {
|
|
|
27
31
|
readonly installs?: number | null
|
|
28
32
|
readonly url?: string
|
|
29
33
|
readonly installCommand?: string | null
|
|
34
|
+
readonly path?: string | null
|
|
35
|
+
readonly scope?: 'internal' | 'project' | 'global'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface InstalledSkillRecord {
|
|
39
|
+
readonly id: string
|
|
40
|
+
readonly description: string
|
|
41
|
+
readonly path: string
|
|
42
|
+
readonly scope: 'internal' | 'project' | 'global'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function extractSkillMetadata(
|
|
46
|
+
content: string,
|
|
47
|
+
fallbackName: string,
|
|
48
|
+
): { name: string; description: string } {
|
|
49
|
+
let name = fallbackName
|
|
50
|
+
let description = ''
|
|
51
|
+
const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/)
|
|
52
|
+
const yaml = fmMatch?.[1]
|
|
53
|
+
if (yaml) {
|
|
54
|
+
const nameMatch = yaml.match(/^name:\s*["']?([^"'\r\n]+)["']?/m)
|
|
55
|
+
if (nameMatch?.[1]) name = nameMatch[1].trim()
|
|
56
|
+
const descMatch = yaml.match(/^description:\s*["']?([^"'\r\n]+)["']?/m)
|
|
57
|
+
if (descMatch?.[1]) description = descMatch[1].trim()
|
|
58
|
+
}
|
|
59
|
+
if (!description) {
|
|
60
|
+
const withoutFm = content.replace(/^---\r?\n[\s\S]*?\r?\n---/, '').trim()
|
|
61
|
+
const lines = withoutFm.split('\n')
|
|
62
|
+
for (const l of lines) {
|
|
63
|
+
const trimmed = l.trim()
|
|
64
|
+
if (trimmed && !trimmed.startsWith('#')) {
|
|
65
|
+
description = trimmed.slice(0, 160)
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { name, description }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function scanInstalledSkills(
|
|
74
|
+
cwd: string = process.cwd(),
|
|
75
|
+
): Map<string, InstalledSkillRecord> {
|
|
76
|
+
const map = new Map<string, InstalledSkillRecord>()
|
|
77
|
+
|
|
78
|
+
// 1. Built-in Pantheon catalog (internal base)
|
|
79
|
+
for (const entry of PANTHEON_SKILL_CATALOG) {
|
|
80
|
+
map.set(entry.id.toLowerCase(), {
|
|
81
|
+
id: entry.id,
|
|
82
|
+
description: entry.description,
|
|
83
|
+
path: `src/skills/${entry.id}/SKILL.md`,
|
|
84
|
+
scope: 'internal',
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const scanDir = (baseDir: string, scope: 'project' | 'global') => {
|
|
89
|
+
try {
|
|
90
|
+
if (!existsSync(baseDir)) return
|
|
91
|
+
const entries = readdirSync(baseDir, { withFileTypes: true })
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue
|
|
94
|
+
const skillName = entry.name
|
|
95
|
+
if (skillName.startsWith('.')) continue
|
|
96
|
+
const skillMd = join(baseDir, skillName, 'SKILL.md')
|
|
97
|
+
if (existsSync(skillMd)) {
|
|
98
|
+
try {
|
|
99
|
+
const raw = readFileSync(skillMd, 'utf8')
|
|
100
|
+
const { name, description } = extractSkillMetadata(raw, skillName)
|
|
101
|
+
const id = (name || skillName).trim()
|
|
102
|
+
map.set(id.toLowerCase(), {
|
|
103
|
+
id,
|
|
104
|
+
description: description || skillName,
|
|
105
|
+
path: skillMd,
|
|
106
|
+
scope,
|
|
107
|
+
})
|
|
108
|
+
} catch {
|
|
109
|
+
// ignore unreadable files
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
// ignore directory errors
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 2. Global directories
|
|
119
|
+
const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), '.config')
|
|
120
|
+
scanDir(join(xdgConfig, 'opencode', 'skills'), 'global')
|
|
121
|
+
scanDir(join(homedir(), '.agents', 'skills'), 'global')
|
|
122
|
+
|
|
123
|
+
// 3. Project directories (override global/internal)
|
|
124
|
+
scanDir(join(cwd, '.opencode', 'skills'), 'project')
|
|
125
|
+
scanDir(join(cwd, '.agents', 'skills'), 'project')
|
|
126
|
+
scanDir(join(cwd, 'skills'), 'project')
|
|
127
|
+
|
|
128
|
+
return map
|
|
30
129
|
}
|
|
31
130
|
|
|
32
131
|
export interface SkillSearchOutput {
|
|
@@ -74,7 +173,76 @@ const SKILL_SEARCH_INPUT_SCHEMA: Record<string, unknown> = {
|
|
|
74
173
|
},
|
|
75
174
|
}
|
|
76
175
|
|
|
77
|
-
export
|
|
176
|
+
export interface SkillScore {
|
|
177
|
+
readonly score: number
|
|
178
|
+
readonly matchedTokens: number
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Score relevance of a skill against query tokens.
|
|
183
|
+
*
|
|
184
|
+
* Uses word-boundary and segment matching with tiered weighting:
|
|
185
|
+
* - Exact ID match: 20 pts
|
|
186
|
+
* - Exact segment match in hyphenated/slashed ID: 12 pts
|
|
187
|
+
* - Prefix match on ID segment (>=4 chars): 6 pts
|
|
188
|
+
* - Exact word match in description: 5 pts
|
|
189
|
+
* - Prefix match on description word (>=4 chars): 2 pts
|
|
190
|
+
* - Multi-token synergy bonus: + (matchedTokens * 5) pts
|
|
191
|
+
*
|
|
192
|
+
* Substrings inside words (e.g. "rate" inside "generates" or "migrate")
|
|
193
|
+
* receive ZERO points, completely eliminating false-positive lexical bleed.
|
|
194
|
+
*/
|
|
195
|
+
export function scoreSkillMatch(
|
|
196
|
+
id: string,
|
|
197
|
+
description: string,
|
|
198
|
+
queryTokens: readonly string[],
|
|
199
|
+
): SkillScore {
|
|
200
|
+
const idLower = id.toLowerCase()
|
|
201
|
+
const descLower = description.toLowerCase()
|
|
202
|
+
const idTokens = idLower.split(/[^a-z0-9]+/).filter(Boolean)
|
|
203
|
+
const descWords = descLower.split(/[^a-z0-9]+/).filter(Boolean)
|
|
204
|
+
|
|
205
|
+
let score = 0
|
|
206
|
+
let matchedTokens = 0
|
|
207
|
+
|
|
208
|
+
for (const t of queryTokens) {
|
|
209
|
+
let tokenScore = 0
|
|
210
|
+
|
|
211
|
+
if (idLower === t) {
|
|
212
|
+
tokenScore += 20
|
|
213
|
+
} else if (idTokens.includes(t)) {
|
|
214
|
+
tokenScore += 12
|
|
215
|
+
} else if (
|
|
216
|
+
idTokens.some((w) => w.length >= 4 && t.length >= 4 && (w.startsWith(t) || t.startsWith(w)))
|
|
217
|
+
) {
|
|
218
|
+
tokenScore += 6
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (descWords.includes(t)) {
|
|
222
|
+
tokenScore += 5
|
|
223
|
+
} else if (
|
|
224
|
+
descWords.some((w) => w.length >= 4 && t.length >= 4 && (w.startsWith(t) || t.startsWith(w)))
|
|
225
|
+
) {
|
|
226
|
+
tokenScore += 2
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (tokenScore > 0) {
|
|
230
|
+
score += tokenScore
|
|
231
|
+
matchedTokens += 1
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (matchedTokens > 1) {
|
|
236
|
+
score += matchedTokens * 5
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return { score, matchedTokens }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function executeSkillSearch(
|
|
243
|
+
input: Record<string, unknown>,
|
|
244
|
+
options: { cwd?: string } = {},
|
|
245
|
+
): SkillSearchOutput {
|
|
78
246
|
const query = typeof input.query === 'string' ? input.query.trim() : ''
|
|
79
247
|
if (query.length === 0) {
|
|
80
248
|
return { ok: false, query: '', count: 0, results: [], failures: ['query must be non-empty'] }
|
|
@@ -94,43 +262,35 @@ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchO
|
|
|
94
262
|
],
|
|
95
263
|
)
|
|
96
264
|
|
|
97
|
-
const results: SkillSearchResult[] = []
|
|
98
265
|
const failures: string[] = []
|
|
99
266
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
description: entry.description,
|
|
128
|
-
source: 'installed',
|
|
129
|
-
installed: true,
|
|
130
|
-
installs: null,
|
|
131
|
-
installCommand: null,
|
|
132
|
-
})
|
|
133
|
-
}
|
|
267
|
+
const cwd = options.cwd ?? process.cwd()
|
|
268
|
+
const installedMap = scanInstalledSkills(cwd)
|
|
269
|
+
|
|
270
|
+
const tokens = query
|
|
271
|
+
.toLowerCase()
|
|
272
|
+
.split(/[^a-z0-9]+/)
|
|
273
|
+
.filter((t) => t.length > 1)
|
|
274
|
+
|
|
275
|
+
const scoredResults: Array<SkillSearchResult & { score: number }> = []
|
|
276
|
+
|
|
277
|
+
// 1. Tier 1: Installed skills (Pantheon catalog + local filesystem .opencode/skills and .agents/skills)
|
|
278
|
+
if (sources.has('installed') && tokens.length > 0) {
|
|
279
|
+
const minThreshold = tokens.length > 1 ? 5 : 2
|
|
280
|
+
for (const entry of installedMap.values()) {
|
|
281
|
+
const { score } = scoreSkillMatch(entry.id, entry.description, tokens)
|
|
282
|
+
if (score >= minThreshold) {
|
|
283
|
+
scoredResults.push({
|
|
284
|
+
skill: entry.id,
|
|
285
|
+
description: entry.description,
|
|
286
|
+
source: 'installed',
|
|
287
|
+
installed: true,
|
|
288
|
+
installs: null,
|
|
289
|
+
installCommand: null,
|
|
290
|
+
path: entry.path,
|
|
291
|
+
scope: entry.scope,
|
|
292
|
+
score,
|
|
293
|
+
})
|
|
134
294
|
}
|
|
135
295
|
}
|
|
136
296
|
}
|
|
@@ -138,9 +298,9 @@ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchO
|
|
|
138
298
|
// 2. External tiers (Anthropic, skills.sh, GitHub)
|
|
139
299
|
const externalSources = ['anthropic', 'skills-sh', 'github'].filter((s) => sources.has(s))
|
|
140
300
|
|
|
141
|
-
if (externalSources.length > 0 &&
|
|
301
|
+
if (externalSources.length > 0 && scoredResults.length < limit) {
|
|
142
302
|
try {
|
|
143
|
-
const extLimit = limit -
|
|
303
|
+
const extLimit = limit - scoredResults.length
|
|
144
304
|
const extRes = searchSkillSources(query, {
|
|
145
305
|
limit: extLimit,
|
|
146
306
|
sources: externalSources,
|
|
@@ -151,15 +311,42 @@ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchO
|
|
|
151
311
|
}
|
|
152
312
|
|
|
153
313
|
if (Array.isArray(extRes.entries)) {
|
|
314
|
+
const minThreshold = tokens.length > 1 ? 5 : 2
|
|
154
315
|
for (const entry of extRes.entries) {
|
|
155
|
-
|
|
316
|
+
const bareName = (
|
|
317
|
+
entry.skill.includes('@') ? entry.skill.split('@')[1] : entry.skill
|
|
318
|
+
).toLowerCase()
|
|
319
|
+
const isInstalled =
|
|
320
|
+
installedMap.has(entry.skill.toLowerCase()) || installedMap.has(bareName)
|
|
321
|
+
const installedRecord =
|
|
322
|
+
installedMap.get(entry.skill.toLowerCase()) || installedMap.get(bareName)
|
|
323
|
+
|
|
324
|
+
const { score } = scoreSkillMatch(entry.skill, entry.skill, tokens)
|
|
325
|
+
if (score < minThreshold && !isInstalled) {
|
|
326
|
+
continue
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (
|
|
330
|
+
scoredResults.some(
|
|
331
|
+
(r) =>
|
|
332
|
+
r.skill.toLowerCase() === entry.skill.toLowerCase() ||
|
|
333
|
+
(bareName && r.skill.toLowerCase() === bareName),
|
|
334
|
+
)
|
|
335
|
+
) {
|
|
336
|
+
continue
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
scoredResults.push({
|
|
156
340
|
skill: entry.skill,
|
|
157
341
|
description: entry.skill,
|
|
158
342
|
source: entry.source as 'anthropic' | 'skills-sh' | 'github',
|
|
159
|
-
installed:
|
|
343
|
+
installed: isInstalled,
|
|
160
344
|
installs: entry.installs ?? null,
|
|
161
|
-
url: entry.url,
|
|
162
|
-
installCommand: `npx skills add ${entry.skill} -a opencode -y`,
|
|
345
|
+
...(entry.url ? { url: entry.url } : {}),
|
|
346
|
+
installCommand: isInstalled ? null : `npx skills add ${entry.skill} -a opencode -y`,
|
|
347
|
+
path: isInstalled && installedRecord ? installedRecord.path : null,
|
|
348
|
+
...(isInstalled && installedRecord ? { scope: installedRecord.scope } : {}),
|
|
349
|
+
score: score || 1,
|
|
163
350
|
})
|
|
164
351
|
}
|
|
165
352
|
}
|
|
@@ -170,7 +357,11 @@ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchO
|
|
|
170
357
|
}
|
|
171
358
|
}
|
|
172
359
|
|
|
173
|
-
|
|
360
|
+
scoredResults.sort((a, b) => b.score - a.score)
|
|
361
|
+
const bounded: SkillSearchResult[] = scoredResults
|
|
362
|
+
.slice(0, limit)
|
|
363
|
+
.map(({ score: _, ...item }) => item)
|
|
364
|
+
|
|
174
365
|
return {
|
|
175
366
|
ok: true,
|
|
176
367
|
query,
|
|
@@ -180,14 +371,17 @@ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchO
|
|
|
180
371
|
}
|
|
181
372
|
}
|
|
182
373
|
|
|
183
|
-
export function createV2SkillSearchDefinition(): V2ToolDef {
|
|
374
|
+
export function createV2SkillSearchDefinition(defaultDir?: string): V2ToolDef {
|
|
184
375
|
return {
|
|
185
376
|
name: 'pantheon_skill_search',
|
|
186
377
|
description: TOOL_DESCRIPTION,
|
|
187
378
|
input: SKILL_SEARCH_INPUT_SCHEMA,
|
|
188
379
|
output: {},
|
|
189
|
-
execute: async (input: Record<string, unknown
|
|
190
|
-
|
|
191
|
-
|
|
380
|
+
execute: async (input: Record<string, unknown>, context?: unknown) => {
|
|
381
|
+
const cwd = resolveToolCwd(context, defaultDir)
|
|
382
|
+
return {
|
|
383
|
+
output: JSON.stringify(executeSkillSearch(input, { cwd }), null, 2),
|
|
384
|
+
}
|
|
385
|
+
},
|
|
192
386
|
}
|
|
193
387
|
}
|
|
@@ -21,3 +21,26 @@ export interface ToolContextLike {
|
|
|
21
21
|
*/
|
|
22
22
|
agent?: string
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolves the effective working directory for tool operations.
|
|
27
|
+
*
|
|
28
|
+
* Checks in order of precedence:
|
|
29
|
+
* 1. ctx.directory (explicit workspace directory on tool context)
|
|
30
|
+
* 2. ctx.worktree (worktree directory if isolated)
|
|
31
|
+
* 3. fallbackDir (injected location directory from host at plugin setup)
|
|
32
|
+
* 4. process.cwd() (fallback process directory)
|
|
33
|
+
*/
|
|
34
|
+
export function resolveToolCwd(context: unknown, fallbackDir?: string): string {
|
|
35
|
+
const ctx = (context ?? {}) as Partial<ToolContextLike>
|
|
36
|
+
if (typeof ctx.directory === 'string' && ctx.directory.trim().length > 0) {
|
|
37
|
+
return ctx.directory
|
|
38
|
+
}
|
|
39
|
+
if (typeof ctx.worktree === 'string' && ctx.worktree.trim().length > 0) {
|
|
40
|
+
return ctx.worktree
|
|
41
|
+
}
|
|
42
|
+
if (typeof fallbackDir === 'string' && fallbackDir.trim().length > 0) {
|
|
43
|
+
return fallbackDir
|
|
44
|
+
}
|
|
45
|
+
return process.cwd()
|
|
46
|
+
}
|
package/src/pantheon/tools.ts
CHANGED
|
@@ -57,7 +57,7 @@ import { createV2LocalDecisionDefinition } from './local-decision-tool.ts'
|
|
|
57
57
|
import { createModelCommand } from './model-command.ts'
|
|
58
58
|
import { createV2VisionTool, type V2VisionRuntime } from './native-vision.ts'
|
|
59
59
|
import { createV2SkillSearchDefinition } from './skill-search-tool.ts'
|
|
60
|
-
import type
|
|
60
|
+
import { resolveToolCwd, type ToolContextLike } from './tool-context.ts'
|
|
61
61
|
|
|
62
62
|
// ─── Contract types ─────────────────────────────────────────────────────
|
|
63
63
|
|
|
@@ -400,7 +400,7 @@ const MODEL_INPUT: Record<string, unknown> = {
|
|
|
400
400
|
scope: {
|
|
401
401
|
type: 'string',
|
|
402
402
|
enum: ['project'],
|
|
403
|
-
description: 'Project scope only; global overrides are not supported
|
|
403
|
+
description: 'Project scope only; global overrides are not supported.',
|
|
404
404
|
},
|
|
405
405
|
},
|
|
406
406
|
}
|
|
@@ -412,12 +412,12 @@ async function executeModel(
|
|
|
412
412
|
context: unknown,
|
|
413
413
|
): Promise<V2ToolResult> {
|
|
414
414
|
if (input.scope !== undefined && input.scope !== 'project') {
|
|
415
|
-
return { output: 'Error:
|
|
415
|
+
return { output: 'Error: pantheon_model is project-only; global scope is not supported.' }
|
|
416
416
|
}
|
|
417
417
|
if (Object.hasOwn(input, 'confirm') || Object.hasOwn(input, 'authorize_global')) {
|
|
418
418
|
return {
|
|
419
419
|
output:
|
|
420
|
-
'Error:
|
|
420
|
+
'Error: pantheon_model does not accept authorization flags; global authorization is not supported by this tool.',
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
// The V1 tool validates its own args (zod) and reports failures as text.
|
|
@@ -557,44 +557,49 @@ const SHELL_INPUT = {
|
|
|
557
557
|
} as const
|
|
558
558
|
|
|
559
559
|
/**
|
|
560
|
-
*
|
|
560
|
+
* Shell tool execution. OpenCode registers `bash`, but models frequently
|
|
561
561
|
* attempt to invoke `shell` because of agent permission YAML conventions.
|
|
562
|
-
* This
|
|
562
|
+
* This tool ensures terminal commands execute seamlessly in the workspace directory.
|
|
563
563
|
*/
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
.
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
564
|
+
export function createShellTool(fallbackDir?: string): V2ToolDef {
|
|
565
|
+
return {
|
|
566
|
+
name: 'shell',
|
|
567
|
+
description: 'Execute a shell command in the workspace directory. Alias for bash execution.',
|
|
568
|
+
input: SHELL_INPUT,
|
|
569
|
+
output: {},
|
|
570
|
+
execute: async (input, context) => {
|
|
571
|
+
const raw = (input as Record<string, unknown>) ?? {}
|
|
572
|
+
const command = String(raw.command ?? raw.cmd ?? '')
|
|
573
|
+
if (!command.trim()) {
|
|
574
|
+
return { output: '', ok: false, error: 'Command cannot be empty' }
|
|
575
|
+
}
|
|
576
|
+
const cwd = resolveToolCwd(context, fallbackDir)
|
|
577
|
+
try {
|
|
578
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
579
|
+
cwd,
|
|
580
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
581
|
+
shell: '/bin/bash',
|
|
582
|
+
})
|
|
583
|
+
const output = [stdout, stderr].filter(Boolean).join('\n')
|
|
584
|
+
return { output, ok: true }
|
|
585
|
+
} catch (err: unknown) {
|
|
586
|
+
const execError = err as { stdout?: string; stderr?: string; message?: string }
|
|
587
|
+
const output = [execError.stdout, execError.stderr, execError.message]
|
|
588
|
+
.filter(Boolean)
|
|
589
|
+
.join('\n')
|
|
590
|
+
return { output, ok: false, error: output }
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
}
|
|
592
594
|
}
|
|
593
595
|
|
|
596
|
+
export const shellTool = createShellTool()
|
|
597
|
+
|
|
594
598
|
export function createV2ToolDefinitions(
|
|
595
599
|
visionRuntime?: V2VisionRuntime,
|
|
596
600
|
shadow: V2ToolShadowOptions = {},
|
|
597
601
|
jevRuntime?: V2JevDecisionRuntime,
|
|
602
|
+
hostLocationDirectory?: string,
|
|
598
603
|
): V2ToolDef[] {
|
|
599
604
|
const definitions: V2ToolDef[] = [
|
|
600
605
|
{
|
|
@@ -617,8 +622,8 @@ export function createV2ToolDefinitions(
|
|
|
617
622
|
'on disk: a call reads that cache and never waits on the network unless refreshPricing is ' +
|
|
618
623
|
'set, a stale cache is refreshed in the background and the report says so, and an unpriced ' +
|
|
619
624
|
'model reads — and is excluded from the totals, which then say partial. Pass session=<root ' +
|
|
620
|
-
'session id> to aggregate that session plus its descendant sessions. Phase may be unknown ' +
|
|
621
|
-
'
|
|
625
|
+
'session id> to aggregate that session plus its descendant sessions. Phase may be unknown; ' +
|
|
626
|
+
'costs are catalog list prices, not an invoice.',
|
|
622
627
|
input: COST_INPUT,
|
|
623
628
|
output: {},
|
|
624
629
|
execute: executeCost,
|
|
@@ -627,8 +632,8 @@ export function createV2ToolDefinitions(
|
|
|
627
632
|
name: 'pantheon_model',
|
|
628
633
|
description:
|
|
629
634
|
'Show, set, or reset explicit per-agent project-scoped model overrides in active-preset.json. ' +
|
|
630
|
-
'
|
|
631
|
-
'selection. Global overrides are not read or written
|
|
635
|
+
'Ignores static preset names and PANTHEON_MODEL_PRESET; no wizard or implicit model ' +
|
|
636
|
+
'selection. Global overrides are not read or written; future global support requires ' +
|
|
632
637
|
'separate explicit authorization. Pass action="status" to read project-scoped overrides. ' +
|
|
633
638
|
'Never writes .env or top-level model/small_model.',
|
|
634
639
|
input: MODEL_INPUT,
|
|
@@ -643,9 +648,9 @@ export function createV2ToolDefinitions(
|
|
|
643
648
|
)
|
|
644
649
|
definitions.push(todowriteTool)
|
|
645
650
|
definitions.push(todoreadTool)
|
|
646
|
-
definitions.push(
|
|
647
|
-
definitions.push(createV2SkillSearchDefinition())
|
|
648
|
-
definitions.push(createDeepworkTool())
|
|
651
|
+
definitions.push(createShellTool(hostLocationDirectory))
|
|
652
|
+
definitions.push(createV2SkillSearchDefinition(hostLocationDirectory))
|
|
653
|
+
definitions.push(createDeepworkTool(hostLocationDirectory))
|
|
649
654
|
if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime))
|
|
650
655
|
if (jevRuntime) definitions.push(createV2JevDecisionDefinition(jevRuntime))
|
|
651
656
|
return definitions
|