@rune-kit/rune 2.10.0 → 2.12.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 (240) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -6
  3. package/commands/rune.md +168 -168
  4. package/compiler/__tests__/detect-invariants.test.js +136 -0
  5. package/compiler/__tests__/doctor-mesh.test.js +229 -0
  6. package/compiler/__tests__/hook-dispatch.test.js +91 -0
  7. package/compiler/__tests__/hooks-antigravity.test.js +118 -0
  8. package/compiler/__tests__/hooks-cursor.test.js +139 -0
  9. package/compiler/__tests__/hooks-install.test.js +305 -0
  10. package/compiler/__tests__/hooks-merge.test.js +204 -0
  11. package/compiler/__tests__/hooks-tiers.test.js +519 -0
  12. package/compiler/__tests__/hooks-windsurf.test.js +115 -0
  13. package/compiler/__tests__/inject-claude-md.test.js +152 -0
  14. package/compiler/__tests__/load-invariants.test.js +408 -0
  15. package/compiler/__tests__/onboard-invariants.test.js +240 -0
  16. package/compiler/adapters/hooks/antigravity.js +140 -0
  17. package/compiler/adapters/hooks/claude.js +166 -0
  18. package/compiler/adapters/hooks/cursor.js +191 -0
  19. package/compiler/adapters/hooks/index.js +82 -0
  20. package/compiler/adapters/hooks/tier-emitter.js +182 -0
  21. package/compiler/adapters/hooks/windsurf.js +202 -0
  22. package/compiler/bin/rune.js +196 -6
  23. package/compiler/commands/hook-dispatch.js +87 -0
  24. package/compiler/commands/hooks/install.js +120 -0
  25. package/compiler/commands/hooks/merge.js +211 -0
  26. package/compiler/commands/hooks/presets.js +116 -0
  27. package/compiler/commands/hooks/status.js +112 -0
  28. package/compiler/commands/hooks/tiers.js +221 -0
  29. package/compiler/commands/hooks/uninstall.js +94 -0
  30. package/compiler/doctor.js +236 -0
  31. package/contexts/dev.md +34 -34
  32. package/contexts/research.md +43 -43
  33. package/contexts/review.md +55 -55
  34. package/extensions/ai-ml/PACK.md +88 -88
  35. package/extensions/ai-ml/skills/ai-agents.md +172 -172
  36. package/extensions/ai-ml/skills/code-sandbox.md +187 -187
  37. package/extensions/ai-ml/skills/deep-research.md +146 -146
  38. package/extensions/ai-ml/skills/embedding-search.md +66 -66
  39. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -74
  40. package/extensions/ai-ml/skills/llm-architect.md +125 -125
  41. package/extensions/ai-ml/skills/llm-integration.md +64 -64
  42. package/extensions/ai-ml/skills/prompt-patterns.md +72 -72
  43. package/extensions/ai-ml/skills/rag-patterns.md +66 -66
  44. package/extensions/ai-ml/skills/web-extraction.md +114 -114
  45. package/extensions/analytics/PACK.md +92 -92
  46. package/extensions/analytics/skills/ab-testing.md +72 -72
  47. package/extensions/analytics/skills/dashboard-patterns.md +83 -83
  48. package/extensions/analytics/skills/data-validation.md +68 -68
  49. package/extensions/analytics/skills/funnel-analysis.md +81 -81
  50. package/extensions/analytics/skills/sql-patterns.md +57 -57
  51. package/extensions/analytics/skills/statistical-analysis.md +79 -79
  52. package/extensions/analytics/skills/tracking-setup.md +71 -71
  53. package/extensions/backend/PACK.md +104 -104
  54. package/extensions/backend/skills/api-patterns.md +84 -84
  55. package/extensions/backend/skills/async-pipeline.md +193 -193
  56. package/extensions/backend/skills/auth-patterns.md +97 -97
  57. package/extensions/backend/skills/background-jobs.md +133 -133
  58. package/extensions/backend/skills/caching-patterns.md +108 -108
  59. package/extensions/backend/skills/cli-generation.md +133 -133
  60. package/extensions/backend/skills/database-patterns.md +87 -87
  61. package/extensions/backend/skills/middleware-patterns.md +104 -104
  62. package/extensions/chrome-ext/PACK.md +93 -93
  63. package/extensions/chrome-ext/skills/cws-preflight.md +143 -143
  64. package/extensions/chrome-ext/skills/cws-publish.md +104 -104
  65. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -251
  66. package/extensions/chrome-ext/skills/ext-messaging.md +139 -139
  67. package/extensions/chrome-ext/skills/ext-storage.md +133 -133
  68. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -164
  69. package/extensions/content/PACK.md +96 -96
  70. package/extensions/content/skills/blog-patterns.md +88 -88
  71. package/extensions/content/skills/cms-integration.md +131 -131
  72. package/extensions/content/skills/content-scoring.md +107 -107
  73. package/extensions/content/skills/i18n.md +83 -83
  74. package/extensions/content/skills/mdx-authoring.md +137 -137
  75. package/extensions/content/skills/reference.md +1014 -1014
  76. package/extensions/content/skills/seo-patterns.md +67 -67
  77. package/extensions/content/skills/video-repurpose.md +153 -153
  78. package/extensions/devops/PACK.md +101 -101
  79. package/extensions/devops/skills/chaos-testing.md +67 -67
  80. package/extensions/devops/skills/ci-cd.md +75 -75
  81. package/extensions/devops/skills/docker.md +58 -58
  82. package/extensions/devops/skills/edge-serverless.md +163 -163
  83. package/extensions/devops/skills/infra-as-code.md +158 -158
  84. package/extensions/devops/skills/kubernetes.md +110 -110
  85. package/extensions/devops/skills/monitoring.md +57 -57
  86. package/extensions/devops/skills/server-setup.md +64 -64
  87. package/extensions/devops/skills/ssl-domain.md +42 -42
  88. package/extensions/ecommerce/PACK.md +116 -116
  89. package/extensions/ecommerce/skills/cart-system.md +79 -79
  90. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -102
  91. package/extensions/ecommerce/skills/order-management.md +126 -126
  92. package/extensions/ecommerce/skills/payment-integration.md +472 -472
  93. package/extensions/ecommerce/skills/shopify-dev.md +69 -69
  94. package/extensions/ecommerce/skills/subscription-billing.md +93 -93
  95. package/extensions/ecommerce/skills/tax-compliance.md +117 -117
  96. package/extensions/gamedev/PACK.md +142 -142
  97. package/extensions/gamedev/skills/asset-pipeline.md +74 -74
  98. package/extensions/gamedev/skills/audio-system.md +129 -129
  99. package/extensions/gamedev/skills/camera-system.md +87 -87
  100. package/extensions/gamedev/skills/ecs.md +98 -98
  101. package/extensions/gamedev/skills/game-loops.md +72 -72
  102. package/extensions/gamedev/skills/input-system.md +199 -199
  103. package/extensions/gamedev/skills/multiplayer.md +180 -180
  104. package/extensions/gamedev/skills/particles.md +105 -105
  105. package/extensions/gamedev/skills/physics-engine.md +89 -89
  106. package/extensions/gamedev/skills/scene-management.md +146 -146
  107. package/extensions/gamedev/skills/threejs-patterns.md +90 -90
  108. package/extensions/gamedev/skills/webgl.md +71 -71
  109. package/extensions/mobile/PACK.md +106 -106
  110. package/extensions/mobile/skills/app-store-connect.md +152 -152
  111. package/extensions/mobile/skills/app-store-prep.md +66 -66
  112. package/extensions/mobile/skills/deep-linking.md +109 -109
  113. package/extensions/mobile/skills/flutter.md +60 -60
  114. package/extensions/mobile/skills/ios-build-pipeline.md +142 -142
  115. package/extensions/mobile/skills/native-bridge.md +66 -66
  116. package/extensions/mobile/skills/ota-updates.md +97 -97
  117. package/extensions/mobile/skills/push-notifications.md +111 -111
  118. package/extensions/mobile/skills/react-native.md +82 -82
  119. package/extensions/saas/PACK.md +116 -116
  120. package/extensions/saas/skills/billing-integration.md +200 -200
  121. package/extensions/saas/skills/feature-flags.md +130 -130
  122. package/extensions/saas/skills/multi-tenant.md +103 -103
  123. package/extensions/saas/skills/onboarding-flow.md +139 -139
  124. package/extensions/saas/skills/subscription-flow.md +95 -95
  125. package/extensions/saas/skills/team-management.md +144 -144
  126. package/extensions/security/PACK.md +99 -99
  127. package/extensions/security/skills/api-security.md +140 -140
  128. package/extensions/security/skills/compliance.md +68 -68
  129. package/extensions/security/skills/owasp-audit.md +64 -64
  130. package/extensions/security/skills/pentest-patterns.md +77 -77
  131. package/extensions/security/skills/secret-mgmt.md +65 -65
  132. package/extensions/security/skills/supply-chain.md +65 -65
  133. package/extensions/trading/PACK.md +80 -80
  134. package/extensions/trading/skills/chart-components.md +55 -55
  135. package/extensions/trading/skills/experiment-loop.md +125 -125
  136. package/extensions/trading/skills/fintech-patterns.md +47 -47
  137. package/extensions/trading/skills/indicator-library.md +58 -58
  138. package/extensions/trading/skills/quant-analysis.md +111 -111
  139. package/extensions/trading/skills/realtime-data.md +58 -58
  140. package/extensions/trading/skills/trade-logic.md +104 -104
  141. package/extensions/ui/PACK.md +130 -130
  142. package/extensions/ui/skills/a11y-audit.md +91 -91
  143. package/extensions/ui/skills/animation-patterns.md +127 -127
  144. package/extensions/ui/skills/component-patterns.md +100 -100
  145. package/extensions/ui/skills/design-decision.md +108 -108
  146. package/extensions/ui/skills/design-system.md +68 -68
  147. package/extensions/ui/skills/landing-patterns.md +155 -155
  148. package/extensions/ui/skills/palette-picker.md +173 -173
  149. package/extensions/ui/skills/react-health.md +90 -90
  150. package/extensions/ui/skills/type-system.md +125 -125
  151. package/extensions/ui/skills/web-vitals.md +153 -153
  152. package/extensions/zalo/PACK.md +145 -145
  153. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -317
  154. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -429
  155. package/extensions/zalo/skills/zalo-oa-setup.md +236 -236
  156. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -189
  157. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -194
  158. package/extensions/zalo/skills/zalo-personal-setup.md +153 -153
  159. package/extensions/zalo/skills/zalo-rate-guard.md +219 -219
  160. package/hooks/auto-format/index.cjs +48 -48
  161. package/hooks/hooks.json +111 -111
  162. package/hooks/post-session-reflect/index.cjs +189 -189
  163. package/hooks/pre-compact/index.cjs +95 -95
  164. package/hooks/run-hook.cmd +1 -1
  165. package/hooks/secrets-scan/index.cjs +100 -100
  166. package/hooks/session-start/index.cjs +71 -71
  167. package/hooks/typecheck/index.cjs +65 -65
  168. package/package.json +63 -63
  169. package/references/ui-pro-max-data/LICENSE-UI-PRO-MAX +21 -21
  170. package/references/ui-pro-max-data/charts.csv +26 -26
  171. package/references/ui-pro-max-data/colors.csv +161 -161
  172. package/references/ui-pro-max-data/styles.csv +68 -68
  173. package/references/ui-pro-max-data/typography.csv +74 -74
  174. package/references/ui-pro-max-data/ui-reasoning.csv +162 -162
  175. package/references/ui-pro-max-data/ux-guidelines.csv +99 -99
  176. package/skills/adversary/SKILL.md +283 -283
  177. package/skills/asset-creator/SKILL.md +157 -157
  178. package/skills/audit/SKILL.md +147 -2
  179. package/skills/autopsy/SKILL.md +335 -335
  180. package/skills/ba/SKILL.md +85 -1
  181. package/skills/brainstorm/SKILL.md +380 -342
  182. package/skills/browser-pilot/SKILL.md +169 -168
  183. package/skills/constraint-check/SKILL.md +165 -165
  184. package/skills/context-engine/SKILL.md +408 -404
  185. package/skills/cook/SKILL.md +917 -863
  186. package/skills/db/SKILL.md +273 -273
  187. package/skills/debug/SKILL.md +465 -465
  188. package/skills/dependency-doctor/SKILL.md +265 -235
  189. package/skills/deploy/SKILL.md +274 -231
  190. package/skills/design/DESIGN-REFERENCE.md +365 -365
  191. package/skills/design/SKILL.md +590 -589
  192. package/skills/doc-processor/SKILL.md +254 -254
  193. package/skills/docs/SKILL.md +374 -374
  194. package/skills/docs-seeker/SKILL.md +178 -177
  195. package/skills/fix/SKILL.md +332 -330
  196. package/skills/git/SKILL.md +339 -339
  197. package/skills/hallucination-guard/SKILL.md +220 -219
  198. package/skills/incident/SKILL.md +254 -253
  199. package/skills/integrity-check/SKILL.md +169 -169
  200. package/skills/journal/SKILL.md +241 -240
  201. package/skills/launch/SKILL.md +344 -344
  202. package/skills/logic-guardian/SKILL.md +269 -251
  203. package/skills/marketing/SKILL.md +351 -289
  204. package/skills/mcp-builder/SKILL.md +425 -425
  205. package/skills/neural-memory/SKILL.md +359 -362
  206. package/skills/onboard/SKILL.md +432 -403
  207. package/skills/onboard/references/invariants-template.md +76 -0
  208. package/skills/onboard/scripts/detect-invariants.js +439 -0
  209. package/skills/onboard/scripts/inject-claude-md.js +150 -0
  210. package/skills/onboard/scripts/onboard-invariants.js +194 -0
  211. package/skills/perf/SKILL.md +347 -346
  212. package/skills/plan/SKILL.md +435 -428
  213. package/skills/preflight/SKILL.md +415 -415
  214. package/skills/problem-solver/SKILL.md +380 -284
  215. package/skills/rescue/SKILL.md +474 -474
  216. package/skills/research/SKILL.md +4 -0
  217. package/skills/retro/SKILL.md +3 -1
  218. package/skills/review/SKILL.md +614 -588
  219. package/skills/review-intake/SKILL.md +249 -249
  220. package/skills/safeguard/SKILL.md +200 -200
  221. package/skills/sast/SKILL.md +190 -190
  222. package/skills/scaffold/SKILL.md +328 -287
  223. package/skills/scope-guard/SKILL.md +183 -180
  224. package/skills/scout/SKILL.md +269 -263
  225. package/skills/sentinel/SKILL.md +384 -381
  226. package/skills/sentinel-env/SKILL.md +254 -254
  227. package/skills/sequential-thinking/SKILL.md +234 -234
  228. package/skills/session-bridge/SKILL.md +595 -543
  229. package/skills/session-bridge/scripts/load-invariants.js +397 -0
  230. package/skills/skill-forge/SKILL.md +581 -581
  231. package/skills/skill-router/SKILL.md +3 -0
  232. package/skills/slides/SKILL.md +19 -0
  233. package/skills/surgeon/SKILL.md +215 -215
  234. package/skills/team/SKILL.md +557 -537
  235. package/skills/test/SKILL.md +620 -614
  236. package/skills/trend-scout/SKILL.md +145 -145
  237. package/skills/verification/SKILL.md +334 -326
  238. package/skills/video-creator/SKILL.md +201 -201
  239. package/skills/watchdog/SKILL.md +168 -168
  240. package/skills/worktree/SKILL.md +140 -140
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Rune Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rune Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -83,14 +83,27 @@ _Methodology: Claude Code CLI headless mode (`claude -p --output-format json`),
83
83
 
84
84
  ---
85
85
 
86
- ## What's New (v2.10.0)
86
+ ## What's New (v2.12.0 — Auto-Discipline)
87
87
 
88
- - **graft skill** (NEW L2) port features from external repos with 5-dimension challenge gate (License, Stack Fit, Scope, Quality, Maintenance)
89
- - **plan v1.4.0** — Feature Map system: auto-maintained `.rune/features.md` for cross-feature awareness and gap detection
90
- - **Mesh Signals v2** — 23 active signals, 14 mesh gaps fixed, signal dispatch ordering documented
91
- - **62 skills, 215+ connections** across 5 layers
88
+ - **Runtime auto-discipline** `rune hooks install` wires native hooks on Claude Code, Cursor, Windsurf, Antigravity so `preflight`, `sentinel`, `completion-gate` auto-fire before tool use. No more "remember to invoke the skill."
89
+ - **Three presets** — `strict` (blocking gates), `gentle` (warnings, default), `off` (uninstall). Idempotent install / uninstall with full restore of user hooks.
90
+ - **Multi-tier hook layering** — `--tier pro` / `--tier business` stack paid-tier hooks on top of Free using a tier-tagged manifest at `$<TIER>_ROOT/hooks/manifest.json`. Free compiler stays tier-agnostic (MIT-clean).
91
+ - **logic-guardian v0.3.0** — `rune init` now auto-seeds `.rune/INVARIANTS.md` with project-detected rules (money math, state machines, payment flows). Preflight reads it as a hard gate.
92
+ - **session-bridge v0.7.0** — emits `context.compact.imminent` signal; cook/plan/team listen and checkpoint work before compaction.
93
+ - **autopilot v1.1.0** (Pro) — honors the hooks manifest; runs overnight with the same blocking gates your interactive sessions enforce.
94
+ - **Security** — tier name sanitization (path-traversal-safe), precise `statusLine` detection (no false-positive uninstall of user commands), `overrides` migration for legacy hook entries.
95
+ - **1,152 tests** — +31 from v2.11.0 covering hooks adapter, tier manifest loader, override migration, and review regressions.
92
96
 
93
- ### Previous (v2.9.0)
97
+ ### Previous (v2.11.0)
98
+
99
+ - **Mesh integrity** — 8 dead wires fixed, 5 workflow gaps closed (hotfix chain, API versioning, monorepo mode, feature flags, dependency upgrade campaigns)
100
+ - **audit v0.4.0** — DX Review Mode: Addy Osmani's 8 developer experience principles with scoring rubric and browser-pilot integration
101
+ - **cook v2.4.0** — remediation cycle counter + upstream inconsistency protocol
102
+ - **problem-solver v0.4.0** — Cynefin, SWOT, PESTLE, Porter's Five Forces, ethics framework
103
+ - **plan v1.5.0** — autopilot suggested_next: autonomous execution path for Pro users after plan approval
104
+ - **Autopilot routing** — skill-router Tier 1 entry for Pro autopilot ("auto", "làm hết", "đi ngủ" → autonomous mode)
105
+
106
+ ### Previous (v2.10.0)
94
107
 
95
108
  - **marketing v0.4.0** — anti-AI copy rules (banned phrases, 5 hook types, specificity mandate), expanded SEO audit with schema markup guide (10 types + `@graph` pattern), programmatic SEO awareness (4 playbooks), optional Pro content-scorer/cro-analyst integration
96
109
  - **Pro growth pack v1.1.0** — 3 new skills (content-scorer, cro-analyst, marketing-psych) + 6 existing skills enriched with SEO Machine patterns
@@ -246,6 +259,52 @@ This compiles all 62 skills into your IDE's rules format. Same knowledge, same w
246
259
  /rune mcp-builder "weather API with forecast tools"
247
260
  ```
248
261
 
262
+ ## Auto-Discipline (Claude Code Hooks)
263
+
264
+ Turn Rune skills into ambient runtime — no more `/rune preflight` every time. Install once, skills auto-fire on relevant tool calls:
265
+
266
+ ```bash
267
+ # Wire Rune quality gates into Claude Code (.claude/settings.json)
268
+ npx @rune-kit/rune hooks install --preset gentle
269
+
270
+ # Preset options:
271
+ # gentle — advisory, never blocks (default)
272
+ # strict — blocks tool call on BLOCK verdict
273
+ # off — uninstall
274
+
275
+ # Inspect current wiring
276
+ npx @rune-kit/rune hooks status
277
+
278
+ # Remove (preserves user-authored hooks)
279
+ npx @rune-kit/rune hooks uninstall
280
+ ```
281
+
282
+ What gets wired:
283
+
284
+ | Event | Skill | When it fires |
285
+ |---|---|---|
286
+ | PreToolUse(Edit\|Write) | preflight | Before Claude edits source files |
287
+ | PreToolUse(Bash) | sentinel | Before shell commands (catches `git commit`, secrets) |
288
+ | PostToolUse(Edit\|Write) | dependency-doctor | After dependency manifest edits |
289
+ | Stop | completion-gate | End of session — validates claims against evidence |
290
+
291
+ Rune only manages entries tagged with its command signature. User-authored hooks in the same events are preserved on install/uninstall.
292
+
293
+ ### Stacking paid tiers (Pro, Business)
294
+
295
+ Paid tiers ship their own `hooks/manifest.json`. Point Rune at the install root and pass `--tier`:
296
+
297
+ ```bash
298
+ export RUNE_PRO_ROOT=~/rune-pro
299
+ rune hooks install --preset gentle --tier pro
300
+
301
+ # Stack Free + Pro + Business in one command
302
+ export RUNE_BUSINESS_ROOT=~/rune-business
303
+ rune hooks install --preset gentle --tier pro --tier business
304
+ ```
305
+
306
+ Multi-platform: tier hooks compile to Claude Code, Cursor, Windsurf, and Antigravity with the same command — no Claude-only lock-in.
307
+
249
308
  ## Architecture
250
309
 
251
310
  ### 5-Layer Model
package/commands/rune.md CHANGED
@@ -1,168 +1,168 @@
1
- ---
2
- description: "Rune skill ecosystem — interconnected workflows for the full project lifecycle. Use /rune <action> to invoke skills."
3
- disable-model-invocation: true
4
- ---
5
-
6
- # Rune — Less skills. Deeper connections.
7
-
8
- Route to the appropriate Rune skill based on the action:
9
-
10
- ## Available Commands
11
-
12
- ### Orchestrators (L1)
13
- - `/rune cook <task>` — Invoke the rune:cook skill for feature implementation
14
- - `/rune team <task>` — Invoke the rune:team skill for parallel multi-agent work
15
- - `/rune launch` — Invoke the rune:launch skill for deploy + marketing
16
- - `/rune rescue` — Invoke the rune:rescue skill for legacy refactoring
17
-
18
- ### Workflow (L2) — Creation
19
- - `/rune plan <task>` — Invoke the rune:plan skill to create implementation plan
20
- - `/rune scout` — Invoke the rune:scout skill to scan codebase
21
- - `/rune brainstorm <topic>` — Invoke the rune:brainstorm skill for creative ideation
22
-
23
- ### Workflow (L2) — Development
24
- - `/rune debug <issue>` — Invoke the rune:debug skill for root cause analysis
25
- - `/rune fix <issue>` — Invoke the rune:fix skill to apply code changes
26
- - `/rune test` — Invoke the rune:test skill to write and run tests
27
- - `/rune review` — Invoke the rune:review skill for code quality review
28
-
29
- ### Workflow (L2) — Quality
30
- - `/rune sentinel` — Invoke the rune:sentinel skill for security scanning
31
- - `/rune preflight` — Invoke the rune:preflight skill for pre-commit quality gate
32
- - `/rune onboard` — Invoke the rune:onboard skill to generate project context
33
- - `/rune logic-guardian` — Invoke the rune:logic-guardian skill to protect business logic from accidental deletion
34
-
35
- ### Workflow (L2) — Delivery
36
- - `/rune deploy` — Invoke the rune:deploy skill for deployment management
37
- - `/rune marketing` — Invoke the rune:marketing skill for launch asset creation
38
-
39
- ### Workflow (L2) — Rescue
40
- - `/rune autopsy` — Invoke the rune:autopsy skill for codebase health assessment
41
- - `/rune safeguard` — Invoke the rune:safeguard skill to build safety nets for legacy code
42
- - `/rune surgeon` — Invoke the rune:surgeon skill for incremental refactoring
43
-
44
- ### Utilities (L3) — Knowledge
45
- - `/rune research <topic>` — Invoke the rune:research skill for web research
46
- - `/rune docs-seeker <query>` — Invoke the rune:docs-seeker skill for documentation lookup
47
- - `/rune trend-scout <topic>` — Invoke the rune:trend-scout skill for market intelligence
48
-
49
- ### Utilities (L3) — Reasoning
50
- - `/rune problem-solver <problem>` — Invoke the rune:problem-solver skill for structured reasoning
51
- - `/rune sequential-thinking <problem>` — Invoke the rune:sequential-thinking skill for multi-variable analysis
52
-
53
- ### Utilities (L3) — Validation
54
- - `/rune verification` — Invoke the rune:verification skill to run lint, type-check, tests, build
55
- - `/rune hallucination-guard` — Invoke the rune:hallucination-guard skill to verify imports and APIs
56
-
57
- ### Utilities (L3) — State
58
- - `/rune context-engine` — Invoke the rune:context-engine skill for context window management
59
- - `/rune journal` — Invoke the rune:journal skill for rescue state tracking
60
- - `/rune session-bridge` — Invoke the rune:session-bridge skill for cross-session persistence
61
-
62
- ### Utilities (L3) — Monitoring
63
- - `/rune watchdog` — Invoke the rune:watchdog skill for post-deploy monitoring
64
- - `/rune scope-guard` — Invoke the rune:scope-guard skill for scope creep detection
65
-
66
- ### Utilities (L3) — Media
67
- - `/rune browser-pilot <url>` — Invoke the rune:browser-pilot skill for Playwright automation
68
- - `/rune asset-creator <brief>` — Invoke the rune:asset-creator skill for visual asset generation
69
- - `/rune video-creator <brief>` — Invoke the rune:video-creator skill for video content planning
70
-
71
- ### Utilities (L3) — Deps
72
- - `/rune dependency-doctor` — Invoke the rune:dependency-doctor skill for dependency management
73
-
74
- ### Intelligence (H3)
75
- - `/rune metrics` — Show mesh analytics from .rune/metrics/ (runs audit Phase 8 only)
76
- - `/rune pack list` — List installed L4 packs (core + community)
77
- - `/rune pack install <git-url>` — Install a community L4 pack from Git
78
- - `/rune pack remove <name>` — Remove a community L4 pack
79
- - `/rune pack create <name>` — Scaffold a new L4 pack using skill-forge
80
-
81
- ### Extension Packs (L4)
82
-
83
- L4 packs provide domain-specific patterns. When invoked, read the pack's PACK.md and follow the matching skill's workflow steps.
84
-
85
- #### Frontend & UI (`extensions/ui/PACK.md`)
86
- - `/rune design-system` — Design token generation and enforcement
87
- - `/rune component-patterns` — Component architecture refactoring
88
- - `/rune a11y-audit` — Accessibility audit (WCAG compliance)
89
- - `/rune animation-patterns` — Motion design and animation patterns
90
-
91
- #### Backend (`extensions/backend/PACK.md`)
92
- - `/rune api-patterns` — REST/GraphQL API design and validation
93
- - `/rune auth-patterns` — Authentication and authorization flows
94
- - `/rune database-patterns` — Schema design, migrations, query optimization
95
- - `/rune middleware-patterns` — Middleware pipeline and error handling
96
-
97
- #### DevOps (`extensions/devops/PACK.md`)
98
- - `/rune docker` — Dockerfile optimization, multi-stage builds, compose
99
- - `/rune ci-cd` — CI/CD pipeline setup (GitHub Actions, GitLab CI)
100
- - `/rune monitoring` — Observability, logging, alerting setup
101
- - `/rune server-setup` — VPS/cloud server provisioning
102
- - `/rune ssl-domain` — SSL certificates and domain configuration
103
-
104
- #### Mobile (`extensions/mobile/PACK.md`)
105
- - `/rune react-native` — React Native / Expo architecture and performance
106
- - `/rune flutter` — Flutter state management and widget patterns
107
- - `/rune app-store-prep` — App Store / Play Store submission preparation
108
- - `/rune native-bridge` — Native module bridges (Turbo Modules, MethodChannel)
109
-
110
- #### Security (`extensions/security/PACK.md`)
111
- - `/rune owasp-audit` — OWASP Top 10 vulnerability audit
112
- - `/rune pentest-patterns` — Penetration testing methodology
113
- - `/rune secret-mgmt` — Secret management and rotation
114
- - `/rune compliance` — Compliance framework guidance (SOC2, HIPAA, PCI)
115
-
116
- #### Trading & Finance (`extensions/trading/PACK.md`)
117
- - `/rune fintech-patterns` — Financial data validation, decimal arithmetic
118
- - `/rune realtime-data` — WebSocket market data, order book management
119
- - `/rune chart-components` — Trading chart integration (TradingView, Lightweight Charts)
120
- - `/rune indicator-library` — Technical indicators (SMA, EMA, RSI, MACD)
121
- - `/rune trade-logic` — Trading logic preservation, strategy specs, backtest linkage
122
-
123
- #### SaaS (`extensions/saas/PACK.md`)
124
- - `/rune multi-tenant` — Multi-tenancy architecture patterns
125
- - `/rune billing-integration` — Stripe/Paddle billing integration
126
- - `/rune subscription-flow` — Subscription lifecycle management
127
- - `/rune onboarding-flow` — User onboarding flow design
128
-
129
- #### E-commerce (`extensions/ecommerce/PACK.md`)
130
- - `/rune shopify-dev` — Shopify theme/app development (Hydrogen, Liquid)
131
- - `/rune payment-integration` — Payment flow (Stripe Payment Intents, 3DS)
132
- - `/rune cart-system` — Shopping cart architecture
133
- - `/rune inventory-mgmt` — Stock tracking with optimistic locking
134
-
135
- #### AI/ML (`extensions/ai-ml/PACK.md`)
136
- - `/rune llm-integration` — LLM API clients with retry and structured output
137
- - `/rune rag-patterns` — RAG pipeline (chunking, embedding, retrieval, reranking)
138
- - `/rune embedding-search` — Hybrid search (BM25 + vector)
139
- - `/rune fine-tuning-guide` — Fine-tuning dataset prep, training, evaluation
140
-
141
- #### Game Development (`extensions/gamedev/PACK.md`)
142
- - `/rune threejs-patterns` — Three.js / React Three Fiber scene optimization
143
- - `/rune webgl` — WebGL shader programming and buffer management
144
- - `/rune game-loops` — Fixed timestep game loop with interpolation
145
- - `/rune physics-engine` — Rapier.js physics integration
146
- - `/rune asset-pipeline` — Game asset loading, compression, preloading
147
-
148
- #### Content (`extensions/content/PACK.md`)
149
- - `/rune blog-patterns` — Blog system (pagination, RSS, reading time)
150
- - `/rune cms-integration` — Headless CMS setup (Sanity, Contentful, Strapi)
151
- - `/rune mdx-authoring` — MDX pipeline with custom components
152
- - `/rune i18n` — Internationalization (locale routing, translations)
153
- - `/rune seo-patterns` — SEO audit (JSON-LD, sitemap, meta tags, OG)
154
-
155
- #### Analytics (`extensions/analytics/PACK.md`)
156
- - `/rune tracking-setup` — Analytics tracking with consent management
157
- - `/rune ab-testing` — A/B experiment design and statistical significance
158
- - `/rune funnel-analysis` — Conversion funnel tracking and drop-off analysis
159
- - `/rune dashboard-patterns` — KPI dashboards with server-side aggregation
160
-
161
- ### Quick Actions
162
- - `/rune status` — Show current project state from .rune/ files
163
-
164
- ## Usage
165
-
166
- When the user runs `/rune <action>`, invoke the corresponding `rune:<action>` skill.
167
- For L4 pack commands, read the specified PACK.md file and follow the matching skill's workflow.
168
- If no action is provided, show this help menu.
1
+ ---
2
+ description: "Rune skill ecosystem — interconnected workflows for the full project lifecycle. Use /rune <action> to invoke skills."
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Rune — Less skills. Deeper connections.
7
+
8
+ Route to the appropriate Rune skill based on the action:
9
+
10
+ ## Available Commands
11
+
12
+ ### Orchestrators (L1)
13
+ - `/rune cook <task>` — Invoke the rune:cook skill for feature implementation
14
+ - `/rune team <task>` — Invoke the rune:team skill for parallel multi-agent work
15
+ - `/rune launch` — Invoke the rune:launch skill for deploy + marketing
16
+ - `/rune rescue` — Invoke the rune:rescue skill for legacy refactoring
17
+
18
+ ### Workflow (L2) — Creation
19
+ - `/rune plan <task>` — Invoke the rune:plan skill to create implementation plan
20
+ - `/rune scout` — Invoke the rune:scout skill to scan codebase
21
+ - `/rune brainstorm <topic>` — Invoke the rune:brainstorm skill for creative ideation
22
+
23
+ ### Workflow (L2) — Development
24
+ - `/rune debug <issue>` — Invoke the rune:debug skill for root cause analysis
25
+ - `/rune fix <issue>` — Invoke the rune:fix skill to apply code changes
26
+ - `/rune test` — Invoke the rune:test skill to write and run tests
27
+ - `/rune review` — Invoke the rune:review skill for code quality review
28
+
29
+ ### Workflow (L2) — Quality
30
+ - `/rune sentinel` — Invoke the rune:sentinel skill for security scanning
31
+ - `/rune preflight` — Invoke the rune:preflight skill for pre-commit quality gate
32
+ - `/rune onboard` — Invoke the rune:onboard skill to generate project context
33
+ - `/rune logic-guardian` — Invoke the rune:logic-guardian skill to protect business logic from accidental deletion
34
+
35
+ ### Workflow (L2) — Delivery
36
+ - `/rune deploy` — Invoke the rune:deploy skill for deployment management
37
+ - `/rune marketing` — Invoke the rune:marketing skill for launch asset creation
38
+
39
+ ### Workflow (L2) — Rescue
40
+ - `/rune autopsy` — Invoke the rune:autopsy skill for codebase health assessment
41
+ - `/rune safeguard` — Invoke the rune:safeguard skill to build safety nets for legacy code
42
+ - `/rune surgeon` — Invoke the rune:surgeon skill for incremental refactoring
43
+
44
+ ### Utilities (L3) — Knowledge
45
+ - `/rune research <topic>` — Invoke the rune:research skill for web research
46
+ - `/rune docs-seeker <query>` — Invoke the rune:docs-seeker skill for documentation lookup
47
+ - `/rune trend-scout <topic>` — Invoke the rune:trend-scout skill for market intelligence
48
+
49
+ ### Utilities (L3) — Reasoning
50
+ - `/rune problem-solver <problem>` — Invoke the rune:problem-solver skill for structured reasoning
51
+ - `/rune sequential-thinking <problem>` — Invoke the rune:sequential-thinking skill for multi-variable analysis
52
+
53
+ ### Utilities (L3) — Validation
54
+ - `/rune verification` — Invoke the rune:verification skill to run lint, type-check, tests, build
55
+ - `/rune hallucination-guard` — Invoke the rune:hallucination-guard skill to verify imports and APIs
56
+
57
+ ### Utilities (L3) — State
58
+ - `/rune context-engine` — Invoke the rune:context-engine skill for context window management
59
+ - `/rune journal` — Invoke the rune:journal skill for rescue state tracking
60
+ - `/rune session-bridge` — Invoke the rune:session-bridge skill for cross-session persistence
61
+
62
+ ### Utilities (L3) — Monitoring
63
+ - `/rune watchdog` — Invoke the rune:watchdog skill for post-deploy monitoring
64
+ - `/rune scope-guard` — Invoke the rune:scope-guard skill for scope creep detection
65
+
66
+ ### Utilities (L3) — Media
67
+ - `/rune browser-pilot <url>` — Invoke the rune:browser-pilot skill for Playwright automation
68
+ - `/rune asset-creator <brief>` — Invoke the rune:asset-creator skill for visual asset generation
69
+ - `/rune video-creator <brief>` — Invoke the rune:video-creator skill for video content planning
70
+
71
+ ### Utilities (L3) — Deps
72
+ - `/rune dependency-doctor` — Invoke the rune:dependency-doctor skill for dependency management
73
+
74
+ ### Intelligence (H3)
75
+ - `/rune metrics` — Show mesh analytics from .rune/metrics/ (runs audit Phase 8 only)
76
+ - `/rune pack list` — List installed L4 packs (core + community)
77
+ - `/rune pack install <git-url>` — Install a community L4 pack from Git
78
+ - `/rune pack remove <name>` — Remove a community L4 pack
79
+ - `/rune pack create <name>` — Scaffold a new L4 pack using skill-forge
80
+
81
+ ### Extension Packs (L4)
82
+
83
+ L4 packs provide domain-specific patterns. When invoked, read the pack's PACK.md and follow the matching skill's workflow steps.
84
+
85
+ #### Frontend & UI (`extensions/ui/PACK.md`)
86
+ - `/rune design-system` — Design token generation and enforcement
87
+ - `/rune component-patterns` — Component architecture refactoring
88
+ - `/rune a11y-audit` — Accessibility audit (WCAG compliance)
89
+ - `/rune animation-patterns` — Motion design and animation patterns
90
+
91
+ #### Backend (`extensions/backend/PACK.md`)
92
+ - `/rune api-patterns` — REST/GraphQL API design and validation
93
+ - `/rune auth-patterns` — Authentication and authorization flows
94
+ - `/rune database-patterns` — Schema design, migrations, query optimization
95
+ - `/rune middleware-patterns` — Middleware pipeline and error handling
96
+
97
+ #### DevOps (`extensions/devops/PACK.md`)
98
+ - `/rune docker` — Dockerfile optimization, multi-stage builds, compose
99
+ - `/rune ci-cd` — CI/CD pipeline setup (GitHub Actions, GitLab CI)
100
+ - `/rune monitoring` — Observability, logging, alerting setup
101
+ - `/rune server-setup` — VPS/cloud server provisioning
102
+ - `/rune ssl-domain` — SSL certificates and domain configuration
103
+
104
+ #### Mobile (`extensions/mobile/PACK.md`)
105
+ - `/rune react-native` — React Native / Expo architecture and performance
106
+ - `/rune flutter` — Flutter state management and widget patterns
107
+ - `/rune app-store-prep` — App Store / Play Store submission preparation
108
+ - `/rune native-bridge` — Native module bridges (Turbo Modules, MethodChannel)
109
+
110
+ #### Security (`extensions/security/PACK.md`)
111
+ - `/rune owasp-audit` — OWASP Top 10 vulnerability audit
112
+ - `/rune pentest-patterns` — Penetration testing methodology
113
+ - `/rune secret-mgmt` — Secret management and rotation
114
+ - `/rune compliance` — Compliance framework guidance (SOC2, HIPAA, PCI)
115
+
116
+ #### Trading & Finance (`extensions/trading/PACK.md`)
117
+ - `/rune fintech-patterns` — Financial data validation, decimal arithmetic
118
+ - `/rune realtime-data` — WebSocket market data, order book management
119
+ - `/rune chart-components` — Trading chart integration (TradingView, Lightweight Charts)
120
+ - `/rune indicator-library` — Technical indicators (SMA, EMA, RSI, MACD)
121
+ - `/rune trade-logic` — Trading logic preservation, strategy specs, backtest linkage
122
+
123
+ #### SaaS (`extensions/saas/PACK.md`)
124
+ - `/rune multi-tenant` — Multi-tenancy architecture patterns
125
+ - `/rune billing-integration` — Stripe/Paddle billing integration
126
+ - `/rune subscription-flow` — Subscription lifecycle management
127
+ - `/rune onboarding-flow` — User onboarding flow design
128
+
129
+ #### E-commerce (`extensions/ecommerce/PACK.md`)
130
+ - `/rune shopify-dev` — Shopify theme/app development (Hydrogen, Liquid)
131
+ - `/rune payment-integration` — Payment flow (Stripe Payment Intents, 3DS)
132
+ - `/rune cart-system` — Shopping cart architecture
133
+ - `/rune inventory-mgmt` — Stock tracking with optimistic locking
134
+
135
+ #### AI/ML (`extensions/ai-ml/PACK.md`)
136
+ - `/rune llm-integration` — LLM API clients with retry and structured output
137
+ - `/rune rag-patterns` — RAG pipeline (chunking, embedding, retrieval, reranking)
138
+ - `/rune embedding-search` — Hybrid search (BM25 + vector)
139
+ - `/rune fine-tuning-guide` — Fine-tuning dataset prep, training, evaluation
140
+
141
+ #### Game Development (`extensions/gamedev/PACK.md`)
142
+ - `/rune threejs-patterns` — Three.js / React Three Fiber scene optimization
143
+ - `/rune webgl` — WebGL shader programming and buffer management
144
+ - `/rune game-loops` — Fixed timestep game loop with interpolation
145
+ - `/rune physics-engine` — Rapier.js physics integration
146
+ - `/rune asset-pipeline` — Game asset loading, compression, preloading
147
+
148
+ #### Content (`extensions/content/PACK.md`)
149
+ - `/rune blog-patterns` — Blog system (pagination, RSS, reading time)
150
+ - `/rune cms-integration` — Headless CMS setup (Sanity, Contentful, Strapi)
151
+ - `/rune mdx-authoring` — MDX pipeline with custom components
152
+ - `/rune i18n` — Internationalization (locale routing, translations)
153
+ - `/rune seo-patterns` — SEO audit (JSON-LD, sitemap, meta tags, OG)
154
+
155
+ #### Analytics (`extensions/analytics/PACK.md`)
156
+ - `/rune tracking-setup` — Analytics tracking with consent management
157
+ - `/rune ab-testing` — A/B experiment design and statistical significance
158
+ - `/rune funnel-analysis` — Conversion funnel tracking and drop-off analysis
159
+ - `/rune dashboard-patterns` — KPI dashboards with server-side aggregation
160
+
161
+ ### Quick Actions
162
+ - `/rune status` — Show current project state from .rune/ files
163
+
164
+ ## Usage
165
+
166
+ When the user runs `/rune <action>`, invoke the corresponding `rune:<action>` skill.
167
+ For L4 pack commands, read the specified PACK.md file and follow the matching skill's workflow.
168
+ If no action is provided, show this help menu.
@@ -0,0 +1,136 @@
1
+ import assert from 'node:assert';
2
+ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import path from 'node:path';
5
+ import { after, before, describe, test } from 'node:test';
6
+ import { detectInvariants, renderInvariants } from '../../skills/onboard/scripts/detect-invariants.js';
7
+
8
+ async function scaffold(files) {
9
+ const root = await mkdtemp(path.join(tmpdir(), 'rune-invariants-'));
10
+ for (const [rel, content] of Object.entries(files)) {
11
+ const abs = path.join(root, rel);
12
+ await mkdir(path.dirname(abs), { recursive: true });
13
+ await writeFile(abs, content, 'utf8');
14
+ }
15
+ return root;
16
+ }
17
+
18
+ describe('detectInvariants — danger zones', () => {
19
+ test('scores deeply-nested source directories as danger zones', async () => {
20
+ const files = {};
21
+ for (let i = 0; i < 12; i++) {
22
+ files[`src/auth/sub/file${i}.ts`] = `export const x${i} = ${i};\n`;
23
+ }
24
+ files['src/auth/session.ts'] = 'export const SESSION_TTL = 900;\n';
25
+ const root = await scaffold(files);
26
+ try {
27
+ const result = await detectInvariants({ root });
28
+ const danger = result.danger.map((r) => r.where[0]);
29
+ assert.ok(
30
+ danger.some((d) => d.startsWith('src/auth')),
31
+ `expected src/auth in danger, got: ${JSON.stringify(danger)}`,
32
+ );
33
+ } finally {
34
+ await rm(root, { recursive: true, force: true });
35
+ }
36
+ });
37
+
38
+ test('ignores node_modules and .git', async () => {
39
+ const files = {};
40
+ for (let i = 0; i < 20; i++) {
41
+ files[`node_modules/pkg/file${i}.js`] = '// noise\n';
42
+ }
43
+ files['src/app.ts'] = 'export const A = 1;\n';
44
+ const root = await scaffold(files);
45
+ try {
46
+ const result = await detectInvariants({ root });
47
+ const danger = result.danger.map((r) => r.where[0]);
48
+ assert.ok(!danger.some((d) => d.includes('node_modules')), 'node_modules must not appear');
49
+ } finally {
50
+ await rm(root, { recursive: true, force: true });
51
+ }
52
+ });
53
+ });
54
+
55
+ describe('detectInvariants — critical constants', () => {
56
+ test('flags SCREAMING_SNAKE constants used in 3+ files', async () => {
57
+ const files = {
58
+ 'src/config.ts': 'export const MAX_RETRIES = 3;\n',
59
+ 'src/a.ts': 'import { MAX_RETRIES } from "./config";\nconsole.log(MAX_RETRIES);\n',
60
+ 'src/b.ts': 'import { MAX_RETRIES } from "./config";\nif (MAX_RETRIES > 0) {}\n',
61
+ 'src/c.ts': 'import { MAX_RETRIES } from "./config";\nconst x = MAX_RETRIES;\n',
62
+ };
63
+ const root = await scaffold(files);
64
+ try {
65
+ const result = await detectInvariants({ root });
66
+ const found = result.critical.some(
67
+ (r) => (r.title ?? '').includes('MAX_RETRIES') || (r.what ?? '').includes('MAX_RETRIES'),
68
+ );
69
+ assert.ok(
70
+ found,
71
+ `expected MAX_RETRIES in critical, got titles: ${JSON.stringify(result.critical.map((r) => r.title))}`,
72
+ );
73
+ } finally {
74
+ await rm(root, { recursive: true, force: true });
75
+ }
76
+ });
77
+
78
+ test('does NOT flag constants used in fewer than 3 places', async () => {
79
+ const files = {
80
+ 'src/config.ts': 'export const LONELY = 1;\n',
81
+ 'src/a.ts': 'import { LONELY } from "./config";\n',
82
+ };
83
+ const root = await scaffold(files);
84
+ try {
85
+ const result = await detectInvariants({ root });
86
+ const found = result.critical.some((r) => (r.title ?? '').includes('LONELY'));
87
+ assert.strictEqual(found, false, 'LONELY should not be flagged with only 2 usages');
88
+ } finally {
89
+ await rm(root, { recursive: true, force: true });
90
+ }
91
+ });
92
+ });
93
+
94
+ describe('renderInvariants', () => {
95
+ test('produces markdown headings per non-empty bucket', () => {
96
+ const result = {
97
+ danger: [{ title: 'src/auth', what: '12 files', where: ['src/auth/**'], why: 'high churn' }],
98
+ critical: [],
99
+ state: [],
100
+ cross: [],
101
+ stats: { filesScanned: 10 },
102
+ };
103
+ const md = renderInvariants(result);
104
+ assert.ok(md.includes('### Danger Zones'));
105
+ assert.ok(md.includes('#### src/auth'));
106
+ assert.ok(md.includes('- **WHAT**: 12 files'));
107
+ assert.ok(!md.includes('### Critical Invariants'));
108
+ });
109
+
110
+ test('falls back to placeholder when empty', () => {
111
+ const md = renderInvariants({ danger: [], critical: [], state: [], cross: [] });
112
+ assert.match(md, /No invariants detected/);
113
+ });
114
+ });
115
+
116
+ describe('detectInvariants — performance', () => {
117
+ let root;
118
+ before(async () => {
119
+ const files = {};
120
+ for (let i = 0; i < 120; i++) {
121
+ files[`src/mod${i % 12}/file${i}.ts`] = `export const FOO_${i} = ${i};\n`;
122
+ }
123
+ root = await scaffold(files);
124
+ });
125
+ after(async () => {
126
+ await rm(root, { recursive: true, force: true });
127
+ });
128
+
129
+ test('completes under 5 seconds for a 120-file project', async () => {
130
+ const start = Date.now();
131
+ const result = await detectInvariants({ root });
132
+ const elapsed = Date.now() - start;
133
+ assert.ok(elapsed < 5000, `took ${elapsed}ms, expected <5000ms`);
134
+ assert.ok(result.stats.filesScanned >= 100, `scanned ${result.stats.filesScanned} files`);
135
+ });
136
+ });