pantheon-opencode 1.6.3-beta.20 → 1.6.3-beta.22

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/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
10
10
  <!-- Add new changes here. Running `node scripts/versioning.mjs apply` will
11
11
  move this section to a versioned entry and reset the template below. -->
12
12
 
13
+ ## [v1.6.3-beta.22] - 2026-11-06
14
+
15
+ ## 🆕 What's New
16
+ - `agent-forge` skill: ask for a dedicated agent ("cria um agente de reviews de PR") and Pantheon interviews you, drafts the canonical agent file (least-privilege permissions, registered-tools-only grants, the governance ladder), confirms, and writes it project- or user-scoped — the host loads it on the next session.
17
+ - Skill discovery now ranks with Jev `mode: "order"`: the top cascade candidates return a full descending ordering with fit scores, not a single winner. `mattpocock/skills` joins the GitHub tier as a known-good reference repo.
18
+
19
+ ## [v1.6.3-beta.21] - 2026-11-06
20
+
21
+ ## 🆕 What's New
22
+ - The J1 enforce block is now an APPROVAL GATE: a high-risk call is denied with an ask — the agent questions the user under a `j1-approval-<hash>` marker; an affirmative answer mints a hash-pinned, TTL-bounded (15 min), session-scoped pass for that exact call, and the retry executes (and records). No observed answer, no pass — fail-closed.
23
+ - QA beta.20 fixes: verify verdict band precedence (0.35–0.65 UNVERIFIABLE inclusive; PASS strictly above), order maps scores back to the caller's candidate ids, `=shadow` no longer reads as off, scorecard count/cost honesty.
24
+
13
25
  ## [v1.6.3-beta.20] - 2026-11-06
14
26
 
15
27
  ## 🆕 What's New
package/README.md CHANGED
@@ -93,7 +93,7 @@ see [Quick Start](docs/QUICKSTART.md).
93
93
 
94
94
  - **14 specialized agents** with one orchestrator, implementation specialists,
95
95
  a quality gate, and supporting roles.
96
- - **21 skills** and reusable instructions for planning, building, reviewing,
96
+ - **22 skills** and reusable instructions for planning, building, reviewing,
97
97
  and documenting work.
98
98
  - **5 local MCP servers** for project memory, persistence, resources, confined
99
99
  script execution, and vision.
package/README.pt-BR.md CHANGED
@@ -71,7 +71,7 @@ apenas — `init` → reiniciar → `/dispatch` → primeiro resultado — veja
71
71
 
72
72
  - **14 agentes especializados**, com um orquestrador, especialistas de
73
73
  implementação, um gate de qualidade e papéis de apoio.
74
- - **21 skills** e instruções reutilizáveis para planejar, construir, revisar e
74
+ - **22 skills** e instruções reutilizáveis para planejar, construir, revisar e
75
75
  documentar.
76
76
  - **5 servidores MCP locais** para memória de projeto, persistência, recursos,
77
77
  execução confinada de scripts e visão.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-opencode",
3
- "version": "1.6.3-beta.20",
3
+ "version": "1.6.3-beta.22",
4
4
  "description": "Multi-agent orchestration for OpenCode \u2014 14 specialized agents, TDD, Themis review gates.",
5
5
  "type": "module",
6
6
  "workspaces": [
package/plugin.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pantheon",
3
3
  "publisher": "ils15",
4
- "version": "1.6.3-beta.20",
4
+ "version": "1.6.3-beta.22",
5
5
  "displayName": "Pantheon",
6
- "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 21 skills, and OpenCode support.",
6
+ "description": "Conductor-Delegate orchestration platform with 14 specialized agents, 22 skills, and OpenCode support.",
7
7
  "agents": "./src/agents",
8
8
  "skills": "./src/skills",
9
9
  "instructions": "./src/instructions",
package/pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
4
4
 
5
5
  [project]
6
6
  name = "pantheon"
7
- version = "1.6.3-beta.20"
7
+ version = "1.6.3-beta.22"
8
8
  description = "Multi-agent orchestration framework"
9
9
  requires-python = ">=3.11"
10
10
  # Python sources under src/mcp/ import fastmcp/pydantic at runtime, but those
@@ -93,7 +93,7 @@ export async function runInteractiveInstall({
93
93
 
94
94
  const componentOptions = [
95
95
  { label: 'agents', value: 'agents', hint: 'Agent configurations and routing (14 agents)' },
96
- { label: 'skills', value: 'skills', hint: `Reusable skill workflows (${21} skills)` },
96
+ { label: 'skills', value: 'skills', hint: `Reusable skill workflows (${22} skills)` },
97
97
  { label: 'instructions', value: 'instructions', hint: 'AGENTS.md and instructional files' },
98
98
  { label: 'prompts', value: 'prompts', hint: 'Prompt templates for agents' },
99
99
  { label: 'commands', value: 'commands', hint: 'OpenCode command shortcuts' },
@@ -178,7 +178,7 @@ function main(args = process.argv.slice(2)) {
178
178
  `# Live J2 scorecard — ${date}`,
179
179
  '',
180
180
  `Route: \`${modelRef.providerID}/${modelRef.id}\`. Operator-run via \`opencode api\``,
181
- '(consented route, billed to the user). 12 scenarios; agreement between the',
181
+ `(consented route, billed to the user). ${rows.length} scenarios; agreement between the`,
182
182
  'live model and the expected pick is the metric — this measures the MODEL,',
183
183
  'unlike the offline harness that measures the plumbing.',
184
184
  '',
@@ -189,7 +189,9 @@ function main(args = process.argv.slice(2)) {
189
189
  `| ${r.state.slice(0, 48)}${r.state.length > 48 ? '…' : ''} | ${r.expect} | ${r.got ?? '—'} | ${r.cost ?? '—'} |`,
190
190
  ),
191
191
  '',
192
- `Total cost: $${totalCost.toFixed(6)}. Honest caveat: one run is a smoke`,
192
+ totalCost > 0
193
+ ? `Total cost: $${totalCost.toFixed(6)} (sum of route-reported costs). Honest caveat: one run is a smoke`
194
+ : `Total cost: NOT reported by the route (the cost field came empty on every call — QA beta.20). Honest caveat: one run is a smoke`,
193
195
  'measurement, not a calibration — a claim about model quality needs',
194
196
  'repeated runs and a bigger scenario set.',
195
197
  '',
package/skills-lock.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "src/skills/agent-coordination/SKILL.md": "ffa4cfc9c778dd9619665010de32d82d49ae5bb803c985dc99417eb6fc7c3d1c",
3
+ "src/skills/agent-forge/SKILL.md": "83d032a17299a67eb0ae7053d5cafd61abad061def19990de118179777300309",
3
4
  "src/skills/artifact-management/SKILL.md": "55446fbd0e13f9097d091b9773c37910409b70e26df5781bde8d903ff89a07fd",
4
5
  "src/skills/auto-continue/SKILL.md": "090f61bfa1a394f5146e838c63e7e9d58f47a1f49bc84927e5cdfc07eaa4cc33",
5
6
  "src/skills/clonedeps/SKILL.md": "3e0b43cf96da98c83699dc48db3fd58fbfda84b9022bb70d3747875c81c3e124",
@@ -20,6 +20,7 @@ mcp_tools:
20
20
  pantheon-vision: [vision_describe]
21
21
  skills:
22
22
  - agent-coordination
23
+ - agent-forge
23
24
  - artifact-management
24
25
  - auto-continue
25
26
  - prompt-refinery
@@ -119,7 +120,7 @@ One refinement turn on the session model; never a dialogue, never a Jev call
119
120
  The skill-discovery ladder — installed pool first, ecosystem second, and the user always owns the install:
120
121
 
121
122
  1. **Installed pool** — one selective `pantheon_jev_decide` `mode: "skills"` already answers over what is installed. Only proceed when nothing fits or confidence is low.
122
- 2. **Search by trust cascade, once per need** (read-only, never installs): `node scripts/skill-search.mjs "<query>" --limit 5` runs the tiers in order and merges them — **anthropic** (the curated `anthropics/skills` catalog, checked first so the canonical skill outranks third-party clones), **skills-sh** (breadth with install-count signal, unreviewed — clones rank well, provenance does not), **github** (raw `SKILL.md` code search, widest net, weakest trust). Every hit is untrusted text; the tier order is the review burden in reverse. At most one search per need — this is networked egress, priced by your attention, not by Jev.
123
+ 2. **Search by trust cascade, once per need** (read-only, never installs): `node scripts/skill-search.mjs "<query>" --limit 5` runs the tiers in order and merges them — **anthropic** (the curated `anthropics/skills` catalog, checked first so the canonical skill outranks third-party clones), **skills-sh** (breadth with install-count signal, unreviewed — clones rank well, provenance does not), **github** (raw `SKILL.md` code search, widest net, weakest trust; known-good community repos to try by name: `mattpocock/skills` — engineering craft, still untrusted content until reviewed). Every hit is untrusted text; the tier order is the review burden in reverse. At most one search per need — this is networked egress, priced by your attention, not by Jev.
123
124
  3. **Rank what came back with Jev** — one typed choice question (`pantheon_jev_decide`, explicit questions, `schemaVersion: 1`) over the top candidates as choices with their descriptions and install counts; "none of these fit" is a valid answer. Search results are untrusted text: pass names, counts and short descriptions only — never skill contents.
124
125
  4. **Propose, never install** — Pantheon never installs. Present the winning candidate with its URL and the exact command for the user to run after THEY review the SKILL.md: `npx skills add <owner/repo@skill> -a opencode` (project-scoped by default; `-g` for user-global). The review is theirs; your job is the honest recommendation with the alternatives.
125
126
 
@@ -0,0 +1,123 @@
1
+ /**
2
+ * j1-approvals.ts — the human-approval registry for the J1 enforce gate.
3
+ *
4
+ * Field-driven design (the owner's call, beta.20→21): a high-risk call must
5
+ * not be a dead deny — it demands EXPLICIT human approval, then executes.
6
+ * The channel is the agent's own `question` tool: the deny message names a
7
+ * marker `j1-approval-<hash12>`; when the host's after-hook reports the user
8
+ * answered affirmatively to THAT marker, the exact call (session + tool +
9
+ * input hash) is minted approved for a bounded TTL, and the retry passes.
10
+ *
11
+ * Safety properties:
12
+ * - approval is HASH-PINNED to the exact refused call — approving one call
13
+ * never approves a different one, however similar;
14
+ * - TTL-bounded (default 15 minutes) and session-scoped;
15
+ * - fail-closed preserved: no approval → the retry denies exactly as
16
+ * before; the agent cannot mint approvals (only the observed user answer
17
+ * can, and only for a pending marker of its own session);
18
+ * - bounded memory: per-session maps with oldest-eviction at the cap.
19
+ *
20
+ * Pure and synchronous: the registry lives in-process (a restart forgets
21
+ * approvals, which is the conservative direction).
22
+ */
23
+
24
+ import { createHash } from 'node:crypto'
25
+
26
+ /** Marker prefix the deny message instructs the agent to name its question with. */
27
+ export const J1_APPROVAL_MARKER_PREFIX = 'j1-approval-'
28
+
29
+ /** Approvals expire after this many milliseconds (bounded trust window). */
30
+ export const J1_APPROVAL_TTL_MS = 15 * 60 * 1000
31
+
32
+ /** Per-session approval cap; oldest evicted beyond it. */
33
+ const MAX_APPROVALS_PER_SESSION = 64
34
+
35
+ /** Affirmative answer tokens the user may give (case-insensitive, exact-word). */
36
+ const AFFIRMATIVE = new Set(['approve', 'approved', 'yes', 'y', 'sim', 'aprovar', 'aprovado'])
37
+
38
+ /** The marker name for one approval request: `j1-approval-<first 12 hash chars>`. */
39
+ export function j1ApprovalMarker(inputHash: string): string {
40
+ return `${J1_APPROVAL_MARKER_PREFIX}${inputHash.slice(0, 12)}`
41
+ }
42
+
43
+ /** Extract the hash12 from a marker name; null when the name is not one. */
44
+ export function hashFromMarker(name: string): string | null {
45
+ if (!name.startsWith(J1_APPROVAL_MARKER_PREFIX)) return null
46
+ const tail = name.slice(J1_APPROVAL_MARKER_PREFIX.length)
47
+ return /^[0-9a-f]{12}$/.test(tail) ? tail : null
48
+ }
49
+
50
+ /**
51
+ * Whether a serialized `question` tool RESULT reads as the user approving the
52
+ * marker. Defensive by design: the result shape is host-defined; we match the
53
+ * marker and an affirmative token anywhere in a bounded serialization.
54
+ */
55
+ export function isAffirmativeAnswer(marker: string, serializedResult: string): boolean {
56
+ if (!serializedResult.includes(marker)) return false
57
+ const bounded = serializedResult.slice(0, 2000).toLowerCase()
58
+ for (const token of AFFIRMATIVE) {
59
+ if (new RegExp(`\\b${token}\\b`).test(bounded)) return true
60
+ }
61
+ return false
62
+ }
63
+
64
+ interface ApprovalStore {
65
+ /** hash12 -> approvedAt (ms) */
66
+ approved: Map<string, number>
67
+ }
68
+
69
+ const store = new Map<string, ApprovalStore>()
70
+
71
+ function pruneSession(session: ApprovalStore, now: number): void {
72
+ for (const [hash, at] of session.approved) {
73
+ if (now - at > J1_APPROVAL_TTL_MS) session.approved.delete(hash)
74
+ }
75
+ while (session.approved.size > MAX_APPROVALS_PER_SESSION) {
76
+ const oldest = [...session.approved.entries()].sort((a, b) => a[1] - b[1])[0]
77
+ if (oldest === undefined) break
78
+ session.approved.delete(oldest[0])
79
+ }
80
+ }
81
+
82
+ /** Mint one approval (the after-hook, on an observed affirmative user answer). */
83
+ export function mintApproval(sessionID: string, inputHash: string, now = Date.now()): void {
84
+ if (sessionID === '' || inputHash === '') return
85
+ const session = store.get(sessionID) ?? { approved: new Map() }
86
+ session.approved.set(inputHash.slice(0, 12), now)
87
+ pruneSession(session, now)
88
+ store.set(sessionID, session)
89
+ }
90
+
91
+ /** Whether the exact call (session + input hash) carries a live approval. */
92
+ export function hasApproval(sessionID: string, inputHash: string, now = Date.now()): boolean {
93
+ const session = store.get(sessionID)
94
+ if (session === undefined) return false
95
+ const at = session.approved.get(inputHash.slice(0, 12))
96
+ if (at === undefined) return false
97
+ if (now - at > J1_APPROVAL_TTL_MS) {
98
+ session.approved.delete(inputHash.slice(0, 12))
99
+ return false
100
+ }
101
+ return true
102
+ }
103
+
104
+ /** Drop everything (tests). */
105
+ export function resetApprovals(): void {
106
+ store.clear()
107
+ }
108
+
109
+ /** Stable content hash for a tool input (same digest as the risk gate uses). */
110
+ export function approvalInputHash(input: unknown): string {
111
+ let serialized: string
112
+ if (typeof input === 'string') {
113
+ serialized = input
114
+ } else {
115
+ try {
116
+ const json = JSON.stringify(input)
117
+ serialized = json === undefined ? String(input) : json
118
+ } catch {
119
+ serialized = 'unserializable-tool-input'
120
+ }
121
+ }
122
+ return createHash('sha256').update(serialized, 'utf8').digest('hex')
123
+ }
@@ -516,6 +516,7 @@ export async function runJevDecision(
516
516
  // neither has a telemetry point — they are tool modes, not shadow gates.
517
517
  let prebuilt: Omit<NativeDecisionRequest, 'model'> | undefined
518
518
  let candidateSource: JevDecisionPreparation['candidateSource'] | undefined
519
+ let orderCandidates: readonly string[] = []
519
520
  if (requested.mode === 'review') {
520
521
  const prepared = buildJevReviewRequest(input ?? {})
521
522
  if (!prepared.ok) {
@@ -542,6 +543,7 @@ export async function runJevDecision(
542
543
  } else if (requested.mode === 'order') {
543
544
  const prepared = buildJevOrderRequest(input ?? {})
544
545
  if (!prepared.ok) return refusal(prepared.reasonCode, prepared.detail)
546
+ orderCandidates = prepared.candidates
545
547
  prebuilt = prepared.request
546
548
  }
547
549
  const result = await runGatedNativeJevCall({
@@ -674,7 +676,11 @@ export async function runJevDecision(
674
676
  // v3.1 ordering: one fit question per candidate (2-4), sorted descending.
675
677
  // Null score = the host answered nothing usable for that candidate —
676
678
  // visible, placed last, never guessed.
677
- const ordering = consumeJevOrderResult(result.call.response, result.call.request)
679
+ const ordering = consumeJevOrderResult(
680
+ result.call.response,
681
+ result.call.request,
682
+ orderCandidates,
683
+ )
678
684
  return JSON.stringify({
679
685
  advisory: true,
680
686
  effect: 'none',
@@ -152,7 +152,7 @@ export const J3_ESCALATION_CHEAP_MODEL = 'opencode/mimo-v2.6-flash'
152
152
  /** Bound for the composed state text (the template is ~320 chars). */
153
153
  export const J3_ESCALATION_STATE_MAX_LENGTH = 512
154
154
 
155
- const FLAG_ON = new Set(['1', 'on', 'true'])
155
+ const FLAG_ON = new Set(['1', 'on', 'true', 'shadow'])
156
156
  const TOKEN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/
157
157
  const SHA256_HEX = /^[0-9a-f]{64}$/
158
158
  /** Largest state_chars printed into the template (8 digits). */
@@ -22,7 +22,8 @@
22
22
  * Zeus can check 1–4 named claims in ONE typed round-trip: one `predicate`
23
23
  * question per claim (within the 4-question bound), the claim text riding that
24
24
  * question's instructions. The consumer maps each answer: probability
25
- * ≥ {@link VERIFY_PASS_THRESHOLD} → `PASS`, below → `FAIL`, and every refusal,
25
+ * > {@link VERIFY_PASS_THRESHOLD} (0.65) → `PASS`; 0.35–0.65 → `UNVERIFIABLE`; below →
26
+ * `FAIL`; and every refusal,
26
27
  * timeout, duplicate or malformed answer → `BLOCK` (fail-closed: an
27
28
  * unanswered mandatory claim must never read as verified). The tool itself
28
29
  * never acts on a verdict — `effect` stays `none` — and a gate-chain refusal
@@ -73,7 +74,13 @@ export const VERIFY_MAX_CLAIMS = 4
73
74
  export const CLAIM_MAX_LENGTH = 200
74
75
 
75
76
  /** Predicate probability at or above which a claim counts as PASS. */
76
- export const VERIFY_PASS_THRESHOLD = 0.5
77
+ /**
78
+ * PASS lives strictly ABOVE the UNVERIFIABLE band (QA beta.20: with PASS at
79
+ * 0.5 the documented 0.35-0.65 band was unreachable at its top half — 0.50
80
+ * and 0.65 returned PASS). Verdicts: < 0.35 FAIL, 0.35-0.65 UNVERIFIABLE,
81
+ * > 0.65 PASS.
82
+ */
83
+ export const VERIFY_PASS_THRESHOLD = 0.65
77
84
 
78
85
  const CANDIDATE_ID_MAX_LENGTH = 64
79
86
  const CLAIM_NAME_MAX_LENGTH = 64
@@ -300,7 +307,12 @@ export type JevOrderBuildFailure =
300
307
  export type JevOrderBuildDetail = 'ORDER_CANDIDATE_COUNT_RANGE'
301
308
 
302
309
  export type JevOrderBuild =
303
- | { readonly ok: true; readonly request: Omit<NativeDecisionRequest, 'model'> }
310
+ | {
311
+ readonly ok: true
312
+ readonly request: Omit<NativeDecisionRequest, 'model'>
313
+ /** The caller's candidate ids in question order (QA beta.20: the consumer must map scores back to THESE, not positional c1..cN). */
314
+ readonly candidates: readonly string[]
315
+ }
304
316
  | {
305
317
  readonly ok: false
306
318
  readonly reasonCode: JevOrderBuildFailure
@@ -308,7 +320,11 @@ export type JevOrderBuild =
308
320
  }
309
321
 
310
322
  export type JevOrderPreparation =
311
- | { readonly ok: true; readonly request: NativeDecisionRequest }
323
+ | {
324
+ readonly ok: true
325
+ readonly request: NativeDecisionRequest
326
+ readonly candidates: readonly string[]
327
+ }
312
328
  | {
313
329
  readonly ok: false
314
330
  readonly reasonCode: JevOrderBuildFailure
@@ -387,7 +403,11 @@ export function buildJevOrderRequest(input: unknown): JevOrderBuild {
387
403
  ]),
388
404
  questions: Object.freeze(questions.map((question) => Object.freeze(question))),
389
405
  } satisfies Omit<NativeDecisionRequest, 'model'>
390
- return { ok: true, request: Object.freeze(request) }
406
+ return {
407
+ ok: true,
408
+ request: Object.freeze(request),
409
+ candidates: Object.freeze(candidates.map((c) => c.id)),
410
+ }
391
411
  }
392
412
 
393
413
  export function prepareJevOrderRequest(
@@ -403,6 +423,7 @@ export function prepareJevOrderRequest(
403
423
  input: built.request.input,
404
424
  questions: built.request.questions,
405
425
  },
426
+ candidates: built.candidates,
406
427
  }
407
428
  }
408
429
 
@@ -420,6 +441,7 @@ export interface JevOrderEntry {
420
441
  export function consumeJevOrderResult(
421
442
  response: unknown,
422
443
  request: NativeDecisionRequest,
444
+ candidates: readonly string[],
423
445
  ): ReadonlyArray<JevOrderEntry> {
424
446
  const advice = consumeJevDecisionResult(response, request)
425
447
  const entries: Array<{ id: string; score: number | null; order: number }> = []
@@ -429,7 +451,9 @@ export function consumeJevOrderResult(
429
451
  answer !== undefined && answer.type === 'score' && typeof answer.score === 'number'
430
452
  ? answer.score
431
453
  : null
432
- entries.push({ id: `c${index + 1}`, score, order: index })
454
+ // QA beta.20: map back to the CALLER's candidate id — positional c1..cN
455
+ // told the user nothing.
456
+ entries.push({ id: candidates[index] ?? `c${index + 1}`, score, order: index })
433
457
  })
434
458
  return Object.freeze(
435
459
  entries
@@ -609,7 +633,7 @@ export type VerifyClaimVerdict = 'PASS' | 'FAIL' | 'UNVERIFIABLE' | 'BLOCK'
609
633
 
610
634
  /**
611
635
  * Consume a host Decisions response against the prepared verify request:
612
- * one verdict per claim name. Probability ≥ {@link VERIFY_PASS_THRESHOLD} is
636
+ * one verdict per claim name. Probability > {@link VERIFY_PASS_THRESHOLD} is
613
637
  * `PASS`, below is `FAIL`; error answers, missing answers and any unusable
614
638
  * response shape are `BLOCK` — fail-closed.
615
639
  */
@@ -624,7 +648,7 @@ export function consumeJevVerifyResult(
624
648
  if (answer !== undefined && answer.type === 'predicate') {
625
649
  const probability = answer.probability ?? 0
626
650
  verdicts[question.name] =
627
- probability >= VERIFY_PASS_THRESHOLD
651
+ probability > VERIFY_PASS_THRESHOLD
628
652
  ? 'PASS'
629
653
  : probability >= VERIFY_UNVERIFIABLE_LOW
630
654
  ? 'UNVERIFIABLE'
@@ -89,7 +89,7 @@ export const J1_RISK_GATE_STATE_MAX_LENGTH = 512
89
89
  /** Predicate probability at or above which the intent counts as consistent. */
90
90
  export const RISK_GATE_INTENT_THRESHOLD = 0.5
91
91
 
92
- const FLAG_ON = new Set(['1', 'on', 'true'])
92
+ const FLAG_ON = new Set(['1', 'on', 'true', 'shadow'])
93
93
  const TOOL_NAME_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/
94
94
  const SHA256_HEX = /^[0-9a-f]{64}$/
95
95
  const SCOPES: ReadonlySet<string> = new Set(['write', 'execute', 'read'])
@@ -192,7 +192,10 @@ export function isRiskGateTarget(tool: unknown): tool is string {
192
192
 
193
193
  /**
194
194
  * sha256 hex of the serialized tool input — an opaque correlation value, the
195
- * only content-derived field that ever leaves this process. Unserializable
195
+ * only content-derived field that ever leaves this process. The hash is a
196
+ * DETERMINISTIC pseudonymization (unsalted SHA-256 — same input, same hash by
197
+ * design, so approvals can be pinned to the exact call), NOT anonymization:
198
+ * someone holding the dictionary can reconstruct the input. Unserializable
196
199
  * inputs hash a stable marker; this never throws.
197
200
  */
198
201
  export function hashToolInput(input: unknown): string {
package/src/plugin-v2.ts CHANGED
@@ -116,6 +116,13 @@ import {
116
116
  import { GOAL_LOOP_DEFAULTS, GoalStore } from './pantheon/goal-loop.ts'
117
117
  import { createGuardPathResolver } from './pantheon/guard-path.ts'
118
118
  import { createJTelemetryMirror } from './pantheon/j-telemetry-file.ts'
119
+ import {
120
+ approvalInputHash,
121
+ hasApproval,
122
+ isAffirmativeAnswer,
123
+ j1ApprovalMarker,
124
+ mintApproval,
125
+ } from './pantheon/j1-approvals.ts'
119
126
  import type { V2JevDecisionRuntime } from './pantheon/jev-decision-tool.ts'
120
127
  import { specialistCallerAllowlist } from './pantheon/jev-decision-tool.ts'
121
128
  import {
@@ -2159,21 +2166,35 @@ async function registerV2ToolHooks(
2159
2166
  // block's visible form. Unavailability never denies (fail-open by
2160
2167
  // design: a dead budget must not brick every shell call).
2161
2168
  if (j1Mode === 'enforce') {
2169
+ // The approval path (field beta.21: "exigir uma aprovação explícita
2170
+ // para execução" — a deny must be askable, not destructive): an
2171
+ // approved retry of the EXACT call (session + input hash, TTL
2172
+ // bounded) passes without re-asking.
2173
+ const enforceEvent = event as { tool?: unknown; input?: unknown; sessionID?: unknown }
2174
+ const sessionID =
2175
+ typeof enforceEvent.sessionID === 'string' ? enforceEvent.sessionID : ''
2176
+ const inputHash = approvalInputHash(enforceEvent.input)
2177
+ if (sessionID !== '' && hasApproval(sessionID, inputHash)) {
2178
+ // Approved by the user: execute — and still observe (the
2179
+ // approved execution is exactly the record the baseline wants).
2180
+ void j1Observer(event)
2181
+ return
2182
+ }
2162
2183
  const verdict = (await j1Observer(event)) as J1Verdict | undefined
2163
2184
  if (verdict?.block === true) {
2164
- // The block is a HANDOFF CONTRACT (field: "risco alto deveria
2165
- // vir pra mim executar manualmente"), not an error to route
2166
- // around: present the refused call to the human for a manual
2167
- // decision. Never echo the tool input here — the arguments may
2168
- // carry the very secret the risk score flagged; the agent owns
2169
- // its own rendering.
2185
+ // The block is an APPROVAL REQUEST (not an error to route
2186
+ // around): ask the user through the `question` tool with the
2187
+ // marker below; an affirmative answer mints a hash-pinned,
2188
+ // TTL-bounded approval and the retry passes. Never echo the
2189
+ // tool input here — the arguments may carry the very secret
2190
+ // the risk score flagged; the agent owns its own rendering.
2170
2191
  throw new Error(
2171
2192
  `[J1 enforce] risco ${verdict.riskScore?.toFixed(2)} >= threshold ` +
2172
- '— ENTREGUE AO USUÁRIO: apresente a chamada ' +
2173
- 'recusada (ferramenta + o que ela faria), sem executá-la nem contorná-la de outra forma, ' +
2174
- 'e pergunte se ele executa manualmente. Alternativas dele: ajustar ' +
2175
- 'PANTHEON_J1_ENFORCE_THRESHOLD, rebaixar o modo para shadow/warn, ou reexecutar a tarefa ' +
2176
- 'sem o passo arriscado.',
2193
+ `— APROVAÇÃO EXPLÍCITA NECESSÁRIA: use a tool question com o nome ` +
2194
+ `"${j1ApprovalMarker(inputHash)}" perguntando ao USUÁRIO se aprova esta exata chamada ` +
2195
+ '(apresente a ferramenta e o que ela faria, sem executá-la nem contorná-la). ' +
2196
+ 'Se ele aprovar, reintente a MESMA chamada — ela passará. Se ele recusar, siga sem o ' +
2197
+ 'passo arriscado ou entregue a execução manual a ele.',
2177
2198
  )
2178
2199
  }
2179
2200
  } else {
@@ -2222,6 +2243,35 @@ async function registerV2ToolHooks(
2222
2243
  try {
2223
2244
  subagentOrigins.forget(event)
2224
2245
  boundedReadOrigins?.forget(event)
2246
+ // J1 approval minter: the user's affirmative answer to a
2247
+ // `j1-approval-<hash12>` question mints the hash-pinned, TTL-bounded
2248
+ // approval the enforce gate checks. Only the OBSERVED host result can
2249
+ // mint — the agent cannot fabricate an answer.
2250
+ if (j1Mode === 'enforce') {
2251
+ try {
2252
+ const after = (event ?? {}) as {
2253
+ tool?: unknown
2254
+ sessionID?: unknown
2255
+ output?: unknown
2256
+ input?: unknown
2257
+ }
2258
+ if (after.tool === 'question') {
2259
+ const sessionID = typeof after.sessionID === 'string' ? after.sessionID : ''
2260
+ const serialized = JSON.stringify(after.output ?? {}) ?? ''
2261
+ const markerMatch = serialized.match(/j1-approval-([0-9a-f]{12})/)
2262
+ const markerHash = markerMatch?.[1]
2263
+ if (sessionID !== '' && markerHash !== undefined) {
2264
+ const name = `j1-approval-${markerHash}`
2265
+ if (isAffirmativeAnswer(name, serialized)) {
2266
+ mintApproval(sessionID, markerHash)
2267
+ }
2268
+ }
2269
+ }
2270
+ } catch {
2271
+ // The minter is best-effort; a parse failure just means no
2272
+ // approval (fail-closed).
2273
+ }
2274
+ }
2225
2275
  await v2ExecuteAfter(event)
2226
2276
  // Formatter + delegation audit STOP (#266). Awaited for the same
2227
2277
  // reason V1 awaits it: the log record should exist before the tool
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
- "version": "1.6.3-beta.20",
3
+ "version": "1.6.3-beta.22",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pantheon-tui",
9
- "version": "1.6.3-beta.20",
9
+ "version": "1.6.3-beta.22",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@opencode-ai/plugin": "1.18.33",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pantheon-tui",
3
3
  "type": "module",
4
- "version": "1.6.3-beta.20",
4
+ "version": "1.6.3-beta.22",
5
5
  "description": "Pantheon TUI plugin — V1 rich sidebar and usage gauges; native V2 status, session and delegation sidebar",
6
6
  "license": "MIT",
7
7
  "engines": {
package/src/routing.yml CHANGED
@@ -174,6 +174,7 @@ agents:
174
174
  - talos
175
175
  skills:
176
176
  - agent-coordination
177
+ - agent-forge
177
178
  - artifact-management
178
179
  - auto-continue
179
180
  - codemap
@@ -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 **21 skills** divided into **5 domains**.
7
+ There are **22 skills** divided into **5 domains**.
8
8
 
9
9
  ## Skills by Domain
10
10
 
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: agent-forge
3
+ description: "Forge a new OpenCode agent on demand — interview the user, draft a canonical agent .md (frontmatter, permissions, MCP grants, governance ladder), write it project- or user-scoped, and validate it against the existing roster. Use when the user asks for 'um agente que faça X', 'create an agent for X', or wants a specialist that the roster lacks."
4
+ ---
5
+
6
+ # Agent Forge
7
+
8
+ > **A new agent is a contract, not a vibe. Interview, draft against the canonical shape, confirm, forge — and never shadow an existing specialist.**
9
+
10
+ ---
11
+
12
+ ## When this fires
13
+
14
+ - The user asks for a dedicated agent ("cria um agente de reviews de PR", "I want an agent that watches deploys").
15
+ - A recurring task keeps being delegated with ad-hoc Briefs and would benefit from a standing definition.
16
+
17
+ Do NOT fire when an existing specialist covers the domain — route there instead (the 14 canonical agents + any agents already forged in this project).
18
+
19
+ ---
20
+
21
+ ## The interview (before any writing)
22
+
23
+ Ask AT MOST four questions, with your recommended default on each so silence proceeds:
24
+
25
+ 1. **Gap** — what recurring task/domain should this agent own? (default: infer from the request)
26
+ 2. **Surface** — which tools does it need? read-only, edit, shell, webfetch, MCP grants? (default: least privilege that can do the job)
27
+ 3. **Scope** — project (`.opencode/agents/`) or user-global (`~/.config/opencode/agents/`)? (default: project)
28
+ 4. **Model posture** — reasoning effort low/medium/high (default: medium; low for narrow mechanical agents).
29
+
30
+ Then present the draft definition for confirm-or-adjust BEFORE writing (the same contract discipline as prompt-refinery).
31
+
32
+ ---
33
+
34
+ ## The forged file (canonical shape)
35
+
36
+ ```markdown
37
+ ---
38
+ name: <kebab-id> # must NOT collide with the 14 canonical ids
39
+ description: "<what it owns> — <domain keywords for routing>. Use when <trigger>."
40
+ mode: subagent # or 'all' when it may also be invoked directly
41
+ reasoning_effort: low|medium|high
42
+ permission:
43
+ read: allow
44
+ grep: allow
45
+ glob: allow
46
+ edit: allow|deny # least privilege from the interview
47
+ shell: allow|deny
48
+ webfetch: allow|deny
49
+ task: { "*": deny } # forged agents do not dispatch by default
50
+ mcp_tools: # ONLY registered servers/tools; 'all' or exact lists
51
+ pantheon-resources: all
52
+ skills: [] # add only installed, reviewed skills
53
+ ---
54
+
55
+ ## MCP governance (identical ladder, grant-aware)
56
+ <copy the governance ladder block verbatim from any canonical agent — the
57
+ escalation order and cost rules are identical for every agent.>
58
+
59
+ ## Role
60
+ <2-4 sentences: what it owns, what it NEVER does, and where it escalates.>
61
+ ```
62
+
63
+ Rules that are NOT optional:
64
+
65
+ - **No collision** — the id must differ from every canonical agent and every already-forged agent in scope; on collision, propose a distinguishable name.
66
+ - **Grants must exist** — every `mcp_tools` entry names a server/tool that is actually registered; an exact list beats `all` whenever the role is narrow.
67
+ - **Governance identical** — the ladder block is byte-copied from a canonical agent; a forged agent never invents its own escalation rules.
68
+ - **Never overwrite** — if the target file exists, show it and ask before replacing.
69
+ - **Routing honesty** — project agents are picked up by the host automatically; do not claim they are in `routing.yml` or the decision catalogs (those are package-level and validated by tests).
70
+
71
+ ---
72
+
73
+ ## After forging
74
+
75
+ Tell the user: restart OpenCode (or start a new session) for the host to load the new agent; invoke it with `@<name>`. If the agent should also appear in the local decision routing later, that is a package-level change — note it as a follow-up, never silently.