@rune-kit/rune 2.4.0 → 2.7.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 (49) hide show
  1. package/README.md +47 -17
  2. package/compiler/__tests__/executive-dashboards.test.js +285 -0
  3. package/compiler/__tests__/inject.test.js +128 -0
  4. package/compiler/__tests__/orchestrators.test.js +151 -0
  5. package/compiler/__tests__/org-templates.test.js +447 -0
  6. package/compiler/__tests__/pack-split.test.js +141 -1
  7. package/compiler/__tests__/parser.test.js +147 -1
  8. package/compiler/__tests__/scripts-bundling.test.js +10 -11
  9. package/compiler/__tests__/skill-index.test.js +218 -0
  10. package/compiler/__tests__/status.test.js +336 -0
  11. package/compiler/__tests__/templates.test.js +245 -0
  12. package/compiler/__tests__/visualizer.test.js +325 -0
  13. package/compiler/adapters/antigravity.js +18 -4
  14. package/compiler/bin/rune.js +90 -1
  15. package/compiler/doctor.js +283 -2
  16. package/compiler/emitter.js +490 -17
  17. package/compiler/parser.js +255 -4
  18. package/compiler/status.js +342 -0
  19. package/compiler/visualizer.js +622 -0
  20. package/hooks/hooks.json +12 -0
  21. package/hooks/intent-router/index.cjs +108 -0
  22. package/hooks/pre-tool-guard/index.cjs +177 -68
  23. package/package.json +63 -63
  24. package/skills/autopsy/SKILL.md +48 -1
  25. package/skills/brainstorm/SKILL.md +2 -0
  26. package/skills/completion-gate/SKILL.md +26 -1
  27. package/skills/context-engine/SKILL.md +93 -2
  28. package/skills/cook/SKILL.md +794 -648
  29. package/skills/debug/SKILL.md +409 -392
  30. package/skills/deploy/SKILL.md +2 -0
  31. package/skills/docs/SKILL.md +28 -3
  32. package/skills/fix/SKILL.md +284 -281
  33. package/skills/mcp-builder/SKILL.md +53 -1
  34. package/skills/onboard/SKILL.md +58 -1
  35. package/skills/perf/SKILL.md +34 -1
  36. package/skills/plan/SKILL.md +372 -342
  37. package/skills/preflight/SKILL.md +396 -360
  38. package/skills/retro/SKILL.md +95 -1
  39. package/skills/review/SKILL.md +535 -489
  40. package/skills/scope-guard/SKILL.md +1 -0
  41. package/skills/scout/SKILL.md +1 -0
  42. package/skills/sentinel/SKILL.md +353 -299
  43. package/skills/sentinel/references/policy-driven-constraints.md +424 -0
  44. package/skills/session-bridge/SKILL.md +58 -2
  45. package/skills/session-bridge/references/evolutionary-memory-patterns.md +312 -0
  46. package/skills/team/SKILL.md +16 -1
  47. package/skills/test/SKILL.md +587 -585
  48. package/skills/verification/SKILL.md +1 -0
  49. package/skills/watchdog/SKILL.md +2 -0
@@ -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.3.0"
6
+ version: "0.4.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: creation
@@ -321,6 +321,58 @@ mcp-server-<name>/
321
321
  - Installation: Claude Code, Cursor, Windsurf config snippets
322
322
  - Configuration reference (env vars with descriptions)
323
323
 
324
+ ## Reference Pattern: Multi-Provider Adapter
325
+
326
+ When the MCP server needs to call multiple AI providers (e.g., both Anthropic and OpenAI), use the **Provider Adapter** pattern to normalize different APIs behind a unified interface.
327
+
328
+ ### Interface
329
+
330
+ ```typescript
331
+ interface ProviderAdapter {
332
+ formatRequest(params: RequestParams): { url: string; init: RequestInit };
333
+ parseResponse(data: unknown): { content: string; usage: TokenUsage | null };
334
+ formatStreamRequest(params: RequestParams): { url: string; init: RequestInit };
335
+ parseSSEEvent(eventType: string, data: string): StreamChunk | null;
336
+ }
337
+ ```
338
+
339
+ ### Discriminated Union for Stream Chunks
340
+
341
+ ```typescript
342
+ type StreamChunk =
343
+ | { type: "thinking"; content: string }
344
+ | { type: "text"; content: string }
345
+ | { type: "done" }
346
+ | { type: "done_with_usage"; usage: TokenUsage }
347
+ | { type: "usage_delta"; inputTokens?: number; outputTokens?: number }
348
+ | { type: "error"; message: string };
349
+ ```
350
+
351
+ ### When to Apply
352
+
353
+ - MCP server wraps multiple AI providers (e.g., a router server that dispatches to Claude, GPT, or local models)
354
+ - MCP server aggregates responses from multiple APIs with different response formats
355
+ - MCP server needs to support streaming from providers with different SSE event schemas
356
+
357
+ ### Key Implementation Notes
358
+
359
+ - Each provider adapter handles its own SSE event types (Anthropic: `content_block_delta`, `message_start`; OpenAI: `response.output_text.delta`, `[DONE]`)
360
+ - Buffer management for SSE: handle incomplete lines, track event types, manage abort signals
361
+ - Provider-specific prompt tuning: some models benefit from additional constraints (e.g., "Maximum 2-3 paragraphs" for verbose models)
362
+ - Per-provider token tracking: normalize different usage reporting formats into a single `TokenUsage` type
363
+
364
+ ### Cost-Aware Model Selection
365
+
366
+ When building MCP servers that call AI providers, support **dual-model configuration** — allow users to specify a primary model for critical operations and a cheaper model for background tasks (summarization, classification, metadata extraction). This avoids burning expensive API credits on tasks that don't need maximum quality.
367
+
368
+ ```typescript
369
+ // config.ts
370
+ const config = {
371
+ primaryModel: process.env.PRIMARY_MODEL || 'claude-sonnet-4-20250514',
372
+ backgroundModel: process.env.BACKGROUND_MODEL || 'claude-haiku-4-5-20251001',
373
+ };
374
+ ```
375
+
324
376
  ## Constraints
325
377
 
326
378
  1. MUST validate all tool inputs with Zod (TS) or Pydantic (Python) — never trust AI-provided inputs
@@ -3,11 +3,12 @@ name: onboard
3
3
  description: Auto-generate project context for AI sessions. Scans codebase, creates CLAUDE.md and .rune/ setup so every future session starts with full context.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.3.0"
6
+ version: "0.4.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: quality
10
10
  tools: "Read, Write, Edit, Glob, Grep"
11
+ emit: project.onboarded
11
12
  ---
12
13
 
13
14
  # onboard
@@ -44,6 +45,7 @@ project/
44
45
  ├── progress.md # Empty, ready for session-bridge
45
46
  ├── session-log.md # Empty, ready for session-bridge
46
47
  ├── instincts.md # Empty, ready for session-bridge instinct learning
48
+ ├── contract.md # Project invariants enforced by cook/sentinel
47
49
  └── DEVELOPER-GUIDE.md # Human-readable onboarding for new developers
48
50
  ```
49
51
 
@@ -105,6 +107,11 @@ Use `Write` to create each file:
105
107
  - `.rune/progress.md` — create with header `# Progress Log` and one placeholder entry
106
108
  - `.rune/session-log.md` — create with header `# Session Log` and current date as first entry
107
109
  - `.rune/instincts.md` — create with header `# Project Instincts` and a description: "Learned trigger→action patterns. Managed by session-bridge. See session-bridge SKILL.md Step 5.7 for format."
110
+ - `.rune/contract.md` — generate a starter contract based on the detected tech stack:
111
+ - Copy structure from `docs/CONTRACT-TEMPLATE.md`
112
+ - Customize rules based on Step 2 findings (e.g., Python → add `no bare except`, Node.js → add `no console.log`, SQL database → add parameterized queries rule)
113
+ - Remove sections that don't apply (e.g., `contract.operations` for a library with no deployed service)
114
+ - The contract is a starting point — tell the user to review and customize it
108
115
 
109
116
  ### Step 5.5 — Load Existing Instincts
110
117
 
@@ -220,6 +227,56 @@ Audit the project's baseline context cost from MCP servers and agent configurati
220
227
 
221
228
  **Skip if**: Total MCP tools ≤80 AND CLAUDE.md ≤150 lines (healthy baseline).
222
229
 
230
+ ### Step 6e — AI-Driven Interview (Optional, User-Initiated)
231
+
232
+ When invoked as `/rune onboard --interview` or when the project is too ambiguous for automated detection (e.g., no package.json, no clear entry point, mixed languages), switch to **conversational onboarding** — the AI asks targeted questions instead of relying solely on file scanning.
233
+
234
+ #### Interview Flow
235
+
236
+ Ask 5-8 questions in sequence, adapting based on answers. Start broad, narrow based on responses:
237
+
238
+ ```
239
+ Q1: "What does this project do in one sentence?"
240
+ → Captures purpose (README may be missing or outdated)
241
+
242
+ Q2: "Who uses this — internal team, external users, or both?"
243
+ → Determines audience, affects DEVELOPER-GUIDE.md tone
244
+
245
+ Q3: "What's the main entry point — where does execution start?"
246
+ → Bypasses file scanning for complex monorepos
247
+
248
+ Q4: "What commands do you use daily? (dev server, tests, build)"
249
+ → Gets verified commands instead of guessing from config files
250
+
251
+ Q5: "Any areas of the codebase you'd warn a new developer about?"
252
+ → Captures tribal knowledge that no scan can detect
253
+
254
+ Q6: "Are there external services this depends on? (databases, APIs, queues)"
255
+ → Maps integration points for Architecture Map
256
+
257
+ Q7: "What's the deployment story — how does code get to production?"
258
+ → Captures CI/CD context
259
+
260
+ Q8 (conditional): "Anything else a new session should know that's not in the code?"
261
+ → Catches edge cases, workarounds, known issues
262
+ ```
263
+
264
+ #### Interview Rules
265
+
266
+ - **Adapt**: Skip questions that were already answered by earlier responses. If Q1 reveals "it's a Next.js app", don't ask about the framework.
267
+ - **Validate**: Cross-reference answers with actual file scan results. If user says "we use Jest" but `vitest.config.ts` exists, ask to clarify.
268
+ - **Merge**: Interview answers supplement (not replace) automated scan. Scan provides facts, interview provides context and intent.
269
+ - **Store**: Save interview responses as high-confidence entries in `.rune/conventions.md` and `.rune/cumulative-notes.md` (tagged `[from-interview]`)
270
+
271
+ #### When to Auto-Suggest Interview
272
+
273
+ Suggest switching to interview mode (but don't force it) when:
274
+ - Step 2 produces 3+ "unknown" fields in tech stack detection
275
+ - Project has no README.md and no package.json/pyproject.toml/Cargo.toml
276
+ - Project appears to be a monorepo with 3+ distinct sub-projects
277
+
278
+ Output: `"ℹ️ This project is hard to auto-detect. Run /rune onboard --interview for guided setup."`
279
+
223
280
  ### Step 7 — Commit
224
281
  Use `Bash` to stage and commit the generated files:
225
282
  ```bash
@@ -3,7 +3,7 @@ name: perf
3
3
  description: Performance regression gate. Detects N+1 queries, sync-in-async, missing indexes, memory leaks, and bundle bloat before they reach production.
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: quality
@@ -242,6 +242,39 @@ Emit structured report:
242
242
  ### Verdict: PASS | WARN | BLOCK
243
243
  ```
244
244
 
245
+ ### Step 8.5 — Token Budget Tracking (AI-Powered Apps)
246
+
247
+ For projects that call AI APIs (detected via imports of `anthropic`, `openai`, `@anthropic-ai/sdk`, `@ai-sdk/core`, `langchain`, `llamaindex`, or `fastmcp`), audit token usage patterns per operation type.
248
+
249
+ **Scan for:**
250
+
251
+ | Pattern | Finding | Impact |
252
+ |---------|---------|--------|
253
+ | AI call inside a loop without batching | `TOKEN_LOOP — [file:line] — AI call in loop over [collection] — batch or parallelize` | Cost scales linearly with collection size |
254
+ | No token usage tracking | `NO_TOKEN_TRACKING — [file:line] — AI response usage not captured — add cost logging` | Invisible spend, no budget control |
255
+ | Expensive model for simple tasks | `MODEL_MISMATCH — [file:line] — using [opus/gpt-4] for [classification/extraction] — use [haiku/gpt-4.1-mini]` | 10-30x cost difference for same result |
256
+ | Missing max_tokens on open-ended prompts | `UNBOUNDED_TOKENS — [file:line] — no max_tokens on [call] — add limit to prevent runaway cost` | Single call can consume entire budget |
257
+ | Duplicate AI calls for same input | `DUPLICATE_AI_CALL — [file:line] — same prompt sent to [provider] without caching — add response cache` | Wasted tokens on redundant calls |
258
+
259
+ **Per-Operation Cost Awareness:**
260
+
261
+ When token tracking IS present, analyze the operation type breakdown:
262
+
263
+ ```
264
+ Operation Type Avg Tokens Frequency Monthly Est.
265
+ ─────────────────────────────────────────────────────────────
266
+ Chat (primary) 2,500 in/800 out high $X.XX
267
+ Background notes 500 in/200 out per-chat $X.XX
268
+ Summarization 1,500 in/300 out periodic $X.XX
269
+ Classification 200 in/50 out high $X.XX
270
+ ─────────────────────────────────────────────────────────────
271
+ Total estimated monthly $X.XX
272
+ ```
273
+
274
+ **Report this under a `### AI Token Budget` subsection** in the Perf Report. Only include when AI API usage detected — skip entirely for non-AI projects.
275
+
276
+ **Key insight**: The most impactful optimization is often **model selection per operation** — using a cheaper model for background tasks (summarization, classification, metadata extraction) while reserving expensive models for primary user-facing interactions. A 10x cost reduction on 60% of calls = 6x overall savings.
277
+
245
278
  ## Output Format
246
279
 
247
280
  ```