@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
@@ -3,7 +3,7 @@ name: design
3
3
  description: Design system reasoning. Maps product domain to style, palette, typography, and platform-specific patterns. Generates .rune/design-system.md as the shared design contract for all UI-generating skills.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.3.0"
6
+ version: "0.4.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: creation
@@ -32,6 +32,8 @@ Design system reasoning layer. Converts a product description into a concrete de
32
32
  ## Called By (inbound)
33
33
 
34
34
  - `cook` (L1): before any frontend code generation
35
+ - `brainstorm` (L2): when selected approach has UI/UX implications
36
+ - `ba` (L2): when requirements include UI/UX components
35
37
  - `review` (L2): when AI anti-pattern detected in diff
36
38
  - `perf` (L2): when Lighthouse Accessibility score blocks
37
39
  - User: `/rune design` direct invocation
@@ -97,6 +99,31 @@ From the user's task description + codebase context, classify product type:
97
99
 
98
100
  If domain is unclear: ask one clarifying question — "Is this closer to X or Y?"
99
101
 
102
+ ### Step 2.5 — Mood-to-Constraint Mapping
103
+
104
+ After classifying domain, ask ONE question: **"What should users feel when they use this?"**
105
+
106
+ Accept a single mood keyword (or infer from context if obvious). Map mood to concrete design constraints:
107
+
108
+ | Mood | Color Temp | Typography Weight | Whitespace | Animation | Shadow |
109
+ |------|-----------|-------------------|------------|-----------|--------|
110
+ | **Impressed** | Cool (blue-slate) | Heavy display (700-800) | Generous (xl-3xl) | Dramatic reveals (0.8-1.2s ease-out) | Deep, layered |
111
+ | **Excited** | Warm (amber-orange) | Bold contrasts (400 vs 800) | Tight-medium (sm-lg) | Energetic springs (0.4-0.6s spring) | Elevation lifts |
112
+ | **Calm** | Neutral-warm (stone-sage) | Light-medium (300-500) | Very generous (2xl-3xl) | Slow fades (0.6-0.8s ease-out-quad) | Soft, minimal |
113
+ | **Confident** | Cool-neutral (zinc-slate) | Medium-heavy (500-700) | Structured (md-xl) | Precise slides (0.3-0.5s ease) | Crisp, defined |
114
+ | **Playful** | Saturated (multi-hue) | Round + bold (600-700) | Medium, irregular (md-lg) | Bouncy springs (0.4-0.6s spring, overshoot) | Hard/comic (3-5px offset) |
115
+ | **Techy** | Cold (gray-cyan) | Mono-heavy, crisp (400-600) | Dense, grid-aligned (sm-md) | Sharp snaps (0.15-0.3s ease-out) | Minimal or glow |
116
+ | **Professional** | Muted neutrals | System fonts, readable (400-500) | Balanced (md-lg) | Subtle (0.2-0.3s ease) | Standard elevation |
117
+ | **Inspired** | Rich-warm (gold-terracotta) | Editorial display (300-700 range) | Asymmetric, generous | Scroll-driven reveals (0.5-0.8s) | Dramatic, directional |
118
+
119
+ **Mapping rules:**
120
+ 1. Mood constraints OVERRIDE generic domain defaults where they conflict (mood is user intent, domain is convention)
121
+ 2. If mood contradicts domain safety (e.g., "Playful" + Healthcare), WARN user: "Playful tone may reduce trust in medical context — proceed?"
122
+ 3. Write selected mood + resolved constraints to `.rune/design-system.md` under `## Mood` section
123
+ 4. Downstream skills (`animation-patterns`, `palette-picker`, `type-system`) read mood constraints from design-system.md
124
+
125
+ **Skip if**: User says "no preference" or "just follow domain defaults" — proceed to Step 3 with domain-only reasoning.
126
+
100
127
  ### Step 3 — Apply Domain Reasoning Rules
101
128
 
102
129
  Map domain to design system parameters:
@@ -333,6 +360,44 @@ sm: 6px | md: 8px | lg: 12px | xl: 16px | full: 9999px
333
360
  - [ ] Responsive tested at 375px / 768px / 1024px / 1440px
334
361
  ```
335
362
 
363
+ ### Step 5.5 — UI Design Contract (UI-SPEC.md)
364
+
365
+ After generating the design system, lock key visual decisions in `.rune/ui-spec.md` — a binding contract that prevents design drift during implementation.
366
+
367
+ **Why**: design-system.md defines tokens (what's available). UI-SPEC locks decisions (what was chosen and WHY). Without a spec, each component re-decides layout, density, and hierarchy — causing visual inconsistency.
368
+
369
+ **Generate `.rune/ui-spec.md`:**
370
+
371
+ ```markdown
372
+ # UI Specification: [Project Name]
373
+ Locked: [YYYY-MM-DD] | Mood: [selected mood]
374
+
375
+ ## Layout Decisions
376
+ - Page max-width: [value]px
377
+ - Sidebar: [yes/no] — [width]px [fixed/collapsible]
378
+ - Content density: [compact/balanced/spacious]
379
+ - Card sizing: [uniform/varied] — if varied, specify hierarchy rules
380
+
381
+ ## Visual Hierarchy Rules
382
+ - Primary action: [color] [size] [weight] — ONE per viewport
383
+ - Secondary action: [ghost/outline] style — max 2 per section
384
+ - Data emphasis: [monospace + bold] for numbers, [color accent] for status
385
+ - Section separation: [border/spacing/background] — pick ONE, be consistent
386
+
387
+ ## Component Decisions
388
+ - Card style: [elevated/bordered/glass] — reasoning: [why]
389
+ - Table style: [striped/bordered/minimal] — reasoning: [why]
390
+ - Form layout: [stacked/inline/grid] — reasoning: [why]
391
+ - Navigation: [sidebar/topbar/tabs] — reasoning: [why]
392
+
393
+ ## Locked Anti-Decisions (things we explicitly chose NOT to do)
394
+ - ❌ [rejected option] — because [reason]
395
+ ```
396
+
397
+ <HARD-GATE>
398
+ UI-SPEC.md is a contract. Once written, changes require explicit user approval ("I want to change the card style"). Skills that generate UI (`cook`, `fix`, `scaffold`) MUST read UI-SPEC.md before producing components. Drift from spec = review finding.
399
+ </HARD-GATE>
400
+
336
401
  ### Step 6 — Accessibility Review
337
402
 
338
403
  Run a focused accessibility audit on the design system and any existing UI code. This step ensures the design contract doesn't produce inaccessible outputs.
@@ -349,6 +414,39 @@ Run a focused accessibility audit on the design system and any existing UI code.
349
414
 
350
415
  If violations found → add them to `.rune/design-system.md` Anti-Patterns section as concrete rules.
351
416
 
417
+ ### Step 6.5 — 6-Pillar Visual Audit
418
+
419
+ Score the generated design system across 6 pillars. Each pillar scored 1-4 (1=Poor, 2=Fair, 3=Good, 4=Excellent). Minimum passing score: **18/24** (average 3.0).
420
+
421
+ | Pillar | Score 1 (Poor) | Score 2 (Fair) | Score 3 (Good) | Score 4 (Excellent) |
422
+ |--------|---------------|----------------|----------------|---------------------|
423
+ | **Copy** | Placeholder text, generic CTAs ("Submit"), no voice | Real copy but inconsistent tone | Consistent voice, domain-appropriate, clear CTAs | Personality-rich, scannable, microcopy for every state |
424
+ | **Visuals** | Stock photos, generic icons, no visual identity | Consistent icon set, basic imagery | Custom illustrations or curated photography, clear hierarchy | Distinctive visual language, icons tell stories, zero stock |
425
+ | **Color** | Default framework palette, no semantic meaning | Brand colors defined but inconsistent usage | Full semantic palette, dark mode, accessible contrast | Mood-aligned, colorblind-safe, context-adaptive (profit/loss/status) |
426
+ | **Typography** | Single font, no scale | Font pairing exists but inconsistent sizing | Clear hierarchy (display/heading/body/mono), numbers monospace | Mood-aligned pairing, fluid scaling, platform-native where needed |
427
+ | **Spacing** | Inconsistent gaps, cramped or too loose | Base unit defined but not consistently applied | 8px grid, consistent section/component/element spacing | Density variants (compact/default/spacious), rhythm feels intentional |
428
+ | **UX** | Missing states (empty/error/loading), no feedback | Basic states exist, some interactive feedback | All states covered, toast/loading/skeleton, focus management | Delightful micro-interactions, smart defaults, zero dead-ends |
429
+
430
+ **Audit output:**
431
+
432
+ ```
433
+ ### Visual Audit Score: [total]/24
434
+
435
+ | Pillar | Score | Notes |
436
+ |--------|-------|-------|
437
+ | Copy | 3 | Consistent voice, missing loading microcopy |
438
+ | Visuals | 2 | Using Phosphor icons (good), no custom illustration |
439
+ | Color | 4 | Full semantic palette, colorblind alternates defined |
440
+ | Typography | 3 | JetBrains Mono for numbers, Inter for prose — solid |
441
+ | Spacing | 3 | 8px grid applied, density variants not needed yet |
442
+ | UX | 3 | All states covered, micro-interactions in progress |
443
+ | **Total** | **18/24** | PASS — ship-ready with Copy improvements recommended |
444
+ ```
445
+
446
+ **If score < 18**: Flag specific weak pillars in Design Report. Add improvement tasks to `.rune/design-system.md` under `## Improvement Backlog`.
447
+
448
+ **Registry safety check**: If an existing component library is in use (shadcn, MUI, etc.), verify the design system doesn't conflict with the library's token structure. Flag collisions.
449
+
352
450
  ### Step 7 — UX Writing Patterns
353
451
 
354
452
  Generate microcopy guidelines specific to this product domain. UX writing is part of design — not an afterthought.
@@ -448,8 +546,10 @@ Trading/Fintech — Data-Dense Dark — Web
448
546
  | Artifact | Format | Location |
449
547
  |----------|--------|----------|
450
548
  | Design system file | Markdown | `.rune/design-system.md` |
549
+ | UI specification contract | Markdown | `.rune/ui-spec.md` |
451
550
  | Design report | Markdown | inline (chat output) |
452
551
  | Accessibility audit findings | Markdown list | inline + appended to design-system.md |
552
+ | Visual audit score | Table (6 pillars × 1-4) | inline + appended to design report |
453
553
  | UX writing guidelines | Markdown section | `.rune/design-system.md` § UX Writing |
454
554
 
455
555
  ## Sharp Edges
@@ -462,6 +562,9 @@ Known failure modes for this skill. Check these before declaring done.
462
562
  | Purple/indigo accent on non-AI-native product | HIGH | Constraint 3 blocks this — re-generate with domain-appropriate accent |
463
563
  | Anti-pattern list copied from generic sources (not domain-specific) | HIGH | Each anti-pattern must cite why it fails in THIS specific domain |
464
564
  | design-system.md not written (only reported verbally) | HIGH | Constraint 4 — no file = no persistence = future sessions lose design context |
565
+ | Mood contradicts domain safety conventions | HIGH | Step 2.5 warns user before proceeding (e.g., Playful + Healthcare) |
566
+ | UI-SPEC.md drift — components diverge from locked decisions | HIGH | HARD-GATE: cook/fix must read ui-spec.md before generating UI |
567
+ | Visual audit score < 18 shipped without improvement plan | MEDIUM | Step 6.5 flags weak pillars and creates backlog items |
465
568
  | iOS target generating solid-background cards | MEDIUM | Platform Gate: iOS 26 Liquid Glass deprecates this pattern |
466
569
  | Android target using hardcoded hex colors | MEDIUM | Platform Gate: MaterialTheme.colorScheme is mandatory for dynamic color |
467
570
 
@@ -469,12 +572,16 @@ Known failure modes for this skill. Check these before declaring done.
469
572
 
470
573
  - Design reference loaded (user override or baseline)
471
574
  - Domain classified (one of the 10 categories or explicit custom reasoning)
575
+ - Mood mapped to constraints (or explicitly skipped with "domain defaults")
472
576
  - Design system generated with: colors (primitive + semantic), typography, spacing, effects, anti-patterns
473
577
  - Platform-specific overrides applied (if iOS/Android target)
578
+ - UI-SPEC.md written with locked layout, hierarchy, and component decisions
474
579
  - Accessibility review completed (6 checks: contrast, focus, touch targets, labels, semantic HTML, motion)
580
+ - 6-Pillar Visual Audit scored ≥ 18/24 (or weak pillars flagged with improvement tasks)
475
581
  - UX writing guidelines generated (error, empty state, confirmation, loading, button templates)
476
- - `.rune/design-system.md` written (includes UX Writing section)
477
- - Design Report emitted with accent/typography reasoning and anti-pattern count
582
+ - `.rune/design-system.md` written (includes Mood + UX Writing sections)
583
+ - `.rune/ui-spec.md` written (design contract for UI-generating skills)
584
+ - Design Report emitted with mood, accent/typography reasoning, visual audit score, and anti-pattern count
478
585
  - Pre-Delivery Checklist included in design-system.md
479
586
 
480
587
  ## Cost Profile
@@ -8,6 +8,7 @@ metadata:
8
8
  model: sonnet
9
9
  group: delivery
10
10
  tools: "Read, Write, Edit, Glob, Grep"
11
+ emit: docs.updated
11
12
  ---
12
13
 
13
14
  # docs
@@ -192,7 +193,7 @@ After updating any doc, verify consistency across all project documentation:
192
193
  Cross-Doc Consistency:
193
194
  - [x] README.md ↔ CLAUDE.md: versions match, commands match
194
195
  - [x] README.md ↔ docs/index.html: stats match, features match
195
- - [ ] README.md says "61 skills" but CLAUDE.md says "59" → FIX CLAUDE.md
196
+ - [ ] README.md says "62 skills" but CLAUDE.md says "59" → FIX CLAUDE.md
196
197
  ```
197
198
 
198
199
  **Fix inconsistencies immediately** — don't just report them. Update the stale doc to match the source of truth (usually the code or the most recently updated doc).
@@ -3,7 +3,7 @@ name: fix
3
3
  description: Apply code changes and fixes. Writes implementation code, applies bug fixes, and verifies changes with tests. Core action hub in the development mesh.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.7.0"
6
+ version: "0.9.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: development
@@ -68,6 +68,29 @@ Read and fully understand the fix request before touching any file.
68
68
  - If the request is ambiguous or root cause is unclear → call `rune:debug` before proceeding
69
69
  - Note the scope: single function, single file, or multi-file change
70
70
 
71
+ ### Step 1b: Recovery Policy Matrix
72
+
73
+ Before locating code, classify the incoming error/task into a recovery category to determine the right fix strategy. This prevents wasting effort on the wrong approach.
74
+
75
+ | Error Type | Recovery Action | Strategy |
76
+ |------------|----------------|----------|
77
+ | `INPUT_REQUIRED` — missing user input, ambiguous spec | **PROMPT_USER** | Return NEEDS_CONTEXT with specific questions. Do NOT guess. |
78
+ | `INPUT_INVALID` — wrong format, type mismatch, encoding | **AUTO_FIX** | Fix at validation layer. Add schema validation (Zod/Pydantic) if missing. |
79
+ | `TIMEOUT` — operation exceeded time limit | **RETRY** with adjustment | Increase timeout, add retry with exponential backoff, or chunk the operation. |
80
+ | `POLICY_BLOCKED` — security gate, lint rule, contract violation | **ABORT** | Do NOT work around the policy. Report to caller with the specific rule that blocked. |
81
+ | `PERMISSION_DENIED` — auth failure, file access, API scope | **PROMPT_USER** | Cannot fix permissions programmatically. Report exact permission needed. |
82
+ | `DEPENDENCY_ERROR` — missing package, version conflict, broken dep | **AUTO_FIX** | Install missing dep, resolve version conflict, or suggest alternative package. |
83
+ | `LOGIC_ERROR` — wrong output, incorrect calculation, bad algorithm | **INVESTIGATE** | Do NOT auto-fix. Call `rune:debug` — logic errors need root cause analysis. |
84
+ | `ENVIRONMENT_ERROR` — wrong Node/Python version, missing system dep | **PROMPT_USER** | Report exact version/tool needed. Agent cannot change system environment. |
85
+
86
+ **Decision flow**:
87
+ 1. Read the incoming diagnosis/error
88
+ 2. Classify into one of the 8 error types above
89
+ 3. Apply the recovery action — this determines whether to proceed (AUTO_FIX, RETRY), ask (PROMPT_USER), stop (ABORT), or re-diagnose (INVESTIGATE)
90
+ 4. Announce: "Recovery policy: {error_type} → {action}"
91
+
92
+ **Why**: Without a recovery matrix, fix attempts the same strategy (read → change → test) for every error type. A POLICY_BLOCKED error doesn't need code reading — it needs the policy reported. An INPUT_REQUIRED error doesn't need debugging — it needs a question asked. Matching strategy to error type eliminates wasted cycles.
93
+
71
94
  ### Step 2: Locate
72
95
 
73
96
  Find the exact files and lines to change.
@@ -248,6 +271,28 @@ Fix returns one of four statuses to its caller (cook, debug, review, surgeon). T
248
271
  | Fix Report | Markdown (inline) | Emitted to calling skill (cook, debug, review, surgeon) |
249
272
  | Verification output | Inline (Fix Report) | Lint + types + test results |
250
273
 
274
+ ## Chain Metadata
275
+
276
+ Append to Fix 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`.
277
+
278
+ ```yaml
279
+ chain_metadata:
280
+ skill: "rune:fix"
281
+ version: "0.9.0"
282
+ status: "[DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED]"
283
+ domain: "[area fixed]"
284
+ files_changed:
285
+ - "[list of modified files]"
286
+ exports:
287
+ fix_applied: { files: ["[paths]"], description: "[what was fixed]" }
288
+ verification: { lint: "[PASS/FAIL]", types: "[PASS/FAIL]", tests: "[PASS/FAIL]" }
289
+ commit_hash: "[hash if committed]"
290
+ suggested_next:
291
+ - skill: "rune:test"
292
+ reason: "[grounded in changes — e.g., 'Modified 3 files in auth module, edge cases need coverage']"
293
+ consumes: ["fix_applied", "verification"]
294
+ ```
295
+
251
296
  ## Sharp Edges
252
297
 
253
298
  Known failure modes for this skill. Check these before declaring done.
@@ -264,6 +309,7 @@ Known failure modes for this skill. Check these before declaring done.
264
309
  | Removing debug instrumentation before fix is verified | MEDIUM | Step 5b: preserve `#region agent-debug` markers until all tests pass — premature cleanup erases failure history |
265
310
  | Runaway fix loop — 20+ fixes without checking quality decay | HIGH | Step 4.5: WTF-likelihood self-regulation. >20% risk = STOP. Hard cap 30 fixes/session. Each fix adds risk — diminishing returns after ~15 |
266
311
  | Each fix creates a new bug elsewhere — whack-a-mole | CRITICAL | Tight coupling signal. STOP fixing → escalate to debug with note "each fix creates new failure — suspect structural issue". Debug will route to plan for redesign |
312
+ | Applying same fix strategy to every error type | MEDIUM | Step 1b Recovery Policy Matrix: classify error type FIRST — POLICY_BLOCKED needs reporting not fixing, INPUT_REQUIRED needs questions not code |
267
313
 
268
314
  ## Done When
269
315
 
@@ -0,0 +1,352 @@
1
+ ---
2
+ name: graft
3
+ description: "Clone, port, or convert features from any GitHub repo into your project. Understand before copy, challenge before implement. 4 modes: port (rewrite), compare (analysis), copy (transplant), improve (copy + optimize)."
4
+ metadata:
5
+ author: runedev
6
+ version: "0.1.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: creation
10
+ tools: "Read, Write, Edit, Bash, Glob, Grep, WebFetch"
11
+ emit: graft.complete
12
+ listen: codebase.scanned
13
+ ---
14
+
15
+ # graft
16
+
17
+ ## Purpose
18
+
19
+ External code intelligence — structured workflow for learning from, adapting, and integrating features from any public repository into your project. Graft is NOT a copy-paste tool. It enforces understanding before adoption through a mandatory challenge gate that evaluates license compatibility, stack fit, scope, quality, and maintenance health before any code touches your codebase.
20
+
21
+ <HARD-GATE>
22
+ Challenge gate (Step 4) MUST complete before adaptation planning (Step 5).
23
+ No implementation without confronting trade-offs. This applies to ALL modes except compare.
24
+ Skip only with --fast flag (user accepts full responsibility).
25
+ </HARD-GATE>
26
+
27
+ ## Modes
28
+
29
+ ### Port (default)
30
+ Rewrite the target feature using YOUR stack and patterns. Source code is a reference, not a template. Output is idiomatic to your codebase.
31
+
32
+ **When**: Different tech stack (Vue→React, Django→FastAPI), or source patterns conflict with your conventions.
33
+
34
+ ### Compare
35
+ Side-by-side analysis only. No code changes. Outputs a structured comparison report.
36
+
37
+ **When**: Evaluating whether to adopt a feature, benchmarking your implementation against another, or learning patterns without importing code.
38
+
39
+ ### Copy
40
+ Pure transplant with minimal adaptation. Stays as close to the original as possible — only changes imports, paths, and config to fit your project structure.
41
+
42
+ **When**: Same tech stack, source code is high quality, you want the exact implementation.
43
+
44
+ ### Improve
45
+ Copy the feature, then refactor and optimize. Fix anti-patterns, add missing tests, adapt to your codebase conventions, upgrade deprecated APIs.
46
+
47
+ **When**: Same stack but source has quality issues, or you want the feature but better.
48
+
49
+ ## Speed Options
50
+
51
+ | Flag | Research | Challenge Gate | User Approval |
52
+ |------|----------|---------------|---------------|
53
+ | (default) | ✅ Full | ✅ Yes | ✅ Each step |
54
+ | `--auto` | ✅ Full | ✅ Yes | ❌ Auto-approve |
55
+ | `--fast` | ❌ Skip | ❌ Skip | ❌ Auto-approve |
56
+
57
+ **`--fast` warning**: Skipping challenge gate means no license check, no quality assessment. User accepts full responsibility. Announce: "Fast mode: skipping challenge gate. You are responsible for license and quality review."
58
+
59
+ ## Smart Intent Detection
60
+
61
+ | Input Pattern | Detected Mode |
62
+ |---------------|---------------|
63
+ | Contains "compare", "vs", "diff", "analyze" | compare |
64
+ | Contains "copy", "exact", "as-is", "same" | copy |
65
+ | Contains "improve", "better", "adapt", "upgrade" | improve |
66
+ | Contains "port", "convert", "rewrite", "migrate" | port |
67
+ | URL points to specific file/dir (not repo root) | Auto-scope to that path |
68
+ | (default — no keyword match) | port |
69
+
70
+ ## Triggers
71
+
72
+ - `/rune graft <url> [--port|--compare|--copy|--improve] [--auto|--fast]`
73
+ - Delegated from `cook` when task contains "graft", "port from", "copy from repo", "clone feature from"
74
+ - Auto-trigger: when user pastes a GitHub URL with context like "use this", "like this repo", "steal this"
75
+
76
+ ## Calls (outbound)
77
+
78
+ - `research` (L3): fetch repo README, docs, understand purpose and architecture
79
+ - `scout` (L2): scan LOCAL codebase for conventions, patterns, stack detection
80
+ - `fix` (L2): implement adapted code (port and improve modes)
81
+ - `review` (L2): post-graft quality check (improve mode only)
82
+
83
+ ## Called By (inbound)
84
+
85
+ - User: `/rune graft <url>` direct invocation
86
+ - `cook` (L1): delegation when task is "port feature from external repo"
87
+
88
+ ## Data Flow
89
+
90
+ ### Feeds Into →
91
+
92
+ - `fix` (L2): adaptation plan → fix's implementation targets (port/improve modes)
93
+ - `review` (L2): grafted code → review's analysis targets (improve mode)
94
+ - `test` (L2): new grafted code → test coverage targets
95
+ - `journal` (L3): graft.complete signal → auto-logged for pattern tracking
96
+
97
+ ### Fed By ←
98
+
99
+ - `scout` (L2): local codebase conventions → graft's adaptation strategy
100
+ - `research` (L3): repo analysis → graft's understanding of source architecture
101
+
102
+ ## Executable Steps
103
+
104
+ ### Step 0 — Parse Input
105
+ <MUST-READ path="references/mode-decision.md" trigger="when auto-detecting mode"/>
106
+
107
+ Extract from user input:
108
+ 1. **URL** — GitHub/GitLab/Bitbucket repo or file URL
109
+ 2. **Mode** — explicit flag or auto-detect via intent detection table
110
+ 3. **Speed** — `--auto` or `--fast` if present
111
+ 4. **Scope** — specific dir/file path if URL points to subdirectory, or user specifies "just the auth module"
112
+
113
+ Validate URL is accessible. If private repo or URL fails → suggest raw file URLs or manual paste.
114
+
115
+ ### Step 1 — Fetch & Scope
116
+
117
+ ```bash
118
+ # Sparse clone for large repos (skip if small or specific files)
119
+ git clone --depth 1 --filter=blob:none --sparse <url> /tmp/graft-<hash>
120
+ cd /tmp/graft-<hash>
121
+ git sparse-checkout set <target-dir>
122
+ ```
123
+
124
+ For specific files or small repos: use `WebFetch` on raw GitHub URLs instead of cloning.
125
+
126
+ **Read in this order** (stop when you have enough context):
127
+ 1. README.md — purpose, architecture overview
128
+ 2. Target dir's files — the actual code to graft
129
+ 3. package.json / pyproject.toml / Cargo.toml — dependencies and stack
130
+ 4. Tests for target feature — understand expected behavior
131
+
132
+ **Scope guard**: If target feature spans >15 files or >2000 LOC → WARN user: "Feature is large. Suggest narrowing to [specific module]. Continue anyway?"
133
+
134
+ ### Step 2 — Analyze Source
135
+
136
+ Understand the target feature's architecture:
137
+ - **What it does** — 2-3 sentence summary
138
+ - **How it works** — key patterns, data flow, core logic
139
+ - **Dependencies** — external packages required, internal imports
140
+ - **Stack** — framework, language version, tooling
141
+ - **Quality signals** — has tests? typed? documented? last commit date?
142
+
143
+ Output a brief analysis (not full report — save context for later steps).
144
+
145
+ ### Step 3 — Scan Local Codebase
146
+
147
+ Invoke `rune:scout` (or use cached output if `codebase.scanned` signal received):
148
+ - Local tech stack and version
149
+ - Naming conventions (camelCase vs snake_case, file structure)
150
+ - Existing patterns that overlap with target feature
151
+ - Import style, test framework, state management approach
152
+
153
+ **Stack comparison**: Produce a quick compatibility matrix:
154
+ ```
155
+ | Aspect | Source | Local | Compatible? |
156
+ |--------|--------|-------|-------------|
157
+ | Framework | Next.js 14 | Next.js 15 | ✅ Minor adaptation |
158
+ | Language | TypeScript | TypeScript | ✅ |
159
+ | State | Redux | Zustand | ⚠️ Port needed |
160
+ | Testing | Jest | Vitest | ⚠️ Port needed |
161
+ ```
162
+
163
+ If stack is identical → suggest copy or improve mode (not port).
164
+ If stack differs significantly → force port mode.
165
+
166
+ ### Step 4 — Challenge Gate
167
+ <MUST-READ path="references/challenge-framework.md" trigger="always (unless --fast)"/>
168
+
169
+ <HARD-GATE>
170
+ Score all 5 dimensions. If 2+ dimensions score ❌ → BLOCK graft.
171
+ If 1 dimension scores ❌ → WARN + require explicit user override.
172
+ Only --fast skips this gate entirely.
173
+ </HARD-GATE>
174
+
175
+ Present challenge results to user:
176
+ ```
177
+ ## Challenge Gate Results
178
+
179
+ | Dimension | Score | Detail |
180
+ |-----------|-------|--------|
181
+ | License | ✅ | MIT — compatible |
182
+ | Stack Fit | ⚠️ | Redux → Zustand migration needed |
183
+ | Scope | ✅ | 6 files, ~400 LOC — manageable |
184
+ | Quality | ✅ | Typed, tested, documented |
185
+ | Maintenance | ⚠️ | Last commit 4 months ago |
186
+
187
+ **Verdict: PROCEED with caveats** (0 ❌, 2 ⚠️)
188
+ ```
189
+
190
+ Wait for user approval (unless `--auto`).
191
+
192
+ ### Step 5 — Plan Adaptation
193
+
194
+ Based on mode, produce adaptation plan:
195
+
196
+ **Compare mode** → skip to output. Write comparison report and STOP.
197
+
198
+ **Copy mode** → list files to transplant, import path changes, config adjustments. Minimal changes only.
199
+
200
+ **Port mode** → for each source component, describe the rewrite:
201
+ - Source pattern → local pattern mapping
202
+ - Dependencies to replace (Redux→Zustand, Jest→Vitest)
203
+ - Files to create/modify in local project
204
+ - What to keep vs what to rewrite from scratch
205
+
206
+ **Improve mode** → copy plan + improvement list:
207
+ - Anti-patterns to fix (mutations, any types, missing error handling)
208
+ - Missing tests to add
209
+ - Deprecated APIs to upgrade
210
+ - Convention mismatches to align
211
+
212
+ Present plan to user. Wait for approval (unless `--auto`).
213
+
214
+ ### Step 6 — Execute
215
+
216
+ **Compare mode**: Output report → emit `graft.complete` → done.
217
+
218
+ **Copy/Port/Improve modes**:
219
+ 1. Create/modify files per adaptation plan
220
+ 2. For port/improve: invoke `rune:fix` for complex rewrites
221
+ 3. For improve: invoke `rune:review` on grafted code
222
+ 4. Run project verification (lint, type-check, test if applicable)
223
+ 5. Clean up temp clone dir
224
+
225
+ **Post-execution**: Emit `graft.complete` signal with payload:
226
+ ```yaml
227
+ graft.complete:
228
+ mode: "port|copy|improve|compare"
229
+ source_url: "<url>"
230
+ files_changed: ["src/auth/middleware.ts", "src/auth/types.ts"]
231
+ challenge_score: { license: "pass", stack: "warn", scope: "pass", quality: "pass", maintenance: "warn" }
232
+ ```
233
+
234
+ ## Output Format
235
+
236
+ ### Compare Mode Output
237
+ ```markdown
238
+ ## Graft Comparison: [feature] — [source repo] vs [local]
239
+
240
+ ### Summary
241
+ [2-3 sentences: what was compared, key differences]
242
+
243
+ ### Comparison
244
+ | Aspect | Source | Local | Winner | Notes |
245
+ |--------|--------|-------|--------|-------|
246
+ | [aspect] | [approach] | [approach] | [which] | [why] |
247
+
248
+ ### Recommendations
249
+ - [what to adopt from source]
250
+ - [what to keep from local]
251
+ - [what to graft: specific files/patterns]
252
+ ```
253
+
254
+ ### Port/Copy/Improve Output
255
+ ```markdown
256
+ ## Graft Complete: [feature] from [source]
257
+
258
+ ### Mode: [port|copy|improve]
259
+ ### Files Changed
260
+ - `path/file.ts` — [new|modified] — [what changed]
261
+
262
+ ### Adaptations Made
263
+ - [adaptation 1]
264
+ - [adaptation 2]
265
+
266
+ ### Verify
267
+ - [ ] `npm run lint` passes
268
+ - [ ] `npm run test` passes
269
+ - [ ] Feature works as expected
270
+ ```
271
+
272
+ ## Returns
273
+
274
+ | Field | Type | Description |
275
+ |-------|------|-------------|
276
+ | `mode` | enum | port, compare, copy, improve |
277
+ | `source_url` | string | Source repository URL |
278
+ | `files_changed` | string[] | List of created/modified local files |
279
+ | `challenge_score` | object | 5-dimension scores (pass/warn/fail) |
280
+ | `status` | enum | DONE, DONE_WITH_CONCERNS, BLOCKED |
281
+ | `comparison_report` | string? | Markdown report (compare mode only) |
282
+
283
+ ## Constraints
284
+
285
+ 1. MUST run challenge gate before any code changes — no blind copying
286
+ 2. MUST clean up temp clone directories after completion
287
+ 3. MUST detect and warn about license incompatibility before proceeding
288
+ 4. MUST use sparse checkout for repos >100MB — never full clone large repos
289
+ 5. MUST respect local conventions — grafted code should look native, not foreign
290
+ 6. MUST NOT modify the source repository — read-only access only
291
+ 7. MUST NOT graft without scoping — always narrow to specific feature/module
292
+
293
+ ## Mesh Gates
294
+
295
+ | Gate | Requires | If Missing |
296
+ |------|----------|------------|
297
+ | Challenge Gate | 5-dimension score with 0-1 ❌ | BLOCK if 2+ ❌, WARN if 1 ❌ |
298
+ | Scout Gate | Local codebase scanned | Invoke `rune:scout` first |
299
+ | Scope Gate | Target feature ≤15 files | WARN user, suggest narrowing |
300
+
301
+ ## Sharp Edges
302
+
303
+ | Failure Mode | Severity | Mitigation |
304
+ |---|---|---|
305
+ | Grafting GPL code into MIT project | CRITICAL | Challenge gate checks license — blocks incompatible |
306
+ | Blindly copying code without understanding | CRITICAL | HARD-GATE: challenge before implement |
307
+ | Context overflow from large source files | HIGH | Scope guard: >15 files or >2000 LOC triggers warning |
308
+ | Grafted code doesn't match local conventions | HIGH | Step 3 scans local patterns, Step 5 plans adaptation |
309
+ | Stale source (abandoned repo) | MEDIUM | Maintenance dimension in challenge gate |
310
+ | Private repo URL fails | MEDIUM | Fallback to WebFetch raw URLs or manual paste |
311
+ | Port mode when copy would suffice (wasted effort) | MEDIUM | Mode decision tree suggests optimal mode |
312
+
313
+ ## Self-Validation
314
+
315
+ ```
316
+ SELF-VALIDATION (run before emitting graft.complete):
317
+ - [ ] Challenge gate was executed (or --fast acknowledged)
318
+ - [ ] All grafted files follow local naming conventions
319
+ - [ ] No source-specific imports remain (wrong paths, missing packages)
320
+ - [ ] License compatibility confirmed (or user override documented)
321
+ - [ ] Temp clone directory cleaned up
322
+ - [ ] Grafted code compiles/lints without new errors
323
+ IF ANY check fails → fix before reporting done. Do NOT defer to completion-gate.
324
+ ```
325
+
326
+ ## Cross-cutting Updates
327
+
328
+ If this skill is added to the repo (first time):
329
+ - [ ] `README.md` — skill count (61→62), L2 count (28→29)
330
+ - [ ] `docs/ARCHITECTURE.md` — add graft to L2 list
331
+ - [ ] `CLAUDE.md` — add graft to L2 list, routing table, skill count
332
+ - [ ] `docs/index.html` — update meta stats if applicable
333
+
334
+ ## Done When
335
+
336
+ - Input parsed: URL, mode, speed flags extracted
337
+ - Source fetched and scoped (sparse clone or WebFetch)
338
+ - Source analyzed: patterns, dependencies, stack understood
339
+ - Challenge gate passed (5 dimensions scored, 0-1 ❌)
340
+ - Local codebase scanned for conventions
341
+ - Adaptation plan produced and approved
342
+ - Code grafted per mode (port/copy/improve/compare)
343
+ - Verification passed (lint, type-check, tests)
344
+ - Temp files cleaned up
345
+ - `graft.complete` signal emitted
346
+ - Self-Validation: all checks passed
347
+
348
+ ## Cost Profile
349
+
350
+ ~2000-4000 tokens input (SKILL.md + 1-2 references), ~3000-8000 tokens output (analysis + adaptation + code). Sonnet for execution. Heaviest when port mode rewrites significant code — but that's where the value is highest.
351
+
352
+ **Scope guardrail**: Do not become a general-purpose code review tool. Graft analyzes external code for adoption purposes only — use `rune:review` for reviewing your own code, `rune:research` for general technology research.