k0ntext 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -2
- package/dist/cli/commands/batch-index.d.ts +16 -0
- package/dist/cli/commands/batch-index.d.ts.map +1 -0
- package/dist/cli/commands/batch-index.js +387 -0
- package/dist/cli/commands/batch-index.js.map +1 -0
- package/dist/cli/index.js +65 -0
- package/dist/cli/index.js.map +1 -1
- package/package.json +2 -2
- package/src/cli/commands/batch-index.ts +492 -0
- package/src/cli/index.ts +81 -3
- package/templates/base/CLI_COMMANDS.md +589 -0
- package/templates/base/agents/api-developer.md +37 -0
- package/templates/base/agents/context-engineer.md +41 -0
- package/templates/base/agents/core-architect.md +41 -0
- package/templates/base/agents/database-ops.md +38 -0
- package/templates/base/agents/deployment-ops.md +41 -0
- package/templates/base/agents/integration-hub.md +37 -0
- package/templates/base/commands/analytics.md +33 -0
- package/templates/base/commands/auto-sync.md +33 -0
- package/templates/base/commands/collab.md +37 -0
- package/templates/base/commands/context-optimize.md +36 -0
- package/templates/base/commands/help.md +55 -0
- package/templates/base/commands/rpi-implement.md +36 -0
- package/templates/base/commands/rpi-plan.md +32 -0
- package/templates/base/commands/rpi-research.md +34 -0
- package/templates/base/commands/session-resume.md +32 -0
- package/templates/base/commands/session-save.md +29 -0
- package/templates/base/commands/validate-all.md +36 -0
- package/templates/base/commands/verify-docs-current.md +33 -0
- package/templates/base/settings.json +10 -1
package/src/cli/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { driftDetectCommand } from './commands/drift-detect.js';
|
|
|
28
28
|
import { crossSyncCommand } from './commands/cross-sync.js';
|
|
29
29
|
import { hooksCommand } from './commands/hooks.js';
|
|
30
30
|
import { factCheckCommand } from './commands/fact-check.js';
|
|
31
|
+
import { batchIndexCommand } from './commands/batch-index.js';
|
|
31
32
|
|
|
32
33
|
const __filename = fileURLToPath(import.meta.url);
|
|
33
34
|
const __dirname = path.dirname(__filename);
|
|
@@ -68,6 +69,65 @@ function _parseAiTools(toolsString: string): string[] {
|
|
|
68
69
|
return tools.includes('all') ? allTools : tools;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Configure MCP server for AI tools that support it
|
|
74
|
+
*
|
|
75
|
+
* Tools with native MCP support:
|
|
76
|
+
* - Claude Code (.claude/settings.json)
|
|
77
|
+
* - Cursor (.cursor/mcp.json or settings)
|
|
78
|
+
* - Continue (.continue/config.json)
|
|
79
|
+
*/
|
|
80
|
+
async function configureMcpServer(projectRoot: string): Promise<void> {
|
|
81
|
+
const fsPromises = fs.promises;
|
|
82
|
+
|
|
83
|
+
// Configure Claude Code MCP server
|
|
84
|
+
const claudeSettingsPath = path.join(projectRoot, '.claude', 'settings.json');
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
let settings: Record<string, any> = {};
|
|
88
|
+
|
|
89
|
+
// Read existing settings if they exist
|
|
90
|
+
if (fs.existsSync(claudeSettingsPath)) {
|
|
91
|
+
const content = fs.readFileSync(claudeSettingsPath, 'utf-8');
|
|
92
|
+
try {
|
|
93
|
+
settings = JSON.parse(content);
|
|
94
|
+
} catch {
|
|
95
|
+
// File exists but is invalid JSON, start fresh
|
|
96
|
+
settings = {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Ensure mcpServers object exists
|
|
101
|
+
if (!settings.mcpServers) {
|
|
102
|
+
settings.mcpServers = {};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Add k0ntext MCP server configuration
|
|
106
|
+
if (!settings.mcpServers.k0ntext) {
|
|
107
|
+
settings.mcpServers.k0ntext = {
|
|
108
|
+
command: 'npx',
|
|
109
|
+
args: ['k0ntext', 'mcp'],
|
|
110
|
+
env: {
|
|
111
|
+
K0NTEXT_PROJECT_ROOT: projectRoot
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Ensure directory exists
|
|
117
|
+
await fsPromises.mkdir(path.dirname(claudeSettingsPath), { recursive: true });
|
|
118
|
+
|
|
119
|
+
// Write settings with proper formatting
|
|
120
|
+
await fsPromises.writeFile(
|
|
121
|
+
claudeSettingsPath,
|
|
122
|
+
JSON.stringify(settings, null, 2),
|
|
123
|
+
'utf-8'
|
|
124
|
+
);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
// Log warning but don't fail the entire init process
|
|
127
|
+
console.warn(chalk.yellow(`\nWarning: Could not configure MCP server: ${error instanceof Error ? error.message : error}`));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
71
131
|
/**
|
|
72
132
|
* Create the CLI program
|
|
73
133
|
*/
|
|
@@ -138,11 +198,17 @@ function createProgram(): Command {
|
|
|
138
198
|
}
|
|
139
199
|
|
|
140
200
|
console.log(`\n${chalk.green('✓')} AI Context initialized successfully!`);
|
|
201
|
+
|
|
202
|
+
// Configure MCP server for Claude Code and other tools
|
|
203
|
+
spinner.start('Configuring MCP server...');
|
|
204
|
+
await configureMcpServer(targetDir);
|
|
205
|
+
spinner.succeed('MCP server configured');
|
|
206
|
+
|
|
141
207
|
console.log(`\n${chalk.bold('Next Steps:')}`);
|
|
142
208
|
console.log(` ${chalk.cyan('1.')} Run ${chalk.white('k0ntext stats')} to view database statistics`);
|
|
143
209
|
console.log(` ${chalk.cyan('2.')} Run ${chalk.white('k0ntext mcp')} to start the MCP server`);
|
|
144
210
|
console.log(` ${chalk.cyan('3.')} Run ${chalk.white('k0ntext --help')} to explore all available commands`);
|
|
145
|
-
|
|
211
|
+
|
|
146
212
|
} catch (error) {
|
|
147
213
|
spinner.fail('Analysis failed');
|
|
148
214
|
console.error(chalk.red(`\nError: ${error instanceof Error ? error.message : error}`));
|
|
@@ -521,15 +587,27 @@ function createProgram(): Command {
|
|
|
521
587
|
console.log(` ${chalk.cyan('•')} Embeddings: ${stats.embeddings}`);
|
|
522
588
|
console.log(` ${chalk.cyan('•')} Tool Configs: ${stats.toolConfigs}`);
|
|
523
589
|
console.log(` ${chalk.cyan('•')} Database Path: ${db.getPath()}`);
|
|
524
|
-
|
|
590
|
+
|
|
525
591
|
db.close();
|
|
526
|
-
|
|
592
|
+
|
|
527
593
|
} catch (error) {
|
|
528
594
|
console.error(chalk.red(`\nError: ${error instanceof Error ? error.message : error}`));
|
|
529
595
|
process.exit(1);
|
|
530
596
|
}
|
|
531
597
|
});
|
|
532
598
|
|
|
599
|
+
// ==================== Batch Index Command ====================
|
|
600
|
+
program
|
|
601
|
+
.command('index:batch')
|
|
602
|
+
.description('Index large monorepos by processing modules in batches')
|
|
603
|
+
.option('-b, --batch-size <n>', 'Files per batch', '100')
|
|
604
|
+
.option('-m, --max-files <n>', 'Maximum files per module', '500')
|
|
605
|
+
.option('--skip-embeddings', 'Skip generating embeddings')
|
|
606
|
+
.option('-v, --verbose', 'Show detailed output')
|
|
607
|
+
.action(async (options) => {
|
|
608
|
+
await batchIndexCommand(options);
|
|
609
|
+
});
|
|
610
|
+
|
|
533
611
|
return program;
|
|
534
612
|
}
|
|
535
613
|
|
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
# k0ntext CLI Commands Reference
|
|
2
|
+
|
|
3
|
+
Complete reference for all k0ntext v3.1.0 CLI commands.
|
|
4
|
+
|
|
5
|
+
## Quick Reference
|
|
6
|
+
|
|
7
|
+
| Command | Purpose | Use Case |
|
|
8
|
+
|---------|---------|----------|
|
|
9
|
+
| `k0ntext init` | Initialize project | First-time setup |
|
|
10
|
+
| `k0ntext generate` | Generate contexts | Add AI tools |
|
|
11
|
+
| `k0ntext mcp` | Start MCP server | For AI tools with MCP support |
|
|
12
|
+
| `k0ntext sync` | Sync contexts | After manual changes |
|
|
13
|
+
| `k0ntext cleanup` | Remove unused tools | When switching tools |
|
|
14
|
+
| `k0ntext validate` | Validate contexts | Before committing |
|
|
15
|
+
| `k0ntext export` | Export database | Backup or transfer |
|
|
16
|
+
| `k0ntext import` | Import context | Restore from backup |
|
|
17
|
+
| `k0ntext performance` | Show metrics | When system is slow |
|
|
18
|
+
| `k0ntext watch` | Auto-index files | During active development |
|
|
19
|
+
| `k0ntext drift-detect` | Detect drift | When code changes |
|
|
20
|
+
| `k0ntext cross-sync` | Cross-tool sync | After drift detected |
|
|
21
|
+
| `k0ntext hooks` | Git hooks | For automation |
|
|
22
|
+
| `k0ntext fact-check` | Validate docs | Quality assurance |
|
|
23
|
+
| `k0ntext index` | Index codebase | After adding files |
|
|
24
|
+
| `k0ntext search <query>` | Search content | Finding code/workflows |
|
|
25
|
+
| `k0ntext stats` | View statistics | Check indexing status |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Detailed Commands
|
|
30
|
+
|
|
31
|
+
### Initialization Commands
|
|
32
|
+
|
|
33
|
+
#### `k0ntext init`
|
|
34
|
+
|
|
35
|
+
Initialize project with intelligent analysis.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
k0ntext init [project-name]
|
|
39
|
+
k0ntext init --no-intelligent # Skip OpenRouter analysis
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**What it does:**
|
|
43
|
+
- Analyzes project structure and tech stack
|
|
44
|
+
- Discovers existing documentation and workflows
|
|
45
|
+
- Detects configured AI tools
|
|
46
|
+
- Initializes SQLite database
|
|
47
|
+
- Configures MCP server for supported AI tools
|
|
48
|
+
|
|
49
|
+
**When to use:**
|
|
50
|
+
- First-time setup for a new project
|
|
51
|
+
- When starting to use k0ntext on an existing project
|
|
52
|
+
|
|
53
|
+
**Output:**
|
|
54
|
+
- Database initialized at `.k0ntext.db`
|
|
55
|
+
- MCP server configured in `.claude/settings.json`
|
|
56
|
+
- Analysis results displayed
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
#### `k0ntext generate`
|
|
61
|
+
|
|
62
|
+
Generate context files for AI tools.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
k0ntext generate
|
|
66
|
+
k0ntext generate --tools claude,cursor,continue
|
|
67
|
+
k0ntext generate --all
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**What it does:**
|
|
71
|
+
- Generates context files for specified AI tools
|
|
72
|
+
- Populates templates with discovered information
|
|
73
|
+
- Creates tool-specific configurations
|
|
74
|
+
|
|
75
|
+
**When to use:**
|
|
76
|
+
- After running `k0ntext init`
|
|
77
|
+
- When adding support for new AI tools
|
|
78
|
+
- After making significant architectural changes
|
|
79
|
+
|
|
80
|
+
**Output:**
|
|
81
|
+
- Context files generated in tool-specific directories
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
#### `k0ntext mcp`
|
|
86
|
+
|
|
87
|
+
Start the MCP server for AI tools.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
k0ntext mcp
|
|
91
|
+
k0ntext mcp --db .k0ntext.db
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**What it does:**
|
|
95
|
+
- Starts the Model Context Protocol server
|
|
96
|
+
- Enables AI tools to query indexed content
|
|
97
|
+
- Provides semantic search capabilities
|
|
98
|
+
|
|
99
|
+
**When to use:**
|
|
100
|
+
- When using AI tools with MCP support (Claude Code, Cursor, Continue)
|
|
101
|
+
- For real-time context access during development
|
|
102
|
+
|
|
103
|
+
**Output:**
|
|
104
|
+
- MCP server running on stdio
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### Synchronization Commands
|
|
109
|
+
|
|
110
|
+
#### `k0ntext sync`
|
|
111
|
+
|
|
112
|
+
Synchronize context across AI tools.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
k0ntext sync
|
|
116
|
+
k0ntext sync --tools claude,cursor
|
|
117
|
+
k0ntext sync --force
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**What it does:**
|
|
121
|
+
- Propagates context changes to all configured AI tools
|
|
122
|
+
- Ensures consistency across tool-specific directories
|
|
123
|
+
- Updates tool-specific configurations
|
|
124
|
+
|
|
125
|
+
**When to use:**
|
|
126
|
+
- After manually modifying context files
|
|
127
|
+
- After running `k0ntext generate`
|
|
128
|
+
- To ensure all tools have the latest context
|
|
129
|
+
|
|
130
|
+
**Output:**
|
|
131
|
+
- Sync status for each tool
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
#### `k0ntext cross-sync`
|
|
136
|
+
|
|
137
|
+
Intelligent cross-tool synchronization.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
k0ntext cross-sync
|
|
141
|
+
k0ntext cross-sync --detect-drift
|
|
142
|
+
k0ntext cross-sync --fix
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**What it does:**
|
|
146
|
+
- Detects differences between tool contexts
|
|
147
|
+
- Intelligently merges changes
|
|
148
|
+
- Resolves conflicts using AI
|
|
149
|
+
|
|
150
|
+
**When to use:**
|
|
151
|
+
- After `k0ntext drift-detect` identifies issues
|
|
152
|
+
- When manual edits have created inconsistencies
|
|
153
|
+
- Before major commits to ensure alignment
|
|
154
|
+
|
|
155
|
+
**Output:**
|
|
156
|
+
- Cross-sync report with conflicts resolved
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### Validation Commands
|
|
161
|
+
|
|
162
|
+
#### `k0ntext validate`
|
|
163
|
+
|
|
164
|
+
Validate context files.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
k0ntext validate
|
|
168
|
+
k0ntext validate --strict
|
|
169
|
+
k0ntext validate --fix
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**What it does:**
|
|
173
|
+
- Checks context file structure
|
|
174
|
+
- Validates required fields
|
|
175
|
+
- Ensures link integrity
|
|
176
|
+
|
|
177
|
+
**When to use:**
|
|
178
|
+
- Before committing changes
|
|
179
|
+
- After modifying context files
|
|
180
|
+
- As part of CI/CD pipeline
|
|
181
|
+
|
|
182
|
+
**Output:**
|
|
183
|
+
- Validation report with errors and warnings
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
#### `k0ntext drift-detect`
|
|
188
|
+
|
|
189
|
+
AI-powered drift detection.
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
k0ntext drift-detect
|
|
193
|
+
k0ntext drift-detect --workflow authentication
|
|
194
|
+
k0ntext drift-detect --fix
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**What it does:**
|
|
198
|
+
- Uses AI to compare documentation with code
|
|
199
|
+
- Detects outdated line references
|
|
200
|
+
- Identifies missing or incorrect documentation
|
|
201
|
+
|
|
202
|
+
**When to use:**
|
|
203
|
+
- After code changes
|
|
204
|
+
- Before documentation updates
|
|
205
|
+
- For regular maintenance checks
|
|
206
|
+
|
|
207
|
+
**Output:**
|
|
208
|
+
- Drift detection report with recommendations
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
#### `k0ntext fact-check`
|
|
213
|
+
|
|
214
|
+
Validate documentation accuracy.
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
k0ntext fact-check
|
|
218
|
+
k0ntext fact-check --file docs/api.md
|
|
219
|
+
k0ntext fact-check --strict
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**What it does:**
|
|
223
|
+
- Validates documentation against current code
|
|
224
|
+
- Checks accuracy of statements
|
|
225
|
+
- Identifies potential errors or omissions
|
|
226
|
+
|
|
227
|
+
**When to use:**
|
|
228
|
+
- Quality assurance before releases
|
|
229
|
+
- After documentation updates
|
|
230
|
+
- For critical documentation verification
|
|
231
|
+
|
|
232
|
+
**Output:**
|
|
233
|
+
- Fact-check report with accuracy scores
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### Database Commands
|
|
238
|
+
|
|
239
|
+
#### `k0ntext index`
|
|
240
|
+
|
|
241
|
+
Index codebase into database.
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
k0ntext index
|
|
245
|
+
k0ntext index --all
|
|
246
|
+
k0ntext index --docs
|
|
247
|
+
k0ntext index --code
|
|
248
|
+
k0ntext index --tools
|
|
249
|
+
k0ntext index --verbose
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**What it does:**
|
|
253
|
+
- Discovers and indexes project files
|
|
254
|
+
- Generates embeddings for semantic search (with API key)
|
|
255
|
+
- Stores file metadata and content
|
|
256
|
+
|
|
257
|
+
**When to use:**
|
|
258
|
+
- After adding new files
|
|
259
|
+
- Before using semantic search
|
|
260
|
+
- For initial database population
|
|
261
|
+
|
|
262
|
+
**Output:**
|
|
263
|
+
- Indexing statistics (files discovered, indexed, embeddings generated)
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
#### `k0ntext search <query>`
|
|
268
|
+
|
|
269
|
+
Search indexed content.
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
k0ntext search "authentication flow"
|
|
273
|
+
k0ntext search "API endpoint" --type code
|
|
274
|
+
k0ntext search "database" --limit 20
|
|
275
|
+
k0ntext search "user" --mode semantic
|
|
276
|
+
k0ntext search "payment" --mode text
|
|
277
|
+
k0ntext search "webhook" --mode hybrid
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**What it does:**
|
|
281
|
+
- Searches indexed codebase content
|
|
282
|
+
- Supports text, semantic, and hybrid search modes
|
|
283
|
+
- Returns ranked results with file paths
|
|
284
|
+
|
|
285
|
+
**When to use:**
|
|
286
|
+
- Finding related code or documentation
|
|
287
|
+
- Discovering patterns and implementations
|
|
288
|
+
- Locating workflow references
|
|
289
|
+
|
|
290
|
+
**Search Modes:**
|
|
291
|
+
- `text` - Pure keyword search
|
|
292
|
+
- `semantic` - Vector similarity search (requires API key)
|
|
293
|
+
- `hybrid` - Combined text and semantic (default)
|
|
294
|
+
|
|
295
|
+
**Output:**
|
|
296
|
+
- Ranked search results with file paths and relevance scores
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
#### `k0ntext stats`
|
|
301
|
+
|
|
302
|
+
View database statistics.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
k0ntext stats
|
|
306
|
+
k0ntext stats --verbose
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**What it does:**
|
|
310
|
+
- Displays database item counts
|
|
311
|
+
- Shows indexing statistics
|
|
312
|
+
- Lists database file location
|
|
313
|
+
|
|
314
|
+
**When to use:**
|
|
315
|
+
- Checking indexing status
|
|
316
|
+
- Verifying database health
|
|
317
|
+
- Understanding database size and contents
|
|
318
|
+
|
|
319
|
+
**Output:**
|
|
320
|
+
- Statistics table showing items, relations, commits, embeddings, tool configs
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### Utility Commands
|
|
325
|
+
|
|
326
|
+
#### `k0ntext export`
|
|
327
|
+
|
|
328
|
+
Export database to file.
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
k0ntext export
|
|
332
|
+
k0ntext export --file backup.json
|
|
333
|
+
k0ntext export --format json
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**What it does:**
|
|
337
|
+
- Exports entire database to JSON file
|
|
338
|
+
- Includes all indexed items, embeddings, and metadata
|
|
339
|
+
- Creates portable backup
|
|
340
|
+
|
|
341
|
+
**When to use:**
|
|
342
|
+
- Creating backups before major changes
|
|
343
|
+
- Transferring context between projects
|
|
344
|
+
- Sharing context with team members
|
|
345
|
+
|
|
346
|
+
**Output:**
|
|
347
|
+
- JSON file with complete database export
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
#### `k0ntext import`
|
|
352
|
+
|
|
353
|
+
Import context from file.
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
k0ntext import
|
|
357
|
+
k0ntext import --file backup.json
|
|
358
|
+
k0ntext import --merge
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**What it does:**
|
|
362
|
+
- Imports database from JSON file
|
|
363
|
+
- Restores indexed content and embeddings
|
|
364
|
+
- Optionally merges with existing data
|
|
365
|
+
|
|
366
|
+
**When to use:**
|
|
367
|
+
- Restoring from backup
|
|
368
|
+
- Loading context shared by team
|
|
369
|
+
- Migrating between projects
|
|
370
|
+
|
|
371
|
+
**Output:**
|
|
372
|
+
- Import statistics with items added
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
#### `k0ntext cleanup`
|
|
377
|
+
|
|
378
|
+
Remove unused AI tool folders.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
k0ntext cleanup
|
|
382
|
+
k0ntext cleanup --dry-run
|
|
383
|
+
k0ntext cleanup --keep claude,cursor
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
**What it does:**
|
|
387
|
+
- Identifies unused AI tool directories
|
|
388
|
+
- Removes stale configuration files
|
|
389
|
+
- Cleans up orphaned context files
|
|
390
|
+
|
|
391
|
+
**When to use:**
|
|
392
|
+
- When switching between AI tools
|
|
393
|
+
- Removing tools no longer in use
|
|
394
|
+
- General cleanup and maintenance
|
|
395
|
+
|
|
396
|
+
**Output:**
|
|
397
|
+
- Cleanup report with folders removed
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
#### `k0ntext performance`
|
|
402
|
+
|
|
403
|
+
Show performance metrics.
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
k0ntext performance
|
|
407
|
+
k0ntext performance --detailed
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**What it does:**
|
|
411
|
+
- Displays system performance metrics
|
|
412
|
+
- Shows database query times
|
|
413
|
+
- Identifies bottlenecks
|
|
414
|
+
|
|
415
|
+
**When to use:**
|
|
416
|
+
- When system is slow
|
|
417
|
+
- Optimizing performance
|
|
418
|
+
- Debugging issues
|
|
419
|
+
|
|
420
|
+
**Output:**
|
|
421
|
+
- Performance metrics report
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
#### `k0ntext watch`
|
|
426
|
+
|
|
427
|
+
Auto-index on file changes.
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
k0ntext watch
|
|
431
|
+
k0ntext watch --debounce 1000
|
|
432
|
+
k0ntext watch --include "src/**/*"
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**What it does:**
|
|
436
|
+
- Watches for file changes
|
|
437
|
+
- Automatically reindexes modified files
|
|
438
|
+
- Runs in background during development
|
|
439
|
+
|
|
440
|
+
**When to use:**
|
|
441
|
+
- During active development
|
|
442
|
+
- For continuous index updates
|
|
443
|
+
- When frequently modifying files
|
|
444
|
+
|
|
445
|
+
**Output:**
|
|
446
|
+
- Watch status with file changes detected
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
#### `k0ntext hooks`
|
|
451
|
+
|
|
452
|
+
Git hooks management.
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
k0ntext hooks install
|
|
456
|
+
k0ntext hooks uninstall
|
|
457
|
+
k0ntext hooks list
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**What it does:**
|
|
461
|
+
- Installs git hooks for automation
|
|
462
|
+
- Configures pre-commit validation
|
|
463
|
+
- Enables automatic context updates
|
|
464
|
+
|
|
465
|
+
**When to use:**
|
|
466
|
+
- Setting up automation
|
|
467
|
+
- Enforcing validation on commits
|
|
468
|
+
- For team-wide consistency
|
|
469
|
+
|
|
470
|
+
**Output:**
|
|
471
|
+
- Hook installation status
|
|
472
|
+
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Command Categories
|
|
476
|
+
|
|
477
|
+
### Setup Commands
|
|
478
|
+
- `k0ntext init` - Initialize project
|
|
479
|
+
- `k0ntext generate` - Generate contexts
|
|
480
|
+
- `k0ntext mcp` - Start MCP server
|
|
481
|
+
|
|
482
|
+
### Sync Commands
|
|
483
|
+
- `k0ntext sync` - Sync contexts
|
|
484
|
+
- `k0ntext cross-sync` - Cross-tool sync
|
|
485
|
+
- `k0ntext cleanup` - Remove unused tools
|
|
486
|
+
|
|
487
|
+
### Validation Commands
|
|
488
|
+
- `k0ntext validate` - Validate contexts
|
|
489
|
+
- `k0ntext drift-detect` - Detect drift
|
|
490
|
+
- `k0ntext fact-check` - Validate accuracy
|
|
491
|
+
|
|
492
|
+
### Database Commands
|
|
493
|
+
- `k0ntext index` - Index codebase
|
|
494
|
+
- `k0ntext search` - Search content
|
|
495
|
+
- `k0ntext stats` - View statistics
|
|
496
|
+
|
|
497
|
+
### Utility Commands
|
|
498
|
+
- `k0ntext export` - Export database
|
|
499
|
+
- `k0ntext import` - Import database
|
|
500
|
+
- `k0ntext performance` - Show metrics
|
|
501
|
+
- `k0ntext watch` - Auto-index
|
|
502
|
+
- `k0ntext hooks` - Git hooks
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
## Integration with AI Tools
|
|
507
|
+
|
|
508
|
+
### Claude Code
|
|
509
|
+
- MCP server: `k0ntext mcp`
|
|
510
|
+
- Config file: `.claude/settings.json`
|
|
511
|
+
- Auto-configured by: `k0ntext init`
|
|
512
|
+
|
|
513
|
+
### Cursor
|
|
514
|
+
- MCP server: `k0ntext mcp`
|
|
515
|
+
- Config file: `.cursor/mcp.json`
|
|
516
|
+
- Manual setup required
|
|
517
|
+
|
|
518
|
+
### Continue
|
|
519
|
+
- MCP server: `k0ntext mcp`
|
|
520
|
+
- Config file: `.continue/config.json`
|
|
521
|
+
- Manual setup required
|
|
522
|
+
|
|
523
|
+
### Other Tools
|
|
524
|
+
- Windsurf, Cline, Gemini, Aider, Antigravity, Copilot
|
|
525
|
+
- Context file generation only
|
|
526
|
+
- No MCP support
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
## Common Workflows
|
|
531
|
+
|
|
532
|
+
### First-Time Setup
|
|
533
|
+
```bash
|
|
534
|
+
k0ntext init # Initialize project
|
|
535
|
+
k0ntext index --all # Index all files
|
|
536
|
+
k0ntext stats # Verify indexing
|
|
537
|
+
k0ntext mcp # Start MCP server
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Daily Development
|
|
541
|
+
```bash
|
|
542
|
+
k0ntext watch # Start auto-indexing
|
|
543
|
+
# ... make changes ...
|
|
544
|
+
k0ntext drift-detect # Check for drift
|
|
545
|
+
k0ntext validate # Validate before commit
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Adding AI Tool
|
|
549
|
+
```bash
|
|
550
|
+
k0ntext generate --tools claude,cursor # Generate contexts
|
|
551
|
+
k0ntext sync # Sync across tools
|
|
552
|
+
k0ntext validate # Validate setup
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### Team Collaboration
|
|
556
|
+
```bash
|
|
557
|
+
k0ntext export --file team-context.json # Export for team
|
|
558
|
+
k0ntext import --file team-context.json # Import from team
|
|
559
|
+
k0ntext cross-sync # Sync changes
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
---
|
|
563
|
+
|
|
564
|
+
## Environment Variables
|
|
565
|
+
|
|
566
|
+
| Variable | Description | Default |
|
|
567
|
+
|----------|-------------|---------|
|
|
568
|
+
| `OPENROUTER_API_KEY` | OpenRouter API key for intelligent analysis | - |
|
|
569
|
+
| `K0NTEXT_PROJECT_ROOT` | Project root path (auto-set) | `cwd` |
|
|
570
|
+
| `K0NTEXT_DB_PATH` | Database file path | `.k0ntext.db` |
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## Configuration Files
|
|
575
|
+
|
|
576
|
+
| File | Purpose |
|
|
577
|
+
|------|---------|
|
|
578
|
+
| `.k0ntext.db` | SQLite database |
|
|
579
|
+
| `.claude/settings.json` | Claude Code settings (includes MCP config) |
|
|
580
|
+
| `.k0ntext/sync-state.json` | Sync state tracking |
|
|
581
|
+
| `.git/hooks/pre-commit` | Git hooks (if installed) |
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## Version
|
|
586
|
+
|
|
587
|
+
**k0ntext:** v3.1.0
|
|
588
|
+
|
|
589
|
+
**Documentation Last Updated:** 2026-02-08
|