@rune-kit/rune 2.6.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 (38) hide show
  1. package/README.md +17 -6
  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__/parser.test.js +201 -147
  7. package/compiler/__tests__/skill-index.test.js +218 -218
  8. package/compiler/__tests__/status.test.js +336 -0
  9. package/compiler/__tests__/templates.test.js +245 -0
  10. package/compiler/__tests__/visualizer.test.js +325 -0
  11. package/compiler/adapters/antigravity.js +71 -71
  12. package/compiler/bin/rune.js +444 -355
  13. package/compiler/doctor.js +272 -1
  14. package/compiler/emitter.js +939 -678
  15. package/compiler/parser.js +498 -267
  16. package/compiler/status.js +342 -0
  17. package/compiler/visualizer.js +622 -0
  18. package/package.json +1 -1
  19. package/skills/autopsy/SKILL.md +48 -1
  20. package/skills/completion-gate/SKILL.md +26 -1
  21. package/skills/context-engine/SKILL.md +93 -2
  22. package/skills/cook/SKILL.md +137 -4
  23. package/skills/debug/SKILL.md +16 -1
  24. package/skills/docs/SKILL.md +28 -3
  25. package/skills/fix/SKILL.md +2 -1
  26. package/skills/mcp-builder/SKILL.md +53 -1
  27. package/skills/onboard/SKILL.md +51 -1
  28. package/skills/perf/SKILL.md +34 -1
  29. package/skills/plan/SKILL.md +29 -1
  30. package/skills/preflight/SKILL.md +35 -1
  31. package/skills/retro/SKILL.md +95 -1
  32. package/skills/review/SKILL.md +45 -1
  33. package/skills/scope-guard/SKILL.md +1 -0
  34. package/skills/sentinel/SKILL.md +35 -1
  35. package/skills/sentinel/references/policy-driven-constraints.md +424 -0
  36. package/skills/session-bridge/SKILL.md +57 -2
  37. package/skills/session-bridge/references/evolutionary-memory-patterns.md +312 -0
  38. package/skills/team/SKILL.md +15 -1
@@ -0,0 +1,424 @@
1
+ > Activate when: agent needs to parse a policy document and auto-enforce structured constraints before commit, tool use, or code generation.
2
+
3
+ # Policy-Driven Constraints
4
+
5
+ Sentinel normally requires a developer to manually configure what is blocked. Policy-driven constraints flip that: upload a document — security policy, compliance requirements, team standards — and Sentinel parses it into enforced rules automatically.
6
+
7
+ ---
8
+
9
+ ## 1. The Pattern: Document → Constraints
10
+
11
+ **Traditional flow:**
12
+ Developer writes constraint config → commits it → Sentinel enforces it.
13
+
14
+ **Policy-driven flow:**
15
+ Team uploads existing policy doc (often already written for audit purposes) → LLM parses structured rules → Sentinel enforces them immediately, with no manual translation.
16
+
17
+ **Why this matters:**
18
+ - Compliance docs already exist. They should not need to be re-expressed as code.
19
+ - Rules stay in sync: update the policy doc → re-parse → constraints update.
20
+ - Non-engineers can author constraints by writing plain policy documents.
21
+
22
+ **Production use cases:**
23
+ - Security policy → agent cannot write code that logs PII fields
24
+ - Data handling requirements → agent blocks unencrypted data storage patterns
25
+ - Team coding standards → agent enforces style and structure rules
26
+ - Temporary lockdown doc → agent restricted to read-only operations during incident
27
+
28
+ ---
29
+
30
+ ## 2. Policy Document Parsing Pipeline
31
+
32
+ ```
33
+ [Policy Document]
34
+
35
+ [1. Ingest] — markdown, PDF, plain text, or URL
36
+
37
+ [2. Extract] — LLM identifies constraint candidates
38
+
39
+ [3. Structure] — normalize to Constraint Schema (below)
40
+
41
+ [4. Validate] — check for conflicts, missing patterns, ambiguous scope
42
+
43
+ [5. Persist] — save to .rune/sentinel/policies/[policy-name].yaml
44
+
45
+ [6. Activate] — Sentinel loads on every check cycle
46
+ ```
47
+
48
+ **Step 2 prompt pattern (internal):**
49
+ ```
50
+ Read the following policy document and extract all rules that restrict, require,
51
+ or warn about specific actions, code patterns, or data handling.
52
+ For each rule, output a structured constraint using the schema below.
53
+ Ignore procedural text, approvals, and organizational information.
54
+ ```
55
+
56
+ **Constraint Schema:**
57
+ ```yaml
58
+ - id: constraint-001
59
+ source: "Security Policy v3.2, Section 4.1"
60
+ type: block | warn | require
61
+ scope: file_pattern | tool | output | code_pattern
62
+ rule: "description of what is blocked/warned/required"
63
+ pattern: "regex or glob if applicable"
64
+ severity: critical | high | medium | low
65
+ active: true
66
+ ```
67
+
68
+ **Persisted policy file location:**
69
+ ```
70
+ .rune/sentinel/policies/
71
+ security-baseline.yaml
72
+ code-quality.yaml
73
+ compliance-soc2.yaml
74
+ [custom-policy-name].yaml
75
+ ```
76
+
77
+ ---
78
+
79
+ ## 3. Constraint Types
80
+
81
+ ### block — hard stop
82
+
83
+ Agent cannot proceed. Action is rejected with explanation.
84
+
85
+ ```yaml
86
+ - id: block-001
87
+ type: block
88
+ scope: file_pattern
89
+ rule: "Never commit credential or secret files"
90
+ pattern: "**/{*.env,.env*,*credentials*,*secret*,*.pem,*.key}"
91
+ severity: critical
92
+
93
+ - id: block-002
94
+ type: block
95
+ scope: code_pattern
96
+ rule: "No hardcoded API keys or tokens in source"
97
+ pattern: "(sk-|pk-|AIza|AKIA|ghp_)[A-Za-z0-9]{16,}"
98
+ severity: critical
99
+
100
+ - id: block-003
101
+ type: block
102
+ scope: code_pattern
103
+ rule: "No eval() — remote code execution risk"
104
+ pattern: "\\beval\\s*\\("
105
+ severity: high
106
+
107
+ - id: block-004
108
+ type: block
109
+ scope: code_pattern
110
+ rule: "No SQL string concatenation — injection risk"
111
+ pattern: "(query|sql)\\s*[+]=.*\\$\\{|f['\"].*SELECT.*\\{"
112
+ severity: critical
113
+
114
+ - id: block-005
115
+ type: block
116
+ scope: tool
117
+ rule: "No force-push to protected branches"
118
+ pattern: "git push --force"
119
+ severity: critical
120
+ ```
121
+
122
+ ### warn — flag but allow
123
+
124
+ Sentinel surfaces the issue. Human decides whether to proceed.
125
+
126
+ ```yaml
127
+ - id: warn-001
128
+ type: warn
129
+ scope: code_pattern
130
+ rule: "TODO/FIXME comments should not ship in committed code"
131
+ pattern: "\\b(TODO|FIXME|HACK|XXX)\\b"
132
+ severity: low
133
+
134
+ - id: warn-002
135
+ type: warn
136
+ scope: output
137
+ rule: "Functions exceeding 100 lines reduce maintainability"
138
+ pattern: "function_length > 100"
139
+ severity: medium
140
+
141
+ - id: warn-003
142
+ type: warn
143
+ scope: code_pattern
144
+ rule: "Async functions without error handling may fail silently"
145
+ pattern: "async\\s+\\w+[^{]*\\{(?![\\s\\S]*try)"
146
+ severity: medium
147
+ ```
148
+
149
+ ### require — must be present before proceeding
150
+
151
+ Agent is blocked until the required artifact exists.
152
+
153
+ ```yaml
154
+ - id: require-001
155
+ type: require
156
+ scope: output
157
+ rule: "Every new function must have a corresponding test"
158
+ pattern: "test_file_exists_for_new_functions"
159
+ severity: high
160
+
161
+ - id: require-002
162
+ type: require
163
+ scope: code_pattern
164
+ rule: "All Python functions must have type hints"
165
+ pattern: "def \\w+\\([^)]*:\\s*\\w"
166
+ severity: medium
167
+
168
+ - id: require-003
169
+ type: require
170
+ scope: file_pattern
171
+ rule: "User-facing changes require a CHANGELOG entry"
172
+ pattern: "CHANGELOG.md"
173
+ severity: medium
174
+ ```
175
+
176
+ ---
177
+
178
+ ## 4. Scope Resolution
179
+
180
+ How Sentinel matches a constraint against an agent action:
181
+
182
+ | Scope | Matches Against | Example |
183
+ |-------|----------------|---------|
184
+ | `file_pattern` | Glob on paths being created/edited/deleted | `**/*.env` |
185
+ | `tool` | Tool name + arguments being invoked | `Bash` with `rm -rf` |
186
+ | `output` | Full text of code being written | scan for `eval(` |
187
+ | `code_pattern` | Regex against generated code diff | `SELECT.*\+.*userId` |
188
+
189
+ **Priority order when multiple constraints match:**
190
+ ```
191
+ block > require > warn
192
+ ```
193
+
194
+ **Multiple policies stacking:**
195
+ All active policy files in `.rune/sentinel/policies/` are loaded and merged. Constraints with the same `id` in a project-level policy override org-level. All `block` constraints from any policy are enforced — there is no way to un-block at a lower tier.
196
+
197
+ **Conflict resolution:**
198
+ If two policies disagree (one requires a pattern, another blocks it), Sentinel halts and surfaces the conflict. It does not silently pick a winner.
199
+
200
+ ---
201
+
202
+ ## 5. Dynamic Skill Disabling
203
+
204
+ A policy document can disable entire Rune skills, not just code patterns.
205
+
206
+ **How it works:**
207
+ 1. Policy document states a prohibition (e.g., "no automated deployments during freeze")
208
+ 2. Parser extracts a `disable_skill` directive
209
+ 3. Sentinel checks active disabled-skills list before skill-router routes any task
210
+ 4. Disabled skill returns a structured refusal explaining the policy source
211
+
212
+ **Disabled skills config:**
213
+ ```yaml
214
+ # .rune/sentinel/disabled-skills.yaml
215
+ disabled:
216
+ - skill: rune:deploy
217
+ reason: "Code freeze in effect — Security Policy v4, Section 2.3"
218
+ policy_source: "compliance-soc2.yaml"
219
+ expires: "2026-04-15T00:00:00Z" # optional
220
+
221
+ - skill: rune:db
222
+ reason: "Production database access restricted to SRE team only"
223
+ policy_source: "security-baseline.yaml"
224
+ expires: null # permanent until policy updated
225
+ ```
226
+
227
+ **Refusal message format (returned to agent):**
228
+ ```
229
+ Skill rune:deploy is currently disabled.
230
+ Reason: Code freeze in effect — Security Policy v4, Section 2.3
231
+ Source: compliance-soc2.yaml
232
+ To re-enable: update or remove the policy, or wait for expiry (2026-04-15).
233
+ ```
234
+
235
+ ---
236
+
237
+ ## 6. Policy Lifecycle
238
+
239
+ **Versioning:**
240
+ Each policy file includes a version field. Re-parsing a document creates a new version; previous versions are retained in `.rune/sentinel/policies/history/`.
241
+
242
+ ```yaml
243
+ # Header of every policy file
244
+ meta:
245
+ policy_name: security-baseline
246
+ version: "1.2.0"
247
+ parsed_from: "docs/security-policy.md"
248
+ parsed_at: "2026-03-31T10:00:00Z"
249
+ active: true
250
+ expires: null
251
+ ```
252
+
253
+ **Override hierarchy:**
254
+ ```
255
+ org-level (default) → project-level (overrides org) → session-level (temporary)
256
+ ```
257
+ Configurable per project in `.rune/config.yaml` via `policy_override_direction`.
258
+
259
+ **Expiry:**
260
+ Policies and individual constraints support `expires` timestamps. Sentinel checks expiry on load and deactivates expired rules automatically. Useful for temporary incident lockdowns.
261
+
262
+ **Audit trail:**
263
+ Every enforcement event is appended to `.rune/sentinel/audit.log`:
264
+ ```
265
+ 2026-03-31T10:42:11Z | BLOCK | constraint-002 | Bash | "git push --force origin main" | security-baseline v1.2.0
266
+ 2026-03-31T10:43:05Z | WARN | warn-001 | Edit | src/api/users.ts | TODO comment on line 47
267
+ ```
268
+
269
+ ---
270
+
271
+ ## 7. Bootstrap Policies
272
+
273
+ Ready-to-use templates. Copy to `.rune/sentinel/policies/` to activate.
274
+
275
+ **security-baseline.yaml:**
276
+ ```yaml
277
+ meta:
278
+ policy_name: security-baseline
279
+ version: "1.0.0"
280
+ active: true
281
+ constraints:
282
+ - id: sb-001
283
+ type: block
284
+ scope: file_pattern
285
+ rule: "No credential or secret files committed"
286
+ pattern: "**/{*.env,.env*,*credentials*,*secret*,*.pem,*.key,*.p12}"
287
+ severity: critical
288
+ - id: sb-002
289
+ type: block
290
+ scope: code_pattern
291
+ rule: "No hardcoded secrets"
292
+ pattern: "(password|api_key|secret|token)\\s*=\\s*['\"][^'\"]{8,}"
293
+ severity: critical
294
+ - id: sb-003
295
+ type: block
296
+ scope: code_pattern
297
+ rule: "No eval() usage"
298
+ pattern: "\\beval\\s*\\("
299
+ severity: high
300
+ - id: sb-004
301
+ type: block
302
+ scope: code_pattern
303
+ rule: "No SQL string concatenation"
304
+ pattern: "f['\"]\\s*SELECT|['\"]\\s*\\+\\s*(user|id|input)"
305
+ severity: critical
306
+ - id: sb-005
307
+ type: block
308
+ scope: tool
309
+ rule: "No force-push"
310
+ pattern: "push --force"
311
+ severity: critical
312
+ ```
313
+
314
+ **code-quality.yaml:**
315
+ ```yaml
316
+ meta:
317
+ policy_name: code-quality
318
+ version: "1.0.0"
319
+ active: true
320
+ constraints:
321
+ - id: cq-001
322
+ type: warn
323
+ scope: code_pattern
324
+ rule: "No TODO/FIXME in committed code"
325
+ pattern: "\\b(TODO|FIXME|HACK)\\b"
326
+ severity: low
327
+ - id: cq-002
328
+ type: require
329
+ scope: output
330
+ rule: "New functions require tests"
331
+ pattern: "test_coverage_for_new_symbols"
332
+ severity: high
333
+ - id: cq-003
334
+ type: require
335
+ scope: code_pattern
336
+ rule: "Python functions require type hints"
337
+ pattern: "def \\w+\\("
338
+ severity: medium
339
+ - id: cq-004
340
+ type: warn
341
+ scope: code_pattern
342
+ rule: "No print() in production Python — use logger"
343
+ pattern: "\\bprint\\s*\\("
344
+ severity: medium
345
+ ```
346
+
347
+ **compliance-soc2.yaml:**
348
+ ```yaml
349
+ meta:
350
+ policy_name: compliance-soc2
351
+ version: "1.0.0"
352
+ active: true
353
+ constraints:
354
+ - id: soc2-001
355
+ type: block
356
+ scope: code_pattern
357
+ rule: "No PII fields in logs — email, SSN, card numbers"
358
+ pattern: "log(ger)?\\.(info|debug|warn|error).*\\b(email|ssn|card_number|password)\\b"
359
+ severity: critical
360
+ - id: soc2-002
361
+ type: block
362
+ scope: code_pattern
363
+ rule: "No unencrypted data-at-rest patterns"
364
+ pattern: "open\\([^)]+,\\s*['\"]w['\"]\\)(?![\\s\\S]{0,200}encrypt)"
365
+ severity: critical
366
+ - id: soc2-003
367
+ type: require
368
+ scope: output
369
+ rule: "All data access must be logged for audit trail"
370
+ pattern: "audit_log_present_for_data_access"
371
+ severity: high
372
+ - id: soc2-004
373
+ type: block
374
+ scope: code_pattern
375
+ rule: "No debug endpoints in production code"
376
+ pattern: "route.*/(debug|test|dev)\\b"
377
+ severity: high
378
+ ```
379
+
380
+ ---
381
+
382
+ ## Signal Integration
383
+
384
+ ```yaml
385
+ skill: sentinel
386
+ version: "0.9.0"
387
+
388
+ signals:
389
+ emit:
390
+ - sentinel.constraint.blocked
391
+ # payload: { constraint_id, scope, matched_pattern, action_attempted, policy_source }
392
+ - sentinel.constraint.warned
393
+ # payload: { constraint_id, scope, message, severity }
394
+ - sentinel.constraint.required_missing
395
+ # payload: { constraint_id, missing_artifact, blocking_action }
396
+ - sentinel.policy.loaded
397
+ # payload: { policy_name, version, constraint_count, active }
398
+ - sentinel.policy.expired
399
+ # payload: { policy_name, expired_at }
400
+ - sentinel.skill.disabled
401
+ # payload: { skill, reason, policy_source, expires }
402
+ - sentinel.audit.logged
403
+ # payload: { event_type, constraint_id, tool, detail, timestamp }
404
+
405
+ listen:
406
+ - cook.phase.starting
407
+ # re-run constraint load in case policies changed between phases
408
+ - skill_router.skill.requested
409
+ # intercept before routing — check disabled-skills list
410
+ - preflight.check.requested
411
+ # piggyback on preflight to surface active policy summary
412
+ - scaffold.file.creating
413
+ # validate new file paths against file_pattern constraints before write
414
+
415
+ triggers:
416
+ - on: pre_commit
417
+ action: run all block + require constraints against staged diff
418
+ - on: tool_use
419
+ action: check tool constraints before allowing Bash/Write/Edit invocation
420
+ - on: policy_file_changed
421
+ action: reload active constraint set, emit sentinel.policy.loaded
422
+ - on: session_start
423
+ action: load all active policies, log count, warn on expired entries
424
+ ```
@@ -3,7 +3,7 @@ name: session-bridge
3
3
  description: Universal context persistence across sessions. Auto-saves decisions, conventions, and progress to .rune/ files. Loads state at session start. Use when any skill makes architectural decisions or establishes patterns that must survive session boundaries.
4
4
  metadata:
5
5
  author: runedev
6
- version: "0.4.0"
6
+ version: "0.5.0"
7
7
  layer: L3
8
8
  model: haiku
9
9
  group: state
@@ -44,7 +44,8 @@ Solve the #1 developer complaint: context loss across sessions. Session-bridge a
44
44
  ├── conventions.md — Established patterns & style
45
45
  ├── progress.md — Task progress tracker
46
46
  ├── session-log.md — Brief log of each session
47
- └── instincts.md — Learned project-specific patterns (trigger→action)
47
+ ├── instincts.md — Learned project-specific patterns (trigger→action)
48
+ └── cumulative-notes.md — Living project understanding (profile, themes, relationships)
48
49
  ```
49
50
 
50
51
  ## Execution
@@ -198,6 +199,58 @@ Extract atomic "instincts" — learned trigger→action patterns — from this s
198
199
 
199
200
  **Max instincts**: Keep `.rune/instincts.md` under 20 entries. When full, evict the lowest-confidence entry.
200
201
 
202
+ #### Step 5.9 — Cumulative Project Notes (Structured Memory)
203
+
204
+ Maintain a running **cumulative notes** file at `.rune/cumulative-notes.md` that evolves across sessions. Unlike `progress.md` (which tracks tasks) or `decisions.md` (which logs choices), cumulative notes capture the **living understanding** of the project — patterns learned, relationships discovered, recurring themes, and open threads.
205
+
206
+ **Format** — use these fixed sections (add content, never remove prior entries):
207
+
208
+ ```markdown
209
+ # Cumulative Project Notes
210
+
211
+ ## Project Profile
212
+ - [Core purpose of the project — 1 sentence]
213
+ - [Primary users/audience]
214
+ - [Key technical constraints — e.g., "must run offline", "latency-critical", "multi-tenant"]
215
+
216
+ ## Architecture Map
217
+ - [Key modules and their responsibilities — discovered over sessions]
218
+ - [Critical data flows — e.g., "user input → validation → API → DB → cache invalidation"]
219
+ - [Integration points — external APIs, services, databases]
220
+
221
+ ## Recurring Themes
222
+ - [Patterns that keep coming up across sessions — e.g., "auth edge cases", "migration complexity"]
223
+ - [Common failure modes — what breaks and why]
224
+ - [Technical debt hotspots — areas that repeatedly cause issues]
225
+
226
+ ## Active Topics
227
+ - [What's currently being worked on — updated each session]
228
+ - [Open questions that haven't been resolved yet]
229
+ - [Experiments in progress]
230
+
231
+ ## Relationship Map
232
+ - [Key files and their dependencies — "changing X requires updating Y"]
233
+ - [People and their areas — "Alice owns auth, Bob owns payments"]
234
+ - [External service dependencies — "Stripe webhook → order.complete handler"]
235
+
236
+ ## Follow-Up Items
237
+ - [ ] [Things noted but not yet addressed — carry forward until done]
238
+ - [ ] [Ideas that came up during work but were out of scope]
239
+
240
+ ## Attention Points
241
+ - [Things the next session should be aware of — fragile areas, pending PRs, deadlines]
242
+ - [Temporary workarounds that need proper fixes]
243
+ ```
244
+
245
+ **Update rules:**
246
+ - **Create** the file on first session-bridge save if it doesn't exist
247
+ - **Append** to existing sections — never overwrite prior entries (they represent accumulated knowledge)
248
+ - **Prune** entries older than 60 days in Recurring Themes and Relationship Map — these may be stale
249
+ - **Move** completed Follow-Up Items to a `## Resolved` section at the bottom (keep last 10)
250
+ - **Keep under 200 lines** — if approaching limit, summarize older entries in each section
251
+
252
+ **Why**: Individual state files (decisions.md, progress.md) capture discrete events. Cumulative notes capture the **emergent understanding** that develops over many sessions — the kind of knowledge that's lost when context resets. This is the project's "institutional memory."
253
+
201
254
  #### Step 6 — Cross-Project Knowledge Extraction (Neural Memory Bridge)
202
255
 
203
256
  Before committing, extract generalizable patterns from this session for cross-project reuse:
@@ -264,6 +317,7 @@ Read: .rune/decisions.md
264
317
  Read: .rune/conventions.md
265
318
  Read: .rune/progress.md
266
319
  Read: .rune/session-log.md
320
+ Read: .rune/cumulative-notes.md
267
321
  ```
268
322
 
269
323
  #### Step 3 — Summarize
@@ -275,6 +329,7 @@ Present the loaded context to the agent in a structured summary:
275
329
  > - Key decisions: [last 3 entries from decisions.md]
276
330
  > - Active conventions: [count from conventions.md]
277
331
  > - Current progress: [in-progress and blocked items from progress.md]
332
+ > - Project understanding: [Active Topics + Attention Points from cumulative-notes.md]
278
333
  > - Next task: [first item under "Next Session Should" from progress.md]
279
334
 
280
335
  #### Step 4 — Resume