@itz4blitz/agentful 1.7.0 → 1.8.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.
@@ -330,8 +330,9 @@ TodoWrite([
330
330
  6. Run @reviewer for quality gates
331
331
  7. If issues → @fixer → re-validate
332
332
  8. Update completion.json
333
- 9. Check if architecture needs re-analysis
334
- 10. LOOP until 100% complete
333
+ 9. COMPOUND: Store learnings and patterns
334
+ 10. Check if architecture needs re-analysis
335
+ 11. LOOP until 100% complete
335
336
  ```
336
337
 
337
338
  ### BUGFIX / ENHANCEMENT / REFACTOR
@@ -455,6 +456,188 @@ else:
455
456
  }
456
457
  ```
457
458
 
459
+ ## Worktree Management
460
+
461
+ Git worktrees provide isolated environments for parallel agent development. Each task can work in its own worktree without polluting the main repository.
462
+
463
+ ### Why Worktrees?
464
+
465
+ - **Isolation**: Changes are isolated until merged
466
+ - **Parallel Development**: Multiple agents can work simultaneously
467
+ - **Safety**: Experimental changes don't affect main branch
468
+ - **Clean History**: Each worktree has its own git history
469
+
470
+ ### Worktree Modes
471
+
472
+ Controlled via `AGENTFUL_WORKTREE_MODE` environment variable:
473
+
474
+ | Mode | Behavior | When to Use |
475
+ |-------|-----------|--------------|
476
+ | `auto` | Create worktrees automatically | Default, recommended |
477
+ | `block` | Require existing worktree | Strict environments |
478
+ | `off` | Allow direct edits | Legacy, manual control |
479
+
480
+ ### Before Delegation: Worktree Setup
481
+
482
+ Before delegating to any specialist agent:
483
+
484
+ ```bash
485
+ # Check worktree mode
486
+ if AGENTFUL_WORKTREE_MODE != "off":
487
+ # Check if we need a worktree
488
+ current_worktree = get_current_worktree()
489
+
490
+ if not current_worktree:
491
+ # Determine purpose from task type
492
+ purpose = determine_worktree_purpose(task_type)
493
+
494
+ # Create worktree via worktree-service
495
+ worktree = execute("node bin/hooks/worktree-service.js create " + purpose)
496
+
497
+ # Set environment for delegated agents
498
+ # They inherit AGENTFUL_WORKTREE_DIR
499
+ current_worktree = worktree
500
+
501
+ # Track in state.json
502
+ state.current_worktree = {
503
+ name: worktree.name,
504
+ path: worktree.path,
505
+ branch: worktree.branch,
506
+ purpose: worktree.purpose,
507
+ created_at: worktree.created_at
508
+ }
509
+ ```
510
+
511
+ ### Worktree Naming Convention
512
+
513
+ Worktrees are automatically named:
514
+
515
+ ```
516
+ agentful-<purpose>-<branch-slug>-<timestamp>
517
+ ```
518
+
519
+ Examples:
520
+ - `agentful-feature-auth-1739297120` - Feature development
521
+ - `agentful-fix-coverage-1739297150` - Fixer adding coverage
522
+ - `agentful-review-1739297180` - Reviewer validating
523
+ - `agentful-hotfix-login-bug-1739297210` - Hotfix work
524
+
525
+ ### State Schema Extension
526
+
527
+ Track worktrees in `.agentful/state.json`:
528
+
529
+ ```json
530
+ {
531
+ "current_task": "feature/auth",
532
+ "current_phase": "implementation",
533
+ "current_worktree": {
534
+ "name": "agentful-feature-auth-1739297120",
535
+ "path": "/Users/dev/project/.git/worktrees/agentful-feature-auth-1739297120",
536
+ "branch": "feature/auth",
537
+ "purpose": "feature",
538
+ "created_at": "2025-02-11T15:30:00Z"
539
+ },
540
+ "worktrees": {
541
+ "active": [
542
+ {
543
+ "name": "agentful-feature-auth-1739297120",
544
+ "branch": "feature/auth",
545
+ "purpose": "feature",
546
+ "agent": "orchestrator",
547
+ "created_at": "2025-02-11T15:30:00Z",
548
+ "last_activity": "2025-02-11T16:45:00Z"
549
+ }
550
+ ]
551
+ }
552
+ }
553
+ ```
554
+
555
+ ### After Task Completion: Worktree Cleanup
556
+
557
+ When a feature passes all quality gates:
558
+
559
+ ```bash
560
+ if task_completed and AGENTFUL_WORKTREE_AUTO_CLEANUP != "false":
561
+ # Commit changes in worktree
562
+ git -C $WORKTREE_PATH add .
563
+ git -C $WORKTREE_PATH commit -m "feat: complete ${feature_name}"
564
+
565
+ # Ask user what to do next
566
+ response = AskUserQuestion(
567
+ "Feature complete! What would you like to do?",
568
+ options: [
569
+ "Create PR",
570
+ "Merge to main",
571
+ "Keep worktree for review",
572
+ "Clean up worktree"
573
+ ]
574
+ )
575
+
576
+ if response == "Create PR" or response == "Merge to main":
577
+ # Push and create PR/merge
578
+ git -C $WORKTREE_PATH push
579
+ # ... PR creation logic ...
580
+
581
+ # Remove worktree
582
+ execute("node bin/hooks/worktree-service.js remove " + worktree.name)
583
+
584
+ # Update state.json
585
+ state.current_worktree = null
586
+ ```
587
+
588
+ ### Handling Interruptions
589
+
590
+ If user interrupts during worktree operation:
591
+
592
+ ```bash
593
+ on SIGINT:
594
+ if active_worktree:
595
+ # Mark for review instead of deleting
596
+ state.interrupted_worktree = {
597
+ name: active_worktree.name,
598
+ path: active_worktree.path,
599
+ interrupted_at: new Date().toISOString()
600
+ }
601
+
602
+ console.log("Worktree preserved: " + active_worktree.name)
603
+ console.log("Run /agentful-worktree --resume to continue")
604
+ console.log("Run /agentful-worktree --cleanup to remove")
605
+ ```
606
+
607
+ ### Worktree Service API
608
+
609
+ The `worktree-service.js` provides these operations:
610
+
611
+ ```bash
612
+ node bin/hooks/worktree-service.js create <purpose> [branch] # Create worktree
613
+ node bin/hooks/worktree-service.js list # List all worktrees
614
+ node bin/hooks/worktree-service.js status # Show current status
615
+ node bin/hooks/worktree-service.js cleanup # Remove stale worktrees
616
+ node bin/hooks/worktree-service.js prune # Run git prune
617
+ node bin/hooks/worktree-service.js remove <name> # Remove specific worktree
618
+ ```
619
+
620
+ ### Environment Variables
621
+
622
+ | Variable | Default | Description |
623
+ |-----------|----------|-------------|
624
+ | `AGENTFUL_WORKTREE_MODE` | `auto` | Worktree enforcement mode |
625
+ | `AGENTFUL_WORKTREE_DIR` | (auto-set) | Current worktree path |
626
+ | `AGENTFUL_WORKTREE_LOCATION` | `../` | Where to create worktrees |
627
+ | `AGENTFUL_WORKTREE_AUTO_CLEANUP` | `true` | Auto-remove after completion |
628
+ | `AGENTFUL_WORKTREE_RETENTION_DAYS` | `7` | Days before stale cleanup |
629
+ | `AGENTFUL_WORKTREE_MAX_ACTIVE` | `5` | Maximum active worktrees |
630
+
631
+ ### CI/CD Detection
632
+
633
+ Worktree mode auto-disables in CI environments:
634
+
635
+ ```bash
636
+ if process.env.CI == "true" or process.env.GITHUB_ACTIONS == "true":
637
+ # Skip worktree creation
638
+ # CI already provides isolated environments
639
+ ```
640
+
458
641
  ## Delegation Pattern
459
642
 
460
643
  **NEVER implement yourself.** Always use Task tool.
@@ -502,6 +685,48 @@ Task("reviewer agent", "Review all changes in src/auth/")
502
685
  - ❌ Fixer needs reviewer results before fixing issues
503
686
  - ❌ Quality gates (must validate sequentially)
504
687
 
688
+ ### COMPOUND Phase
689
+
690
+ After a feature passes all quality gates in FEATURE_DEVELOPMENT, run the compound phase:
691
+
692
+ 1. **Store successful patterns to MCP** (if available):
693
+ ```
694
+ Try MCP tool: store_pattern
695
+ - code: <key implementation pattern that worked well>
696
+ - tech_stack: <detected tech stack>
697
+ ```
698
+ - Only store if feature passed all quality gates
699
+ - Focus on reusable patterns (not one-off code)
700
+ - If tool unavailable: skip silently
701
+
702
+ 2. **Append retrospective to `.agentful/learnings.json`** (create if missing):
703
+ ```json
704
+ {
705
+ "learnings": [
706
+ {
707
+ "feature": "<feature name>",
708
+ "timestamp": "<ISO 8601>",
709
+ "review_fix_cycles": <number of review→fix→re-validate cycles>,
710
+ "gates_failed_initially": ["<gate names that failed on first review>"],
711
+ "key_learning": "<1-sentence summary of what was learned>"
712
+ }
713
+ ]
714
+ }
715
+ ```
716
+
717
+ 3. **Track iteration metrics** in `state.json`:
718
+ ```json
719
+ {
720
+ "last_feature_metrics": {
721
+ "feature": "<feature name>",
722
+ "cycles": <review/fix cycle count>,
723
+ "gates_passed_first_try": <boolean>
724
+ }
725
+ }
726
+ ```
727
+
728
+ **Skip COMPOUND for**: BUGFIX, ENHANCEMENT, REFACTOR workflows and blocked/skipped features.
729
+
505
730
  ## Decision Handling
506
731
 
507
732
  When you need user input:
@@ -2,7 +2,7 @@
2
2
  name: reviewer
3
3
  description: Reviews code quality, finds dead code, validates production readiness. Runs all checks and reports issues.
4
4
  model: sonnet
5
- tools: Read, Write, Edit, Glob, Grep, Bash
5
+ tools: Read, Write, Edit, Glob, Grep, Bash, mcp__agentful__store_pattern
6
6
  ---
7
7
 
8
8
  # Reviewer Agent
@@ -38,6 +38,24 @@ Fall back to manual Grep if none available
38
38
 
39
39
  **Reference the validation skill** (`.claude/skills/validation/SKILL.md`) for comprehensive validation strategies.
40
40
 
41
+ ## Step 1.5: Worktree Check
42
+
43
+ Before running checks, verify your working environment:
44
+
45
+ ```bash
46
+ # Check if AGENTFUL_WORKTREE_DIR is set
47
+ if exists("$AGENTFUL_WORKTREE_DIR"):
48
+ worktree_path = "$AGENTFUL_WORKTREE_DIR"
49
+ echo "✅ Reviewing in worktree: $worktree_path"
50
+ else:
51
+ echo "📍 Reviewing in root repository"
52
+ echo "⚠️ Validation reports will be saved to main .agentful/"
53
+ ```
54
+
55
+ **Report worktree status**: In your validation report, always include:
56
+ - Worktree path (if applicable)
57
+ - Branch being validated
58
+
41
59
  ## Your Scope
42
60
 
43
61
  - **Type Checking** - Run type checker (tsc, mypy, etc.)
@@ -221,9 +239,21 @@ When validation tools are unavailable:
221
239
 
222
240
  ## After Implementation
223
241
 
224
- Report:
225
- - Overall validation status (passed/failed)
226
- - Which gates passed/failed
227
- - List of issues requiring fixes
228
- - List of warnings that can be ignored
229
- - Recommendation: delegate to @fixer if issues found
242
+ 1. **Store error patterns to MCP** (if available):
243
+ For each failed gate with specific error messages:
244
+ ```
245
+ Try MCP tool: store_pattern
246
+ - code: <error pattern and context>
247
+ - tech_stack: <detected tech stack>
248
+ - error: <specific error message from failed gate>
249
+ ```
250
+ - Focus on recurring or non-obvious errors
251
+ - Include enough context for the fixer to match against
252
+ - If tool unavailable: skip silently
253
+
254
+ 2. **Report**:
255
+ - Overall validation status (passed/failed)
256
+ - Which gates passed/failed
257
+ - List of issues requiring fixes
258
+ - List of warnings that can be ignored
259
+ - Recommendation: delegate to @fixer if issues found
@@ -2,7 +2,7 @@
2
2
  name: tester
3
3
  description: Writes comprehensive unit, integration, and E2E tests. Ensures coverage meets 80% threshold.
4
4
  model: sonnet
5
- tools: Read, Write, Edit, Glob, Grep, Bash, mcp__agentful-mcp-server__find_patterns, mcp__agentful-mcp-server__store_pattern, mcp__agentful-mcp-server__add_feedback
5
+ tools: Read, Write, Edit, Glob, Grep, Bash, mcp__agentful__find_patterns, mcp__agentful__store_pattern, mcp__agentful__add_feedback
6
6
  ---
7
7
 
8
8
  # Tester Agent
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: agentful-worktree
3
+ description: Manage git worktrees for parallel agent development. List, create, and cleanup worktrees.
4
+ ---
5
+
6
+ # /agentful-worktree
7
+
8
+ Manage git worktrees for parallel agentful development.
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ /agentful-worktree # List all active worktrees
14
+ /agentful-worktree --status # Show current session worktree
15
+ /agentful-worktree --create feature/x # Create new worktree for branch
16
+ /agentful-worktree --cleanup # Remove stale worktrees
17
+ /agentful-worktree --prune # Run git worktree prune
18
+ /agentful-worktree --remove <name> # Remove specific worktree
19
+ ```
20
+
21
+ ## Environment Variables
22
+
23
+ | Variable | Default | Description |
24
+ |-----------|----------|-------------|
25
+ | `AGENTFUL_WORKTREE_MODE` | `auto` | `auto` (create), `block` (require), `off` (disabled) |
26
+ | `AGENTFUL_WORKTREE_LOCATION` | `../` | Where to create worktrees (relative to repo) |
27
+ | `AGENTFUL_WORKTREE_AUTO_CLEANUP` | `true` | Auto-remove worktrees after task completion |
28
+ | `AGENTFUL_WORKTREE_RETENTION_DAYS` | `7` | Days before worktrees are marked stale |
29
+ | `AGENTFUL_WORKTREE_MAX_ACTIVE` | `5` | Maximum active worktrees before cleanup forced |
30
+
31
+ ## Examples
32
+
33
+ ### List Worktrees
34
+
35
+ ```
36
+ /agentful-worktree
37
+ ```
38
+
39
+ Output:
40
+ ```
41
+ 📋 Active Worktrees:
42
+
43
+ ┌─────────────────────────────────────────────────────────────┐
44
+ │ agentful-feature-auth-1739297120 │
45
+ │ ├─ Branch: feature/auth │
46
+ │ ├─ Purpose: feature │
47
+ │ ├─ Path: ../agentful-feature-auth-1739297120 │
48
+ │ ├─ Status: 🟢 Active (15 min ago) │
49
+ │ └─ Created: 2025-02-11T15:30:00.000Z │
50
+ └─────────────────────────────────────────────────────────────┘
51
+ ```
52
+
53
+ ### Show Current Status
54
+
55
+ ```
56
+ /agentful-worktree --status
57
+ ```
58
+
59
+ ### Create Worktree
60
+
61
+ ```
62
+ /agentful-worktree --create feature/dashboard
63
+ ```
64
+
65
+ Creates a worktree named `agentful-feature-dashboard-<timestamp>` on the `feature/dashboard` branch.
66
+
67
+ ### Cleanup Stale Worktrees
68
+
69
+ ```
70
+ /agentful-worktree --cleanup
71
+ ```
72
+
73
+ Removes worktrees older than `AGENTFUL_WORKTREE_RETENTION_DAYS` (default: 7 days).
74
+
75
+ ## Worktree Naming Convention
76
+
77
+ Worktrees are automatically named using this pattern:
78
+
79
+ ```
80
+ agentful-<purpose>-<branch-slug>-<timestamp>
81
+ ```
82
+
83
+ Examples:
84
+ - `agentful-feature-auth-1739297120` - Feature development
85
+ - `agentful-fix-coverage-1739297150` - Fixer adding coverage
86
+ - `agentful-review-1739297180` - Reviewer validating
87
+ - `agentful-hotfix-login-bug-1739297210` - Hotfix work
88
+
89
+ ## When to Use Worktrees
90
+
91
+ **Use worktrees when**:
92
+ - Working on multiple features simultaneously
93
+ - Running quality gates while developing other features
94
+ - Reviewing PRs without interrupting active work
95
+ - Testing experimental approaches safely
96
+
97
+ **Don't need worktrees when**:
98
+ - Quick fixes in a single feature branch
99
+ - Documentation-only changes
100
+ - Set `AGENTFUL_WORKTREE_MODE=off` to disable
101
+
102
+ ## See Also
103
+
104
+ - [Git Worktrees Concept](/concepts/git-worktrees) - Deep dive on worktree usage
105
+ - [/agentful-start](/commands/agentful-start) - Main development loop
106
+ - [/agentful-status](/commands/agentful-status) - Check completion progress
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "includeCoAuthoredBy": false,
3
3
  "env": {
4
- "ENABLE_TOOL_SEARCH": "true"
4
+ "ENABLE_TOOL_SEARCH": "true",
5
+ "AGENTFUL_WORKTREE_MODE": "auto"
5
6
  },
6
7
  "hooks": {
7
8
  "SessionStart": [
@@ -23,6 +24,17 @@
23
24
  }
24
25
  ],
25
26
  "PreToolUse": [
27
+ {
28
+ "tools": ["Write", "Edit"],
29
+ "hooks": [
30
+ {
31
+ "type": "command",
32
+ "command": "node bin/hooks/ensure-worktree.js",
33
+ "timeout": 10,
34
+ "description": "Ensure agents work in git worktrees (disable with AGENTFUL_WORKTREE_MODE=off)"
35
+ }
36
+ ]
37
+ },
26
38
  {
27
39
  "tools": ["Write", "Edit"],
28
40
  "hooks": [
@@ -61,6 +61,23 @@ When you start a Claude Code session, agentful automatically:
61
61
 
62
62
  No need to remember commands - just pick a numbered action!
63
63
 
64
+ ## Pattern Learning (MCP Server)
65
+
66
+ Enable cross-session pattern learning so agents compound knowledge over time:
67
+
68
+ ```bash
69
+ claude mcp add agentful -- npx -y @itz4blitz/agentful-mcp-server
70
+ ```
71
+
72
+ **What this enables:**
73
+ - **Reviewer** stores error patterns so the fixer can look up known fixes instantly
74
+ - **Fixer** queries known fixes before attempting manual repairs, then stores successful fixes
75
+ - **Orchestrator** stores successful implementation patterns after features pass all quality gates
76
+
77
+ Without MCP: agents start from scratch every session. With MCP: agents compound across sessions.
78
+
79
+ See [Hooks System](#hooks-system) below for manual setup or other editors.
80
+
64
81
  ## Commands
65
82
 
66
83
  | Command | Description | When to Use |
@@ -119,6 +136,8 @@ These appear only when relevant:
119
136
  - `.agentful/conversation-history.json` - Message history for context tracking
120
137
  - `.agentful/agent-metrics.json` - Agent lifecycle hooks and metrics
121
138
  - `.agentful/architecture.json` - Detected tech stack and generated agents
139
+ - `.agentful/learnings.json` - Compound engineering retrospectives
140
+ - `.agentful/last-validation.json` - Latest validation report from reviewer
122
141
 
123
142
  **Configuration** (auto-generated, customizable):
124
143
  - `.claude/agents/` - Specialized agents for your tech stack
@@ -180,6 +199,33 @@ The `reviewer` agent runs these checks automatically. The `fixer` agent resolves
180
199
  - Estimated remaining work
181
200
  → If no progress for 2+ minutes, the task may be stuck. Check `.agentful/state.json` for circuit breaker status.
182
201
 
202
+ ### Git Worktree Mode
203
+
204
+ agentful supports automatic git worktree management for safer parallel development.
205
+
206
+ **Modes**:
207
+ | Mode | Behavior |
208
+ |-------|-----------|
209
+ | `auto` | Create worktrees automatically when agents make changes (recommended) |
210
+ | `block` | Require agents to work in existing worktrees |
211
+ | `off` | Allow direct edits to root repository (legacy) |
212
+
213
+ **Enable via environment**:
214
+ ```bash
215
+ export AGENTFUL_WORKTREE_MODE=auto
216
+ ```
217
+
218
+ **Or in `.claude/settings.json`**:
219
+ ```json
220
+ {
221
+ "env": {
222
+ "AGENTFUL_WORKTREE_MODE": "auto"
223
+ }
224
+ }
225
+ ```
226
+
227
+ **More configuration**: See [/agentful-worktree](/commands/agentful-worktree) command and [Git Worktrees concept](/concepts/git-worktrees) for full details.
228
+
183
229
  ## Getting Help
184
230
 
185
231
  **Documentation**: See `.claude/commands/` for detailed command documentation
package/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.6.0"
2
+ "version": "1.8.0"
3
3
  }