@rune-kit/rune 2.18.1 → 2.20.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 (34) hide show
  1. package/README.md +22 -7
  2. package/compiler/__tests__/comprehension.test.js +916 -0
  3. package/compiler/__tests__/governance-collector.test.js +376 -0
  4. package/compiler/__tests__/setup.test.js +5 -0
  5. package/compiler/analytics.js +5 -0
  6. package/compiler/bin/rune.js +165 -1
  7. package/compiler/comprehension-client.js +2348 -0
  8. package/compiler/comprehension.js +1254 -0
  9. package/compiler/governance-collector.js +382 -0
  10. package/compiler/schemas/comprehension.schema.json +87 -0
  11. package/compiler/schemas/governance.schema.json +78 -0
  12. package/compiler/transforms/branding.js +1 -1
  13. package/hooks/context-watch/index.cjs +24 -13
  14. package/hooks/hooks.json +2 -2
  15. package/hooks/lib/context-key.cjs +37 -0
  16. package/hooks/metrics-collector/index.cjs +37 -8
  17. package/hooks/pre-tool-guard/index.cjs +44 -0
  18. package/hooks/session-start/index.cjs +4 -10
  19. package/package.json +1 -1
  20. package/skills/adversary/SKILL.md +36 -3
  21. package/skills/adversary/references/cross-model-escalation.md +85 -0
  22. package/skills/adversary/references/reasoning-modes.md +95 -0
  23. package/skills/autopsy/SKILL.md +41 -0
  24. package/skills/ba/SKILL.md +44 -2
  25. package/skills/ba/references/ears-format.md +91 -0
  26. package/skills/brainstorm/SKILL.md +32 -7
  27. package/skills/cook/SKILL.md +8 -1
  28. package/skills/debug/SKILL.md +4 -2
  29. package/skills/deploy/SKILL.md +20 -1
  30. package/skills/deploy/references/observability.md +146 -0
  31. package/skills/graft/SKILL.md +24 -8
  32. package/skills/onboard/SKILL.md +45 -0
  33. package/skills/perf/SKILL.md +4 -1
  34. package/skills/review/SKILL.md +4 -2
@@ -306,6 +306,49 @@ Suggest switching to interview mode (but don't force it) when:
306
306
 
307
307
  Output: `"ℹ️ This project is hard to auto-detect. Run /rune onboard --interview for guided setup."`
308
308
 
309
+ ### Step 6f — Emit comprehension.json
310
+
311
+ Write `.rune/comprehension.json` conforming to `compiler/schemas/comprehension.schema.json`.
312
+ This is ADDITIVE — do not touch any of the Markdown files created above.
313
+
314
+ Populate from the scan data already collected in Steps 2–3:
315
+
316
+ ```json
317
+ {
318
+ "project": "<project name from Step 2>",
319
+ "generated_at": "<ISO 8601 timestamp>",
320
+ "source": "onboard",
321
+ "health_score": null,
322
+ "layers": [
323
+ { "id": "api", "name": "API / Routes", "color": "service" },
324
+ { "id": "service", "name": "Business Logic", "color": "service" },
325
+ { "id": "data", "name": "Data / Storage", "color": "data" },
326
+ { "id": "ui", "name": "UI / Views", "color": "code" },
327
+ { "id": "util", "name": "Utilities", "color": "code" }
328
+ ],
329
+ "domains": [],
330
+ "modules": [
331
+ {
332
+ "id": "<relative file path or module id>",
333
+ "name": "<file or module name>",
334
+ "layer": "<id from layers — best-guess from file path>",
335
+ "type": "file",
336
+ "complexity": "simple",
337
+ "files": 1,
338
+ "summary": "<one-line description>"
339
+ }
340
+ ],
341
+ "edges": []
342
+ }
343
+ ```
344
+
345
+ Rules:
346
+ - `modules[]` — include only the entry points and config files read in Steps 1–3 (5–15 items max). Do not enumerate all project files.
347
+ - `layers[]` — include only layers actually detected; omit unused ones.
348
+ - `edges[]` — leave empty; onboard does not trace cross-file dependencies.
349
+ - `health_score` — set to null; health scoring requires autopsy.
350
+ - If `.rune/comprehension.json` already exists, overwrite it (generated output, not human-written).
351
+
309
352
  ### Step 7 — Commit
310
353
  Use `Bash` to stage and commit the generated files:
311
354
  ```bash
@@ -413,6 +456,7 @@ Known failure modes for this skill. Check these before declaring done.
413
456
  - .rune/ directory initialized with conventions, decisions, progress, session-log, instincts
414
457
  - .rune/DEVELOPER-GUIDE.md written with setup commands from actual scan
415
458
  - All generated commands verified to exist in package.json/Makefile/etc.
459
+ - .rune/comprehension.json written conforming to comprehension.schema.json (project, generated_at, source:"onboard", modules[], edges[])
416
460
  - Onboard Report emitted with Generated + Skipped + Observations sections
417
461
 
418
462
  ## Returns
@@ -424,6 +468,7 @@ Known failure modes for this skill. Check these before declaring done.
424
468
  | Decision log (initialized) | Markdown | `.rune/decisions.md` |
425
469
  | Developer onboarding guide | Markdown | `.rune/DEVELOPER-GUIDE.md` |
426
470
  | Session/progress files | Markdown | `.rune/progress.md`, `.rune/session-log.md` |
471
+ | Comprehension graph | JSON | `.rune/comprehension.json` |
427
472
 
428
473
  ## Cost Profile
429
474
 
@@ -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. Ranks findings by Cost Impact Hierarchy (architecture > data transfer > compute > DB > caching) so fix priority maps to actual unit-cost reduction."
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.4.0"
6
+ version: "0.5.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: quality
@@ -43,6 +43,9 @@ Performance regression gate. Analyzes code changes for patterns that cause measu
43
43
 
44
44
  - `references/cost-reference.md` — Cost priority hierarchy, quick wins checklist, instance right-sizing, data transfer traps, serverless optimization, observability cost control, managed vs self-hosted matrix, unit economics tracking. Load when cost analysis or FinOps context detected.
45
45
  - `references/scalability-reference.md` — Bottleneck identification flow, performance thresholds, API patterns (cursor pagination, rate limiting, circuit breaker, graceful shutdown), caching strategies, queue-based load leveling, concurrency patterns, K8s HPA, CDN headers, load testing. Load when scaling or infrastructure optimization context detected.
46
+ - `../deploy/references/observability.md` — Instrumentation discipline (RED/USE metrics, percentiles-not-averages, cardinality bounds, structured logs, correlation IDs). Load when establishing the *measurement basis* for an optimization — you cannot optimize what you do not measure.
47
+
48
+ **Measure before optimizing.** A perf finding without a metric behind it is a guess. Before recommending a fix, confirm the hotpath actually emits the signal that proves it is slow: RED latency as a **histogram** (read p95/p99 — averages hide the slow tail), bounded label cardinality, and a correlation ID to tie a slow trace to its logs. If the instrumentation does not exist yet, that absence is itself a finding (`UNMEASURED_HOTPATH`). See `../deploy/references/observability.md` for the instrumentation contract.
46
49
 
47
50
  ## Executable Steps
48
51
 
@@ -3,7 +3,7 @@ name: review
3
3
  description: "Code quality review — patterns, security, performance, correctness. Finds bugs, suggests improvements, triggers fix for issues found. Escalates to opus for security-critical code."
4
4
  metadata:
5
5
  author: runedev
6
- version: "1.1.0"
6
+ version: "1.2.0"
7
7
  layer: L2
8
8
  model: sonnet
9
9
  group: development
@@ -181,6 +181,8 @@ Check for security-relevant issues.
181
181
  - If any security-sensitive code found (auth logic, input handling, crypto, payment): call `rune:sentinel` for deep scan
182
182
  - Sentinel escalation is mandatory — do not skip it for auth or crypto code
183
183
 
184
+ **Optional cross-model second opinion** (security-critical / opus-escalated reviews only): a same-family reviewer shares blind spots with the author. For genuinely irreversible or attacker-facing changes (auth, crypto, payment, data migration), you MAY *offer* the user a different-architecture second pass via an external CLI (Gemini/Codex). This is opt-in and interactive-only — **offer, never auto-invoke**; skip in non-interactive runs (CI, `/loop`, scheduled) and announce the skip. If the user accepts, follow the safe transport in `../adversary/references/cross-model-escalation.md` (per-call authorization, read-only sandbox, stdin not inline args), pass the diff + the security contract (not your verdict), and reconcile the reply as data — not a ruling.
185
+
184
186
  ### Step 4.5: API Pit-of-Success Check
185
187
 
186
188
  For code that exposes APIs, shared utilities, or reusable interfaces, evaluate through 3 adversary personas:
@@ -619,7 +621,7 @@ Append to Code Review Report when invoked standalone. Suppress when called as su
619
621
  ```yaml
620
622
  chain_metadata:
621
623
  skill: "rune:review"
622
- version: "1.0.0"
624
+ version: "1.2.0"
623
625
  status: "[DONE | DONE_WITH_CONCERNS]"
624
626
  domain: "[area reviewed]"
625
627
  files_changed: [] # review doesn't change files