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.
Files changed (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +171 -0
  3. package/bin/create-ai-context.js +337 -0
  4. package/lib/adapters/antigravity.js +160 -0
  5. package/lib/adapters/claude.js +122 -0
  6. package/lib/adapters/cline.js +111 -0
  7. package/lib/adapters/copilot.js +117 -0
  8. package/lib/adapters/index.js +69 -0
  9. package/lib/ai-context-generator.js +234 -0
  10. package/lib/ai-orchestrator.js +431 -0
  11. package/lib/call-tracer.js +444 -0
  12. package/lib/detector.js +726 -0
  13. package/lib/environment-detector.js +239 -0
  14. package/lib/index.js +310 -0
  15. package/lib/installer.js +418 -0
  16. package/lib/migrate.js +319 -0
  17. package/lib/placeholder.js +541 -0
  18. package/lib/prompts.js +287 -0
  19. package/lib/spinner.js +60 -0
  20. package/lib/static-analyzer.js +729 -0
  21. package/lib/template-populator.js +843 -0
  22. package/lib/template-renderer.js +382 -0
  23. package/lib/validate.js +155 -0
  24. package/package.json +70 -0
  25. package/templates/AI_CONTEXT.md.template +245 -0
  26. package/templates/base/README.md +257 -0
  27. package/templates/base/RPI_WORKFLOW_PLAN.md +320 -0
  28. package/templates/base/agents/api-developer.md +76 -0
  29. package/templates/base/agents/context-engineer.md +525 -0
  30. package/templates/base/agents/core-architect.md +76 -0
  31. package/templates/base/agents/database-ops.md +76 -0
  32. package/templates/base/agents/deployment-ops.md +76 -0
  33. package/templates/base/agents/integration-hub.md +76 -0
  34. package/templates/base/analytics/README.md +114 -0
  35. package/templates/base/automation/config.json +58 -0
  36. package/templates/base/automation/generators/code-mapper.js +308 -0
  37. package/templates/base/automation/generators/index-builder.js +321 -0
  38. package/templates/base/automation/hooks/post-commit.sh +83 -0
  39. package/templates/base/automation/hooks/pre-commit.sh +103 -0
  40. package/templates/base/ci-templates/README.md +108 -0
  41. package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
  42. package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
  43. package/templates/base/commands/analytics.md +238 -0
  44. package/templates/base/commands/auto-sync.md +172 -0
  45. package/templates/base/commands/collab.md +194 -0
  46. package/templates/base/commands/help.md +450 -0
  47. package/templates/base/commands/rpi-implement.md +115 -0
  48. package/templates/base/commands/rpi-plan.md +93 -0
  49. package/templates/base/commands/rpi-research.md +88 -0
  50. package/templates/base/commands/session-resume.md +144 -0
  51. package/templates/base/commands/session-save.md +112 -0
  52. package/templates/base/commands/validate-all.md +77 -0
  53. package/templates/base/commands/verify-docs-current.md +86 -0
  54. package/templates/base/config/base.json +57 -0
  55. package/templates/base/config/environments/development.json +13 -0
  56. package/templates/base/config/environments/production.json +17 -0
  57. package/templates/base/config/environments/staging.json +13 -0
  58. package/templates/base/config/local.json.example +21 -0
  59. package/templates/base/context/.meta/generated-at.json +18 -0
  60. package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
  61. package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
  62. package/templates/base/context/FILE_OWNERSHIP.md +57 -0
  63. package/templates/base/context/INTEGRATION_POINTS.md +92 -0
  64. package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
  65. package/templates/base/context/TESTING_MAP.md +95 -0
  66. package/templates/base/context/WORKFLOW_INDEX.md +129 -0
  67. package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
  68. package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
  69. package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
  70. package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
  71. package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
  72. package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
  73. package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
  74. package/templates/base/knowledge/README.md +98 -0
  75. package/templates/base/knowledge/sessions/README.md +88 -0
  76. package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
  77. package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
  78. package/templates/base/knowledge/shared/decisions/README.md +49 -0
  79. package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
  80. package/templates/base/knowledge/shared/patterns/README.md +62 -0
  81. package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
  82. package/templates/base/plans/PLAN_TEMPLATE.md +250 -0
  83. package/templates/base/plans/active/.gitkeep +0 -0
  84. package/templates/base/plans/completed/.gitkeep +0 -0
  85. package/templates/base/research/RESEARCH_TEMPLATE.md +153 -0
  86. package/templates/base/research/active/.gitkeep +0 -0
  87. package/templates/base/research/completed/.gitkeep +0 -0
  88. package/templates/base/schemas/agent.schema.json +141 -0
  89. package/templates/base/schemas/anchors.schema.json +54 -0
  90. package/templates/base/schemas/automation.schema.json +93 -0
  91. package/templates/base/schemas/command.schema.json +134 -0
  92. package/templates/base/schemas/hashes.schema.json +40 -0
  93. package/templates/base/schemas/manifest.schema.json +117 -0
  94. package/templates/base/schemas/plan.schema.json +136 -0
  95. package/templates/base/schemas/research.schema.json +115 -0
  96. package/templates/base/schemas/roles.schema.json +34 -0
  97. package/templates/base/schemas/session.schema.json +77 -0
  98. package/templates/base/schemas/settings.schema.json +244 -0
  99. package/templates/base/schemas/staleness.schema.json +53 -0
  100. package/templates/base/schemas/team-config.schema.json +42 -0
  101. package/templates/base/schemas/workflow.schema.json +126 -0
  102. package/templates/base/session/checkpoints/.gitkeep +2 -0
  103. package/templates/base/session/current/state.json +20 -0
  104. package/templates/base/session/history/.gitkeep +2 -0
  105. package/templates/base/settings.json +3 -0
  106. package/templates/base/standards/COMPATIBILITY.md +219 -0
  107. package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
  108. package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
  109. package/templates/base/standards/README.md +66 -0
  110. package/templates/base/sync/anchors.json +6 -0
  111. package/templates/base/sync/hashes.json +6 -0
  112. package/templates/base/sync/staleness.json +10 -0
  113. package/templates/base/team/README.md +168 -0
  114. package/templates/base/team/config.json +79 -0
  115. package/templates/base/team/roles.json +145 -0
  116. package/templates/base/tools/bin/claude-context.js +151 -0
  117. package/templates/base/tools/lib/anchor-resolver.js +276 -0
  118. package/templates/base/tools/lib/config-loader.js +363 -0
  119. package/templates/base/tools/lib/detector.js +350 -0
  120. package/templates/base/tools/lib/diagnose.js +206 -0
  121. package/templates/base/tools/lib/drift-detector.js +373 -0
  122. package/templates/base/tools/lib/errors.js +199 -0
  123. package/templates/base/tools/lib/index.js +36 -0
  124. package/templates/base/tools/lib/init.js +192 -0
  125. package/templates/base/tools/lib/logger.js +230 -0
  126. package/templates/base/tools/lib/placeholder.js +201 -0
  127. package/templates/base/tools/lib/session-manager.js +354 -0
  128. package/templates/base/tools/lib/validate.js +521 -0
  129. package/templates/base/tools/package.json +49 -0
  130. package/templates/handlebars/antigravity.hbs +337 -0
  131. package/templates/handlebars/claude.hbs +184 -0
  132. package/templates/handlebars/cline.hbs +63 -0
  133. package/templates/handlebars/copilot.hbs +131 -0
  134. package/templates/handlebars/partials/gotcha-list.hbs +11 -0
  135. package/templates/handlebars/partials/header.hbs +3 -0
  136. package/templates/handlebars/partials/workflow-summary.hbs +16 -0
@@ -0,0 +1,320 @@
1
+ # RPI (Research, Plan, Implement) Workflow
2
+
3
+ **Created:** {{DATE}}
4
+ **Platform:** Claude Code
5
+ **Context Budget:** 200k tokens max, target <40%
6
+ **Output Budget:** 30k tokens max per response
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ The RPI workflow prevents the "slop" and "dumb zone" problems in AI-assisted development. By separating research, planning, and implementation into distinct phases, we achieve:
13
+
14
+ - **90% fewer cascading errors**
15
+ - **3× faster feature implementation**
16
+ - **5× faster issue resolution**
17
+ - **Self-documenting changes**
18
+
19
+ ---
20
+
21
+ ## Phase 1: RESEARCH
22
+
23
+ ### Purpose
24
+ Understand the system, locate relevant components, prevent context pollution
25
+
26
+ ### Artifacts
27
+ - Research document in `.ai-context/research/active/[feature]_research.md`
28
+ - 150-word summary for parent context
29
+
30
+ ### Process
31
+ 1. Load WORKFLOW_INDEX.md first (saves 100k+ tokens)
32
+ 2. Use parallel Explore agents (3 simultaneous)
33
+ 3. Trace call chains with line numbers
34
+ 4. Map dependencies (internal + external)
35
+ 5. Identify test coverage gaps
36
+ 6. Document open questions
37
+
38
+ ### Context Budget
39
+ - Starting: Up to 50k tokens for exploration
40
+ - Ending: 20k tokens (research doc only)
41
+ - Compaction: After each phase
42
+
43
+ ### Exit Criteria
44
+ - [ ] Research document created
45
+ - [ ] 3-20 relevant files identified
46
+ - [ ] Call chains traced with line numbers
47
+ - [ ] Dependencies mapped
48
+ - [ ] 150-word summary generated
49
+
50
+ ---
51
+
52
+ ## Phase 2: PLAN
53
+
54
+ ### Purpose
55
+ Design implementation with file:line precision, get human alignment
56
+
57
+ ### Artifacts
58
+ - Plan document in `.ai-context/plans/active/[feature]_plan.md`
59
+ - Step-by-step implementation roadmap
60
+
61
+ ### Process
62
+ 1. Load research document
63
+ 2. Reference workflow gotchas
64
+ 3. Create modification list with exact line numbers
65
+ 4. Plan testing strategy
66
+ 5. Estimate context budget per step
67
+ 6. Define rollback plan
68
+
69
+ ### Context Budget
70
+ - Research doc: 20k tokens
71
+ - Plan creation: 15k tokens
72
+ - Total: 35k tokens (17.5%)
73
+
74
+ ### Exit Criteria
75
+ - [ ] Plan document created with file:line references
76
+ - [ ] All modifications listed with risk level
77
+ - [ ] Test strategy defined
78
+ - [ ] Rollback plan documented
79
+ - [ ] Human review completed
80
+
81
+ ---
82
+
83
+ ## Phase 3: IMPLEMENT
84
+
85
+ ### Purpose
86
+ Execute atomically with continuous testing
87
+
88
+ ### Golden Rule
89
+ ```
90
+ ONE CHANGE → ONE TEST → ONE COMMIT
91
+ ```
92
+
93
+ ### Process
94
+ 1. Load plan and affected workflow sections
95
+ 2. Make single, atomic change
96
+ 3. Run affected tests immediately
97
+ 4. Commit if tests pass
98
+ 5. Update documentation
99
+ 6. Repeat until plan complete
100
+
101
+ ### Context Budget
102
+ - Plan: 15k tokens
103
+ - Active code: 30k tokens
104
+ - Test results: 15k tokens
105
+ - Total: 60k tokens (30%)
106
+
107
+ ### Context Reset (Every 3 Steps)
108
+ 1. Update progress checklist
109
+ 2. Re-read plan document
110
+ 3. Verify scope alignment
111
+ 4. Compact if >35% utilization
112
+
113
+ ### Exit Criteria
114
+ - [ ] All plan steps completed
115
+ - [ ] All tests passing
116
+ - [ ] Documentation updated
117
+ - [ ] Changes committed
118
+
119
+ ---
120
+
121
+ ## Template Files
122
+
123
+ ### RESEARCH_TEMPLATE.md
124
+
125
+ ```markdown
126
+ # Research: [Feature/Bug Name]
127
+
128
+ **Date:** YYYY-MM-DD
129
+ **Researcher:** Claude Code
130
+ **Status:** IN_PROGRESS | COMPLETE | BLOCKED
131
+
132
+ ---
133
+
134
+ ## Objective
135
+ [Clear statement of what we're trying to understand]
136
+
137
+ ---
138
+
139
+ ## Relevant Files Explored
140
+
141
+ | File | Lines | Key Findings |
142
+ |------|-------|--------------|
143
+ | `path/to/file.py` | 100-200 | Entry point for [feature] |
144
+
145
+ ---
146
+
147
+ ## Code Flow Analysis
148
+
149
+ [Entry Point] → [Function A] → [Function B] → [Exit Point]
150
+
151
+ ```
152
+ entry_function() [file.py:100]
153
+ ├─ helper_a() [file.py:150]
154
+ │ └─ utility() [utils.py:50]
155
+ └─ helper_b() [file.py:200]
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Dependencies Identified
161
+
162
+ **External:**
163
+ - API Name (purpose)
164
+
165
+ **Internal:**
166
+ - service_file.py (purpose)
167
+
168
+ ---
169
+
170
+ ## Test Files & Coverage
171
+
172
+ **Existing:**
173
+ - tests/test_feature.py - Covers main flow
174
+
175
+ **Gaps:**
176
+ - ❌ No test for error scenario
177
+
178
+ ---
179
+
180
+ ## Open Questions
181
+
182
+ - [ ] Question 1
183
+ - [ ] Question 2
184
+
185
+ ---
186
+
187
+ ## Summary (for Plan Phase, 150 words max)
188
+
189
+ [Concise summary for parent context]
190
+ ```
191
+
192
+ ---
193
+
194
+ ### PLAN_TEMPLATE.md
195
+
196
+ ```markdown
197
+ # Implementation Plan: [Feature/Fix Name]
198
+
199
+ **Date:** YYYY-MM-DD
200
+ **Based on:** research/active/[feature]_research.md
201
+ **Status:** DRAFT | APPROVED | IMPLEMENTING | COMPLETE
202
+
203
+ ---
204
+
205
+ ## Research Summary
206
+ [From Phase 1 - max 200 words]
207
+
208
+ ---
209
+
210
+ ## Scope Definition
211
+
212
+ **In Scope:**
213
+ - [Explicit list]
214
+
215
+ **Out of Scope:**
216
+ - [What we're NOT touching]
217
+
218
+ ---
219
+
220
+ ## Files to Modify
221
+
222
+ | File | Lines | Change | Risk |
223
+ |------|-------|--------|------|
224
+ | `path/file.py` | 100-150 | Add parameter | LOW |
225
+
226
+ ---
227
+
228
+ ## Step-by-Step Implementation
229
+
230
+ ### Step 1: [Action Name]
231
+
232
+ **File:** `path/to/file.py`
233
+ **Lines:** 100-120
234
+
235
+ **Current:**
236
+ ```python
237
+ def existing_function():
238
+ pass
239
+ ```
240
+
241
+ **Proposed:**
242
+ ```python
243
+ def existing_function(new_param: str = "default"):
244
+ pass
245
+ ```
246
+
247
+ **Test:** `pytest tests/test_file.py -k test_name`
248
+
249
+ ---
250
+
251
+ ### Step 2: [Action Name]
252
+ ...
253
+
254
+ ---
255
+
256
+ ## Verification Checklist
257
+
258
+ - [ ] Syntax check passes
259
+ - [ ] Unit tests pass
260
+ - [ ] Integration tests pass
261
+ - [ ] E2E test passes
262
+
263
+ ---
264
+
265
+ ## Rollback Plan
266
+
267
+ - Revert: `git revert HEAD`
268
+ - Safe commit: `[hash]`
269
+
270
+ ---
271
+
272
+ ## Documentation Updates Required
273
+
274
+ - [ ] Workflow file: [name]
275
+ - [ ] Agent file: [name]
276
+ - [ ] AI_CONTEXT.md section: [name]
277
+ ```
278
+
279
+ ---
280
+
281
+ ## Error Recovery Protocol
282
+
283
+ | Error Type | Response |
284
+ |------------|----------|
285
+ | Syntax Error | STOP. Fix immediately in same session. |
286
+ | Import Error | Check file paths, verify imports. |
287
+ | Runtime Error | Create research subtask before fixing. |
288
+ | Test Failure | Do NOT add more code. Investigate first. |
289
+ | 3+ Failures | STOP. Compact context. Start new session. |
290
+
291
+ ---
292
+
293
+ ## Context Management
294
+
295
+ ### Compaction Triggers
296
+ - After 5+ file reads without tool use
297
+ - Error loop (3+ failed attempts)
298
+ - Session > 1 hour
299
+ - Context > 35% utilization
300
+
301
+ ### Compaction Actions
302
+ 1. Save progress to SESSION_HANDOFF.md
303
+ 2. Archive tool results
304
+ 3. Keep only essential context
305
+ 4. Continue or start fresh session
306
+
307
+ ---
308
+
309
+ ## Key Principles
310
+
311
+ 1. **<40% Context Rule:** Performance degrades beyond 40% context utilization
312
+ 2. **Sub-Agents:** Use parallel Explore agents for context isolation
313
+ 3. **On-Demand Loading:** Load information as needed, not upfront
314
+ 4. **Mental Alignment:** Plans align human and AI understanding
315
+ 5. **Atomic Changes:** Small, testable, reversible modifications
316
+
317
+ ---
318
+
319
+ **Version:** 1.1
320
+ **Status:** TEMPLATE
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: api-developer
3
+ version: "1.0.0"
4
+ displayName: "API Developer"
5
+ description: "API design, contract definition, and endpoint implementation specialist"
6
+ category: "api"
7
+ complexity: "medium"
8
+ context_budget: "~35K tokens"
9
+ capabilities:
10
+ - "rest-api-design"
11
+ - "graphql-design"
12
+ - "contract-definition"
13
+ - "endpoint-documentation"
14
+ - "api-testing-strategy"
15
+ workflows:
16
+ - "api-endpoints"
17
+ - "contracts"
18
+ - "versioning"
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: '@api-developer "Document API endpoints for [resource]"'
28
+ description: "Create comprehensive API documentation"
29
+ - invocation: '@api-developer "Validate API contracts"'
30
+ description: "Check contract consistency and completeness"
31
+ - invocation: '@api-developer "Generate OpenAPI spec"'
32
+ description: "Create OpenAPI/Swagger specification"
33
+ ---
34
+
35
+ # API Developer Agent
36
+
37
+ **Purpose:** API design, contract definition, and endpoint implementation
38
+
39
+ ## Capabilities
40
+
41
+ This agent specializes in:
42
+ - **API design** - Creating RESTful and GraphQL APIs with proper conventions
43
+ - **Contract definition** - Defining request/response schemas and validation rules
44
+ - **Endpoint implementation** - Generating boilerplate for API endpoints
45
+ - **Documentation generation** - Creating comprehensive API documentation
46
+ - **Testing strategy** - Planning and implementing API tests
47
+
48
+ ## Usage
49
+
50
+ After template initialization, this agent will be generated based on your API structure. It will:
51
+ 1. Analyze your existing API endpoints
52
+ 2. Create comprehensive API documentation
53
+ 3. Identify potential security vulnerabilities
54
+ 4. Provide recommendations for API optimization
55
+
56
+ ## Example Commands
57
+
58
+ ```bash
59
+ @api-developer "Document API endpoints for [resource]"
60
+ @api-developer "Validate API contracts for [endpoint]"
61
+ @api-developer "Generate test cases for [API]"
62
+ ```
63
+
64
+ ## Integration Points
65
+
66
+ This agent integrates with:
67
+ - Workflow documentation
68
+ - Database schema (for data endpoints)
69
+ - Testing strategies
70
+ - Security validation
71
+
72
+ ## Validation
73
+
74
+ - API contract consistency
75
+ - Endpoint security checks
76
+ - Response schema validation