@rune-kit/rune 2.7.0 → 2.10.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 (123) hide show
  1. package/README.md +78 -41
  2. package/agents/adversary.md +27 -0
  3. package/agents/architect.md +19 -29
  4. package/agents/asset-creator.md +18 -4
  5. package/agents/audit.md +25 -4
  6. package/agents/autopsy.md +19 -4
  7. package/agents/ba.md +35 -0
  8. package/agents/brainstorm.md +31 -4
  9. package/agents/browser-pilot.md +21 -4
  10. package/agents/coder.md +21 -29
  11. package/agents/completion-gate.md +20 -4
  12. package/agents/constraint-check.md +18 -4
  13. package/agents/context-engine.md +22 -4
  14. package/agents/context-pack.md +32 -0
  15. package/agents/cook.md +41 -4
  16. package/agents/db.md +19 -4
  17. package/agents/debug.md +33 -4
  18. package/agents/dependency-doctor.md +20 -4
  19. package/agents/deploy.md +27 -4
  20. package/agents/design.md +22 -4
  21. package/agents/doc-processor.md +27 -0
  22. package/agents/docs-seeker.md +19 -4
  23. package/agents/docs.md +31 -0
  24. package/agents/fix.md +37 -4
  25. package/agents/git.md +29 -0
  26. package/agents/hallucination-guard.md +20 -4
  27. package/agents/incident.md +21 -4
  28. package/agents/integrity-check.md +18 -4
  29. package/agents/journal.md +19 -4
  30. package/agents/launch.md +32 -4
  31. package/agents/logic-guardian.md +26 -11
  32. package/agents/marketing.md +23 -4
  33. package/agents/mcp-builder.md +26 -0
  34. package/agents/neural-memory.md +30 -0
  35. package/agents/onboard.md +22 -4
  36. package/agents/perf.md +21 -4
  37. package/agents/plan.md +29 -4
  38. package/agents/preflight.md +22 -4
  39. package/agents/problem-solver.md +20 -4
  40. package/agents/rescue.md +23 -4
  41. package/agents/research.md +19 -4
  42. package/agents/researcher.md +19 -29
  43. package/agents/retro.md +32 -0
  44. package/agents/review-intake.md +20 -4
  45. package/agents/review.md +32 -4
  46. package/agents/reviewer.md +20 -28
  47. package/agents/safeguard.md +19 -4
  48. package/agents/sast.md +18 -4
  49. package/agents/scaffold.md +41 -0
  50. package/agents/scanner.md +19 -28
  51. package/agents/scope-guard.md +18 -4
  52. package/agents/scout.md +23 -4
  53. package/agents/sentinel-env.md +26 -0
  54. package/agents/sentinel.md +33 -4
  55. package/agents/sequential-thinking.md +20 -4
  56. package/agents/session-bridge.md +24 -4
  57. package/agents/skill-forge.md +22 -4
  58. package/agents/skill-router.md +26 -4
  59. package/agents/slides.md +24 -0
  60. package/agents/surgeon.md +19 -4
  61. package/agents/team.md +30 -4
  62. package/agents/test.md +36 -4
  63. package/agents/trend-scout.md +17 -4
  64. package/agents/verification.md +20 -4
  65. package/agents/video-creator.md +20 -4
  66. package/agents/watchdog.md +19 -4
  67. package/agents/worktree.md +17 -4
  68. package/compiler/__tests__/analytics.test.js +370 -0
  69. package/compiler/adapters/openclaw.js +2 -2
  70. package/compiler/analytics.js +385 -0
  71. package/compiler/bin/rune.js +68 -2
  72. package/compiler/dashboard.js +883 -0
  73. package/compiler/transforms/branding.js +1 -1
  74. package/extensions/ui/skills/animation-patterns.md +21 -0
  75. package/extensions/ui/skills/component-patterns.md +25 -0
  76. package/extensions/ui/skills/landing-patterns.md +1 -1
  77. package/hooks/context-watch/index.cjs +95 -68
  78. package/hooks/metrics-collector/index.cjs +86 -42
  79. package/hooks/post-session-reflect/index.cjs +41 -5
  80. package/hooks/session-start/index.cjs +8 -2
  81. package/package.json +2 -2
  82. package/skills/audit/SKILL.md +1 -0
  83. package/skills/autopsy/SKILL.md +78 -2
  84. package/skills/autopsy/references/repo-analysis-patterns.md +113 -0
  85. package/skills/ba/SKILL.md +72 -2
  86. package/skills/brainstorm/SKILL.md +1 -0
  87. package/skills/completion-gate/SKILL.md +26 -3
  88. package/skills/context-engine/SKILL.md +49 -1
  89. package/skills/cook/SKILL.md +72 -3
  90. package/skills/cook/references/output-format.md +33 -0
  91. package/skills/db/SKILL.md +1 -0
  92. package/skills/debug/SKILL.md +57 -1
  93. package/skills/deploy/SKILL.md +1 -1
  94. package/skills/design/SKILL.md +110 -3
  95. package/skills/docs/SKILL.md +2 -1
  96. package/skills/fix/SKILL.md +47 -1
  97. package/skills/graft/SKILL.md +352 -0
  98. package/skills/graft/references/challenge-framework.md +98 -0
  99. package/skills/graft/references/mode-decision.md +44 -0
  100. package/skills/incident/SKILL.md +2 -0
  101. package/skills/journal/SKILL.md +2 -0
  102. package/skills/launch/SKILL.md +2 -0
  103. package/skills/marketing/SKILL.md +46 -2
  104. package/skills/mcp-builder/SKILL.md +3 -1
  105. package/skills/mcp-builder/references/auto-discovery-pattern.md +169 -0
  106. package/skills/plan/SKILL.md +60 -4
  107. package/skills/plan/references/feature-map.md +84 -0
  108. package/skills/preflight/SKILL.md +20 -1
  109. package/skills/rescue/SKILL.md +25 -1
  110. package/skills/research/SKILL.md +24 -1
  111. package/skills/retro/SKILL.md +2 -0
  112. package/skills/review/SKILL.md +55 -2
  113. package/skills/scaffold/SKILL.md +1 -0
  114. package/skills/scope-guard/SKILL.md +35 -17
  115. package/skills/scout/SKILL.md +22 -1
  116. package/skills/sentinel/SKILL.md +29 -1
  117. package/skills/sentinel-env/SKILL.md +0 -2
  118. package/skills/session-bridge/SKILL.md +155 -9
  119. package/skills/skill-forge/SKILL.md +43 -1
  120. package/skills/skill-router/{skill.md → SKILL.md} +27 -2
  121. package/skills/team/SKILL.md +24 -1
  122. package/skills/test/SKILL.md +29 -2
  123. package/skills/verification/SKILL.md +1 -2
@@ -0,0 +1,113 @@
1
+ # Repo Analysis Patterns
2
+
3
+ Reference for autopsy Step 0 (repo intelligence) and cross-cutting analysis.
4
+
5
+ ## GitHub API Metrics Interpretation
6
+
7
+ | Metric | Healthy | Warning | Critical |
8
+ |--------|---------|---------|----------|
9
+ | Commits/week (avg last 12w) | > 5 | 1-5 | < 1 |
10
+ | Contributors (all-time) | > 5 | 2-4 | 1 (bus factor) |
11
+ | Open issues / total issues | < 30% | 30-60% | > 60% |
12
+ | Days since last push | < 14 | 14-90 | > 90 |
13
+ | Stars/fork ratio | > 5:1 | 2-5:1 | < 2:1 (fork-heavy = fragmentation) |
14
+
15
+ ## Bus Factor Assessment
16
+
17
+ Bus factor = number of contributors who authored > 10% of recent commits (last 6 months).
18
+
19
+ ```bash
20
+ # Bus factor calculation
21
+ git shortlog -sn --since="6 months ago" | awk '{total+=$1; print}' | \
22
+ awk -v t=$(git shortlog -sn --since="6 months ago" | awk '{s+=$1}END{print s}') \
23
+ '{pct=$1/t*100; if(pct>10) count++} END{print "Bus factor:", count}'
24
+ ```
25
+
26
+ | Bus Factor | Risk | Action |
27
+ |-----------|------|--------|
28
+ | 1 | Critical | Flag in report — single point of failure |
29
+ | 2-3 | Moderate | Note in report — knowledge concentration |
30
+ | 4+ | Low | Healthy distribution |
31
+
32
+ ## Hotspot-Complexity Correlation
33
+
34
+ Files that are BOTH hotspots (high change frequency) AND high complexity are the highest-priority rescue targets. Plot on a 2x2 matrix:
35
+
36
+ ```
37
+ High Complexity
38
+ |
39
+ Refactor NOW | Monitor
40
+ (hot + complex) | (cold + complex)
41
+ -------------------+-------------------
42
+ Leave alone | Review
43
+ (hot + simple) | (cold + simple)
44
+ |
45
+ Low Complexity
46
+ High Churn ←————→ Low Churn
47
+ ```
48
+
49
+ Priority order: hot+complex > cold+complex > hot+simple > cold+simple.
50
+
51
+ ## Dependency Health Signals
52
+
53
+ ### Outdated packages
54
+ ```bash
55
+ # Node.js
56
+ npx npm-check-updates --format group 2>/dev/null | head -40
57
+
58
+ # Python
59
+ pip list --outdated --format columns 2>/dev/null | head -20
60
+ ```
61
+
62
+ ### Known vulnerabilities
63
+ ```bash
64
+ # Node.js
65
+ npm audit --json 2>/dev/null | jq '.metadata.vulnerabilities'
66
+
67
+ # Python
68
+ pip-audit --format json 2>/dev/null | jq '.dependencies | length'
69
+ ```
70
+
71
+ ### Circular dependency detection
72
+ ```bash
73
+ # Node.js (madge)
74
+ npx madge --circular --extensions ts,js src/ 2>/dev/null
75
+
76
+ # Python (pydeps)
77
+ pydeps --no-output --show-cycles . 2>/dev/null
78
+ ```
79
+
80
+ ## Dead Code Heuristics
81
+
82
+ A file is likely dead code if ALL of these are true:
83
+ 1. No other file imports it (check with grep/madge)
84
+ 2. Not referenced in any config (webpack entry, tsconfig paths, package.json bin/main)
85
+ 3. Last modified > 6 months ago
86
+ 4. Not a test file, fixture, or migration
87
+
88
+ False positive checklist (do NOT flag these as dead):
89
+ - Dynamic imports (`import()`, `require(variable)`)
90
+ - Plugin/middleware loaded by config (e.g., babel plugins, ESLint rules)
91
+ - CLI entry points referenced in package.json `bin`
92
+ - Database migrations (executed by ORM, not imported)
93
+ - Template files loaded by path string
94
+
95
+ ## Velocity Trend Analysis
96
+
97
+ Compare commit counts across 3-month windows to detect trajectory:
98
+
99
+ | Pattern | Signal | Interpretation |
100
+ |---------|--------|---------------|
101
+ | M1 > M2 > M3 | Decelerating | Project may be winding down or blocked |
102
+ | M1 < M2 < M3 | Accelerating | Active development, check for quality regression |
103
+ | M1 ~ M2 ~ M3 | Stable | Healthy maintenance pace |
104
+ | Spiky (high variance) | Irregular | Deadline-driven development — check quality around spikes |
105
+
106
+ ```bash
107
+ # Monthly commit counts for last 6 months
108
+ for i in 0 1 2 3 4 5; do
109
+ month=$(date -d "$i months ago" +%Y-%m 2>/dev/null || date -v-${i}m +%Y-%m)
110
+ count=$(git log --after="$month-01" --before="$month-31" --oneline 2>/dev/null | wc -l)
111
+ echo "$month: $count commits"
112
+ done
113
+ ```
@@ -3,7 +3,7 @@ name: ba
3
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.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.4.0"
6
+ version: "0.5.0"
7
7
  layer: L2
8
8
  model: opus
9
9
  group: creation
@@ -34,6 +34,7 @@ Output is a Requirements Document → hand off to rune:plan for implementation p
34
34
  - `research` (L3): look up similar products, APIs, integrations
35
35
  - `plan` (L2): hand off Requirements Document for implementation planning
36
36
  - `brainstorm` (L2): when multiple approaches exist for a requirement
37
+ - `design` (L2): when requirements include UI/UX components — hand off visual requirements
37
38
 
38
39
  ## Called By (inbound)
39
40
 
@@ -64,7 +65,7 @@ Read the user's request. Classify the requirement type:
64
65
  | Greenfield | "new project", "build from scratch" | Full BA + market context |
65
66
 
66
67
  If Bug Fix → skip BA, route to cook/debug directly.
67
- If Refactor → light version (Step 1 + Step 4 only).
68
+ If Refactor → light version (Step 1 + Step 4 only). Skip Steps 2, 2.5, 3, 5, 6.
68
69
 
69
70
  If existing codebase → invoke `rune:scout` for context before proceeding.
70
71
 
@@ -110,6 +111,72 @@ O: 30% faster incident detection (measurable KPI)
110
111
  - Product/UX feature → Jobs-to-be-Done (keeps focus on user motivation)
111
112
  - Integration → 5 Questions only (frameworks add noise for plumbing tasks)
112
113
 
114
+ ### Step 2.5 — Ambiguity Scoring (Execution Gate)
115
+
116
+ After each question round, compute an **Ambiguity Score** to determine if requirements are clear enough to proceed. This prevents premature handoff to `plan` with vague inputs.
117
+
118
+ #### Scoring Formula
119
+
120
+ ```
121
+ Ambiguity = 1 - weighted_average(dimensions)
122
+
123
+ Dimensions (weights vary by requirement type):
124
+ Greenfield: Goal (40%) + Constraints (30%) + Success Criteria (30%)
125
+ Feature: Goal (30%) + Constraints (30%) + Success Criteria (20%) + Integration (20%)
126
+ Integration: Goal (20%) + Constraints (25%) + Success Criteria (20%) + API Contract (35%)
127
+ ```
128
+
129
+ #### Dimension Scoring (0.0 – 1.0)
130
+
131
+ | Dimension | 0.0 (Unknown) | 0.5 (Partial) | 1.0 (Clear) |
132
+ |-----------|---------------|----------------|--------------|
133
+ | **Goal** | "Make it better" | "Improve dashboard performance" | "Dashboard loads in <2s with 10k rows" |
134
+ | **Constraints** | No constraints mentioned | "Use existing DB" | "PostgreSQL 15, no new deps, GDPR compliant" |
135
+ | **Success Criteria** | "It should work" | "Users can see their data" | "AC-1.1: GIVEN 10k rows WHEN page loads THEN render <2s" |
136
+ | **Integration** | "Connect to the API" | "Use REST, need auth" | "POST /api/v2/orders, OAuth2, rate limit 100/min" |
137
+ | **API Contract** | "It sends data somewhere" | "JSON payload to endpoint" | "OpenAPI spec provided, request/response schemas defined" |
138
+
139
+ #### Threshold Gate
140
+
141
+ | Ambiguity | Level | Action |
142
+ |-----------|-------|--------|
143
+ | **< 15%** | Crystal Clear | Proceed to Step 3 immediately |
144
+ | **15-25%** | Acceptable | Proceed with noted assumptions — flag gaps in Requirements Doc |
145
+ | **25-40%** | Unclear | Ask 1-2 targeted follow-up questions on weakest dimension |
146
+ | **> 40%** | Blocked | Do NOT proceed. Re-ask the weakest dimension question with examples |
147
+
148
+ <HARD-GATE>
149
+ NEVER hand off to plan with Ambiguity > 40%.
150
+ If user insists "just build it" at > 40%, respond:
151
+ "Ambiguity is [X]% — the weakest area is [dimension]. One more answer cuts this in half: [targeted question]"
152
+ </HARD-GATE>
153
+
154
+ #### Scoring After Each Question
155
+
156
+ After each of the 5 Questions (Step 2), update the score:
157
+
158
+ ```
159
+ Round 1 (WHO): Goal ≈ 0.3, others = 0.0 → Ambiguity ≈ 91%
160
+ Round 2 (WHAT): Goal ≈ 0.7, Success ≈ 0.3 → Ambiguity ≈ 72%
161
+ Round 3 (WHY): Goal ≈ 0.9, Success ≈ 0.5 → Ambiguity ≈ 47%
162
+ Round 4 (BOUNDS): Constraints ≈ 0.6 → Ambiguity ≈ 30%
163
+ Round 5 (CONSTR): Constraints ≈ 0.9 → Ambiguity ≈ 12% ✅
164
+ ```
165
+
166
+ If Ambiguity drops below 15% before all 5 questions are asked (e.g., user provides a detailed PRD), skip remaining questions and proceed. The gate is about clarity, not ceremony.
167
+
168
+ #### Display Format
169
+
170
+ After completing Step 2, show the user:
171
+
172
+ ```
173
+ Clarity Score: [100 - ambiguity]%
174
+ Goal: [██████████] 0.9
175
+ Constraints: [████████░░] 0.8
176
+ Success Criteria: [██████░░░░] 0.6 ← weakest
177
+ Status: ACCEPTABLE (ambiguity 23%) — proceeding with noted gaps
178
+ ```
179
+
113
180
  ### Step 3 — Hidden Requirement Discovery
114
181
 
115
182
  After the 5 questions, analyze for requirements the user DIDN'T mention:
@@ -332,11 +399,14 @@ Known failure modes for this skill. Check these before declaring done.
332
399
  | Requirements doc too verbose (>500 lines) | MEDIUM | Max 200 lines — concise, actionable, testable |
333
400
  | Skipping BA for "simple" features that turn out complex | HIGH | Let cook's complexity detection trigger BA, not user judgment |
334
401
  | Recommending shortcuts without Completeness Score | MEDIUM | Step 3.5: every option needs X/10 score + dual effort estimate (human vs AI). "90% coverage" is a red flag when 100% costs 15 min more |
402
+ | Handing off to plan with ambiguity > 40% | CRITICAL | Step 2.5 HARD-GATE: compute ambiguity score after elicitation, block handoff if > 40%, ask targeted follow-up on weakest dimension |
403
+ | Skipping ambiguity scoring because "user seems clear" | HIGH | Always compute the score — perceived clarity ≠ measured clarity. The formula catches gaps humans miss |
335
404
 
336
405
  ## Done When
337
406
 
338
407
  - Requirement type classified (feature/refactor/integration/greenfield)
339
408
  - 5 probing questions asked and answered (or extracted from spec/PRD)
409
+ - Ambiguity Score computed and displayed — must be ≤ 40% before proceeding (≤ 25% preferred)
340
410
  - Hidden requirements discovered and confirmed with user
341
411
  - Scope defined (in/out/assumptions/dependencies)
342
412
  - User stories with testable acceptance criteria produced
@@ -87,6 +87,7 @@ Direct API call ≠ Wrapper/middleware layer ≠ Reverse engineering ≠ Browser
87
87
  ## Calls (outbound)
88
88
 
89
89
  - `plan` (L2): when idea is selected and needs structuring into actionable steps
90
+ - `design` (L2): when selected approach has UI/UX implications — hand off visual decisions
90
91
  - `research` (L3): gather data for informed brainstorming (existing solutions, benchmarks)
91
92
  - `trend-scout` (L3): market context and trends for product-oriented brainstorming
92
93
  - `problem-solver` (L3): structured reasoning frameworks (SCAMPER, First Principles, 6 Hats)
@@ -4,7 +4,7 @@ description: "Validates agent claims against evidence trail. Catches 'done' with
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "1.7.0"
7
+ version: "1.8.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: validation
@@ -91,6 +91,30 @@ Why: Self-Validation catches domain-specific quality issues that generic claim m
91
91
  If a skill has Self-Validation and ANY check is UNCONFIRMED or CONTRADICTED → overall verdict cannot be CONFIRMED, even if all explicit claims pass.
92
92
  </HARD-GATE>
93
93
 
94
+ ### Step 1d — Execution Loop Audit
95
+
96
+ Before validating claims, audit the agent's tool call pattern for execution loops that indicate the agent was stuck but didn't report it:
97
+
98
+ **Classify the agent's tool calls** from this workflow into two categories:
99
+
100
+ | Category | Tools | Expected in Phase 4 |
101
+ |----------|-------|---------------------|
102
+ | **Observation** | Read, Grep, Glob, Bash(grep/ls/cat) | <40% of calls |
103
+ | **Effect** | Write, Edit, Bash(build/test/npm) | >60% of calls |
104
+
105
+ **Loop patterns to detect**:
106
+
107
+ | Pattern | Detection | Verdict Impact |
108
+ |---------|-----------|----------------|
109
+ | **Observation chain**: 6+ consecutive observation tools in Phase 4 | Count longest observation-only streak | Add WARN: "Agent had {N}-call observation streak during implementation — possible analysis paralysis" |
110
+ | **Low effect ratio**: <20% effect calls during Phase 4 | `effect_calls / total_calls` | Add WARN: "Only {X}% of Phase 4 calls were writes — agent may have been stuck" |
111
+ | **Repeating tool pattern**: Same tool+args called 3+ times | Hash tool+args, count duplicates | Add WARN: "Agent called {tool}({args}) {N} times — possible loop" |
112
+ | **Budget overrun**: Phase 4 exceeded 50 tool calls for a single-file task | Count Phase 4 calls vs files changed | Add WARN: "50+ tool calls for {N} files changed — disproportionate effort" |
113
+
114
+ **Scoring impact**: Loop warnings don't change individual claim verdicts but ARE included in the Completion Gate Report under a new `### Execution Efficiency` section. This gives the calling orchestrator signal about whether the agent's process was healthy, not just whether the output was correct.
115
+
116
+ **Skip if**: Nano/Fast rigor — not enough tool calls to meaningfully analyze.
117
+
94
118
  ### Step 2 — Match Evidence
95
119
 
96
120
  For each claim, look for corresponding evidence in the conversation context:
@@ -167,8 +191,6 @@ UNCONFIRMED — 1 claim lacks evidence, 1 contradicted. Cannot proceed to commit
167
191
 
168
192
  ### Step 4.5 — Cross-Phase Integration Check
169
193
 
170
- > From GSD (gsd-build/get-shit-done, 30.8k★): "Phase boundaries are where integration bugs hide."
171
-
172
194
  When validating a completed phase in a multi-phase plan, check for integration gaps between phases:
173
195
 
174
196
  1. **Orphaned exports** — files/functions created in this phase that claim to be used by future phases (see `## Cross-Phase Context → Exports`) but are not yet importable:
@@ -269,6 +291,7 @@ Completion Gate Report with status (CONFIRMED/UNCONFIRMED/CONTRADICTED), claim v
269
291
  | Partial completion claimed as full — 80% done but "implemented" | HIGH | Adversarial checklist: check for partial completion, scope mismatch, evidence-claim alignment |
270
292
  | Self-Validation skipped — skill has checks but gate ignores them | HIGH | Step 1c: extract Self-Validation from skill's SKILL.md, treat each as implicit claim. Missing = UNCONFIRMED |
271
293
  | Plan says done but phase file has unchecked tasks | HIGH | Step 5.5: diff changed files vs phase plan's Files Touched + Tasks sections |
294
+ | Agent stuck in observation loop but claims "implemented" | HIGH | Step 1d: Execution Loop Audit detects low effect ratio and observation chains — flags in report even if claims pass |
272
295
 
273
296
  ## Done When
274
297
 
@@ -4,7 +4,7 @@ description: "Context window management. Auto-triggered when context is filling
4
4
  user-invocable: false
5
5
  metadata:
6
6
  author: runedev
7
- version: "0.8.0"
7
+ version: "0.9.0"
8
8
  layer: L3
9
9
  model: haiku
10
10
  group: state
@@ -218,6 +218,54 @@ When processing streaming LLM output (e.g., in skills that invoke AI calls or pr
218
218
  - **JSON output**: accumulate until the closing brace — partial JSON can't be parsed
219
219
  - **Short responses** (<100 chars expected): overhead of boundary detection exceeds benefit
220
220
 
221
+ ## Artifact Folding (Large Output Management)
222
+
223
+ When tool results are excessively large, they consume disproportionate context without proportionate value. **Artifact folding** saves the full output to a file and replaces it in context with a compact preview.
224
+
225
+ ### When to Fold
226
+
227
+ | Condition | Action |
228
+ |-----------|--------|
229
+ | Tool output > 4000 characters | Fold to artifact |
230
+ | Tool output > 120 lines | Fold to artifact |
231
+ | Multiple tool outputs from the same command class (e.g., 5+ Grep results) | Fold all into single artifact |
232
+ | Code block output > 200 lines | Fold to artifact |
233
+
234
+ ### Folding Procedure
235
+
236
+ 1. **Save full output** to `.rune/artifacts/artifact-{timestamp}-{tool}.md`:
237
+ ```markdown
238
+ # Artifact: {tool_name} output
239
+ Generated: {timestamp}
240
+ Command: {tool_call_summary}
241
+
242
+ {full_output}
243
+ ```
244
+
245
+ 2. **Replace in context** with a compact preview:
246
+ ```
247
+ [FOLDED: {tool_name} output — {line_count} lines, {char_count} chars]
248
+ Preview (first 10 lines):
249
+ {first_10_lines}
250
+ ...
251
+ Full output: .rune/artifacts/artifact-{timestamp}-{tool}.md
252
+ Use Read to access the full artifact if needed.
253
+ ```
254
+
255
+ 3. **On compaction**: Artifact files survive compaction — the continuation summary references them by path. This means large outputs are preserved across compaction boundaries without consuming context.
256
+
257
+ ### Rules
258
+
259
+ - **Never fold user messages** — only tool outputs
260
+ - **Never fold error outputs** — errors need full visibility for debugging
261
+ - **Never fold outputs < 1000 chars** — folding overhead exceeds savings
262
+ - **Fold preemptively in YELLOW/ORANGE** — don't wait for RED to start managing output size
263
+ - **Clean up artifacts** at session end: artifacts older than the current session can be deleted (they're already in git history or irrelevant)
264
+
265
+ ### Why
266
+
267
+ A single `Grep` across a large codebase can return 3000+ lines. Without folding, this consumes ~4000 tokens of context — often more than the rest of the conversation combined. Folding preserves the information (accessible via Read) while keeping context lean. Combined with the Structured Summary compaction technique, artifact folding enables much longer productive sessions.
268
+
221
269
  ## Context Health Levels
222
270
 
223
271
  ```
@@ -5,13 +5,13 @@ context: fork
5
5
  agent: general-purpose
6
6
  metadata:
7
7
  author: runedev
8
- version: "2.0.0"
8
+ version: "2.3.0"
9
9
  layer: L1
10
10
  model: sonnet
11
11
  group: orchestrator
12
12
  tools: "Read, Write, Edit, Bash, Glob, Grep"
13
- emit: phase.complete
14
- listen: plan.ready, review.complete
13
+ emit: phase.complete, checkpoint.request
14
+ listen: plan.ready, review.complete, ideas.ready, preflight.passed, verification.complete
15
15
  ---
16
16
 
17
17
  # cook
@@ -73,6 +73,7 @@ When `--template <name>` is provided, cook loads a pre-built workflow template i
73
73
  - Contains "security", "auth", "vulnerability", "CVE" → `security`
74
74
  - Contains "urgent", "hotfix", "production" → `hotfix`
75
75
  - Contains "quick", "just", "chỉ cần", "copy", "move", "rename", "bump" → `nano`
76
+ - Contains "graft", "port from", "copy from repo", "clone feature from" → **delegate to `rune:graft`** (not a cook chain — hand off entirely)
76
77
  - Contains `--template` → load template workflow (see above)
77
78
  - Default → `feature`
78
79
 
@@ -379,6 +380,11 @@ If the coder model needs info from other phases, it's in the Cross-Phase Context
379
380
 
380
381
  Quality checks run in **two stages** — spec compliance gates code review. Reviewing code quality before verifying it matches the spec wastes effort on code that may need rewriting.
381
382
 
383
+ **Signal dispatch ordering**: When `fix` emits `code.changed`, 4 listeners react (preflight, sentinel, test, review). Cook coordinates dispatch order — do NOT let all 4 fire simultaneously:
384
+ - **Stage 1**: preflight + sentinel (parallel — independent checks)
385
+ - **Stage 2**: test (after Stage 1 passes — no point testing non-compliant code)
386
+ - **Stage 3**: review (after test passes — review verified code only)
387
+
382
388
  ```
383
389
  STAGE 1 (parallel):
384
390
  Launch 5a (preflight) + 5b (sentinel) simultaneously.
@@ -634,6 +640,46 @@ Stuck patterns (all banned):
634
640
  A wrong first attempt that produces feedback beats perfect understanding that never ships.
635
641
  </HARD-GATE>
636
642
 
643
+ ### Observation/Effect Ratio Tracking
644
+
645
+ Track every tool call during Phase 4 (IMPLEMENT) as either **observation** (read-only) or **effect** (modifies state):
646
+
647
+ | Category | Tool Examples |
648
+ |----------|--------------|
649
+ | **Observation** | Read, Grep, Glob, Bash(grep/ls/cat/git log) |
650
+ | **Effect** | Write, Edit, Bash(npm/build/test/mkdir) |
651
+
652
+ **Detection rules** (check every 8 tool calls during Phase 4):
653
+
654
+ | Pattern | Threshold | Signal | Action |
655
+ |---------|-----------|--------|--------|
656
+ | **Observation chain** | 6+ consecutive observation tools with zero effects | Agent is stuck reading, not building | Inject: "OBSERVATION LOOP — 6 reads without writing. Act on what you know or report BLOCKED." |
657
+ | **Low effect ratio** | In last 10 calls, effects < 15% | Agent is in analysis mode, not implementation | Inject: "Effect ratio below 15%. Phase 4 is IMPLEMENT — write code, don't just read it." |
658
+ | **Diminishing returns** | Last 3 observations found <2 new relevant facts combined | Searching is no longer productive | Inject: "Diminishing returns — last 3 reads added nothing new. Synthesize and act." |
659
+ | **Repeating sequences** | A-B-A-B or A-B-C-A-B-C pattern across 6+ calls | Circular behavior | Inject: "REPEATING SEQUENCE detected. Break the cycle — try a different approach or report BLOCKED." |
660
+
661
+ **Important**: These are injected as advisor messages, not hard blocks. The agent can continue if it has good reason, but the message forces conscious acknowledgment of the pattern.
662
+
663
+ **Skip if**: Phase 1 (UNDERSTAND) — observation-heavy is expected during research. Only track during Phase 4+ where effects should dominate.
664
+
665
+ ### Budget-Aware Phase Progression
666
+
667
+ Beyond the existing Exit Conditions (MAX_DEBUG_LOOPS, MAX_QUALITY_LOOPS, etc.), track **cumulative budget** across the entire cook session:
668
+
669
+ | Budget | Limit | What Happens at Limit |
670
+ |--------|-------|----------------------|
671
+ | **Phase 4 react budget** | 15 tool calls per task within Phase 4 | Force: move to next task or report partial completion |
672
+ | **Global replan budget** | 2 replans per session (Phase 4 Step 6) | Force: proceed with current plan or escalate to user |
673
+ | **Quality retry budget** | 3 total quality re-runs across 5a-5d | Force: ship with known issues documented, don't loop |
674
+ | **Total session tool calls** | 150 calls | Force: save state via session-bridge, compact or pause |
675
+
676
+ **Hard override rules**:
677
+ - If react budget exhausted for a task but task is IN_PROGRESS → force CONTINUE to next task (don't re-attempt)
678
+ - If replan budget exhausted but plan still failing → force escalation (don't attempt 3rd replan)
679
+ - If quality retry budget exhausted → emit concerns in Cook Report, proceed to commit with documented caveats
680
+
681
+ **Why**: Without hard budgets, agents get trapped in local optimization loops — retrying the same failing approach indefinitely. Budget constraints force escalation or acceptance of partial results, which is always better than an infinite loop.
682
+
637
683
  ### Hash-Based Tool Loop Detection
638
684
 
639
685
  <MUST-READ path="references/loop-detection.md" trigger="when same tool+args+result appears to be repeating"/>
@@ -766,6 +812,29 @@ When invoked by `team` with a NEXUS Handoff, include the Deliverables table —
766
812
  | Cook Report | Markdown (inline) | Emitted at end of session |
767
813
  | Session state | Markdown | `.rune/decisions.md`, `.rune/progress.md`, `.rune/conventions.md` |
768
814
 
815
+ ## Document Ownership
816
+
817
+ | Scope | Access | Files |
818
+ |-------|--------|-------|
819
+ | **Owns** (read + write) | `.rune/plan-*.md`, `.rune/progress.md`, `.rune/decisions.md`, `.rune/conventions.md`, source files per approved plan |
820
+ | **Reads** (never writes) | `CLAUDE.md`, `SKILL.md` (any), `.rune/contract.md`, `.rune/checkpoint.md` |
821
+ | **Never modifies** | `compiler/**`, `extensions/**`, `PACK.md`, other skills' `SKILL.md`, `.rune/learnings.jsonl` |
822
+
823
+ When delegating to sub-skills (scout, plan, test, review), each sub-skill owns its own output. Cook coordinates but does not overwrite sub-skill artifacts.
824
+
825
+ ## Anti-Patterns
826
+
827
+ Common multi-agent failures to explicitly avoid. These are NOT edge cases — they are the most frequent cook failures in production.
828
+
829
+ | Anti-Pattern | Why It Fails | Correct Approach |
830
+ |---|---|---|
831
+ | **Bypass hierarchy** — skipping scout/plan and jumping to Phase 4 code | Builds wrong thing. Most "wasted work" traces back to missing Phase 1-2 | Follow phase gates. Even "obvious" tasks benefit from 30s of scout |
832
+ | **Shadow decisions** — making architectural choices without logging to decisions.md | Next session repeats the same debate. Team agents contradict each other | Log every non-trivial choice via `decisions.md` or `journal` |
833
+ | **Gold-plating** — adding "nice-to-have" features not in the approved plan | Scope creep, delayed delivery, untested code paths | Build ONLY what's in the plan. Log extras as follow-up tasks |
834
+ | **Test-after** — writing tests after implementation instead of before (TDD violation) | Tests validate implementation bugs, not requirements. Coverage looks good but misses edge cases | Phase 3 (RED) before Phase 4 (GREEN). Always |
835
+ | **Monolithic commit** — one giant commit with all changes | Impossible to revert partially. Review is overwhelming | Commit per phase or per logical unit. Small, reviewable diffs |
836
+ | **Assumption-based implementation** — guessing requirements instead of asking | Builds the wrong thing confidently. User discovers mismatch late | If ambiguous, ask. 30s of clarification saves 30min of rework |
837
+
769
838
  ## Sharp Edges
770
839
 
771
840
  <MUST-READ path="references/sharp-edges.md" trigger="before declaring done — review all 18 failure modes"/>
@@ -32,6 +32,39 @@ Also defines the NEXUS Deliverables table format used when cook is invoked by `t
32
32
  - Saved to .rune/progress.md
33
33
  ```
34
34
 
35
+ ## Chain Metadata (Cross-Skill Data Forwarding)
36
+
37
+ Every Cook Report MUST end with a `chain_metadata` YAML block. This enables downstream skills to consume cook's output data without parsing prose. See `docs/references/chain-metadata.md` for the full contract.
38
+
39
+ ```yaml
40
+ chain_metadata:
41
+ skill: "rune:cook"
42
+ version: "2.2.0"
43
+ status: "[same as Cook Report status]"
44
+ domain: "[area worked on — e.g., auth, payments, compiler]"
45
+ files_changed:
46
+ - "[list of files created/modified in this session]"
47
+ exports:
48
+ commit_hash: "[actual git hash]"
49
+ files_changed_count: [N]
50
+ test_results: { passed: [N], failed: [N], coverage: [N] }
51
+ quality_gates: { preflight: "[PASS/WARN/FAIL]", sentinel: "[PASS/WARN/FAIL]", review: "[PASS/WARN/FAIL]" }
52
+ phase_count: [N]
53
+ concerns: [] # populated if DONE_WITH_CONCERNS
54
+ suggested_next: # 1-3 data-driven recommendations based on THIS output
55
+ - skill: "rune:[skill]"
56
+ reason: "[grounded in actual data — not generic advice]"
57
+ consumes: ["[export keys the suggested skill would use]"]
58
+ ```
59
+
60
+ **Rules for suggested_next:**
61
+ - Base suggestions on ACTUAL output data (sentinel WARN → suggest deeper security review, low coverage → suggest more tests)
62
+ - Never suggest skills that already ran successfully in this session
63
+ - Status-aware: BLOCKED → suggest debug/fix, DONE → suggest review/deploy/test
64
+ - Max 3 suggestions, ordered by priority
65
+
66
+ **When NOT to emit:** When cook is invoked as a sub-step of `autopilot` or `team` — the orchestrator emits its own chain_metadata at the end.
67
+
35
68
  ## Usage Rules
36
69
 
37
70
  - When cook is invoked **standalone** (not by team): Deliverables table is optional
@@ -8,6 +8,7 @@ metadata:
8
8
  model: sonnet
9
9
  group: development
10
10
  tools: "Read, Write, Edit, Bash, Glob, Grep"
11
+ emit: db.migrated
11
12
  ---
12
13
 
13
14
  # db
@@ -3,7 +3,7 @@ name: debug
3
3
  description: Root cause analysis for bugs and unexpected behavior. Traces errors through code, uses structured reasoning, and hands off to fix when cause is found. Core of the debug↔fix mesh.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.9.0"
6
+ version: "1.1.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: development
@@ -178,6 +178,38 @@ After successful root cause identification (Step 5), append entry:
178
178
 
179
179
  This prevents re-debugging the same issue across sessions.
180
180
 
181
+ ### Step 2d: Known Error Pattern Matching
182
+
183
+ Before forming hypotheses, match the error against common **error archetypes**. If a match is found, skip directly to the known fix approach — no hypothesis cycling needed.
184
+
185
+ **Error Pattern Catalog**:
186
+
187
+ | Pattern ID | Detection (Error Type + Keywords) | Root Cause | Recovery Hint |
188
+ |------------|----------------------------------|------------|---------------|
189
+ | `STATELESS_LOSS` | `NameError` / `ReferenceError` + variable defined in previous step | Execution context doesn't persist between tool calls | "Combine all variable definitions and usage in a single code block" |
190
+ | `MODULE_NOT_FOUND` | `ModuleNotFoundError` / `Cannot find module` | Dependency not installed or wrong import path | "Check package.json/requirements.txt. Install missing dep, then retry" |
191
+ | `TYPE_MISMATCH` | `TypeError` + "undefined is not a function" / "has no attribute" | Wrong type passed through chain — object where primitive expected or vice versa | "Trace the value backward: where was it created? What type was intended?" |
192
+ | `ASYNC_DEADLOCK` | `TimeoutError` / `Promise` + hang / `await` missing | Async/await misuse — missing await, blocking in async, unresolved promise | "Check: missing await? Blocking call in async context? Unresolved promise chain?" |
193
+ | `PATH_MISMATCH` | `ENOENT` / `FileNotFoundError` + path string in error | Relative vs absolute path, or CWD differs from expected | "Print resolved path. Check CWD. Use path.resolve() or Path.resolve()" |
194
+ | `ENCODING_ISSUE` | `UnicodeDecodeError` / `SyntaxError` + quotes/special chars | Non-ASCII characters in code or data (curly quotes, BOM, etc.) | "Check for smart quotes, BOM markers, or non-ASCII in the file. Use `file` command to check encoding" |
195
+ | `ENV_MISSING` | `KeyError` / "undefined" + env var name | Environment variable not set or .env not loaded | "Check .env file exists and is loaded. Verify var name matches exactly (case-sensitive)" |
196
+ | `CIRCULAR_IMPORT` | `ImportError` + "partially initialized" / "circular" | Module A imports B imports A | "Restructure: move shared types to a third module, or use lazy imports" |
197
+
198
+ **Matching rules**:
199
+ - Match on error type + 2+ keywords from the Detection column
200
+ - If matched: report the pattern ID and recovery hint in the Debug Report, then proceed to test the known fix approach as H1 (highest priority hypothesis)
201
+ - If NOT matched: proceed to Step 3 (form hypotheses from scratch)
202
+
203
+ **Error fingerprinting**: When comparing errors across hypothesis cycles, normalize these elements before comparison:
204
+ - Line numbers → `<LINE>`
205
+ - File paths → `<PATH>`
206
+ - Variable/function names → `<IDENT>`
207
+ - Timestamps → `<TIME>`
208
+
209
+ Two errors with the same fingerprint after normalization are the SAME error — don't re-investigate, the previous hypothesis result still applies.
210
+
211
+ **Catalog growth**: After each successful debug (Step 5), check: does this error pattern match any existing catalog entry? If not, and the root cause is generalizable (not project-specific), suggest adding it to the catalog via a note in the Debug Report: "New pattern candidate: [pattern] — consider adding to error catalog."
212
+
181
213
  ### Step 3: Form Hypotheses
182
214
 
183
215
  List exactly 2-3 possible root causes — no more, no fewer.
@@ -373,6 +405,28 @@ Debug returns one of four statuses to its caller (cook, fix, test, surgeon). The
373
405
  | Fix recommendation | Inline (Debug Report) | Direction only — no code changes |
374
406
  | Debug knowledge base entry | Markdown | `.rune/debug/knowledge-base.md` (appended on success) |
375
407
 
408
+ ## Chain Metadata
409
+
410
+ Append to Debug Report when invoked standalone. Suppress when called as sub-skill inside an L1 orchestrator (cook, team, etc.) — the orchestrator emits a consolidated block. See `docs/references/chain-metadata.md`.
411
+
412
+ ```yaml
413
+ chain_metadata:
414
+ skill: "rune:debug"
415
+ version: "1.1.0"
416
+ status: "[DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED]"
417
+ domain: "[area debugged]"
418
+ files_changed: [] # debug never changes files
419
+ exports:
420
+ root_cause: { file: "[path]", line: [N], explanation: "[cause]" }
421
+ severity: "[critical | high | medium | low]"
422
+ confidence: "[high | medium | low]"
423
+ fix_recommendation: "[direction for fix skill]"
424
+ suggested_next:
425
+ - skill: "rune:fix"
426
+ reason: "[grounded in root cause — e.g., 'Critical race condition found in auth.ts:42']"
427
+ consumes: ["root_cause", "fix_recommendation"]
428
+ ```
429
+
376
430
  ## Sharp Edges
377
431
 
378
432
  | Failure Mode | Severity | Mitigation |
@@ -390,6 +444,8 @@ Debug returns one of four statuses to its caller (cook, fix, test, surgeon). The
390
444
  | Running same test 3x with same failure without code change | MEDIUM | True stuck loop — no progress possible. Hand off to fix with current incomplete diagnosis |
391
445
  | Scope creep via debug — "while investigating, also fix X" | HIGH | Step 1.5 Scope Lock: lock edits to narrowest affected directory. Fix recommendations MUST stay within boundary. Expand only with user confirmation |
392
446
  | Debug report recommends touching 5+ unrelated files | HIGH | Symptom of fixing at crash sites instead of source. Backward trace (Step 2) to find origin. If truly 5+ files → likely architectural issue → escalate via 3-Fix Rule |
447
+ | Re-investigating known error patterns from scratch | MEDIUM | Step 2d: match error against Known Error Pattern Catalog first — skip hypothesis cycling for recognized patterns |
448
+ | Same error fingerprint across cycles treated as different errors | MEDIUM | Step 2d: normalize line numbers, paths, variable names before comparison — same fingerprint = same error |
393
449
 
394
450
  ## Done When
395
451
 
@@ -10,7 +10,7 @@ metadata:
10
10
  group: delivery
11
11
  tools: "Read, Write, Edit, Bash, Glob, Grep"
12
12
  emit: deploy.complete
13
- listen: security.passed, tests.passed
13
+ listen: security.passed, tests.passed, docs.updated, audit.complete, db.migrated
14
14
  ---
15
15
 
16
16
  # deploy