@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.
- package/README.md +22 -7
- package/compiler/__tests__/comprehension.test.js +916 -0
- package/compiler/__tests__/governance-collector.test.js +376 -0
- package/compiler/__tests__/setup.test.js +5 -0
- package/compiler/analytics.js +5 -0
- package/compiler/bin/rune.js +165 -1
- package/compiler/comprehension-client.js +2348 -0
- package/compiler/comprehension.js +1254 -0
- package/compiler/governance-collector.js +382 -0
- package/compiler/schemas/comprehension.schema.json +87 -0
- package/compiler/schemas/governance.schema.json +78 -0
- package/compiler/transforms/branding.js +1 -1
- package/hooks/context-watch/index.cjs +24 -13
- package/hooks/hooks.json +2 -2
- package/hooks/lib/context-key.cjs +37 -0
- package/hooks/metrics-collector/index.cjs +37 -8
- package/hooks/pre-tool-guard/index.cjs +44 -0
- package/hooks/session-start/index.cjs +4 -10
- package/package.json +1 -1
- package/skills/adversary/SKILL.md +36 -3
- package/skills/adversary/references/cross-model-escalation.md +85 -0
- package/skills/adversary/references/reasoning-modes.md +95 -0
- package/skills/autopsy/SKILL.md +41 -0
- package/skills/ba/SKILL.md +44 -2
- package/skills/ba/references/ears-format.md +91 -0
- package/skills/brainstorm/SKILL.md +32 -7
- package/skills/cook/SKILL.md +8 -1
- package/skills/debug/SKILL.md +4 -2
- package/skills/deploy/SKILL.md +20 -1
- package/skills/deploy/references/observability.md +146 -0
- package/skills/graft/SKILL.md +24 -8
- package/skills/onboard/SKILL.md +45 -0
- package/skills/perf/SKILL.md +4 -1
- package/skills/review/SKILL.md +4 -2
package/skills/ba/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: ba
|
|
|
3
3
|
description: "Business Analyst agent. Use when starting a new feature requiring requirements elicitation BEFORE plan or cook. Asks probing questions, identifies hidden requirements, maps stakeholders, defines scope boundaries, and produces a structured Requirements Document that plan and cook consume."
|
|
4
4
|
metadata:
|
|
5
5
|
author: runedev
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.1.0"
|
|
7
7
|
layer: L2
|
|
8
8
|
model: opus
|
|
9
9
|
group: creation
|
|
@@ -44,6 +44,7 @@ Output is a Requirements Document → hand off to rune:plan for implementation p
|
|
|
44
44
|
- `cook` (L1): before Phase 2 PLAN, when task is non-trivial
|
|
45
45
|
- `scaffold` (L1): Phase 1, before any project generation
|
|
46
46
|
- `plan` (L2): when plan receives vague requirements
|
|
47
|
+
- `brainstorm` (L2): standalone ideation that picked an approach for a new feature with no spec — hands the chosen approach to `ba` for requirements before `plan`
|
|
47
48
|
- `mcp-builder` (L2): requirements elicitation before MCP server design
|
|
48
49
|
- User: `/rune ba` direct invocation
|
|
49
50
|
|
|
@@ -389,6 +390,7 @@ Run each, label verdict 🟢 pass / 🟡 warn / 🔴 fail:
|
|
|
389
390
|
| # | Check | 🔴 Fail | 🟢 Pass |
|
|
390
391
|
|---|-------|---------|---------|
|
|
391
392
|
| 1 | Every Acceptance Criterion traces to a User Story | AC orphaned | 1:N mapping clear |
|
|
393
|
+
| 1b | Every EARS `FR-n` (Step 4.5) traces up to a User Story AND down to an AC | FR has no AC (untested promise) or no story (orphan behavior) | FR → story + AC both present |
|
|
392
394
|
| 2 | Every Business Rule (Q5) is enforced in an AC or Exception Flow | Rule has no enforcement path | Rule → specific AC or exception |
|
|
393
395
|
| 3 | Scope IN ∩ Scope OUT = ∅ | Direct overlap in phrasing | Sets disjoint |
|
|
394
396
|
| 4 | Every user-story flow has a terminal state | State loop without exit condition | Terminal state explicit |
|
|
@@ -402,6 +404,7 @@ Run each, label verdict 🟢 pass / 🟡 warn / 🔴 fail:
|
|
|
402
404
|
```
|
|
403
405
|
Logic Consistency Report:
|
|
404
406
|
1. AC → User Story: 🟢 all AC trace to US-1 or US-2
|
|
407
|
+
1b. EARS FR → story+AC: 🟢 FR-1..FR-5 each map to a story and an AC
|
|
405
408
|
2. Business rule → AC: 🟡 "no duplicate emails" cited — exception flow missing
|
|
406
409
|
3. Scope disjoint: 🟢
|
|
407
410
|
4. Terminal states: 🟢
|
|
@@ -441,6 +444,36 @@ Based on all gathered information, produce:
|
|
|
441
444
|
**Dependencies** (things that must exist before we can build):
|
|
442
445
|
- [APIs, services, libraries, access, existing code]
|
|
443
446
|
|
|
447
|
+
### Step 4.5 — Functional Requirements (EARS)
|
|
448
|
+
<MUST-READ path="references/ears-format.md" trigger="when writing the functional-requirements section for a Feature/Integration/Greenfield requirement"/>
|
|
449
|
+
|
|
450
|
+
Translate each in-scope item (Step 4) into atomic, testable **functional requirements** using EARS (Easy Approach to Requirements Syntax). EARS sits between user stories (WHY) and acceptance criteria (HOW we prove it) — it names exactly WHAT the system shall do, with an explicit trigger or condition.
|
|
451
|
+
|
|
452
|
+
Pick the simplest EARS template that fits each behavior; give each a stable ID (`FR-1`, `FR-2`, …):
|
|
453
|
+
|
|
454
|
+
| Type | Template |
|
|
455
|
+
|------|----------|
|
|
456
|
+
| Ubiquitous | The `<system>` shall `<response>`. |
|
|
457
|
+
| Event-driven | When `<trigger>`, the `<system>` shall `<response>`. |
|
|
458
|
+
| State-driven | While `<state>`, the `<system>` shall `<response>`. |
|
|
459
|
+
| Optional | Where `<feature is included>`, the `<system>` shall `<response>`. |
|
|
460
|
+
| Unwanted | If `<unwanted condition>`, then the `<system>` shall `<response>`. |
|
|
461
|
+
| Complex | While `<state>`, when `<trigger>`, the `<system>` shall `<response>`. |
|
|
462
|
+
|
|
463
|
+
```
|
|
464
|
+
FR-1 The API shall return responses in JSON.
|
|
465
|
+
FR-2 When a request omits a valid auth token, the API shall respond with HTTP 401.
|
|
466
|
+
FR-3 If the payment provider times out, then the system shall mark the order pending and queue a retry.
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
Rules (full guidance in [references/ears-format.md](references/ears-format.md)):
|
|
470
|
+
- **One `shall` per requirement** — compound "shall do A and B" splits into two `FR-n`.
|
|
471
|
+
- **Named subject, testable response** — never "it shall handle gracefully". Move measurable limits into the response; pure performance targets stay in NFRs (Step 6).
|
|
472
|
+
- **Don't smuggle HOW** — observable behavior only; leave implementation to `plan`.
|
|
473
|
+
- Every `FR-n` traces up to a User Story and down to an Acceptance Criterion (checked in Step 3.6).
|
|
474
|
+
|
|
475
|
+
**Skip EARS** for Bug Fix and Refactor types (no new behavior to specify). For plumbing/integration, a few event-driven + unwanted-behavior lines suffice — don't pad with ubiquitous filler. EARS is a format recommendation, not a gate.
|
|
476
|
+
|
|
444
477
|
### Step 5 — User Stories & Acceptance Criteria
|
|
445
478
|
|
|
446
479
|
For each in-scope feature, generate:
|
|
@@ -456,6 +489,7 @@ Rules:
|
|
|
456
489
|
- Primary user story first, then edge cases
|
|
457
490
|
- Every user story has at least 2 acceptance criteria (happy path + error)
|
|
458
491
|
- Acceptance criteria are TESTABLE — they become test cases in Phase 3
|
|
492
|
+
- Each AC proves a specific `FR-n` from Step 4.5 — cite it (`AC-1.2 → FR-3`). Every unwanted-behavior `FR` (the `If …` lines) needs an error-path AC; that's where EARS earns its keep
|
|
459
493
|
|
|
460
494
|
### Step 6 — Non-Functional Requirements (NFRs)
|
|
461
495
|
|
|
@@ -540,6 +574,9 @@ Created: [date] | BA Session: [summary]
|
|
|
540
574
|
## User Stories
|
|
541
575
|
[from Step 5]
|
|
542
576
|
|
|
577
|
+
## Functional Requirements
|
|
578
|
+
[from Step 4.5 — EARS-format FR-n list; skip for Bug Fix/Refactor]
|
|
579
|
+
|
|
543
580
|
## Scope
|
|
544
581
|
### In Scope
|
|
545
582
|
### Out of Scope
|
|
@@ -718,6 +755,10 @@ Known failure modes for this skill. Check these before declaring done.
|
|
|
718
755
|
| All three tiers have same resources/effort | MEDIUM | Quick Win should be low-effort. If all tiers need "2 engineers, 3 months" → re-scope Quick Win to something achievable in 1 sprint |
|
|
719
756
|
| Skipping Logic Consistency check because ambiguity is low | CRITICAL | Step 3.6 HARD-GATE: clarity ≠ consistency. A 90% clarity spec can still contain pairwise contradictions (scope IN/OUT overlap, rules with no enforcement, orphan ACs) |
|
|
720
757
|
| Handing off to plan with unresolved 🔴 consistency fails | CRITICAL | Step 3.6 gate: 1+ 🔴 = BLOCK. 🟡 allowed only when logged as Risk in requirements.md |
|
|
758
|
+
| Vague functional requirements ("system shall be fast/user-friendly") instead of EARS | MEDIUM | Step 4.5: every FR uses an EARS template with a named subject + testable response; vague targets move to NFRs (Step 6) |
|
|
759
|
+
| Compound EARS requirement ("shall do A and B and C") hiding untested behavior | MEDIUM | Step 4.5: one `shall` per `FR-n` — split compounds so each behavior gets its own AC |
|
|
760
|
+
| EARS `FR-n` with no acceptance criterion (untested promise) | MEDIUM | Step 3.6 check 1b: every FR traces down to an AC and up to a User Story |
|
|
761
|
+
| Manufacturing EARS requirements for a bug fix or refactor | LOW | Step 4.5: skip EARS when there's no new behavior to specify — format recommendation, not ceremony |
|
|
721
762
|
| Producing only requirements.md, skipping mermaid and tasks.md | HIGH | Step 7 is a triad — plan's contract expects all 3. Sequence diagram is always produced; state machine only if stateful; tasks.md always produced |
|
|
722
763
|
| Mermaid diagram unrelated to actual user stories (decorative only) | MEDIUM | Sequence must trace AC-1.1 of US-1; state machine nodes must map to state-bearing ACs. Auditable by pattern-match |
|
|
723
764
|
| tasks.md as flat list instead of layered | MEDIUM | Derivation rules enforce 1 US → Interface task, 1 rule → Logic + Unit test, 1 AC → Test task, 1 NFR → verification. Skipping layers loses plan's backbone structure |
|
|
@@ -741,7 +782,8 @@ Known failure modes for this skill. Check these before declaring done.
|
|
|
741
782
|
- Ambiguity Score computed and displayed — must be ≤ 40% before proceeding (≤ 25% preferred)
|
|
742
783
|
- Hidden requirements discovered and confirmed with user
|
|
743
784
|
- Scope defined (in/out/assumptions/dependencies)
|
|
744
|
-
-
|
|
785
|
+
- Functional requirements written in EARS format (FR-n) — skip for Bug Fix/Refactor
|
|
786
|
+
- User stories with testable acceptance criteria produced, each AC citing the `FR-n` it proves
|
|
745
787
|
- Non-functional requirements assessed (relevant ones only)
|
|
746
788
|
- Logic Consistency Report produced — 0 🔴 before handoff (🟡 logged as Risks)
|
|
747
789
|
- Tiered recommendations generated (Quick Win / Differentiation / Moat) — skip for Bug Fix/Refactor
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# EARS — Easy Approach to Requirements Syntax
|
|
2
|
+
|
|
3
|
+
EARS (Mavin et al., Rolls-Royce) constrains a functional requirement to one of a
|
|
4
|
+
few sentence templates. The constraint is the value: every requirement becomes a
|
|
5
|
+
single, atomic, testable "shall" statement with an explicit trigger or condition —
|
|
6
|
+
which kills the two classic requirement defects, **ambiguity** and **compound scope**.
|
|
7
|
+
|
|
8
|
+
EARS sits **between** user stories and acceptance criteria:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
User Story (WHY) → EARS Functional Requirement (WHAT the system shall do) → Acceptance Criterion (HOW we prove it)
|
|
12
|
+
As a user, I want… → When X, the system shall Y. → GIVEN … WHEN … THEN …
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
A user story is intent. An AC is a test. EARS is the contract in between — the
|
|
16
|
+
precise behavior the test verifies. Skipping it lets vague stories ("make login
|
|
17
|
+
smooth") flow straight into vague tests.
|
|
18
|
+
|
|
19
|
+
## The 5 Templates (+ 1 combined)
|
|
20
|
+
|
|
21
|
+
Give each requirement a stable ID (`FR-1`, `FR-2`, …). Pick the **simplest**
|
|
22
|
+
template that fits — escalate only when the behavior genuinely needs it.
|
|
23
|
+
|
|
24
|
+
| # | Type | Template | Use when |
|
|
25
|
+
|---|------|----------|----------|
|
|
26
|
+
| 1 | **Ubiquitous** | The `<system>` shall `<response>`. | Always-active behavior, no trigger or precondition. |
|
|
27
|
+
| 2 | **Event-driven** | When `<trigger>`, the `<system>` shall `<response>`. | A discrete event/input causes the behavior. |
|
|
28
|
+
| 3 | **State-driven** | While `<state>`, the `<system>` shall `<response>`. | Behavior holds for the duration of a state. |
|
|
29
|
+
| 4 | **Optional** | Where `<feature is included>`, the `<system>` shall `<response>`. | Behavior exists only when an optional feature/config is present. |
|
|
30
|
+
| 5 | **Unwanted** | If `<unwanted condition>`, then the `<system>` shall `<response>`. | Error handling, failure modes, abuse, invalid input. |
|
|
31
|
+
| 6 | **Complex** | While `<state>`, when `<trigger>`, the `<system>` shall `<response>`. | A trigger handled differently depending on state. |
|
|
32
|
+
|
|
33
|
+
### Examples (good)
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
FR-1 (ubiquitous) The API shall return responses in JSON.
|
|
37
|
+
FR-2 (event-driven) When a request omits a valid auth token, the API shall respond with HTTP 401.
|
|
38
|
+
FR-3 (state-driven) While the account is in maintenance mode, the system shall reject all write operations.
|
|
39
|
+
FR-4 (optional) Where rate limiting is enabled, the API shall reject the 101st request per minute with HTTP 429.
|
|
40
|
+
FR-5 (unwanted) If the payment provider times out, then the system shall mark the order pending and queue a retry.
|
|
41
|
+
FR-6 (complex) While a checkout is in progress, when the cart total changes, the system shall recompute tax before payment.
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Rules for a well-formed EARS requirement
|
|
45
|
+
|
|
46
|
+
1. **Named subject, never "it".** The `<system>` is a concrete component ("the
|
|
47
|
+
API", "the scheduler", "the login form") — not a pronoun.
|
|
48
|
+
2. **One shall per requirement.** Two behaviors → two `FR-n`. Compound "shall do A
|
|
49
|
+
and B" hides one of them from testing.
|
|
50
|
+
3. **Testable response.** "shall respond with HTTP 401" is testable; "shall handle
|
|
51
|
+
it gracefully" / "shall be fast" is not. Move measurable limits into the response
|
|
52
|
+
("within 200 ms", "with HTTP 429"). Pure performance targets stay in NFRs (Step 6).
|
|
53
|
+
4. **Trigger/condition is observable.** "When the user clicks Submit" — yes. "When
|
|
54
|
+
appropriate" — no.
|
|
55
|
+
5. **Active voice.** "the system shall reject…" not "requests are rejected".
|
|
56
|
+
6. **Don't smuggle HOW.** EARS captures observable behavior, not implementation
|
|
57
|
+
("…shall store the token in Redis" → leave Redis to plan; say "…shall persist the
|
|
58
|
+
session token").
|
|
59
|
+
|
|
60
|
+
## Anti-patterns
|
|
61
|
+
|
|
62
|
+
| Smell | Why it fails | Fix |
|
|
63
|
+
|-------|--------------|-----|
|
|
64
|
+
| "The system shall be user-friendly." | Not testable, no trigger. | Reframe as a concrete event/response, or move to NFR/UX. |
|
|
65
|
+
| "When X, the system shall do A and B and C." | Compound — partial passes hide. | Split into 3 EARS requirements. |
|
|
66
|
+
| "It shall validate input." | "It" is ambiguous; "validate" is vague. | "If a field fails validation, then the form shall display the field-level error." |
|
|
67
|
+
| Every requirement is Ubiquitous. | Triggers/states were dropped → context lost. | Most real requirements are event- or unwanted-behavior. Look for the trigger. |
|
|
68
|
+
| EARS restates the user story verbatim. | No added precision. | The story is WHY; the EARS line is the specific observable behavior. |
|
|
69
|
+
|
|
70
|
+
## Traceability (feeds Step 3.6 Logic Consistency)
|
|
71
|
+
|
|
72
|
+
EARS is only worth the ceremony if it chains:
|
|
73
|
+
|
|
74
|
+
- Every `FR-n` traces **up** to at least one User Story (it exists for a reason).
|
|
75
|
+
- Every `FR-n` traces **down** to at least one Acceptance Criterion (it gets proven).
|
|
76
|
+
- Every **unwanted-behavior** requirement (`If …`) should map to an error-path AC —
|
|
77
|
+
this is where EARS earns its keep, by forcing failure modes to be named, not assumed.
|
|
78
|
+
|
|
79
|
+
An `FR-n` with no AC is an untested promise. An AC with no `FR-n` is a test for a
|
|
80
|
+
behavior nobody specified. Both are consistency failures.
|
|
81
|
+
|
|
82
|
+
## When to keep it light
|
|
83
|
+
|
|
84
|
+
- **Bug fix / Refactor** → skip EARS entirely (no new behavior to specify).
|
|
85
|
+
- **Plumbing / Integration** → a handful of event-driven + unwanted-behavior lines is
|
|
86
|
+
usually enough; don't manufacture ubiquitous requirements to pad the list.
|
|
87
|
+
- **Small feature** → 3–7 requirements is typical. If you have 30, the feature is an
|
|
88
|
+
epic — hand the split to `plan`.
|
|
89
|
+
|
|
90
|
+
EARS is a **format recommendation**, not a gate. The goal is precision per
|
|
91
|
+
requirement, not requirement count.
|
|
@@ -103,7 +103,8 @@ Direct API call ≠ Wrapper/middleware layer ≠ Reverse engineering ≠ Browser
|
|
|
103
103
|
|
|
104
104
|
## Calls (outbound)
|
|
105
105
|
|
|
106
|
-
- `
|
|
106
|
+
- `ba` (L2): when no requirements spec exists yet AND brainstorm is a standalone entry point — hand off for requirement elicitation BEFORE plan (never when `ba` is the caller — would loop)
|
|
107
|
+
- `plan` (L2): when idea is selected and needs structuring into actionable steps (spec already exists, or task is a refactor/config change with no new behavior)
|
|
107
108
|
- `design` (L2): when selected approach has UI/UX implications — hand off visual decisions
|
|
108
109
|
- `research` (L3): gather data for informed brainstorming (existing solutions, benchmarks)
|
|
109
110
|
- `trend-scout` (L3): market context and trends for product-oriented brainstorming
|
|
@@ -124,6 +125,7 @@ Direct API call ≠ Wrapper/middleware layer ≠ Reverse engineering ≠ Browser
|
|
|
124
125
|
## Cross-Hub Connections
|
|
125
126
|
|
|
126
127
|
- `brainstorm` ↔ `plan` — bidirectional: brainstorm generates options → plan structures the chosen one, plan needs exploration → brainstorm ideates
|
|
128
|
+
- `brainstorm` → `ba` — a standalone brainstorm that picks an approach for a NEW feature with no requirements spec routes to `ba` first (WHAT before HOW). Suppressed when `ba` is the caller — that direction is `ba` → `brainstorm` and re-invoking would loop.
|
|
127
129
|
|
|
128
130
|
## Reasoning Frameworks
|
|
129
131
|
|
|
@@ -374,12 +376,33 @@ For each rejected option, state:
|
|
|
374
376
|
|
|
375
377
|
The "Revisit if" clause is critical — it turns a rejection into a future trigger, not a permanent dismissal.
|
|
376
378
|
|
|
377
|
-
### Step 5 —
|
|
378
|
-
|
|
379
|
+
### Step 5 — Hand Off (Spec Gate → BA if missing, then Plan)
|
|
380
|
+
|
|
381
|
+
Before structuring the chosen approach, check whether a requirements spec exists. Choosing an approach answers **HOW** — it does NOT answer **WHAT** (requirements, acceptance criteria, scope boundaries, hidden requirements). Handing a bare approach straight to `plan` produces a plan with no spec behind it — the "plan without spec" gap that turns into vibe-coding.
|
|
382
|
+
|
|
383
|
+
**Spec-presence gate:**
|
|
384
|
+
|
|
385
|
+
1. `Glob` `.rune/features/*/requirements.md`.
|
|
386
|
+
2. **Route to `rune:plan` directly** if ANY of:
|
|
387
|
+
- A requirements doc already exists (BA ran earlier this session, or a continuation).
|
|
388
|
+
- Brainstorm was invoked BY `ba` or `cook` (mode/caller from Step 0) — the spec step is already in the chain; re-invoking `ba` would loop.
|
|
389
|
+
- The chosen approach implies NO new user-facing behavior (pure refactor, config change, infra swap, dependency choice).
|
|
390
|
+
3. **Route to `rune:ba` FIRST** (then `ba` hands to `plan`) if ALL of:
|
|
391
|
+
- No requirements doc exists, AND
|
|
392
|
+
- Brainstorm is a standalone entry point (user ran `/rune brainstorm …` directly), AND
|
|
393
|
+
- The chosen approach implies new feature behavior (a new capability, workflow, or product surface).
|
|
394
|
+
|
|
395
|
+
<HARD-GATE>
|
|
396
|
+
Do NOT skip `ba` on the way to `plan` for a NEW feature just because an approach was already chosen.
|
|
397
|
+
Approach ≠ requirements. A plan built on a chosen approach but no acceptance criteria is a plan without a spec.
|
|
398
|
+
Loop guard: if `ba` was the caller, hand back to `plan` normally — NEVER re-invoke `ba`.
|
|
399
|
+
</HARD-GATE>
|
|
400
|
+
|
|
401
|
+
Pass to the next skill (`ba` or `plan`):
|
|
379
402
|
- The chosen option name
|
|
380
|
-
- Key constraints to honor
|
|
381
|
-
- Any risks identified that
|
|
382
|
-
- The Not Doing list (so
|
|
403
|
+
- Key constraints to honor
|
|
404
|
+
- Any risks identified that must be mitigated
|
|
405
|
+
- The Not Doing list (so the next skill knows what's explicitly out of scope)
|
|
383
406
|
|
|
384
407
|
If the user rejects the recommendation, return to Step 2 with adjusted constraints and regenerate.
|
|
385
408
|
|
|
@@ -456,6 +479,7 @@ Known failure modes for this skill. Check these before declaring done.
|
|
|
456
479
|
| [Rescue] Skipping Collision-Zone/Inversion frameworks | HIGH | Conventional thinking already failed — MUST use at least one breakthrough framework |
|
|
457
480
|
| [Rescue] All approaches are "clean/proper" — no hacky option | MEDIUM | At least 1 must be unconventional — wrappers, reverse-engineering, debug mode abuse, proxy layers |
|
|
458
481
|
| Calling plan directly instead of presenting options first | CRITICAL | Steps 2-3 are mandatory — present options, get approval, THEN call plan |
|
|
482
|
+
| Handing a chosen approach straight to `plan` for a new feature with no requirements spec | CRITICAL | Step 5 spec-presence gate: standalone brainstorm + no `requirements.md` + new behavior → route to `ba` FIRST. Approach (HOW) is not a spec (WHAT). Skipping `ba` here is the "plan without spec" vibe-coding gap |
|
|
459
483
|
| "Creative" options that ignore stated constraints | MEDIUM | Every option must satisfy the constraints declared in Step 1 |
|
|
460
484
|
| Missing "Not Doing" list — rejected options not documented | MEDIUM | Step 4.75 is MANDATORY — every rejected option needs trade-off rationale + "Revisit if" condition |
|
|
461
485
|
| [Design-It-Twice] Single agent producing N options instead of N parallel subagents | HIGH | Step 2.5 — constraint pinning happens at spawn, not in a loop. Each constraint = one Task call |
|
|
@@ -470,7 +494,8 @@ Known failure modes for this skill. Check these before declaring done.
|
|
|
470
494
|
- User has explicitly approved an approach (not implied or assumed)
|
|
471
495
|
- Selected option documented with rationale
|
|
472
496
|
- Constraints for plan phase listed explicitly
|
|
473
|
-
- `
|
|
497
|
+
- Step 5 spec-presence gate evaluated — routed to `ba` (new feature, no spec, standalone) or `plan` (spec exists, or ba/cook was the caller, or no new behavior)
|
|
498
|
+
- Next skill (`ba` or `plan`) called with the approved approach and constraints
|
|
474
499
|
|
|
475
500
|
## Cost Profile
|
|
476
501
|
|
package/skills/cook/SKILL.md
CHANGED
|
@@ -282,7 +282,12 @@ After scout completes, check if the detected tech stack or task description matc
|
|
|
282
282
|
**Step 0.5 — Cross-Project Recall**: Call `neural-memory` (Recall Mode) with 3-5 topics relevant to the current task. Always prefix queries with the project name (e.g., `"ProjectName auth pattern"` not `"auth pattern"`).
|
|
283
283
|
|
|
284
284
|
1. Use `Glob` to check for `.rune/plan-*.md` files
|
|
285
|
-
2. If a master plan exists matching the current task:
|
|
285
|
+
2. If a master plan exists matching the current task:
|
|
286
|
+
- **Step 0.55 — Spec-Backfill Gate (HARD-GATE)**: Before resuming, `Glob` `.rune/features/*/requirements.md`. If NO requirements doc exists AND the task is a **Feature / Integration / Greenfield** (same classification as the Phase 1 BA-gate — NOT a bug fix, refactor, or trivial change), the plan was produced without a spec (e.g., a `brainstorm → plan` bypass that skipped `ba`). Do NOT resume blindly:
|
|
287
|
+
1. Invoke `rune:ba` to backfill requirements (5-question elicitation, or Synthesis Mode if the plan + conversation already carry enough context) → produces `.rune/features/<name>/requirements.md`.
|
|
288
|
+
2. Re-invoke `rune:plan` to reconcile the existing plan against the new spec — if the plan contradicts a locked Decision or misses a requirement, revise the affected phase files and get user re-approval (Re-Planning protocol).
|
|
289
|
+
3. THEN resume. For Bug Fix / Refactor / trivial tasks, skip this gate — no spec is expected.
|
|
290
|
+
- Read the (reconciled) master plan → find first `⬚ Pending` or `🔄 Active` phase → load ONLY that phase file → announce "Resuming from Phase N" → skip to Phase 4
|
|
286
291
|
3. If no master plan exists → proceed to Phase 1 as normal
|
|
287
292
|
|
|
288
293
|
**Step 0.6 — Contract Load**: Use `Glob` to check for `.rune/contract.md`. If it exists:
|
|
@@ -802,6 +807,7 @@ Mentally track tool call fingerprints. 3 identical calls → WARN. 5 identical c
|
|
|
802
807
|
| Gate | Requires | If Missing |
|
|
803
808
|
|------|----------|------------|
|
|
804
809
|
| Resume Gate | Phase 0 checks for master plan before starting | Proceed to Phase 1 |
|
|
810
|
+
| Spec-Backfill Gate | Feature/greenfield resume requires `requirements.md` to exist alongside the plan | Plan without spec → invoke `rune:ba` to backfill, reconcile plan, THEN resume |
|
|
805
811
|
| Scout Gate | scout output before Phase 2 | Invoke rune:scout first |
|
|
806
812
|
| Plan Gate | User-approved plan before Phase 3 | Cannot proceed |
|
|
807
813
|
| Adversary Gate | adversary verdict before Phase 3 for features | Skip for bugfix/hotfix/refactor |
|
|
@@ -881,6 +887,7 @@ Common multi-agent failures to explicitly avoid. These are NOT edge cases — th
|
|
|
881
887
|
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
882
888
|
|---|---|---|
|
|
883
889
|
| **Bypass hierarchy** — skipping scout/plan and jumping to Phase 4 code | Builds wrong thing. Most "wasted work" traces back to missing Phase 1-2 | Follow phase gates. Even "obvious" tasks benefit from 30s of scout |
|
|
890
|
+
| **Resume without spec** — a `brainstorm → plan` chain produced a plan file, so Phase 0 skips to Phase 4 and `ba` never runs | Plan exists but no requirements/acceptance criteria — a plan without a spec. Ships confident code for the wrong "what" | Spec-Backfill Gate (Step 0.55): feature/greenfield resume with no `requirements.md` → run `ba`, reconcile plan, THEN resume |
|
|
884
891
|
| **Shadow decisions** — making architectural choices without logging to decisions.md | Next session repeats the same debate. Team agents contradict each other | Log every non-trivial choice via `decisions.md` or `journal` |
|
|
885
892
|
| **Gold-plating** — adding "nice-to-have" features not in the approved plan | Scope creep, delayed delivery, untested code paths | Build ONLY what's in the plan. Log extras as follow-up tasks |
|
|
886
893
|
| **Test-after** — writing tests after implementation instead of before (TDD violation) | Tests validate implementation bugs, not requirements. Coverage looks good but misses edge cases | Phase 3 (RED) before Phase 4 (GREEN). Always |
|
package/skills/debug/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: debug
|
|
|
3
3
|
description: "Root cause analysis for bugs and unexpected behavior. Traces errors through code, uses structured reasoning, and hands off to fix when cause is found. Core of the debug↔fix mesh. When the diagnosed cause is a memory leak in a long-running process, escalates to perf for cost-impact framing (leaks drive OOM-restart → cold-start → autoscaler spend, often 20-40% bill inflation)."
|
|
4
4
|
metadata:
|
|
5
5
|
author: runedev
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.4.0"
|
|
7
7
|
layer: L2
|
|
8
8
|
model: sonnet
|
|
9
9
|
group: development
|
|
@@ -174,6 +174,8 @@ ALL diagnostic code added during debug MUST be wrapped in `#region agent-debug`
|
|
|
174
174
|
Unmarked instrumentation will be treated as stray code and removed prematurely.
|
|
175
175
|
</HARD-GATE>
|
|
176
176
|
|
|
177
|
+
**Observability gap as a finding.** If you had to add temporary `console.log` markers because the code emitted *nothing useful* about this path, that absence is itself a root-cause-adjacent signal: the bug was hard to diagnose because the system is blind here. When the fix lands, recommend converting the throwaway markers into **durable structured telemetry** (a stable event name + correlation ID, not prose) so the next occurrence is a query, not another archaeology session. This is advisory — note it in the report, don't block on it. Contract: `../deploy/references/observability.md`.
|
|
178
|
+
|
|
177
179
|
### Step 2c: Check Debug Knowledge Base
|
|
178
180
|
|
|
179
181
|
Before forming hypotheses, check `.rune/debug/knowledge-base.md`:
|
|
@@ -427,7 +429,7 @@ Append to Debug Report when invoked standalone. Suppress when called as sub-skil
|
|
|
427
429
|
```yaml
|
|
428
430
|
chain_metadata:
|
|
429
431
|
skill: "rune:debug"
|
|
430
|
-
version: "1.
|
|
432
|
+
version: "1.4.0"
|
|
431
433
|
status: "[DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED]"
|
|
432
434
|
domain: "[area debugged]"
|
|
433
435
|
files_changed: [] # debug never changes files
|
package/skills/deploy/SKILL.md
CHANGED
|
@@ -4,7 +4,7 @@ description: "Deploy application to target platform. Use when user explicitly sa
|
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
metadata:
|
|
6
6
|
author: runedev
|
|
7
|
-
version: "0.
|
|
7
|
+
version: "0.7.0"
|
|
8
8
|
layer: L2
|
|
9
9
|
model: sonnet
|
|
10
10
|
group: delivery
|
|
@@ -290,6 +290,24 @@ Production observability (Datadog, Sentry, New Relic, Honeycomb, Logtail) bills
|
|
|
290
290
|
|
|
291
291
|
This overlaps with `perf` Step 8.6 (Observability Cost Control). `perf` finds the code patterns that emit overheavy telemetry; `deploy` ensures the platform-side ingestion + retention defaults are configured before the first prod release where the bill compounds.
|
|
292
292
|
|
|
293
|
+
## Instrumentation Readiness (pre-prod advisory gate)
|
|
294
|
+
|
|
295
|
+
> Two observability concerns, kept separate: the section *above* ("Observability Cost in Deploys") gates the telemetry **bill** (retention/sampling/cardinality config). This section gates whether the telemetry **exists and works** at all. Both run; neither replaces the other.
|
|
296
|
+
|
|
297
|
+
Cost config (above) answers "is the telemetry *affordable*". This answers "does the telemetry *exist and work*". A feature with retries, queues, external calls, or new endpoints that ships **zero new telemetry** is shipping blind — the first incident becomes archaeology.
|
|
298
|
+
|
|
299
|
+
<MUST-READ path="references/observability.md" trigger="first prod deploy of a feature that adds I/O, endpoints, jobs, or external integrations"/>
|
|
300
|
+
|
|
301
|
+
Before the first production deploy of such a feature, verify the **Instrumentation Readiness Checklist** in `references/observability.md`. This is **advisory** (WARN, not BLOCK) — do not stop a deploy over missing telemetry, but surface the gap:
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
INSTRUMENTATION_GAP — feature adds [endpoint/job/integration] with no new
|
|
305
|
+
structured logs / RED metrics / correlation ID. First incident will be blind.
|
|
306
|
+
→ See deploy/references/observability.md before shipping.
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Skip for: static sites, config-only changes, hotfixes (flag for follow-up), non-prod deploys.
|
|
310
|
+
|
|
293
311
|
## Output Format
|
|
294
312
|
|
|
295
313
|
Deploy Report with platform, status (success/failed/rollback), deployed URL, build time, and checks (tests, security, HTTP, visual, monitoring). See Step 6 Report above for full template.
|
|
@@ -328,6 +346,7 @@ Known failure modes for this skill. Check these before declaring done.
|
|
|
328
346
|
| Resources deployed without cost-allocation tags | HIGH | Step 1 pre-deploy MUST verify Environment/Team/Service tags. Untagged = unfalsifiable cost claims downstream |
|
|
329
347
|
| Self-host migration recommended on bill threshold alone | HIGH | Crossover rule requires ALL 3 conditions: bill + ops bandwidth + customization need. Single-criterion recommendations produce engineering-debt swap |
|
|
330
348
|
| Defaults shipped on observability stack | MEDIUM | Verify retention + sampling + cardinality config BEFORE first prod deploy; defaults often bleed > compute bill |
|
|
349
|
+
| Feature ships with zero telemetry (logs/metrics/traces) | MEDIUM | Instrumentation Readiness advisory gate — WARN `INSTRUMENTATION_GAP` (skip for static sites/config-only/hotfix per section); first incident is blind without it. See `references/observability.md` |
|
|
331
350
|
| Premature self-host (< 10K MAU) | MEDIUM | Flag `PREMATURE_SELFHOST` — managed equivalent at this scale is cheaper than engineering time spent operating |
|
|
332
351
|
|
|
333
352
|
## Done When
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Observability & Instrumentation Reference
|
|
2
|
+
|
|
3
|
+
Code you cannot observe is code you cannot operate. Instrumentation is written **alongside** the feature, like tests — not bolted on after the first incident. A feature that ships without telemetry turns its first user-reported bug into archaeology instead of a query.
|
|
4
|
+
|
|
5
|
+
This reference is the shared instrumentation discipline. `deploy` gates on it before prod, `perf` uses it as the measurement basis, `debug` leaves it behind so the next investigation is fast.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Define "working" before instrumenting
|
|
10
|
+
|
|
11
|
+
Telemetry without a question is noise. Before adding anything, write 2-4 questions an on-call engineer will ask about this feature:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
FEATURE: checkout payment retry
|
|
15
|
+
ON-CALL WILL ASK:
|
|
16
|
+
1. What fraction of payments succeed first-try vs after retry?
|
|
17
|
+
2. When a payment fails permanently, why? (provider error / timeout / validation?)
|
|
18
|
+
3. Is the payment provider slower than usual?
|
|
19
|
+
→ Every signal below must answer one of these.
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
If you cannot name the questions, you are not ready to instrument — you will log everything and learn nothing.
|
|
23
|
+
|
|
24
|
+
## 2. One signal per question
|
|
25
|
+
|
|
26
|
+
| Signal | Answers | Cost profile |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| **Structured log** | "What happened in this specific case?" | Per-event; grows with traffic |
|
|
29
|
+
| **Metric** | "How often / how fast, in aggregate?" | Fixed per series; cheap to query |
|
|
30
|
+
| **Trace** | "Where did time go across services?" | Per-request; usually sampled |
|
|
31
|
+
|
|
32
|
+
Rule of thumb: **metrics say *that* something is wrong, traces say *where*, logs say *why*.**
|
|
33
|
+
|
|
34
|
+
## 3. Structured logging
|
|
35
|
+
|
|
36
|
+
Log events, not prose. Every line is a JSON object with a stable event name and machine-readable fields:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// BAD: string interpolation — unqueryable, inconsistent
|
|
40
|
+
logger.info(`Payment ${id} failed for ${userId} after ${n} retries`);
|
|
41
|
+
|
|
42
|
+
// GOOD: stable event name + structured fields
|
|
43
|
+
logger.warn({ event: 'payment_failed', paymentId: id, provider: 'stripe', errorCode: err.code, attempt: n }, 'payment failed');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Log levels — consistent meaning:**
|
|
47
|
+
|
|
48
|
+
| Level | Meaning | On-call action |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `error` | Invariant broken; someone may need to act | Investigate |
|
|
51
|
+
| `warn` | Degraded but handled (retry succeeded, fallback used) | Watch trends |
|
|
52
|
+
| `info` | Significant business event (order placed, job finished) | None |
|
|
53
|
+
| `debug` | Diagnostic detail | Off in prod by default |
|
|
54
|
+
|
|
55
|
+
**Correlation IDs are mandatory.** Generate or accept a request ID at the system boundary; attach it to every log line, span, and outbound call. Without it you cannot reconstruct one request from interleaved logs:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
app.use((req, res, next) => {
|
|
59
|
+
req.id = req.headers['x-request-id'] ?? crypto.randomUUID();
|
|
60
|
+
req.log = logger.child({ requestId: req.id });
|
|
61
|
+
res.setHeader('x-request-id', req.id);
|
|
62
|
+
next();
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Never log secrets, tokens, passwords, or full PII.** Telemetry pipelines are a classic data-leak path (hard rule, shared with `sentinel`). Allowlist fields; never log whole request bodies.
|
|
67
|
+
|
|
68
|
+
## 4. Metrics — RED and USE
|
|
69
|
+
|
|
70
|
+
- **Request-driven services** (endpoints, external deps): instrument **RED** — **R**ate (req/s), **E**rrors (failure rate), **D**uration (latency *histogram*).
|
|
71
|
+
- **Resources** (queues, pools, hosts): instrument **USE** — **U**tilization, **S**aturation, **E**rrors.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const httpDuration = new Histogram({
|
|
75
|
+
name: 'http_request_duration_seconds',
|
|
76
|
+
labelNames: ['method', 'route', 'status_class'], // '2xx', not '200'
|
|
77
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2.5, 5],
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Cardinality is the failure mode.** Every unique label combination is a separate time series. Labels must come from small fixed sets (route template, status class, provider). Never use user IDs, raw URLs, request IDs, or error-message text as labels — that belongs in logs/traces.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
OK as label: route="/api/tasks/:id" status_class="5xx" provider="stripe"
|
|
85
|
+
NEVER a label: user_id, email, request_id, full URL, error message text
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Averages never, percentiles always.** An average hides the 1% of users having a terrible time. Use histograms; read p50/p95/p99.
|
|
89
|
+
|
|
90
|
+
## 5. Distributed tracing
|
|
91
|
+
|
|
92
|
+
Use OpenTelemetry (vendor-neutral). Auto-instrumentation covers HTTP/gRPC/common DB clients with near-zero code:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
// tracing.ts — imported before anything else
|
|
96
|
+
const sdk = new NodeSDK({ serviceName: 'checkout-service', instrumentations: [getNodeAutoInstrumentations()] });
|
|
97
|
+
sdk.start();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Add manual spans only around meaningful internal work (`applyDiscounts`, `chargeProvider`) with the attributes on-call filters by. Propagate context across every async boundary (HTTP headers, queue metadata) or the trace dies at the gap. Sample head-based at a low rate; keep 100% of errors if the backend supports tail sampling.
|
|
101
|
+
|
|
102
|
+
## 6. Alerting — symptoms, not causes
|
|
103
|
+
|
|
104
|
+
Alert on **what users feel**, not on internal causes:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
SYMPTOM (page-worthy): CAUSE (dashboard, not a page):
|
|
108
|
+
error rate > 1% for 5 min CPU at 85%
|
|
109
|
+
p99 latency > 2s one pod restarted
|
|
110
|
+
queue age > 10 min disk at 70%
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Cause-based alerts fire when nothing is wrong and miss failures you did not predict. Every alert must:
|
|
114
|
+
|
|
115
|
+
1. **Be actionable.** If the response is "ignore it, it self-heals" → delete it.
|
|
116
|
+
2. **Link to a runbook** — even three lines: what it means, first query to run, escalation path.
|
|
117
|
+
3. **Have a threshold + duration** justified by an SLO or historical data, not a guess.
|
|
118
|
+
4. **Use two severities only** — *page* (user-facing, act now) and *ticket* (degradation, act this week). A third tier trains people to ignore everything.
|
|
119
|
+
|
|
120
|
+
## 7. Verify the telemetry itself
|
|
121
|
+
|
|
122
|
+
Instrumentation is code; it can be wrong. Before calling it done, trigger the paths and look at the real output:
|
|
123
|
+
|
|
124
|
+
- Force an error in staging → find it by `requestId`, confirm fields are structured (not `[object Object]`).
|
|
125
|
+
- Send test traffic → metric series appear with expected labels and sane values.
|
|
126
|
+
- Follow one request end-to-end in the tracing UI → no broken spans.
|
|
127
|
+
- Fire each new alert once (lower the threshold temporarily) → it reaches the right channel and the runbook link works.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Instrumentation Readiness Checklist (gate)
|
|
132
|
+
|
|
133
|
+
A feature is observable-ready when:
|
|
134
|
+
|
|
135
|
+
- [ ] On-call questions written down; each signal maps to one
|
|
136
|
+
- [ ] All logs structured (JSON), stable event names, correlation ID on every line
|
|
137
|
+
- [ ] No secrets/tokens/PII in any log line (spot-check actual output)
|
|
138
|
+
- [ ] RED metrics on every new endpoint + external dependency, bounded labels
|
|
139
|
+
- [ ] Latency is a histogram; p95/p99 queryable
|
|
140
|
+
- [ ] One request followable end-to-end without broken spans
|
|
141
|
+
- [ ] Every new alert is symptom-based, has a runbook link, was test-fired once
|
|
142
|
+
- [ ] An induced staging failure was located via telemetry alone, without reading source
|
|
143
|
+
|
|
144
|
+
## Cost note
|
|
145
|
+
|
|
146
|
+
Instrumentation has a bill. Retention, sampling, and cardinality defaults bleed money (see `deploy` → "Observability Cost in Deploys" and `perf` Step 8.6). Instrument for the on-call questions — not for completeness. Three queryable events beat three hundred prose lines.
|
package/skills/graft/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: graft
|
|
|
3
3
|
description: "Clone, port, or convert features from any GitHub repo into your project. Use when stealing patterns from external repos or porting proven code. Understand before copy, challenge before implement. 4 modes: port (rewrite), compare (analysis), copy (transplant), improve (copy + optimize)."
|
|
4
4
|
metadata:
|
|
5
5
|
author: runedev
|
|
6
|
-
version: "0.
|
|
6
|
+
version: "0.3.0"
|
|
7
7
|
layer: L2
|
|
8
8
|
model: sonnet
|
|
9
9
|
group: creation
|
|
@@ -25,9 +25,10 @@ When you clone a repo you see hundreds of files. **That tree is a menu — optio
|
|
|
25
25
|
- Read the README + the **2-5 files that implement the target feature**. Skip the rest.
|
|
26
26
|
- If you cannot name the specific files you need before reading, you do not know what you want yet — go back to Step 0 and narrow scope.
|
|
27
27
|
- `WebFetch` on raw GitHub URLs beats `git clone` whenever you know the exact files. Use clone only when discovery is genuinely needed.
|
|
28
|
-
- A graft that reads >10 source files is almost always a scoping failure, not a thorough one.
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
**Reading to understand is not grafting.** The discipline above caps the **graft scope** — the files you actually transplant, port, or improve into your codebase (2-5, hard-cap 10). It does NOT cap how many files you may *read to learn a pattern*. Studying a 24-skill library to extract one convention legitimately reads dozens of files but grafts almost none. Keep the two counts separate: a wide read with a narrow graft is thorough; a wide graft is the failure mode.
|
|
30
|
+
|
|
31
|
+
This menu discipline applies to the **transplant modes** (port, copy, improve). Copy mode is not an excuse to import a directory wholesale — you still select files deliberately. **Compare mode and survey scope (`--deep`)** are exempt from the read cap by design: their job is breadth of understanding, not transplant. They still must NOT import code wholesale — wide reading, narrow (or zero) graft.
|
|
31
32
|
|
|
32
33
|
<HARD-GATE>
|
|
33
34
|
Challenge gate (Step 4) MUST complete before adaptation planning (Step 5).
|
|
@@ -67,6 +68,17 @@ Copy the feature, then refactor and optimize. Fix anti-patterns, add missing tes
|
|
|
67
68
|
|
|
68
69
|
**`--fast` warning**: Skipping challenge gate means no license check, no quality assessment. User accepts full responsibility. Announce: "Fast mode: skipping challenge gate. You are responsible for license and quality review."
|
|
69
70
|
|
|
71
|
+
## Scope Depth
|
|
72
|
+
|
|
73
|
+
Orthogonal to mode and speed. Controls how widely you may read.
|
|
74
|
+
|
|
75
|
+
| Scope | Read budget | Graft scope | When |
|
|
76
|
+
|-------|-------------|-------------|------|
|
|
77
|
+
| (default) | 2-5 files, hard-cap 10 | the feature's files | Transplant one feature/module |
|
|
78
|
+
| `--deep` (survey) | unbounded reads, full clone OK | narrow — patterns extracted, not files copied | Study a whole repo/library to learn architecture or compare many components |
|
|
79
|
+
|
|
80
|
+
**`--deep` is for understanding, not importing.** Use it when the goal is "what can I learn from this repo" rather than "port this function." Pairs naturally with `compare` mode. It relaxes the read cap and the scope-guard warning — but the transplant discipline still holds: extract the *pattern*, then graft narrowly (often into multiple existing skills/files rather than copying source files 1:1).
|
|
81
|
+
|
|
70
82
|
## Smart Intent Detection
|
|
71
83
|
|
|
72
84
|
| Input Pattern | Detected Mode |
|
|
@@ -76,6 +88,7 @@ Copy the feature, then refactor and optimize. Fix anti-patterns, add missing tes
|
|
|
76
88
|
| Contains "improve", "better", "adapt", "upgrade" | improve |
|
|
77
89
|
| Contains "port", "convert", "rewrite", "migrate" | port |
|
|
78
90
|
| URL points to specific file/dir (not repo root) | Auto-scope to that path |
|
|
91
|
+
| Contains "survey", "study", "learn from", "what can I take", "deep dive" | compare + `--deep` |
|
|
79
92
|
| (default — no keyword match) | port |
|
|
80
93
|
|
|
81
94
|
## Triggers
|
|
@@ -140,9 +153,9 @@ For specific files or small repos: use `WebFetch` on raw GitHub URLs instead of
|
|
|
140
153
|
3. package.json / pyproject.toml / Cargo.toml — dependencies and stack
|
|
141
154
|
4. Tests for target feature — understand expected behavior
|
|
142
155
|
|
|
143
|
-
**Scope guard**: If target feature spans >15 files or >2000 LOC → WARN user: "Feature is large. Suggest narrowing to [specific module]. Continue anyway?"
|
|
156
|
+
**Scope guard**: If target feature spans >15 files or >2000 LOC → WARN user: "Feature is large. Suggest narrowing to [specific module]. Continue anyway?" (Suppressed under `--deep`/compare — breadth is the point there.)
|
|
144
157
|
|
|
145
|
-
**Menu discipline
|
|
158
|
+
**Menu discipline** (transplant modes): Before reading file #6, pause and ask "do I actually need this *to graft it*, or am I eating the menu?" If the answer isn't a concrete reason tied to the target feature, stop reading and move to Step 2. Under `--deep`/survey scope this gate is lifted — read as widely as understanding requires, but keep the graft scope narrow (Step 5).
|
|
146
159
|
|
|
147
160
|
### Step 2 — Analyze Source
|
|
148
161
|
|
|
@@ -204,6 +217,8 @@ Wait for user approval (unless `--auto`).
|
|
|
204
217
|
|
|
205
218
|
### Step 5 — Plan Adaptation
|
|
206
219
|
|
|
220
|
+
**Graft scope stays narrow regardless of how widely you read.** If this run used `--deep`/survey to study a library, the read cap was lifted — but the adaptation plan below still selects a small set of files/patterns to actually transplant. A wide survey legitimately feeds a `copy`/`improve` plan that grafts only the 2-5 best files; it does not license importing the surveyed tree.
|
|
221
|
+
|
|
207
222
|
Based on mode, produce adaptation plan:
|
|
208
223
|
|
|
209
224
|
**Compare mode** → skip to output. Write comparison report and STOP.
|
|
@@ -302,7 +317,7 @@ graft.complete:
|
|
|
302
317
|
5. MUST respect local conventions — grafted code should look native, not foreign
|
|
303
318
|
6. MUST NOT modify the source repository — read-only access only
|
|
304
319
|
7. MUST NOT graft without scoping — always narrow to specific feature/module
|
|
305
|
-
8. MUST treat the source file tree as a menu, not a meal —
|
|
320
|
+
8. MUST treat the source file tree as a menu, not a meal for **transplant** — graft the 2-5 files the feature actually needs, not every file you can see. Reading widely to understand (esp. under `--deep`/compare) is allowed; grafting widely is not
|
|
306
321
|
|
|
307
322
|
## Mesh Gates
|
|
308
323
|
|
|
@@ -319,7 +334,8 @@ graft.complete:
|
|
|
319
334
|
| Grafting GPL code into MIT project | CRITICAL | Challenge gate checks license — blocks incompatible |
|
|
320
335
|
| Blindly copying code without understanding | CRITICAL | HARD-GATE: challenge before implement |
|
|
321
336
|
| Context overflow from large source files | HIGH | Scope guard: >15 files or >2000 LOC triggers warning |
|
|
322
|
-
| Reading the whole repo instead of the feature | HIGH | "Tree is a menu" rule — pause before file #6, justify each read |
|
|
337
|
+
| Reading the whole repo instead of the feature | HIGH | "Tree is a menu" rule — pause before file #6, justify each read (transplant modes only) |
|
|
338
|
+
| Forcing a pattern-study graft into the 10-file feature cap | MEDIUM | Use `--deep`/survey scope — wide read, narrow graft; cap counts grafted files, not reads |
|
|
323
339
|
| Grafted code doesn't match local conventions | HIGH | Step 3 scans local patterns, Step 5 plans adaptation |
|
|
324
340
|
| Stale source (abandoned repo) | MEDIUM | Maintenance dimension in challenge gate |
|
|
325
341
|
| Private repo URL fails | MEDIUM | Fallback to WebFetch raw URLs or manual paste |
|
|
@@ -335,7 +351,7 @@ SELF-VALIDATION (run before emitting graft.complete):
|
|
|
335
351
|
- [ ] License compatibility confirmed (or user override documented)
|
|
336
352
|
- [ ] Temp clone directory cleaned up
|
|
337
353
|
- [ ] Grafted code compiles/lints without new errors
|
|
338
|
-
- [ ]
|
|
354
|
+
- [ ] **Graft scope** ≤10 files (files actually transplanted/ported/improved) — if >10, document why. This is NOT the read count: under `--deep`/compare you may read far more to understand, but the files you graft stay narrow.
|
|
339
355
|
IF ANY check fails → fix before reporting done. Do NOT defer to completion-gate.
|
|
340
356
|
```
|
|
341
357
|
|