the-grid-cc 1.7.13 → 1.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/02-SUMMARY.md +156 -0
  2. package/DAEMON_VALIDATION.md +354 -0
  3. package/README.md +6 -6
  4. package/agents/grid-accountant.md +519 -0
  5. package/agents/grid-git-operator.md +661 -0
  6. package/agents/grid-researcher.md +421 -0
  7. package/agents/grid-scout.md +376 -0
  8. package/commands/grid/VERSION +1 -1
  9. package/commands/grid/branch.md +567 -0
  10. package/commands/grid/budget.md +438 -0
  11. package/commands/grid/daemon.md +637 -0
  12. package/commands/grid/help.md +29 -0
  13. package/commands/grid/init.md +409 -18
  14. package/commands/grid/mc.md +163 -1111
  15. package/commands/grid/resume.md +656 -0
  16. package/docs/BUDGET_SYSTEM.md +745 -0
  17. package/docs/CONFIG_SCHEMA.md +479 -0
  18. package/docs/DAEMON_ARCHITECTURE.md +780 -0
  19. package/docs/GIT_AUTONOMY.md +981 -0
  20. package/docs/GIT_AUTONOMY_INTEGRATION.md +343 -0
  21. package/docs/MC_OPTIMIZATION.md +181 -0
  22. package/docs/MC_PROTOCOLS.md +950 -0
  23. package/docs/PERSISTENCE.md +962 -0
  24. package/docs/PERSISTENCE_IMPLEMENTATION.md +361 -0
  25. package/docs/PERSISTENCE_QUICKSTART.md +283 -0
  26. package/docs/RESEARCH_CONFIG.md +511 -0
  27. package/docs/RESEARCH_FIRST.md +591 -0
  28. package/docs/WIRING_VERIFICATION.md +389 -0
  29. package/package.json +1 -1
  30. package/templates/daemon-checkpoint.json +51 -0
  31. package/templates/daemon-config.json +28 -0
  32. package/templates/git-config.json +65 -0
  33. package/templates/grid-state/.gitignore-entry +3 -0
  34. package/templates/grid-state/BLOCK-SUMMARY.md +66 -0
  35. package/templates/grid-state/BLOCKERS.md +31 -0
  36. package/templates/grid-state/CHECKPOINT.md +59 -0
  37. package/templates/grid-state/DECISIONS.md +30 -0
  38. package/templates/grid-state/README.md +138 -0
  39. package/templates/grid-state/SCRATCHPAD.md +29 -0
  40. package/templates/grid-state/STATE.md +47 -0
  41. package/templates/grid-state/WARMTH.md +48 -0
  42. package/templates/grid-state/config.json +24 -0
@@ -2,50 +2,441 @@
2
2
 
3
3
  ---
4
4
  name: grid:init
5
- description: Initialize .grid directory for current project
5
+ description: Initialize .grid directory for current project with full persistence support
6
6
  allowed-tools:
7
7
  - Bash
8
8
  - Write
9
9
  ---
10
10
 
11
- Create the `.grid/` directory structure for the current project:
11
+ Initialize the `.grid/` directory structure for the current project. This creates all directories and files needed for state persistence, enabling mission recovery via `/grid:resume`.
12
+
13
+ ## USAGE
14
+
15
+ ```
16
+ /grid:init # Initialize in current directory
17
+ /grid:init --force # Reinitialize (preserves existing state)
18
+ ```
19
+
20
+ ## DIRECTORY STRUCTURE
21
+
22
+ Create the complete `.grid/` directory structure:
12
23
 
13
24
  ```bash
14
- mkdir -p .grid/clusters .grid/discs
25
+ mkdir -p .grid/plans .grid/phases .grid/discs .grid/debug .grid/daemon .grid/refinement/screenshots .grid/refinement/e2e .grid/refinement/personas
15
26
  ```
16
27
 
17
- Then create `.grid/STATE.md`:
28
+ ### Directory Purposes
29
+
30
+ | Directory | Purpose | Persistence |
31
+ |-----------|---------|-------------|
32
+ | `.grid/` | Root state directory | Session-scoped |
33
+ | `.grid/plans/` | Execution plans (PLAN.md files) | Mission-scoped |
34
+ | `.grid/phases/` | Execution artifacts (SUMMARY.md files) | Mission-scoped |
35
+ | `.grid/discs/` | Identity Discs for Programs | Session-scoped |
36
+ | `.grid/debug/` | Debug session state | Survives /clear |
37
+ | `.grid/daemon/` | Daemon execution state | Mission-scoped |
38
+ | `.grid/refinement/` | Refinement swarm outputs | Mission-scoped |
39
+
40
+ ## CORE STATE FILES
41
+
42
+ ### STATE.md (Central State)
43
+
44
+ The primary state file - always read first on resume:
18
45
 
19
46
  ```markdown
47
+ ---
48
+ # Identity
49
+ cluster: null
50
+ session_id: "{timestamp}-init"
51
+ status: initialized # initialized | active | checkpoint | interrupted | completed | failed
52
+
53
+ # Position tracking
54
+ position:
55
+ phase: 0
56
+ phase_total: 0
57
+ phase_name: null
58
+ block: 0
59
+ block_total: 0
60
+ wave: 0
61
+ wave_total: 0
62
+
63
+ # Progress
64
+ progress_percent: 0
65
+ energy_remaining: 10000
66
+
67
+ # Execution mode
68
+ mode: autopilot # autopilot | guided | hands_on
69
+
70
+ # Timestamps
71
+ created_at: "{ISO timestamp}"
72
+ updated_at: "{ISO timestamp}"
73
+ ---
74
+
20
75
  # Grid State
21
76
 
22
77
  ## Current Position
23
78
  - Active Cluster: none
24
79
  - Active Block: none
25
- - Energy Remaining: 10000
80
+ - Status: Initialized
81
+
82
+ Progress: [----------] 0%
83
+
84
+ ## Session Info
85
+ - Initialized: {current date}
86
+ - Session ID: {session_id}
87
+ - Mode: AUTOPILOT
88
+
89
+ ## Last Activity
90
+ Initialized Grid state directory.
91
+
92
+ ## Notes
93
+ Ready for /grid to begin a mission.
94
+ ```
95
+
96
+ ### WARMTH.md (Institutional Knowledge)
97
+
98
+ Template for accumulated knowledge:
99
+
100
+ ```markdown
101
+ ---
102
+ cluster: null
103
+ accumulated_from: []
104
+ last_updated: "{ISO timestamp}"
105
+ ---
106
+
107
+ # Grid Warmth
108
+
109
+ Accumulated knowledge from Programs. Survives session death.
110
+
111
+ ## Codebase Patterns
112
+ (Patterns discovered about the codebase)
113
+
114
+ ## Gotchas
115
+ (Traps and pitfalls to avoid)
116
+
117
+ ## User Preferences
118
+ (Inferred user preferences)
26
119
 
27
120
  ## Decisions Made
28
- (none yet)
121
+ (Key decisions and their rationale)
29
122
 
30
- ## Programs Spawned This Session
31
- (none yet)
123
+ ## Almost Did
124
+ (Approaches considered but rejected)
32
125
 
33
- ## History
34
- - Initialized: {current date}
126
+ ## Fragile Areas
127
+ (Code that breaks easily)
128
+ ```
129
+
130
+ ### SCRATCHPAD.md (Live Discoveries)
131
+
132
+ Template for real-time discoveries during execution:
133
+
134
+ ```markdown
135
+ ---
136
+ updated: "{ISO timestamp}"
137
+ active_programs: []
138
+ ---
139
+
140
+ # Grid Scratchpad
141
+
142
+ Live discoveries during execution. Programs write here when they learn something others need to know.
143
+
144
+ ## Format
145
+
146
+ Each entry must follow:
147
+ ```
148
+ ### {program-id} | {ISO-timestamp} | {category}
149
+
150
+ **Finding:** {one clear sentence}
151
+ **Impact:** {who needs to know}
152
+ **Action:** [INFORM_ONLY | REQUIRES_CHANGE | BLOCKER]
153
+ **Details:** {additional context}
154
+ ```
155
+
156
+ Categories: PATTERN | DECISION | BLOCKER | PROGRESS | CORRECTION
157
+
158
+ ---
159
+
160
+ (Entries will appear below)
161
+ ```
162
+
163
+ ### DECISIONS.md (User Decisions Log)
164
+
165
+ Template for tracking user decisions:
166
+
167
+ ```markdown
168
+ ---
169
+ cluster: null
170
+ decision_count: 0
171
+ last_updated: "{ISO timestamp}"
172
+ ---
173
+
174
+ # Grid Decisions Log
175
+
176
+ User decisions made via I/O Tower. Referenced during resume to maintain consistency.
177
+
178
+ ---
179
+
180
+ (Decisions will appear below in format:)
181
+
182
+ ## Decision {N}: {ISO timestamp}
183
+ **Question:** {what was asked}
184
+ **Options Presented:**
185
+ - {option_a}: "{description}"
186
+ - {option_b}: "{description}"
187
+ **User Choice:** {choice}
188
+ **Rationale:** "{user's reason if given}"
189
+ **Affects:** {blocks/features affected}
35
190
  ```
36
191
 
37
- After creating, display:
192
+ ### BLOCKERS.md (Blocker Tracking)
193
+
194
+ Template for tracking blockers:
195
+
196
+ ```markdown
197
+ ---
198
+ cluster: null
199
+ active_blockers: 0
200
+ resolved_blockers: 0
201
+ last_updated: "{ISO timestamp}"
202
+ ---
203
+
204
+ # Grid Blockers
205
+
206
+ Issues that blocked progress. Used for resume and reporting.
207
+
208
+ ---
209
+
210
+ (Blockers will appear below in format:)
211
+
212
+ ## Blocker {N}: {ACTIVE | RESOLVED}
213
+ **Block:** {block_id}
214
+ **Thread:** {thread_id}
215
+ **Type:** {dependency_missing | human_action_required | external_service | bug}
216
+ **Description:** {what's blocking}
217
+ **Resolution:** {how it was resolved, if resolved}
218
+ **Created At:** {timestamp}
219
+ **Resolved At:** {timestamp, if resolved}
220
+ ```
221
+
222
+ ### config.json (Grid Configuration)
223
+
224
+ Configuration for Grid behavior:
225
+
226
+ ```json
227
+ {
228
+ "model_tier": "quality",
229
+ "model_tier_options": ["quality", "balanced", "budget"],
230
+ "auto_verify": true,
231
+ "scratchpad_heartbeat_minutes": 5,
232
+ "stale_threshold_minutes": 10,
233
+ "max_retry_attempts": 3,
234
+ "created_at": "{ISO timestamp}"
235
+ }
236
+ ```
237
+
238
+ ### budget.json (Budget Tracking)
239
+
240
+ Initialize from template if not exists:
241
+
242
+ ```bash
243
+ if [ ! -f .grid/budget.json ]; then
244
+ cp .grid/budget.template.json .grid/budget.json
245
+ fi
246
+ ```
247
+
248
+ Budget configuration for cost tracking (see `/grid:budget` for details):
249
+
250
+ ```json
251
+ {
252
+ "budget_limit": null,
253
+ "currency": "USD",
254
+ "enforcement": "hard",
255
+ "warning_threshold": 0.75,
256
+ "confirmation_threshold": 0.90,
257
+ "current_session": {
258
+ "estimated_cost": 0,
259
+ "spawns": []
260
+ },
261
+ "history": {
262
+ "total_cost": 0,
263
+ "total_spawns": 0
264
+ }
265
+ }
266
+ ```
267
+
268
+ ## INITIALIZATION BEHAVIOR
269
+
270
+ ### Step 1: Check Existing State
271
+
272
+ ```python
273
+ if file_exists(".grid/STATE.md"):
274
+ state = parse_yaml(read(".grid/STATE.md"))
275
+ if state.get("status") not in ["completed", "failed", "initialized"]:
276
+ # Active mission exists
277
+ display("""
278
+ WARNING: Active Grid mission detected.
279
+
280
+ Cluster: {state['cluster']}
281
+ Status: {state['status']}
282
+ Progress: {state['progress_percent']}%
283
+
284
+ Use /grid:resume to continue, or /grid:init --force to reinitialize.
285
+ """)
286
+ return
287
+ ```
288
+
289
+ ### Step 2: Create Directories
290
+
291
+ ```bash
292
+ mkdir -p .grid/plans
293
+ mkdir -p .grid/phases
294
+ mkdir -p .grid/discs
295
+ mkdir -p .grid/debug
296
+ mkdir -p .grid/daemon
297
+ mkdir -p .grid/refinement/screenshots
298
+ mkdir -p .grid/refinement/e2e
299
+ mkdir -p .grid/refinement/personas
300
+ ```
301
+
302
+ ### Step 3: Create State Files
303
+
304
+ Create each core state file with its template.
305
+
306
+ ### Step 4: Create .gitignore Entry
307
+
308
+ If `.gitignore` exists, suggest adding `.grid/`:
309
+
310
+ ```python
311
+ if file_exists(".gitignore"):
312
+ gitignore = read(".gitignore")
313
+ if ".grid/" not in gitignore:
314
+ suggest("""
315
+ Consider adding to .gitignore:
316
+
317
+ # Grid state (local only)
318
+ .grid/
319
+ """)
320
+ ```
321
+
322
+ ### Step 5: Display Confirmation
38
323
 
39
324
  ```
40
- MCP > Grid state initialized.
325
+ GRID INITIALIZED
326
+ ================
41
327
 
42
- Directory structure:
43
- .grid/
44
- ├── STATE.md (Grid memory)
45
- ├── clusters/ (Cluster plans and summaries)
46
- └── discs/ (Identity Discs for Programs)
328
+ Directory structure created:
47
329
 
48
- Ready to build.
330
+ .grid/
331
+ ├── STATE.md Central state file (read first on resume)
332
+ ├── WARMTH.md Institutional knowledge
333
+ ├── SCRATCHPAD.md Live discoveries during execution
334
+ ├── DECISIONS.md User decisions log
335
+ ├── BLOCKERS.md Blocker tracking
336
+ ├── config.json Grid configuration
337
+ ├── budget.json Budget tracking (cost management)
338
+
339
+ ├── plans/ Execution plans
340
+ ├── phases/ Execution artifacts (SUMMARY.md files)
341
+ ├── discs/ Identity Discs for Programs
342
+ ├── debug/ Debug session state
343
+ ├── daemon/ Daemon execution state (long-running tasks)
344
+ └── refinement/ Refinement swarm outputs
345
+ ├── screenshots/
346
+ ├── e2e/
347
+ └── personas/
348
+
349
+ PERSISTENCE ENABLED
350
+ -------------------
351
+ Your mission state will survive session death.
352
+ Use /grid:resume to continue an interrupted mission.
353
+
354
+ Ready to build. Run /grid to begin.
49
355
 
50
356
  End of Line.
51
357
  ```
358
+
359
+ ## FORCE REINITIALIZATION
360
+
361
+ With `--force` flag:
362
+
363
+ 1. Archive existing state (if active):
364
+ ```bash
365
+ mv .grid/STATE.md .grid/STATE.md.{timestamp}.bak
366
+ mv .grid/WARMTH.md .grid/WARMTH.md.{timestamp}.bak
367
+ ```
368
+
369
+ 2. Preserve completed work:
370
+ - Keep `.grid/phases/` (SUMMARY.md files)
371
+ - Keep `.grid/plans/` (for reference)
372
+
373
+ 3. Create fresh state files
374
+
375
+ 4. Display:
376
+ ```
377
+ GRID REINITIALIZED
378
+ ==================
379
+
380
+ Archived:
381
+ - STATE.md -> STATE.md.{timestamp}.bak
382
+ - WARMTH.md -> WARMTH.md.{timestamp}.bak
383
+
384
+ Preserved:
385
+ - phases/ (completed work)
386
+ - plans/ (execution plans)
387
+
388
+ Fresh state created. Ready to build.
389
+
390
+ End of Line.
391
+ ```
392
+
393
+ ## STATE FILE SCHEMAS
394
+
395
+ ### STATE.md YAML Frontmatter Schema
396
+
397
+ | Field | Type | Required | Description |
398
+ |-------|------|----------|-------------|
399
+ | `cluster` | string | Yes | Cluster name |
400
+ | `session_id` | string | Yes | Unique session identifier |
401
+ | `status` | enum | Yes | initialized/active/checkpoint/interrupted/completed/failed |
402
+ | `position.phase` | integer | Yes | Current phase number |
403
+ | `position.phase_total` | integer | Yes | Total phases |
404
+ | `position.phase_name` | string | No | Phase name |
405
+ | `position.block` | integer | Yes | Current block number |
406
+ | `position.block_total` | integer | Yes | Total blocks |
407
+ | `position.wave` | integer | Yes | Current wave number |
408
+ | `position.wave_total` | integer | Yes | Total waves |
409
+ | `progress_percent` | integer | Yes | 0-100 |
410
+ | `energy_remaining` | integer | Yes | Energy budget |
411
+ | `mode` | enum | Yes | autopilot/guided/hands_on |
412
+ | `created_at` | ISO8601 | Yes | Creation timestamp |
413
+ | `updated_at` | ISO8601 | Yes | Last update timestamp |
414
+
415
+ ### config.json Schema
416
+
417
+ | Field | Type | Default | Description |
418
+ |-------|------|---------|-------------|
419
+ | `model_tier` | enum | "quality" | quality/balanced/budget |
420
+ | `auto_verify` | boolean | true | Auto-spawn Recognizer |
421
+ | `scratchpad_heartbeat_minutes` | integer | 5 | Expected write frequency |
422
+ | `stale_threshold_minutes` | integer | 10 | When to consider session dead |
423
+ | `max_retry_attempts` | integer | 3 | Max retries on failure |
424
+
425
+ ## PERSISTENCE GUARANTEES
426
+
427
+ After initialization, the Grid guarantees:
428
+
429
+ 1. **State survives session death** - All progress recorded in files
430
+ 2. **Warmth accumulates** - Knowledge transfers across Programs
431
+ 3. **Decisions persist** - User choices never need repeating
432
+ 4. **Commits are verified** - Git hashes enable state validation
433
+ 5. **Plans are preserved** - Full execution plans available for resume
434
+
435
+ ## RELATED COMMANDS
436
+
437
+ - `/grid` - Begin a mission (auto-initializes if needed)
438
+ - `/grid:resume` - Resume an interrupted mission
439
+ - `/grid:status` - Display current Grid state
440
+ - `/grid:model` - Configure model tier
441
+
442
+ End of Line.