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,194 @@
1
+ ---
2
+ name: collab
3
+ version: "1.0.0"
4
+ displayName: "Team Collaboration"
5
+ description: "Team collaboration tools for handoffs, knowledge sync, and status"
6
+ category: "team"
7
+ complexity: "low"
8
+ context_budget: "~10K tokens"
9
+ typical_context_usage: "5%"
10
+ prerequisites:
11
+ - ".ai-context/team/config.json exists"
12
+ - "Team configuration completed"
13
+ outputs:
14
+ - "Session handoff document (handoff)"
15
+ - "Sync status report (sync)"
16
+ - "Team status overview (status)"
17
+ related_agents: []
18
+ examples:
19
+ - command: "/collab handoff"
20
+ description: "Create session handoff for next team member"
21
+ - command: "/collab sync"
22
+ description: "Synchronize shared knowledge base"
23
+ - command: "/collab status"
24
+ description: "View team configuration and status"
25
+ ---
26
+
27
+ # /collab - Team Collaboration Command
28
+
29
+ Manage team collaboration features including session handoffs, knowledge synchronization, and team status.
30
+
31
+ ## Subcommands
32
+
33
+ ### `/collab handoff`
34
+
35
+ Create a session handoff document for the next team member.
36
+
37
+ **Workflow:**
38
+ 1. Collect session information:
39
+ - Files modified in session
40
+ - Git status and recent commits
41
+ - Open tasks and blockers
42
+ 2. Prompt for additional context:
43
+ - Work in progress description
44
+ - Blockers encountered
45
+ - Recommended next steps
46
+ 3. Generate handoff document from template
47
+ 4. Save to `.ai-context/knowledge/sessions/`
48
+ 5. Display handoff summary
49
+
50
+ **Output:** `.ai-context/knowledge/sessions/YYYY-MM-DD-HH-MM-{member-id}.md`
51
+
52
+ ### `/collab sync`
53
+
54
+ Synchronize and validate the shared knowledge base.
55
+
56
+ **Workflow:**
57
+ 1. Scan knowledge directories:
58
+ - `shared/decisions/` - ADRs
59
+ - `shared/patterns/` - Patterns
60
+ - `sessions/` - Recent handoffs
61
+ 2. Validate document structure
62
+ 3. Check for stale content (>30 days unchanged)
63
+ 4. Report sync status:
64
+ - Documents found
65
+ - Validation issues
66
+ - Stale content warnings
67
+ 5. Optionally notify team of updates
68
+
69
+ **Output:** Sync status report to console
70
+
71
+ ### `/collab status`
72
+
73
+ Display team configuration and current status.
74
+
75
+ **Workflow:**
76
+ 1. Load team configuration from `.ai-context/team/config.json`
77
+ 2. Display:
78
+ - Team name and organization
79
+ - Active members and roles
80
+ - Current policies
81
+ - Integration status
82
+ 3. Check for configuration issues
83
+ 4. Show recent activity summary
84
+
85
+ **Output:** Team status report to console
86
+
87
+ ## Usage Examples
88
+
89
+ ### End of Session Handoff
90
+
91
+ ```
92
+ User: /collab handoff
93
+
94
+ Claude: Creating session handoff...
95
+
96
+ ## Session Summary
97
+ Please describe what you worked on this session:
98
+
99
+ User: Implemented user authentication flow, added login/logout endpoints
100
+
101
+ Claude: ## Work In Progress
102
+ Any incomplete work to note?
103
+
104
+ User: JWT refresh token logic needs testing
105
+
106
+ Claude: ## Blockers
107
+ Any blockers for the next person?
108
+
109
+ User: None
110
+
111
+ Claude: ## Next Steps
112
+ Recommended priorities for next session?
113
+
114
+ User: 1. Test refresh tokens 2. Add password reset
115
+
116
+ Claude: Session handoff created: .ai-context/knowledge/sessions/2024-01-15-16-30-dev-1.md
117
+
118
+ ### Handoff Summary
119
+ - Session: 2024-01-15 16:30
120
+ - Files Modified: 8
121
+ - Commits: 3
122
+ - Status: Ready for handoff
123
+
124
+ The next team member can review this handoff to continue your work.
125
+ ```
126
+
127
+ ### Sync Knowledge Base
128
+
129
+ ```
130
+ User: /collab sync
131
+
132
+ Claude: Synchronizing knowledge base...
133
+
134
+ ### Scan Results
135
+ - ADRs: 3 documents
136
+ - Patterns: 5 documents
137
+ - Sessions: 12 handoffs
138
+
139
+ ### Validation
140
+ ✓ All ADRs have required sections
141
+ ✓ All patterns follow template
142
+ ⚠ 2 session handoffs > 30 days old
143
+
144
+ ### Recommendations
145
+ - Archive or delete old handoffs:
146
+ - sessions/2023-12-01-14-00-dev-2.md
147
+ - sessions/2023-12-05-09-15-dev-1.md
148
+
149
+ Knowledge base sync complete.
150
+ ```
151
+
152
+ ### Check Team Status
153
+
154
+ ```
155
+ User: /collab status
156
+
157
+ Claude: ## Team Status
158
+
159
+ ### Configuration
160
+ - Team: Engineering Team
161
+ - Organization: Acme Corp
162
+ - Version: 1.0.0
163
+
164
+ ### Members (3 active)
165
+ | Name | Role | Status |
166
+ |------|------|--------|
167
+ | Alice | team-lead | active |
168
+ | Bob | developer | active |
169
+ | Carol | developer | active |
170
+
171
+ ### Policies
172
+ - Code review required: Yes
173
+ - Documentation updates required: Yes
174
+ - Test coverage minimum: 80%
175
+
176
+ ### Integrations
177
+ - Slack: Configured ✓
178
+ - Jira: Not configured
179
+ - Confluence: Not configured
180
+
181
+ ### Recent Activity
182
+ - Last handoff: 2024-01-15 by Bob
183
+ - Knowledge updates: 2 this week
184
+ ```
185
+
186
+ ## Configuration
187
+
188
+ Requires `.ai-context/team/config.json` to be configured. See `.ai-context/team/README.md` for setup instructions.
189
+
190
+ ## Related
191
+
192
+ - [Team Configuration](./../team/README.md)
193
+ - [Knowledge Base](./../knowledge/README.md)
194
+ - [Session Handoff Template](./../knowledge/sessions/TEMPLATE.md)
@@ -0,0 +1,226 @@
1
+ ---
2
+ name: context-optimize
3
+ version: "1.0.0"
4
+ description: "Orchestrate context engineering optimization with interactive scoping and RPI workflow TODO generation"
5
+ category: "orchestration"
6
+ context_budget_estimate: "40K tokens"
7
+ typical_context_usage: "20%"
8
+ prerequisites: []
9
+ outputs:
10
+ - "Optimization TODO checklist in .ai-context/plans/active/context-optimization_plan.md"
11
+ - "Context enhancement recommendations"
12
+ - "Redundant file identification report"
13
+ - "Agent/command creation suggestions based on user scope"
14
+ next_commands: ["/rpi-research", "/rpi-plan", "/rpi-implement"]
15
+ related_agents: ["context-engineer"]
16
+ examples:
17
+ - command: "/context-optimize"
18
+ description: "Start interactive context optimization workflow"
19
+ - command: "/context-optimize --auto"
20
+ description: "Run optimization with automatic scoping"
21
+ - command: "/context-optimize --scope documentation"
22
+ description: "Focus optimization on documentation only"
23
+ exit_criteria:
24
+ - "User scope defined through up to 4 questions"
25
+ - "TODO checklist generated with RPI phases"
26
+ - "Redundant files identified"
27
+ - "Enhancement opportunities documented"
28
+ - "Action plan ready for execution"
29
+ ---
30
+
31
+ # Context Optimization Command
32
+
33
+ **Purpose:** Orchestrate the context engineer agent to create a comprehensive TODO list for running RPI workflow, functionalize the context engineering system, and identify enhancement opportunities.
34
+
35
+ **Syntax:** `/context-optimize [--auto|--scope <area>]`
36
+
37
+ ---
38
+
39
+ ## What This Command Does
40
+
41
+ 1. **Interactive Scoping** - Asks up to 4 multiple choice questions to understand your optimization goals
42
+ 2. **Context Audit** - Analyzes the current context engineering setup for the codebase
43
+ 3. **RPI TODO Generation** - Creates actionable TODO list with research, plan, implement phases
44
+ 4. **Redundancy Detection** - Identifies redundant or outdated files in the context system
45
+ 5. **Enhancement Suggestions** - Recommends specific agents or commands to add based on codebase needs
46
+
47
+ ---
48
+
49
+ ## Execution Flow
50
+
51
+ ### Step 1: Interactive Scoping (Optional with --auto)
52
+
53
+ Ask up to 4 multiple choice questions to define optimization scope:
54
+
55
+ **Question 1: Optimization Focus**
56
+ ```
57
+ What is your primary optimization goal?
58
+ A) Functionalize the entire context engineering system
59
+ B) Update outdated documentation and line references
60
+ C) Identify and remove redundant context files
61
+ D) Discover enhancement opportunities (new agents/commands)
62
+ ```
63
+
64
+ **Question 2: Codebase Coverage**
65
+ ```
66
+ Which areas of the codebase should be prioritized?
67
+ A) Core business logic
68
+ B) API/External integrations
69
+ C) Database/Data layer
70
+ D) All areas equally
71
+ ```
72
+
73
+ **Question 3: Enhancement Preferences**
74
+ ```
75
+ What types of enhancements would be most valuable?
76
+ A) New specialized agents for specific domains
77
+ B) New workflow commands for common tasks
78
+ C) Improved documentation structure
79
+ D) Better cross-referencing and navigation
80
+ ```
81
+
82
+ **Question 4: TODO Priority Order**
83
+ ```
84
+ How should the TODO list be structured?
85
+ A) Quick wins first (< 30 min each)
86
+ B) High impact first (regardless of effort)
87
+ C) By workflow area (grouped logically)
88
+ D) By dependency order (foundational first)
89
+ ```
90
+
91
+ ---
92
+
93
+ ### Step 2: Context System Audit
94
+
95
+ **Actions:**
96
+ 1. Analyze `.ai-context/` directory structure
97
+ 2. Check workflow file coverage and accuracy
98
+ 3. Verify index file completeness
99
+ 4. Identify orphaned or outdated files
100
+ 5. Assess agent and command coverage gaps
101
+
102
+ **Audit Checklist:**
103
+ ```
104
+ [ ] AI_CONTEXT.md is current and accurate
105
+ [ ] All workflow files have valid line references
106
+ [ ] CODE_TO_WORKFLOW_MAP.md matches codebase structure
107
+ [ ] All agents are properly documented
108
+ [ ] All commands are functional
109
+ [ ] Index files are complete and navigable
110
+ [ ] Research/Plans directories are organized
111
+ ```
112
+
113
+ ---
114
+
115
+ ### Step 3: Generate RPI TODO List
116
+
117
+ Based on scoping and audit, generate actionable TODO with RPI phases:
118
+
119
+ **Output Format:**
120
+ ```markdown
121
+ # Context Optimization TODO
122
+
123
+ **Generated:** [timestamp]
124
+ **Scope:** [user-selected scope]
125
+ **Priority:** [user-selected priority]
126
+
127
+ ## Phase 1: RESEARCH Tasks
128
+
129
+ - [ ] /rpi-research context-system-audit
130
+ - Discover all existing context files and their relationships
131
+ - Map current workflow coverage
132
+ - Identify gaps in documentation
133
+
134
+ - [ ] /rpi-research [area-specific-task]
135
+ - [Description based on scoping]
136
+
137
+ ## Phase 2: PLAN Tasks
138
+
139
+ - [ ] /rpi-plan context-restructure
140
+ - Define file reorganization strategy
141
+ - Plan redundant file cleanup
142
+ - Design enhanced navigation structure
143
+
144
+ - [ ] /rpi-plan [enhancement-specific-task]
145
+ - [Description based on scoping]
146
+
147
+ ## Phase 3: IMPLEMENT Tasks
148
+
149
+ - [ ] /rpi-implement context-updates
150
+ - Execute planned changes atomically
151
+ - Update all affected index files
152
+ - Validate with /verify-docs-current
153
+
154
+ - [ ] /rpi-implement [new-agent-or-command]
155
+ - [Description based on scoping]
156
+
157
+ ## Post-Implementation
158
+
159
+ - [ ] Run /validate-all
160
+ - [ ] Archive completed plans
161
+ - [ ] Update CHANGELOG.md
162
+ ```
163
+
164
+ ---
165
+
166
+ ### Step 4: Redundant File Detection
167
+
168
+ **Detection Rules:**
169
+ 1. Files not referenced by any index
170
+ 2. Duplicate or overlapping content (>70% similarity)
171
+ 3. Outdated files with stale line references (>20% drift)
172
+ 4. Empty placeholder files without content
173
+ 5. Orphaned research/plan files older than 30 days
174
+
175
+ **Output:**
176
+ ```
177
+ REDUNDANT FILES DETECTED:
178
+
179
+ ⚠️ High Priority (should remove):
180
+ - .ai-context/context/workflows/old_feature.md - Not in any index
181
+ - .ai-context/research/completed/stale_research.md - 90 days old
182
+
183
+ 📋 Medium Priority (review needed):
184
+ - .ai-context/context/DUPLICATE_FILE.md - 85% similar to other.md
185
+
186
+ ℹ️ Low Priority (consider archiving):
187
+ - .ai-context/plans/completed/ancient_plan.md - 60 days old
188
+ ```
189
+
190
+ ---
191
+
192
+ ### Step 5: Enhancement Recommendations
193
+
194
+ **Analysis Categories:**
195
+
196
+ 1. **Agent Gaps**
197
+ - Identify domains without specialized agents
198
+ - Suggest new agents based on codebase patterns
199
+ ```
200
+ RECOMMENDED AGENTS:
201
+ - payment-specialist (Payments, Billing)
202
+ - data-pipeline-ops (ETL, analytics)
203
+ ```
204
+
205
+ 2. **Command Gaps**
206
+ - Identify missing commands for frequent tasks
207
+ - Suggest new commands based on patterns
208
+ ```
209
+ RECOMMENDED COMMANDS:
210
+ - /db-migrate (Database migration helper)
211
+ - /api-docs (Generate API documentation)
212
+ ```
213
+
214
+ 3. **Documentation Gaps**
215
+ - Identify undocumented workflows
216
+ - Recommend new workflow documentation
217
+
218
+ ---
219
+
220
+ ## Next Steps
221
+
222
+ After completion, execute the generated TODO list:
223
+ 1. `/rpi-research [first-research-task]`
224
+ 2. `/rpi-plan [first-plan-task]`
225
+ 3. `/rpi-implement [first-impl-task]`
226
+ 4. `/validate-all`