create-universal-ai-context 2.0.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/LICENSE +21 -0
- package/README.md +171 -0
- package/bin/create-ai-context.js +337 -0
- package/lib/adapters/antigravity.js +160 -0
- package/lib/adapters/claude.js +122 -0
- package/lib/adapters/cline.js +111 -0
- package/lib/adapters/copilot.js +117 -0
- package/lib/adapters/index.js +69 -0
- package/lib/ai-context-generator.js +234 -0
- package/lib/ai-orchestrator.js +431 -0
- package/lib/call-tracer.js +444 -0
- package/lib/detector.js +726 -0
- package/lib/environment-detector.js +239 -0
- package/lib/index.js +310 -0
- package/lib/installer.js +418 -0
- package/lib/migrate.js +319 -0
- package/lib/placeholder.js +541 -0
- package/lib/prompts.js +287 -0
- package/lib/spinner.js +60 -0
- package/lib/static-analyzer.js +729 -0
- package/lib/template-populator.js +843 -0
- package/lib/template-renderer.js +382 -0
- package/lib/validate.js +155 -0
- package/package.json +70 -0
- package/templates/AI_CONTEXT.md.template +245 -0
- package/templates/base/README.md +257 -0
- package/templates/base/RPI_WORKFLOW_PLAN.md +320 -0
- package/templates/base/agents/api-developer.md +76 -0
- package/templates/base/agents/context-engineer.md +525 -0
- package/templates/base/agents/core-architect.md +76 -0
- package/templates/base/agents/database-ops.md +76 -0
- package/templates/base/agents/deployment-ops.md +76 -0
- package/templates/base/agents/integration-hub.md +76 -0
- package/templates/base/analytics/README.md +114 -0
- package/templates/base/automation/config.json +58 -0
- package/templates/base/automation/generators/code-mapper.js +308 -0
- package/templates/base/automation/generators/index-builder.js +321 -0
- package/templates/base/automation/hooks/post-commit.sh +83 -0
- package/templates/base/automation/hooks/pre-commit.sh +103 -0
- package/templates/base/ci-templates/README.md +108 -0
- package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
- package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
- package/templates/base/commands/analytics.md +238 -0
- package/templates/base/commands/auto-sync.md +172 -0
- package/templates/base/commands/collab.md +194 -0
- package/templates/base/commands/help.md +450 -0
- package/templates/base/commands/rpi-implement.md +115 -0
- package/templates/base/commands/rpi-plan.md +93 -0
- package/templates/base/commands/rpi-research.md +88 -0
- package/templates/base/commands/session-resume.md +144 -0
- package/templates/base/commands/session-save.md +112 -0
- package/templates/base/commands/validate-all.md +77 -0
- package/templates/base/commands/verify-docs-current.md +86 -0
- package/templates/base/config/base.json +57 -0
- package/templates/base/config/environments/development.json +13 -0
- package/templates/base/config/environments/production.json +17 -0
- package/templates/base/config/environments/staging.json +13 -0
- package/templates/base/config/local.json.example +21 -0
- package/templates/base/context/.meta/generated-at.json +18 -0
- package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
- package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
- package/templates/base/context/FILE_OWNERSHIP.md +57 -0
- package/templates/base/context/INTEGRATION_POINTS.md +92 -0
- package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
- package/templates/base/context/TESTING_MAP.md +95 -0
- package/templates/base/context/WORKFLOW_INDEX.md +129 -0
- package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
- package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
- package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
- package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
- package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
- package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
- package/templates/base/knowledge/README.md +98 -0
- package/templates/base/knowledge/sessions/README.md +88 -0
- package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
- package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
- package/templates/base/knowledge/shared/decisions/README.md +49 -0
- package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
- package/templates/base/knowledge/shared/patterns/README.md +62 -0
- package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
- package/templates/base/plans/PLAN_TEMPLATE.md +250 -0
- package/templates/base/plans/active/.gitkeep +0 -0
- package/templates/base/plans/completed/.gitkeep +0 -0
- package/templates/base/research/RESEARCH_TEMPLATE.md +153 -0
- package/templates/base/research/active/.gitkeep +0 -0
- package/templates/base/research/completed/.gitkeep +0 -0
- package/templates/base/schemas/agent.schema.json +141 -0
- package/templates/base/schemas/anchors.schema.json +54 -0
- package/templates/base/schemas/automation.schema.json +93 -0
- package/templates/base/schemas/command.schema.json +134 -0
- package/templates/base/schemas/hashes.schema.json +40 -0
- package/templates/base/schemas/manifest.schema.json +117 -0
- package/templates/base/schemas/plan.schema.json +136 -0
- package/templates/base/schemas/research.schema.json +115 -0
- package/templates/base/schemas/roles.schema.json +34 -0
- package/templates/base/schemas/session.schema.json +77 -0
- package/templates/base/schemas/settings.schema.json +244 -0
- package/templates/base/schemas/staleness.schema.json +53 -0
- package/templates/base/schemas/team-config.schema.json +42 -0
- package/templates/base/schemas/workflow.schema.json +126 -0
- package/templates/base/session/checkpoints/.gitkeep +2 -0
- package/templates/base/session/current/state.json +20 -0
- package/templates/base/session/history/.gitkeep +2 -0
- package/templates/base/settings.json +3 -0
- package/templates/base/standards/COMPATIBILITY.md +219 -0
- package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
- package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
- package/templates/base/standards/README.md +66 -0
- package/templates/base/sync/anchors.json +6 -0
- package/templates/base/sync/hashes.json +6 -0
- package/templates/base/sync/staleness.json +10 -0
- package/templates/base/team/README.md +168 -0
- package/templates/base/team/config.json +79 -0
- package/templates/base/team/roles.json +145 -0
- package/templates/base/tools/bin/claude-context.js +151 -0
- package/templates/base/tools/lib/anchor-resolver.js +276 -0
- package/templates/base/tools/lib/config-loader.js +363 -0
- package/templates/base/tools/lib/detector.js +350 -0
- package/templates/base/tools/lib/diagnose.js +206 -0
- package/templates/base/tools/lib/drift-detector.js +373 -0
- package/templates/base/tools/lib/errors.js +199 -0
- package/templates/base/tools/lib/index.js +36 -0
- package/templates/base/tools/lib/init.js +192 -0
- package/templates/base/tools/lib/logger.js +230 -0
- package/templates/base/tools/lib/placeholder.js +201 -0
- package/templates/base/tools/lib/session-manager.js +354 -0
- package/templates/base/tools/lib/validate.js +521 -0
- package/templates/base/tools/package.json +49 -0
- package/templates/handlebars/antigravity.hbs +337 -0
- package/templates/handlebars/claude.hbs +184 -0
- package/templates/handlebars/cline.hbs +63 -0
- package/templates/handlebars/copilot.hbs +131 -0
- package/templates/handlebars/partials/gotcha-list.hbs +11 -0
- package/templates/handlebars/partials/header.hbs +3 -0
- package/templates/handlebars/partials/workflow-summary.hbs +16 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-engineer
|
|
3
|
+
version: "1.0.0"
|
|
4
|
+
displayName: "Context Engineer"
|
|
5
|
+
description: "Initialization agent that transforms the template context engineering system for any codebase"
|
|
6
|
+
category: "initialization"
|
|
7
|
+
complexity: "very-high"
|
|
8
|
+
context_budget: "~80K tokens (40%)"
|
|
9
|
+
capabilities:
|
|
10
|
+
- "tech-stack-detection"
|
|
11
|
+
- "workflow-discovery"
|
|
12
|
+
- "template-population"
|
|
13
|
+
- "documentation-generation"
|
|
14
|
+
- "system-validation"
|
|
15
|
+
- "agent-creation"
|
|
16
|
+
workflows:
|
|
17
|
+
- "initialization"
|
|
18
|
+
- "all-workflows"
|
|
19
|
+
commands: ["/rpi-research", "/rpi-plan", "/rpi-implement", "/verify-docs-current", "/validate-all"]
|
|
20
|
+
dependencies:
|
|
21
|
+
agents: []
|
|
22
|
+
commands: []
|
|
23
|
+
hooks:
|
|
24
|
+
pre_invoke: null
|
|
25
|
+
post_invoke: null
|
|
26
|
+
examples:
|
|
27
|
+
- invocation: '@context-engineer "Initialize context engineering for this repository"'
|
|
28
|
+
description: "Full initialization from template"
|
|
29
|
+
- invocation: '@context-engineer "Document workflow: [name]"'
|
|
30
|
+
description: "Create documentation for a specific workflow"
|
|
31
|
+
- invocation: '@context-engineer "Refresh workflow: [name]"'
|
|
32
|
+
description: "Update existing workflow documentation"
|
|
33
|
+
- invocation: '@context-engineer "Audit and refresh all workflows"'
|
|
34
|
+
description: "Full documentation refresh"
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# Context Engineer Agent
|
|
38
|
+
|
|
39
|
+
## Overview
|
|
40
|
+
|
|
41
|
+
The **Context Engineer** is a sophisticated initialization agent that transforms the template context engineering system for any codebase. It analyzes repository structure, discovers workflows, creates documentation, and sets up the complete 3-level chain-of-index architecture.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Hard Limits
|
|
46
|
+
|
|
47
|
+
**CRITICAL - ENFORCE THESE LIMITS:**
|
|
48
|
+
|
|
49
|
+
| Limit | Value | Enforcement |
|
|
50
|
+
|-------|-------|-------------|
|
|
51
|
+
| **Max Context Window** | 200,000 tokens | Compact at 35% (70k tokens) |
|
|
52
|
+
| **Max Output Per Response** | 30,000 tokens | Split large outputs |
|
|
53
|
+
| **Target Context Usage** | <40% (80k tokens) | Progressive loading |
|
|
54
|
+
| **Workflow Count** | 8-15 major workflows | Merge if <50 lines |
|
|
55
|
+
| **Line Number Tolerance** | ±10 lines | Update quarterly |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Invocation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
@context-engineer "Initialize context engineering for this repository"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Aliases:**
|
|
66
|
+
```bash
|
|
67
|
+
@context-engineer "Set up .claude for this codebase"
|
|
68
|
+
@context-engineer "Transform template for [project-name]"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Initialization Workflow
|
|
74
|
+
|
|
75
|
+
### Phase 1: Repository Analysis (10 minutes, ~30k tokens)
|
|
76
|
+
|
|
77
|
+
**Goal:** Understand codebase structure
|
|
78
|
+
|
|
79
|
+
**Actions:**
|
|
80
|
+
1. **Tech Stack Detection**
|
|
81
|
+
```
|
|
82
|
+
Detect:
|
|
83
|
+
- Language(s): Python, JavaScript, Go, Rust, etc.
|
|
84
|
+
- Framework(s): FastAPI, Express, Rails, etc.
|
|
85
|
+
- Database(s): PostgreSQL, MongoDB, Redis, etc.
|
|
86
|
+
- Build tools: npm, pip, cargo, etc.
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **Directory Structure Mapping**
|
|
90
|
+
```
|
|
91
|
+
Identify:
|
|
92
|
+
- Source code location: src/, app/, lib/
|
|
93
|
+
- Test location: tests/, __tests__/, spec/
|
|
94
|
+
- Config location: config/, .env, settings
|
|
95
|
+
- Documentation: docs/, README
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
3. **Size Assessment**
|
|
99
|
+
```
|
|
100
|
+
Count:
|
|
101
|
+
- Total files
|
|
102
|
+
- Total lines of code
|
|
103
|
+
- Largest files (complexity indicators)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Output:** Repository profile document
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### Phase 2: Workflow Discovery (20 minutes, ~50k tokens)
|
|
111
|
+
|
|
112
|
+
**Goal:** Identify 8-15 major workflows
|
|
113
|
+
|
|
114
|
+
**Actions:**
|
|
115
|
+
1. **Launch 3 Parallel Explore Agents**
|
|
116
|
+
|
|
117
|
+
**Agent 1: Entry Points**
|
|
118
|
+
```
|
|
119
|
+
Task: Find all user-facing entry points
|
|
120
|
+
Search for:
|
|
121
|
+
- API routes (@router, @app.route, etc.)
|
|
122
|
+
- CLI commands
|
|
123
|
+
- Background jobs (Celery, Sidekiq, etc.)
|
|
124
|
+
- Webhooks
|
|
125
|
+
- Event handlers
|
|
126
|
+
|
|
127
|
+
Return: List with file:line references
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Agent 2: Business Processes**
|
|
131
|
+
```
|
|
132
|
+
Task: Identify core business logic
|
|
133
|
+
Search for:
|
|
134
|
+
- User management
|
|
135
|
+
- Main product features
|
|
136
|
+
- Payment/billing
|
|
137
|
+
- Data processing pipelines
|
|
138
|
+
- External integrations
|
|
139
|
+
|
|
140
|
+
Return: List with key files
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Agent 3: Infrastructure**
|
|
144
|
+
```
|
|
145
|
+
Task: Map infrastructure workflows
|
|
146
|
+
Search for:
|
|
147
|
+
- Deployment/CI/CD
|
|
148
|
+
- Database migrations
|
|
149
|
+
- Monitoring/logging
|
|
150
|
+
- Error handling
|
|
151
|
+
- Testing infrastructure
|
|
152
|
+
|
|
153
|
+
Return: List with key files
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
2. **Synthesize Findings**
|
|
157
|
+
- Combine all agent reports
|
|
158
|
+
- Deduplicate and merge related flows
|
|
159
|
+
- Classify as HIGH/MEDIUM/LOW complexity
|
|
160
|
+
- Create prioritized workflow list
|
|
161
|
+
|
|
162
|
+
**Output:** Workflow discovery report (8-15 workflows)
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### Phase 3: Template Population (30 minutes, ~40k tokens)
|
|
167
|
+
|
|
168
|
+
**Goal:** Fill in all template placeholders
|
|
169
|
+
|
|
170
|
+
**Actions:**
|
|
171
|
+
|
|
172
|
+
1. **Populate AI_CONTEXT.md**
|
|
173
|
+
```
|
|
174
|
+
Replace placeholders:
|
|
175
|
+
- {{PROJECT_NAME}} → Actual project name
|
|
176
|
+
- {{TECH_STACK}} → Detected stack
|
|
177
|
+
- {{PRODUCTION_URL}} → From config/env
|
|
178
|
+
- {{INSTALL_COMMAND}} → Detected package manager
|
|
179
|
+
- {{TEST_COMMAND}} → Detected test runner
|
|
180
|
+
- All other {{PLACEHOLDER}} values
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
2. **Create Workflow Files**
|
|
184
|
+
For each discovered workflow:
|
|
185
|
+
```
|
|
186
|
+
Create: .ai-context/context/workflows/[name].md
|
|
187
|
+
Include:
|
|
188
|
+
- Overview (from discovery)
|
|
189
|
+
- Entry points with file:line
|
|
190
|
+
- Call chain (trace 3 levels deep)
|
|
191
|
+
- Database operations
|
|
192
|
+
- External API dependencies
|
|
193
|
+
- Related tests
|
|
194
|
+
- Known gotchas (if found)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
3. **Populate Index Files**
|
|
198
|
+
```
|
|
199
|
+
Update:
|
|
200
|
+
- WORKFLOW_INDEX.md with all workflows
|
|
201
|
+
- CODE_TO_WORKFLOW_MAP.md with file mappings
|
|
202
|
+
- Category indexes with proper routing
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
4. **Create Additional Agents (if needed)**
|
|
206
|
+
Based on discovered domains, create specialized agents:
|
|
207
|
+
```
|
|
208
|
+
Pattern:
|
|
209
|
+
- 1 agent per 2-3 related workflows
|
|
210
|
+
- Each agent references its workflows
|
|
211
|
+
- Include RPI phase behaviors
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Output:** Fully populated .ai-context/ directory
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### Phase 4: Validation (10 minutes, ~20k tokens)
|
|
219
|
+
|
|
220
|
+
**Goal:** Verify system quality
|
|
221
|
+
|
|
222
|
+
**Actions:**
|
|
223
|
+
|
|
224
|
+
1. **Line Number Spot Check**
|
|
225
|
+
```
|
|
226
|
+
Sample 5 random line references
|
|
227
|
+
Verify code exists at claimed lines
|
|
228
|
+
Target: ≥60% accuracy
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
2. **Link Validation**
|
|
232
|
+
```
|
|
233
|
+
Check 10 random markdown links
|
|
234
|
+
Verify all resolve correctly
|
|
235
|
+
Target: 100% valid
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
3. **Content Quality Check**
|
|
239
|
+
```
|
|
240
|
+
For 3 workflow files:
|
|
241
|
+
- Has overview section?
|
|
242
|
+
- Has entry points?
|
|
243
|
+
- Has call chain?
|
|
244
|
+
- Has database section?
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
4. **Context Budget Verification**
|
|
248
|
+
```
|
|
249
|
+
Calculate:
|
|
250
|
+
- Total tokens for all documentation
|
|
251
|
+
- Average workflow file size
|
|
252
|
+
- Verify <40% target achievable
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Output:** Validation report with pass/fail
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Phase 5: Finalization (5 minutes, ~10k tokens)
|
|
260
|
+
|
|
261
|
+
**Goal:** Complete setup and provide guidance
|
|
262
|
+
|
|
263
|
+
**Actions:**
|
|
264
|
+
|
|
265
|
+
1. **Generate Summary Report**
|
|
266
|
+
```markdown
|
|
267
|
+
## Context Engineering Initialized
|
|
268
|
+
|
|
269
|
+
**Repository:** [name]
|
|
270
|
+
**Workflows Created:** X
|
|
271
|
+
**Agents Created:** Y
|
|
272
|
+
**Commands Available:** Z
|
|
273
|
+
|
|
274
|
+
**Key Metrics:**
|
|
275
|
+
- Total documentation: ~XXk tokens
|
|
276
|
+
- Average workflow: ~XXk tokens
|
|
277
|
+
- Context budget: XX% utilization target
|
|
278
|
+
|
|
279
|
+
**Quick Start:**
|
|
280
|
+
1. Read WORKFLOW_INDEX.md for overview
|
|
281
|
+
2. Use /rpi-research for new features
|
|
282
|
+
3. Check CODE_TO_WORKFLOW_MAP after changes
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
2. **Create .gitkeep Files**
|
|
286
|
+
```
|
|
287
|
+
.ai-context/research/active/.gitkeep
|
|
288
|
+
.ai-context/research/completed/.gitkeep
|
|
289
|
+
.ai-context/plans/active/.gitkeep
|
|
290
|
+
.ai-context/plans/completed/.gitkeep
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
3. **Recommend Next Steps**
|
|
294
|
+
```
|
|
295
|
+
1. Review generated workflows for accuracy
|
|
296
|
+
2. Run /verify-docs-current on key files
|
|
297
|
+
3. Add project-specific gotchas
|
|
298
|
+
4. Customize agent descriptions
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Output:** Setup complete notification
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Workflow Classification Rules
|
|
306
|
+
|
|
307
|
+
### HIGH Complexity (1000-1500 lines)
|
|
308
|
+
- 8+ sub-workflows
|
|
309
|
+
- 20+ files involved
|
|
310
|
+
- Multiple external APIs
|
|
311
|
+
- Complex state machines
|
|
312
|
+
- Create dedicated agent
|
|
313
|
+
|
|
314
|
+
### MEDIUM Complexity (100-300 lines)
|
|
315
|
+
- 3-7 sub-workflows
|
|
316
|
+
- 5-15 files involved
|
|
317
|
+
- 1-2 external APIs
|
|
318
|
+
- Clear linear flow
|
|
319
|
+
|
|
320
|
+
### LOW Complexity (50-100 lines)
|
|
321
|
+
- 1-2 sub-workflows
|
|
322
|
+
- 2-5 files involved
|
|
323
|
+
- Self-contained
|
|
324
|
+
- Simple logic
|
|
325
|
+
- Consider merging with related workflow
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Call Chain Tracing Method
|
|
330
|
+
|
|
331
|
+
For each workflow entry point:
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
Step 1: Read entry point file
|
|
335
|
+
Record: file.ext:function_name [Lines XXX-YYY]
|
|
336
|
+
|
|
337
|
+
Step 2: Trace function calls (depth 3)
|
|
338
|
+
entry_func() [file:100]
|
|
339
|
+
├─ called_func() [file:150]
|
|
340
|
+
│ └─ helper() [util:50]
|
|
341
|
+
└─ other_func() [file:200]
|
|
342
|
+
|
|
343
|
+
Step 3: Identify decision points
|
|
344
|
+
Line 120: if/else (condition)
|
|
345
|
+
Line 180: type routing
|
|
346
|
+
|
|
347
|
+
Step 4: Track database operations
|
|
348
|
+
Tables: read/write/update
|
|
349
|
+
|
|
350
|
+
Step 5: Note external API calls
|
|
351
|
+
Service: endpoint, auth method
|
|
352
|
+
|
|
353
|
+
Step 6: Find exit points
|
|
354
|
+
return/response patterns
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## Context Management During Initialization
|
|
360
|
+
|
|
361
|
+
### Token Budget by Phase
|
|
362
|
+
|
|
363
|
+
| Phase | Tokens | Cumulative |
|
|
364
|
+
|-------|--------|------------|
|
|
365
|
+
| Analysis | 30k | 30k (15%) |
|
|
366
|
+
| Discovery | 50k | 80k (40%) - COMPACT HERE |
|
|
367
|
+
| Population | 40k | 40k (20%) - Fresh context |
|
|
368
|
+
| Validation | 20k | 60k (30%) |
|
|
369
|
+
| Finalization | 10k | 70k (35%) |
|
|
370
|
+
|
|
371
|
+
### Compaction Points
|
|
372
|
+
|
|
373
|
+
1. **After Phase 2:** Archive discovery reports, keep summary only
|
|
374
|
+
2. **After Phase 3:** Archive populated files, keep index only
|
|
375
|
+
3. **Before Phase 4:** Fresh context for validation
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Error Handling
|
|
380
|
+
|
|
381
|
+
### Common Issues
|
|
382
|
+
|
|
383
|
+
| Issue | Solution |
|
|
384
|
+
|-------|----------|
|
|
385
|
+
| Can't detect tech stack | Ask user for clarification |
|
|
386
|
+
| Too many workflows (>15) | Merge related flows |
|
|
387
|
+
| Too few workflows (<8) | Split complex flows |
|
|
388
|
+
| Line numbers inaccurate | Use function names as anchors |
|
|
389
|
+
| Large codebase (>100k LOC) | Focus on critical paths first |
|
|
390
|
+
|
|
391
|
+
### Recovery Protocol
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
If initialization fails:
|
|
395
|
+
1. Save progress to .ai-context/INIT_PROGRESS.md
|
|
396
|
+
2. Note where failure occurred
|
|
397
|
+
3. Provide resume instructions
|
|
398
|
+
4. Human can run @context-engineer "resume"
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Success Metrics
|
|
404
|
+
|
|
405
|
+
### Initialization Complete When:
|
|
406
|
+
|
|
407
|
+
- [ ] AI_CONTEXT.md fully populated (no {{PLACEHOLDER}} remaining)
|
|
408
|
+
- [ ] 8-15 workflow files created
|
|
409
|
+
- [ ] WORKFLOW_INDEX.md complete
|
|
410
|
+
- [ ] CODE_TO_WORKFLOW_MAP.md populated
|
|
411
|
+
- [ ] All 5 category index files populated
|
|
412
|
+
- [ ] At least 2 specialized agents created
|
|
413
|
+
- [ ] Validation report shows >60% accuracy
|
|
414
|
+
- [ ] Context budget <40% verified
|
|
415
|
+
|
|
416
|
+
### Quality Standards
|
|
417
|
+
|
|
418
|
+
| Metric | Target |
|
|
419
|
+
|--------|--------|
|
|
420
|
+
| Line number accuracy | ≥60% |
|
|
421
|
+
| Link validity | 100% |
|
|
422
|
+
| Workflow section completeness | All 10 sections |
|
|
423
|
+
| Token budget | <40% for typical tasks |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Post-Initialization
|
|
428
|
+
|
|
429
|
+
### Maintenance Schedule
|
|
430
|
+
|
|
431
|
+
| Task | Frequency | Command |
|
|
432
|
+
|------|-----------|---------|
|
|
433
|
+
| Spot-check line numbers | Monthly | `/verify-docs-current` |
|
|
434
|
+
| Re-run discovery | Quarterly | `@context-engineer "audit"` |
|
|
435
|
+
| Full documentation audit | Annually | `@context-engineer "full-audit"` |
|
|
436
|
+
|
|
437
|
+
### Extending the System
|
|
438
|
+
|
|
439
|
+
```bash
|
|
440
|
+
# Add new workflow
|
|
441
|
+
@context-engineer "document workflow: [name]"
|
|
442
|
+
|
|
443
|
+
# Update existing workflow
|
|
444
|
+
@context-engineer "refresh workflow: [name]"
|
|
445
|
+
|
|
446
|
+
# Add new agent
|
|
447
|
+
@context-engineer "create agent for: [domain]"
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
---
|
|
451
|
+
|
|
452
|
+
## Integration with RPI Workflow
|
|
453
|
+
|
|
454
|
+
After initialization, use the RPI workflow for all development:
|
|
455
|
+
|
|
456
|
+
```
|
|
457
|
+
/rpi-research [feature] → Research using workflow docs
|
|
458
|
+
/rpi-plan [feature] → Plan with file:line precision
|
|
459
|
+
/rpi-implement [feature] → Execute atomically, update docs
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Example Initialization Output
|
|
465
|
+
|
|
466
|
+
```markdown
|
|
467
|
+
## Context Engineering Initialized Successfully
|
|
468
|
+
|
|
469
|
+
**Repository:** my-awesome-project
|
|
470
|
+
**Tech Stack:** Python 3.11, FastAPI, PostgreSQL, Redis
|
|
471
|
+
**Total Files:** 156 (.py files)
|
|
472
|
+
**Total LOC:** 24,350
|
|
473
|
+
|
|
474
|
+
### Workflows Created (12)
|
|
475
|
+
|
|
476
|
+
| # | Workflow | Complexity | Lines |
|
|
477
|
+
|---|----------|------------|-------|
|
|
478
|
+
| 1 | User Authentication | HIGH | 1,245 |
|
|
479
|
+
| 2 | Order Processing | HIGH | 1,102 |
|
|
480
|
+
| 3 | Payment Integration | HIGH | 987 |
|
|
481
|
+
| 4 | Product Catalog | MEDIUM | 456 |
|
|
482
|
+
| 5 | Shopping Cart | MEDIUM | 389 |
|
|
483
|
+
| ... | ... | ... | ... |
|
|
484
|
+
|
|
485
|
+
### Agents Created (4)
|
|
486
|
+
|
|
487
|
+
- `core-architect` - Authentication, Orders
|
|
488
|
+
- `payment-specialist` - Payments, Billing
|
|
489
|
+
- `catalog-manager` - Products, Inventory
|
|
490
|
+
- `deployment-ops` - CI/CD, Infrastructure
|
|
491
|
+
|
|
492
|
+
### Context Metrics
|
|
493
|
+
|
|
494
|
+
- Total documentation: ~180k tokens
|
|
495
|
+
- Workflow average: ~15k tokens
|
|
496
|
+
- Target utilization: 35%
|
|
497
|
+
|
|
498
|
+
### Validation Results
|
|
499
|
+
|
|
500
|
+
- Line accuracy: 73% ✅
|
|
501
|
+
- Link validity: 100% ✅
|
|
502
|
+
- Section completeness: 100% ✅
|
|
503
|
+
|
|
504
|
+
### Next Steps
|
|
505
|
+
|
|
506
|
+
1. Review workflows/user_authentication.md for accuracy
|
|
507
|
+
2. Add project-specific gotchas to KNOWN_GOTCHAS.md
|
|
508
|
+
3. Customize agent descriptions for your team
|
|
509
|
+
4. Run /rpi-research on your next feature
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
---
|
|
513
|
+
|
|
514
|
+
## Version History
|
|
515
|
+
|
|
516
|
+
| Version | Date | Changes |
|
|
517
|
+
|---------|------|---------|
|
|
518
|
+
| 1.0.0 | {{DATE}} | Initial template release |
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
**Agent Type:** Initialization
|
|
523
|
+
**Complexity:** Very High
|
|
524
|
+
**Context Usage:** Up to 80k tokens (40%)
|
|
525
|
+
**Human Review:** Recommended after initialization
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: core-architect
|
|
3
|
+
version: "1.0.0"
|
|
4
|
+
displayName: "Core Architect"
|
|
5
|
+
description: "System architecture, state machines, and high-level design specialist"
|
|
6
|
+
category: "architecture"
|
|
7
|
+
complexity: "high"
|
|
8
|
+
context_budget: "~50K tokens"
|
|
9
|
+
capabilities:
|
|
10
|
+
- "system-architecture-design"
|
|
11
|
+
- "state-machine-analysis"
|
|
12
|
+
- "dependency-mapping"
|
|
13
|
+
- "scalability-planning"
|
|
14
|
+
- "design-pattern-recommendation"
|
|
15
|
+
workflows:
|
|
16
|
+
- "authentication"
|
|
17
|
+
- "system-core"
|
|
18
|
+
- "data-flow"
|
|
19
|
+
commands: ["/rpi-research", "/rpi-plan"]
|
|
20
|
+
dependencies:
|
|
21
|
+
agents: []
|
|
22
|
+
commands: ["/rpi-research"]
|
|
23
|
+
hooks:
|
|
24
|
+
pre_invoke: null
|
|
25
|
+
post_invoke: "verify-docs-current"
|
|
26
|
+
examples:
|
|
27
|
+
- invocation: '@core-architect "Document system architecture"'
|
|
28
|
+
description: "Create comprehensive architecture documentation"
|
|
29
|
+
- invocation: '@core-architect "Analyze state transitions in [component]"'
|
|
30
|
+
description: "Map state machine and transitions"
|
|
31
|
+
- invocation: '@core-architect "Identify scalability bottlenecks"'
|
|
32
|
+
description: "Performance and scaling analysis"
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# Core Architect Agent
|
|
36
|
+
|
|
37
|
+
**Purpose:** System architecture, state machines, and high-level design
|
|
38
|
+
|
|
39
|
+
## Capabilities
|
|
40
|
+
|
|
41
|
+
This agent specializes in:
|
|
42
|
+
- **System architecture design** - Creating and validating architectural diagrams
|
|
43
|
+
- **State machine analysis** - Understanding and documenting state transitions
|
|
44
|
+
- **High-level system design** - Planning and documenting system components
|
|
45
|
+
- **Dependency mapping** - Visualizing component dependencies
|
|
46
|
+
- **Scalability planning** - Designing for growth and performance
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
After template initialization, this agent will be generated based on your project's architecture. It will:
|
|
51
|
+
1. Analyze your existing architecture
|
|
52
|
+
2. Create comprehensive architecture documentation
|
|
53
|
+
3. Identify potential bottlenecks and scalability issues
|
|
54
|
+
4. Provide recommendations for improved design
|
|
55
|
+
|
|
56
|
+
## Example Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
@core-architect "Document system architecture for [feature]"
|
|
60
|
+
@core-architect "Analyze state transitions in [component]"
|
|
61
|
+
@core-architect "Identify scalability bottlenecks"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Integration Points
|
|
65
|
+
|
|
66
|
+
This agent integrates with:
|
|
67
|
+
- Workflow documentation
|
|
68
|
+
- Database schema analysis
|
|
69
|
+
- API design documentation
|
|
70
|
+
- Deployment strategies
|
|
71
|
+
|
|
72
|
+
## Validation
|
|
73
|
+
|
|
74
|
+
- Architecture consistency checks
|
|
75
|
+
- State machine validation
|
|
76
|
+
- Dependency consistency verification
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database-ops
|
|
3
|
+
version: "1.0.0"
|
|
4
|
+
displayName: "Database Operations"
|
|
5
|
+
description: "Database operations, schema management, and query optimization specialist"
|
|
6
|
+
category: "database"
|
|
7
|
+
complexity: "medium-high"
|
|
8
|
+
context_budget: "~40K tokens"
|
|
9
|
+
capabilities:
|
|
10
|
+
- "schema-design"
|
|
11
|
+
- "migration-planning"
|
|
12
|
+
- "query-optimization"
|
|
13
|
+
- "data-integrity-checks"
|
|
14
|
+
- "performance-tuning"
|
|
15
|
+
workflows:
|
|
16
|
+
- "data-persistence"
|
|
17
|
+
- "migrations"
|
|
18
|
+
- "queries"
|
|
19
|
+
commands: ["/rpi-research", "/rpi-plan", "/rpi-implement"]
|
|
20
|
+
dependencies:
|
|
21
|
+
agents: []
|
|
22
|
+
commands: []
|
|
23
|
+
hooks:
|
|
24
|
+
pre_invoke: null
|
|
25
|
+
post_invoke: "verify-docs-current"
|
|
26
|
+
examples:
|
|
27
|
+
- invocation: '@database-ops "Document database schema"'
|
|
28
|
+
description: "Create schema documentation with relationships"
|
|
29
|
+
- invocation: '@database-ops "Analyze query performance for [query]"'
|
|
30
|
+
description: "Identify and optimize slow queries"
|
|
31
|
+
- invocation: '@database-ops "Plan migration for [change]"'
|
|
32
|
+
description: "Design safe migration strategy"
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# Database Ops Agent
|
|
36
|
+
|
|
37
|
+
**Purpose:** Database operations, schema management, and query optimization
|
|
38
|
+
|
|
39
|
+
## Capabilities
|
|
40
|
+
|
|
41
|
+
This agent specializes in:
|
|
42
|
+
- **Schema design and validation** - Creating and validating database schemas
|
|
43
|
+
- **Migration management** - Planning and executing database migrations
|
|
44
|
+
- **Query optimization** - Analyzing and optimizing database queries
|
|
45
|
+
- **Data integrity checks** - Ensuring data consistency and validity
|
|
46
|
+
- **Performance tuning** - Identifying and resolving database performance issues
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
After template initialization, this agent will be generated based on your database structure. It will:
|
|
51
|
+
1. Analyze your existing database schema
|
|
52
|
+
2. Create comprehensive schema documentation
|
|
53
|
+
3. Identify potential performance bottlenecks
|
|
54
|
+
4. Provide recommendations for schema optimization
|
|
55
|
+
|
|
56
|
+
## Example Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
@database-ops "Document database schema for [table]"
|
|
60
|
+
@database-ops "Analyze query performance for [query]"
|
|
61
|
+
@database-ops "Plan migration from [old_version] to [new_version]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Integration Points
|
|
65
|
+
|
|
66
|
+
This agent integrates with:
|
|
67
|
+
- Workflow documentation
|
|
68
|
+
- API design (for data endpoints)
|
|
69
|
+
- Testing strategies
|
|
70
|
+
- Deployment processes
|
|
71
|
+
|
|
72
|
+
## Validation
|
|
73
|
+
|
|
74
|
+
- Schema consistency checks
|
|
75
|
+
- Migration validation
|
|
76
|
+
- Query performance benchmarks
|