the-grid-cc 1.7.14 → 1.7.16
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/DAEMON_VALIDATION.md +354 -0
- package/DAEMON_WIRING_COMPLETE.md +176 -0
- package/PERSISTENCE_COMPLETE.md +309 -0
- package/README.md +36 -6
- package/RESEARCH_FIRST_DELIVERABLES.md +604 -0
- package/commands/grid/VERSION +1 -1
- package/commands/grid/help.md +29 -0
- package/commands/grid/init.md +35 -1
- package/commands/grid/mc.md +61 -14
- package/docs/CONFIG_SCHEMA.md +479 -0
- package/docs/GIT_AUTONOMY_INTEGRATION.md +343 -0
- package/docs/INTEGRATION_SUMMARY.md +316 -0
- package/docs/MC_RESEARCH_INTEGRATION.md +716 -0
- package/docs/PERSISTENCE_FLOW.md +483 -0
- package/docs/PERSISTENCE_IMPLEMENTATION.md +361 -0
- package/docs/PERSISTENCE_QUICKSTART.md +283 -0
- package/docs/RESEARCH_CONFIG.md +511 -0
- package/docs/RESEARCH_INFRASTRUCTURE.md +429 -0
- package/docs/WIRING_VERIFICATION.md +389 -0
- package/package.json +1 -1
- package/templates/daemon-checkpoint.json +51 -0
- package/templates/daemon-config.json +28 -0
- package/templates/git-config.json +65 -0
- package/templates/grid-state/.gitignore-entry +3 -0
- package/templates/grid-state/BLOCK-SUMMARY.md +66 -0
- package/templates/grid-state/BLOCKERS.md +31 -0
- package/templates/grid-state/CHECKPOINT.md +59 -0
- package/templates/grid-state/DECISIONS.md +30 -0
- package/templates/grid-state/README.md +138 -0
- package/templates/grid-state/SCRATCHPAD.md +29 -0
- package/templates/grid-state/STATE.md +47 -0
- package/templates/grid-state/WARMTH.md +48 -0
- package/templates/grid-state/config.json +24 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
# Research Infrastructure Setup
|
|
2
|
+
|
|
3
|
+
**Implementation Complete**
|
|
4
|
+
**Version:** 1.0
|
|
5
|
+
**Date:** 2026-01-23
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The research-first infrastructure is now functional and ready for MC integration. This document describes what was created and how to use it.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Directory Structure Created
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
.grid/ # Local state (gitignored)
|
|
19
|
+
├── research/ # Fresh research outputs
|
|
20
|
+
│ ├── README.md # Documentation
|
|
21
|
+
│ ├── .gitignore # Ignore *.md except README
|
|
22
|
+
│ └── {topic}-{timestamp}.md # Research outputs (created by Researchers)
|
|
23
|
+
│
|
|
24
|
+
├── research_cache/ # Cached research (24h TTL)
|
|
25
|
+
│ ├── README.md # Documentation
|
|
26
|
+
│ ├── .gitignore # Ignore *.md except README/index
|
|
27
|
+
│ ├── index.json # Cache index with metadata
|
|
28
|
+
│ └── {topic-slug}.md # Cached research (reusable)
|
|
29
|
+
│
|
|
30
|
+
└── scout/ # Codebase reconnaissance
|
|
31
|
+
├── README.md # Documentation
|
|
32
|
+
├── .gitignore # Ignore RECON_*.md except README
|
|
33
|
+
└── RECON_{timestamp}.md # Scout reports (created by Scouts)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
All directories are in `.grid/` which is gitignored for local state isolation.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Files Created
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
|
|
44
|
+
| File | Purpose |
|
|
45
|
+
|------|---------|
|
|
46
|
+
| `.grid/research/README.md` | Documents research output directory |
|
|
47
|
+
| `.grid/research_cache/README.md` | Documents cache structure and policies |
|
|
48
|
+
| `.grid/scout/README.md` | Documents scout report directory |
|
|
49
|
+
| `docs/RESEARCH_CONFIG.md` | Configuration schema reference |
|
|
50
|
+
| `docs/MC_RESEARCH_INTEGRATION.md` | MC integration implementation guide |
|
|
51
|
+
| `docs/RESEARCH_INFRASTRUCTURE.md` | This file - setup summary |
|
|
52
|
+
|
|
53
|
+
### Gitignores
|
|
54
|
+
|
|
55
|
+
| File | Purpose |
|
|
56
|
+
|------|---------|
|
|
57
|
+
| `.grid/research/.gitignore` | Ignore research outputs, keep README |
|
|
58
|
+
| `.grid/research_cache/.gitignore` | Ignore cached files, keep README + index |
|
|
59
|
+
| `.grid/scout/.gitignore` | Ignore scout reports, keep README |
|
|
60
|
+
|
|
61
|
+
### State Files
|
|
62
|
+
|
|
63
|
+
| File | Purpose |
|
|
64
|
+
|------|---------|
|
|
65
|
+
| `.grid/research_cache/index.json` | Empty cache index (ready for entries) |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Agent Files Verified
|
|
70
|
+
|
|
71
|
+
Both agent files are properly formatted for spawning:
|
|
72
|
+
|
|
73
|
+
### `/Users/jacweath/grid/agents/grid-researcher.md`
|
|
74
|
+
|
|
75
|
+
**Status:** ✅ Functional
|
|
76
|
+
|
|
77
|
+
**Contents:**
|
|
78
|
+
- Role definition
|
|
79
|
+
- Mission types (technology, patterns, similar projects, API docs)
|
|
80
|
+
- Research protocol (query generation, parallel search, context assembly)
|
|
81
|
+
- Caching protocol (cache structure, hit logic, invalidation)
|
|
82
|
+
- Search tool selection
|
|
83
|
+
- Output format
|
|
84
|
+
- Quality rules
|
|
85
|
+
- Integration with planning
|
|
86
|
+
|
|
87
|
+
**Ready to spawn:** Yes - MC can spawn with Task tool
|
|
88
|
+
|
|
89
|
+
### `/Users/jacweath/grid/agents/grid-scout.md`
|
|
90
|
+
|
|
91
|
+
**Status:** ✅ Functional
|
|
92
|
+
|
|
93
|
+
**Contents:**
|
|
94
|
+
- Role definition
|
|
95
|
+
- Reconnaissance protocol (4 phases in 2 minutes)
|
|
96
|
+
- Technology detection
|
|
97
|
+
- Pattern detection
|
|
98
|
+
- Constraint discovery
|
|
99
|
+
- Output format (scout report)
|
|
100
|
+
- Speed optimization
|
|
101
|
+
- Special modes (greenfield, monorepo)
|
|
102
|
+
- Integration with research
|
|
103
|
+
|
|
104
|
+
**Ready to spawn:** Yes - MC can spawn with Task tool
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Cache Index Schema
|
|
109
|
+
|
|
110
|
+
The cache index is initialized and ready:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"version": "1.0",
|
|
115
|
+
"created": "2026-01-23T20:00:00Z",
|
|
116
|
+
"updated": "2026-01-23T20:00:00Z",
|
|
117
|
+
"entries": []
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
As Researchers cache results, entries will be added:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"entries": [
|
|
126
|
+
{
|
|
127
|
+
"key": "nextjs-14-app-router",
|
|
128
|
+
"queries": ["Next.js 14 best practices 2024 2025", ...],
|
|
129
|
+
"created": "2026-01-23T14:00:00Z",
|
|
130
|
+
"expires": "2026-01-24T14:00:00Z",
|
|
131
|
+
"file": "nextjs-14-app-router.md",
|
|
132
|
+
"hit_count": 0,
|
|
133
|
+
"size_kb": 15
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## How MC Spawns Researchers
|
|
142
|
+
|
|
143
|
+
### 1. Research Decision
|
|
144
|
+
|
|
145
|
+
MC checks if research should run:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
decision = should_run_research(user_request, config)
|
|
149
|
+
if not decision['run']:
|
|
150
|
+
# Skip research, go direct to Planner
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 2. Scout Spawn (if existing codebase)
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
scout_prompt = """
|
|
157
|
+
First, read ~/.claude/agents/grid-scout.md for your role.
|
|
158
|
+
|
|
159
|
+
<config>
|
|
160
|
+
project_root: /path/to/project
|
|
161
|
+
timeout_seconds: 120
|
|
162
|
+
max_files_analyzed: 1000
|
|
163
|
+
</config>
|
|
164
|
+
|
|
165
|
+
Scan the codebase. Output to .grid/scout/RECON_{timestamp}.md
|
|
166
|
+
"""
|
|
167
|
+
|
|
168
|
+
scout_result = Task(
|
|
169
|
+
prompt=scout_prompt,
|
|
170
|
+
subagent_type="general-purpose",
|
|
171
|
+
description="Scout: Codebase reconnaissance"
|
|
172
|
+
)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. Research Needs Extraction
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
needs = extract_research_needs(user_request, scout_result)
|
|
179
|
+
# Returns: [
|
|
180
|
+
# {'type': 'technology', 'topic': 'Next.js 14', 'queries': [...]},
|
|
181
|
+
# {'type': 'pattern', 'topic': 'Server Components', 'queries': [...]},
|
|
182
|
+
# ]
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 4. Cache Check
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
cached, needed = check_research_cache(needs, config)
|
|
189
|
+
# Returns:
|
|
190
|
+
# - cached: Research already in .grid/research_cache/
|
|
191
|
+
# - needed: Topics not cached or expired
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 5. Researcher Spawn (parallel)
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
for need in needed:
|
|
198
|
+
researcher_prompt = f"""
|
|
199
|
+
First, read ~/.claude/agents/grid-researcher.md for your role.
|
|
200
|
+
|
|
201
|
+
<research_request>
|
|
202
|
+
mission: {need['type']}
|
|
203
|
+
topic: {need['topic']}
|
|
204
|
+
queries: {need['queries']}
|
|
205
|
+
</research_request>
|
|
206
|
+
|
|
207
|
+
Research and output to .grid/research_cache/{topic}.md
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
Task(
|
|
211
|
+
prompt=researcher_prompt,
|
|
212
|
+
subagent_type="general-purpose",
|
|
213
|
+
description=f"Research: {need['topic']}"
|
|
214
|
+
)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
All Researchers spawn in parallel (single MC message, multiple Task calls).
|
|
218
|
+
|
|
219
|
+
### 6. Context Assembly
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
context = {
|
|
223
|
+
'scout': scout_result,
|
|
224
|
+
'cached_research': cached,
|
|
225
|
+
'fresh_research': fresh_results
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 7. Planner Spawn
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
planner_prompt = f"""
|
|
233
|
+
First, read ~/.claude/agents/grid-planner.md for your role.
|
|
234
|
+
|
|
235
|
+
<codebase_context>
|
|
236
|
+
{context['scout']}
|
|
237
|
+
</codebase_context>
|
|
238
|
+
|
|
239
|
+
<research_context>
|
|
240
|
+
{format_research(context['cached_research'])}
|
|
241
|
+
{format_research(context['fresh_research'])}
|
|
242
|
+
</research_context>
|
|
243
|
+
|
|
244
|
+
<user_request>
|
|
245
|
+
{user_request}
|
|
246
|
+
</user_request>
|
|
247
|
+
|
|
248
|
+
Create plan that respects codebase constraints and uses best practices.
|
|
249
|
+
"""
|
|
250
|
+
|
|
251
|
+
Task(
|
|
252
|
+
prompt=planner_prompt,
|
|
253
|
+
subagent_type="general-purpose",
|
|
254
|
+
description="Planner: Research-informed plan"
|
|
255
|
+
)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Configuration Schema Added
|
|
261
|
+
|
|
262
|
+
### Proposed `.grid/config.json`
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"version": "1.0",
|
|
267
|
+
"research": {
|
|
268
|
+
"enabled": true,
|
|
269
|
+
"scout": {
|
|
270
|
+
"enabled": true,
|
|
271
|
+
"timeout_seconds": 120,
|
|
272
|
+
"max_files_analyzed": 1000,
|
|
273
|
+
"depth_limit": 4
|
|
274
|
+
},
|
|
275
|
+
"researcher": {
|
|
276
|
+
"enabled": true,
|
|
277
|
+
"timeout_seconds": 300,
|
|
278
|
+
"max_researchers_parallel": 3,
|
|
279
|
+
"max_queries_per_topic": 10
|
|
280
|
+
},
|
|
281
|
+
"cache": {
|
|
282
|
+
"enabled": true,
|
|
283
|
+
"ttl_hours": 24,
|
|
284
|
+
"max_entries": 50
|
|
285
|
+
},
|
|
286
|
+
"skip_conditions": {
|
|
287
|
+
"quick_mode_eligible": true,
|
|
288
|
+
"debug_mode": true,
|
|
289
|
+
"all_tech_cached": true
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Full schema documented in: `docs/RESEARCH_CONFIG.md`
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Integration Checklist
|
|
300
|
+
|
|
301
|
+
Research infrastructure is complete. Next steps for full integration:
|
|
302
|
+
|
|
303
|
+
### Phase 1: Validation (Complete)
|
|
304
|
+
- [x] Create `.grid/research/` directory
|
|
305
|
+
- [x] Create `.grid/research_cache/` directory
|
|
306
|
+
- [x] Create `.grid/scout/` directory
|
|
307
|
+
- [x] Write README files documenting structure
|
|
308
|
+
- [x] Initialize cache index JSON
|
|
309
|
+
- [x] Add .gitignore files
|
|
310
|
+
- [x] Verify agent files are spawn-ready
|
|
311
|
+
- [x] Document configuration schema
|
|
312
|
+
- [x] Document MC integration flow
|
|
313
|
+
|
|
314
|
+
### Phase 2: MC Integration (Ready to implement)
|
|
315
|
+
- [ ] Add config loading to MC initialization
|
|
316
|
+
- [ ] Implement `should_run_research()` logic
|
|
317
|
+
- [ ] Implement `spawn_scout()` function
|
|
318
|
+
- [ ] Implement `extract_research_needs()` function
|
|
319
|
+
- [ ] Implement `check_research_cache()` function
|
|
320
|
+
- [ ] Implement `spawn_researchers()` function
|
|
321
|
+
- [ ] Implement context assembly
|
|
322
|
+
- [ ] Update Planner spawn with research context
|
|
323
|
+
|
|
324
|
+
### Phase 3: User Experience (After MC integration)
|
|
325
|
+
- [ ] Add user commands ("skip research", "fresh research")
|
|
326
|
+
- [ ] Add progress output ("Research phase: Scout complete...")
|
|
327
|
+
- [ ] Document in `/grid:help`
|
|
328
|
+
- [ ] Add metrics logging
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## File Locations Reference
|
|
333
|
+
|
|
334
|
+
### Agent Definitions
|
|
335
|
+
- `/Users/jacweath/grid/agents/grid-scout.md` - Scout agent
|
|
336
|
+
- `/Users/jacweath/grid/agents/grid-researcher.md` - Researcher agent
|
|
337
|
+
- `/Users/jacweath/grid/agents/grid-planner.md` - Planner agent (receives research)
|
|
338
|
+
|
|
339
|
+
### Documentation
|
|
340
|
+
- `/Users/jacweath/grid/docs/RESEARCH_FIRST.md` - Architecture design
|
|
341
|
+
- `/Users/jacweath/grid/docs/RESEARCH_CONFIG.md` - Configuration reference
|
|
342
|
+
- `/Users/jacweath/grid/docs/MC_RESEARCH_INTEGRATION.md` - MC integration guide
|
|
343
|
+
- `/Users/jacweath/grid/docs/RESEARCH_INFRASTRUCTURE.md` - This file
|
|
344
|
+
|
|
345
|
+
### State Directories (Local Only - Gitignored)
|
|
346
|
+
- `/Users/jacweath/grid/.grid/research/` - Fresh research outputs
|
|
347
|
+
- `/Users/jacweath/grid/.grid/research_cache/` - Cached research
|
|
348
|
+
- `/Users/jacweath/grid/.grid/scout/` - Scout reports
|
|
349
|
+
|
|
350
|
+
### Master Control
|
|
351
|
+
- `/Users/jacweath/grid/commands/grid/mc.md` - MC command definition
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Testing Research Infrastructure
|
|
356
|
+
|
|
357
|
+
### Manual Test: Scout Spawn
|
|
358
|
+
|
|
359
|
+
```python
|
|
360
|
+
# In MC
|
|
361
|
+
scout_prompt = """
|
|
362
|
+
First, read ~/.claude/agents/grid-scout.md for your role.
|
|
363
|
+
|
|
364
|
+
<config>
|
|
365
|
+
project_root: /Users/jacweath/grid
|
|
366
|
+
timeout_seconds: 120
|
|
367
|
+
</config>
|
|
368
|
+
|
|
369
|
+
Scan the Grid codebase. Write report to .grid/scout/RECON_test.md
|
|
370
|
+
"""
|
|
371
|
+
|
|
372
|
+
Task(prompt=scout_prompt, subagent_type="general-purpose", description="Test Scout")
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Expected: Scout report in `.grid/scout/RECON_test.md`
|
|
376
|
+
|
|
377
|
+
### Manual Test: Researcher Spawn
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
# In MC
|
|
381
|
+
researcher_prompt = """
|
|
382
|
+
First, read ~/.claude/agents/grid-researcher.md for your role.
|
|
383
|
+
|
|
384
|
+
<research_request>
|
|
385
|
+
mission: technology
|
|
386
|
+
topic: Next.js 14 App Router
|
|
387
|
+
queries:
|
|
388
|
+
- Next.js 14 App Router best practices 2024 2025
|
|
389
|
+
- Server Components production patterns
|
|
390
|
+
</research_request>
|
|
391
|
+
|
|
392
|
+
Research and write to .grid/research_cache/nextjs-14-app-router.md
|
|
393
|
+
Update cache index at .grid/research_cache/index.json
|
|
394
|
+
"""
|
|
395
|
+
|
|
396
|
+
Task(prompt=researcher_prompt, subagent_type="general-purpose", description="Test Researcher")
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Expected:
|
|
400
|
+
- Research output in `.grid/research_cache/nextjs-14-app-router.md`
|
|
401
|
+
- Cache index updated with new entry
|
|
402
|
+
|
|
403
|
+
### Manual Test: Cache Hit
|
|
404
|
+
|
|
405
|
+
```python
|
|
406
|
+
# Second call with same topic should hit cache
|
|
407
|
+
cached, needed = check_research_cache([
|
|
408
|
+
{'topic': 'Next.js 14 App Router', 'queries': ['Next.js 14 best practices']}
|
|
409
|
+
])
|
|
410
|
+
|
|
411
|
+
assert len(cached) == 1 # Hit!
|
|
412
|
+
assert len(needed) == 0 # Nothing to research
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
---
|
|
416
|
+
|
|
417
|
+
## Summary
|
|
418
|
+
|
|
419
|
+
Research-first infrastructure is **FUNCTIONAL**:
|
|
420
|
+
|
|
421
|
+
1. **Directories created** - `.grid/research/`, `.grid/research_cache/`, `.grid/scout/`
|
|
422
|
+
2. **Documentation complete** - READMEs, config schema, integration guide
|
|
423
|
+
3. **Agents validated** - Scout and Researcher are spawn-ready
|
|
424
|
+
4. **Cache initialized** - Empty index ready for entries
|
|
425
|
+
5. **Gitignores added** - State files properly excluded
|
|
426
|
+
|
|
427
|
+
**Next Step:** MC integration - implement research phase logic in Master Control.
|
|
428
|
+
|
|
429
|
+
**End of Line.**
|