k0ntext 3.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 (239) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +623 -0
  3. package/bin/k0ntext.js +12 -0
  4. package/dist/agents/cleanup-agent.d.ts +39 -0
  5. package/dist/agents/cleanup-agent.d.ts.map +1 -0
  6. package/dist/agents/cleanup-agent.js +56 -0
  7. package/dist/agents/cleanup-agent.js.map +1 -0
  8. package/dist/agents/performance-agent.d.ts +37 -0
  9. package/dist/agents/performance-agent.d.ts.map +1 -0
  10. package/dist/agents/performance-agent.js +91 -0
  11. package/dist/agents/performance-agent.js.map +1 -0
  12. package/dist/analyzer/index.d.ts +5 -0
  13. package/dist/analyzer/index.d.ts.map +1 -0
  14. package/dist/analyzer/index.js +5 -0
  15. package/dist/analyzer/index.js.map +1 -0
  16. package/dist/analyzer/intelligent-analyzer.d.ts +111 -0
  17. package/dist/analyzer/intelligent-analyzer.d.ts.map +1 -0
  18. package/dist/analyzer/intelligent-analyzer.js +537 -0
  19. package/dist/analyzer/intelligent-analyzer.js.map +1 -0
  20. package/dist/cli/commands/cleanup.d.ts +3 -0
  21. package/dist/cli/commands/cleanup.d.ts.map +1 -0
  22. package/dist/cli/commands/cleanup.js +24 -0
  23. package/dist/cli/commands/cleanup.js.map +1 -0
  24. package/dist/cli/commands/export.d.ts +9 -0
  25. package/dist/cli/commands/export.d.ts.map +1 -0
  26. package/dist/cli/commands/export.js +72 -0
  27. package/dist/cli/commands/export.js.map +1 -0
  28. package/dist/cli/commands/import.d.ts +9 -0
  29. package/dist/cli/commands/import.d.ts.map +1 -0
  30. package/dist/cli/commands/import.js +62 -0
  31. package/dist/cli/commands/import.js.map +1 -0
  32. package/dist/cli/commands/performance.d.ts +9 -0
  33. package/dist/cli/commands/performance.d.ts.map +1 -0
  34. package/dist/cli/commands/performance.js +36 -0
  35. package/dist/cli/commands/performance.js.map +1 -0
  36. package/dist/cli/commands/validate.d.ts +9 -0
  37. package/dist/cli/commands/validate.d.ts.map +1 -0
  38. package/dist/cli/commands/validate.js +82 -0
  39. package/dist/cli/commands/validate.js.map +1 -0
  40. package/dist/cli/commands/watch.d.ts +9 -0
  41. package/dist/cli/commands/watch.d.ts.map +1 -0
  42. package/dist/cli/commands/watch.js +72 -0
  43. package/dist/cli/commands/watch.js.map +1 -0
  44. package/dist/cli/generate.d.ts +3 -0
  45. package/dist/cli/generate.d.ts.map +1 -0
  46. package/dist/cli/generate.js +194 -0
  47. package/dist/cli/generate.js.map +1 -0
  48. package/dist/cli/index.d.ts +9 -0
  49. package/dist/cli/index.d.ts.map +1 -0
  50. package/dist/cli/index.js +448 -0
  51. package/dist/cli/index.js.map +1 -0
  52. package/dist/cli/sync.d.ts +26 -0
  53. package/dist/cli/sync.d.ts.map +1 -0
  54. package/dist/cli/sync.js +163 -0
  55. package/dist/cli/sync.js.map +1 -0
  56. package/dist/config/cleanup-config.d.ts +26 -0
  57. package/dist/config/cleanup-config.d.ts.map +1 -0
  58. package/dist/config/cleanup-config.js +21 -0
  59. package/dist/config/cleanup-config.js.map +1 -0
  60. package/dist/db/client.d.ts +284 -0
  61. package/dist/db/client.d.ts.map +1 -0
  62. package/dist/db/client.js +688 -0
  63. package/dist/db/client.js.map +1 -0
  64. package/dist/db/index.d.ts +6 -0
  65. package/dist/db/index.d.ts.map +1 -0
  66. package/dist/db/index.js +6 -0
  67. package/dist/db/index.js.map +1 -0
  68. package/dist/db/schema.d.ts +41 -0
  69. package/dist/db/schema.d.ts.map +1 -0
  70. package/dist/db/schema.js +226 -0
  71. package/dist/db/schema.js.map +1 -0
  72. package/dist/embeddings/index.d.ts +5 -0
  73. package/dist/embeddings/index.d.ts.map +1 -0
  74. package/dist/embeddings/index.js +5 -0
  75. package/dist/embeddings/index.js.map +1 -0
  76. package/dist/embeddings/openrouter.d.ts +133 -0
  77. package/dist/embeddings/openrouter.d.ts.map +1 -0
  78. package/dist/embeddings/openrouter.js +455 -0
  79. package/dist/embeddings/openrouter.js.map +1 -0
  80. package/dist/index.d.ts +14 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +18 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/mcp.d.ts +29 -0
  85. package/dist/mcp.d.ts.map +1 -0
  86. package/dist/mcp.js +257 -0
  87. package/dist/mcp.js.map +1 -0
  88. package/docs/ARCHIVE/MIGRATE_TO_NEW_REPO.md +222 -0
  89. package/docs/ARCHIVE/MIGRATE_TO_UNIFIED.md +220 -0
  90. package/docs/CLEANUP.md +76 -0
  91. package/docs/MCP_QUICKSTART.md +219 -0
  92. package/docs/QUICKSTART.md +119 -0
  93. package/docs/TROUBLESHOOTING.md +611 -0
  94. package/package.json +100 -0
  95. package/skills/context-optimize/SKILL.md +86 -0
  96. package/skills/implement/SKILL.md +150 -0
  97. package/skills/plan/SKILL.md +143 -0
  98. package/skills/research/SKILL.md +103 -0
  99. package/skills/validate/SKILL.md +62 -0
  100. package/skills/verify-docs/SKILL.md +77 -0
  101. package/src/agents/cleanup-agent.ts +96 -0
  102. package/src/agents/performance-agent.ts +117 -0
  103. package/src/analyzer/index.ts +10 -0
  104. package/src/analyzer/intelligent-analyzer.ts +640 -0
  105. package/src/cli/commands/cleanup.ts +26 -0
  106. package/src/cli/commands/export.ts +82 -0
  107. package/src/cli/commands/import.ts +73 -0
  108. package/src/cli/commands/performance.ts +40 -0
  109. package/src/cli/commands/validate.ts +98 -0
  110. package/src/cli/commands/watch.ts +83 -0
  111. package/src/cli/generate.ts +219 -0
  112. package/src/cli/index.ts +510 -0
  113. package/src/cli/sync.ts +194 -0
  114. package/src/config/cleanup-config.ts +42 -0
  115. package/src/db/client.ts +949 -0
  116. package/src/db/index.ts +19 -0
  117. package/src/db/schema.ts +241 -0
  118. package/src/embeddings/index.ts +11 -0
  119. package/src/embeddings/openrouter.ts +592 -0
  120. package/src/index.ts +57 -0
  121. package/src/mcp.ts +354 -0
  122. package/templates/AI_CONTEXT.md.template +245 -0
  123. package/templates/base/README.md +260 -0
  124. package/templates/base/RPI_WORKFLOW_PLAN.md +325 -0
  125. package/templates/base/agents/api-developer.md +76 -0
  126. package/templates/base/agents/context-engineer.md +525 -0
  127. package/templates/base/agents/core-architect.md +76 -0
  128. package/templates/base/agents/database-ops.md +76 -0
  129. package/templates/base/agents/deployment-ops.md +76 -0
  130. package/templates/base/agents/integration-hub.md +76 -0
  131. package/templates/base/analytics/README.md +114 -0
  132. package/templates/base/automation/config.json +58 -0
  133. package/templates/base/automation/generators/code-mapper.js +308 -0
  134. package/templates/base/automation/generators/index-builder.js +321 -0
  135. package/templates/base/automation/hooks/post-commit.sh +83 -0
  136. package/templates/base/automation/hooks/pre-commit.sh +103 -0
  137. package/templates/base/ci-templates/README.md +108 -0
  138. package/templates/base/ci-templates/github-actions/context-check.yml +144 -0
  139. package/templates/base/ci-templates/github-actions/validate-docs.yml +105 -0
  140. package/templates/base/commands/analytics.md +238 -0
  141. package/templates/base/commands/auto-sync.md +172 -0
  142. package/templates/base/commands/collab.md +194 -0
  143. package/templates/base/commands/context-optimize.md +226 -0
  144. package/templates/base/commands/help.md +485 -0
  145. package/templates/base/commands/rpi-implement.md +164 -0
  146. package/templates/base/commands/rpi-plan.md +147 -0
  147. package/templates/base/commands/rpi-research.md +145 -0
  148. package/templates/base/commands/session-resume.md +144 -0
  149. package/templates/base/commands/session-save.md +112 -0
  150. package/templates/base/commands/validate-all.md +77 -0
  151. package/templates/base/commands/verify-docs-current.md +86 -0
  152. package/templates/base/config/base.json +57 -0
  153. package/templates/base/config/environments/development.json +13 -0
  154. package/templates/base/config/environments/production.json +17 -0
  155. package/templates/base/config/environments/staging.json +13 -0
  156. package/templates/base/config/local.json.example +21 -0
  157. package/templates/base/context/.meta/generated-at.json +18 -0
  158. package/templates/base/context/ARCHITECTURE_SNAPSHOT.md +156 -0
  159. package/templates/base/context/CODE_TO_WORKFLOW_MAP.md +94 -0
  160. package/templates/base/context/FILE_OWNERSHIP.md +57 -0
  161. package/templates/base/context/INTEGRATION_POINTS.md +92 -0
  162. package/templates/base/context/KNOWN_GOTCHAS.md +195 -0
  163. package/templates/base/context/TESTING_MAP.md +95 -0
  164. package/templates/base/context/WORKFLOW_INDEX.md +129 -0
  165. package/templates/base/context/workflows/WORKFLOW_TEMPLATE.md +294 -0
  166. package/templates/base/indexes/agents/CAPABILITY_MATRIX.md +255 -0
  167. package/templates/base/indexes/agents/CATEGORY_INDEX.md +44 -0
  168. package/templates/base/indexes/code/CATEGORY_INDEX.md +38 -0
  169. package/templates/base/indexes/routing/CATEGORY_INDEX.md +39 -0
  170. package/templates/base/indexes/search/CATEGORY_INDEX.md +39 -0
  171. package/templates/base/indexes/workflows/CATEGORY_INDEX.md +38 -0
  172. package/templates/base/knowledge/README.md +98 -0
  173. package/templates/base/knowledge/sessions/README.md +88 -0
  174. package/templates/base/knowledge/sessions/TEMPLATE.md +150 -0
  175. package/templates/base/knowledge/shared/decisions/0001-adopt-context-engineering.md +144 -0
  176. package/templates/base/knowledge/shared/decisions/README.md +49 -0
  177. package/templates/base/knowledge/shared/decisions/TEMPLATE.md +123 -0
  178. package/templates/base/knowledge/shared/patterns/README.md +62 -0
  179. package/templates/base/knowledge/shared/patterns/TEMPLATE.md +120 -0
  180. package/templates/base/plans/PLAN_TEMPLATE.md +316 -0
  181. package/templates/base/plans/active/.gitkeep +0 -0
  182. package/templates/base/plans/completed/.gitkeep +0 -0
  183. package/templates/base/research/RESEARCH_TEMPLATE.md +245 -0
  184. package/templates/base/research/active/.gitkeep +0 -0
  185. package/templates/base/research/completed/.gitkeep +0 -0
  186. package/templates/base/schemas/agent.schema.json +141 -0
  187. package/templates/base/schemas/anchors.schema.json +54 -0
  188. package/templates/base/schemas/automation.schema.json +93 -0
  189. package/templates/base/schemas/command.schema.json +134 -0
  190. package/templates/base/schemas/hashes.schema.json +40 -0
  191. package/templates/base/schemas/manifest.schema.json +117 -0
  192. package/templates/base/schemas/plan.schema.json +136 -0
  193. package/templates/base/schemas/research.schema.json +115 -0
  194. package/templates/base/schemas/roles.schema.json +34 -0
  195. package/templates/base/schemas/session.schema.json +77 -0
  196. package/templates/base/schemas/settings.schema.json +244 -0
  197. package/templates/base/schemas/staleness.schema.json +53 -0
  198. package/templates/base/schemas/team-config.schema.json +42 -0
  199. package/templates/base/schemas/workflow.schema.json +126 -0
  200. package/templates/base/session/checkpoints/.gitkeep +2 -0
  201. package/templates/base/session/current/state.json +20 -0
  202. package/templates/base/session/history/.gitkeep +2 -0
  203. package/templates/base/settings.json +3 -0
  204. package/templates/base/standards/COMPATIBILITY.md +219 -0
  205. package/templates/base/standards/EXTENSION_GUIDELINES.md +280 -0
  206. package/templates/base/standards/QUALITY_CHECKLIST.md +211 -0
  207. package/templates/base/standards/README.md +66 -0
  208. package/templates/base/sync/anchors.json +6 -0
  209. package/templates/base/sync/hashes.json +6 -0
  210. package/templates/base/sync/staleness.json +10 -0
  211. package/templates/base/team/README.md +168 -0
  212. package/templates/base/team/config.json +79 -0
  213. package/templates/base/team/roles.json +145 -0
  214. package/templates/base/tools/bin/claude-context.js +151 -0
  215. package/templates/base/tools/lib/anchor-resolver.js +276 -0
  216. package/templates/base/tools/lib/config-loader.js +363 -0
  217. package/templates/base/tools/lib/detector.js +350 -0
  218. package/templates/base/tools/lib/diagnose.js +206 -0
  219. package/templates/base/tools/lib/drift-detector.js +373 -0
  220. package/templates/base/tools/lib/errors.js +199 -0
  221. package/templates/base/tools/lib/index.js +36 -0
  222. package/templates/base/tools/lib/init.js +192 -0
  223. package/templates/base/tools/lib/logger.js +230 -0
  224. package/templates/base/tools/lib/placeholder.js +201 -0
  225. package/templates/base/tools/lib/session-manager.js +354 -0
  226. package/templates/base/tools/lib/validate.js +521 -0
  227. package/templates/base/tools/package.json +49 -0
  228. package/templates/handlebars/aider-config.hbs +146 -0
  229. package/templates/handlebars/antigravity.hbs +377 -0
  230. package/templates/handlebars/claude.hbs +183 -0
  231. package/templates/handlebars/cline.hbs +62 -0
  232. package/templates/handlebars/continue-config.hbs +116 -0
  233. package/templates/handlebars/copilot.hbs +130 -0
  234. package/templates/handlebars/partials/gotcha-list.hbs +11 -0
  235. package/templates/handlebars/partials/header.hbs +3 -0
  236. package/templates/handlebars/partials/workflow-summary.hbs +16 -0
  237. package/templates/handlebars/windsurf-rules.hbs +69 -0
  238. package/templates/hooks/post-commit.hbs +28 -0
  239. package/templates/hooks/pre-commit.hbs +46 -0
@@ -0,0 +1,86 @@
1
+ ---
2
+ description: Context Optimization - Orchestrate RPI workflow TODO generation with interactive scoping
3
+ ---
4
+
5
+ # Context Engineering: Optimization Orchestrator
6
+
7
+ When invoked, orchestrate context engineering optimization with interactive scoping:
8
+
9
+ ## Process
10
+
11
+ 1. **Interactive Scoping (if no --auto flag)**
12
+ - Ask up to 4 multiple choice questions to define scope
13
+ - Questions cover: optimization focus, codebase areas, enhancement types, priority order
14
+ - Skip questions if --scope or --auto flag provided
15
+
16
+ 2. **Context System Audit**
17
+ - Analyze `.claude/` directory structure
18
+ - Check workflow file coverage and accuracy
19
+ - Verify index file completeness
20
+ - Identify orphaned or outdated files
21
+ - Assess agent and command coverage gaps
22
+
23
+ 3. **Generate RPI TODO List**
24
+ - Create actionable TODO with research, plan, implement phases
25
+ - Save to `.claude/plans/active/context-optimization_plan.md`
26
+ - Include specific commands for each task
27
+
28
+ 4. **Redundant File Detection**
29
+ - Find files not referenced by any index
30
+ - Identify duplicate or overlapping content
31
+ - Flag outdated files with stale line references
32
+ - Report empty placeholder files
33
+
34
+ 5. **Enhancement Recommendations**
35
+ - Suggest new specialized agents based on codebase patterns
36
+ - Recommend workflow commands for common tasks
37
+ - Identify undocumented workflows needing documentation
38
+
39
+ ## Scoping Questions (Max 4)
40
+
41
+ **Q1: Optimization Focus**
42
+ - A) Functionalize the entire context engineering system
43
+ - B) Update outdated documentation and line references
44
+ - C) Identify and remove redundant context files
45
+ - D) Discover enhancement opportunities (new agents/commands)
46
+
47
+ **Q2: Codebase Coverage**
48
+ - A) Core business logic
49
+ - B) API/External integrations
50
+ - C) Database/Data layer
51
+ - D) All areas equally
52
+
53
+ **Q3: Enhancement Preferences**
54
+ - A) New specialized agents for specific domains
55
+ - B) New workflow commands for common tasks
56
+ - C) Improved documentation structure
57
+ - D) Better cross-referencing and navigation
58
+
59
+ **Q4: TODO Priority Order**
60
+ - A) Quick wins first (< 30 min each)
61
+ - B) High impact first (regardless of effort)
62
+ - C) By workflow area (grouped logically)
63
+ - D) By dependency order (foundational first)
64
+
65
+ ## Context Budget
66
+ - Target: 20% of 200k tokens (40k)
67
+ - Output: TODO checklist + recommendations
68
+
69
+ ## Output
70
+ - TODO checklist saved to `.claude/plans/active/context-optimization_plan.md`
71
+ - Audit findings in `.claude/research/active/context-audit_research.md`
72
+
73
+ ## Arguments
74
+ - `$ARGUMENTS` can include:
75
+ - `--auto` - Use intelligent defaults, skip questions
76
+ - `--scope documentation` - Focus on docs only
77
+ - `--scope agents` - Focus on agent gaps
78
+ - `--scope workflows` - Focus on workflow coverage
79
+ - `--scope cleanup` - Focus on redundant file removal
80
+
81
+ ## Next Steps
82
+ After completion, execute the generated TODO list:
83
+ 1. `/rpi-research [first-research-task]`
84
+ 2. `/rpi-plan [first-plan-task]`
85
+ 3. `/rpi-implement [first-impl-task]`
86
+ 4. `/validate-all`
@@ -0,0 +1,150 @@
1
+ ---
2
+ description: RPI Implement Phase - Execute chunk-based todolists with atomic changes and continuous testing
3
+ ---
4
+
5
+ # Context Engineering: Implement Phase (Enhanced)
6
+
7
+ When invoked, execute the approved implementation plan chunk by chunk:
8
+
9
+ ## Key Innovation: Inter-Phase Awareness
10
+
11
+ This implement phase **KNOWS**:
12
+ - RPI-Plan structured chunks for atomic implementation
13
+ - Each CHUNK-Pn contains a complete, ordered todolist
14
+ - Chunk dependencies dictate execution order
15
+ - Marking chunks complete updates both plan AND research documents
16
+ - Context reset is needed after every 3 chunks or 35% utilization
17
+
18
+ ## Prerequisites
19
+ - Approved plan at `.claude/plans/active/[feature]_plan.md`
20
+ - Plan contains chunk manifest with chunk-todolists
21
+ - If not found, run `/context-eng:plan $ARGUMENTS` first
22
+
23
+ ## Golden Rules
24
+
25
+ ```
26
+ ONE CHUNK → COMPLETE TODOLIST → MARK DONE → NEXT CHUNK
27
+ ONE TODO → ONE CHANGE → ONE TEST → ONE COMMIT
28
+ ```
29
+
30
+ ## Chunk-Based Implementation Loop
31
+
32
+ ```
33
+ FOR each CHUNK-Pn in dependency_order:
34
+ IF dependencies_complete:
35
+ 1. Load CHUNK-Pn todolist
36
+
37
+ FOR each TODO in todolist:
38
+ a. Make atomic change
39
+ b. Run todo-specific test
40
+ c. If PASS: commit, mark TODO ✅
41
+ d. If FAIL: STOP, investigate, fix
42
+ END TODO LOOP
43
+
44
+ 2. Update chunk documentation
45
+ 3. Mark CHUNK-Pn as IMPLEMENTED
46
+ 4. Update research CHUNK-Rn to IMPLEMENTED
47
+
48
+ IF chunks_processed % 3 == 0 OR context > 35%:
49
+ Context reset (save progress, reload plan)
50
+ END IF
51
+
52
+ 5. Proceed to next ready chunk
53
+ END IF
54
+ END CHUNK LOOP
55
+ ```
56
+
57
+ ## Process
58
+
59
+ 1. **Load Plan Document**
60
+ - Read `.claude/plans/active/[feature]_plan.md`
61
+ - Extract chunk manifest and dependency graph
62
+ - Verify plan status is APPROVED
63
+
64
+ 2. **Determine Execution Order**
65
+ Based on chunk dependency graph:
66
+ - Independent chunks first (parallel capable)
67
+ - Dependent chunks in order
68
+ - Final chunks (e.g., test additions)
69
+
70
+ 3. **For Each Chunk (in dependency order):**
71
+
72
+ a. **Check dependencies complete**
73
+
74
+ b. **Execute each todo atomically:**
75
+ - Make single change
76
+ - Run specified test
77
+ - If pass: commit with message
78
+ - If fail: STOP, investigate, fix
79
+
80
+ c. **After all todos complete:**
81
+ - Mark CHUNK-Pn as IMPLEMENTED
82
+ - Update CHUNK-Rn in research to IMPLEMENTED
83
+ - Commit chunk documentation updates
84
+
85
+ d. **Context management:**
86
+ - After every 3 chunks: reload plan
87
+ - If >35% utilization: save, compact, continue
88
+
89
+ 4. **Run Full Test Suite**
90
+ After all chunks complete
91
+
92
+ 5. **Documentation Updates (MANDATORY)**
93
+ - Check `CODE_TO_WORKFLOW_MAP.md` for affected workflows
94
+ - Update workflow files with new line numbers
95
+ - Update function signatures if changed
96
+
97
+ 6. **Context Reset (Every 3 Chunks)**
98
+ - Update chunk progress in plan
99
+ - Re-read plan document
100
+ - Verify scope alignment
101
+ - Compact if >35% utilization
102
+
103
+ 7. **Finalize**
104
+ - Move plan to `.claude/plans/completed/`
105
+ - Move research to `.claude/research/completed/`
106
+ - Run `/context-eng:validate` to verify
107
+
108
+ ## Chunk Status Updates
109
+
110
+ ### Update Plan Document
111
+ ```markdown
112
+ | Chunk | Status | Todos Done | Commit | Research Updated |
113
+ |-------|--------|------------|--------|------------------|
114
+ | P1 | ✅ IMPLEMENTED | 4/4 | abc123 | ✅ R1 |
115
+ | P2 | ▶️ IMPLEMENTING | 2/5 | - | - |
116
+ ```
117
+
118
+ ### Update Research Document
119
+ Mark each CHUNK-Rn status:
120
+ - FOUND → COMPLETE → PLANNED → **IMPLEMENTED**
121
+
122
+ ## Error Handling
123
+
124
+ | Error Type | Response |
125
+ |------------|----------|
126
+ | Syntax Error | STOP. Fix immediately in same todo. |
127
+ | Import Error | Check file paths, verify imports. |
128
+ | Test Failure | Do NOT add more code. Investigate first. |
129
+ | 3+ Failures in chunk | Mark chunk BLOCKED, try next independent chunk. |
130
+ | 3+ Chunks blocked | STOP. Start new session. |
131
+
132
+ ## Commit Format
133
+
134
+ Per-todo:
135
+ ```
136
+ feat(chunk-Pn): Todo N - description
137
+ Implements: [feature] chunk N
138
+ ```
139
+
140
+ Per-chunk completion:
141
+ ```
142
+ feat(chunk-Pn): Complete chunk - [domain]
143
+ Completes: CHUNK-Pn, Updates: CHUNK-Rn
144
+ ```
145
+
146
+ ## Context Budget
147
+ - Plan: 15k tokens
148
+ - Active code (per chunk): ~10k tokens
149
+ - Test results (per chunk): ~5k tokens
150
+ - Max active (3 chunks): ~45k tokens (22.5%)
@@ -0,0 +1,143 @@
1
+ ---
2
+ description: RPI Plan Phase - Create chunk-based todolists from research chunks for rpi-implement consumption
3
+ ---
4
+
5
+ # Context Engineering: Plan Phase (Enhanced)
6
+
7
+ When invoked, create a detailed implementation plan with chunk-based todolists:
8
+
9
+ ## Key Innovation: Inter-Phase Awareness
10
+
11
+ This plan phase **KNOWS**:
12
+ - RPI-Research structured chunks specifically for sequential processing
13
+ - RPI-Implement will read each CHUNK-Pn as an atomic implementation unit
14
+ - Each CHUNK-Pn todolist must be independently executable
15
+ - Chunk dependencies must be explicit for proper execution ordering
16
+
17
+ ## Prerequisites
18
+ - Research document exists at `.claude/research/active/[feature]_research.md`
19
+ - Research document contains chunk manifest
20
+ - If not found, run `/context-eng:research $ARGUMENTS` first
21
+
22
+ ## Chunk Processing Loop
23
+
24
+ ```
25
+ FOR each CHUNK-Rn in research_chunks:
26
+ 1. Read CHUNK-Rn content
27
+ 2. Create CHUNK-Pn todolist:
28
+ - Define atomic action items
29
+ - Specify file:line for each action
30
+ - Assign test for each action
31
+ - Document chunk-specific rollback
32
+ 3. Mark CHUNK-Rn status as PLANNED
33
+ 4. Define CHUNK-Pn dependencies
34
+ 5. Proceed to next CHUNK-R(n+1)
35
+ END LOOP
36
+ ```
37
+
38
+ ## Process
39
+
40
+ 1. **Load Research Document**
41
+ - Read the research document for $ARGUMENTS
42
+ - Extract chunk manifest
43
+ - Extract per-chunk files and line numbers
44
+
45
+ 2. **For Each Research Chunk (CHUNK-Rn):**
46
+
47
+ a. **Analyze chunk content:**
48
+ - Files explored with line numbers
49
+ - Code flow analysis
50
+ - Dependencies identified
51
+
52
+ b. **Create CHUNK-Pn todolist:**
53
+ ```markdown
54
+ | # | Action | File | Lines | Risk | Test | Status |
55
+ |---|--------|------|-------|------|------|--------|
56
+ | 1 | [Action] | file.ext | XXX | LOW | test_x | ⏳ |
57
+ ```
58
+
59
+ c. **Define per-todo details:**
60
+ - Current code snippet
61
+ - Proposed change
62
+ - Test to run after
63
+
64
+ d. **Mark research chunk as PLANNED**
65
+
66
+ e. **Document chunk dependencies**
67
+
68
+ 3. **Create Chunk Dependency Graph**
69
+ ```
70
+ CHUNK-P1 → CHUNK-P2 → CHUNK-P3
71
+
72
+ CHUNK-P4 CHUNK-P5
73
+ ```
74
+
75
+ 4. **Generate Inter-Phase Contract**
76
+ ```
77
+ EXPECTED_CONSUMER: rpi-implement
78
+ CHUNK_PROCESSING_ORDER: dependency-ordered
79
+ MARK_AS_IMPLEMENTED_WHEN: all chunk todos complete
80
+ UPDATE_RESEARCH_STATUS: true
81
+ ```
82
+
83
+ 5. **Create Plan Document**
84
+ - Save to `.claude/plans/active/[feature]_plan.md`
85
+ - Include chunk manifest
86
+ - Include per-chunk todolists
87
+ - Include verification checklist
88
+
89
+ ## Plan Format (Chunk-Based)
90
+
91
+ ```markdown
92
+ # Implementation Plan: [Feature]
93
+
94
+ ## Chunk Manifest
95
+ | Chunk ID | From Research | Status | Todos | Dependencies | Ready |
96
+ |----------|---------------|--------|-------|--------------|-------|
97
+ | CHUNK-P1 | CHUNK-R1 | READY | 4 | None | ✅ |
98
+ | CHUNK-P2 | CHUNK-R2 | READY | 5 | CHUNK-P1 | ⏳ |
99
+
100
+ ## CHUNK-P1: [Domain] (from CHUNK-R1)
101
+
102
+ **Status:** READY
103
+ **Dependencies:** None
104
+ **Update Research When Complete:** Mark CHUNK-R1 as IMPLEMENTED
105
+
106
+ ### Todolist
107
+ | # | Action | File | Lines | Risk | Test | Status |
108
+ |---|--------|------|-------|------|------|--------|
109
+ | 1 | [Action] | file.ext | XXX | LOW | test_x | ⏳ |
110
+
111
+ ### Todo 1: [Action Name]
112
+ **File:** path/to/file.ext
113
+ **Lines:** X-Y
114
+ **Current:** [code block]
115
+ **Proposed:** [code block]
116
+ **Test:** [command]
117
+
118
+ ### Chunk Completion Criteria
119
+ - [ ] All todos complete
120
+ - [ ] Update CHUNK-R1 status
121
+ - [ ] Proceed to dependent chunks
122
+
123
+ ## Inter-Phase Contract
124
+ [contract for rpi-implement]
125
+
126
+ ## Rollback (Per Chunk)
127
+ - CHUNK-P1: git revert [hash]
128
+ ```
129
+
130
+ ## Context Budget
131
+ - Research doc: 20k tokens
132
+ - Plan creation: 15k tokens
133
+ - Total: 35k tokens (17.5%)
134
+
135
+ ## Next Step
136
+ After approval, run `/context-eng:implement $ARGUMENTS`
137
+
138
+ RPI-Implement will:
139
+ 1. Load chunk manifest
140
+ 2. Process chunks in dependency order
141
+ 3. Execute todos atomically per chunk
142
+ 4. Mark chunks as IMPLEMENTED
143
+ 5. Update research document status
@@ -0,0 +1,103 @@
1
+ ---
2
+ description: RPI Research Phase - Systematic codebase exploration with parallel agents and chunked output
3
+ ---
4
+
5
+ # Context Engineering: Research Phase (Enhanced)
6
+
7
+ When invoked, perform systematic codebase exploration using parallel agents:
8
+
9
+ ## Key Innovation: Inter-Phase Awareness
10
+
11
+ This research phase **KNOWS** how RPI-Plan will consume its output:
12
+ - Output structured into research chunks (CHUNK-R1, CHUNK-R2, etc.)
13
+ - Each chunk is self-contained with files, dependencies, and status
14
+ - RPI-Plan will create a CHUNK-Pn todolist per CHUNK-Rn
15
+ - Chunk manifest enables sequential processing by RPI-Plan
16
+
17
+ ## Process
18
+
19
+ 1. **Initialize Research Document**
20
+ - Create `.claude/research/active/[feature]_research.md`
21
+ - Use template from `.claude/research/RESEARCH_TEMPLATE.md`
22
+
23
+ 2. **Spawn Parallel Agents (3-5 agents)**
24
+
25
+ ```
26
+ Agent 1: API/Route Entry Points → CHUNK-R1
27
+ Agent 2: Business Logic & Models → CHUNK-R2
28
+ Agent 3: Database/Storage Layer → CHUNK-R3
29
+ Agent 4: External Integrations → CHUNK-R4
30
+ Agent 5: Test Coverage Analysis → CHUNK-R5
31
+ ```
32
+
33
+ Each agent receives:
34
+ - Feature name and objective
35
+ - Assigned domain
36
+ - Required output format (chunk structure)
37
+ - Line number requirement for all file references
38
+
39
+ 3. **Per-Agent Chunk Output**
40
+ Each agent produces a self-contained chunk:
41
+ ```markdown
42
+ ## CHUNK-Rn: [Domain]
43
+ **Status:** COMPLETE
44
+ **Parallel Agent:** Agent N
45
+ **Ready for Planning:** Yes
46
+
47
+ ### Files Explored
48
+ | File | Lines | Key Findings |
49
+
50
+ ### Code Flow Analysis
51
+ [call chain with file:line refs]
52
+
53
+ ### Dependencies (This Chunk)
54
+ - External: [APIs]
55
+ - Internal: [services]
56
+ ```
57
+
58
+ 4. **Aggregate Chunk Results**
59
+ - Create chunk manifest table
60
+ - Combine all agent outputs
61
+ - Verify all chunks are COMPLETE
62
+
63
+ 5. **Generate Inter-Phase Contract**
64
+ ```
65
+ EXPECTED_CONSUMER: rpi-plan
66
+ CHUNK_PROCESSING_ORDER: sequential (R1 → R2 → R3 → R4 → R5)
67
+ MARK_AS_PLANNED_WHEN: chunk todolist created
68
+ REQUIRED_OUTPUT: CHUNK-Pn per CHUNK-Rn
69
+ ```
70
+
71
+ 6. **Generate Summary**
72
+ - 150-word summary for Plan phase
73
+ - Reference key files from each chunk
74
+ - Recommend approach
75
+
76
+ ## Chunk Manifest Format (Required)
77
+
78
+ ```markdown
79
+ | Chunk ID | Domain | Status | Files | Ready for Planning |
80
+ |----------|--------|--------|-------|-------------------|
81
+ | CHUNK-R1 | API/Routes | COMPLETE | 3 | ✅ |
82
+ | CHUNK-R2 | Business Logic | COMPLETE | 4 | ✅ |
83
+ | CHUNK-R3 | Database | COMPLETE | 2 | ✅ |
84
+ | CHUNK-R4 | External | COMPLETE | 1 | ✅ |
85
+ | CHUNK-R5 | Tests | COMPLETE | 3 | ✅ |
86
+ ```
87
+
88
+ ## Context Budget
89
+ - Target: 25% of 200k tokens (50k)
90
+ - Per-agent budget: ~10k tokens each
91
+ - Compaction: After each agent returns
92
+ - Final output: ~20k tokens (research doc only)
93
+
94
+ ## Output
95
+ Research document saved to `.claude/research/active/` with:
96
+ - Chunk manifest
97
+ - Per-chunk details
98
+ - Inter-phase contract for RPI-Plan
99
+
100
+ ## Next Step
101
+ After completion, run `/context-eng:plan $ARGUMENTS`
102
+
103
+ RPI-Plan will read chunk manifest and create CHUNK-Pn todolist per CHUNK-Rn
@@ -0,0 +1,62 @@
1
+ ---
2
+ description: Run complete validation suite on context engineering documentation
3
+ ---
4
+
5
+ # Context Engineering: Validation
6
+
7
+ Run comprehensive validation on the context engineering setup.
8
+
9
+ ## Validation Checks
10
+
11
+ ### 1. Structure Validation
12
+ - All required directories exist in `.claude/`
13
+ - Required files are present
14
+ - Settings file is valid JSON
15
+
16
+ ### 2. Schema Validation
17
+ - JSON files validate against their schemas
18
+ - Frontmatter in markdown files is valid
19
+
20
+ ### 3. Link Validation
21
+ - All internal markdown links resolve
22
+ - No broken references to files or anchors
23
+
24
+ ### 4. Placeholder Detection
25
+ - Find remaining `{{PLACEHOLDER}}` values
26
+ - Report files that need manual completion
27
+
28
+ ### 5. Line Number Accuracy
29
+ - Sample referenced line numbers in documentation
30
+ - Verify they match actual code
31
+ - Target: ≥60% accuracy
32
+
33
+ ## Output
34
+
35
+ ```
36
+ Validation Results
37
+ ==================
38
+ ✓ Structure: PASS (12/12 directories)
39
+ ✓ Schemas: PASS (5/5 files valid)
40
+ ✓ Links: PASS (45/45 links resolve)
41
+ ⚠ Placeholders: WARN (3 remaining in 2 files)
42
+ ✓ Line Accuracy: PASS (78% accurate)
43
+
44
+ Overall: PASS with warnings
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ Run validation:
50
+ - Full suite: `/context-eng:validate`
51
+ - Specific check: `/context-eng:validate --links`
52
+ - With fix: `/context-eng:validate --fix`
53
+
54
+ ## Thresholds
55
+
56
+ | Check | Pass | Warn | Fail |
57
+ |-------|------|------|------|
58
+ | Structure | 100% | - | <100% |
59
+ | Schemas | 100% | - | <100% |
60
+ | Links | 100% | <100% | <90% |
61
+ | Placeholders | 0 | 1-5 | >5 |
62
+ | Line Accuracy | ≥60% | 50-60% | <50% |
@@ -0,0 +1,77 @@
1
+ ---
2
+ description: Verify documentation line numbers match current code state
3
+ ---
4
+
5
+ # Context Engineering: Verify Documentation
6
+
7
+ Check if documentation line numbers still match the actual code.
8
+
9
+ ## Purpose
10
+
11
+ After code changes, line numbers in documentation may drift. This skill:
12
+ 1. Finds all `file:line` references in `.claude/` documentation
13
+ 2. Verifies the referenced lines exist and match described content
14
+ 3. Reports accuracy and suggests fixes
15
+
16
+ ## Process
17
+
18
+ 1. **Scan Documentation**
19
+ - Find all patterns like `file.py:123` or `[file.py:123]`
20
+ - Extract file path and line number
21
+
22
+ 2. **Verify References**
23
+ - Check if file exists
24
+ - Check if line number is within file bounds
25
+ - Sample content to verify it matches description
26
+
27
+ 3. **Calculate Accuracy**
28
+ - Total references found
29
+ - Valid references
30
+ - Accuracy percentage
31
+
32
+ 4. **Generate Report**
33
+ ```
34
+ Documentation Accuracy Report
35
+ =============================
36
+ Total References: 156
37
+ Valid: 142
38
+ Invalid: 14
39
+ Accuracy: 91%
40
+
41
+ Invalid References:
42
+ - context/workflows/auth.md:45 → src/auth.py:230 (line moved to 245)
43
+ - context/workflows/api.md:12 → src/api.py:100 (file renamed)
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ Check specific file:
49
+ ```
50
+ /context-eng:verify-docs path/to/changed/file.py
51
+ ```
52
+
53
+ Check all documentation:
54
+ ```
55
+ /context-eng:verify-docs
56
+ ```
57
+
58
+ Auto-fix (update line numbers):
59
+ ```
60
+ /context-eng:verify-docs --fix
61
+ ```
62
+
63
+ ## Target Accuracy
64
+
65
+ | Level | Accuracy | Action |
66
+ |-------|----------|--------|
67
+ | Excellent | ≥80% | No action needed |
68
+ | Good | 60-80% | Update when convenient |
69
+ | Warning | 40-60% | Update soon |
70
+ | Critical | <40% | Update immediately |
71
+
72
+ ## When to Run
73
+
74
+ - After refactoring
75
+ - After adding/removing significant code
76
+ - Before creating a PR
77
+ - Weekly maintenance