pantheon-opencode 1.6.3-beta.2 → 1.6.3-beta.21

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 (69) hide show
  1. package/AGENTS.global.md +1 -1
  2. package/AGENTS.md +1 -1
  3. package/CHANGELOG.md +143 -0
  4. package/README.md +21 -3
  5. package/README.pt-BR.md +1 -1
  6. package/bin/pantheon-init.mjs +46 -28
  7. package/package.json +1 -1
  8. package/plugin.json +2 -2
  9. package/pyproject.toml +1 -1
  10. package/scripts/decision-router-budget.mjs +103 -3
  11. package/scripts/decision-router-v2-budget.mjs +2 -2
  12. package/scripts/decision-router.mjs +88 -6
  13. package/scripts/install/cli-ui.mjs +2 -1
  14. package/scripts/install/decision-router-config.mjs +53 -0
  15. package/scripts/install/interactive.mjs +103 -9
  16. package/scripts/install/opencode.mjs +101 -30
  17. package/scripts/install/plugin.mjs +17 -0
  18. package/scripts/jev-live-probe.mjs +212 -0
  19. package/scripts/skill-search.mjs +273 -0
  20. package/scripts/sync-tui.mjs +11 -0
  21. package/skills-lock.json +1 -0
  22. package/src/agents/aphrodite.md +34 -1
  23. package/src/agents/apollo.md +227 -0
  24. package/src/agents/athena.md +26 -0
  25. package/src/agents/demeter.md +33 -0
  26. package/src/agents/gaia.md +24 -0
  27. package/src/agents/hephaestus.md +24 -0
  28. package/src/agents/hermes.md +33 -0
  29. package/src/agents/iris.md +24 -0
  30. package/src/agents/mnemosyne.md +25 -3
  31. package/src/agents/nyx.md +50 -22
  32. package/src/agents/prometheus.md +242 -1
  33. package/src/agents/talos.md +24 -0
  34. package/src/agents/themis.md +24 -0
  35. package/src/agents/zeus.md +67 -6
  36. package/src/pantheon/j-telemetry-file.ts +96 -0
  37. package/src/pantheon/j1-approvals.ts +123 -0
  38. package/src/pantheon/jev-decision-tool.ts +268 -34
  39. package/src/pantheon/jev-decisions.ts +92 -8
  40. package/src/pantheon/jev-escalation.ts +1 -1
  41. package/src/pantheon/jev-quality-score.ts +7 -2
  42. package/src/pantheon/jev-rank-verify.ts +661 -0
  43. package/src/pantheon/jev-risk-gate.ts +75 -8
  44. package/src/pantheon/local-decision-budget.ts +170 -3
  45. package/src/pantheon/local-decision-router.ts +16 -0
  46. package/src/pantheon/local-decision-turn.ts +39 -4
  47. package/src/pantheon/local-decision-usage-evidence.internal.ts +2 -2
  48. package/src/pantheon/pantheon-decision-catalog.ts +9 -2
  49. package/src/pantheon/v2-decision-budget.ts +4 -2
  50. package/src/plugin-v2.ts +94 -7
  51. package/src/plugins/tui/dist/server-v2.d.ts +14 -6
  52. package/src/plugins/tui/dist/server-v2.d.ts.map +1 -1
  53. package/src/plugins/tui/dist/server-v2.js +16 -9
  54. package/src/plugins/tui/dist/server-v2.js.map +1 -1
  55. package/src/plugins/tui/dist/tui-v2.d.ts.map +1 -1
  56. package/src/plugins/tui/dist/tui-v2.js +560 -4
  57. package/src/plugins/tui/dist/tui-v2.js.map +1 -1
  58. package/src/plugins/tui/dist/tui.js +1 -1
  59. package/src/plugins/tui/package-lock.json +2 -2
  60. package/src/plugins/tui/package.json +1 -1
  61. package/src/plugins/tui/src/index-v2.tsx +6 -0
  62. package/src/plugins/tui/src/server-v2.ts +14 -7
  63. package/src/plugins/tui/src/whats-new-highlights.ts +317 -0
  64. package/src/plugins/tui/src/whats-new-open.ts +120 -0
  65. package/src/plugins/tui/src/whats-new-state.ts +128 -0
  66. package/src/plugins/tui/src/whats-new.tsx +172 -0
  67. package/src/routing.yml +1 -0
  68. package/src/skills/README.md +1 -1
  69. package/src/skills/prompt-refinery/SKILL.md +41 -0
@@ -0,0 +1,128 @@
1
+ /**
2
+ * whats-new-state.ts — last-seen version for the one-time "What's new" window.
3
+ *
4
+ * The TUI shows a dismissable release-highlights dialog once per Pantheon
5
+ * version. Whether a version was already seen is persisted next to the other
6
+ * opencode-level Pantheon state: `<configDir>/.pantheon/whats-new.json`, the
7
+ * same directory that already holds `install-state.json` (scripts/install/
8
+ * state.mjs) and the active-preset file the sidebar reads. There is no
9
+ * established persistent TUI KV store (the host `api.kv` is per-process), so
10
+ * the plugin owns one small JSON file with the atomic-write discipline used
11
+ * across the repo (unique tmp + rename, mirrors scripts/install/verify.mjs).
12
+ *
13
+ * Fail-open everywhere: a missing or corrupt file reads as "never seen" (the
14
+ * window may show), a failed write is silent (the window may show again) —
15
+ * neither can ever block TUI startup.
16
+ */
17
+ import { mkdir, readFile, rename, stat, unlink, writeFile } from 'node:fs/promises'
18
+ import { homedir } from 'node:os'
19
+ import { dirname, join } from 'node:path'
20
+
21
+ /** State file name, kept next to `install-state.json` in `<configDir>/.pantheon/`. */
22
+ export const WHATS_NEW_STATE_FILENAME = 'whats-new.json'
23
+
24
+ /** Shape of the persisted file — the plugin owns this file outright. */
25
+ export interface WhatsNewStateFile {
26
+ seenVersion: string | null
27
+ updatedAt: string
28
+ }
29
+
30
+ type Env = Record<string, string | undefined>
31
+
32
+ /** Parse a state file body; null when unreadable as the expected shape. */
33
+ export function parseWhatsNewState(raw: string): WhatsNewStateFile | null {
34
+ try {
35
+ const parsed: unknown = JSON.parse(raw)
36
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null
37
+ const record = parsed as Record<string, unknown>
38
+ const seen = record.seenVersion
39
+ if (typeof seen !== 'string' && seen !== null) return null
40
+ return { seenVersion: seen, updatedAt: String(record.updatedAt ?? '') }
41
+ } catch {
42
+ return null
43
+ }
44
+ }
45
+
46
+ /** Read the persisted state; null when missing or corrupt (never throws). */
47
+ export async function readWhatsNewState(statePath: string): Promise<WhatsNewStateFile | null> {
48
+ try {
49
+ return parseWhatsNewState(await readFile(statePath, 'utf8'))
50
+ } catch {
51
+ return null
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Whether the one-time window should show for `version`: any version change
57
+ * since the last dismissal (including downgrades). A falsy version — the
58
+ * resolver failed — never shows.
59
+ */
60
+ export async function shouldShowWhatsNew(
61
+ version: string | null | undefined,
62
+ statePath: string,
63
+ ): Promise<boolean> {
64
+ if (typeof version !== 'string' || version.trim() === '') return false
65
+ const state = await readWhatsNewState(statePath)
66
+ return state?.seenVersion !== version
67
+ }
68
+
69
+ /**
70
+ * Persist `version` as seen (atomic tmp + rename, 0o600). Never throws: a
71
+ * failed write leaves the state untouched and the window may show again —
72
+ * the same fail-open contract as the rest of the plugin.
73
+ */
74
+ export async function markSeenWhatsNew(version: string, statePath: string): Promise<boolean> {
75
+ if (typeof version !== 'string' || version.trim() === '') return false
76
+ const previous = await readWhatsNewState(statePath)
77
+ const next: WhatsNewStateFile = {
78
+ seenVersion: version,
79
+ updatedAt: new Date().toISOString(),
80
+ }
81
+ const tmpPath = `${statePath}.tmp-${process.pid}`
82
+ try {
83
+ await mkdir(dirname(statePath), { recursive: true })
84
+ await writeFile(tmpPath, `${JSON.stringify({ ...previous, ...next }, null, 2)}\n`, {
85
+ encoding: 'utf8',
86
+ mode: 0o600,
87
+ })
88
+ await rename(tmpPath, statePath)
89
+ return true
90
+ } catch {
91
+ try {
92
+ await unlink(tmpPath)
93
+ } catch {
94
+ /* nothing to clean up */
95
+ }
96
+ return false
97
+ }
98
+ }
99
+
100
+ /** `stat`-based existence probe (async I/O discipline). */
101
+ async function pathExists(path: string): Promise<boolean> {
102
+ try {
103
+ await stat(path)
104
+ return true
105
+ } catch {
106
+ return false
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Default state path: `<configDir>/.pantheon/whats-new.json`, resolving the
112
+ * OpenCode config directory exactly like src/pantheon/tui-version-check.ts
113
+ * (`$XDG_CONFIG_HOME/opencode` → `~/.opencode`), defaulting to the XDG
114
+ * location `init` creates when neither exists yet.
115
+ */
116
+ export async function defaultWhatsNewStatePath(
117
+ env: Env = process.env,
118
+ home: string = homedir(),
119
+ ): Promise<string> {
120
+ const xdgConfig = env.XDG_CONFIG_HOME || join(home, '.config')
121
+ const primary = join(xdgConfig, 'opencode')
122
+ if (await pathExists(primary)) return join(primary, '.pantheon', WHATS_NEW_STATE_FILENAME)
123
+
124
+ const legacy = join(home, '.opencode')
125
+ if (await pathExists(legacy)) return join(legacy, '.pantheon', WHATS_NEW_STATE_FILENAME)
126
+
127
+ return join(primary, '.pantheon', WHATS_NEW_STATE_FILENAME)
128
+ }
@@ -0,0 +1,172 @@
1
+ // biome-ignore-all lint/suspicious/noExplicitAny: OpenCode exposes its TUI API at runtime.
2
+ // biome-ignore-all lint/a11y/noStaticElementInteractions: TUI elements, not DOM
3
+ /** @jsxImportSource @opentui/solid */
4
+
5
+ /**
6
+ * whats-new.tsx — the one-time "What's new" window (per Pantheon version).
7
+ *
8
+ * When the running Pantheon version changed since the last TUI start, the V2
9
+ * entrypoint fires {@link maybeShowWhatsNewV2} (fire-and-forget, never
10
+ * awaited — startup must never block). The decision lives in
11
+ * whats-new-open.ts; this file is only the host glue + view:
12
+ * `context.ui.dialog.show` plus a keymap layer gated on the open signal so
13
+ * `escape`/`q` dismiss and `n`/`p` flip pages while (and only while) the
14
+ * window is up — the same gated-layer pattern as the dispatch panel.
15
+ *
16
+ * The window shows the curated 🆕 What's New summary (whats-new-highlights
17
+ * prefers it), hard-wrapped to the window width and sliced into fixed-size
18
+ * pages — a big changelog can never overflow the terminal; the footer points
19
+ * at the complete CHANGELOG.md.
20
+ *
21
+ * Deliberately V2-only: the two dist entries are self-contained (the V1
22
+ * sidebar mirrors the preset resolver rather than importing it) because any
23
+ * module shared by both entries becomes a content-hashed chunk in dist/,
24
+ * changing the artifact shape the byte-reproducible-dist gate pins. The V1
25
+ * generation (OpenCode 1.x, legacy) does not show the window; the pure
26
+ * modules here are generation-agnostic, so a V1 mirror can follow the
27
+ * documented inline-replica precedent if it is ever wanted.
28
+ *
29
+ * Dismissal always funnels into `markSeenWhatsNew` (idempotent), so the window
30
+ * is shown exactly once per version. Every failure path is silent: missing
31
+ * CHANGELOG.md, unreadable state, a host API that throws — the window simply
32
+ * does not show (fail-open, like the rest of the plugin).
33
+ */
34
+ import type { Context } from '@opencode/plugin/tui/context'
35
+ import { createSignal, For } from 'solid-js'
36
+ import { readChangelogForBundle, resolveRunningVersion } from './whats-new-highlights.ts'
37
+ import { openWhatsNew, type WhatsNewViewData, wrapWhatsNewLine } from './whats-new-open.ts'
38
+ import { defaultWhatsNewStatePath } from './whats-new-state.ts'
39
+
40
+ /** Window body: title, rule, the current page (wrapped), footer hint. */
41
+ export function WhatsNewContent(props: {
42
+ data: WhatsNewViewData
43
+ page: () => number
44
+ pageCount: () => number
45
+ fg?: any
46
+ muted?: any
47
+ }) {
48
+ const rows = () => {
49
+ const current = props.data.pages[Math.min(props.page(), props.pageCount() - 1)] ?? []
50
+ const wrapped: string[] = []
51
+ for (const line of current) wrapped.push(...wrapWhatsNewLine(line, 76))
52
+ return wrapped
53
+ }
54
+ return (
55
+ <box flexDirection="column" paddingLeft={1} paddingRight={1} paddingTop={1}>
56
+ <text attributes={1} fg={props.fg}>
57
+ {props.data.title}
58
+ </text>
59
+ <text fg={props.muted}>{'─'.repeat(38)}</text>
60
+ <For each={rows()}>
61
+ {(line: string) => <text fg={line.startsWith('• ') ? props.fg : props.muted}>{line}</text>}
62
+ </For>
63
+ <box height={1} />
64
+ <text fg={props.muted}>
65
+ {props.pageCount() > 1 ? `${props.page() + 1}/${props.pageCount()} · ` : ''}
66
+ {props.data.hint}
67
+ </text>
68
+ </box>
69
+ )
70
+ }
71
+
72
+ /**
73
+ * Entry glue: resolve version + shipped CHANGELOG.md, then show the window
74
+ * through the host dialog stack once. Never throws.
75
+ */
76
+ export async function maybeShowWhatsNewV2(context: Context): Promise<void> {
77
+ try {
78
+ const version = await resolveRunningVersion(import.meta.url)
79
+ if (!version) return
80
+ const statePath = await defaultWhatsNewStatePath()
81
+ const changelogText = await readChangelogForBundle(import.meta.url)
82
+
83
+ const [open, setOpen] = createSignal(false)
84
+ const [page, setPage] = createSignal(0)
85
+ let viewData: WhatsNewViewData | undefined
86
+ const pageCount = () => Math.max(1, Math.ceil(viewData?.pages.length ?? 1))
87
+ let dismiss: () => void = () => {}
88
+ try {
89
+ // Gated layer: inert (all keys fall through) while the window is closed.
90
+ context.keymap.layer(() => ({
91
+ mode: 'global',
92
+ enabled: () => open(),
93
+ commands: [
94
+ {
95
+ id: 'pantheon.whats-new.close',
96
+ title: 'Fechar o que há de novo',
97
+ bind: 'escape,q',
98
+ run: () => {
99
+ if (!open()) return false
100
+ dismiss()
101
+ return undefined
102
+ },
103
+ },
104
+ {
105
+ id: 'pantheon.whats-new.next',
106
+ title: 'Próxima página',
107
+ bind: 'n,right',
108
+ run: () => {
109
+ if (!open()) return false
110
+ setPage((current) => Math.min(current + 1, pageCount() - 1))
111
+ return undefined
112
+ },
113
+ },
114
+ {
115
+ id: 'pantheon.whats-new.prev',
116
+ title: 'Página anterior',
117
+ bind: 'p,left',
118
+ run: () => {
119
+ if (!open()) return false
120
+ setPage((current) => Math.max(current - 1, 0))
121
+ return undefined
122
+ },
123
+ },
124
+ ],
125
+ }))
126
+ } catch {
127
+ /* keymap API unavailable — the host dialog chrome still dismisses (ESC) */
128
+ }
129
+
130
+ await openWhatsNew({
131
+ version,
132
+ statePath,
133
+ changelogText,
134
+ show: (render, onClose) => {
135
+ const close = () => {
136
+ setOpen(false)
137
+ onClose()
138
+ }
139
+ dismiss = () => {
140
+ try {
141
+ context.ui.dialog.clear()
142
+ } catch {
143
+ /* already closed */
144
+ }
145
+ close()
146
+ }
147
+ viewData = render()
148
+ setPage(0)
149
+ setOpen(true)
150
+ try {
151
+ const theme = context.theme?.text ?? {}
152
+ context.ui.dialog.show(
153
+ () => (
154
+ <WhatsNewContent
155
+ data={viewData as WhatsNewViewData}
156
+ page={page}
157
+ pageCount={pageCount}
158
+ fg={theme.base}
159
+ muted={theme.muted}
160
+ />
161
+ ),
162
+ close,
163
+ )
164
+ } catch {
165
+ /* dialog stack unavailable — fail-open, retried on the next start */
166
+ }
167
+ },
168
+ })
169
+ } catch {
170
+ /* fail-open — the window must never block or break TUI startup */
171
+ }
172
+ }
package/src/routing.yml CHANGED
@@ -177,6 +177,7 @@ agents:
177
177
  - artifact-management
178
178
  - auto-continue
179
179
  - codemap
180
+ - prompt-refinery
180
181
  - context-compression
181
182
  - incremental-implementation
182
183
  - loop-engineering
@@ -4,7 +4,7 @@
4
4
 
5
5
  Skills are reference modules loaded on demand by agents. Each skill provides domain-specific knowledge — architecture patterns, security checklists, optimization strategies, and implementation guides. Agents load skills when their task matches the skill's description, keeping context focused and token-efficient.
6
6
 
7
- There are **20 skills** divided into **5 domains**.
7
+ There are **21 skills** divided into **5 domains**.
8
8
 
9
9
  ## Skills by Domain
10
10
 
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: prompt-refinery
3
+ description: "Turn a rough, vague, or one-line request into a structured execution contract (objective, scope slices, acceptance criteria, deliverables, open questions) shown to the user BEFORE executing. Use when a request spans multiple concerns or lacks explicit acceptance criteria."
4
+ ---
5
+
6
+ # Prompt Refinery
7
+
8
+ > **A vague request executes expensively and wrong. Refine it into a contract, show the contract, then execute what was confirmed.**
9
+
10
+ ---
11
+
12
+ ## When this fires
13
+
14
+ - The request spans multiple concerns ("refatora o dashboard, corrige os cálculos, melhora a UI") with no explicit acceptance criteria.
15
+ - The request names a desired OUTCOME but not the slices, nomenclature, data sources, or quality bar.
16
+ - The user pastes a long context dump and asks for "melhorar/refatorar/revisar" without structure.
17
+
18
+ A one-line bounded fix ("troque essa cor", "corrija esse typo") does NOT fire this skill — execute directly.
19
+
20
+ ---
21
+
22
+ ## The contract shape (the rewrite target)
23
+
24
+ Produce ALL of the following sections, filling from the request and marking real gaps as open questions — never invent requirements silently:
25
+
26
+ 1. **Objetivo do projeto** — one paragraph: what changes and why.
27
+ 2. **Escopo em fatias numeradas** — each slice independently verifiable (audit/corrections; architecture/IA; nomenclature/statistics; UI/UX; …). Slices the user did not ask for go under "fora de escopo", not here.
28
+ 3. **Critérios de aceite por fatia** — testable statements ("toda moeda passa por Decimal; nenhum float em valor monetário"), not vibes.
29
+ 4. **Entregáveis esperados** — the concrete artifacts (report, route map, dictionary, implementation).
30
+ 5. **Perguntas abertas** — the gaps that change the plan, with your recommended default for each so silence means "proceed with the default".
31
+ 6. **Glossário/nomenclatura proposta** — when the domain has ambiguous terms, propose the canonical names up front.
32
+
33
+ ---
34
+
35
+ ## Operating rules
36
+
37
+ - **Show, then execute.** The refined contract is presented to the user for confirm-or-adjust BEFORE implementation — one confirmation, not a dialogue. Silence or "ok" proceeds with the defaults stated in Perguntas abertas.
38
+ - **Domain mapping stays the ladder's**: after confirmation, slices route through the normal discovery ladder (local selector → Jev → specialist dispatch). The contract is the SPEC, not the dispatcher.
39
+ - **Preserve the user's language** (a PT-BR request refines into PT-BR).
40
+ - **One refinement turn.** The rewrite is a single planning pass on the session model — no extra provider call, no Jev needed for the rewrite itself (decision models answer typed scalars, they do not write prose).
41
+ - **Cost honesty**: the refinement costs roughly one planning turn (~1–4K tokens each way). The expensive thing is executing a mis-specified request; this skill buys that back.