@rune-kit/rune 2.1.1 → 2.2.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 (157) hide show
  1. package/README.md +40 -34
  2. package/compiler/__tests__/pack-split.test.js +145 -0
  3. package/compiler/adapters/antigravity.js +1 -1
  4. package/compiler/adapters/codex.js +77 -0
  5. package/compiler/adapters/cursor.js +1 -1
  6. package/compiler/adapters/generic.js +1 -1
  7. package/compiler/adapters/index.js +4 -0
  8. package/compiler/adapters/opencode.js +86 -0
  9. package/compiler/adapters/windsurf.js +1 -1
  10. package/compiler/bin/rune.js +10 -7
  11. package/compiler/doctor.js +42 -0
  12. package/compiler/emitter.js +64 -10
  13. package/compiler/parser.js +42 -3
  14. package/compiler/transformer.js +10 -6
  15. package/compiler/transforms/branding.js +1 -1
  16. package/compiler/transforms/compliance.js +40 -0
  17. package/extensions/ai-ml/PACK.md +38 -474
  18. package/extensions/ai-ml/skills/ai-agents.md +172 -0
  19. package/extensions/ai-ml/skills/code-sandbox.md +187 -0
  20. package/extensions/ai-ml/skills/deep-research.md +146 -0
  21. package/extensions/ai-ml/skills/embedding-search.md +66 -0
  22. package/extensions/ai-ml/skills/fine-tuning-guide.md +74 -0
  23. package/extensions/ai-ml/skills/llm-architect.md +125 -0
  24. package/extensions/ai-ml/skills/llm-integration.md +64 -0
  25. package/extensions/ai-ml/skills/prompt-patterns.md +72 -0
  26. package/extensions/ai-ml/skills/rag-patterns.md +66 -0
  27. package/extensions/ai-ml/skills/web-extraction.md +114 -0
  28. package/extensions/analytics/PACK.md +19 -484
  29. package/extensions/analytics/skills/ab-testing.md +72 -0
  30. package/extensions/analytics/skills/dashboard-patterns.md +83 -0
  31. package/extensions/analytics/skills/data-validation.md +68 -0
  32. package/extensions/analytics/skills/funnel-analysis.md +81 -0
  33. package/extensions/analytics/skills/sql-patterns.md +57 -0
  34. package/extensions/analytics/skills/statistical-analysis.md +79 -0
  35. package/extensions/analytics/skills/tracking-setup.md +71 -0
  36. package/extensions/backend/PACK.md +44 -618
  37. package/extensions/backend/skills/api-patterns.md +84 -0
  38. package/extensions/backend/skills/async-pipeline.md +193 -0
  39. package/extensions/backend/skills/auth-patterns.md +97 -0
  40. package/extensions/backend/skills/background-jobs.md +133 -0
  41. package/extensions/backend/skills/caching-patterns.md +108 -0
  42. package/extensions/backend/skills/cli-generation.md +133 -0
  43. package/extensions/backend/skills/database-patterns.md +87 -0
  44. package/extensions/backend/skills/middleware-patterns.md +104 -0
  45. package/extensions/chrome-ext/PACK.md +19 -921
  46. package/extensions/chrome-ext/skills/cws-preflight.md +143 -0
  47. package/extensions/chrome-ext/skills/cws-publish.md +104 -0
  48. package/extensions/chrome-ext/skills/ext-ai-integration.md +251 -0
  49. package/extensions/chrome-ext/skills/ext-messaging.md +139 -0
  50. package/extensions/chrome-ext/skills/ext-storage.md +133 -0
  51. package/extensions/chrome-ext/skills/mv3-scaffold.md +164 -0
  52. package/extensions/content/PACK.md +43 -335
  53. package/extensions/content/skills/blog-patterns.md +88 -0
  54. package/extensions/content/skills/cms-integration.md +131 -0
  55. package/extensions/content/skills/content-scoring.md +107 -0
  56. package/extensions/content/skills/i18n.md +83 -0
  57. package/extensions/content/skills/mdx-authoring.md +137 -0
  58. package/extensions/content/skills/reference.md +1014 -0
  59. package/extensions/content/skills/seo-patterns.md +67 -0
  60. package/extensions/content/skills/video-repurpose.md +153 -0
  61. package/extensions/devops/PACK.md +38 -457
  62. package/extensions/devops/skills/chaos-testing.md +67 -0
  63. package/extensions/devops/skills/ci-cd.md +75 -0
  64. package/extensions/devops/skills/docker.md +58 -0
  65. package/extensions/devops/skills/edge-serverless.md +163 -0
  66. package/extensions/devops/skills/infra-as-code.md +158 -0
  67. package/extensions/devops/skills/kubernetes.md +110 -0
  68. package/extensions/devops/skills/monitoring.md +57 -0
  69. package/extensions/devops/skills/server-setup.md +64 -0
  70. package/extensions/devops/skills/ssl-domain.md +42 -0
  71. package/extensions/ecommerce/PACK.md +62 -226
  72. package/extensions/ecommerce/skills/cart-system.md +79 -0
  73. package/extensions/ecommerce/skills/inventory-mgmt.md +102 -0
  74. package/extensions/ecommerce/skills/order-management.md +126 -0
  75. package/extensions/ecommerce/skills/payment-integration.md +472 -0
  76. package/extensions/ecommerce/skills/shopify-dev.md +69 -0
  77. package/extensions/ecommerce/skills/subscription-billing.md +93 -0
  78. package/extensions/ecommerce/skills/tax-compliance.md +117 -0
  79. package/extensions/gamedev/PACK.md +66 -317
  80. package/extensions/gamedev/skills/asset-pipeline.md +74 -0
  81. package/extensions/gamedev/skills/audio-system.md +129 -0
  82. package/extensions/gamedev/skills/camera-system.md +87 -0
  83. package/extensions/gamedev/skills/ecs.md +98 -0
  84. package/extensions/gamedev/skills/game-loops.md +72 -0
  85. package/extensions/gamedev/skills/input-system.md +199 -0
  86. package/extensions/gamedev/skills/multiplayer.md +180 -0
  87. package/extensions/gamedev/skills/particles.md +105 -0
  88. package/extensions/gamedev/skills/physics-engine.md +89 -0
  89. package/extensions/gamedev/skills/scene-management.md +146 -0
  90. package/extensions/gamedev/skills/threejs-patterns.md +90 -0
  91. package/extensions/gamedev/skills/webgl.md +71 -0
  92. package/extensions/mobile/PACK.md +56 -223
  93. package/extensions/mobile/skills/app-store-connect.md +152 -0
  94. package/extensions/mobile/skills/app-store-prep.md +66 -0
  95. package/extensions/mobile/skills/deep-linking.md +109 -0
  96. package/extensions/mobile/skills/flutter.md +60 -0
  97. package/extensions/mobile/skills/ios-build-pipeline.md +142 -0
  98. package/extensions/mobile/skills/native-bridge.md +66 -0
  99. package/extensions/mobile/skills/ota-updates.md +97 -0
  100. package/extensions/mobile/skills/push-notifications.md +111 -0
  101. package/extensions/mobile/skills/react-native.md +82 -0
  102. package/extensions/saas/PACK.md +26 -720
  103. package/extensions/saas/skills/billing-integration.md +121 -0
  104. package/extensions/saas/skills/feature-flags.md +130 -0
  105. package/extensions/saas/skills/multi-tenant.md +103 -0
  106. package/extensions/saas/skills/onboarding-flow.md +139 -0
  107. package/extensions/saas/skills/subscription-flow.md +95 -0
  108. package/extensions/saas/skills/team-management.md +144 -0
  109. package/extensions/security/PACK.md +10 -448
  110. package/extensions/security/skills/api-security.md +140 -0
  111. package/extensions/security/skills/compliance.md +68 -0
  112. package/extensions/security/skills/owasp-audit.md +64 -0
  113. package/extensions/security/skills/pentest-patterns.md +77 -0
  114. package/extensions/security/skills/secret-mgmt.md +65 -0
  115. package/extensions/security/skills/supply-chain.md +65 -0
  116. package/extensions/trading/PACK.md +18 -535
  117. package/extensions/trading/skills/chart-components.md +55 -0
  118. package/extensions/trading/skills/experiment-loop.md +125 -0
  119. package/extensions/trading/skills/fintech-patterns.md +47 -0
  120. package/extensions/trading/skills/indicator-library.md +58 -0
  121. package/extensions/trading/skills/quant-analysis.md +111 -0
  122. package/extensions/trading/skills/realtime-data.md +58 -0
  123. package/extensions/trading/skills/trade-logic.md +104 -0
  124. package/extensions/ui/PACK.md +34 -853
  125. package/extensions/ui/skills/a11y-audit.md +91 -0
  126. package/extensions/ui/skills/animation-patterns.md +106 -0
  127. package/extensions/ui/skills/component-patterns.md +75 -0
  128. package/extensions/ui/skills/design-decision.md +98 -0
  129. package/extensions/ui/skills/design-system.md +68 -0
  130. package/extensions/ui/skills/landing-patterns.md +155 -0
  131. package/extensions/ui/skills/palette-picker.md +162 -0
  132. package/extensions/ui/skills/react-health.md +90 -0
  133. package/extensions/ui/skills/type-system.md +125 -0
  134. package/extensions/ui/skills/web-vitals.md +153 -0
  135. package/extensions/zalo/PACK.md +117 -0
  136. package/extensions/zalo/skills/zalo-oa-mcp.md +317 -0
  137. package/extensions/zalo/skills/zalo-oa-messaging.md +429 -0
  138. package/extensions/zalo/skills/zalo-oa-setup.md +236 -0
  139. package/extensions/zalo/skills/zalo-oa-webhook.md +189 -0
  140. package/extensions/zalo/skills/zalo-personal-messaging.md +194 -0
  141. package/extensions/zalo/skills/zalo-personal-setup.md +153 -0
  142. package/extensions/zalo/skills/zalo-rate-guard.md +219 -0
  143. package/package.json +5 -2
  144. package/skills/brainstorm/SKILL.md +63 -1
  145. package/skills/cook/SKILL.md +89 -6
  146. package/skills/debug/SKILL.md +5 -0
  147. package/skills/fix/SKILL.md +5 -0
  148. package/skills/mcp-builder/SKILL.md +48 -1
  149. package/skills/neural-memory/SKILL.md +362 -0
  150. package/skills/plan/SKILL.md +3 -0
  151. package/skills/rescue/SKILL.md +5 -0
  152. package/skills/review/SKILL.md +44 -5
  153. package/skills/review-intake/SKILL.md +17 -1
  154. package/skills/skill-router/SKILL.md +106 -8
  155. package/skills/team/SKILL.md +24 -1
  156. package/skills/test/SKILL.md +18 -0
  157. package/skills/verification/SKILL.md +40 -1
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: zalo-rate-guard
3
+ pack: "@rune/zalo"
4
+ description: Rate limiting patterns for Zalo OA and personal APIs — token bucket per endpoint, exponential backoff, queue management, quota monitoring, anti-ban strategies.
5
+ model: sonnet
6
+ tools: "Read, Glob, Grep, Bash, Write, Edit"
7
+ ---
8
+
9
+ # zalo-rate-guard
10
+
11
+ Shared rate limiting layer for both Track A (OA API) and Track B (Personal via zca-js).
12
+ Zalo has **undocumented rate limits** — no official RPM/QPM numbers published.
13
+ Exceeding limits: throttled (429) → warned → OA suspended / account banned.
14
+ Neither `zalo-php-sdk`, `zalo-java-sdk`, nor `zca-js` implement any rate limiting.
15
+ This skill fills that gap.
16
+
17
+ ---
18
+
19
+ ## Estimated Safe Limits
20
+
21
+ **Track A — OA API:**
22
+
23
+ | Endpoint | Safe RPM | Burst | Notes |
24
+ |----------|----------|-------|-------|
25
+ | Send CS message | 200 | 10 | Per OA, includes all message types |
26
+ | Send broadcast | 50 | 5 | Monthly quota based on follower count |
27
+ | Get user profile | 300 | 20 | Cacheable — use name cache |
28
+ | Get follower list | 100 | 10 | Paginated, cache results |
29
+ | Upload media | 60 | 5 | Large payloads, slower |
30
+ | Global | 500 | 30 | Total across all endpoints |
31
+
32
+ **Track B — Personal (zca-js):**
33
+
34
+ | Action | Safe RPM | Burst | Notes |
35
+ |--------|----------|-------|-------|
36
+ | Send message (DM) | 30 | 5 | Much lower than OA — personal account |
37
+ | Send message (group) | 20 | 3 | Groups are more scrutinized |
38
+ | Friend operations | 10 | 2 | Add/remove friend is very sensitive |
39
+ | Profile lookups | 60 | 10 | Less sensitive, still cache |
40
+ | Global | 100 | 15 | Err on side of caution |
41
+
42
+ ---
43
+
44
+ ## Token Bucket Implementation
45
+
46
+ ```typescript
47
+ import PQueue from 'p-queue'
48
+
49
+ interface RateLimitConfig {
50
+ rpm: number // requests per minute
51
+ burst: number // max concurrent
52
+ retryAfter: number // ms to wait on 429
53
+ }
54
+
55
+ const LIMITS: Record<string, RateLimitConfig> = {
56
+ 'oa:send_message': { rpm: 200, burst: 10, retryAfter: 5000 },
57
+ 'oa:broadcast': { rpm: 50, burst: 5, retryAfter: 10000 },
58
+ 'oa:get_profile': { rpm: 300, burst: 20, retryAfter: 3000 },
59
+ 'oa:upload': { rpm: 60, burst: 5, retryAfter: 5000 },
60
+ 'personal:send_dm': { rpm: 30, burst: 5, retryAfter: 10000 },
61
+ 'personal:send_grp': { rpm: 20, burst: 3, retryAfter: 15000 },
62
+ 'personal:friend': { rpm: 10, burst: 2, retryAfter: 30000 },
63
+ }
64
+
65
+ export class ZaloRateLimiter {
66
+ private queues = new Map<string, PQueue>()
67
+
68
+ constructor() {
69
+ for (const [key, config] of Object.entries(LIMITS)) {
70
+ this.queues.set(key, new PQueue({
71
+ concurrency: config.burst,
72
+ intervalCap: config.rpm,
73
+ interval: 60_000, // per minute window
74
+ }))
75
+ }
76
+ }
77
+
78
+ async execute<T>(endpoint: string, fn: () => Promise<T>): Promise<T> {
79
+ const queue = this.queues.get(endpoint)
80
+ if (!queue) throw new Error(`Unknown endpoint: ${endpoint}`)
81
+ return queue.add(fn) as Promise<T>
82
+ }
83
+
84
+ queueSize(endpoint: string): number {
85
+ return this.queues.get(endpoint)?.size ?? 0
86
+ }
87
+
88
+ pending(endpoint: string): number {
89
+ return this.queues.get(endpoint)?.pending ?? 0
90
+ }
91
+ }
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Exponential Backoff on 429
97
+
98
+ ```typescript
99
+ export async function withBackoff<T>(
100
+ fn: () => Promise<T>,
101
+ maxRetries = 3,
102
+ baseDelay = 1000
103
+ ): Promise<T> {
104
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
105
+ try {
106
+ return await fn()
107
+ } catch (error: any) {
108
+ const isRateLimit = error?.status === 429 || error?.error_code === 429
109
+ if (!isRateLimit || attempt === maxRetries) throw error
110
+ const delay = baseDelay * Math.pow(2, attempt) + Math.random() * 1000
111
+ console.warn(`[zalo-rate-guard] Rate limited. Retry ${attempt + 1}/${maxRetries} in ${Math.round(delay)}ms`)
112
+ await new Promise(r => setTimeout(r, delay))
113
+ }
114
+ }
115
+ throw new Error('Unreachable')
116
+ }
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Quota Monitoring (OA Broadcast)
122
+
123
+ Broadcast quota is a **hard monthly limit** — exceeding it silently drops messages, no error returned.
124
+
125
+ ```typescript
126
+ interface QuotaTracker {
127
+ monthly_limit: number // based on follower count + OA level
128
+ used: number
129
+ resets_at: Date // 1st of each month
130
+ }
131
+
132
+ export function canBroadcast(tracker: QuotaTracker, recipientCount: number): boolean {
133
+ const remaining = tracker.monthly_limit - tracker.used
134
+ if (recipientCount > remaining) {
135
+ console.error(
136
+ `[zalo-rate-guard] Broadcast quota insufficient: need ${recipientCount}, have ${remaining}/${tracker.monthly_limit}`
137
+ )
138
+ return false
139
+ }
140
+ return true
141
+ }
142
+
143
+ export function trackBroadcastUsed(tracker: QuotaTracker, sent: number): QuotaTracker {
144
+ return { ...tracker, used: tracker.used + sent }
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Integration Pattern
151
+
152
+ ```typescript
153
+ // Singleton — shared across the app
154
+ export const limiter = new ZaloRateLimiter()
155
+
156
+ // Track A: OA message send with rate limiting
157
+ export async function sendOaMessage(userId: string, text: string) {
158
+ return limiter.execute('oa:send_message', () =>
159
+ withBackoff(() =>
160
+ oaApiCall('/message/cs', {
161
+ recipient: { user_id: userId },
162
+ message: { text },
163
+ })
164
+ )
165
+ )
166
+ }
167
+
168
+ // Track B: Personal DM with rate limiting + human jitter
169
+ export async function sendPersonalMessage(threadId: string, text: string) {
170
+ const jitter = 500 + Math.random() * 1500 // 500–2000ms
171
+ await new Promise(r => setTimeout(r, jitter))
172
+ return limiter.execute('personal:send_dm', () =>
173
+ withBackoff(() => api.sendMessage(text, threadId, 'User'))
174
+ )
175
+ }
176
+
177
+ // Track B: Friend operation — highest-risk, extra jitter
178
+ export async function addFriend(userId: string) {
179
+ const jitter = 2000 + Math.random() * 3000 // 2–5s
180
+ await new Promise(r => setTimeout(r, jitter))
181
+ return limiter.execute('personal:friend', () =>
182
+ withBackoff(() => api.sendFriendRequest(userId), 2, 5000)
183
+ )
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Anti-Ban Strategies
190
+
191
+ **Track A (OA):**
192
+ 1. Stay under safe RPM limits (table above)
193
+ 2. Exponential backoff on ALL 429 responses — never retry immediately
194
+ 3. Cache user profiles — avoid repeated lookups for the same user
195
+ 4. Spread broadcasts over time — don't burst the entire follower list at once
196
+ 5. Monitor quota before each broadcast batch — stop before hitting monthly limit
197
+ 6. Use `appsecret_proof` on all requests — proves you're the legitimate app owner
198
+
199
+ **Track B (Personal):**
200
+ 1. Much lower limits than OA — personal accounts are watched more closely
201
+ 2. Add human-like jitter: 500–2000ms random delay between messages (not optional)
202
+ 3. Avoid 3–6 AM (VN timezone) — traffic at those hours flags automated activity
203
+ 4. Never change profile info programmatically — triggers manual review
204
+ 5. Friend operations are highest-risk — max 10 RPM, prefer lower in practice
205
+ 6. Keep sessions long-lived — repeated login/logout is a strong ban signal
206
+ 7. Use a consistent device fingerprint (`userAgent` + `IMEI`) per account
207
+ 8. On `DuplicateConnection` (error 3000): wait 30s before reconnecting, never spam reconnects
208
+
209
+ ---
210
+
211
+ ## Sharp Edges
212
+
213
+ - Rate limits are **estimated** — Zalo does not publish official numbers; treat all figures as conservative targets
214
+ - `p-queue` `intervalCap` applies per window, not per request — test behavior under burst
215
+ - 429 without backoff = accelerating toward ban, not slowing down
216
+ - Broadcast quota overflow **silently drops messages** — no 429, no error, just lost sends
217
+ - Stale cached profile data is acceptable; hitting rate limits for fresh data is not
218
+ - Personal account friend operations are the single highest-risk action — handle with care
219
+ - Human jitter for personal track is a survival strategy, not a nice-to-have
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rune-kit/rune",
3
- "version": "2.1.1",
4
- "description": "57-skill mesh for AI coding assistants — 5-layer architecture, 200+ connections, all platforms (Claude Code, Cursor, Windsurf, Antigravity)",
3
+ "version": "2.2.1",
4
+ "description": "58-skill mesh for AI coding assistants — 5-layer architecture, 200+ connections, 8 platforms (Claude Code, Cursor, Windsurf, Antigravity, Codex, OpenCode, OpenClaw, Generic)",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "rune": "./compiler/bin/rune.js"
@@ -16,6 +16,9 @@
16
16
  "cursor",
17
17
  "windsurf",
18
18
  "antigravity",
19
+ "codex",
20
+ "opencode",
21
+ "openclaw",
19
22
  "ai-assistant",
20
23
  "ai-coding",
21
24
  "skills",
@@ -3,7 +3,7 @@ name: brainstorm
3
3
  description: Creative ideation and solution exploration. Generates multiple approaches with trade-offs, uses structured frameworks (SCAMPER, First Principles), and hands off to plan for structuring.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.3.0"
6
+ version: "0.4.0"
7
7
  layer: L2
8
8
  model: opus
9
9
  group: creation
@@ -27,6 +27,20 @@ This applies to EVERY task regardless of perceived simplicity.
27
27
  ### Discovery Mode (default)
28
28
  Normal brainstorming at the start of a task — generate approaches before any code is written.
29
29
 
30
+ ### Vision Mode
31
+ Activated for product-level rethinks — not "how to implement X" but "should we even build X?" Forces 10x thinking instead of incremental improvement.
32
+
33
+ **Vision Mode triggers:**
34
+ - Manual: `/rune brainstorm vision <product area>`
35
+ - Called by `@rune-pro/product.feature-spec` when requirements feel incremental
36
+ - When the user says "rethink", "reimagine", "what if we", "step back"
37
+
38
+ **Vision Mode constraints:**
39
+ 1. MUST restate the user's REAL problem (not their proposed solution) — "you asked for a settings page, but your real problem is users can't find the right config"
40
+ 2. MUST generate 2-3 approaches where at least 1 eliminates the need for the feature entirely
41
+ 3. MUST apply the "10-star experience" lens: what would a 1-star, 5-star, and 10-star version look like?
42
+ 4. MUST challenge assumptions: "why does this need to be a page?" "why does the user need to do this at all?"
43
+
30
44
  ### Rescue Mode
31
45
  Activated when an approach has been tried and **fundamentally failed** — not a bug, but a wrong approach. Rescue mode forces **category-diverse** alternatives instead of variants of the failed approach.
32
46
 
@@ -125,6 +139,7 @@ CRAZY 8s — 8 ideas in 8 minutes (rapid ideation)
125
139
  ### Step 0 — Detect Mode
126
140
 
127
141
  Check the invocation context:
142
+ - If `mode="vision"` is set, or user says "rethink/reimagine/step back" → **Vision Mode**
128
143
  - If `mode="rescue"` is set, or caller is Approach Pivot Gate / 3-Fix Escalation → **Rescue Mode**
129
144
  - Otherwise → **Discovery Mode**
130
145
 
@@ -139,6 +154,53 @@ State the decision to be made in one clear sentence: "We need to decide HOW TO [
139
154
 
140
155
  If the problem is unclear, ask the user ONE clarifying question before proceeding.
141
156
 
157
+ ### Step 1.5 — Problem Restatement (MANDATORY)
158
+
159
+ After framing the problem, restate it back to the user for confirmation:
160
+
161
+ ```
162
+ "Let me confirm: you want to [X] because [Y],
163
+ and the main constraint is [Z]. Correct?"
164
+ ```
165
+
166
+ DO NOT generate approaches until user confirms the restatement. This prevents wasted ideation on a misunderstood problem — the most expensive brainstorm failure mode.
167
+
168
+ **Skip conditions** (Rescue Mode only):
169
+ - Rescue Mode: problem is already well-defined by `failure_evidence` — restatement is implicit in the failed approach summary.
170
+
171
+ ### Step 1.75 — Dynamic Questioning (When Clarification Needed)
172
+
173
+ When Step 1 or Step 1.5 reveals gaps, ask structured clarifying questions using this format:
174
+
175
+ ```
176
+ ### [P0|P1|P2] **[DECISION POINT]**
177
+
178
+ **Question:** [Clear, specific question]
179
+
180
+ **Why This Matters:**
181
+ - [Architectural consequence — what changes based on the answer]
182
+ - [Affects: cost | complexity | timeline | scale | security]
183
+
184
+ **Options:**
185
+ | Option | Pros | Cons | Best For |
186
+ |--------|------|------|----------|
187
+ | A | [+] | [-] | [scenario] |
188
+ | B | [+] | [-] | [scenario] |
189
+
190
+ **If Not Specified:** [Default choice + rationale]
191
+ ```
192
+
193
+ **Priority levels:**
194
+ - **P0**: Blocking — cannot generate approaches without this answer
195
+ - **P1**: High-leverage — significantly changes the recommended approach
196
+ - **P2**: Nice-to-have — refines the recommendation but doesn't change direction
197
+
198
+ **Rules:**
199
+ 1. Ask maximum 3 questions per round (avoid overwhelming the user)
200
+ 2. Each question MUST connect to a specific decision point (no generic "what do you want?")
201
+ 3. MUST provide a default answer — if user says "you decide", the default is used
202
+ 4. Questions generate data, not assumptions — each eliminates implementation paths
203
+
142
204
  ### Step 2 — Generate Approaches
143
205
 
144
206
  **Discovery Mode**: Produce exactly 2–3 distinct approaches.
@@ -5,7 +5,7 @@ context: fork
5
5
  agent: general-purpose
6
6
  metadata:
7
7
  author: runedev
8
- version: "0.5.0"
8
+ version: "0.7.0"
9
9
  layer: L1
10
10
  model: sonnet
11
11
  group: orchestrator
@@ -115,6 +115,23 @@ Skip silently on subsequent runs. User can force with `/rune env-check`.
115
115
  - Extract decisions relevant to the current task domain (match by keywords: module names, tech choices, patterns)
116
116
  - These become **constraints for Phase 2 (PLAN)** — the plan MUST NOT contradict active decisions without explicit user override
117
117
  - If no `.rune/decisions.md` exists, skip silently
118
+ ### Phase 1 Step 3.5 — Clarification Gate (Lightweight Socratic Check)
119
+
120
+ Before planning, ask the user at minimum **2 clarifying questions**:
121
+
122
+ 1. **"What does success look like?"** — defines acceptance criteria (how we know we're done)
123
+ 2. **"What should NOT change?"** — defines blast radius constraints (what's off-limits)
124
+
125
+ **Skip conditions** (ALL must be true to skip):
126
+ - Bug fix with clear reproduction steps already provided by user
127
+ - User explicitly said "just do it", "no questions", or "skip questions"
128
+ - Fast mode active AND estimated change < 10 LOC
129
+ - Hotfix chain active (production emergency)
130
+
131
+ This is NOT the full BA elicitation (5 questions). It's a lightweight 2-question gate that prevents the most common failure: implementing the wrong thing. If the answers reveal complexity → escalate to `rune:ba` for deep requirement analysis.
132
+
133
+ **Question format**: Use brainstorm's dynamic questioning format when possible (Priority level, Decision Point, Why This Matters, Options table, Default).
134
+
118
135
  4. Invoke scout to scan the codebase:
119
136
  - Use `Glob` to find files matching the feature domain (e.g., `**/*auth*`, `**/*user*`)
120
137
  - Use `Grep` to search for related patterns, imports, existing implementations
@@ -136,7 +153,16 @@ Skip silently on subsequent runs. User can force with `/rune env-check`.
136
153
 
137
154
  **Goal**: Detect if domain-specific L4 extension packs apply to this task.
138
155
 
139
- After scout completes (Phase 1), check if the detected tech stack or task description matches any L4 extension pack. If a match is found, read the pack's PACK.md to load domain-specific patterns, constraints, and sharp edges into the current workflow.
156
+ After scout completes (Phase 1), check if the detected tech stack or task description matches any L4 extension pack. If a match is found, load the relevant domain-specific patterns, constraints, and sharp edges into the current workflow.
157
+
158
+ **Split pack protocol** (context-efficient):
159
+ - `Read` the matching PACK.md index (~60-80 lines) — this contains triggers, skill table, connections, and workflows
160
+ - Match the task to the specific skill name in the index's Skills Included table
161
+ - `Read` only the matching skill file(s) from `skills/` subdirectory (e.g., `extensions/backend/skills/auth.md`)
162
+ - Load max 2-3 skill files per invocation — not all skills in the pack
163
+ - Pack-level constraints (from index's Connections and Sharp Edges sections) always apply
164
+
165
+ **Monolith pack protocol** (legacy): If no `format: split` in PACK.md frontmatter, read the full PACK.md and extract the matching `### skill-name` section as before.
140
166
 
141
167
  1. Check the project's detected stack against the L4 pack mapping:
142
168
 
@@ -154,13 +180,20 @@ After scout completes (Phase 1), check if the detected tech stack or task descri
154
180
  | `three`, `pixi`, `phaser`, `*.glsl`, game loop | `@rune/gamedev` | `extensions/gamedev/PACK.md` |
155
181
  | CMS, blog, MDX, `i18next`, SEO | `@rune/content` | `extensions/content/PACK.md` |
156
182
  | Analytics, tracking, A/B test, funnel | `@rune/analytics` | `extensions/analytics/PACK.md` |
183
+ | Chrome extension, `manifest.json`, service worker, content script | `@rune/chrome-ext` | `extensions/chrome-ext/PACK.md` |
157
184
  | PRD, roadmap, KPI, release notes, `.rune/business/` | `@rune-pro/product` | `extensions/pro-product/PACK.md` |
185
+ | Sales outreach, pipeline, call prep, competitive intel | `@rune-pro/sales` | `extensions/pro-sales/PACK.md` |
186
+ | Data science, SQL, dashboard, statistical testing, ETL | `@rune-pro/data-science` | `extensions/pro-data-science/PACK.md` |
187
+ | Support ticket, KB article, escalation, SLA, FAQ | `@rune-pro/support` | `extensions/pro-support/PACK.md` |
188
+ | Budget, expense, revenue forecast, P&L, cash flow, runway | `@rune-pro/finance` | `extensions/pro-finance/PACK.md` |
189
+ | Contract, NDA, compliance, GDPR, IP, legal incident | `@rune-pro/legal` | `extensions/pro-legal/PACK.md` |
158
190
 
159
191
  2. If ≥1 pack matches:
160
- - Use `Read` to load the matching PACK.md
161
- - Extract the relevant skill's **Workflow** steps and **Constraints**
192
+ - Use `Read` to load the matching PACK.md (index if split, full if monolith)
193
+ - For split packs: identify the relevant skill from the index table, then `Read` only that skill file from `skills/` subdirectory
194
+ - For monolith packs: extract the relevant `### skill-name` section from the PACK.md body
162
195
  - Apply pack constraints alongside cook's own constraints for the rest of the workflow
163
- - Announce: "Loaded @rune/[pack] applying [skill-name] domain patterns"
196
+ - Announce: "Loaded @rune/[pack] [skill-name] (split)" or "Loaded @rune/[pack] → [skill-name] (full)"
164
197
 
165
198
  3. If 0 packs match: skip silently, proceed to Phase 2
166
199
 
@@ -170,6 +203,8 @@ This phase is lightweight — a Read + pattern match, not a full scan. It does N
170
203
 
171
204
  **Goal**: Detect if a master plan already exists for this task. If so, skip Phase 1-2 and resume from the current phase.
172
205
 
206
+ **Step 0.5 — Cross-Project Recall**: Call `neural-memory` (Recall Mode) with 3-5 topics relevant to the current task. Load applicable patterns, past decisions, and error history from neural memory. Always prefix queries with the project name to avoid cross-project noise (e.g., `"ProjectName auth pattern"` not just `"auth pattern"`). This activates neurons from past sessions and surfaces context that may not be in the local `.rune/` files.
207
+
173
208
  1. Use `Glob` to check for `.rune/plan-*.md` files
174
209
  2. If a master plan exists that matches the current task:
175
210
  - Read the master plan file
@@ -405,6 +440,32 @@ This is OPT-IN — only activate if:
405
440
  - User explicitly requests checkpoints
406
441
  ```
407
442
 
443
+ ## Phase Transition Protocol (MANDATORY)
444
+
445
+ Before entering ANY Phase N+1, assert ALL of the following:
446
+
447
+ ```
448
+ ASSERT Phase N status == completed (in TodoWrite)
449
+ ASSERT Phase N gate condition met (see Mesh Gates table below)
450
+ ASSERT No BLOCK status from any sub-skill in Phase N
451
+ ASSERT No unresolved CRITICAL findings from quality checks
452
+
453
+ IF any assertion fails:
454
+ → STOP. Do NOT proceed to Phase N+1.
455
+ → Log: "BLOCKED at Phase N→N+1 transition: [specific assertion that failed]"
456
+ → Fix the blocking issue, then re-check assertions.
457
+ ```
458
+
459
+ **Key transitions to enforce:**
460
+ | Transition | Gate | Common Violation |
461
+ |---|---|---|
462
+ | Phase 1 → 2 | Scout Gate (codebase scanned) | Skipping scout "to save time" |
463
+ | Phase 2 → 3 | Plan Gate (user approved plan) | Starting code without approval |
464
+ | Phase 3 → 4 | Test-First Gate (failing tests exist) | Writing code before tests |
465
+ | Phase 4 → 5 | All tests pass | Moving to quality with failing tests |
466
+ | Phase 5 → 6 | Quality gate (no CRITICAL findings) | Ignoring sentinel CRITICAL |
467
+ | Phase 6 → 7 | Verification green (lint + types + build) | Committing broken build |
468
+
408
469
  ## Phase 6: VERIFY
409
470
 
410
471
  **Goal**: Final automated verification before commit.
@@ -470,7 +531,8 @@ This is OPT-IN — only activate if:
470
531
  - If Phase 4 had 3 debug-fix loops (max) for a specific error pattern, write a routing override to `.rune/metrics/routing-overrides.json`:
471
532
  - Format: `{ "id": "r-<timestamp>", "condition": "<error pattern>", "action": "route to problem-solver before debug", "source": "auto", "active": true }`
472
533
  - Max 10 active rules — if exceeded, remove oldest inactive rule
473
- 7. Mark Phase 8 as `completed`
534
+ 7. **Step 8.5 Capture Learnings**: Call `neural-memory` (Capture Mode). Save 2-5 memories covering: architecture decisions made this session, patterns introduced or validated, errors encountered and their root-cause fixes, and any trade-offs chosen. Use rich cognitive language (causal, decisional, comparative — not flat facts). Tag each memory with `[project-name, technology, topic]`. Priority: 5 for routine patterns, 7-8 for key decisions, 9-10 for critical errors. Do NOT batch — save each memory immediately. Do NOT wait for the user to ask.
535
+ 8. Mark Phase 8 as `completed`
474
536
 
475
537
  ## Autonomous Loop Patterns
476
538
 
@@ -510,6 +572,26 @@ TIMEOUT_SIGNAL: If context-watch reports ORANGE, wrap up current phase and ch
510
572
 
511
573
  If any exit condition triggers without resolution → cook emits `BLOCKED` status with details and stops. Never spin indefinitely.
512
574
 
575
+ ### Subagent Status Protocol
576
+
577
+ When cook completes (whether standalone or invoked by `team`), it MUST return one of four statuses. Sub-skills invoked by cook (fix, test, review, sentinel, etc.) MUST also return one of these statuses so cook can route accordingly.
578
+
579
+ | Status | Meaning | Cook Action |
580
+ |--------|---------|-------------|
581
+ | `DONE` | Task complete, no issues | Proceed to next phase |
582
+ | `DONE_WITH_CONCERNS` | Task complete but issues noted (e.g., "tests pass but a performance regression observed") | Proceed, but append concern to `.rune/progress.md` and surface in Cook Report; address in Phase 5 (QUALITY) or next review cycle |
583
+ | `NEEDS_CONTEXT` | Cannot proceed without more information (missing requirement, ambiguous spec, unknown environment) | Pause execution. Ask user the specific question(s) blocking progress. Resume from the same phase after answer received. |
584
+ | `BLOCKED` | Hard blocker — cannot continue regardless of context (broken dependency, fundamental incompatibility, exhausted escalation chain) | Trigger escalation chain: debug-fix (3x) → re-plan (1x) → brainstorm rescue (1x) → then escalate to user with full details |
585
+
586
+ **DONE_WITH_CONCERNS logging format** (append to `.rune/progress.md`):
587
+ ```
588
+ [CONCERN][phase][timestamp] <sub-skill>: <concern description>
589
+ ```
590
+
591
+ **NEEDS_CONTEXT format**: State exactly what is unknown, why it blocks progress, and what the two most likely answers are (to help the user respond quickly).
592
+
593
+ **BLOCKED format**: Include the phase, the sub-skill that emitted BLOCKED, the specific blocker, and what was already attempted.
594
+
513
595
  ## Error Recovery
514
596
 
515
597
  | Phase | If this fails... | Do this... |
@@ -530,6 +612,7 @@ If any exit condition triggers without resolution → cook emits `BLOCKED` statu
530
612
 
531
613
  ## Calls (outbound)
532
614
 
615
+ - `neural-memory` (external): Phase 0 (resume) + Phase 8 (complete) — Recall project context at start, capture learnings at end
533
616
  - `sentinel-env` (L3): Phase 0.5 — environment pre-flight (first run only)
534
617
  - `scout` (L2): Phase 1 — scan codebase before planning
535
618
  - `onboard` (L2): Phase 1 — if no CLAUDE.md exists, initialize project context first
@@ -42,6 +42,7 @@ If root cause cannot be identified after 3 hypothesis cycles:
42
42
  - `problem-solver` (L3): structured reasoning (5 Whys, Fishbone) for complex bugs
43
43
  - `browser-pilot` (L3): capture browser console errors, network failures, visual bugs
44
44
  - `sequential-thinking` (L3): multi-variable root cause analysis
45
+ - `neural-memory` (L3): after root cause found — capture error pattern for future recognition
45
46
 
46
47
  ## Called By (inbound)
47
48
 
@@ -130,6 +131,10 @@ Narrow to the single actual cause.
130
131
  - Identify the specific file, line number, and code construct responsible
131
132
  - Note any contributing factors (environment, data, timing, config)
132
133
 
134
+ ### Step 5b: Capture Error Pattern
135
+
136
+ Call `neural-memory` (Capture Mode) to save the error pattern: root cause, symptoms, and fix approach. Tag with [project-name, error, technology].
137
+
133
138
  ### Step 6: 3-Fix Escalation Rule
134
139
 
135
140
  <HARD-GATE>
@@ -38,6 +38,7 @@ If unsure whether the test is wrong or the implementation is wrong → call `run
38
38
  - `docs-seeker` (L3): check correct API usage before applying changes
39
39
  - `hallucination-guard` (L3): verify imports after code changes
40
40
  - `scout` (L2): find related code before applying changes
41
+ - `neural-memory` (L3): after fix verified — capture fix pattern (cause → solution)
41
42
 
42
43
  ## Called By (inbound)
43
44
 
@@ -119,6 +120,10 @@ Verify correctness of the changes just made.
119
120
  - Call `rune:docs-seeker` if any external API, library method, or SDK call was added or changed
120
121
  - For complex or risky fixes (auth, data mutation, async logic): call `rune:review` for a full quality check
121
122
 
123
+ ### Step 6b: Capture Fix Pattern
124
+
125
+ Call `neural-memory` (Capture Mode) to save the fix pattern: what broke, why, and how it was fixed. Priority 7 for recurring bugs.
126
+
122
127
  ### Step 7: Report
123
128
 
124
129
  Produce a structured summary of all changes made.
@@ -3,7 +3,7 @@ name: mcp-builder
3
3
  description: Build Model Context Protocol servers from specifications. Generates tool definitions, resource handlers, and test suites for MCP servers in TypeScript or Python (FastMCP).
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.2.0"
6
+ version: "0.3.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: creation
@@ -174,6 +174,52 @@ const envSchema = z.object({
174
174
  export const config = envSchema.parse(process.env);
175
175
  ```
176
176
 
177
+ ### Step 3.5 — Tool Safety Classification
178
+
179
+ Before generating tests, classify every tool as `query` or `mutation`:
180
+
181
+ | Category | Examples | Behavior |
182
+ |---|---|---|
183
+ | `query` | read, list, search, get, fetch | Auto-approve — no confirmation needed |
184
+ | `mutation` | create, update, delete, send, write, publish | Require user confirmation before execution |
185
+
186
+ **Implementation rules:**
187
+
188
+ 1. Add `safety` metadata to each tool definition:
189
+ ```typescript
190
+ export const deleteTool = {
191
+ name: 'delete_user',
192
+ description: '...',
193
+ safety: 'mutation' as const, // ← add this
194
+ inputSchema: z.object({ id: z.string() }),
195
+ async handler(input) { ... },
196
+ };
197
+ ```
198
+
199
+ 2. For every `mutation` tool, generate a preview step that surfaces WHAT WILL HAPPEN before the action runs:
200
+ ```typescript
201
+ // In the handler, before executing:
202
+ if (tool.safety === 'mutation') {
203
+ return {
204
+ content: [{ type: 'text', text:
205
+ `⚠️ Will delete user "${user.name}" (ID: ${input.id}). This cannot be undone.\nConfirm? (yes/no)`
206
+ }],
207
+ requiresConfirmation: true,
208
+ };
209
+ }
210
+ // Proceed only after confirmation received
211
+ ```
212
+
213
+ 3. For Python (FastMCP), add a `@confirm_mutation` decorator or inline guard in the docstring:
214
+ ```python
215
+ @mcp.tool()
216
+ async def delete_user(id: str) -> str:
217
+ """[MUTATION] Delete a user by ID. Will prompt for confirmation before executing."""
218
+ ...
219
+ ```
220
+
221
+ 4. Document the safety classification in the README tool catalog (add a `🔒` badge on mutation tools).
222
+
177
223
  ### Step 4 — Generate Tests
178
224
 
179
225
  For each tool:
@@ -295,6 +341,7 @@ mcp-server-<name>/
295
341
  | Tests mock everything → no real integration coverage | MEDIUM | Generate both unit tests (mocked) and integration test template (real API) |
296
342
  | Generated server doesn't match MCP spec | HIGH | Use official SDK — don't hand-roll protocol handling |
297
343
  | Installation docs only for Claude Code | LOW | Include Cursor/Windsurf config examples too |
344
+ | Mutation tool without confirmation gate | CRITICAL | Step 3.5: classify every tool — any write/delete/send without a preview+confirm step is a footgun |
298
345
 
299
346
  ## Done When
300
347