@rune-kit/rune 2.1.1

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 (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +357 -0
  3. package/agents/.gitkeep +0 -0
  4. package/agents/architect.md +29 -0
  5. package/agents/asset-creator.md +11 -0
  6. package/agents/audit.md +11 -0
  7. package/agents/autopsy.md +11 -0
  8. package/agents/brainstorm.md +11 -0
  9. package/agents/browser-pilot.md +11 -0
  10. package/agents/coder.md +29 -0
  11. package/agents/completion-gate.md +11 -0
  12. package/agents/constraint-check.md +11 -0
  13. package/agents/context-engine.md +11 -0
  14. package/agents/cook.md +11 -0
  15. package/agents/db.md +11 -0
  16. package/agents/debug.md +11 -0
  17. package/agents/dependency-doctor.md +11 -0
  18. package/agents/deploy.md +11 -0
  19. package/agents/design.md +11 -0
  20. package/agents/docs-seeker.md +11 -0
  21. package/agents/fix.md +11 -0
  22. package/agents/hallucination-guard.md +11 -0
  23. package/agents/incident.md +11 -0
  24. package/agents/integrity-check.md +11 -0
  25. package/agents/journal.md +11 -0
  26. package/agents/launch.md +11 -0
  27. package/agents/logic-guardian.md +11 -0
  28. package/agents/marketing.md +11 -0
  29. package/agents/onboard.md +11 -0
  30. package/agents/perf.md +11 -0
  31. package/agents/plan.md +11 -0
  32. package/agents/preflight.md +11 -0
  33. package/agents/problem-solver.md +11 -0
  34. package/agents/rescue.md +11 -0
  35. package/agents/research.md +11 -0
  36. package/agents/researcher.md +29 -0
  37. package/agents/review-intake.md +11 -0
  38. package/agents/review.md +11 -0
  39. package/agents/reviewer.md +28 -0
  40. package/agents/safeguard.md +11 -0
  41. package/agents/sast.md +11 -0
  42. package/agents/scanner.md +28 -0
  43. package/agents/scope-guard.md +11 -0
  44. package/agents/scout.md +11 -0
  45. package/agents/sentinel.md +11 -0
  46. package/agents/sequential-thinking.md +11 -0
  47. package/agents/session-bridge.md +11 -0
  48. package/agents/skill-forge.md +11 -0
  49. package/agents/skill-router.md +11 -0
  50. package/agents/surgeon.md +11 -0
  51. package/agents/team.md +11 -0
  52. package/agents/test.md +11 -0
  53. package/agents/trend-scout.md +11 -0
  54. package/agents/verification.md +11 -0
  55. package/agents/video-creator.md +11 -0
  56. package/agents/watchdog.md +11 -0
  57. package/agents/worktree.md +11 -0
  58. package/commands/.gitkeep +0 -0
  59. package/commands/rune.md +168 -0
  60. package/compiler/__tests__/openclaw-adapter.test.js +140 -0
  61. package/compiler/__tests__/parser.test.js +55 -0
  62. package/compiler/adapters/antigravity.js +59 -0
  63. package/compiler/adapters/claude.js +37 -0
  64. package/compiler/adapters/cursor.js +67 -0
  65. package/compiler/adapters/generic.js +60 -0
  66. package/compiler/adapters/index.js +45 -0
  67. package/compiler/adapters/openclaw.js +150 -0
  68. package/compiler/adapters/windsurf.js +60 -0
  69. package/compiler/bin/rune.js +288 -0
  70. package/compiler/doctor.js +153 -0
  71. package/compiler/emitter.js +240 -0
  72. package/compiler/parser.js +208 -0
  73. package/compiler/transformer.js +69 -0
  74. package/compiler/transforms/branding.js +27 -0
  75. package/compiler/transforms/cross-references.js +29 -0
  76. package/compiler/transforms/frontmatter.js +38 -0
  77. package/compiler/transforms/hooks.js +68 -0
  78. package/compiler/transforms/subagents.js +36 -0
  79. package/compiler/transforms/tool-names.js +60 -0
  80. package/contexts/dev.md +34 -0
  81. package/contexts/research.md +43 -0
  82. package/contexts/review.md +55 -0
  83. package/extensions/ai-ml/PACK.md +517 -0
  84. package/extensions/analytics/PACK.md +557 -0
  85. package/extensions/backend/PACK.md +678 -0
  86. package/extensions/chrome-ext/PACK.md +995 -0
  87. package/extensions/content/PACK.md +381 -0
  88. package/extensions/devops/PACK.md +520 -0
  89. package/extensions/ecommerce/PACK.md +280 -0
  90. package/extensions/gamedev/PACK.md +393 -0
  91. package/extensions/mobile/PACK.md +273 -0
  92. package/extensions/saas/PACK.md +805 -0
  93. package/extensions/security/PACK.md +536 -0
  94. package/extensions/trading/PACK.md +597 -0
  95. package/extensions/ui/PACK.md +947 -0
  96. package/package.json +47 -0
  97. package/skills/.gitkeep +0 -0
  98. package/skills/adversary/SKILL.md +271 -0
  99. package/skills/asset-creator/SKILL.md +157 -0
  100. package/skills/audit/SKILL.md +466 -0
  101. package/skills/autopsy/SKILL.md +200 -0
  102. package/skills/ba/SKILL.md +279 -0
  103. package/skills/brainstorm/SKILL.md +266 -0
  104. package/skills/browser-pilot/SKILL.md +168 -0
  105. package/skills/completion-gate/SKILL.md +151 -0
  106. package/skills/constraint-check/SKILL.md +165 -0
  107. package/skills/context-engine/SKILL.md +176 -0
  108. package/skills/cook/SKILL.md +636 -0
  109. package/skills/db/SKILL.md +256 -0
  110. package/skills/debug/SKILL.md +240 -0
  111. package/skills/dependency-doctor/SKILL.md +235 -0
  112. package/skills/deploy/SKILL.md +174 -0
  113. package/skills/design/DESIGN-REFERENCE.md +365 -0
  114. package/skills/design/SKILL.md +462 -0
  115. package/skills/doc-processor/SKILL.md +254 -0
  116. package/skills/docs/SKILL.md +336 -0
  117. package/skills/docs-seeker/SKILL.md +166 -0
  118. package/skills/fix/SKILL.md +192 -0
  119. package/skills/git/SKILL.md +285 -0
  120. package/skills/hallucination-guard/SKILL.md +204 -0
  121. package/skills/incident/SKILL.md +241 -0
  122. package/skills/integrity-check/SKILL.md +169 -0
  123. package/skills/journal/SKILL.md +190 -0
  124. package/skills/launch/SKILL.md +330 -0
  125. package/skills/logic-guardian/SKILL.md +240 -0
  126. package/skills/marketing/SKILL.md +229 -0
  127. package/skills/mcp-builder/SKILL.md +311 -0
  128. package/skills/onboard/SKILL.md +298 -0
  129. package/skills/perf/SKILL.md +297 -0
  130. package/skills/plan/SKILL.md +520 -0
  131. package/skills/preflight/SKILL.md +231 -0
  132. package/skills/problem-solver/SKILL.md +284 -0
  133. package/skills/rescue/SKILL.md +434 -0
  134. package/skills/research/SKILL.md +122 -0
  135. package/skills/review/SKILL.md +354 -0
  136. package/skills/review-intake/SKILL.md +222 -0
  137. package/skills/safeguard/SKILL.md +188 -0
  138. package/skills/sast/SKILL.md +190 -0
  139. package/skills/scaffold/SKILL.md +276 -0
  140. package/skills/scope-guard/SKILL.md +150 -0
  141. package/skills/scout/SKILL.md +232 -0
  142. package/skills/sentinel/SKILL.md +320 -0
  143. package/skills/sentinel-env/SKILL.md +226 -0
  144. package/skills/sequential-thinking/SKILL.md +234 -0
  145. package/skills/session-bridge/SKILL.md +287 -0
  146. package/skills/skill-forge/SKILL.md +317 -0
  147. package/skills/skill-router/SKILL.md +267 -0
  148. package/skills/surgeon/SKILL.md +203 -0
  149. package/skills/team/SKILL.md +397 -0
  150. package/skills/test/SKILL.md +271 -0
  151. package/skills/trend-scout/SKILL.md +145 -0
  152. package/skills/verification/SKILL.md +201 -0
  153. package/skills/video-creator/SKILL.md +201 -0
  154. package/skills/watchdog/SKILL.md +166 -0
  155. package/skills/worktree/SKILL.md +140 -0
@@ -0,0 +1,297 @@
1
+ ---
2
+ name: perf
3
+ description: Performance regression gate. Detects N+1 queries, sync-in-async, missing indexes, memory leaks, and bundle bloat before they reach production.
4
+ metadata:
5
+ author: runedev
6
+ version: "0.1.0"
7
+ layer: L2
8
+ model: sonnet
9
+ group: quality
10
+ tools: "Read, Bash, Glob, Grep"
11
+ ---
12
+
13
+ # perf
14
+
15
+ ## Purpose
16
+
17
+ Performance regression gate. Analyzes code changes for patterns that cause measurable slowdowns — N+1 queries, sync operations in async handlers, unbounded DB queries, missing indexes, memory leaks, and bundle bloat. Not a profiler — a gate. Finds performance bugs with measurable/estimated impact before production, so developers fix them at the cheapest point in the cycle.
18
+
19
+ ## Triggers
20
+
21
+ - `/rune perf` — manual invocation before commit
22
+ - Called by `cook` (L1): Phase 5 quality gate
23
+ - Called by `review` (L2): performance patterns detected in diff
24
+ - Called by `deploy` (L2): pre-deploy regression check
25
+ - Called by `audit` (L2): performance health dimension
26
+
27
+ ## Calls (outbound)
28
+
29
+ - `scout` (L2): find hotpath files and identify framework in use
30
+ - `browser-pilot` (L3): run Lighthouse / Core Web Vitals for frontend projects
31
+ - `verification` (L3): run benchmark scripts if configured (e.g. `npm run bench`)
32
+ - `design` (L2): when Lighthouse Accessibility BLOCK — design system may lack a11y foundation
33
+
34
+ ## Called By (inbound)
35
+
36
+ - `cook` (L1): Phase 5 quality gate before PR
37
+ - `audit` (L2): performance dimension delegation
38
+ - `review` (L2): performance patterns detected in diff
39
+ - `deploy` (L2): pre-deploy perf regression check
40
+
41
+ ## Executable Steps
42
+
43
+ ### Step 1 — Scope
44
+
45
+ Determine what to analyze:
46
+ - If called with a file list or diff → analyze those files only
47
+ - If called standalone → invoke `scout` to identify top 10 hotpath files (entry points, routes, DB access layers, render-heavy components)
48
+ - Detect project type: **frontend** (React/Vue/Svelte) | **backend** (Node/Python/Go) | **fullstack** | **CLI**
49
+
50
+ ### Step 2 — DB Query Patterns
51
+
52
+ Scan all in-scope files for:
53
+
54
+ **N+1 pattern** — loop containing ORM call:
55
+ ```
56
+ # BAD: N+1
57
+ for user in users:
58
+ orders = Order.objects.filter(user=user) # N queries
59
+
60
+ # GOOD: prefetch
61
+ users = User.objects.prefetch_related('orders').all()
62
+ ```
63
+ Finding: `N+1 DETECTED — [file:line] — loop over [collection] with [ORM call] inside — use prefetch/JOIN`
64
+
65
+ **Unbounded query** — no LIMIT/pagination:
66
+ ```
67
+ # BAD
68
+ db.query("SELECT * FROM events")
69
+
70
+ # GOOD
71
+ db.query("SELECT * FROM events LIMIT 100 OFFSET ?", [offset])
72
+ ```
73
+ Finding: `UNBOUNDED_QUERY — [file:line] — missing LIMIT on [table] — add pagination`
74
+
75
+ **SELECT \*** — fetching all columns when only some are needed:
76
+ Finding: `SELECT_STAR — [file:line] — select only needed columns`
77
+
78
+ ### Step 3 — Async/Sync Violations
79
+
80
+ Scan for synchronous operations in async contexts:
81
+
82
+ **Blocking I/O in async handler:**
83
+ ```javascript
84
+ // BAD: blocks event loop
85
+ async function handler(req) {
86
+ const data = fs.readFileSync('./config.json')
87
+ }
88
+
89
+ // GOOD
90
+ async function handler(req) {
91
+ const data = await fs.promises.readFile('./config.json')
92
+ }
93
+ ```
94
+ Finding: `SYNC_IN_ASYNC — [file:line] — [readFileSync|execSync|etc] in async function — blocks event loop`
95
+
96
+ **Missing await:**
97
+ ```javascript
98
+ // BAD: fire-and-forget
99
+ async function save() {
100
+ db.insert(record) // no await
101
+ }
102
+ ```
103
+ Finding: `MISSING_AWAIT — [file:line] — unresolved Promise may cause race condition`
104
+
105
+ ### Step 4 — Memory Leak Patterns
106
+
107
+ Scan for:
108
+
109
+ **Event listener without cleanup:**
110
+ ```javascript
111
+ // BAD: leak in React
112
+ useEffect(() => {
113
+ window.addEventListener('resize', handler)
114
+ // missing return cleanup
115
+ })
116
+
117
+ // GOOD
118
+ useEffect(() => {
119
+ window.addEventListener('resize', handler)
120
+ return () => window.removeEventListener('resize', handler)
121
+ }, [])
122
+ ```
123
+ Finding: `MEMORY_LEAK — [file:line] — addEventListener without cleanup in useEffect`
124
+
125
+ **Growing collection without eviction:**
126
+ ```python
127
+ # BAD: unbounded cache
128
+ cache = {}
129
+ def get(key):
130
+ if key not in cache:
131
+ cache[key] = expensive_compute(key)
132
+ return cache[key]
133
+ ```
134
+ Finding: `UNBOUNDED_CACHE — [file:line] — dict grows indefinitely — add LRU eviction or TTL`
135
+
136
+ ### Step 5 — Bundle Analysis (frontend only)
137
+
138
+ If project type is frontend:
139
+ - Check for large direct imports that block tree-shaking:
140
+ ```javascript
141
+ // BAD: imports entire lodash
142
+ import _ from 'lodash'
143
+ // GOOD: named import
144
+ import { debounce } from 'lodash'
145
+ ```
146
+ Finding: `BUNDLE_BLOAT — [file:line] — default import of [library] prevents tree-shaking`
147
+ - Check for missing React.memo / useMemo on expensive renders
148
+ - Check for component definitions inside render (recreated every render)
149
+
150
+ If `browser-pilot` is available and project has a URL: invoke it for Lighthouse score.
151
+
152
+ **Lighthouse Score Gates** (apply to any project with a public URL):
153
+
154
+ ```
155
+ Performance: ≥ 90 → PASS | 70–89 → WARN | < 70 → BLOCK
156
+ Accessibility: ≥ 95 → PASS | 80–94 → WARN | < 80 → BLOCK
157
+ Best Practices: ≥ 90 → PASS | < 90 → WARN
158
+ SEO: ≥ 80 → PASS | < 80 → WARN (public-facing pages only)
159
+ ```
160
+
161
+ **Core Web Vitals thresholds:**
162
+ ```
163
+ LCP (Largest Contentful Paint):
164
+ ≤ 2.5s → PASS | 2.5–4s → WARN | > 4s → BLOCK
165
+
166
+ INP (Interaction to Next Paint, replaces FID):
167
+ ≤ 200ms → PASS | 200–500ms → WARN | > 500ms → BLOCK
168
+
169
+ CLS (Cumulative Layout Shift):
170
+ ≤ 0.1 → PASS | 0.1–0.25 → WARN | > 0.25 → BLOCK
171
+ ```
172
+
173
+ <HARD-GATE>
174
+ Lighthouse Accessibility score < 80 = BLOCK regardless of other scores.
175
+ Accessibility regressions are legal liability and cannot be auto-fixed by the AI.
176
+ Do NOT downgrade this gate.
177
+ </HARD-GATE>
178
+
179
+ If no URL available (dev-only environment): log `INFO: no URL for Lighthouse — run manually before deploy`
180
+ If Lighthouse MCP not installed: log `INFO: Lighthouse MCP not available — run lighthouse [url] --output json manually`
181
+
182
+ ### Step 6 — Framework-Specific Checks
183
+
184
+ **React:**
185
+ - `useEffect` without dependency array → runs every render
186
+ - Expensive computation directly in render (not wrapped in useMemo)
187
+ - Component created inside another component body
188
+
189
+ **Node.js / Express:**
190
+ - `require()` calls inside route handlers (should be top-level)
191
+ - Missing connection pool config (default pool size = 1 on some ORMs)
192
+ - Synchronous crypto operations (use `crypto.subtle` async API)
193
+
194
+ **Python / Django:**
195
+ - Missing `select_related` / `prefetch_related` on ForeignKey traversal
196
+ - `len(queryset)` instead of `queryset.count()` (loads all rows)
197
+ - Celery tasks without `bind=True` retried without backoff
198
+
199
+ **SQL:**
200
+ - JOIN without index on join column
201
+ - WHERE on non-indexed column in large table
202
+ - Cartesian product (missing JOIN condition)
203
+
204
+ ### Step 7 — Benchmark Execution
205
+
206
+ If project has benchmark scripts (detected via `package.json` scripts, `Makefile`, or `pytest-benchmark`):
207
+ - Invoke `verification` to run them
208
+ - Compare output to baseline if `.perf-baseline.json` exists
209
+
210
+ If no benchmarks configured: log `INFO: no benchmark scripts found — skipping`
211
+
212
+ ### Step 8 — Report
213
+
214
+ Emit structured report:
215
+
216
+ ```
217
+ ## Perf Report: [scope]
218
+
219
+ ### BLOCK (must fix before merge)
220
+ - [FINDING_TYPE] [file:line] — [description] — estimated impact: [Xms|X% bundle|X queries]
221
+
222
+ ### WARN (should fix)
223
+ - [FINDING_TYPE] [file:line] — [description] — estimated impact: [...]
224
+
225
+ ### PASS
226
+ - DB query patterns: clean
227
+ - Async/sync violations: none
228
+ - [etc.]
229
+
230
+ ### Lighthouse (if ran)
231
+ - Performance: [score] [PASS|WARN|BLOCK]
232
+ - Accessibility: [score] [PASS|WARN|BLOCK]
233
+ - Best Practices: [score] [PASS|WARN]
234
+ - SEO: [score] [PASS|WARN]
235
+ - LCP: [Xs] [PASS|WARN|BLOCK] | INP: [Xms] [PASS|WARN|BLOCK] | CLS: [X] [PASS|WARN|BLOCK]
236
+
237
+ ### Verdict: PASS | WARN | BLOCK
238
+ ```
239
+
240
+ ## Output Format
241
+
242
+ ```
243
+ ## Perf Report: src/api/users.ts, src/db/queries.ts
244
+
245
+ ### BLOCK
246
+ - N+1_QUERY src/db/queries.ts:47 — loop over users with Order.find() inside — fix: use JOIN or prefetch — estimated: +200ms per 100 users
247
+
248
+ ### WARN
249
+ - SYNC_IN_ASYNC src/api/users.ts:23 — readFileSync in async handler — fix: fs.promises.readFile
250
+
251
+ ### PASS
252
+ - Memory leak patterns: clean
253
+ - Bundle analysis: N/A (backend project)
254
+
255
+ ### Verdict: BLOCK
256
+ ```
257
+
258
+ ## Constraints
259
+
260
+ 1. MUST cite file:line for every finding — "might be slow" without evidence is not a finding
261
+ 2. MUST include estimated impact — impact-free findings are noise
262
+ 3. MUST NOT fix code — perf investigates only, never edits files
263
+ 4. MUST distinguish BLOCK (blocks merge) from WARN (should fix but doesn't block)
264
+ 5. MUST run framework-specific checks for detected framework — not just generic patterns
265
+
266
+ ## Mesh Gates (L1/L2 only)
267
+
268
+ | Gate | Requires | If Missing |
269
+ |------|----------|------------|
270
+ | Scope Gate | File list or scout result before scanning | Invoke scout to identify hotpath files |
271
+ | Evidence Gate | file:line + estimated impact for every BLOCK finding | Downgrade to WARN or remove finding |
272
+ | Framework Gate | Framework detected before framework-specific checks | Fall back to generic patterns only |
273
+
274
+ ## Sharp Edges
275
+
276
+ Known failure modes for this skill. Check these before declaring done.
277
+
278
+ | Failure Mode | Severity | Mitigation |
279
+ |---|---|---|
280
+ | BLOCK finding without impact estimate | HIGH | Every BLOCK needs "estimated impact: X" — evidence gate enforces this |
281
+ | False N+1 on intentional batched loops | MEDIUM | Check if loop has a `batch_size` limiter or is already prefetched upstream |
282
+ | Skipping framework checks because framework not detected | MEDIUM | If scout returns unknown framework, run generic checks + note in report |
283
+ | Calling browser-pilot on backend-only project | LOW | Check project type in Step 1 — browser-pilot only for frontend/fullstack |
284
+ | Reporting WARN as BLOCK (severity inflation) | MEDIUM | BLOCK = measurable regression on hot path; WARN = pattern that could be slow |
285
+
286
+ ## Done When
287
+
288
+ - All in-scope files analyzed for DB patterns, async/sync violations, memory leaks
289
+ - Framework-specific checks applied for detected framework
290
+ - Every finding has file:line + estimated impact
291
+ - Bundle analysis ran (frontend) or skipped with reason (backend)
292
+ - Benchmark scripts ran (if configured) or INFO: skipped
293
+ - Perf Report emitted with PASS/WARN/BLOCK verdict
294
+
295
+ ## Cost Profile
296
+
297
+ ~3000-8000 tokens input, ~500-1500 tokens output. Sonnet for pattern recognition.