projecta-rrr 1.18.10 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ All notable changes to RRR will be documented in this file.
4
4
 
5
5
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.19.1] - 2026-02-11
8
+
9
+ ### Fixed
10
+
11
+ - **Install failure** - Postinstall script referenced wrong path for `register-mcp.js` (`rrr/scripts/` instead of `scripts/`)
12
+
13
+ ## [1.19.0] - 2026-02-05
14
+
15
+ ### Added
16
+
17
+ - **Auto-Capture Observation Logger** - PostToolUse hook that automatically captures file creates/deletes, test results, git commits, and decision signals to `.planning/observations-YYYY-MM-DD.jsonl` with daily rotation and 1MB limit
18
+ - **Progressive STATE.md Disclosure** - Compact ~30 token state index loaded on session start; full STATE.md only on explicit resume (saves context budget)
19
+ - **SessionStart Auto-Resume Hook** - Handles Claude Code's `source` field (startup/resume/compact/clear) for automatic context restoration
20
+ - **Native Context Window Metrics** - 4-level fallback (HUD state > env var > cached file > estimation) with pressure levels integrated into drift detection
21
+ - **Timeline-Aware Session Queries** - `since`/`until` filters for session search with ISO dates, relative words ("yesterday"), and durations ("3d", "2w")
22
+ - **Complexity-Adaptive Routing** - `/rrr:mvp` auto-detects task complexity (SMALL/MEDIUM/LARGE) and routes to appropriate workflow depth
23
+ - **Configurable Git Branching** - `git_branching` strategy (none/phase/milestone) in config.json with squash-on-complete option
24
+ - **`/rrr:think` Command** - 4 structured thinking models: first-principles, inversion (pre-mortem), pareto (80/20), five-whys (root cause)
25
+ - **TeammateTool / Hidden Swarm Embedding** - File-based team coordination mirroring Claude Code's hidden TeammateTool API with spawnTeam/write/broadcast/cleanup primitives, team-aware executor for wave parallelization, and GA migration path with transport swap
26
+ - **Session Forking Guidance** - Documented session forking as preferred overnight method with fallback to traditional Jarvis
27
+
28
+ ### Changed
29
+
30
+ - `/rrr:mvp` now includes complexity detection preamble before routing
31
+ - `/rrr:execute-phase` supports team coordination for multi-plan waves
32
+ - `/rrr:execute-plan` creates git branches when `git_branching` is configured
33
+ - `/rrr:complete-milestone` handles branch merge and optional squash cleanup
34
+ - `/rrr:discuss-phase` offers optional thinking model integration
35
+ - `/rrr:overnight` uses session forking with 10-min hook timeout
36
+ - Resume workflow uses compact-first progressive disclosure approach
37
+ - Memory store includes context pressure signals in drift detection
38
+
7
39
  ## [1.18.10] - 2026-02-03
8
40
 
9
41
  ### Added
package/bin/install.js CHANGED
@@ -1412,6 +1412,27 @@ function install(isGlobal) {
1412
1412
  });
1413
1413
  console.log(` ${green}✓${reset} Configured cache stats hook`);
1414
1414
  }
1415
+
1416
+ // Configure SessionStart hook for auto-resume context
1417
+ const sessionStartCommand = isGlobal
1418
+ ? '$HOME/.claude/hooks/rrr-session-start.sh'
1419
+ : `${localDirName}/hooks/rrr-session-start.sh`;
1420
+
1421
+ const hasSessionStartHook = settings.hooks.SessionStart.some(entry =>
1422
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('rrr-session-start'))
1423
+ );
1424
+
1425
+ if (!hasSessionStartHook && hookFileExists(claudeDir, 'rrr-session-start.sh')) {
1426
+ settings.hooks.SessionStart.push({
1427
+ hooks: [
1428
+ {
1429
+ type: 'command',
1430
+ command: sessionStartCommand
1431
+ }
1432
+ ]
1433
+ });
1434
+ console.log(` ${green}✓${reset} Configured auto-resume hook (SessionStart)`);
1435
+ }
1415
1436
  }
1416
1437
 
1417
1438
  // PATCH-01: Configure PostToolUse hook for drift detection
@@ -1447,6 +1468,37 @@ function install(isGlobal) {
1447
1468
  }
1448
1469
  }
1449
1470
 
1471
+ // Configure PostToolUse hook for observation logger (auto-capture key events)
1472
+ const observationLoggerCommand = isGlobal
1473
+ ? '$HOME/.claude/hooks/rrr-observation-logger.sh'
1474
+ : `${localDirName}/hooks/rrr-observation-logger.sh`;
1475
+
1476
+ if (bashStatus.available && hookFileExists(claudeDir, 'rrr-observation-logger.sh')) {
1477
+ if (!settings.hooks) {
1478
+ settings.hooks = {};
1479
+ }
1480
+ if (!settings.hooks.PostToolUse) {
1481
+ settings.hooks.PostToolUse = [];
1482
+ }
1483
+
1484
+ const hasObservationHook = settings.hooks.PostToolUse.some(entry =>
1485
+ entry.hooks && entry.hooks.some(h => h.command && h.command.includes('rrr-observation-logger'))
1486
+ );
1487
+
1488
+ if (!hasObservationHook) {
1489
+ settings.hooks.PostToolUse.push({
1490
+ matcher: '*',
1491
+ hooks: [
1492
+ {
1493
+ type: 'command',
1494
+ command: observationLoggerCommand
1495
+ }
1496
+ ]
1497
+ });
1498
+ console.log(` ${green}✓${reset} Configured observation logger hook (PostToolUse)`);
1499
+ }
1500
+ }
1501
+
1450
1502
  // Configure UserPromptSubmit hook for intent classification (smart drift detection)
1451
1503
  const classifyIntentCommand = isGlobal
1452
1504
  ? '$HOME/.claude/hooks/rrr-classify-intent.sh'
@@ -100,14 +100,55 @@ Output: Milestone archived (roadmap + requirements), PROJECT.md evolved, git tag
100
100
  - Add "Next Milestone Goals" section
101
101
  - Archive previous content in `<details>` (if v1.1+)
102
102
 
103
- 7. **Commit and tag:**
103
+ 7. **Merge branches (if git branching was used):**
104
+
105
+ Check config.json for `git_branching` setting:
106
+
107
+ ```bash
108
+ GIT_BRANCHING=$(node -e "try { const c = require('./.planning/config.json'); console.log(c.git_branching || 'none'); } catch(e) { console.log('none'); }" 2>/dev/null)
109
+ SQUASH=$(node -e "try { const c = require('./.planning/config.json'); console.log(c.squash_on_complete ? 'true' : 'false'); } catch(e) { console.log('false'); }" 2>/dev/null)
110
+ ```
111
+
112
+ **If `git_branching` is `phase` or `milestone`:**
113
+
114
+ a. List all RRR branches:
115
+ ```bash
116
+ git branch --list 'rrr/*'
117
+ ```
118
+
119
+ b. For each RRR branch:
120
+ - Ensure we are on the main/default branch
121
+ - Merge or squash-merge based on `squash_on_complete`:
122
+ ```bash
123
+ DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
124
+ git checkout "$DEFAULT_BRANCH"
125
+
126
+ if [ "$SQUASH" = "true" ]; then
127
+ git merge --squash "$BRANCH_NAME"
128
+ git commit -m "feat: merge ${BRANCH_NAME} (squashed)"
129
+ else
130
+ git merge "$BRANCH_NAME" --no-edit
131
+ fi
132
+ ```
133
+
134
+ c. Clean up merged branches:
135
+ ```bash
136
+ git branch -d "$BRANCH_NAME"
137
+ echo "[RRR] Merged and deleted branch: $BRANCH_NAME"
138
+ ```
139
+
140
+ d. Present summary of merged branches to user for confirmation.
141
+
142
+ **If `none`:** Skip this step entirely.
143
+
144
+ 8. **Commit and tag:**
104
145
 
105
146
  - Stage: MILESTONES.md, PROJECT.md, ROADMAP.md, STATE.md, archive files
106
147
  - Commit: `chore: archive v{{version}} milestone`
107
148
  - Tag: `git tag -a v{{version}} -m "[milestone summary]"`
108
149
  - Ask about pushing tag
109
150
 
110
- 8. **Offer next steps:**
151
+ 9. **Offer next steps:**
111
152
  - `/rrr:discuss-milestone` — thinking partner, creates context file
112
153
  - Then `/rrr:new-milestone` — update PROJECT.md with new goals
113
154
 
@@ -62,6 +62,39 @@ Phase number: $ARGUMENTS (required)
62
62
  - Scope expansion (roadmap defines scope)
63
63
  </process>
64
64
 
65
+ <thinking_models>
66
+ **Optional: Apply thinking model during discussion**
67
+
68
+ After step 5 (deep-dive areas) and before step 6 (write CONTEXT.md), offer structured analysis if the discussion revealed complex architectural decisions:
69
+
70
+ ```
71
+ ---
72
+
73
+ Noticed some meaty decisions in this discussion. Want to apply a thinking model?
74
+
75
+ | Model | Good For |
76
+ |-------|----------|
77
+ | `/rrr:think first-principles` | Strip assumptions, rebuild approach |
78
+ | `/rrr:think inversion` | Pre-mortem: what could go wrong? |
79
+ | `/rrr:think pareto` | Cut scope to the essential 20% |
80
+ | `/rrr:think five-whys` | Dig into root cause of a design question |
81
+
82
+ Or skip and proceed to CONTEXT.md.
83
+
84
+ ---
85
+ ```
86
+
87
+ **When to offer:**
88
+ - At least one gray area involved architecture or technology choice
89
+ - Discussion surfaced significant trade-offs
90
+ - User expressed uncertainty about approach
91
+
92
+ **When to skip (just proceed):**
93
+ - All gray areas were UI/UX/content (not architectural)
94
+ - Discussion was quick and clear
95
+ - User has strong opinions already
96
+ </thinking_models>
97
+
65
98
  <success_criteria>
66
99
  - Gray areas identified through intelligent analysis
67
100
  - User chose which areas to discuss
@@ -100,6 +100,50 @@ Phase: $ARGUMENTS
100
100
  **If script not found:**
101
101
  - Log warning, continue without preflight
102
102
 
103
+ 1.7. **Git branching (if configured)**
104
+
105
+ Check config.json for `git_branching` setting:
106
+
107
+ ```bash
108
+ GIT_BRANCHING=$(node -e "try { const c = require('./.planning/config.json'); console.log(c.git_branching || 'none'); } catch(e) { console.log('none'); }" 2>/dev/null)
109
+ ```
110
+
111
+ **If `git_branching` is `phase`:**
112
+ - Create and checkout branch for this phase:
113
+ ```bash
114
+ PHASE_NUM=$ARGUMENTS
115
+ PHASE_SLUG=$(basename "$PHASE_DIR" | sed "s/^${PHASE_NUM}-//")
116
+ BRANCH_NAME="rrr/phase-${PHASE_NUM}-${PHASE_SLUG}"
117
+
118
+ if ! git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
119
+ git checkout -b "$BRANCH_NAME"
120
+ echo "[RRR] Created branch: $BRANCH_NAME"
121
+ else
122
+ git checkout "$BRANCH_NAME" 2>/dev/null || echo "[RRR] Already on branch: $BRANCH_NAME"
123
+ fi
124
+ ```
125
+
126
+ **If `git_branching` is `milestone`:**
127
+ - Branch is created at milestone level (by execute-plan or new-milestone)
128
+ - Ensure we are on the milestone branch if it exists
129
+
130
+ **If `none` (default):** No branching, continue on current branch.
131
+
132
+ 1.8. **Team coordination (if configured)**
133
+
134
+ Check config.json for `team_coordination` setting:
135
+
136
+ ```bash
137
+ TEAM_COORD=$(node -e "try { const c = require('./.planning/config.json'); console.log(c.team_coordination !== false ? 'true' : 'false'); } catch(e) { console.log('true'); }" 2>/dev/null)
138
+ ```
139
+
140
+ **If `true` (default):** Team coordination enabled for multi-plan waves.
141
+ - Load team libraries: `rrr/lib/team-coord.js` and `rrr/lib/team-executor.js`
142
+ - Team coordination only activates for waves with 2+ plans
143
+ - Single-plan waves always skip team coordination (zero overhead)
144
+
145
+ **If `false`:** Team coordination disabled. Execute with original hub-and-spoke pattern.
146
+
103
147
  2. **Discover plans**
104
148
  - List all *-PLAN.md files in phase directory
105
149
  - Check which have *-SUMMARY.md (already complete)
@@ -133,11 +177,69 @@ Phase: $ARGUMENTS
133
177
  - If user chooses to skip: Mark plan as skipped, continue to next
134
178
  - If user chooses to continue: Proceed with execution
135
179
 
136
- **5b. Execute plans:**
180
+ **5b. Team setup (if multi-plan wave and team_coordination enabled):**
181
+
182
+ For waves with 2+ plans when `TEAM_COORD=true`:
183
+
184
+ ```javascript
185
+ // Using rrr/lib/team-executor.js
186
+ const team = prepareWaveTeam(phaseNum, waveNum, planIds, planPaths, projectRoot);
187
+ // team is null for single-plan waves (zero overhead)
188
+ ```
189
+
190
+ This creates `.planning/teams/phase-{N}-wave-{W}/` with:
191
+ - `config.json` — team members, status
192
+ - `messages/{agent-id}/` — per-agent inbox dirs
193
+ - `messages/broadcast/` — group messages
194
+ - `state.json` — team lifecycle state
195
+
196
+ Shared file detection: parse each plan's `## Files Modified` section,
197
+ find files appearing in 2+ plans. These require coordination.
198
+
199
+ **5c. Execute plans:**
137
200
  - For each plan, inject `<skills>` block into executor prompt
201
+ - If team exists (multi-plan wave): inject `<team_context>` block with team name, agent ID, peer IDs, shared files
138
202
  - Spawn `rrr-executor` for each plan in wave (parallel Task calls)
139
203
  - Wait for completion (Task blocks)
140
- - Verify SUMMARYs created
204
+
205
+ **5d. Post-wave team analysis (if team exists):**
206
+
207
+ After all executors in wave complete:
208
+
209
+ 1. **Read team messages** (for logging/debugging):
210
+ ```javascript
211
+ const { messages } = collectTeamMessages(team);
212
+ // Log: "[RRR] Wave {W}: {N} team messages exchanged"
213
+ ```
214
+
215
+ 2. **Detect file conflicts** (same file modified by 2+ agents):
216
+ ```javascript
217
+ const conflicts = detectFileConflicts(team, summaryPaths);
218
+ ```
219
+
220
+ 3. **If conflicts detected:** Present conflict resolution UI:
221
+ ```
222
+ ── FILE CONFLICT DETECTED ──────────────────────────
223
+
224
+ File: {file_path}
225
+ Modified by: {agent-1}, {agent-2}
226
+
227
+ {agent-1} changes: {summary from team messages}
228
+ {agent-2} changes: {summary from team messages}
229
+
230
+ ────────────────────────────────────────────────────
231
+ > Select: merge-both / keep-{agent-1} / keep-{agent-2} / manual
232
+ ────────────────────────────────────────────────────
233
+ ```
234
+
235
+ Use AskUserQuestion for conflict resolution if any non-expected conflicts exist.
236
+
237
+ 4. **Cleanup team:**
238
+ ```javascript
239
+ cleanupWaveTeam(team); // Archives to .planning/teams/archived/
240
+ ```
241
+
242
+ 5. **Verify SUMMARYs created**
141
243
  - Proceed to next wave
142
244
 
143
245
  6. **Aggregate results**
@@ -374,22 +476,56 @@ After user runs `/rrr:plan-phase {Z} --gaps`:
374
476
  </offer_next>
375
477
 
376
478
  <wave_execution>
377
- **Parallel spawning:**
479
+ **Parallel spawning with team coordination:**
480
+
481
+ **Step 1: Prepare team (multi-plan waves only)**
482
+
483
+ For waves with 2+ plans when `team_coordination` is enabled:
484
+
485
+ ```javascript
486
+ // From rrr/lib/team-executor.js
487
+ const team = prepareWaveTeam(phaseNum, waveNum, planIds, planPaths, projectRoot);
488
+ // Returns null for single-plan waves (zero overhead)
489
+
490
+ // Build team context for each executor
491
+ const teamBlock = buildTeamPromptBlock(team, planId);
492
+ // Returns '' for null teams
493
+ ```
494
+
495
+ **Step 2: Spawn executors**
378
496
 
379
497
  Spawn all plans in a wave with a single message containing multiple Task calls.
380
- Include the `<skills>` block loaded in step 4 for each plan:
498
+ Include the `<skills>` block loaded in step 4 and `<team_context>` block for each plan:
381
499
 
382
500
  ```
383
- Task(prompt="Execute plan at {plan_01_path}\n\n{skills_01_block}\n\nPlan: @{plan_01_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
384
- Task(prompt="Execute plan at {plan_02_path}\n\n{skills_02_block}\n\nPlan: @{plan_02_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
385
- Task(prompt="Execute plan at {plan_03_path}\n\n{skills_03_block}\n\nPlan: @{plan_03_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
501
+ Task(prompt="Execute plan at {plan_01_path}\n\n{skills_01_block}\n\n{team_context_01}\n\nPlan: @{plan_01_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
502
+ Task(prompt="Execute plan at {plan_02_path}\n\n{skills_02_block}\n\n{team_context_02}\n\nPlan: @{plan_02_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
503
+ Task(prompt="Execute plan at {plan_03_path}\n\n{skills_03_block}\n\n{team_context_03}\n\nPlan: @{plan_03_path}\nProject state: @.planning/STATE.md", subagent_type="rrr-executor")
386
504
  ```
387
505
 
388
- Where `{skills_XX_block}` is the `<skills>` content containing skill SKILL.md files specific to that plan.
506
+ Where:
507
+ - `{skills_XX_block}` is the `<skills>` content containing skill SKILL.md files specific to that plan
508
+ - `{team_context_XX}` is the `<team_context>` block from `buildTeamPromptBlock()` (empty for single-plan waves)
509
+
510
+ All executors run in parallel. Task tool blocks until all complete.
511
+
512
+ **Step 3: Post-wave analysis (multi-plan waves only)**
389
513
 
390
- All three run in parallel. Task tool blocks until all complete.
514
+ ```javascript
515
+ // Collect team messages for logging
516
+ const { messages } = collectTeamMessages(team);
517
+ // Log: "[RRR] Wave {W}: {N} team messages exchanged"
518
+
519
+ // Check for file conflicts
520
+ const conflicts = detectFileConflicts(team, summaryPaths);
521
+ // If conflicts: present resolution UI via AskUserQuestion
522
+
523
+ // Archive team
524
+ cleanupWaveTeam(team);
525
+ ```
391
526
 
392
527
  **No polling.** No background agents. No TaskOutput loops.
528
+ **Single-plan waves:** Skip all team logic. Zero overhead. Same as before.
393
529
  </wave_execution>
394
530
 
395
531
  <checkpoint_handling>
@@ -168,6 +168,50 @@ Plan path: $ARGUMENTS
168
168
  - "Review plan first" → display plan summary, ask again
169
169
  - "Cancel" → exit without executing
170
170
 
171
+ 0.7. **Git branching (if configured)**
172
+
173
+ Check config.json for `git_branching` setting:
174
+
175
+ ```bash
176
+ GIT_BRANCHING=$(node -e "try { const c = require('./.planning/config.json'); console.log(c.git_branching || 'none'); } catch(e) { console.log('none'); }" 2>/dev/null)
177
+ ```
178
+
179
+ **If `git_branching` is `phase`:**
180
+ - Extract phase number and slug from plan path
181
+ - Check if branch `rrr/phase-{N}-{slug}` already exists
182
+ - If not: create and checkout the branch
183
+ ```bash
184
+ PHASE_NUM=$(basename "$(dirname "$ARGUMENTS")" | cut -d'-' -f1)
185
+ PHASE_SLUG=$(basename "$(dirname "$ARGUMENTS")" | sed "s/^${PHASE_NUM}-//")
186
+ BRANCH_NAME="rrr/phase-${PHASE_NUM}-${PHASE_SLUG}"
187
+
188
+ if ! git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
189
+ git checkout -b "$BRANCH_NAME"
190
+ echo "[RRR] Created branch: $BRANCH_NAME"
191
+ else
192
+ git checkout "$BRANCH_NAME" 2>/dev/null || echo "[RRR] Already on branch: $BRANCH_NAME"
193
+ fi
194
+ ```
195
+
196
+ **If `git_branching` is `milestone`:**
197
+ - Extract milestone version from ROADMAP.md
198
+ - Check if branch `rrr/{version}-{slug}` already exists
199
+ - If not: create and checkout the branch
200
+ ```bash
201
+ MILESTONE_VER=$(grep -E "^## Current Milestone:" .planning/ROADMAP.md 2>/dev/null | sed 's/.*: *\(v[0-9.]*\).*/\1/' || echo "vX.X")
202
+ PHASE_SLUG=$(basename "$(dirname "$ARGUMENTS")" | sed 's/^[0-9]*-//')
203
+ BRANCH_NAME="rrr/${MILESTONE_VER}-${PHASE_SLUG}"
204
+
205
+ if ! git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
206
+ git checkout -b "$BRANCH_NAME"
207
+ echo "[RRR] Created branch: $BRANCH_NAME"
208
+ else
209
+ git checkout "$BRANCH_NAME" 2>/dev/null || echo "[RRR] Already on branch: $BRANCH_NAME"
210
+ fi
211
+ ```
212
+
213
+ **If `none` (default):** No branching, continue on current branch.
214
+
171
215
  1. **Validate plan exists**
172
216
  - Confirm file at $ARGUMENTS exists
173
217
  - Error if not found: "Plan not found: {path}"
@@ -1,17 +1,67 @@
1
1
  ---
2
2
  name: rrr:mvp
3
- description: One-command router - detects project state and tells you exactly what to run next
3
+ description: One-command router - detects project state, estimates complexity, and tells you exactly what to run next
4
4
  ---
5
5
 
6
6
  <objective>
7
- Detect project state and provide the exact next command to run.
7
+ Detect project state, estimate task complexity, and provide the exact next command to run.
8
8
 
9
9
  Do NOT execute any commands yourself. Just detect and route.
10
10
  </objective>
11
11
 
12
+ <complexity_routing>
13
+ **For initialized projects, auto-select workflow depth based on task scope:**
14
+
15
+ Before routing to `/rrr:progress`, analyze the user's request (if they described a task) using these heuristics:
16
+
17
+ | Signal | Estimated Files | Route |
18
+ |--------|----------------|-------|
19
+ | 1-2 files, <50 lines changed | 1-2 | Direct edit (skip planning) |
20
+ | 3-5 files, single concern | 3-5 | `/rrr:plan-phase` (lightweight) |
21
+ | 6+ files or cross-cutting | 6+ | `/rrr:discuss-phase` then full cycle |
22
+ | Bug report / error trace | varies | `/rrr:debug` |
23
+ | "what's next" / no specific ask | 0 | `/rrr:progress` |
24
+
25
+ **Detection heuristic (applied to user's request text):**
26
+ - Parse for file count signals ("update the config" = 1 file, "refactor auth system" = many)
27
+ - Single-file keywords: "fix typo", "update version", "change the title", "edit the"
28
+ - Multi-file keywords: "component", "endpoint", "page", "feature", "add a new"
29
+ - Large-scope keywords: "system", "module", "refactor", "migrate", "overhaul", "across"
30
+ - Bug keywords: "broken", "error", "crash", "not working", "fails"
31
+ - Progress keywords: "what's next", "status", "where was I"
32
+
33
+ **Uses `rrr/lib/scope-classifier.js` — `estimateComplexity(text)` for classification.**
34
+ </complexity_routing>
35
+
12
36
  <behavior>
13
37
  1. **Check for existing RRR initialization:**
14
38
  - If `.planning/STATE.md` exists → project is already initialized
39
+
40
+ **1a. If user described a specific task (not just running `/rrr:mvp`):**
41
+ Apply complexity routing to their request:
42
+
43
+ ```
44
+ ## RRR Project State
45
+
46
+ **Status:** Initialized
47
+ **Task complexity:** [SMALL | MEDIUM | LARGE | DEBUG | PROGRESS]
48
+ **Estimated scope:** [N] file(s)
49
+
50
+ **Next command:** `/rrr:...`
51
+
52
+ [Explanation based on complexity level:]
53
+ - SMALL (1-2 files): "This looks like a small change. You can edit directly — no planning needed."
54
+ - MEDIUM (3-5 files): "This is a focused feature. Quick planning will keep it clean."
55
+ - LARGE (6+): "This is cross-cutting work. Discussing the approach first will save time."
56
+ - DEBUG: "This looks like a bug. Let's diagnose it."
57
+ - PROGRESS: [show progress]
58
+
59
+ ---
60
+
61
+ Want me to run it now?
62
+ ```
63
+
64
+ **1b. If no specific task described (just `/rrr:mvp` with no context):**
15
65
  - Route: Tell user to run `/rrr:progress`
16
66
  - Offer: "Want me to run `/rrr:progress` for you now?"
17
67
 
@@ -119,8 +119,76 @@ The script will detect if you run it inside Claude Code and prompt to confirm.
119
119
  ```
120
120
  </behavior>
121
121
 
122
+ <session_forking>
123
+ ## Session Forking (Claude Code v2.1+)
124
+
125
+ **When available**, session forking is the preferred method for overnight runs:
126
+
127
+ ### Detection
128
+
129
+ Check if session forking is available:
130
+ ```bash
131
+ # Session forking is available if Claude Code >= 2.1
132
+ claude --version 2>/dev/null | grep -E "^[2-9]\.[1-9]" && echo "Session forking available"
133
+ ```
134
+
135
+ ### How to use
136
+
137
+ Instead of running Jarvis in a new terminal, fork the current session:
138
+
139
+ ```bash
140
+ # Fork current session for overnight execution
141
+ # The forked session inherits all context from the parent
142
+ claude session fork --name "jarvis-overnight-$(date +%Y%m%d)"
143
+ ```
144
+
145
+ **Benefits of session forking over new terminal:**
146
+ - Forked session inherits parent context (STATE.md loaded, codebase mapped)
147
+ - No cold-start penalty for context loading
148
+ - Parent session can resume independently
149
+ - Forked session can be monitored: `claude session list`
150
+
151
+ ### Fork detection (for hooks)
152
+
153
+ If a session was forked, the hooks should detect it and load parent context:
154
+ ```bash
155
+ # Check if this is a forked session
156
+ if [ -n "$CLAUDE_PARENT_SESSION" ]; then
157
+ echo "[RRR] Forked session detected. Loading parent context..."
158
+ # Parent context is automatically available via fork
159
+ fi
160
+ ```
161
+
162
+ ### Fallback
163
+
164
+ If session forking is not available (Claude Code < 2.1), use the traditional Jarvis approach:
165
+ - Open separate terminal
166
+ - Run `bash scripts/jarvis.sh`
167
+ </session_forking>
168
+
169
+ <extended_timeout>
170
+ ## Extended Hook Timeout (Claude Code v2.1+)
171
+
172
+ Claude Code v2.1 increased the hook timeout from 60 seconds to 10 minutes.
173
+
174
+ **Impact on overnight preflight:**
175
+ - Jarvis preflight can now run comprehensive checks without timeout risk
176
+ - Previously constrained to lightweight checks (file existence, quick stats)
177
+ - Now can include: full test suite smoke test, dependency audit, git integrity check
178
+
179
+ **Recommended preflight additions (when 10-min timeout available):**
180
+ ```bash
181
+ # Extended preflight checks (only if timeout >= 600s)
182
+ npm test --bail 2>/dev/null # Quick smoke test
183
+ npm audit --audit-level=high 2>/dev/null # Security audit
184
+ git fsck --no-dangling 2>/dev/null # Git integrity
185
+ ```
186
+
187
+ These checks are skipped automatically if the hook detects the 60s timeout constraint.
188
+ </extended_timeout>
189
+
122
190
  <constraints>
123
191
  - Do NOT run jarvis.sh from this command
124
192
  - Only provide guidance and instructions
125
- - Always recommend running in a separate terminal
193
+ - Always recommend running in a separate terminal (or session fork if available)
126
194
  </constraints>
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: rrr:think
3
+ description: Apply structured thinking models for architecture decisions, risk assessment, scope cuts, and root cause analysis
4
+ argument-hint: "<model> [context]"
5
+ allowed-tools: [Read, Glob, Grep, Bash, AskUserQuestion]
6
+ ---
7
+
8
+ <objective>
9
+ Apply a structured decision framework to analyze a problem, decision, or design question.
10
+
11
+ Available models:
12
+ - `first-principles` -- Break down to fundamentals, rebuild. For architecture decisions.
13
+ - `inversion` -- "What would make this fail?" For risk assessment.
14
+ - `pareto` -- What 20% of work delivers 80% of value? For scope cuts.
15
+ - `five-whys` -- Chain of "why?" to find root cause. For debugging and design decisions.
16
+
17
+ Output: Structured analysis following the selected model's framework.
18
+ </objective>
19
+
20
+ <behavior>
21
+
22
+ ## 1. Parse arguments
23
+
24
+ Extract model name from $ARGUMENTS. If no model specified, present selector:
25
+
26
+ ```
27
+ ## /rrr:think -- Structured Decision Frameworks
28
+
29
+ Select a thinking model:
30
+
31
+ | Model | Best For | Command |
32
+ |-------|----------|---------|
33
+ | First Principles | Architecture decisions, "how should we build this?" | `/rrr:think first-principles` |
34
+ | Inversion | Risk assessment, "what could go wrong?" | `/rrr:think inversion` |
35
+ | Pareto (80/20) | Scope cuts, "what's the minimum viable work?" | `/rrr:think pareto` |
36
+ | 5 Whys | Root cause analysis, "why does this keep happening?" | `/rrr:think five-whys` |
37
+
38
+ Provide context after the model name:
39
+ `/rrr:think inversion should we use JWT or sessions for auth?`
40
+ ```
41
+
42
+ ## 2. Load thinking model template
43
+
44
+ Load the appropriate template from `rrr/templates/thinking-models/{model}.md`.
45
+
46
+ ## 3. Gather context
47
+
48
+ If context was provided in $ARGUMENTS, use it directly.
49
+
50
+ If no context provided, ask:
51
+ ```
52
+ What problem, decision, or question should we analyze?
53
+
54
+ Provide as much context as you have -- what you're building, constraints, options you're considering.
55
+ ```
56
+
57
+ Also load relevant project context:
58
+ - @.planning/STATE.md (current position)
59
+ - @.planning/ROADMAP.md (if exists, for scope awareness)
60
+ - Recent SUMMARY.md files (for established patterns/decisions)
61
+
62
+ ## 4. Execute thinking model
63
+
64
+ Follow the template's structured steps to produce analysis.
65
+
66
+ **Key rules:**
67
+ - Stay within the model's framework (don't mix models)
68
+ - Ground analysis in project-specific context, not generic advice
69
+ - Reference actual code, files, and decisions where applicable
70
+ - Produce actionable output, not abstract philosophy
71
+
72
+ ## 5. Present output
73
+
74
+ Format analysis using the model template's output structure.
75
+
76
+ End with:
77
+ ```
78
+ ---
79
+
80
+ **Model used:** {model-name}
81
+ **Next step:** {actionable recommendation}
82
+
83
+ Want to apply another model to this same question? `/rrr:think {different-model}`
84
+ ```
85
+
86
+ </behavior>
87
+
88
+ <constraints>
89
+ - Do NOT execute any commands or modify files
90
+ - Analysis only -- the user decides what to do with the output
91
+ - If the question is too vague, ask for specifics before analyzing
92
+ - Keep output focused and actionable (not academic)
93
+ - Maximum output: ~500 lines (keep it digestible)
94
+ </constraints>