k0ntext 3.6.0 → 3.8.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 (77) hide show
  1. package/README.md +281 -382
  2. package/dist/agent-system/timestamp-tracker.d.ts +159 -0
  3. package/dist/agent-system/timestamp-tracker.d.ts.map +1 -0
  4. package/dist/agent-system/timestamp-tracker.js +405 -0
  5. package/dist/agent-system/timestamp-tracker.js.map +1 -0
  6. package/dist/agent-system/todolist-manager.d.ts +244 -0
  7. package/dist/agent-system/todolist-manager.d.ts.map +1 -0
  8. package/dist/agent-system/todolist-manager.js +580 -0
  9. package/dist/agent-system/todolist-manager.js.map +1 -0
  10. package/dist/analyzer/intelligent-analyzer.d.ts +7 -0
  11. package/dist/analyzer/intelligent-analyzer.d.ts.map +1 -1
  12. package/dist/analyzer/intelligent-analyzer.js +46 -1
  13. package/dist/analyzer/intelligent-analyzer.js.map +1 -1
  14. package/dist/cli/commands/embeddings-refresh.d.ts.map +1 -1
  15. package/dist/cli/commands/embeddings-refresh.js +4 -1
  16. package/dist/cli/commands/embeddings-refresh.js.map +1 -1
  17. package/dist/cli/commands/migrate.d.ts.map +1 -1
  18. package/dist/cli/commands/migrate.js +8 -0
  19. package/dist/cli/commands/migrate.js.map +1 -1
  20. package/dist/cli/commands/snapshot.d.ts +28 -0
  21. package/dist/cli/commands/snapshot.d.ts.map +1 -0
  22. package/dist/cli/commands/snapshot.js +408 -0
  23. package/dist/cli/commands/snapshot.js.map +1 -0
  24. package/dist/cli/repl/init/wizard.d.ts.map +1 -1
  25. package/dist/cli/repl/init/wizard.js +12 -4
  26. package/dist/cli/repl/init/wizard.js.map +1 -1
  27. package/dist/cli/version/comparator.d.ts +1 -0
  28. package/dist/cli/version/comparator.d.ts.map +1 -1
  29. package/dist/cli/version/comparator.js +1 -0
  30. package/dist/cli/version/comparator.js.map +1 -1
  31. package/dist/db/client.d.ts +5 -0
  32. package/dist/db/client.d.ts.map +1 -1
  33. package/dist/db/client.js +7 -0
  34. package/dist/db/client.js.map +1 -1
  35. package/dist/db/schema.d.ts +1 -1
  36. package/dist/db/schema.js +1 -1
  37. package/dist/embeddings/openrouter.d.ts.map +1 -1
  38. package/dist/embeddings/openrouter.js +8 -3
  39. package/dist/embeddings/openrouter.js.map +1 -1
  40. package/dist/services/snapshot-manager.d.ts +251 -0
  41. package/dist/services/snapshot-manager.d.ts.map +1 -0
  42. package/dist/services/snapshot-manager.js +541 -0
  43. package/dist/services/snapshot-manager.js.map +1 -0
  44. package/dist/utils/chunking.d.ts +38 -0
  45. package/dist/utils/chunking.d.ts.map +1 -0
  46. package/dist/utils/chunking.js +133 -0
  47. package/dist/utils/chunking.js.map +1 -0
  48. package/dist/utils/encoding.d.ts +24 -0
  49. package/dist/utils/encoding.d.ts.map +1 -0
  50. package/dist/utils/encoding.js +32 -0
  51. package/dist/utils/encoding.js.map +1 -0
  52. package/dist/utils/index.d.ts +8 -0
  53. package/dist/utils/index.d.ts.map +1 -0
  54. package/dist/utils/index.js +8 -0
  55. package/dist/utils/index.js.map +1 -0
  56. package/docs/QUICKSTART.md +1 -1
  57. package/docs/TROUBLESHOOTING.md +51 -76
  58. package/docs/plans/2026-02-09-v3.7.0-database-fixes-and-improvements.md +900 -0
  59. package/docs/plans/2026-02-11-context-engineering-enhancement.md +1402 -0
  60. package/package.json +8 -2
  61. package/src/agent-system/timestamp-tracker.ts +520 -0
  62. package/src/agent-system/todolist-manager.ts +753 -0
  63. package/src/analyzer/intelligent-analyzer.ts +58 -1
  64. package/src/cli/commands/embeddings-refresh.ts +4 -1
  65. package/src/cli/commands/migrate.ts +8 -0
  66. package/src/cli/commands/snapshot.ts +471 -0
  67. package/src/cli/repl/init/wizard.ts +12 -4
  68. package/src/cli/version/comparator.ts +1 -0
  69. package/src/db/client.ts +8 -0
  70. package/src/db/migrations/0016_add_context_system_tables.sql +38 -0
  71. package/src/db/migrations/files/0015_add_sync_state_version_tracking.sql +18 -0
  72. package/src/db/schema.ts +1 -1
  73. package/src/embeddings/openrouter.ts +10 -4
  74. package/src/services/snapshot-manager.ts +719 -0
  75. package/src/utils/chunking.ts +152 -0
  76. package/src/utils/encoding.ts +33 -0
  77. package/src/utils/index.ts +8 -0
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Text Chunking Utility
3
+ *
4
+ * Splits large texts into chunks suitable for embedding generation.
5
+ * Handles token limits, word boundaries, and overlap for context preservation.
6
+ */
7
+ /**
8
+ * Estimate token count for text.
9
+ *
10
+ * Uses a simple heuristic: ~4 characters per token for English text.
11
+ * This is approximate but works well for our use case.
12
+ *
13
+ * @param text - Text to estimate tokens for
14
+ * @returns Estimated token count
15
+ */
16
+ export function estimateTokens(text) {
17
+ if (!text)
18
+ return 0;
19
+ // Remove whitespace for more accurate estimate
20
+ const trimmed = text.trim();
21
+ if (trimmed.length === 0)
22
+ return 0;
23
+ // Rough estimate: 1 token per 4 characters for English text
24
+ // This is a simplification but works well for most cases
25
+ return Math.ceil(trimmed.length / 4);
26
+ }
27
+ /**
28
+ * Split text into chunks that fit within max tokens.
29
+ *
30
+ * Tries to break at word boundaries when possible.
31
+ * Adds overlap between chunks to preserve context.
32
+ *
33
+ * @param text - Text to chunk
34
+ * @param maxTokens - Maximum tokens per chunk (default: 8000 for OpenRouter)
35
+ * @param overlapTokens - Number of tokens to overlap between chunks (default: 0)
36
+ * @returns Array of text chunks
37
+ */
38
+ export function chunkText(text, maxTokens = 8000, overlapTokens = 0) {
39
+ // Handle empty or very short text
40
+ if (!text || text.trim().length === 0) {
41
+ return [''];
42
+ }
43
+ const trimmedText = text.trim();
44
+ const estimatedTokens = estimateTokens(trimmedText);
45
+ // If text is under the limit, return as-is
46
+ if (estimatedTokens <= maxTokens) {
47
+ return [trimmedText];
48
+ }
49
+ const chunks = [];
50
+ const maxChars = maxTokens * 4; // Convert tokens to approximate characters
51
+ const overlapChars = overlapTokens * 4;
52
+ let startIndex = 0;
53
+ let previousEndIndex = 0;
54
+ let loopCount = 0;
55
+ const maxLoops = 1000; // Safety limit to prevent infinite loops
56
+ while (startIndex < trimmedText.length && loopCount < maxLoops) {
57
+ loopCount++;
58
+ // Calculate end index for this chunk
59
+ let endIndex = Math.min(startIndex + maxChars, trimmedText.length);
60
+ // If not the last chunk, try to break at a word boundary
61
+ if (endIndex < trimmedText.length) {
62
+ // Look for word boundary near the end
63
+ const boundaryChars = 200; // Look back up to 200 chars
64
+ const searchStart = Math.max(startIndex, endIndex - boundaryChars);
65
+ const substring = trimmedText.slice(searchStart, endIndex);
66
+ // Try to find line break first, then space, then punctuation
67
+ let breakIndex = -1;
68
+ // Look for last newline in the window
69
+ const lastNewline = substring.lastIndexOf('\n');
70
+ if (lastNewline !== -1) {
71
+ breakIndex = searchStart + lastNewline + 1;
72
+ }
73
+ else {
74
+ // Look for last space in the window
75
+ const lastSpace = substring.lastIndexOf(' ');
76
+ if (lastSpace !== -1) {
77
+ breakIndex = searchStart + lastSpace + 1;
78
+ }
79
+ else {
80
+ // Look for sentence-ending punctuation
81
+ for (let i = substring.length - 1; i >= Math.max(0, substring.length - 100); i--) {
82
+ const char = substring[i];
83
+ if (char === '.' || char === '!' || char === '?') {
84
+ // Make sure it's actually a sentence end (followed by space or end)
85
+ const nextChar = substring[i + 1];
86
+ if (!nextChar || nextChar === ' ' || nextChar === '\n') {
87
+ breakIndex = searchStart + i + 1;
88
+ break;
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ // Use the break index if found, otherwise use the calculated end
95
+ if (breakIndex > startIndex) {
96
+ endIndex = breakIndex;
97
+ }
98
+ }
99
+ // Extract the chunk
100
+ const chunk = trimmedText.slice(startIndex, endIndex);
101
+ chunks.push(chunk);
102
+ // Move to next chunk, accounting for overlap
103
+ if (overlapChars > 0 && endIndex < trimmedText.length) {
104
+ // Only apply overlap if not at the end
105
+ startIndex = Math.max(endIndex - overlapChars, endIndex - maxChars / 2);
106
+ // Ensure we make progress
107
+ if (startIndex <= previousEndIndex) {
108
+ startIndex = endIndex;
109
+ }
110
+ // Also ensure we move forward at least a bit
111
+ if (startIndex >= endIndex) {
112
+ startIndex = endIndex;
113
+ }
114
+ }
115
+ else {
116
+ startIndex = endIndex;
117
+ }
118
+ previousEndIndex = endIndex;
119
+ }
120
+ return chunks;
121
+ }
122
+ /**
123
+ * Chunk text specifically for embedding generation.
124
+ *
125
+ * Uses 8000 token limit (OpenRouter's limit for text-embedding-3-small).
126
+ *
127
+ * @param text - Text to chunk
128
+ * @returns Array of text chunks suitable for embeddings
129
+ */
130
+ export function chunkForEmbedding(text) {
131
+ return chunkText(text, 8000, 100); // 100 token overlap for context
132
+ }
133
+ //# sourceMappingURL=chunking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunking.js","sourceRoot":"","sources":["../../src/utils/chunking.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,CAAC;IAEpB,+CAA+C;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAEnC,4DAA4D;IAC5D,yDAAyD;IACzD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,YAAoB,IAAI,EACxB,gBAAwB,CAAC;IAEzB,kCAAkC;IAClC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAChC,MAAM,eAAe,GAAG,cAAc,CAAC,WAAW,CAAC,CAA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AG,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,EAAE,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC;YAExE,0BAA0B;YAC1B,IAAI,UAAU,IAAI,gBAAgB,EAAE,CAAC;gBACnC,UAAU,GAAG,QAAQ,CAAC;YACxB,CAAC;YAED,6CAA6C;YAC7C,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;gBAC3B,UAAU,GAAG,QAAQ,CAAC;YACxB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,QAAQ,CAAC;QACxB,CAAC;QAED,gBAAgB,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,gCAAgC;AACrE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Encoding Utilities
3
+ *
4
+ * Handles text encoding issues across different platforms.
5
+ */
6
+ /**
7
+ * Strip UTF-8 BOM (Byte Order Mark) from a string.
8
+ *
9
+ * The UTF-8 BOM is the byte sequence EF BB BF (U+FEFF).
10
+ * Some Windows editors add this to the start of files,
11
+ * which can break environment variable parsing.
12
+ *
13
+ * @param str - String that may contain a BOM
14
+ * @returns String with BOM removed if present
15
+ */
16
+ export declare function stripBOM(str: string): string;
17
+ /**
18
+ * Detect if a string has a UTF-8 BOM.
19
+ *
20
+ * @param str - String to check
21
+ * @returns true if BOM is present
22
+ */
23
+ export declare function hasBOM(str: string): boolean;
24
+ //# sourceMappingURL=encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM5C;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3C"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Encoding Utilities
3
+ *
4
+ * Handles text encoding issues across different platforms.
5
+ */
6
+ /**
7
+ * Strip UTF-8 BOM (Byte Order Mark) from a string.
8
+ *
9
+ * The UTF-8 BOM is the byte sequence EF BB BF (U+FEFF).
10
+ * Some Windows editors add this to the start of files,
11
+ * which can break environment variable parsing.
12
+ *
13
+ * @param str - String that may contain a BOM
14
+ * @returns String with BOM removed if present
15
+ */
16
+ export function stripBOM(str) {
17
+ // Check for BOM at position 0
18
+ if (str.charCodeAt(0) === 0xFEFF) {
19
+ return str.slice(1);
20
+ }
21
+ return str;
22
+ }
23
+ /**
24
+ * Detect if a string has a UTF-8 BOM.
25
+ *
26
+ * @param str - String to check
27
+ * @returns true if BOM is present
28
+ */
29
+ export function hasBOM(str) {
30
+ return str.charCodeAt(0) === 0xFEFF;
31
+ }
32
+ //# sourceMappingURL=encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,8BAA8B;IAC9B,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC;AACtC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared Utilities Module
3
+ *
4
+ * Exports all shared utility functions.
5
+ */
6
+ export * from './encoding.js';
7
+ export * from './chunking.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared Utilities Module
3
+ *
4
+ * Exports all shared utility functions.
5
+ */
6
+ export * from './encoding.js';
7
+ export * from './chunking.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -81,7 +81,7 @@ your-project/
81
81
  ## Next Steps
82
82
 
83
83
  1. **Configure Claude Desktop with MCP** → [MCP Quick Start](MCP_QUICKSTART.md)
84
- 2. **Learn about cross-tool sync** → [Migration Guide](MIGRATE_TO_UNIFIED.md)
84
+ 2. **Learn about cross-tool sync** → [Migration Guide](ARCHIVE/MIGRATE_TO_UNIFIED.md)
85
85
  3. **Troubleshoot issues** → [Troubleshooting](TROUBLESHOOTING.md)
86
86
 
87
87
  ## How It Works
@@ -1,6 +1,6 @@
1
1
  # Troubleshooting Guide
2
2
 
3
- Common issues and solutions for Claude Context Engineering.
3
+ Common issues and solutions for K0ntext (v3.8.0).
4
4
 
5
5
  ---
6
6
 
@@ -9,17 +9,14 @@ Common issues and solutions for Claude Context Engineering.
9
9
  Run diagnostics to automatically detect issues:
10
10
 
11
11
  ```bash
12
- # Using the unified package
12
+ # Check database and indexing status
13
13
  k0ntext stats
14
14
 
15
- # Or using the legacy tools (deprecated)
16
- npx .k0ntext/tools/bin/claude-context.js diagnose
17
- ```
18
-
19
- To attempt auto-fix:
15
+ # Validate context files
16
+ k0ntext validate
20
17
 
21
- ```bash
22
- npx .k0ntext/tools/bin/claude-context.js diagnose --fix
18
+ # Check for documentation drift
19
+ k0ntext drift-detect
23
20
  ```
24
21
 
25
22
  ---
@@ -41,12 +38,12 @@ npx .k0ntext/tools/bin/claude-context.js diagnose --fix
41
38
  ### TSG-001: CLI Tools Won't Install
42
39
 
43
40
  **Symptoms:**
44
- - `npm install` fails in `.k0ntext/tools/`
41
+ - `npm install -g k0ntext` fails
45
42
  - Missing dependencies errors
46
43
 
47
44
  **Diagnosis:**
48
45
  ```bash
49
- node --version # Should be 16+
46
+ node --version # Should be 18+
50
47
  npm --version # Should be 8+
51
48
  ```
52
49
 
@@ -62,13 +59,10 @@ nvm use 18
62
59
  **B. Clear npm cache**
63
60
  ```bash
64
61
  npm cache clean --force
65
- cd .k0ntext/tools && rm -rf node_modules && npm install
62
+ npm install -g k0ntext
66
63
  ```
67
64
 
68
- **C. Use yarn instead**
69
- ```bash
70
- cd .k0ntext/tools && yarn install
71
- ```
65
+ **C. Windows users** - Use Node.js LTS (v18, v20, v22) for pre-built SQLite binaries. Non-LTS versions may require Visual Studio Build Tools.
72
66
 
73
67
  ---
74
68
 
@@ -76,20 +70,18 @@ cd .k0ntext/tools && yarn install
76
70
 
77
71
  **Symptoms:**
78
72
  - "AI_CONTEXT.md not found" errors
79
- - Missing `.k0ntext/` directory
73
+ - Missing `.claude/` directory
80
74
 
81
75
  **Solutions:**
82
76
 
83
- **A. Verify copy was complete**
77
+ **A. Re-initialize project**
84
78
  ```bash
85
- ls -la .k0ntext/
86
- # Should contain: agents/, commands/, context/, indexes/, settings.json, README.md
79
+ k0ntext init
87
80
  ```
88
81
 
89
- **B. Re-copy from template**
82
+ **B. Sync templates manually**
90
83
  ```bash
91
- cp -r /path/to/template/.claude ./.claude
92
- cp /path/to/template/AI_CONTEXT.md ./AI_CONTEXT.md
84
+ k0ntext sync-templates
93
85
  ```
94
86
 
95
87
  ---
@@ -181,7 +173,7 @@ The agent should merge related workflows. If not:
181
173
 
182
174
  **A. Resume initialization**
183
175
  ```bash
184
- npx .k0ntext/tools/bin/claude-context.js init --resume
176
+ k0ntext init
185
177
  # Or in Claude Code:
186
178
  @context-engineer "Resume initialization"
187
179
  ```
@@ -189,7 +181,7 @@ npx .k0ntext/tools/bin/claude-context.js init --resume
189
181
  **B. Start fresh**
190
182
  ```bash
191
183
  rm .k0ntext/INIT_PROGRESS.json
192
- @context-engineer "Initialize context engineering for this repository"
184
+ k0ntext init
193
185
  ```
194
186
 
195
187
  ---
@@ -261,18 +253,18 @@ Search for the specific function: [function name] in [file pattern]
261
253
 
262
254
  **Diagnosis:**
263
255
  ```bash
264
- npx .k0ntext/tools/bin/claude-context.js validate --schema
256
+ k0ntext validate --strict
265
257
  ```
266
258
 
267
259
  **Solutions:**
268
260
 
269
- **A. Auto-fix with defaults**
261
+ **A. Auto-fix with validation**
270
262
  ```bash
271
- npx .k0ntext/tools/bin/claude-context.js diagnose --fix
263
+ k0ntext validate --fix
272
264
  ```
273
265
 
274
266
  **B. Manual fix**
275
- Compare your `settings.json` with the schema in `.k0ntext/schemas/settings.schema.json`.
267
+ Compare your `settings.json` with the schema in `.claude/schemas/settings.schema.json`.
276
268
 
277
269
  ---
278
270
 
@@ -284,7 +276,7 @@ Compare your `settings.json` with the schema in `.k0ntext/schemas/settings.schem
284
276
 
285
277
  **Diagnosis:**
286
278
  ```bash
287
- npx .k0ntext/tools/bin/claude-context.js validate --links
279
+ k0ntext validate
288
280
  ```
289
281
 
290
282
  **Solutions:**
@@ -293,7 +285,7 @@ npx .k0ntext/tools/bin/claude-context.js validate --links
293
285
  After refactoring, update documentation:
294
286
  ```bash
295
287
  # Find all references to old path
296
- grep -r "old/path" .k0ntext/
288
+ grep -r "old/path" .claude/
297
289
  # Update to new path
298
290
  ```
299
291
 
@@ -312,7 +304,7 @@ grep -r "old/path" .k0ntext/
312
304
 
313
305
  **Diagnosis:**
314
306
  ```bash
315
- npx .k0ntext/tools/bin/claude-context.js validate --lines --threshold 60
307
+ k0ntext validate
316
308
  ```
317
309
 
318
310
  **Solutions:**
@@ -340,7 +332,7 @@ Line numbers within ±10 lines are acceptable. Focus on function names as anchor
340
332
 
341
333
  **Diagnosis:**
342
334
  ```bash
343
- npx .k0ntext/tools/bin/claude-context.js validate --placeholders
335
+ k0ntext validate
344
336
  ```
345
337
 
346
338
  **Solutions:**
@@ -367,7 +359,7 @@ Search and replace remaining placeholders in AI_CONTEXT.md with actual values.
367
359
 
368
360
  **A. Check agent exists**
369
361
  ```bash
370
- ls .k0ntext/agents/
362
+ ls .claude/agents/
371
363
  ```
372
364
 
373
365
  **B. Use correct invocation**
@@ -391,7 +383,7 @@ ls .k0ntext/agents/
391
383
 
392
384
  **A. Check command exists**
393
385
  ```bash
394
- ls .k0ntext/commands/
386
+ ls .claude/commands/
395
387
  ```
396
388
 
397
389
  **B. Verify command is registered**
@@ -420,12 +412,9 @@ Check `settings.json` includes the command:
420
412
  @context-engineer "Initialize focusing on src/ directory only"
421
413
  ```
422
414
 
423
- **B. Increase timeout**
424
- Edit `settings.json`:
425
- ```json
426
- "rpi_workflow": {
427
- "research_timeout_minutes": 60
428
- }
415
+ **B. Skip intelligent analysis**
416
+ ```bash
417
+ k0ntext init --no-intelligent
429
418
  ```
430
419
 
431
420
  ---
@@ -438,13 +427,9 @@ Edit `settings.json`:
438
427
 
439
428
  **Solutions:**
440
429
 
441
- **A. Validate specific checks only**
430
+ **A. Use quick validation**
442
431
  ```bash
443
- # Just schema
444
- npx .k0ntext/tools/bin/claude-context.js validate --schema
445
-
446
- # Just structure
447
- npx .k0ntext/tools/bin/claude-context.js validate --structure
432
+ k0ntext validate
448
433
  ```
449
434
 
450
435
  **B. Skip external link checking**
@@ -462,19 +447,20 @@ Ensure this is disabled (default):
462
447
  ### TSG-060: MCP Server Won't Start
463
448
 
464
449
  **Symptoms:**
465
- - `mcp:start` exits immediately
450
+ - `k0ntext mcp` exits immediately
466
451
  - "Database not found" or "Missing OPENROUTER_API_KEY"
467
452
 
468
453
  **Diagnosis:**
469
454
  ```bash
470
- npx k0ntext mcp:status
455
+ k0ntext stats
471
456
  ```
472
457
 
473
458
  **Solutions:**
474
459
 
475
460
  **A. Initialize the database first**
476
461
  ```bash
477
- npx k0ntext mcp:init
462
+ k0ntext init
463
+ k0ntext index
478
464
  ```
479
465
 
480
466
  **B. Set the OpenRouter API key**
@@ -482,9 +468,9 @@ npx k0ntext mcp:init
482
468
  export OPENROUTER_API_KEY="your-api-key-here"
483
469
  ```
484
470
 
485
- **C. Start the server again**
471
+ **C. Start the server**
486
472
  ```bash
487
- npx k0ntext mcp:start
473
+ k0ntext mcp
488
474
  ```
489
475
 
490
476
  ---
@@ -492,25 +478,21 @@ npx k0ntext mcp:start
492
478
  ### TSG-061: MCP Sync Exports Missing
493
479
 
494
480
  **Symptoms:**
495
- - `mcp:sync` finishes without generating files
481
+ - Sync finishes without generating files
496
482
  - Output files remain unchanged
497
483
 
498
- **Diagnosis:**
499
- ```bash
500
- npx k0ntext mcp:sync --status
501
- ```
502
-
503
484
  **Solutions:**
504
485
 
505
- **A. Force overwrite managed files**
486
+ **A. Force sync**
506
487
  ```bash
507
- npx k0ntext mcp:sync --force
488
+ k0ntext sync --force
508
489
  ```
509
490
 
510
491
  **B. Recreate database index**
511
492
  ```bash
512
493
  rm -f .k0ntext.db
513
- npx k0ntext mcp:init
494
+ k0ntext init
495
+ k0ntext index
514
496
  ```
515
497
 
516
498
  **C. Ensure database exists**
@@ -520,8 +502,6 @@ ls -la .k0ntext.db
520
502
 
521
503
  ---
522
504
 
523
- ## New Error Codes (v3.0.0)
524
-
525
505
  ### TSG-062: Generate Command Failed
526
506
 
527
507
  **Error:** `Failed to generate context files`
@@ -566,19 +546,18 @@ k0ntext sync --from claude
566
546
 
567
547
  ---
568
548
 
569
- ### TSG-064: MCP Server Not Starting
549
+ ### TSG-064: MCP Server Build Issues
570
550
 
571
551
  **Error:** `MCP server failed to start`
572
552
 
573
553
  **Diagnosis:**
574
- 1. Verify build: `cd packages/ai-context && npm run build`
575
- 2. Check port availability
554
+ 1. Verify build: `npm run build`
555
+ 2. Check that database file exists
576
556
  3. Verify OpenRouter API key
577
557
 
578
558
  **Solution:**
579
559
  ```bash
580
560
  # Rebuild
581
- cd packages/ai-context
582
561
  npm run build
583
562
 
584
563
  # Test MCP server
@@ -591,21 +570,17 @@ npm run start:mcp
591
570
 
592
571
  If your issue isn't listed:
593
572
 
594
- 1. **Run full diagnostics:**
595
- ```bash
596
- npx .k0ntext/tools/bin/claude-context.js diagnose --verbose
597
- ```
598
-
599
- 2. **Check logs:**
573
+ 1. **Run diagnostics:**
600
574
  ```bash
601
- cat .k0ntext/logs/claude.log
575
+ k0ntext stats
576
+ k0ntext validate -v
602
577
  ```
603
578
 
604
- 3. **Report an issue:**
579
+ 2. **Report an issue:**
605
580
  https://github.com/SireJeff/k0ntext/issues
606
581
 
607
582
  Include:
608
583
  - Error message
609
- - Diagnostic output
584
+ - Diagnostic output (`k0ntext stats`)
610
585
  - Tech stack
611
586
  - Steps to reproduce