pantheon-opencode 2.0.0-beta.6 → 2.0.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 (93) hide show
  1. package/AGENTS.global.md +7 -2
  2. package/AGENTS.md +8 -8
  3. package/CHANGELOG.md +99 -0
  4. package/README.md +171 -510
  5. package/README.pt-BR.md +179 -149
  6. package/bin/pantheon-init.mjs +14 -1
  7. package/commands/pantheon-audit.md +1 -1
  8. package/commands/pantheon-deepwork.md +7 -2
  9. package/commands/pantheon-optimize.md +41 -63
  10. package/commands/pantheon.md +10 -5
  11. package/package.json +4 -3
  12. package/plugin.json +2 -2
  13. package/prompts/optimize-database.prompt.md +5 -5
  14. package/prompts/orchestrate-with-zeus.prompt.md +82 -290
  15. package/prompts/plan-architecture.prompt.md +6 -6
  16. package/prompts/subtask.prompt.md +1 -1
  17. package/pyproject.toml +1 -1
  18. package/scripts/build-agents-md.mjs +10 -10
  19. package/scripts/build-plugin.mjs +26 -0
  20. package/scripts/doctor.mjs +27 -11
  21. package/scripts/hooks/format-multi-language.sh +30 -48
  22. package/scripts/install/opencode-version.mjs +17 -5
  23. package/scripts/install/opencode.mjs +8 -1
  24. package/scripts/jev-live-probe.mjs +1 -1
  25. package/scripts/optimize.mjs +322 -0
  26. package/scripts/prune.mjs +105 -14
  27. package/scripts/release-gates.mjs +19 -5
  28. package/scripts/skill-search.mjs +27 -3
  29. package/scripts/test-opencode-sandbox.sh +44 -15
  30. package/scripts/update.mjs +29 -17
  31. package/skills-lock.json +15 -13
  32. package/src/agents/aphrodite.md +17 -14
  33. package/src/agents/apollo.md +10 -207
  34. package/src/agents/athena.md +30 -34
  35. package/src/agents/demeter.md +2 -0
  36. package/src/agents/hephaestus.md +1 -0
  37. package/src/agents/hermes.md +21 -95
  38. package/src/agents/iris.md +3 -0
  39. package/src/agents/mnemosyne.md +1 -1
  40. package/src/agents/nyx.md +2 -1
  41. package/src/agents/prometheus.md +2 -203
  42. package/src/agents/talos.md +5 -0
  43. package/src/agents/themis.md +93 -84
  44. package/src/agents/zeus.md +44 -263
  45. package/src/instructions/agent-return-format.instructions.md +1 -1
  46. package/src/instructions/memory-protocol.instructions.md +5 -1
  47. package/src/instructions/test-economy.instructions.md +1 -0
  48. package/src/instructions/zeus-anti-stall.instructions.md +3 -3
  49. package/src/instructions/zeus-communication-rules.instructions.md +1 -1
  50. package/src/instructions/zeus-council-synthesis.instructions.md +15 -3
  51. package/src/instructions/zeus-timeout-retry.instructions.md +10 -10
  52. package/src/pantheon/model-command.ts +12 -12
  53. package/src/pantheon/pantheon-decision-catalog.ts +8 -0
  54. package/src/pantheon/skill-search-tool.ts +193 -0
  55. package/src/pantheon/tools.ts +6 -0
  56. package/src/pantheon/tui-version-check.ts +1 -1
  57. package/src/pantheon/update-notifier.ts +13 -8
  58. package/src/pantheon/vision.ts +20 -20
  59. package/src/plugin/index.js +14594 -0
  60. package/src/plugins/tui/dist/tui.d.ts +15 -5
  61. package/src/plugins/tui/dist/tui.d.ts.map +1 -1
  62. package/src/plugins/tui/dist/tui.js +1761 -556
  63. package/src/plugins/tui/dist/tui.js.map +1 -1
  64. package/src/plugins/tui/package-lock.json +2 -2
  65. package/src/plugins/tui/package.json +1 -1
  66. package/src/plugins/tui/src/autonomy-state.ts +28 -16
  67. package/src/plugins/tui/src/context-gauge.ts +64 -5
  68. package/src/plugins/tui/src/decision-router-state.ts +49 -2
  69. package/src/plugins/tui/src/index.tsx +69 -26
  70. package/src/plugins/tui/src/pantheon-settings-state.ts +99 -0
  71. package/src/plugins/tui/src/pantheon-settings.tsx +771 -125
  72. package/src/plugins/tui/src/tui-prefs.ts +266 -12
  73. package/src/plugins/tui/src/update-notice.ts +9 -6
  74. package/src/plugins/tui/src/update-status.ts +27 -8
  75. package/src/plugins/tui/src/whats-new-open.ts +4 -4
  76. package/src/plugins/tui/src/whats-new.tsx +119 -17
  77. package/src/routing.yml +9 -0
  78. package/src/skills/README.md +35 -25
  79. package/src/skills/agent-coordination/SKILL.md +6 -6
  80. package/src/skills/artifact-management/SKILL.md +43 -39
  81. package/src/skills/artifact-management/references/artifact-templates.md +103 -48
  82. package/src/skills/auto-continue/references/auto-continue-details.md +13 -13
  83. package/src/skills/code-review-checklist/SKILL.md +6 -6
  84. package/src/skills/fast-path-execution/SKILL.md +54 -0
  85. package/src/skills/incremental-implementation/SKILL.md +13 -13
  86. package/src/skills/memory-bank/references/anti-patterns.md +3 -3
  87. package/src/skills/prompt-refinery/SKILL.md +51 -65
  88. package/src/skills/spec-driven-development/SKILL.md +12 -14
  89. package/src/skills/tdd-with-agents/SKILL.md +23 -10
  90. package/src/skills/test-slicing/SKILL.md +56 -0
  91. package/src/skills/verification-planning/SKILL.md +4 -3
  92. package/src/skills/visual-review-pipeline/SKILL.md +1 -1
  93. package/src/skills/visual-review-pipeline/references/workflow-steps.md +1 -1
@@ -0,0 +1,193 @@
1
+ /**
2
+ * Skill search tool surface for Pantheon OpenCode V2.
3
+ *
4
+ * Implements the skill provenance search design from
5
+ * `docs/reference/skill-search-design.md`:
6
+ *
7
+ * 1. Tier 1 (Installed): Searches local Pantheon skill catalog in-memory.
8
+ * 2. Tier 2 (Canonical): Searches Anthropic catalog (curated).
9
+ * 3. Tier 3 (Ecosystem): Searches skills.sh and GitHub code search.
10
+ *
11
+ * Fail-open and safe by design: never throws, reports provenance tiers,
12
+ * and leaves the install decision to the user (`npx skills add ...`).
13
+ *
14
+ * @module pantheon/skill-search-tool
15
+ */
16
+
17
+ // @ts-expect-error scripts/skill-search.mjs is a plain Node ESM script without bundled .d.ts
18
+ import { searchSkillSources } from '../../scripts/skill-search.mjs'
19
+ import { PANTHEON_SKILL_CATALOG } from './pantheon-decision-catalog.ts'
20
+ import type { V2ToolDef } from './tools.ts'
21
+
22
+ export interface SkillSearchResult {
23
+ readonly skill: string
24
+ readonly description?: string
25
+ readonly source: 'installed' | 'anthropic' | 'skills-sh' | 'github'
26
+ readonly installed: boolean
27
+ readonly installs?: number | null
28
+ readonly url?: string
29
+ readonly installCommand?: string | null
30
+ }
31
+
32
+ export interface SkillSearchOutput {
33
+ readonly ok: boolean
34
+ readonly query: string
35
+ readonly count: number
36
+ readonly results: readonly SkillSearchResult[]
37
+ readonly failures: readonly string[]
38
+ }
39
+
40
+ const TOOL_DESCRIPTION =
41
+ 'Advisory discovery tool for skills. Queries installed Pantheon skills and external ' +
42
+ 'registries (Anthropic catalog, skills.sh, GitHub). Returns matched skill IDs, ' +
43
+ 'descriptions, install counts, and provenance tiers. Zeus uses this to recommend ' +
44
+ 'skills before prompting the user to install.'
45
+
46
+ const SKILL_SEARCH_INPUT_SCHEMA: Record<string, unknown> = {
47
+ type: 'object',
48
+ additionalProperties: false,
49
+ required: ['query'],
50
+ properties: {
51
+ query: {
52
+ type: 'string',
53
+ minLength: 1,
54
+ maxLength: 100,
55
+ description: 'Search terms to discover skills (e.g. "docker", "fastapi", "testing")',
56
+ },
57
+ limit: {
58
+ type: 'integer',
59
+ minimum: 1,
60
+ maximum: 20,
61
+ default: 5,
62
+ description: 'Maximum number of results to return across all sources (default 5)',
63
+ },
64
+ sources: {
65
+ type: 'array',
66
+ items: {
67
+ type: 'string',
68
+ enum: ['installed', 'anthropic', 'skills-sh', 'github'],
69
+ },
70
+ description:
71
+ 'Sources to search. Defaults to ["installed", "anthropic", "skills-sh"]. ' +
72
+ 'Pass ["installed"] for local-only search without network egress.',
73
+ },
74
+ },
75
+ }
76
+
77
+ export function executeSkillSearch(input: Record<string, unknown>): SkillSearchOutput {
78
+ const query = typeof input.query === 'string' ? input.query.trim() : ''
79
+ if (query.length === 0) {
80
+ return { ok: false, query: '', count: 0, results: [], failures: ['query must be non-empty'] }
81
+ }
82
+
83
+ const limit =
84
+ typeof input.limit === 'number' && Number.isFinite(input.limit)
85
+ ? Math.max(1, Math.min(20, Math.floor(input.limit)))
86
+ : 5
87
+
88
+ const rawSources = Array.isArray(input.sources) ? input.sources : undefined
89
+ const sources = new Set<string>(
90
+ rawSources?.filter((s): s is string => typeof s === 'string') ?? [
91
+ 'installed',
92
+ 'anthropic',
93
+ 'skills-sh',
94
+ ],
95
+ )
96
+
97
+ const results: SkillSearchResult[] = []
98
+ const failures: string[] = []
99
+
100
+ // 1. Tier 1: Installed Pantheon catalog (in-memory, instant, zero-network)
101
+ if (sources.has('installed')) {
102
+ const tokens = query
103
+ .toLowerCase()
104
+ .split(/[^a-z0-9]+/)
105
+ .filter((t) => t.length > 2)
106
+
107
+ if (tokens.length > 0) {
108
+ for (const entry of PANTHEON_SKILL_CATALOG) {
109
+ const idLower = entry.id.toLowerCase()
110
+ const descLower = entry.description.toLowerCase()
111
+ const matchScore = tokens.reduce((score, t) => {
112
+ const stem = t.length > 4 ? t.slice(0, 4) : t
113
+ return (
114
+ score +
115
+ (idLower.includes(t) ||
116
+ descLower.includes(t) ||
117
+ idLower.includes(stem) ||
118
+ descLower.includes(stem)
119
+ ? 1
120
+ : 0)
121
+ )
122
+ }, 0)
123
+
124
+ if (matchScore > 0) {
125
+ results.push({
126
+ skill: entry.id,
127
+ description: entry.description,
128
+ source: 'installed',
129
+ installed: true,
130
+ installs: null,
131
+ installCommand: null,
132
+ })
133
+ }
134
+ }
135
+ }
136
+ }
137
+
138
+ // 2. External tiers (Anthropic, skills.sh, GitHub)
139
+ const externalSources = ['anthropic', 'skills-sh', 'github'].filter((s) => sources.has(s))
140
+
141
+ if (externalSources.length > 0 && results.length < limit) {
142
+ try {
143
+ const extLimit = limit - results.length
144
+ const extRes = searchSkillSources(query, {
145
+ limit: extLimit,
146
+ sources: externalSources,
147
+ })
148
+
149
+ if (Array.isArray(extRes.failures)) {
150
+ failures.push(...extRes.failures)
151
+ }
152
+
153
+ if (Array.isArray(extRes.entries)) {
154
+ for (const entry of extRes.entries) {
155
+ results.push({
156
+ skill: entry.skill,
157
+ description: entry.skill,
158
+ source: entry.source as 'anthropic' | 'skills-sh' | 'github',
159
+ installed: false,
160
+ installs: entry.installs ?? null,
161
+ url: entry.url,
162
+ installCommand: `npx skills add ${entry.skill} -a opencode`,
163
+ })
164
+ }
165
+ }
166
+ } catch (err) {
167
+ failures.push(
168
+ `external skill search error: ${err instanceof Error ? err.message : String(err)}`,
169
+ )
170
+ }
171
+ }
172
+
173
+ const bounded = results.slice(0, limit)
174
+ return {
175
+ ok: true,
176
+ query,
177
+ count: bounded.length,
178
+ results: bounded,
179
+ failures,
180
+ }
181
+ }
182
+
183
+ export function createV2SkillSearchDefinition(): V2ToolDef {
184
+ return {
185
+ name: 'pantheon_skill_search',
186
+ description: TOOL_DESCRIPTION,
187
+ input: SKILL_SEARCH_INPUT_SCHEMA,
188
+ output: {},
189
+ execute: async (input: Record<string, unknown>) => ({
190
+ output: JSON.stringify(executeSkillSearch(input), null, 2),
191
+ }),
192
+ }
193
+ }
@@ -53,6 +53,7 @@ import { createV2JevDecisionDefinition, type V2JevDecisionRuntime } from './jev-
53
53
  import { createV2LocalDecisionDefinition } from './local-decision-tool.ts'
54
54
  import { createModelCommand } from './model-command.ts'
55
55
  import { createV2VisionTool, type V2VisionRuntime } from './native-vision.ts'
56
+ import { createV2SkillSearchDefinition } from './skill-search-tool.ts'
56
57
  import type { ToolContextLike } from './tool-context.ts'
57
58
 
58
59
  // ─── Contract types ─────────────────────────────────────────────────────
@@ -344,6 +345,10 @@ function coerceRefreshPricing(
344
345
 
345
346
  const costCommand = createCostCommand()
346
347
 
348
+ /**
349
+ * Executes the `pantheon_cost` tool: generates token usage and cost report in USD
350
+ * per agent/phase, model, and session over the last N days, reading opencode.db (read-only).
351
+ */
347
352
  async function executeCost(
348
353
  input: Record<string, unknown>,
349
354
  context: unknown,
@@ -539,6 +544,7 @@ export function createV2ToolDefinitions(
539
544
  }),
540
545
  )
541
546
  definitions.push(todowriteTool)
547
+ definitions.push(createV2SkillSearchDefinition())
542
548
  if (visionRuntime) definitions.push(createV2VisionTool(visionRuntime))
543
549
  if (jevRuntime) definitions.push(createV2JevDecisionDefinition(jevRuntime))
544
550
  return definitions
@@ -61,7 +61,7 @@ export function checkTuiVersionStaleness(logger: (msg: string) => void = console
61
61
 
62
62
  if (copyVersion !== currentVersion) {
63
63
  logger(
64
- `⚠️ TUI plugin v${copyVersion} is outdated. Current: v${currentVersion}. Run: npx pantheon-opencode init`,
64
+ `[WARN] TUI plugin v${copyVersion} is outdated. Current: v${currentVersion}. Run: npx pantheon-opencode init`,
65
65
  )
66
66
  }
67
67
  } catch {
@@ -33,30 +33,35 @@ export interface UpdateNotice {
33
33
  message: string
34
34
  }
35
35
 
36
- /** Semver-ish compare for X.Y.Z[-beta.N]; betas sort before their release. */
36
+ /** Semver-ish compare for X.Y.Z[-(beta|rc).N]; prereleases sort before their release. */
37
37
  export function comparePantheonVersions(left: string, right: string): number {
38
38
  const parse = (version: string) => {
39
39
  const match = String(version)
40
40
  .trim()
41
- .match(/^(\d+)\.(\d+)\.(\d+)(?:-beta\.(\d+))?$/)
41
+ .match(/^(\d+)\.(\d+)\.(\d+)(?:-(beta|rc)\.(\d+))?$/)
42
42
  if (!match) return null
43
43
  if (match[1] === undefined || match[2] === undefined || match[3] === undefined) {
44
44
  return null
45
45
  }
46
+ const stage = match[4]
47
+ const stageNum = match[5] !== undefined ? +match[5] : 0
48
+ const stageRank = stage === 'beta' ? 1 : stage === 'rc' ? 2 : 3
46
49
  return {
47
50
  core: [Number(match[1]), Number(match[2]), Number(match[3])],
48
- beta: match[4] === undefined ? Number.POSITIVE_INFINITY : +match[4],
51
+ stageRank,
52
+ stageNum: stage ? stageNum : Number.POSITIVE_INFINITY,
49
53
  }
50
54
  }
51
55
  const a = parse(left)
52
56
  const b = parse(right)
53
57
  if (!a || !b) return 0
54
58
  for (let index = 0; index < 3; index += 1) {
55
- const left = a.core[index] ?? 0
56
- const right = b.core[index] ?? 0
57
- if (left !== right) return left - right
59
+ const leftVal = a.core[index] ?? 0
60
+ const rightVal = b.core[index] ?? 0
61
+ if (leftVal !== rightVal) return leftVal - rightVal
58
62
  }
59
- return a.beta - b.beta
63
+ if (a.stageRank !== b.stageRank) return a.stageRank - b.stageRank
64
+ return a.stageNum - b.stageNum
60
65
  }
61
66
 
62
67
  /**
@@ -73,7 +78,7 @@ export function pickUpdateNotice(input: UpdateNoticeInput): UpdateNotice | null
73
78
  if (nowMs - lastCheck < ttlMs) return null
74
79
  if (state.lastNotifiedVersion === latestVersion) return null
75
80
 
76
- const stable = (version: string) => !/-beta\.\d+$/.test(version)
81
+ const stable = (version: string) => !/-(?:beta|rc)\.\d+$/.test(version)
77
82
  // A stable install is never advertised a beta: the update guard owns that
78
83
  // crossing and requires explicit opt-in there.
79
84
  if (stable(currentVersion) && !stable(latestVersion)) return null
@@ -1762,18 +1762,18 @@ export function truncateUserText(
1762
1762
 
1763
1763
  const INTENT_TASK_INSTRUCTIONS: Record<VisionIntent, string> = {
1764
1764
  describe:
1765
- 'Descreva cada imagem fielmente e em detalhes: texto visível verbatim, cores, layout, objetos.',
1765
+ 'Describe each image faithfully and in detail: visible text verbatim, colors, layout, and objects.',
1766
1766
  compare:
1767
- 'Descreva cada imagem no seu próprio bloco <item>; depois coloque uma comparação direta e exaustiva no <context> (diferenças por região/elemento), terminando com um veredito claro.',
1768
- ocr: 'Transcreva literalmente todo o texto visível em cada imagem, preservando ordem e estrutura. A transcrição vai dentro do <description> da imagem correspondente.',
1767
+ 'Describe each image in its own <item> block; then provide a direct, exhaustive comparison in <context> (differences by region/element), concluding with a clear verdict.',
1768
+ ocr: 'Transcribe literally all visible text in each image, preserving order and structure. Place the transcription inside the corresponding image <description>.',
1769
1769
  reconstruct:
1770
- 'Descreva cada imagem com detalhe de reconstrução para reprodução em código: layout completo (regiões, alinhamento, espaçamento), todo texto visível verbatim, paleta de cores exata em hex, fontes/tamanhos/pesos por elemento, estrutura de componentes e estados.',
1771
- bugs: 'Descreva o sintoma visual observado em cada imagem: o que está errado, onde, esperado vs real, com referências de região precisas e contexto suficiente para localizar e reproduzir.',
1770
+ 'Describe each image with reconstruction-level detail for reproduction in code: complete layout (regions, alignment, spacing), all visible text verbatim, exact color palette in hex, fonts/sizes/weights per element, component structure, and states.',
1771
+ bugs: 'Describe the visual bug or symptom observed in each image: what is wrong, where, expected vs actual, with precise region references and sufficient context to reproduce.',
1772
1772
  }
1773
1773
 
1774
1774
  const INTENT_CONTEXT_INSTRUCTIONS: Record<VisionIntent, string> = {
1775
1775
  compare:
1776
- 'Depois dos itens, adicione UM bloco <context> com a análise cruzada das imagens (comparação, veredito).',
1776
+ 'After the items, add ONE <context> block with cross-image analysis (comparison, verdict).',
1777
1777
  describe: '',
1778
1778
  ocr: '',
1779
1779
  reconstruct: '',
@@ -1962,7 +1962,7 @@ export function buildNativeVisionPrompt(
1962
1962
  const count = Math.max(1, imageCount)
1963
1963
  const request =
1964
1964
  escapeXml(truncateUserText(userText)) ||
1965
- '(sem pedido explícito — descreva as imagens com precisão)'
1965
+ '(no explicit request — describe the images accurately)'
1966
1966
  const contextInstruction = INTENT_CONTEXT_INSTRUCTIONS[intent]
1967
1967
  const contextLine = contextInstruction ? ` ${contextInstruction}` : ''
1968
1968
  return [
@@ -1976,26 +1976,26 @@ export function buildNativeVisionPrompt(
1976
1976
  INTENT_TASK_INSTRUCTIONS[intent],
1977
1977
  '',
1978
1978
  'OUTPUT FORMAT — binding, no exceptions:',
1979
- `Responda com UM bloco <item id="N"> para cada uma das ${count} imagens anexadas`,
1980
- `(N = 1..${count}), em ordem. Cada bloco contém um <description>.${contextLine}`,
1979
+ `Reply with ONE <item id="N"> block for each of the ${count} attached images`,
1980
+ `(N = 1..${count}), in order. Each block contains a <description>.${contextLine}`,
1981
1981
  '',
1982
1982
  '<item id="1">',
1983
- '<description>...apenas fatos sobre a imagem 1...</description>',
1983
+ '<description>...facts only about image 1...</description>',
1984
1984
  '</item>',
1985
1985
  '<item id="2">',
1986
- '<description>...apenas fatos sobre a imagem 2...</description>',
1986
+ '<description>...facts only about image 2...</description>',
1987
1987
  '</item>',
1988
1988
  '',
1989
1989
  'RULES',
1990
- '- O primeiro caractere da sua resposta deve ser "<". Sem preâmbulo, sem "Aqui está",',
1991
- ' sem observações finais, sem wrap em blocos de código.',
1992
- '- ESCAPING — obrigatório: dentro dos corpos de <description> e <context>, escape TODO',
1993
- ' "&", "<" e ">" literais como "&amp;", "&lt;", "&gt;". Isso vale para qualquer texto',
1994
- ' tag-like reproduzido verbatim (HTML, XML, erros com colchetes angulares). NÃO escape',
1995
- ' as tags estruturais <item>, <description>, <context>.',
1996
- '- Nunca invente detalhes que não consegue perceber. Se um texto estiver ilegível,',
1997
- ' escreva "ilegível". Coloque análises cruzadas (comparação, veredito) no <context>,',
1998
- ' nunca dentro de um <description>.',
1990
+ '- The first character of your response MUST be "<". No preamble, no "Here is",',
1991
+ ' no closing remarks, no code fence wrapping.',
1992
+ '- ESCAPING — mandatory: inside the bodies of <description> and <context>, escape ALL',
1993
+ ' literal "&", "<", and ">" as "&amp;", "&lt;", "&gt;". This applies to any verbatim',
1994
+ ' tag-like text (HTML, XML, bracketed errors). Do NOT escape',
1995
+ ' the structural tags <item>, <description>, <context>.',
1996
+ '- Never hallucinate details you cannot perceive. If text is illegible,',
1997
+ ' write "illegible". Place cross-image analysis (comparison, verdict) in <context>,',
1998
+ ' never inside a <description>.',
1999
1999
  ...(orientationHint.trim()
2000
2000
  ? [
2001
2001
  '',