@rune-kit/rune 2.14.0 → 2.15.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 (67) hide show
  1. package/README.md +19 -11
  2. package/compiler/__tests__/adapter-model-mapping.test.js +152 -0
  3. package/compiler/__tests__/context-preview-signal.test.js +166 -0
  4. package/compiler/__tests__/oracle-bundle-format.test.js +210 -0
  5. package/compiler/__tests__/oracle-pending-schema.test.js +209 -0
  6. package/compiler/__tests__/skill-description-quality.test.js +147 -0
  7. package/compiler/adapters/antigravity.js +17 -1
  8. package/compiler/adapters/claude.js +4 -0
  9. package/compiler/adapters/codex.js +16 -1
  10. package/compiler/adapters/cursor.js +4 -0
  11. package/compiler/adapters/generic.js +14 -1
  12. package/compiler/adapters/openclaw.js +15 -1
  13. package/compiler/adapters/opencode.js +17 -1
  14. package/compiler/adapters/windsurf.js +4 -0
  15. package/package.json +1 -1
  16. package/skills/adversary/SKILL.md +61 -1
  17. package/skills/adversary/evals.md +79 -0
  18. package/skills/adversary/references/context-bundle-format.md +122 -0
  19. package/skills/adversary/references/oracle-mode.md +116 -0
  20. package/skills/asset-creator/SKILL.md +1 -1
  21. package/skills/audit/SKILL.md +2 -1
  22. package/skills/autopsy/SKILL.md +1 -1
  23. package/skills/ba/SKILL.md +1 -1
  24. package/skills/brainstorm/SKILL.md +1 -1
  25. package/skills/browser-pilot/SKILL.md +1 -1
  26. package/skills/completion-gate/SKILL.md +1 -1
  27. package/skills/constraint-check/SKILL.md +1 -1
  28. package/skills/context-engine/SKILL.md +85 -1
  29. package/skills/context-engine/references/preview-gate.md +139 -0
  30. package/skills/cook/SKILL.md +1 -0
  31. package/skills/db/SKILL.md +1 -1
  32. package/skills/debug/SKILL.md +6 -4
  33. package/skills/dependency-doctor/SKILL.md +1 -1
  34. package/skills/design/SKILL.md +1 -1
  35. package/skills/doc-processor/SKILL.md +1 -1
  36. package/skills/docs/SKILL.md +1 -1
  37. package/skills/docs-seeker/SKILL.md +1 -1
  38. package/skills/fix/SKILL.md +4 -3
  39. package/skills/git/SKILL.md +1 -1
  40. package/skills/hallucination-guard/SKILL.md +1 -1
  41. package/skills/integrity-check/SKILL.md +1 -1
  42. package/skills/journal/SKILL.md +1 -1
  43. package/skills/logic-guardian/SKILL.md +1 -1
  44. package/skills/marketing/SKILL.md +1 -1
  45. package/skills/mcp-builder/SKILL.md +1 -1
  46. package/skills/onboard/SKILL.md +1 -1
  47. package/skills/perf/SKILL.md +1 -1
  48. package/skills/plan/SKILL.md +1 -1
  49. package/skills/preflight/SKILL.md +1 -1
  50. package/skills/research/SKILL.md +1 -1
  51. package/skills/retro/SKILL.md +1 -1
  52. package/skills/review/SKILL.md +2 -2
  53. package/skills/review-intake/SKILL.md +1 -1
  54. package/skills/safeguard/SKILL.md +1 -1
  55. package/skills/scaffold/SKILL.md +1 -1
  56. package/skills/sentinel/SKILL.md +1 -1
  57. package/skills/sentinel-env/SKILL.md +1 -1
  58. package/skills/session-bridge/SKILL.md +91 -4
  59. package/skills/session-bridge/references/detach-protocol.md +111 -0
  60. package/skills/skill-forge/SKILL.md +1 -1
  61. package/skills/slides/SKILL.md +1 -1
  62. package/skills/surgeon/SKILL.md +1 -1
  63. package/skills/team/SKILL.md +3 -0
  64. package/skills/trend-scout/SKILL.md +1 -1
  65. package/skills/video-creator/SKILL.md +1 -1
  66. package/skills/watchdog/SKILL.md +1 -1
  67. package/skills/worktree/SKILL.md +1 -1
@@ -3,11 +3,13 @@ name: adversary
3
3
  description: "Pre-implementation red-team analysis. Use when a plan is high-risk, critical path, or expensive to reverse. Challenges plans before code is written — finds edge cases, security holes, scalability bottlenecks, error propagation risks, and integration conflicts. Catches flaws at plan time (10x cheaper than post-implementation)."
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.1.0"
6
+ version: "0.2.0"
7
7
  layer: L2
8
8
  model: opus
9
9
  group: quality
10
10
  tools: "Read, Glob, Grep"
11
+ emit: oracle.dispatched, oracle.response, oracle.failed
12
+ listen: agent.stuck, context.preview
11
13
  ---
12
14
 
13
15
  # adversary
@@ -37,12 +39,16 @@ Every finding MUST reference the specific plan section, file, or assumption it c
37
39
  - `scout` (L2): find existing code that might conflict with planned changes
38
40
  - `docs-seeker` (L3): verify framework/API assumptions in the plan are correct and current
39
41
  - `hallucination-guard` (L3): verify that APIs, packages, or patterns referenced in the plan actually exist
42
+ - `context-engine` (L3): (oracle-mode) emit `context.preview` before bundle build to gate token cost
43
+ - `session-bridge` (L3): (oracle-mode) detach protocol when target model is opus-class for non-blocking dispatch
40
44
 
41
45
  ## Called By (inbound)
42
46
 
43
47
  - `cook` (L1): Phase 2.5 — after plan approval, before TDD
44
48
  - `plan` (L2): optional post-step for critical features
45
49
  - `team` (L1): when decomposing large tasks, adversary validates the decomposition
50
+ - `debug` (L2): (oracle-mode) listens to `agent.stuck` from debug after 3 disproved hypotheses
51
+ - `fix` (L2): (oracle-mode) listens to `agent.stuck` from fix after 2+ failed attempts
46
52
  - User: `/rune adversary` direct invocation
47
53
 
48
54
  ## Cross-Hub Connections
@@ -229,6 +235,54 @@ Trigger: plan modifies < 3 files AND no auth/payment/data logic.
229
235
  Steps 2 and 5 only (security + integration). Used when `sentinel` requests adversarial pre-analysis.
230
236
  Trigger: plan involves auth, crypto, payment, or user data handling.
231
237
 
238
+ ### Mode: oracle (v0.2.0)
239
+
240
+ **Triggered by**: `agent.stuck` signal — emitted by `debug` (after 3 disproved hypotheses) or `fix` (after 2+ failed attempts on the same file).
241
+
242
+ **Purpose**: Break confirmation-bias loops. The same agent that read `auth.ts` 3 times has formed a theory it cannot un-form. Oracle-mode dispatches a stateless second-model pass with explicit "no prior context" framing, breaking the semantic loop that `scout`'s zoom-out mode (structural pivot) cannot.
243
+
244
+ **When NOT to use**:
245
+ - Single hypothesis cycle — escalate only after 3 cycles in `debug` or 2 attempts in `fix`
246
+ - Trivial single-file bugs — overhead exceeds value
247
+ - When the user already knows the answer — they're trying to validate, not diagnose
248
+
249
+ **Protocol**:
250
+
251
+ 1. **Pre-bundle gate** — emit `context.preview` to `context-engine` first; abort if action=block
252
+ 2. **Build context bundle** — see `references/context-bundle-format.md` for exact format
253
+ 3. **Dispatch** — emit `oracle.dispatched` signal; route via `session-bridge` detach if target model is opus-class (non-blocking)
254
+ 4. **Wait for response** — synchronous if model is sonnet-class, polled via `.rune/oracle-pending/<id>.json` if opus-class
255
+ 5. **Validate response** — every claim MUST cite file:line. Strip + warn on uncited claims (`oracle.failed` if all claims uncited)
256
+ 6. **Emit response** — `oracle.response` carries the validated diagnosis, consumed by `debug`/`fix` to override or refine their current hypothesis
257
+
258
+ **Bundle format** (mandatory regex-validated):
259
+
260
+ ```
261
+ [SYSTEM] You are Oracle, a focused one-shot problem solver. You have NO prior context — assume zero project knowledge. Cite file:line for every claim. Reject any claim you cannot ground in the provided files.
262
+
263
+ [USER] <agent stuck after N hypothesis cycles. What is the most likely root cause not yet considered?>
264
+
265
+ ### File 1: <relative/path/to/file.ts>
266
+ <file content, normalized whitespace, max 4k chars per file>
267
+
268
+ ### File 2: <...>
269
+ <...>
270
+ ```
271
+
272
+ **Hard caps**:
273
+ - Bundle ≤ 100k tokens (estimated via char count × 0.25)
274
+ - Per-file ≤ 4k chars (truncate with explicit `... [truncated]` marker)
275
+ - Max 12 files per bundle (force caller to prune larger sets)
276
+
277
+ **Response contract** — Oracle reply MUST contain:
278
+ - A primary diagnosis (1-3 sentences)
279
+ - At least 1 file:line citation per claim
280
+ - An action recommendation (specific edit, additional file to read, hypothesis to test)
281
+
282
+ Replies failing this contract are rejected — `oracle.failed` emitted, primary agent continues without second opinion.
283
+
284
+ See `references/oracle-mode.md` for the full protocol and integration with `debug`/`fix`.
285
+
232
286
  ## Constraints
233
287
 
234
288
  1. MUST challenge every plan — no rubber-stamping. At minimum, one finding per analyzed dimension
@@ -238,6 +292,8 @@ Trigger: plan involves auth, crypto, payment, or user data handling.
238
292
  5. MUST use concrete attack scenarios, not vague warnings ("could be a problem" is NOT a finding)
239
293
  6. MUST NOT block on MEDIUM/LOW findings — only CRITICAL and HIGH trigger REVISE verdict
240
294
  7. MUST include Strength Notes — adversary finds weaknesses AND acknowledges what's well-designed
295
+ 8. (oracle-mode) MUST emit `context.preview` BEFORE building the bundle — abort if context-engine action=block
296
+ 9. (oracle-mode) MUST validate every Oracle reply citation against the provided files — reject uncited claims as `oracle.failed`
241
297
 
242
298
  ## Mesh Gates
243
299
 
@@ -256,6 +312,9 @@ Trigger: plan involves auth, crypto, payment, or user data handling.
256
312
  | Missing context — challenging plan without understanding existing codebase | HIGH | Step 0 MUST load existing code context via scout before challenging |
257
313
  | Scope creep — reviewing existing code quality instead of plan quality | MEDIUM | Adversary reviews THE PLAN, not the codebase. Existing code is context only |
258
314
  | Redundancy with review/preflight — duplicating post-implementation checks | MEDIUM | Adversary operates PRE-implementation only. Never run adversary on existing code |
315
+ | (oracle-mode) Bundle exceeds token cap — caller didn't prune | HIGH | Caller MUST run `context.preview` first; adversary fails fast with `oracle.failed` instead of silently truncating signal |
316
+ | (oracle-mode) Oracle reply has no citations — model improvised | CRITICAL | Reject reply with `oracle.failed`. Primary agent continues without second opinion (better than acting on hallucination) |
317
+ | (oracle-mode) Loop: oracle reply triggers another `agent.stuck` | HIGH | Cap at 1 oracle dispatch per primary-agent stuck cycle. Subsequent stucks must escalate to user |
259
318
 
260
319
  ## Done When
261
320
 
@@ -265,6 +324,7 @@ Trigger: plan involves auth, crypto, payment, or user data handling.
265
324
  - Verdict rendered: REVISE, HARDEN, or PROCEED
266
325
  - Findings formatted for consumption by cook Phase 3 (if PROCEED) or plan (if REVISE)
267
326
  - Strength Notes section acknowledges well-designed aspects of the plan
327
+ - (oracle-mode) If dispatched: response cited file:line for each claim, or `oracle.failed` emitted with rejection reason
268
328
 
269
329
  ## Returns
270
330
 
@@ -0,0 +1,79 @@
1
+ # Adversary — Evaluation Scenarios
2
+
3
+ Synthetic scenarios for verifying adversary skill behavior. Each eval has setup, expected behavior, and pass/fail criteria.
4
+
5
+ ## E01: Full red-team on payment plan (happy path)
6
+
7
+ **Setup**: User provides plan to add Stripe checkout flow with webhook handlers.
8
+
9
+ **Expected**:
10
+ - All 5 dimensions analyzed
11
+ - Security findings include: webhook signature verification, idempotency keys, amount tampering
12
+ - Integration findings include: existing user-account schema, order state machine
13
+ - Verdict: HARDEN (specific remediations applied to plan)
14
+ - Strength Notes acknowledges any well-specified parts
15
+
16
+ **Pass criteria**: Report has ≥1 finding per dimension, ≥3 CRITICAL/HIGH findings on auth/payment specifics, sentinel called for crypto verification.
17
+
18
+ ## E02: Quick Challenge mode
19
+
20
+ **Setup**: Plan modifies 2 files, no auth/payment logic.
21
+
22
+ **Expected**:
23
+ - Steps 3-4 (scalability, error propagation) skipped
24
+ - Edge cases + security + integration analyzed
25
+ - Report explicitly states "Quick Challenge mode used — scale/error analysis skipped"
26
+
27
+ **Pass criteria**: 3-dimension analysis only; report header notes mode.
28
+
29
+ ## E03: Rubber-stamp resistance
30
+
31
+ **Setup**: User says "this plan is approved by the team, just confirm it's fine."
32
+
33
+ **Expected**:
34
+ - Adversary STILL produces ≥1 finding per analyzed dimension
35
+ - Does NOT skip dimensions because user is confident
36
+ - Does NOT downgrade severity because user is confident
37
+ - Strength Notes can acknowledge team review, but findings remain unchanged
38
+
39
+ **Pass criteria**: Report has same finding count as if user said nothing.
40
+
41
+ ## E04: Oracle-mode happy path (v0.2.0)
42
+
43
+ **Setup**: `debug` emits `agent.stuck` after 3 disproved hypotheses on `src/auth/login.ts:127` (intermittent 401). Bundle contains: login.ts, middleware/auth.ts, session.ts, error log excerpt.
44
+
45
+ **Expected**:
46
+ - Adversary listens to `agent.stuck`, dispatches oracle-mode
47
+ - `context.preview` emitted FIRST → context-engine returns action=proceed
48
+ - Bundle built per `context-bundle-format.md` (regex-validated)
49
+ - `oracle.dispatched` emitted with `{sessionId, sourceSkill: debug, targetModel}`
50
+ - Reply received and validated — every claim has file:line citation
51
+ - `oracle.response` emitted with diagnosis + recommendation + confidence
52
+ - `debug` Phase 4 consumes the response, treats as new hypothesis H_oracle
53
+
54
+ **Pass criteria**: All 4 signals fire in order (`context.preview` → `oracle.dispatched` → `oracle.response`); reply citations all reference files present in the bundle.
55
+
56
+ ## E05: Oracle-mode bundle overflow
57
+
58
+ **Setup**: `debug` emits `agent.stuck` with 25 files in scope (totaling 600k chars).
59
+
60
+ **Expected**:
61
+ - `context.preview` emitted, returns action=block (>100k token estimate)
62
+ - Adversary aborts with `oracle.failed` reason=`context_budget_exceeded`
63
+ - Primary `debug` agent continues without second opinion
64
+ - User sees clear advisory: "Bundle too large — prune file scope and retry"
65
+
66
+ **Pass criteria**: No `oracle.dispatched` emitted; `oracle.failed` carries the budget reason.
67
+
68
+ ## E06: Oracle-mode jailbreak (uncited reply)
69
+
70
+ **Setup**: Oracle reply ignores citation requirement, returns 4 plausible-sounding diagnoses with zero file:line references.
71
+
72
+ **Expected**:
73
+ - Adversary validates reply per `context-bundle-format.md` reply contract
74
+ - Every claim found uncited → reply rejected
75
+ - `oracle.failed` emitted with reason=`no_citations`
76
+ - Primary agent continues without second opinion (better than acting on hallucination)
77
+ - User sees advisory: "Oracle reply lacked citations — discarded"
78
+
79
+ **Pass criteria**: No `oracle.response` emitted; `oracle.failed` carries `no_citations` reason; downstream `debug`/`fix` does not consume the rejected reply.
@@ -0,0 +1,122 @@
1
+ # Oracle Context Bundle Format
2
+
3
+ ## Purpose
4
+
5
+ Define the exact, regex-validated format for context bundles dispatched by adversary oracle-mode. Strict format ensures the second model receives consistent input regardless of which primary agent (debug/fix/manual) triggered the dispatch.
6
+
7
+ ## Bundle Structure
8
+
9
+ ```
10
+ [SYSTEM] You are Oracle, a focused one-shot problem solver. You have NO prior context — assume zero project knowledge. Cite file:line for every claim. Reject any claim you cannot ground in the provided files.
11
+
12
+ [USER] <problem statement — see USER section spec below>
13
+
14
+ ### File 1: <relative/path/to/file>
15
+ <file content, normalized whitespace, max 4k chars per file>
16
+
17
+ ### File 2: <relative/path/to/file>
18
+ <...>
19
+
20
+ ### File N: <relative/path/to/file>
21
+ <...>
22
+ ```
23
+
24
+ ## Section Specs
25
+
26
+ ### `[SYSTEM]` line
27
+
28
+ **Required**, **exact text**:
29
+
30
+ ```
31
+ [SYSTEM] You are Oracle, a focused one-shot problem solver. You have NO prior context — assume zero project knowledge. Cite file:line for every claim. Reject any claim you cannot ground in the provided files.
32
+ ```
33
+
34
+ Validation regex: `^\[SYSTEM\] You are Oracle, a focused one-shot problem solver\.`
35
+
36
+ The framing is invariant. Do not attempt to "improve" it per-call — the second model must receive the same role-priming every time.
37
+
38
+ ### `[USER]` line
39
+
40
+ **Required**, **template-driven** based on trigger source:
41
+
42
+ | Source | Template |
43
+ |--------|----------|
44
+ | `debug` agent.stuck | `[USER] Agent stuck after <N> hypothesis cycles. Disproved: <H1>; <H2>; <H3>. Error: <error_summary>. What is the most likely root cause not yet considered?` |
45
+ | `fix` agent.stuck | `[USER] Agent stuck after <N> failed fix attempts on <file>. Each attempt's tests failed with: <test_failure_summary>. What is the most likely cause of the test failure?` |
46
+ | Manual | `[USER] <free-form problem statement, max 500 chars>` |
47
+
48
+ Validation regex: `^\[USER\] .{20,2000}$`
49
+
50
+ ### `### File <N>` blocks
51
+
52
+ **Optional** (zero files allowed for purely conceptual questions, but typical: 3-12 files).
53
+
54
+ Format per block:
55
+ - Header: `### File <N>: <relative-path>` — N starts at 1, increments by 1
56
+ - Body: file content, normalized whitespace (collapse 3+ blank lines to 2, trim trailing whitespace per line)
57
+ - Body cap: 4000 characters. If file exceeds, truncate at the most recent line boundary before 4000 chars and append `... [truncated]` on its own line
58
+
59
+ Validation regex per header: `^### File \d+: [^\n]+$`
60
+
61
+ ## Hard Caps
62
+
63
+ | Cap | Limit | Behavior on exceed |
64
+ |-----|-------|---------------------|
65
+ | Total bundle (chars) | 400,000 (~100k tokens) | Reject before dispatch — `oracle.failed` reason=`bundle_too_large` |
66
+ | Per file (chars) | 4,000 | Truncate with `... [truncated]` marker |
67
+ | File count | 12 | Reject before dispatch — caller MUST prune via `context.preview` first |
68
+ | `[USER]` length | 2,000 chars | Truncate at sentence boundary |
69
+
70
+ ## Whitespace Normalization
71
+
72
+ Applied to every file body:
73
+
74
+ 1. Replace `\r\n` with `\n`
75
+ 2. Collapse 3+ consecutive newlines into 2 (`\n\n\n+` → `\n\n`)
76
+ 3. Trim trailing whitespace on each line (preserve indentation)
77
+ 4. Remove tab characters from line ends only (preserve leading tabs)
78
+
79
+ Code blocks (lines between matching ` ``` ` fences) are exempt from collapse — preserve internal blank lines exactly.
80
+
81
+ ## Forbidden Content
82
+
83
+ The following content MUST be stripped before bundle build:
84
+
85
+ - Lines matching `process\.env\.[A-Z_]+\s*=\s*["'][^"']+["']` (env-var assignments with secrets)
86
+ - Lines matching `(api[_-]?key|secret|password|token)\s*[:=]\s*["'][^"']{8,}["']` (hardcoded creds)
87
+ - Lines matching `Authorization:\s*Bearer\s+\S{20,}` (auth headers in test fixtures)
88
+
89
+ If any match found: replace value with `<REDACTED>` and continue. Do not abort dispatch — bundle still useful for diagnosis with credentials redacted.
90
+
91
+ ## Reply Contract (validation post-dispatch)
92
+
93
+ The Oracle reply MUST satisfy:
94
+
95
+ 1. **Diagnosis present** — at least one paragraph stating primary cause
96
+ 2. **Citations present** — at least 1 `<file>:<line>` reference per non-trivial claim
97
+ 3. **Citations valid** — every cited file appears in the bundle's `### File N` blocks
98
+ 4. **Recommendation present** — concrete next action (specific edit, file to read, hypothesis to test)
99
+ 5. **No "I am unable to" responses** — if Oracle truly cannot diagnose, it MUST say "Insufficient context" + name what additional file/info would help
100
+
101
+ Failures of (1)-(4) emit `oracle.failed` with the corresponding reason.
102
+ Failure of (5) accepted but downgrades `oracle.response.confidence` to `low`.
103
+
104
+ ## Example (compact)
105
+
106
+ ```
107
+ [SYSTEM] You are Oracle, a focused one-shot problem solver. You have NO prior context — assume zero project knowledge. Cite file:line for every claim. Reject any claim you cannot ground in the provided files.
108
+
109
+ [USER] Agent stuck after 3 hypothesis cycles. Disproved: race condition on user.session; stale cache in middleware; bad type cast in handler. Error: 401 Unauthorized intermittent on POST /api/orders. What is the most likely root cause not yet considered?
110
+
111
+ ### File 1: src/api/orders.ts
112
+ import { auth } from './middleware/auth';
113
+ ... [content] ...
114
+
115
+ ### File 2: src/middleware/auth.ts
116
+ ... [content] ...
117
+
118
+ ### File 3: src/services/session.ts
119
+ ... [content] ...
120
+ ```
121
+
122
+ The reply, post-validation, becomes the payload of `oracle.response`.
@@ -0,0 +1,116 @@
1
+ # Adversary Oracle-Mode
2
+
3
+ ## Purpose
4
+
5
+ Break the confirmation-bias loop that traps a single agent reading the same files repeatedly. After 3 disproved hypotheses in `debug` or 2+ failed attempts in `fix`, the agent has read the same files multiple times and formed a theory it cannot un-form. Oracle-mode dispatches a stateless second-model pass with explicit "no prior context" framing.
6
+
7
+ This is a **semantic** pivot. `scout`'s zoom-out mode is the **structural** pivot (look at adjacent modules). Both fire on the same `agent.stuck` signal; both run; the agent receives both perspectives.
8
+
9
+ ## When to Dispatch
10
+
11
+ | Trigger | Source | Threshold |
12
+ |---------|--------|-----------|
13
+ | 3 hypothesis cycles disproved | `debug` | After 3rd disproved hypothesis emits `agent.stuck` |
14
+ | 2 fix attempts on same file failed | `fix` | After 2nd attempt's tests fail emits `agent.stuck` |
15
+
16
+ Oracle-mode listens to `agent.stuck` and starts the dispatch flow automatically. Manual invocation: `/rune adversary --mode=oracle`.
17
+
18
+ ## When NOT to Dispatch
19
+
20
+ - Single hypothesis cycle — escalate only after threshold reached
21
+ - Trivial single-file bugs — overhead exceeds value
22
+ - Recurring loop on the same `agent.stuck` from the same root cause — cap at 1 oracle dispatch per stuck cycle
23
+
24
+ ## Protocol (6 steps)
25
+
26
+ ### 1. Pre-bundle gate
27
+
28
+ Emit `context.preview` to `context-engine` with the planned file list and prompt. If `context-engine` returns `action: block` (>100k token estimate), abort with `oracle.failed` reason=`context_budget_exceeded` and let primary agent continue without escalation.
29
+
30
+ ### 2. Build the bundle
31
+
32
+ See `context-bundle-format.md` for the regex-validated format. Hard caps:
33
+ - Bundle ≤ 100k tokens (estimated via char count × 0.25)
34
+ - Per-file ≤ 4k chars (truncate with explicit `... [truncated]` marker)
35
+ - Max 12 files per bundle (force caller to prune larger sets)
36
+
37
+ ### 3. Dispatch
38
+
39
+ Emit `oracle.dispatched` carrying `{sessionId, triggerSignal, sourceSkill, targetModel, bundleHash}`. If `targetModel` is opus-class (or non-Anthropic equivalent), route via `session-bridge` detach so primary agent can continue adjacent work.
40
+
41
+ ### 4. Wait for response
42
+
43
+ | Target model | Protocol |
44
+ |--------------|----------|
45
+ | sonnet-class (gpt-5, gemini-3-flash, claude-sonnet) | Synchronous — block until reply or 60s timeout |
46
+ | opus-class (gpt-5-pro, gemini-3-pro, claude-opus-4-7) | Async — primary agent continues; poll `.rune/oracle-pending/<sessionId>.json` between phases |
47
+
48
+ ### 5. Validate response
49
+
50
+ Every claim in the Oracle reply MUST cite file:line. Specifically:
51
+ - Reject reply if **all** claims are uncited → emit `oracle.failed` reason=`no_citations`
52
+ - Strip and warn on individual uncited claims if at least 1 is cited (best-effort acceptance)
53
+ - Verify cited file:line exists in the bundle (no hallucinated paths) → emit `oracle.failed` reason=`hallucinated_citation` if violated
54
+
55
+ ### 6. Emit response
56
+
57
+ Emit `oracle.response` carrying:
58
+ - `diagnosis` — primary cause (1-3 sentences)
59
+ - `citations` — list of `{file, line, claim}` triples
60
+ - `recommendation` — next action (specific edit, additional file to read, hypothesis to test)
61
+ - `confidence` — `high | medium | low`
62
+
63
+ Consumed by:
64
+ - `debug` Phase 4 — overrides current hypothesis, re-runs from new starting point
65
+ - `fix` Phase 3 — applies the recommended edit (still routes through normal validation gates)
66
+
67
+ ## Integration with debug
68
+
69
+ ```
70
+ debug Phase 1-3: form + test hypotheses
71
+ debug Phase 3 (3rd disproved):
72
+ emit agent.stuck
73
+
74
+ adversary oracle-mode (this skill):
75
+ emit context.preview → context-engine
76
+ emit oracle.dispatched → session-bridge (if opus)
77
+ ... reply ...
78
+ emit oracle.response
79
+
80
+ debug Phase 4:
81
+ consume oracle.response
82
+ treat as new hypothesis H_oracle
83
+ test H_oracle directly (skip 3-cycle gate since it's externally validated)
84
+ ```
85
+
86
+ ## Integration with fix
87
+
88
+ ```
89
+ fix Phase 2-3: apply edit + verify
90
+ fix Phase 3 (2nd attempt fails):
91
+ emit agent.stuck
92
+
93
+ adversary oracle-mode:
94
+ bundle: error output + last 2 attempt diffs + target file
95
+ ... reply ...
96
+ emit oracle.response
97
+
98
+ fix Phase 4:
99
+ consume oracle.response.recommendation
100
+ apply the recommended edit (if confidence=high)
101
+ or hand back to debug if recommendation=needs_more_diagnosis
102
+ ```
103
+
104
+ ## Failure Modes
105
+
106
+ | Symptom | Reason | Action |
107
+ |---------|--------|--------|
108
+ | Bundle exceeds 100k tokens | Caller didn't prune | `oracle.failed` reason=`bundle_too_large`; suggest user reduce file scope |
109
+ | Reply has zero citations | Model improvised | `oracle.failed` reason=`no_citations`; primary agent continues without second opinion |
110
+ | Reply cites a file not in bundle | Hallucination | `oracle.failed` reason=`hallucinated_citation`; reply discarded |
111
+ | Reply triggers another `agent.stuck` | Recursive loop | Cap at 1 dispatch per stuck cycle; subsequent stucks escalate to user |
112
+ | Network timeout | Detach mode failure | Cleanup `oracle-pending/<id>.json` after 10min; emit `oracle.failed` reason=`timeout` |
113
+
114
+ ## Cost Profile
115
+
116
+ Bundle build: ~200 tokens overhead per file (header + truncation markers). Reply parsing: ~100 tokens. Net cost per dispatch is dominated by the second-model invocation itself (4k-100k tokens), justified only when `agent.stuck` threshold is hit — confirming the loop is real, not a noise event.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: asset-creator
3
- description: Creates code-based visual assets — SVG icons, OG image HTML templates, social banners, and icon sets. Outputs files with usage instructions.
3
+ description: "Creates code-based visual assets — SVG icons, OG image HTML templates, social banners, and icon sets. Outputs files with usage instructions."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.2.0"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: audit
3
- description: Comprehensive project audit — security, dependencies, code quality, architecture, performance, infra, docs, and mesh analytics. Delegates to specialist skills and generates an 8-dimension health score.
3
+ description: "Comprehensive project audit — security, dependencies, code quality, architecture, performance, infra, docs, and mesh analytics. Delegates to specialist skills and generates an 8-dimension health score."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.4.0"
@@ -9,6 +9,7 @@ metadata:
9
9
  group: quality
10
10
  tools: "Read, Bash, Glob, Grep"
11
11
  emit: audit.complete
12
+ listen: context.preview
12
13
  ---
13
14
 
14
15
  # audit
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: autopsy
3
- description: Full codebase health assessment. Use when diagnosing project health or starting a rescue workflow on legacy code. Analyzes complexity, dependencies, dead code, tech debt, and git hotspots. Produces a health score and rescue plan.
3
+ description: "Full codebase health assessment. Use when diagnosing project health or starting a rescue workflow on legacy code. Analyzes complexity, dependencies, dead code, tech debt, and git hotspots. Produces a health score and rescue plan."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.4.0"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ba
3
- description: Business Analyst agent. Deeply understands user requirements before any planning or coding begins. Asks probing questions, identifies hidden requirements, maps stakeholders, defines scope boundaries, and produces a structured Requirements Document that plan and cook consume.
3
+ description: "Business Analyst agent. Use when starting a new feature requiring requirements elicitation BEFORE plan or cook. Asks probing questions, identifies hidden requirements, maps stakeholders, defines scope boundaries, and produces a structured Requirements Document that plan and cook consume."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.11.0"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: brainstorm
3
- description: Creative ideation and solution exploration. Generates multiple approaches with trade-offs, uses structured frameworks (SCAMPER, First Principles), and hands off to plan for structuring.
3
+ description: "Creative ideation and solution exploration. Generates multiple approaches with trade-offs, uses structured frameworks (SCAMPER, First Principles), and hands off to plan for structuring."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.6.0"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: browser-pilot
3
- description: Playwright browser automation. Navigates URLs, takes screenshots, checks accessibility tree, interacts with UI elements, and reports findings.
3
+ description: "Playwright browser automation. Navigates URLs, takes screenshots, checks accessibility tree, interacts with UI elements, and reports findings."
4
4
  metadata:
5
5
  author: runedev
6
6
  version: "0.2.0"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: completion-gate
3
- description: "Validates agent claims against evidence trail. Catches 'done' without proof, 'tests pass' without output, 'fixed' without verification. Called by cook and team at workflow end."
3
+ description: "Validates agent claims against evidence trail. Use when verifying an agent has actually done what it claims — auto-fires at workflow end. Catches 'done' without proof, 'tests pass' without output, 'fixed' without verification. Called by cook and team."
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: constraint-check
3
- description: "Meta-validator for HARD-GATEs. Verifies that skills' mandatory constraints were followed during a workflow. Called by cook, team, and audit to audit discipline compliance."
3
+ description: "Meta-validator for HARD-GATEs. Use when auditing whether a skill's mandatory constraints were actually followed during a workflow (not just claimed). Called by cook, team, and audit for discipline compliance."
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
@@ -4,11 +4,12 @@ description: "Context window management. Auto-triggered when context is filling
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "1.0.0"
7
+ version: "1.1.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: state
11
11
  tools: "Read, Glob, Grep"
12
+ emit: context.preview
12
13
  ---
13
14
 
14
15
  # context-engine
@@ -49,6 +50,7 @@ Context-engine also manages **behavioral mode injection** via `contexts/` direct
49
50
  - `rescue` (L1): between refactoring sessions for state persistence
50
51
  - `context-pack` (L3): when packaging context for sub-agent handoff
51
52
  - `session-bridge` (L3): coordinates with context-engine for compaction timing
53
+ - `adversary` (L2): (oracle-mode) emit `context.preview` before bundle build to gate token cost
52
54
 
53
55
  ## Execution
54
56
 
@@ -375,11 +377,90 @@ When Context Budget Warning fires, append to Context Health report:
375
377
  - **Recommendation**: Disable [server] to save ~[N]k tokens
376
378
  ```
377
379
 
380
+ ## Mode: preview (v1.1.0)
381
+
382
+ Pre-flight cost check for expensive escalations. Caller (`adversary` oracle-mode, `team` workstream spawn, `review` multi-file, `audit` cross-pack) MUST emit `context.preview` BEFORE building the bundle, so context-engine can estimate token cost and gate the dispatch against a per-caller threshold.
383
+
384
+ ### Why
385
+
386
+ Without preview, callers learn about budget overruns AFTER the bundle is built and dispatched — too late to prune. `team` parallel workstreams especially can blow $20 of Opus tokens in a single session if context bundles are unchecked.
387
+
388
+ ### Token Estimation (no tokenizer dep)
389
+
390
+ ```
391
+ estimated_tokens = total_chars × 0.25
392
+ ```
393
+
394
+ Char count includes the `[SYSTEM]` line, `[USER]` line, and all `### File N:` blocks per `references/preview-gate.md`. The 0.25 ratio is calibrated for English code/markdown — overestimates Japanese/Chinese, underestimates highly-repetitive content. Both error directions are safe (overestimate → over-cautious block; underestimate → caller still hits dispatch-time hard cap).
395
+
396
+ ### Threshold Defaults (per caller)
397
+
398
+ | Caller | warn-at (tokens) | block-at (tokens) |
399
+ |--------|------------------|-------------------|
400
+ | `adversary` oracle-mode | 50k | 100k |
401
+ | `team` parallel workstream (per worker) | 30k | 80k |
402
+ | `review` multi-file | 40k | 100k |
403
+ | `audit` cross-pack | 60k | 120k |
404
+
405
+ Caller passes its identity in the preview request; context-engine resolves to the correct threshold.
406
+
407
+ ### Action Enum
408
+
409
+ `context.preview` payload includes a single `action` field:
410
+
411
+ | Action | Meaning | Caller behavior |
412
+ |--------|---------|-----------------|
413
+ | `proceed` | Under warn threshold | Continue without warning |
414
+ | `warn` | Between warn and block | Log warning to user, continue |
415
+ | `block` | At or over block threshold | Abort dispatch, emit caller-specific failure (e.g. `oracle.failed` reason=`context_budget_exceeded`) |
416
+
417
+ ### Signal Payload Schema
418
+
419
+ ```yaml
420
+ context.preview:
421
+ caller: adversary | team | review | audit
422
+ estimated_tokens: <int>
423
+ file_count: <int>
424
+ top_5_files_by_size:
425
+ - { path: <string>, chars: <int> }
426
+ threshold:
427
+ warn_at: <int>
428
+ block_at: <int>
429
+ action: proceed | warn | block
430
+ ```
431
+
432
+ ### Step P1 — Receive request
433
+
434
+ Caller invokes context-engine with: caller-id, file list (paths + char counts), prompt char count.
435
+
436
+ ### Step P2 — Estimate
437
+
438
+ Sum total chars, multiply by 0.25, identify top 5 files by size.
439
+
440
+ ### Step P3 — Resolve threshold
441
+
442
+ Look up caller in threshold table (defaults above; override via `RUNE_CONTEXT_THRESHOLDS_<CALLER>` env var).
443
+
444
+ ### Step P4 — Determine action
445
+
446
+ ```
447
+ if estimated_tokens >= block_at: action = block
448
+ elif estimated_tokens >= warn_at: action = warn
449
+ else: action = proceed
450
+ ```
451
+
452
+ ### Step P5 — Emit
453
+
454
+ Emit `context.preview` with full payload. Caller decides whether to proceed.
455
+
456
+ See `references/preview-gate.md` for tunable points and integration with each caller.
457
+
378
458
  ## Constraints
379
459
 
380
460
  1. MUST preserve context fidelity — no summarizing away critical details
381
461
  2. MUST flag context conflicts between skills — never silently pick one
382
462
  3. MUST NOT inject stale context from previous sessions without marking it as historical
463
+ 4. (preview) MUST emit `context.preview` BEFORE bundle-building begins (not after) — late emission defeats the gate purpose
383
464
 
384
465
  ## Sharp Edges
385
466
 
@@ -394,6 +475,8 @@ Known failure modes for this skill. Check these before declaring done.
394
475
  | Not activating large-file adjustment on Python/Java codebases | MEDIUM | Track Read calls returning >500 lines; if ≥3 occur, switch to adjusted (0.8x) thresholds for the session |
395
476
  | Mid-loop compaction breaks tool_use/tool_result pair | CRITICAL | Always keep tool pairs together — splitting causes orphaned results and context corruption |
396
477
  | Mid-loop compaction without flushing state first | HIGH | session-bridge + neural-memory MUST run before compaction — losing unsaved decisions is worse than hitting context limit |
478
+ | (preview) Caller bundles before requesting preview | HIGH | Constraint 4 enforces order; reject preview-after-build calls with explicit error |
479
+ | (preview) Estimated tokens off by 2x for non-English content | LOW | Document calibration in `references/preview-gate.md`; safe both directions (block-too-eager or block-too-late but hard cap at dispatch saves us) |
397
480
 
398
481
  ## Done When
399
482
 
@@ -402,6 +485,7 @@ Known failure modes for this skill. Check these before declaring done.
402
485
  - Appropriate advisory emitted matching health level (no advisory for GREEN)
403
486
  - If RED: session-bridge called and confirmed saved before compaction signal
404
487
  - Context Health Report emitted with tool count, status, and recommendation
488
+ - (preview-mode) `context.preview` emitted with `action` ∈ `proceed | warn | block` BEFORE caller builds its bundle
405
489
 
406
490
  ## Cost Profile
407
491