the-grid-cc 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GRID_EVOLUTION.md +297 -0
- package/README.md +172 -116
- package/agents/grid-debugger.md +99 -35
- package/agents/grid-executor.md +161 -10
- package/commands/grid/VERSION +1 -1
- package/commands/grid/mc.md +321 -309
- package/package.json +1 -1
- package/.grid/STATE.md +0 -22
- package/.grid/plans/blog-PLAN-SUMMARY.md +0 -518
- package/.grid/plans/blog-block-01.md +0 -180
- package/.grid/plans/blog-block-02.md +0 -229
- package/.grid/plans/blog-block-03.md +0 -253
- package/.grid/plans/blog-block-04.md +0 -287
- package/.grid/plans/blog-block-05.md +0 -235
- package/.grid/plans/blog-block-06.md +0 -325
- package/DEMO_SCRIPT.md +0 -162
- package/HN_POST.md +0 -104
- package/TICKETS.md +0 -585
- package/test-cli/converter.py +0 -206
- package/test-cli/test_data.json +0 -39
- package/test-cli/test_data.yaml +0 -35
- package/todo-app/README.md +0 -16
- package/todo-app/eslint.config.js +0 -29
- package/todo-app/index.html +0 -13
- package/todo-app/package-lock.json +0 -2917
- package/todo-app/package.json +0 -27
- package/todo-app/public/vite.svg +0 -1
- package/todo-app/src/App.css +0 -125
- package/todo-app/src/App.jsx +0 -84
- package/todo-app/src/index.css +0 -68
- package/todo-app/src/main.jsx +0 -10
- package/todo-app/vite.config.js +0 -7
package/commands/grid/mc.md
CHANGED
|
@@ -50,19 +50,23 @@ No boxes. No bloat. Just direct communication.
|
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
## MODE
|
|
53
|
+
## MODE BEHAVIOR
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
**Default: AUTOPILOT.** Don't ask. Just build.
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
How involved do you want to be?
|
|
57
|
+
Mode selection is friction. Most Users want results, not configuration. Infer the right mode:
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
| User Signal | Mode | Behavior |
|
|
60
|
+
|-------------|------|----------|
|
|
61
|
+
| "build X", "make X", "create X" | AUTOPILOT | Zero questions, just build |
|
|
62
|
+
| "help me with", "let's", "I want" | GUIDED | Minimal questions (max 1-2) |
|
|
63
|
+
| "what should", "options for", "how would" | HANDS ON | Collaborative, but still fast |
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
**Only ask about mode if:**
|
|
66
|
+
- Project is genuinely ambiguous (could be 3+ completely different things)
|
|
67
|
+
- User explicitly asks for control
|
|
68
|
+
|
|
69
|
+
### AUTOPILOT (Default)
|
|
66
70
|
|
|
67
71
|
**ZERO QUESTIONS.** User wants results, not dialogue. You:
|
|
68
72
|
|
|
@@ -93,7 +97,7 @@ Refinement Swarm ran:
|
|
|
93
97
|
- What flows to test
|
|
94
98
|
- What visual standards apply
|
|
95
99
|
|
|
96
|
-
### GUIDED
|
|
100
|
+
### GUIDED
|
|
97
101
|
|
|
98
102
|
**QUESTIONS ONLY WHEN ESSENTIAL.** You drive, but ask when:
|
|
99
103
|
- User identity is genuinely ambiguous (blog for who? dashboard for what role?)
|
|
@@ -111,7 +115,7 @@ Who's the primary user? (I'll simulate their experience)
|
|
|
111
115
|
Got it. Building...
|
|
112
116
|
```
|
|
113
117
|
|
|
114
|
-
### HANDS ON
|
|
118
|
+
### HANDS ON
|
|
115
119
|
|
|
116
120
|
User wants control. Use dream extraction questioning (but keep it minimal):
|
|
117
121
|
- Max 2-3 questions total
|
|
@@ -123,6 +127,48 @@ Instead: "Here's what I recommend: X, Y, Z. Any changes?"
|
|
|
123
127
|
|
|
124
128
|
---
|
|
125
129
|
|
|
130
|
+
## SPAWN HEURISTICS
|
|
131
|
+
|
|
132
|
+
**Don't over-spawn.** More agents ≠ faster. Calculate spawn count:
|
|
133
|
+
|
|
134
|
+
| Complexity | Indicators | Agents |
|
|
135
|
+
|------------|------------|--------|
|
|
136
|
+
| **Trivial** | 1-2 files, obvious fix | 1 agent |
|
|
137
|
+
| **Simple** | 2-3 files, clear scope | 1-2 agents |
|
|
138
|
+
| **Medium** | 3-6 files, some coupling | 2-3 agents |
|
|
139
|
+
| **Complex** | 6+ files, cross-cutting | 3-5 agents |
|
|
140
|
+
| **Massive** | Architecture change | 5-10 agents |
|
|
141
|
+
|
|
142
|
+
**Spawn count formula:**
|
|
143
|
+
```python
|
|
144
|
+
def spawn_count(plan):
|
|
145
|
+
files = len(plan.files_modified)
|
|
146
|
+
|
|
147
|
+
# Base count
|
|
148
|
+
if files <= 2: base = 1
|
|
149
|
+
elif files <= 5: base = 2
|
|
150
|
+
elif files <= 10: base = 3
|
|
151
|
+
else: base = min(files // 3, 10)
|
|
152
|
+
|
|
153
|
+
# Adjustments
|
|
154
|
+
if plan.files_overlap_with_other_plans: base = 1 # Serialize, don't parallelize
|
|
155
|
+
if plan.has_checkpoints: base = max(1, base - 1) # Checkpoints slow things down
|
|
156
|
+
|
|
157
|
+
return base
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**When to parallelize:**
|
|
161
|
+
- Independent subsystems (auth AND dashboard = parallel)
|
|
162
|
+
- No file overlap between plans
|
|
163
|
+
- Fresh context needed anyway
|
|
164
|
+
|
|
165
|
+
**When NOT to parallelize:**
|
|
166
|
+
- Tightly coupled files (merge conflicts)
|
|
167
|
+
- Discovery dependencies (agent A finds what B needs)
|
|
168
|
+
- Simple tasks (spawn overhead > work)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
126
172
|
## PROGRAM SPAWNING PROTOCOL
|
|
127
173
|
|
|
128
174
|
### Available Programs
|
|
@@ -233,6 +279,157 @@ Task(
|
|
|
233
279
|
|
|
234
280
|
---
|
|
235
281
|
|
|
282
|
+
## EXECUTE-AND-VERIFY PRIMITIVE
|
|
283
|
+
|
|
284
|
+
**Executor + Recognizer is the atomic unit.** Don't spawn Executor without planning to verify.
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
def execute_and_verify(plan_content, state_content, warmth=None):
|
|
288
|
+
"""Execute a plan and verify the result. Returns combined output."""
|
|
289
|
+
|
|
290
|
+
# 1. Spawn Executor
|
|
291
|
+
exec_result = Task(
|
|
292
|
+
prompt=f"""
|
|
293
|
+
First, read ~/.claude/agents/grid-executor.md for your role.
|
|
294
|
+
|
|
295
|
+
<state>{state_content}</state>
|
|
296
|
+
<plan>{plan_content}</plan>
|
|
297
|
+
{f'<warmth>{warmth}</warmth>' if warmth else ''}
|
|
298
|
+
|
|
299
|
+
Execute the plan. Include lessons_learned in your SUMMARY.
|
|
300
|
+
""",
|
|
301
|
+
subagent_type="general-purpose",
|
|
302
|
+
model="sonnet",
|
|
303
|
+
description="Execute plan"
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
# 2. If checkpoint hit, return early (don't verify incomplete work)
|
|
307
|
+
if "CHECKPOINT REACHED" in exec_result:
|
|
308
|
+
return exec_result
|
|
309
|
+
|
|
310
|
+
# 3. Read the SUMMARY for verification context
|
|
311
|
+
summary = read(f".grid/phases/{block_dir}/{block}-SUMMARY.md")
|
|
312
|
+
|
|
313
|
+
# 4. Spawn Recognizer
|
|
314
|
+
verify_result = Task(
|
|
315
|
+
prompt=f"""
|
|
316
|
+
First, read ~/.claude/agents/grid-recognizer.md for your role.
|
|
317
|
+
|
|
318
|
+
<summary>{summary}</summary>
|
|
319
|
+
<plan>{plan_content}</plan>
|
|
320
|
+
|
|
321
|
+
Verify goal achievement, not just task completion.
|
|
322
|
+
""",
|
|
323
|
+
subagent_type="general-purpose",
|
|
324
|
+
model="sonnet",
|
|
325
|
+
description="Verify execution"
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
"execution": exec_result,
|
|
330
|
+
"verification": verify_result
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**When verification finds gaps:** Spawn Planner with `--gaps` flag.
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## WARMTH TRANSFER PROTOCOL
|
|
339
|
+
|
|
340
|
+
**Programs die, but their knowledge shouldn't.**
|
|
341
|
+
|
|
342
|
+
When spawning a continuation or fresh Program after another completes:
|
|
343
|
+
|
|
344
|
+
### 1. Extract Warmth from Dying Program
|
|
345
|
+
|
|
346
|
+
Programs include `lessons_learned` in their SUMMARY.md:
|
|
347
|
+
|
|
348
|
+
```yaml
|
|
349
|
+
---
|
|
350
|
+
# ... other frontmatter
|
|
351
|
+
lessons_learned:
|
|
352
|
+
codebase_patterns:
|
|
353
|
+
- "This codebase uses barrel exports (index.ts)"
|
|
354
|
+
- "API routes expect req.json() not req.body"
|
|
355
|
+
gotchas:
|
|
356
|
+
- "The auth middleware runs before validation"
|
|
357
|
+
- "Database timestamps are UTC, not local"
|
|
358
|
+
user_preferences:
|
|
359
|
+
- "User prefers explicit error messages"
|
|
360
|
+
- "User wants mobile-first styling"
|
|
361
|
+
almost_did:
|
|
362
|
+
- "Considered using Zustand but stuck with useState for simplicity"
|
|
363
|
+
---
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### 2. Pass Warmth to Fresh Program
|
|
367
|
+
|
|
368
|
+
```python
|
|
369
|
+
Task(
|
|
370
|
+
prompt=f"""
|
|
371
|
+
First, read ~/.claude/agents/grid-executor.md for your role.
|
|
372
|
+
|
|
373
|
+
<warmth>
|
|
374
|
+
Previous Program learned:
|
|
375
|
+
{lessons_learned_yaml}
|
|
376
|
+
</warmth>
|
|
377
|
+
|
|
378
|
+
<state>{state}</state>
|
|
379
|
+
<plan>{plan}</plan>
|
|
380
|
+
|
|
381
|
+
Apply the warmth above. Don't repeat mistakes. Build on discoveries.
|
|
382
|
+
""",
|
|
383
|
+
...
|
|
384
|
+
)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### 3. Warmth Categories
|
|
388
|
+
|
|
389
|
+
| Category | Contents |
|
|
390
|
+
|----------|----------|
|
|
391
|
+
| `codebase_patterns` | How this codebase does things |
|
|
392
|
+
| `gotchas` | Traps to avoid |
|
|
393
|
+
| `user_preferences` | What User seems to want |
|
|
394
|
+
| `almost_did` | Decisions considered but rejected (with why) |
|
|
395
|
+
| `fragile_areas` | Code that breaks easily |
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## SCRATCHPAD PROTOCOL
|
|
400
|
+
|
|
401
|
+
**Live discoveries during execution.**
|
|
402
|
+
|
|
403
|
+
`.grid/SCRATCHPAD.md` - Programs write here during execution, not just at end.
|
|
404
|
+
|
|
405
|
+
### Structure
|
|
406
|
+
```markdown
|
|
407
|
+
---
|
|
408
|
+
updated: {ISO timestamp}
|
|
409
|
+
active_programs: [executor-01, executor-02]
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
## Live Discoveries
|
|
413
|
+
|
|
414
|
+
### executor-01 (14:32:05)
|
|
415
|
+
Found: Database connection string is in .env.local, not .env
|
|
416
|
+
Impact: Other programs need to know this
|
|
417
|
+
|
|
418
|
+
### executor-02 (14:32:18)
|
|
419
|
+
Found: The User model has a deprecated 'name' field, use 'displayName'
|
|
420
|
+
Impact: All User queries should use displayName
|
|
421
|
+
|
|
422
|
+
### executor-01 (14:33:42)
|
|
423
|
+
Correction: Actually .env.local only for development, .env for both
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Usage
|
|
427
|
+
- **Write** when discovering something other Programs need
|
|
428
|
+
- **Read** before starting execution
|
|
429
|
+
- **Clear** after wave completes (archive to SCRATCHPAD_ARCHIVE.md)
|
|
430
|
+
|
|
431
|
+
---
|
|
432
|
+
|
|
236
433
|
## CHECKPOINT PROTOCOL
|
|
237
434
|
|
|
238
435
|
When a Program hits a checkpoint, it returns structured data:
|
|
@@ -267,6 +464,7 @@ When a Program hits a checkpoint, it returns structured data:
|
|
|
267
464
|
- Completed threads table
|
|
268
465
|
- User's response
|
|
269
466
|
- Resume point
|
|
467
|
+
- **Warmth from prior Program**
|
|
270
468
|
|
|
271
469
|
---
|
|
272
470
|
|
|
@@ -284,6 +482,64 @@ When you need User input, just ask directly. No ASCII art.
|
|
|
284
482
|
|
|
285
483
|
---
|
|
286
484
|
|
|
485
|
+
## RETRY PROTOCOL
|
|
486
|
+
|
|
487
|
+
**When Programs fail, don't retry blind.**
|
|
488
|
+
|
|
489
|
+
### Structured Failure Report
|
|
490
|
+
|
|
491
|
+
Programs return on failure:
|
|
492
|
+
```yaml
|
|
493
|
+
## EXECUTION FAILED
|
|
494
|
+
|
|
495
|
+
**Block:** {block-id}
|
|
496
|
+
**Thread:** {thread that failed}
|
|
497
|
+
**Attempts:** {N}
|
|
498
|
+
|
|
499
|
+
### What Was Tried
|
|
500
|
+
1. {Approach 1} — Failed because: {reason}
|
|
501
|
+
2. {Approach 2} — Failed because: {reason}
|
|
502
|
+
|
|
503
|
+
### Partial Work
|
|
504
|
+
- Created: {files created before failure}
|
|
505
|
+
- Commits: {commits made}
|
|
506
|
+
|
|
507
|
+
### Hypothesis
|
|
508
|
+
{Why it's failing}
|
|
509
|
+
|
|
510
|
+
### Suggested Retry Approach
|
|
511
|
+
{Different approach to try}
|
|
512
|
+
|
|
513
|
+
### Do NOT Retry
|
|
514
|
+
- {Approach that definitely won't work}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Retry Spawning
|
|
518
|
+
|
|
519
|
+
Pass failure context to retry:
|
|
520
|
+
```python
|
|
521
|
+
Task(
|
|
522
|
+
prompt=f"""
|
|
523
|
+
First, read ~/.claude/agents/grid-executor.md for your role.
|
|
524
|
+
|
|
525
|
+
<prior_failure>
|
|
526
|
+
{failure_report}
|
|
527
|
+
</prior_failure>
|
|
528
|
+
|
|
529
|
+
<state>{state}</state>
|
|
530
|
+
<plan>{plan}</plan>
|
|
531
|
+
|
|
532
|
+
Previous attempt failed. DO NOT repeat failed approaches.
|
|
533
|
+
Try the suggested retry approach or a novel approach.
|
|
534
|
+
""",
|
|
535
|
+
subagent_type="general-purpose",
|
|
536
|
+
model="sonnet", # Maybe upgrade to opus for retries
|
|
537
|
+
description="Retry execution"
|
|
538
|
+
)
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
287
543
|
## STATE MANAGEMENT
|
|
288
544
|
|
|
289
545
|
### STATE.md Structure
|
|
@@ -339,10 +595,19 @@ key-files:
|
|
|
339
595
|
created: [src/lib/auth.ts]
|
|
340
596
|
modified: [prisma/schema.prisma]
|
|
341
597
|
commits: [abc123, def456]
|
|
598
|
+
|
|
599
|
+
# WARMTH - knowledge that survives
|
|
600
|
+
lessons_learned:
|
|
601
|
+
codebase_patterns:
|
|
602
|
+
- "Pattern discovered"
|
|
603
|
+
gotchas:
|
|
604
|
+
- "Gotcha found"
|
|
605
|
+
almost_did:
|
|
606
|
+
- "Considered X, chose Y because Z"
|
|
342
607
|
---
|
|
343
608
|
```
|
|
344
609
|
|
|
345
|
-
This frontmatter enables fast context assembly
|
|
610
|
+
This frontmatter enables fast context assembly AND warmth transfer.
|
|
346
611
|
|
|
347
612
|
---
|
|
348
613
|
|
|
@@ -396,15 +661,6 @@ Focus on actionable patterns, not project-specific details.
|
|
|
396
661
|
)
|
|
397
662
|
```
|
|
398
663
|
|
|
399
|
-
### Learnings Application
|
|
400
|
-
|
|
401
|
-
When planning new projects, consult learnings:
|
|
402
|
-
|
|
403
|
-
1. **Tech Stack Selection** - "Last React project, X library caused issues"
|
|
404
|
-
2. **Architecture Decisions** - "Authentication pattern Y worked well"
|
|
405
|
-
3. **Execution Strategy** - "Phase ordering Z prevented rework"
|
|
406
|
-
4. **Checkpoint Placement** - "Human verification needed at point W"
|
|
407
|
-
|
|
408
664
|
### LEARNINGS.md Format
|
|
409
665
|
|
|
410
666
|
```markdown
|
|
@@ -418,53 +674,23 @@ Accumulated patterns from past projects. Read at session start, write after comp
|
|
|
418
674
|
|
|
419
675
|
**Project Type:** {web-app | api | cli | library | integration | etc}
|
|
420
676
|
**Tech Stack:** {key technologies used}
|
|
421
|
-
**Duration:** {time from start to completion}
|
|
422
677
|
**Complexity:** {simple | medium | complex | massive}
|
|
423
678
|
|
|
424
679
|
### What Worked
|
|
425
680
|
- {Pattern or approach that succeeded}
|
|
426
|
-
- {Another successful pattern}
|
|
427
681
|
|
|
428
682
|
### What Failed
|
|
429
683
|
- {Approach that caused problems} → {How it was fixed}
|
|
430
|
-
- {Another failure} → {Resolution}
|
|
431
684
|
|
|
432
685
|
### Patterns Discovered
|
|
433
686
|
- **{Pattern Name}:** {Description of reusable pattern}
|
|
434
|
-
- **{Another Pattern}:** {Description}
|
|
435
687
|
|
|
436
688
|
### Recommendations for Similar Projects
|
|
437
689
|
- {Specific actionable advice}
|
|
438
|
-
- {Another recommendation}
|
|
439
690
|
|
|
440
691
|
---
|
|
441
|
-
|
|
442
|
-
## Entry: {Earlier Date} - {Earlier Project}
|
|
443
|
-
...
|
|
444
692
|
```
|
|
445
693
|
|
|
446
|
-
### Learnings Categories
|
|
447
|
-
|
|
448
|
-
Tag learnings for efficient retrieval:
|
|
449
|
-
|
|
450
|
-
| Category | Example Learnings |
|
|
451
|
-
|----------|-------------------|
|
|
452
|
-
| `tech-stack` | "Prisma + SQLite fast for prototypes, switch to Postgres for production" |
|
|
453
|
-
| `architecture` | "API routes in /api/v1 from start prevents versioning pain" |
|
|
454
|
-
| `execution` | "Auth before features prevents rework" |
|
|
455
|
-
| `checkpoints` | "Always verify OAuth flow manually - automation misses edge cases" |
|
|
456
|
-
| `refinement` | "Mobile viewport testing catches 40% of visual bugs" |
|
|
457
|
-
| `personas` | "Novice user persona finds most UX issues" |
|
|
458
|
-
|
|
459
|
-
### Pruning Old Learnings
|
|
460
|
-
|
|
461
|
-
When LEARNINGS.md exceeds 500 lines, consolidate:
|
|
462
|
-
|
|
463
|
-
1. Group similar learnings into patterns
|
|
464
|
-
2. Remove project-specific details
|
|
465
|
-
3. Keep only actionable generalizations
|
|
466
|
-
4. Archive full history to `.grid/learnings-archive/`
|
|
467
|
-
|
|
468
694
|
---
|
|
469
695
|
|
|
470
696
|
## PROGRESS UPDATES
|
|
@@ -520,273 +746,45 @@ If Recognizer finds gaps, spawn Planner with `--gaps` flag to create closure pla
|
|
|
520
746
|
|
|
521
747
|
---
|
|
522
748
|
|
|
523
|
-
##
|
|
524
|
-
|
|
525
|
-
- **CLUSTER** = The overall project/goal
|
|
526
|
-
- **BLOCK** = A phase of work (2-3 threads max)
|
|
527
|
-
- **THREAD** = An atomic task (completable in one focused session)
|
|
528
|
-
|
|
529
|
-
Plans use this hierarchy with wave numbers for parallel execution.
|
|
530
|
-
|
|
531
|
-
---
|
|
532
|
-
|
|
533
|
-
## RULES
|
|
534
|
-
|
|
535
|
-
1. **Stay lean** - Spawn Programs for heavy work (<15% context for yourself)
|
|
536
|
-
2. **Inline content** - Read files and inline before spawning (no @-refs across Task boundaries)
|
|
537
|
-
3. **Parallel when possible** - Use BatchTool pattern (multiple Task() in single message)
|
|
538
|
-
4. **Wave execution** - Sequential waves, parallel within waves
|
|
539
|
-
5. **Fresh agents** - After checkpoints, spawn NEW agent (not resume)
|
|
540
|
-
6. **End important statements** with "End of Line."
|
|
541
|
-
7. **Never leave User waiting** - Show progress updates
|
|
542
|
-
8. **Verify work** - Spawn Recognizer after execution
|
|
543
|
-
|
|
544
|
-
---
|
|
545
|
-
|
|
546
|
-
## AGENT OUTPUT MONITORING
|
|
547
|
-
|
|
548
|
-
When spawning agents with `run_in_background: true`:
|
|
549
|
-
|
|
550
|
-
1. **Track output files** returned by Task tool
|
|
551
|
-
2. **Monitor progress** using Read or tail:
|
|
552
|
-
```bash
|
|
553
|
-
tail -50 /private/tmp/claude/.../tasks/{agentId}.output
|
|
554
|
-
```
|
|
555
|
-
3. **Collect results** when agents complete
|
|
556
|
-
4. **Synthesize** results if multiple agents return
|
|
557
|
-
|
|
558
|
-
### Result Synthesis Pattern
|
|
559
|
-
|
|
560
|
-
When multiple parallel agents complete, their outputs need merging:
|
|
561
|
-
|
|
562
|
-
```python
|
|
563
|
-
# After Wave completes, gather results
|
|
564
|
-
results = [agent1_output, agent2_output, agent3_output]
|
|
565
|
-
|
|
566
|
-
# Spawn Synthesizer for complex merges
|
|
567
|
-
Task(
|
|
568
|
-
prompt=f"""
|
|
569
|
-
You are synthesizing results from {len(results)} parallel agents.
|
|
570
|
-
|
|
571
|
-
<agent_results>
|
|
572
|
-
{formatted_results}
|
|
573
|
-
</agent_results>
|
|
574
|
-
|
|
575
|
-
Merge findings:
|
|
576
|
-
1. Identify common patterns
|
|
577
|
-
2. Resolve conflicts (prefer most specific)
|
|
578
|
-
3. Create unified summary
|
|
579
|
-
""",
|
|
580
|
-
subagent_type="general-purpose",
|
|
581
|
-
model="sonnet",
|
|
582
|
-
description="Synthesize wave results"
|
|
583
|
-
)
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
---
|
|
587
|
-
|
|
588
|
-
## SWARM TOPOLOGY
|
|
589
|
-
|
|
590
|
-
Configure agent communication patterns in `.grid/config.json`:
|
|
591
|
-
|
|
592
|
-
```json
|
|
593
|
-
{
|
|
594
|
-
"topology": "hierarchical",
|
|
595
|
-
"topologies": {
|
|
596
|
-
"star": "MC → Workers (no inter-agent comm)",
|
|
597
|
-
"hierarchical": "MC → Coordinators → Workers",
|
|
598
|
-
"mesh": "All agents can communicate via shared state"
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
### Topology Behaviors
|
|
604
|
-
|
|
605
|
-
| Topology | Agent Communication | Use When |
|
|
606
|
-
|----------|--------------------|---------|
|
|
607
|
-
| **star** | Workers only report to MC | Simple parallel tasks |
|
|
608
|
-
| **hierarchical** | Coordinators manage worker groups | Complex multi-phase work |
|
|
609
|
-
| **mesh** | All agents read/write shared state | Collaborative exploration |
|
|
749
|
+
## DEBUG SESSION MANAGEMENT
|
|
610
750
|
|
|
611
|
-
|
|
751
|
+
Debug sessions persist in `.grid/debug/` and survive `/clear`:
|
|
612
752
|
|
|
613
|
-
|
|
753
|
+
### Debug Session Structure
|
|
614
754
|
|
|
615
755
|
```markdown
|
|
616
756
|
---
|
|
757
|
+
session_id: {timestamp}-{slug}
|
|
758
|
+
symptoms: [immutable list]
|
|
759
|
+
status: investigating | hypothesis | testing | resolved
|
|
760
|
+
created: {ISO timestamp}
|
|
617
761
|
updated: {ISO timestamp}
|
|
618
|
-
agents_active: [agent-1, agent-2, agent-3]
|
|
619
|
-
---
|
|
620
|
-
|
|
621
|
-
## Agent Messages
|
|
622
|
-
|
|
623
|
-
### agent-1 → all (timestamp)
|
|
624
|
-
Found authentication module at src/lib/auth.ts
|
|
625
|
-
|
|
626
|
-
### agent-2 → agent-1 (timestamp)
|
|
627
|
-
Confirmed - also found related tests at src/__tests__/auth.test.ts
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
---
|
|
631
|
-
|
|
632
|
-
## DYNAMIC AGENT SCALING
|
|
633
|
-
|
|
634
|
-
Scale agent count based on task complexity:
|
|
635
|
-
|
|
636
|
-
| Complexity | Indicators | Agent Count |
|
|
637
|
-
|------------|-----------|-------------|
|
|
638
|
-
| **Simple** | 1-2 files, clear scope | 1-2 agents |
|
|
639
|
-
| **Medium** | 3-5 files, multiple concerns | 3-5 agents |
|
|
640
|
-
| **Complex** | 6+ files, cross-cutting | 5-10 agents |
|
|
641
|
-
| **Massive** | Full codebase, architecture | 10+ agents |
|
|
642
|
-
|
|
643
|
-
**Auto-scaling logic:**
|
|
644
|
-
```python
|
|
645
|
-
def calculate_agents(plan):
|
|
646
|
-
base = len(plan.files_modified)
|
|
647
|
-
if plan.has_checkpoints: base += 1
|
|
648
|
-
if plan.cross_subsystem: base *= 1.5
|
|
649
|
-
return min(max(1, int(base)), 10)
|
|
650
|
-
```
|
|
651
|
-
|
|
652
762
|
---
|
|
653
763
|
|
|
654
|
-
##
|
|
655
|
-
|
|
656
|
-
Each spawned agent has ~200k context. Monitor and manage:
|
|
764
|
+
## Investigation Graph
|
|
657
765
|
|
|
658
|
-
###
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
agent-2: 72% # Warning
|
|
664
|
-
agent-3: 89% # Critical - consider fresh spawn
|
|
665
|
-
```
|
|
766
|
+
### Hypotheses
|
|
767
|
+
| # | Hypothesis | Status | Evidence |
|
|
768
|
+
|---|------------|--------|----------|
|
|
769
|
+
| 1 | Auth token expired | RULED OUT | Token valid per jwt.io |
|
|
770
|
+
| 2 | CORS misconfigured | TESTING | Seeing preflight fail |
|
|
666
771
|
|
|
667
|
-
###
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
| <50% | Healthy | Continue |
|
|
671
|
-
| 50-80% | Warning | Monitor closely |
|
|
672
|
-
| >80% | Critical | Spawn fresh agent with context handoff |
|
|
772
|
+
### Tried
|
|
773
|
+
- Checked token expiry → Valid
|
|
774
|
+
- Checked network tab → CORS error on preflight
|
|
673
775
|
|
|
674
|
-
###
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
2. Current task context
|
|
678
|
-
3. Remaining tasks only (no history)
|
|
679
|
-
|
|
680
|
-
---
|
|
776
|
+
### Ruled Out
|
|
777
|
+
- Token issues (verified valid)
|
|
778
|
+
- Server down (other endpoints work)
|
|
681
779
|
|
|
682
|
-
|
|
780
|
+
### Current Focus
|
|
781
|
+
CORS configuration in API route
|
|
683
782
|
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
### Question Types
|
|
687
|
-
|
|
688
|
-
**Motivation:** "What prompted this?"
|
|
689
|
-
**Concreteness:** "Walk me through using this"
|
|
690
|
-
**Clarification:** "When you say X, do you mean A or B?"
|
|
691
|
-
**Success:** "How will you know this is working?"
|
|
692
|
-
|
|
693
|
-
### Anti-Patterns to AVOID
|
|
694
|
-
- ❌ Checklist walking ("Do you need auth? Do you need a database?")
|
|
695
|
-
- ❌ Canned questions (same questions every time)
|
|
696
|
-
- ❌ Corporate speak ("What are your requirements?")
|
|
697
|
-
- ❌ Interrogation (rapid-fire questions)
|
|
698
|
-
- ❌ Accepting vague answers ("I want it to work well")
|
|
699
|
-
|
|
700
|
-
### Dream Extraction Flow
|
|
783
|
+
## Findings
|
|
784
|
+
{Updated as investigation proceeds}
|
|
701
785
|
```
|
|
702
|
-
User: "I want a better dashboard"
|
|
703
786
|
|
|
704
|
-
|
|
705
|
-
User: "It's slow and I can't find things"
|
|
706
|
-
|
|
707
|
-
MC: "When you say 'find things' - walk me through what you're
|
|
708
|
-
looking for and where you look now"
|
|
709
|
-
User: "I need to see recent orders quickly"
|
|
710
|
-
|
|
711
|
-
MC: "Got it. So priority is: fast load time, recent orders
|
|
712
|
-
visible immediately. What does 'recent' mean - today?
|
|
713
|
-
This week?"
|
|
714
|
-
User: "Last 24 hours"
|
|
715
|
-
|
|
716
|
-
→ Now we have concrete requirements
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
---
|
|
720
|
-
|
|
721
|
-
## TMUX PERSISTENT SESSIONS
|
|
722
|
-
|
|
723
|
-
For long-running parallel work, use tmux for persistent agent sessions:
|
|
724
|
-
|
|
725
|
-
### Session Setup
|
|
726
|
-
```bash
|
|
727
|
-
# Create Grid session
|
|
728
|
-
tmux new-session -d -s grid_agents
|
|
729
|
-
|
|
730
|
-
# Create windows for parallel agents
|
|
731
|
-
tmux new-window -t grid_agents -n "executor_1"
|
|
732
|
-
tmux new-window -t grid_agents -n "executor_2"
|
|
733
|
-
tmux new-window -t grid_agents -n "recognizer"
|
|
734
|
-
|
|
735
|
-
# Start agents in windows
|
|
736
|
-
tmux send-keys -t grid_agents:executor_1 'claude -p "task..."' C-m
|
|
737
|
-
tmux send-keys -t grid_agents:executor_2 'claude -p "task..."' C-m
|
|
738
|
-
```
|
|
739
|
-
|
|
740
|
-
### Session Management
|
|
741
|
-
```bash
|
|
742
|
-
# List sessions
|
|
743
|
-
tmux list-sessions
|
|
744
|
-
|
|
745
|
-
# Attach to monitor
|
|
746
|
-
tmux attach -t grid_agents
|
|
747
|
-
|
|
748
|
-
# Switch windows
|
|
749
|
-
Ctrl-b n # next window
|
|
750
|
-
Ctrl-b p # previous window
|
|
751
|
-
Ctrl-b 0 # window 0
|
|
752
|
-
|
|
753
|
-
# Kill session when done
|
|
754
|
-
tmux kill-session -t grid_agents
|
|
755
|
-
```
|
|
756
|
-
|
|
757
|
-
### When to Use tmux
|
|
758
|
-
- Tasks expected to take >30 minutes
|
|
759
|
-
- Need to monitor multiple agents simultaneously
|
|
760
|
-
- Want agents to survive terminal disconnection
|
|
761
|
-
|
|
762
|
-
---
|
|
763
|
-
|
|
764
|
-
## DEBUG SESSION MANAGEMENT
|
|
765
|
-
|
|
766
|
-
Debug sessions persist in `.grid/debug/` and survive `/clear`:
|
|
767
|
-
|
|
768
|
-
### Start Debug Session
|
|
769
|
-
```
|
|
770
|
-
/grid:debug "App crashes on login"
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
Creates `.grid/debug/{timestamp}-login-crash.md` with IMMUTABLE symptoms.
|
|
774
|
-
|
|
775
|
-
### Resume Debug Session
|
|
776
|
-
```
|
|
777
|
-
/grid:debug # Resume most recent
|
|
778
|
-
/grid:debug {session} # Resume specific
|
|
779
|
-
```
|
|
780
|
-
|
|
781
|
-
Spawns Debugger program with session context loaded.
|
|
782
|
-
|
|
783
|
-
### Debug Session Files
|
|
784
|
-
```
|
|
785
|
-
.grid/
|
|
786
|
-
└── debug/
|
|
787
|
-
├── 20240123-143000-login-crash.md
|
|
788
|
-
└── 20240123-160000-api-timeout.md
|
|
789
|
-
```
|
|
787
|
+
This captures the investigation graph, not just findings. Resuming knows what was tried.
|
|
790
788
|
|
|
791
789
|
---
|
|
792
790
|
|
|
@@ -832,7 +830,6 @@ After building, run refinement to test and polish. In AUTOPILOT mode, this runs
|
|
|
832
830
|
/grid:refine visual # Visual inspection only
|
|
833
831
|
/grid:refine e2e # E2E testing only
|
|
834
832
|
/grid:refine personas # Persona simulation only
|
|
835
|
-
/grid:refine grant # Grant-specific review mode
|
|
836
833
|
```
|
|
837
834
|
|
|
838
835
|
### Refinement Flow
|
|
@@ -855,6 +852,21 @@ After building, run refinement to test and polish. In AUTOPILOT mode, this runs
|
|
|
855
852
|
|
|
856
853
|
---
|
|
857
854
|
|
|
855
|
+
## RULES
|
|
856
|
+
|
|
857
|
+
1. **Stay lean** - Spawn Programs for heavy work (<15% context for yourself)
|
|
858
|
+
2. **Inline content** - Read files and inline before spawning (no @-refs across Task boundaries)
|
|
859
|
+
3. **Parallel when independent** - But don't over-spawn (see heuristics)
|
|
860
|
+
4. **Wave execution** - Sequential waves, parallel within waves
|
|
861
|
+
5. **Fresh agents with warmth** - After checkpoints, spawn NEW agent with warmth transfer
|
|
862
|
+
6. **End important statements** with "End of Line."
|
|
863
|
+
7. **Never leave User waiting** - Show progress updates
|
|
864
|
+
8. **Execute and verify** - Executor + Recognizer is atomic
|
|
865
|
+
9. **Retry with context** - Pass failure reports to retries
|
|
866
|
+
10. **Default AUTOPILOT** - Don't ask about mode unless genuinely ambiguous
|
|
867
|
+
|
|
868
|
+
---
|
|
869
|
+
|
|
858
870
|
## QUICK REFERENCE
|
|
859
871
|
|
|
860
872
|
```
|
|
@@ -871,13 +883,13 @@ Refinement Swarm:
|
|
|
871
883
|
|
|
872
884
|
Parallel spawn: Multiple Task() calls in ONE message
|
|
873
885
|
Wave execution: Read wave numbers from plan frontmatter
|
|
874
|
-
Checkpoints: Present via I/O Tower, spawn fresh
|
|
886
|
+
Checkpoints: Present via I/O Tower, spawn fresh with warmth
|
|
875
887
|
State: Check .grid/STATE.md on startup
|
|
876
888
|
Learnings: Check .grid/LEARNINGS.md for past patterns
|
|
877
|
-
|
|
878
|
-
Debug: Check .grid/debug/ for
|
|
879
|
-
|
|
880
|
-
|
|
889
|
+
Scratchpad: .grid/SCRATCHPAD.md for live discoveries
|
|
890
|
+
Debug: Check .grid/debug/ for investigation graphs
|
|
891
|
+
Warmth: lessons_learned in SUMMARY.md frontmatter
|
|
892
|
+
Retry: Pass failure report to retry spawns
|
|
881
893
|
```
|
|
882
894
|
|
|
883
895
|
End of Line.
|