k0ntext 3.0.0 → 3.1.1
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 +237 -5
- package/dist/agents/drift-agent.d.ts +114 -0
- package/dist/agents/drift-agent.d.ts.map +1 -0
- package/dist/agents/drift-agent.js +324 -0
- package/dist/agents/drift-agent.js.map +1 -0
- package/dist/agents/fact-check-agent.d.ts +103 -0
- package/dist/agents/fact-check-agent.d.ts.map +1 -0
- package/dist/agents/fact-check-agent.js +273 -0
- package/dist/agents/fact-check-agent.js.map +1 -0
- package/dist/cli/commands/cleanup.d.ts.map +1 -1
- package/dist/cli/commands/cleanup.js +77 -5
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/cross-sync.d.ts +10 -0
- package/dist/cli/commands/cross-sync.d.ts.map +1 -0
- package/dist/cli/commands/cross-sync.js +398 -0
- package/dist/cli/commands/cross-sync.js.map +1 -0
- package/dist/cli/commands/drift-detect.d.ts +10 -0
- package/dist/cli/commands/drift-detect.d.ts.map +1 -0
- package/dist/cli/commands/drift-detect.js +120 -0
- package/dist/cli/commands/drift-detect.js.map +1 -0
- package/dist/cli/commands/fact-check.d.ts +10 -0
- package/dist/cli/commands/fact-check.d.ts.map +1 -0
- package/dist/cli/commands/fact-check.js +105 -0
- package/dist/cli/commands/fact-check.js.map +1 -0
- package/dist/cli/commands/hooks.d.ts +13 -0
- package/dist/cli/commands/hooks.d.ts.map +1 -0
- package/dist/cli/commands/hooks.js +216 -0
- package/dist/cli/commands/hooks.js.map +1 -0
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +278 -12
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/index.js +86 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/config/models.d.ts +112 -0
- package/dist/config/models.d.ts.map +1 -0
- package/dist/config/models.js +116 -0
- package/dist/config/models.js.map +1 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +2 -2
- package/dist/db/client.js.map +1 -1
- package/dist/embeddings/openrouter.d.ts +8 -0
- package/dist/embeddings/openrouter.d.ts.map +1 -1
- package/dist/embeddings/openrouter.js +16 -6
- package/dist/embeddings/openrouter.js.map +1 -1
- package/package.json +2 -2
- package/src/agents/drift-agent.ts +430 -0
- package/src/agents/fact-check-agent.ts +348 -0
- package/src/cli/commands/cleanup.ts +86 -5
- package/src/cli/commands/cross-sync.ts +473 -0
- package/src/cli/commands/drift-detect.ts +139 -0
- package/src/cli/commands/fact-check.ts +127 -0
- package/src/cli/commands/hooks.ts +244 -0
- package/src/cli/generate.ts +286 -12
- package/src/cli/index.ts +102 -9
- package/src/config/models.ts +136 -0
- package/src/db/client.ts +4 -3
- package/src/embeddings/openrouter.ts +19 -7
- 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/templates/map/claude.md +82 -0
- package/templates/map/cline.md +37 -0
- package/templates/map/copilot.md +31 -0
- package/templates/map/cursor.md +39 -0
- package/templates/map/gemini.md +47 -0
package/README.md
CHANGED
|
@@ -9,6 +9,38 @@
|
|
|
9
9
|
|
|
10
10
|
Universal AI context engineering for Claude, GitHub Copilot, Cline, Cursor, Windsurf, Aider, Continue, Antigravity, and Gemini with OpenRouter-powered intelligent analysis.
|
|
11
11
|
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
- [Quick Start](#-quick-start-30-seconds)
|
|
15
|
+
- [Zero-to-Hero Workflow](#-zero-to-hero-workflow)
|
|
16
|
+
- [Windows Support](#-windows-support)
|
|
17
|
+
- [Features Overview](#-features-overview)
|
|
18
|
+
- [Intelligent Analysis](#-intelligent-analysis)
|
|
19
|
+
- [Semantic Search](#-semantic-search)
|
|
20
|
+
- [Cross-Tool Sync](#-cross-tool-sync)
|
|
21
|
+
- [Git Hooks Automation](#-git-hooks-automation-v310)
|
|
22
|
+
- [Drift Detection](#-drift-detection-v310)
|
|
23
|
+
- [Fact-Checking](#-fact-checking-v310)
|
|
24
|
+
- [Map-Based Context](#-map-based-context-v310)
|
|
25
|
+
- [MCP Server](#-mcp-server)
|
|
26
|
+
- [Complete CLI](#-complete-cli-18-commands)
|
|
27
|
+
- [Smart Agents](#-smart-agents)
|
|
28
|
+
- [SQLite Storage](#-sqlite-storage)
|
|
29
|
+
- [Complete CLI Reference](#-complete-cli-reference)
|
|
30
|
+
- [Core Commands](#core-commands)
|
|
31
|
+
- [v3.1.0 New Commands](#v310-new-commands)
|
|
32
|
+
- [Git Hooks Workflow](#-git-hooks-workflow-v310)
|
|
33
|
+
- [MCP Server Usage](#-mcp-server-usage)
|
|
34
|
+
- [Supported AI Tools](#-supported-ai-tools)
|
|
35
|
+
- [Configuration](#-configuration)
|
|
36
|
+
- [Architecture](#-architecture)
|
|
37
|
+
- [Development](#-development)
|
|
38
|
+
- [Performance Monitoring](#-performance-monitoring)
|
|
39
|
+
- [Troubleshooting](#-troubleshooting)
|
|
40
|
+
- [Community](#-community)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
12
44
|
## 🚀 Quick Start (30 Seconds)
|
|
13
45
|
|
|
14
46
|
```bash
|
|
@@ -38,7 +70,7 @@ k0ntext index
|
|
|
38
70
|
# 3. Generate context files
|
|
39
71
|
k0ntext generate
|
|
40
72
|
|
|
41
|
-
# 4. Start MCP server
|
|
73
|
+
# 4. Start MCP server (auto-configured)
|
|
42
74
|
k0ntext mcp
|
|
43
75
|
```
|
|
44
76
|
|
|
@@ -73,6 +105,7 @@ K0ntext uses native SQLite extensions for high-performance vector search.
|
|
|
73
105
|
- Tech stack detection and documentation
|
|
74
106
|
- Workflow discovery and categorization
|
|
75
107
|
- Automatic context generation
|
|
108
|
+
- **Centralized model configuration** (v3.1.0) - Single source of truth for all AI operations
|
|
76
109
|
|
|
77
110
|
### 🔍 Semantic Search
|
|
78
111
|
- Vector database (sqlite-vec) for intelligent code retrieval
|
|
@@ -85,14 +118,61 @@ K0ntext uses native SQLite extensions for high-performance vector search.
|
|
|
85
118
|
- Automatic synchronization between tool configurations
|
|
86
119
|
- Change detection with SHA256 hashing
|
|
87
120
|
- Sync status monitoring
|
|
121
|
+
- **Intelligent cross-sync** (v3.1.0) - AI-powered propagation of changes across tools
|
|
122
|
+
|
|
123
|
+
### 🤖 Git Hooks Automation (v3.1.0)
|
|
124
|
+
- **Pre-commit workflow** - Automatic context maintenance
|
|
125
|
+
- Drift detection on every commit
|
|
126
|
+
- Automatic cross-sync when drift detected
|
|
127
|
+
- Updated context files auto-added to commits
|
|
128
|
+
|
|
129
|
+
### 🎯 Drift Detection (v3.1.0)
|
|
130
|
+
- **AI-powered semantic analysis** - Detect when documentation diverges from code
|
|
131
|
+
- Replaces hash-based checks with intelligent understanding
|
|
132
|
+
- Severity-based reporting (high/medium/low)
|
|
133
|
+
- Automatic fix suggestions
|
|
134
|
+
|
|
135
|
+
### 📋 Fact-Checking (v3.1.0)
|
|
136
|
+
- Validate documentation accuracy against codebase
|
|
137
|
+
- Identify outdated APIs, wrong file paths, missing dependencies
|
|
138
|
+
- Confidence scoring for each claim
|
|
139
|
+
|
|
140
|
+
### 🗺️ Map-Based Context (v3.1.0)
|
|
141
|
+
- Concise, structured context files
|
|
142
|
+
- Reduce hallucination through precise references
|
|
143
|
+
- Alternative to verbose documentation format
|
|
88
144
|
|
|
89
145
|
### 🤖 MCP Server
|
|
146
|
+
- **Auto-Configuration** (v3.1.1) - MCP server automatically configured in `.claude/settings.json` on init
|
|
147
|
+
- **10 Tools:** search_context, get_item, add_knowledge, analyze, get_tool_configs, query_graph, get_stats
|
|
148
|
+
- **6 Prompts:** context-engineer, core-architect, api-developer, database-ops, integration-hub, deployment-ops
|
|
149
|
+
- Real-time context access for AI assistants
|
|
150
|
+
- Knowledge graph traversal
|
|
90
151
|
- **10 Tools:** search_context, get_item, add_knowledge, analyze, get_tool_configs, query_graph, get_stats
|
|
91
152
|
- **6 Prompts:** context-engineer, core-architect, api-developer, database-ops, integration-hub, deployment-ops
|
|
92
153
|
- Real-time context access for AI assistants
|
|
93
154
|
- Knowledge graph traversal
|
|
94
155
|
|
|
95
|
-
### 🛠️ Complete CLI (
|
|
156
|
+
### 🛠️ Complete CLI (18 Commands)
|
|
157
|
+
- `init` - Initialize with intelligent analysis **(auto-configures MCP in v3.1.1)**
|
|
158
|
+
- `generate` - Generate context files for all tools
|
|
159
|
+
- `mcp` - Start MCP server
|
|
160
|
+
- `sync` - Sync across AI tools
|
|
161
|
+
- `cleanup` - Clean up conflicting tool folders
|
|
162
|
+
- `validate` - Validate context files
|
|
163
|
+
- `export` - Export database
|
|
164
|
+
- `import` - Import from exports
|
|
165
|
+
- `performance` - Show performance metrics
|
|
166
|
+
- `watch` - Auto-index file changes
|
|
167
|
+
- `index` - Index codebase
|
|
168
|
+
- `search` - Search indexed content
|
|
169
|
+
- `stats` - View database statistics
|
|
170
|
+
- **`drift-detect`** - AI-powered documentation drift detection (v3.1.0)
|
|
171
|
+
- **`cross-sync`** - Intelligent sync across all AI tools (v3.1.0)
|
|
172
|
+
- **`hooks`** - Git hooks management (install/uninstall/status) (v3.1.0)
|
|
173
|
+
- **`fact-check`** - Validate documentation accuracy (v3.1.0)
|
|
174
|
+
- `generate --map` - Generate concise map-based context files (v3.1.0)
|
|
175
|
+
- **CLI documentation in all templates** (v3.1.1) - Agent and command templates now include k0ntext CLI usage guidance
|
|
96
176
|
- `init` - Initialize with intelligent analysis
|
|
97
177
|
- `generate` - Generate context files for all tools
|
|
98
178
|
- `mcp` - Start MCP server
|
|
@@ -106,10 +186,17 @@ K0ntext uses native SQLite extensions for high-performance vector search.
|
|
|
106
186
|
- `index` - Index codebase
|
|
107
187
|
- `search` - Search indexed content
|
|
108
188
|
- `stats` - View database statistics
|
|
189
|
+
- **`drift-detect`** - AI-powered documentation drift detection
|
|
190
|
+
- **`cross-sync`** - Intelligent sync across all AI tools
|
|
191
|
+
- **`hooks`** - Git hooks management (install/uninstall/status)
|
|
192
|
+
- **`fact-check`** - Validate documentation accuracy
|
|
193
|
+
- `generate --map` - Generate concise map-based context files
|
|
109
194
|
|
|
110
195
|
### 📊 Smart Agents
|
|
111
196
|
- **CleanupAgent** - Remove conflicting AI tool folders (.cursor, .windsurf, .cline, etc.)
|
|
112
197
|
- **PerformanceMonitorAgent** - Track database performance and suggest optimizations
|
|
198
|
+
- **DriftAgent** (v3.1.0) - AI-powered documentation drift detection
|
|
199
|
+
- **FactCheckAgent** (v3.1.0) - Validate documentation accuracy against codebase
|
|
113
200
|
|
|
114
201
|
### 🗃️ SQLite Storage
|
|
115
202
|
- Persistent database with SHA256 change detection
|
|
@@ -159,6 +246,7 @@ k0ntext generate -v
|
|
|
159
246
|
**Options:**
|
|
160
247
|
- `-ai, --ai <tools>` - Specific tools (comma-separated)
|
|
161
248
|
- `--force` - Force regenerate all files
|
|
249
|
+
- `--map` - Use concise map-based format (new in v3.1.0)
|
|
162
250
|
- `-v, --verbose` - Show detailed output
|
|
163
251
|
|
|
164
252
|
#### `k0ntext mcp`
|
|
@@ -218,6 +306,7 @@ k0ntext cleanup -v
|
|
|
218
306
|
**Options:**
|
|
219
307
|
- `--dry-run` - Show what would be removed
|
|
220
308
|
- `--keep <folders>` - Folders to keep (comma-separated)
|
|
309
|
+
- `--ai` - Use AI to intelligently analyze which folders can be safely removed (new in v3.1.0)
|
|
221
310
|
- `-v, --verbose` - Show detailed output
|
|
222
311
|
|
|
223
312
|
#### `k0ntext validate`
|
|
@@ -362,11 +451,153 @@ k0ntext stats
|
|
|
362
451
|
k0ntext stats | grep "Context Items"
|
|
363
452
|
```
|
|
364
453
|
|
|
454
|
+
### v3.1.0 New Commands
|
|
455
|
+
|
|
456
|
+
#### `k0ntext drift-detect`
|
|
457
|
+
AI-powered documentation drift detection using semantic analysis.
|
|
458
|
+
|
|
459
|
+
```bash
|
|
460
|
+
# Detect drift in all context files
|
|
461
|
+
k0ntext drift-detect
|
|
462
|
+
|
|
463
|
+
# Detect drift in specific paths
|
|
464
|
+
k0ntext drift-detect -p CLAUDE.md,.cursorrules
|
|
465
|
+
|
|
466
|
+
# Check up to 20 files
|
|
467
|
+
k0ntext drift-detect --max-files 20
|
|
468
|
+
|
|
469
|
+
# Strict mode (fails on any drift)
|
|
470
|
+
k0ntext drift-detect --strict
|
|
471
|
+
|
|
472
|
+
# Verbose output
|
|
473
|
+
k0ntext drift-detect -v
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
**Options:**
|
|
477
|
+
- `--fix` - Automatically fix detected drift (experimental)
|
|
478
|
+
- `--strict` - Fail on any drift detected
|
|
479
|
+
- `-p, --paths <paths>` - Comma-separated paths to check
|
|
480
|
+
- `--max-files <number>` - Maximum files to check (default: 50)
|
|
481
|
+
- `--model <model>` - Override model (not recommended)
|
|
482
|
+
- `-v, --verbose` - Show detailed output
|
|
483
|
+
|
|
484
|
+
#### `k0ntext cross-sync`
|
|
485
|
+
Intelligently synchronize context across all AI tools after drift detection.
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Sync all affected files
|
|
489
|
+
k0ntext cross-sync
|
|
490
|
+
|
|
491
|
+
# Dry run to see what would be synced
|
|
492
|
+
k0ntext cross-sync --dry-run
|
|
493
|
+
|
|
494
|
+
# Sync to specific tools only
|
|
495
|
+
k0ntext cross-sync --to claude,cursor
|
|
496
|
+
|
|
497
|
+
# Sync from specific files
|
|
498
|
+
k0ntext cross-sync --affected CLAUDE.md,.cursorrules
|
|
499
|
+
|
|
500
|
+
# Verbose output with details
|
|
501
|
+
k0ntext cross-sync -v
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**Options:**
|
|
505
|
+
- `--dry-run` - Show what would be synced without making changes
|
|
506
|
+
- `--from <tool>` - Sync only from specific tool
|
|
507
|
+
- `--to <tools>` - Sync only to specific tools (comma-separated)
|
|
508
|
+
- `--affected <files>` - Comma-separated list of affected files
|
|
509
|
+
- `-v, --verbose` - Show detailed sync output
|
|
510
|
+
|
|
511
|
+
#### `k0ntext hooks`
|
|
512
|
+
Manage git hooks for automatic context synchronization.
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
# Install git hooks
|
|
516
|
+
k0ntext hooks install
|
|
517
|
+
|
|
518
|
+
# Install with force (overwrite existing)
|
|
519
|
+
k0ntext hooks install -f
|
|
520
|
+
|
|
521
|
+
# Uninstall git hooks
|
|
522
|
+
k0ntext hooks uninstall
|
|
523
|
+
|
|
524
|
+
# Check hooks status
|
|
525
|
+
k0ntext hooks status
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**Subcommands:**
|
|
529
|
+
- `install` - Install pre-commit hook for automatic workflow
|
|
530
|
+
- `uninstall` - Remove installed hooks
|
|
531
|
+
- `status` - Show hook installation status
|
|
532
|
+
|
|
533
|
+
**Install Options:**
|
|
534
|
+
- `-f, --force` - Overwrite existing hooks
|
|
535
|
+
- `--skip-backup` - Skip backing up existing hooks
|
|
536
|
+
|
|
537
|
+
#### `k0ntext fact-check [files...]`
|
|
538
|
+
Validate documentation accuracy using AI analysis.
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
# Check all documentation files
|
|
542
|
+
k0ntext fact-check
|
|
543
|
+
|
|
544
|
+
# Check specific files
|
|
545
|
+
k0ntext fact-check CLAUDE.md .cursorrules
|
|
546
|
+
|
|
547
|
+
# Set minimum confidence threshold
|
|
548
|
+
k0ntext fact-check --min-confidence 0.7
|
|
549
|
+
|
|
550
|
+
# Verbose output
|
|
551
|
+
k0ntext fact-check -v
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**Options:**
|
|
555
|
+
- `--fix` - Automatically fix detected issues (experimental)
|
|
556
|
+
- `-v, --verbose` - Show detailed output
|
|
557
|
+
- `--min-confidence <number>` - Minimum confidence to report (0-1, default: 0.5)
|
|
558
|
+
|
|
559
|
+
### Git Hooks Workflow (v3.1.0)
|
|
560
|
+
|
|
561
|
+
When you install hooks with `k0ntext hooks install`, the pre-commit hook automatically:
|
|
562
|
+
|
|
563
|
+
1. **Autosync** - Sync context from source of truth
|
|
564
|
+
2. **Validate** - Check for context errors
|
|
565
|
+
3. **Drift Detect** - AI-powered drift detection
|
|
566
|
+
4. **Cross-Sync** - Update all AI tool contexts if drift found
|
|
567
|
+
5. **Auto-Add** - Include updated context files in commit
|
|
568
|
+
|
|
569
|
+
**Skip hooks temporarily:**
|
|
570
|
+
```bash
|
|
571
|
+
K0NTEXT_SKIP_HOOKS=1 git commit -m "message"
|
|
572
|
+
# or
|
|
573
|
+
git commit --no-verify -m "message"
|
|
574
|
+
```
|
|
575
|
+
|
|
365
576
|
## 🤖 MCP Server Usage
|
|
366
577
|
|
|
578
|
+
### Auto-Configuration (v3.1.1)
|
|
579
|
+
|
|
580
|
+
When you run `k0ntext init`, the MCP server is **automatically configured** in `.claude/settings.json`:
|
|
581
|
+
|
|
582
|
+
```json
|
|
583
|
+
{
|
|
584
|
+
"mcpServers": {
|
|
585
|
+
"k0ntext": {
|
|
586
|
+
"command": "npx",
|
|
587
|
+
"args": ["k0ntext", "mcp"],
|
|
588
|
+
"env": {
|
|
589
|
+
"K0NTEXT_PROJECT_ROOT": "${projectFolder}"
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
**Manual setup is no longer required!** The MCP server works immediately after initialization.
|
|
597
|
+
|
|
367
598
|
### Start the Server
|
|
368
599
|
```bash
|
|
369
|
-
# Start MCP server
|
|
600
|
+
# Start MCP server (auto-configured)
|
|
370
601
|
k0ntext mcp
|
|
371
602
|
```
|
|
372
603
|
|
|
@@ -467,11 +698,12 @@ Each AI tool has its own configuration file path:
|
|
|
467
698
|
```
|
|
468
699
|
k0ntext/
|
|
469
700
|
├── src/ # TypeScript source
|
|
470
|
-
│ ├── cli/ # CLI commands (
|
|
701
|
+
│ ├── cli/ # CLI commands (18 commands)
|
|
702
|
+
│ ├── config/ # Centralized configuration (v3.1.0)
|
|
471
703
|
│ ├── db/ # SQLite database client
|
|
472
704
|
│ ├── analyzer/ # Intelligent codebase analysis
|
|
473
705
|
│ ├── embeddings/ # OpenRouter integration
|
|
474
|
-
│ ├── agents/ # Smart agents (Cleanup, Performance)
|
|
706
|
+
│ ├── agents/ # Smart agents (Cleanup, Performance, Drift, FactCheck)
|
|
475
707
|
│ └── mcp.ts # MCP server implementation
|
|
476
708
|
├── agents/ # Agent definitions
|
|
477
709
|
├── skills/ # RPI workflow skills
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drift Detection Agent
|
|
3
|
+
*
|
|
4
|
+
* Uses AI to detect when documentation drifts from the actual codebase.
|
|
5
|
+
* This is the core of intelligent drift detection for k0ntext v3.1.0.
|
|
6
|
+
*
|
|
7
|
+
* @version 3.1.0
|
|
8
|
+
*/
|
|
9
|
+
import { OpenRouterClient } from '../embeddings/openrouter.js';
|
|
10
|
+
/**
|
|
11
|
+
* A detected drift issue
|
|
12
|
+
*/
|
|
13
|
+
export interface DriftIssue {
|
|
14
|
+
/** The file where drift was detected */
|
|
15
|
+
file: string;
|
|
16
|
+
/** Severity level */
|
|
17
|
+
severity: 'low' | 'medium' | 'high';
|
|
18
|
+
/** What the documentation says */
|
|
19
|
+
expected: string;
|
|
20
|
+
/** What the actual codebase has */
|
|
21
|
+
actual: string;
|
|
22
|
+
/** Suggested fix (optional) */
|
|
23
|
+
suggestion?: string;
|
|
24
|
+
/** Line number where drift occurs (optional) */
|
|
25
|
+
line?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Result of drift detection
|
|
29
|
+
*/
|
|
30
|
+
export interface DriftResult {
|
|
31
|
+
/** All detected drifts */
|
|
32
|
+
drifts: DriftIssue[];
|
|
33
|
+
/** Number of drifts automatically fixed */
|
|
34
|
+
fixed: number;
|
|
35
|
+
/** Files checked */
|
|
36
|
+
filesChecked: number;
|
|
37
|
+
/** Time taken in milliseconds */
|
|
38
|
+
duration: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration for the drift agent
|
|
42
|
+
*/
|
|
43
|
+
export interface DriftAgentConfig {
|
|
44
|
+
/** OpenRouter client for AI analysis */
|
|
45
|
+
openRouter: OpenRouterClient;
|
|
46
|
+
/** Model override (not recommended) */
|
|
47
|
+
model?: string;
|
|
48
|
+
/** Whether to fail on any drift */
|
|
49
|
+
strict?: boolean;
|
|
50
|
+
/** Project root directory */
|
|
51
|
+
projectRoot: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Drift Detection Agent
|
|
55
|
+
*
|
|
56
|
+
* Analyzes documentation files and compares them against the actual
|
|
57
|
+
* codebase to detect discrepancies using AI semantic analysis.
|
|
58
|
+
*/
|
|
59
|
+
export declare class DriftAgent {
|
|
60
|
+
private openRouter;
|
|
61
|
+
private model;
|
|
62
|
+
private strict;
|
|
63
|
+
private projectRoot;
|
|
64
|
+
constructor(config: DriftAgentConfig);
|
|
65
|
+
/**
|
|
66
|
+
* Detect drift across all context files
|
|
67
|
+
*/
|
|
68
|
+
detectDrift(options: {
|
|
69
|
+
paths?: string[];
|
|
70
|
+
autoFix?: boolean;
|
|
71
|
+
maxFiles?: number;
|
|
72
|
+
}): Promise<DriftResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Check a single file for drift
|
|
75
|
+
*/
|
|
76
|
+
private checkFileForDrift;
|
|
77
|
+
/**
|
|
78
|
+
* Get the drift detection system prompt
|
|
79
|
+
*/
|
|
80
|
+
private getDriftDetectionPrompt;
|
|
81
|
+
/**
|
|
82
|
+
* Build the drift analysis prompt for a specific file
|
|
83
|
+
*/
|
|
84
|
+
private buildDriftAnalysisPrompt;
|
|
85
|
+
/**
|
|
86
|
+
* Parse the drift detection response
|
|
87
|
+
*/
|
|
88
|
+
private parseDriftResponse;
|
|
89
|
+
/**
|
|
90
|
+
* Get relevant source code samples for comparison
|
|
91
|
+
*/
|
|
92
|
+
private getRelevantSourceSamples;
|
|
93
|
+
/**
|
|
94
|
+
* Discover source files in the project
|
|
95
|
+
*/
|
|
96
|
+
private discoverSourceFiles;
|
|
97
|
+
/**
|
|
98
|
+
* Get all context files to check
|
|
99
|
+
*/
|
|
100
|
+
private getContextFiles;
|
|
101
|
+
/**
|
|
102
|
+
* Attempt to fix drift in a file
|
|
103
|
+
*/
|
|
104
|
+
private fixDrift;
|
|
105
|
+
/**
|
|
106
|
+
* Close the agent and clean up resources
|
|
107
|
+
*/
|
|
108
|
+
close(): void;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create a drift agent
|
|
112
|
+
*/
|
|
113
|
+
export declare function createDriftAgent(config: Omit<DriftAgentConfig, 'projectRoot'>): DriftAgent;
|
|
114
|
+
//# sourceMappingURL=drift-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift-agent.d.ts","sourceRoot":"","sources":["../../src/agents/drift-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpC,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,UAAU,EAAE,gBAAgB,CAAC;IAC7B,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AA4CD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAmB;IACrC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,gBAAgB;IAOpC;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE;QACzB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuCxB;;OAEG;YACW,iBAAiB;IAsD/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA4B/B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA4B1B;;OAEG;YACW,wBAAwB;IAuCtC;;OAEG;YACW,mBAAmB;IA0BjC;;OAEG;YACW,eAAe;IAgB7B;;OAEG;YACW,QAAQ;IAQtB;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,GAAG,UAAU,CAK1F"}
|