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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SireJeff
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,623 @@
1
+ # K0ntext
2
+
3
+ [![npm version](https://img.shields.io/npm/v/k0ntext.svg)](https://www.npmjs.com/package/k0ntext)
4
+ [![npm downloads](https://img.shields.io/npm/dt/k0ntext.svg)](https://www.npmjs.com/package/k0ntext)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Build Status](https://github.com/SireJeff/k0ntext/workflows/CI/badge.svg)](https://github.com/SireJeff/k0ntext/actions)
7
+ [![Node Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org)
8
+ [![MCP Protocol](https://img.shields.io/badge/MCP-Protocol-blue)](https://modelcontextprotocol.io)
9
+
10
+ Universal AI context engineering for Claude, GitHub Copilot, Cline, Cursor, Windsurf, Aider, Continue, Antigravity, and Gemini with OpenRouter-powered intelligent analysis.
11
+
12
+ ## 🚀 Quick Start (30 Seconds)
13
+
14
+ ```bash
15
+ # Install globally
16
+ npm install -g k0ntext
17
+
18
+ # Initialize your project with intelligent analysis
19
+ k0ntext init
20
+
21
+ # Generate context files for all AI tools
22
+ k0ntext generate
23
+
24
+ # Start the MCP server for AI tools
25
+ k0ntext mcp
26
+ ```
27
+
28
+ ## 🎯 Zero-to-Hero Workflow
29
+
30
+ ### New Project Setup
31
+ ```bash
32
+ # 1. Initialize with intelligent analysis
33
+ k0ntext init --intelligent
34
+
35
+ # 2. Index your codebase
36
+ k0ntext index
37
+
38
+ # 3. Generate context files
39
+ k0ntext generate
40
+
41
+ # 4. Start MCP server
42
+ k0ntext mcp
43
+ ```
44
+
45
+ ### Existing Project Setup
46
+ ```bash
47
+ # 1. Check existing context
48
+ k0ntext stats
49
+
50
+ # 2. Index codebase if needed
51
+ k0ntext index --docs --code
52
+
53
+ # 3. Generate missing tool configs
54
+ k0ntext generate --force
55
+
56
+ # 4. Validate everything
57
+ k0ntext validate --strict
58
+ ```
59
+
60
+ ## 🖥️ Windows Support
61
+
62
+ K0ntext uses native SQLite extensions for high-performance vector search.
63
+
64
+ **For Windows Users:**
65
+ - **Recommended:** Use Node.js LTS (v18, v20, v22) with pre-built binaries
66
+ - **Instant install:** These versions install without extra tools
67
+ - **Non-LTS versions (v23/v24):** May require [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/) to compile the database driver
68
+
69
+ ## ✨ Features Overview
70
+
71
+ ### 🧠 Intelligent Analysis
72
+ - OpenRouter-powered codebase analysis with embeddings
73
+ - Tech stack detection and documentation
74
+ - Workflow discovery and categorization
75
+ - Automatic context generation
76
+
77
+ ### 🔍 Semantic Search
78
+ - Vector database (sqlite-vec) for intelligent code retrieval
79
+ - Hybrid search (text + semantic)
80
+ - Content type filtering (workflow, agent, command, code, doc, etc.)
81
+ - Real-time indexing with watch mode
82
+
83
+ ### 🔄 Cross-Tool Sync
84
+ - **9 AI Tools Supported:** Claude, Copilot, Cline, Antigravity, Windsurf, Aider, Continue, Cursor, Gemini
85
+ - Automatic synchronization between tool configurations
86
+ - Change detection with SHA256 hashing
87
+ - Sync status monitoring
88
+
89
+ ### 🤖 MCP Server
90
+ - **10 Tools:** search_context, get_item, add_knowledge, analyze, get_tool_configs, query_graph, get_stats
91
+ - **6 Prompts:** context-engineer, core-architect, api-developer, database-ops, integration-hub, deployment-ops
92
+ - Real-time context access for AI assistants
93
+ - Knowledge graph traversal
94
+
95
+ ### 🛠️ Complete CLI (13 Commands)
96
+ - `init` - Initialize with intelligent analysis
97
+ - `generate` - Generate context files for all tools
98
+ - `mcp` - Start MCP server
99
+ - `sync` - Sync across AI tools
100
+ - `cleanup` - Clean up conflicting tool folders
101
+ - `validate` - Validate context files
102
+ - `export` - Export database
103
+ - `import` - Import from exports
104
+ - `performance` - Show performance metrics
105
+ - `watch` - Auto-index file changes
106
+ - `index` - Index codebase
107
+ - `search` - Search indexed content
108
+ - `stats` - View database statistics
109
+
110
+ ### 📊 Smart Agents
111
+ - **CleanupAgent** - Remove conflicting AI tool folders (.cursor, .windsurf, .cline, etc.)
112
+ - **PerformanceMonitorAgent** - Track database performance and suggest optimizations
113
+
114
+ ### 🗃️ SQLite Storage
115
+ - Persistent database with SHA256 change detection
116
+ - Embeddings support for semantic search
117
+ - Knowledge graph relationships
118
+ - Automatic schema migrations
119
+
120
+ ## 📖 Complete CLI Reference
121
+
122
+ ### Core Commands
123
+
124
+ #### `k0ntext init [project-name]`
125
+ Initialize AI context for a project with intelligent analysis.
126
+
127
+ ```bash
128
+ # Initialize current directory
129
+ k0ntext init
130
+
131
+ # Initialize specific project
132
+ k0ntext init my-project
133
+
134
+ # Skip intelligent analysis (faster)
135
+ k0ntext init --no-intelligent
136
+ ```
137
+
138
+ **Options:**
139
+ - `--no-intelligent` - Skip OpenRouter-powered analysis
140
+ - `-v, --verbose` - Show detailed output
141
+
142
+ #### `k0ntext generate`
143
+ Generate context files for all AI tools.
144
+
145
+ ```bash
146
+ # Generate for all tools
147
+ k0ntext generate
148
+
149
+ # Generate for specific tools
150
+ k0ntext generate -ai claude,copilot,cursor
151
+
152
+ # Force regenerate all files
153
+ k0ntext generate --force
154
+
155
+ # Verbose output
156
+ k0ntext generate -v
157
+ ```
158
+
159
+ **Options:**
160
+ - `-ai, --ai <tools>` - Specific tools (comma-separated)
161
+ - `--force` - Force regenerate all files
162
+ - `-v, --verbose` - Show detailed output
163
+
164
+ #### `k0ntext mcp`
165
+ Start the Model Context Protocol server.
166
+
167
+ ```bash
168
+ # Start with default database
169
+ k0ntext mcp
170
+
171
+ # Specify database path
172
+ k0ntext mcp --db .my-context.db
173
+ ```
174
+
175
+ **Options:**
176
+ - `--db <path>` - Database file path
177
+
178
+ #### `k0ntext sync`
179
+ Synchronize context across AI tools.
180
+
181
+ ```bash
182
+ # Sync all tools
183
+ k0ntext sync
184
+
185
+ # Check sync status only
186
+ k0ntext sync --check
187
+
188
+ # Sync from specific tool
189
+ k0ntext sync --from claude
190
+
191
+ # Sync to specific tool
192
+ k0ntext sync --to copilot
193
+
194
+ # Force sync
195
+ k0ntext sync --force
196
+ ```
197
+
198
+ **Options:**
199
+ - `--check` - Only check synchronization status
200
+ - `--from <tool>` - Sync from specific tool
201
+ - `--to <tool>` - Sync to specific tool
202
+ - `--force` - Force sync even if up-to-date
203
+
204
+ #### `k0ntext cleanup`
205
+ Clean up context folders from other AI tools.
206
+
207
+ ```bash
208
+ # Dry run to see what would be removed
209
+ k0ntext cleanup --dry-run
210
+
211
+ # Keep specific folders
212
+ k0ntext cleanup --keep .github,.vscode
213
+
214
+ # Verbose output
215
+ k0ntext cleanup -v
216
+ ```
217
+
218
+ **Options:**
219
+ - `--dry-run` - Show what would be removed
220
+ - `--keep <folders>` - Folders to keep (comma-separated)
221
+ - `-v, --verbose` - Show detailed output
222
+
223
+ #### `k0ntext validate`
224
+ Validate context files and AI tool configurations.
225
+
226
+ ```bash
227
+ # Basic validation
228
+ k0ntext validate
229
+
230
+ # Auto-fix errors
231
+ k0ntext validate --fix
232
+
233
+ # Treat warnings as errors
234
+ k0ntext validate --strict
235
+ ```
236
+
237
+ **Options:**
238
+ - `--fix` - Automatically fix validation errors
239
+ - `--strict` - Treat warnings as errors
240
+
241
+ #### `k0ntext export <output>`
242
+ Export context database to file.
243
+
244
+ ```bash
245
+ # Export as JSON
246
+ k0ntext export context.json
247
+
248
+ # Export as markdown
249
+ k0ntext export docs.md --format markdown
250
+
251
+ # Export specific type
252
+ k0ntext export workflows.json --type workflow
253
+ ```
254
+
255
+ **Options:**
256
+ - `--format <format>` - Export format (json, markdown)
257
+ - `--type <type>` - Filter by context type
258
+
259
+ #### `k0ntext import <input>`
260
+ Import context data from exported files.
261
+
262
+ ```bash
263
+ # Import JSON export
264
+ k0ntext import context.json
265
+
266
+ # Import and merge with existing data
267
+ k0ntext import context.json --merge
268
+ ```
269
+
270
+ **Options:**
271
+ - `--format <format>` - Import format (json, markdown)
272
+ - `--merge` - Merge with existing data (default: replace)
273
+
274
+ #### `k0ntext performance`
275
+ Show performance metrics and optimization suggestions.
276
+
277
+ ```bash
278
+ # Human-readable report
279
+ k0ntext performance
280
+
281
+ # JSON output
282
+ k0ntext performance --json
283
+ ```
284
+
285
+ **Options:**
286
+ - `--json` - Output as JSON
287
+
288
+ #### `k0ntext watch`
289
+ Watch for file changes and auto-update index.
290
+
291
+ ```bash
292
+ # Start watching with 1s delay
293
+ k0ntext watch
294
+
295
+ # Custom debounce delay
296
+ k0ntext watch -d 2000
297
+ ```
298
+
299
+ **Options:**
300
+ - `-d, --delay <ms>` - Debounce delay in milliseconds
301
+
302
+ #### `k0ntext index`
303
+ Index codebase content into the database.
304
+
305
+ ```bash
306
+ # Index everything
307
+ k0ntext index
308
+
309
+ # Index documentation only
310
+ k0ntext index --docs
311
+
312
+ # Index source code only
313
+ k0ntext index --code
314
+
315
+ # Index AI tool configs only
316
+ k0ntext index --tools
317
+
318
+ # Verbose output
319
+ k0ntext index -v
320
+ ```
321
+
322
+ **Options:**
323
+ - `--docs` - Index documentation files only
324
+ - `--code` - Index source code only
325
+ - `--tools` - Index AI tool configurations only
326
+ - `--all` - Index everything (default)
327
+ - `-v, --verbose` - Show detailed output
328
+
329
+ #### `k0ntext search <query>`
330
+ Search across indexed content.
331
+
332
+ ```bash
333
+ # Basic search
334
+ k0ntext search "authentication"
335
+
336
+ # Search specific type
337
+ k0ntext search "user login" -t workflow
338
+
339
+ # Text-only search
340
+ k0ntext search "API endpoint" -m text
341
+
342
+ # Semantic search (requires OPENROUTER_API_KEY)
343
+ k0ntext search "data persistence" -m semantic
344
+
345
+ # Limit results
346
+ k0ntext search "database" -l 5
347
+ ```
348
+
349
+ **Options:**
350
+ - `-t, --type <type>` - Filter by type
351
+ - `-l, --limit <n>` - Maximum results (default: 10)
352
+ - `-m, --mode <mode>` - Search mode: text, semantic, hybrid
353
+
354
+ #### `k0ntext stats`
355
+ Show database and indexing statistics.
356
+
357
+ ```bash
358
+ # View all statistics
359
+ k0ntext stats
360
+
361
+ # Show specific stats (filtered by index)
362
+ k0ntext stats | grep "Context Items"
363
+ ```
364
+
365
+ ## 🤖 MCP Server Usage
366
+
367
+ ### Start the Server
368
+ ```bash
369
+ # Start MCP server
370
+ k0ntext mcp
371
+ ```
372
+
373
+ ### Available MCP Tools
374
+
375
+ 1. **search_context** - Semantic search across all indexed content
376
+ 2. **get_item** - Get a specific context item by ID or path
377
+ 3. **add_knowledge** - Store new insights or facts
378
+ 4. **analyze** - Run intelligent analysis on codebase
379
+ 5. **get_tool_configs** - Get AI tool configurations
380
+ 6. **query_graph** - Traverse knowledge graph
381
+ 7. **get_stats** - Get database statistics
382
+
383
+ ### Available Prompts
384
+
385
+ 1. **context-engineer** - Initialize and configure AI context system
386
+ 2. **core-architect** - Design system architecture
387
+ 3. **api-developer** - Develop API endpoints
388
+ 4. **database-ops** - Database operations
389
+ 5. **integration-hub** - External integrations
390
+ 6. **deployment-ops** - CI/CD and deployment
391
+
392
+ ### Example MCP Tool Usage
393
+
394
+ ```javascript
395
+ // Search for authentication workflows
396
+ const results = await search_context({
397
+ query: "user authentication flow",
398
+ type: "workflow",
399
+ limit: 5
400
+ });
401
+
402
+ // Get a specific item
403
+ const item = await get_item({
404
+ id: "workflow:user-auth"
405
+ });
406
+
407
+ // Add new knowledge
408
+ await add_knowledge({
409
+ name: "API Rate Limiting",
410
+ content: "Our API uses token bucket algorithm with 1000 req/min",
411
+ relatedTo: ["api:main-endpoint"]
412
+ });
413
+ ```
414
+
415
+ ## 🎨 Supported AI Tools
416
+
417
+ ### Fully Supported
418
+ - **Claude** - AI_CONTEXT.md
419
+ - **GitHub Copilot** - .github/copilot-instructions.md
420
+ - **Cursor** - .cursorrules
421
+ - **Windsurf** - .windsurf/rules.md
422
+ - **Cline** - .clinerules
423
+ - **Aider** - .aider.conf.yml
424
+ - **Continue** - .continue/config.json
425
+ - **Antigravity** - .agent/README.md
426
+ - **Gemini** - .gemini/config.md
427
+
428
+ ### RPI Workflow Skills
429
+ - **@context-engineer** - Setup and configuration
430
+ - **@core-architect** - System design
431
+ - **@api-developer** - API development
432
+ - **@database-ops** - Database operations
433
+ - **@integration-hub** - External integrations
434
+ - **@deployment-ops** - CI/CD and deployment
435
+
436
+ ## 🔧 Configuration
437
+
438
+ ### Environment Variables
439
+
440
+ | Variable | Description | Required |
441
+ |----------|-------------|----------|
442
+ | `OPENROUTER_API_KEY` | API key for intelligent analysis via OpenRouter | For `--intelligent` flag |
443
+ | `K0NTEXT_PROJECT_ROOT` | Override project root path | Optional |
444
+ | `K0NTEXT_DB_PATH` | Override database file path | Optional |
445
+
446
+ ### Database Location
447
+
448
+ By default, k0ntext stores its SQLite database at `.k0ntext.db` in the project root. This file is automatically added to `.gitignore`.
449
+
450
+ ### Tool Configuration Paths
451
+
452
+ Each AI tool has its own configuration file path:
453
+ - Claude: `AI_CONTEXT.md`
454
+ - Copilot: `.github/copilot-instructions.md`
455
+ - Cursor: `.cursorrules`
456
+ - Windsurf: `.windsurf/rules.md`
457
+ - Cline: `.clinerules`
458
+ - Aider: `.aider.conf.yml`
459
+ - Continue: `.continue/config.json`
460
+ - Antigravity: `.agent/README.md`
461
+ - Gemini: `.gemini/config.md`
462
+
463
+ ## 🏗️ Architecture
464
+
465
+ ### System Components
466
+
467
+ ```
468
+ k0ntext/
469
+ ├── src/ # TypeScript source
470
+ │ ├── cli/ # CLI commands (13 commands)
471
+ │ ├── db/ # SQLite database client
472
+ │ ├── analyzer/ # Intelligent codebase analysis
473
+ │ ├── embeddings/ # OpenRouter integration
474
+ │ ├── agents/ # Smart agents (Cleanup, Performance)
475
+ │ └── mcp.ts # MCP server implementation
476
+ ├── agents/ # Agent definitions
477
+ ├── skills/ # RPI workflow skills
478
+ ├── templates/ # Output templates
479
+ └── .k0ntext.db # SQLite database (auto-created)
480
+ ```
481
+
482
+ ### Data Flow
483
+
484
+ 1. **Initialization** - `k0ntext init` discovers and analyzes codebase
485
+ 2. **Indexing** - `k0ntext index` stores content in SQLite with embeddings
486
+ 3. **Generation** - `k0ntext generate` creates tool-specific context files
487
+ 4. **Sync** - `k0ntext sync` keeps all AI tools synchronized
488
+ 5. **MCP Server** - `k0ntext mcp` provides real-time context to AI assistants
489
+
490
+ ### Database Schema
491
+
492
+ The SQLite database contains:
493
+ - **Context Items** - Workflows, agents, commands, code, docs
494
+ - **Embeddings** - Vector embeddings for semantic search
495
+ - **Relations** - Knowledge graph connections
496
+ - **Sync State** - Change tracking for synchronization
497
+ - **Tool Configs** - AI tool configurations
498
+
499
+ ## 🚀 Development
500
+
501
+ ### Build and Test
502
+
503
+ ```bash
504
+ # Install dependencies
505
+ npm install
506
+
507
+ # Build the project
508
+ npm run build
509
+
510
+ # Run tests
511
+ npm test
512
+
513
+ # Run tests once (no watch)
514
+ npm run test:run
515
+
516
+ # Lint code
517
+ npm run lint
518
+ ```
519
+
520
+ ### Publishing
521
+
522
+ ```bash
523
+ # Dry run
524
+ npm run publish:dry
525
+
526
+ # Publish to npm
527
+ npm run publish:public
528
+ ```
529
+
530
+ ### Contributing
531
+
532
+ 1. Fork the repository
533
+ 2. Create a feature branch
534
+ 3. Make your changes
535
+ 4. Run tests and linting
536
+ 5. Submit a pull request
537
+
538
+ ### Project Structure
539
+
540
+ - `src/cli/` - Command implementations
541
+ - `src/db/` - Database operations
542
+ - `src/analyzer/` - Code analysis logic
543
+ - `src/agents/` - Smart agents
544
+ - `templates/` - Context templates
545
+ - `.claude/` - Claude Code development context
546
+
547
+ ## 📊 Performance Monitoring
548
+
549
+ The PerformanceMonitorAgent provides insights into:
550
+ - Query execution times
551
+ - Database size and growth
552
+ - Slow query detection
553
+ - Optimization suggestions
554
+
555
+ ```bash
556
+ # View performance report
557
+ k0ntext performance
558
+
559
+ # Get JSON metrics
560
+ k0ntext performance --json
561
+ ```
562
+
563
+ Common optimization suggestions:
564
+ - Add indexes for frequently queried columns
565
+ - Run VACUUM for large databases
566
+ - Review and optimize slow queries
567
+ - Monitor cache hit rates
568
+
569
+ ## 🔍 Troubleshooting
570
+
571
+ ### Common Issues
572
+
573
+ 1. **SQLite Native Extension Issues (Windows)**
574
+ ```bash
575
+ # Use Node.js LTS version
576
+ node --version
577
+ ```
578
+
579
+ 2. **OpenRouter API Key Not Found**
580
+ ```bash
581
+ # Set the environment variable
582
+ export OPENROUTER_API_KEY=your_api_key_here
583
+ ```
584
+
585
+ 3. **Database Locked**
586
+ ```bash
587
+ # Close other instances of k0ntext
588
+ # Or wait a few seconds
589
+ ```
590
+
591
+ 4. **Permission Errors**
592
+ ```bash
593
+ # Check file permissions
594
+ ls -la .k0ntext.db
595
+ ```
596
+
597
+ ### Debug Mode
598
+
599
+ ```bash
600
+ # Verbose output for most commands
601
+ k0ntext init -v
602
+ k0ntext index -v
603
+ k0ntext generate -v
604
+ ```
605
+
606
+ ## 🤝 Community
607
+
608
+ - **GitHub Issues:** [Report bugs and request features](https://github.com/SireJeff/k0ntext/issues)
609
+ - **Discussions:** [Join community discussions](https://github.com/SireJeff/k0ntext/discussions)
610
+ - **Documentation:** [Full API documentation](./docs/)
611
+
612
+ ## 📄 License
613
+
614
+ MIT License - see [LICENSE](LICENSE) file for details.
615
+
616
+ ---
617
+
618
+ **Repository:** https://github.com/SireJeff/k0ntext
619
+ **npm Package:** https://www.npmjs.com/package/k0ntext
620
+ **Issues:** https://github.com/SireJeff/k0ntext/issues
621
+ **MCP Protocol:** https://modelcontextprotocol.io
622
+
623
+ Made with ❤️ by [SireJeff](https://github.com/SireJeff)
package/bin/k0ntext.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * K0ntext CLI Entry Point
5
+ *
6
+ * This is the main entry point for the k0ntext command.
7
+ */
8
+
9
+ import('../dist/cli/index.js').catch((error) => {
10
+ console.error('Failed to start K0ntext CLI:', error);
11
+ process.exit(1);
12
+ });
@@ -0,0 +1,39 @@
1
+ import { DEFAULT_CLEANUP_CONFIG } from '../config/cleanup-config.js';
2
+ export interface CleanupOptions {
3
+ dryRun?: boolean;
4
+ keep?: string[];
5
+ verbose?: boolean;
6
+ cwd?: string;
7
+ }
8
+ export interface CleanupConfig {
9
+ /** Default dry run mode (safe mode) */
10
+ dryRun: boolean;
11
+ /** Default folders to keep */
12
+ defaultKeep: string[];
13
+ /** Verbose output by default */
14
+ verbose: boolean;
15
+ /** Maximum folder depth to scan */
16
+ maxDepth: number;
17
+ /** Timeout for folder operations in milliseconds */
18
+ timeout: number;
19
+ /** Default working directory */
20
+ cwd: string;
21
+ }
22
+ export interface CleanupResult {
23
+ scanned: number;
24
+ removed: string[];
25
+ kept: string[];
26
+ errors: Array<{
27
+ folder: string;
28
+ error: unknown;
29
+ }>;
30
+ }
31
+ export declare class CleanupAgent {
32
+ private readonly KNOWN_TOOL_FOLDERS;
33
+ private config;
34
+ constructor(config?: Partial<typeof DEFAULT_CLEANUP_CONFIG>);
35
+ cleanup(options?: CleanupOptions): Promise<CleanupResult>;
36
+ analyze(options?: Omit<CleanupOptions, 'dryRun'>): Promise<CleanupResult>;
37
+ getConfig(): typeof DEFAULT_CLEANUP_CONFIG;
38
+ }
39
+ //# sourceMappingURL=cleanup-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup-agent.d.ts","sourceRoot":"","sources":["../../src/agents/cleanup-agent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,MAAM,EAAE,OAAO,CAAC;IAEhB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IAEjB,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IAEjB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAEhB,gCAAgC;IAChC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnD;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAKjC;IAEF,OAAO,CAAC,MAAM,CAAgC;gBAElC,MAAM,CAAC,EAAE,OAAO,CAAC,OAAO,sBAAsB,CAAC;IAIrD,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IAoC7D,OAAO,CAAC,OAAO,GAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAInF,SAAS,IAAI,OAAO,sBAAsB;CAG3C"}