AI-Powered Code Refactoring with Reset Weights & Blueprint Orchestration
Kimi Code Explorer is a production-grade VS Code extension that combines cutting-edge AI patterns for intelligent code refactoring:
| Feature | Description |
|---|---|
| π Reset Weights | Clean state for every analysis, eliminating context pollution |
| π Blueprint Orchestration | Multi-agent coordination for large-scale projects |
| π§ 3-Tier Memory | Short-term / Mid-term / Long-term memory management |
| β Verification Pipeline | Syntax, security, and style gates before code changes |
| π Detach/Reload | Context isolation to prevent memory overflow |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ORCHESTRATOR AGENT β
β (Blueprint Controller + State Manager) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
β β Blueprint β β Checklist β β 3-Tier Memory β β
β β Store β β Manager β β (ST/MT/LT + Vectors) β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββΌββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β WORKER 1 β β WORKER 2 β β WORKER N β
β β β β β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
β β 1. RESET β β β β 1. RESET β β β β 1. RESET β β
β β 2. LOAD β β β β 2. LOAD β β β β 2. LOAD β β
β β 3. EXECUTE β β β β 3. EXECUTE β β β β 3. EXECUTE β β
β β 4. VERIFY β β β β 4. VERIFY β β β β 4. VERIFY β β
β β 5. DETACH β β β β 5. DETACH β β β β 5. DETACH β β
β βββββββββββββββ β β βββββββββββββββ β β βββββββββββββββ β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββΌββββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SHARED ARTIFACTS β
β (Code, Tests, Docs, Verification Results) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Clone repository
git clone https://github.com/yourname/kimi-code-explorer.git
cd kimi-code-explorer
# Install dependencies
npm install
# Configure API key
cp .env.example .env
# Edit .env and add KIMI_API_KEY
# Build
npm run build
# Launch in VS Code
press F5- Select code in VS Code
- Press
Ctrl+Shift+K - View alternatives in Kimi Explorer panel
- Click "Apply" to replace code
- Create
blueprint.yamlin project root - Press
Ctrl+Shift+B - Workers process modules in parallel
- Each worker detaches after completion
{
"kimiCodeExplorer.apiKey": "your-api-key",
"kimiCodeExplorer.model": "moonshot-v1-32k",
"kimiCodeExplorer.resetWeights": true,
"kimiCodeExplorer.blueprint.enabled": true,
"kimiCodeExplorer.memory.fusionWeight": 0.15,
"kimiCodeExplorer.verification.syntaxCheck": true,
"kimiCodeExplorer.verification.securityScan": true
}kimi-code-explorer/
βββ src/
β βββ core/
β β βββ resetWeights.ts # Reset Weights implementation
β β βββ worker.ts # Worker Agent lifecycle
β β βββ orchestrator.ts # Blueprint orchestration
β β βββ verification.ts # Quality verification
β β βββ memoryManager.ts # 3-Tier memory system
β β βββ checkpoint.ts # State persistence
β βββ services/
β β βββ llmService.ts # Kimi API integration
β β βββ blueprintService.ts # Blueprint parser
β βββ providers/
β β βββ kimiExplorer.ts # VS Code sidebar panel
β βββ extension.ts # Entry point
βββ docs/
β βββ ARCHITECTURE.md
β βββ BLUEPRINT.md
β βββ MEMORY_SYSTEM.md
βββ examples/
β βββ blueprint.example.yaml
βββ AGENTS.md # Dynamic agent config
βββ package.json
βββ tsconfig.json
βββ README.md
Ensures each analysis starts from a clean state:
// Before analysis
const cleanContext = await resetManager.reset({
reason: 'code_exploration'
});
// Analysis with no historical baggage
const result = await analyze(code, cleanContext);
// After analysis, context is detached
await detachContext();Benefits:
- β No context pollution from previous analyses
- β Consistent results regardless of history
- β Predictable behavior
- β Easier debugging
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3-TIER MEMORY ARCHITECTURE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββ Short-term (Session Cache) β
β β Ephemeral β β’ Duration: Current session only β
β β Buffer β β’ Fusion Weight: β€0.15 β
β β (EB) β β’ Auto-clear on reset β
β ββββββββ¬βββββββ β
β β β
β ββββββββΌβββββββ Mid-term (Validated Knowledge) β
β β Working β β’ Duration: 48 hours β
β β Memory β β’ Fusion Weight: 0.15-0.35 β
β β (WM) β β’ Requires external validation β
β ββββββββ¬βββββββ β
β β β
β ββββββββΌβββββββ Long-term (Proven Knowledge Base) β
β β Long-term β β’ Duration: Permanent β
β β Memory β β’ Fusion Weight: 0.35-0.50 β
β β (LTM) β β’ Requires multiple validations β
β βββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Define project structure and execution order:
# blueprint.yaml
project:
name: "E-Commerce API"
version: "1.0.0"
modules:
- id: "auth"
name: "Authentication Service"
dependencies: []
output: "src/auth/"
checklist:
- "JWT token generation"
- "Password hashing (bcrypt)"
- "Unit tests > 80%"
- id: "api"
name: "API Gateway"
dependencies: ["auth"]
output: "src/api/"
checklist:
- "Rate limiting middleware"
- "Input validation"
execution:
strategy: "parallel"
maxWorkers: 4Multi-layer quality gates:
| Layer | Check | Description |
|---|---|---|
| 1 | Syntax | Validate code can be parsed |
| 2 | Security | Detect dangerous patterns (eval, hardcoded secrets) |
| 3 | Style | Check line length, whitespace, formatting |
| 4 | Complexity | Analyze loop depth, branch count |
| 5 | Checklist | Verify against module requirements |
Worker lifecycle for context isolation:
RESET β LOAD CONTEXT β EXECUTE β VERIFY β SAVE β DETACH
Critical: DETACH Phase
After every task completion:
- Clear LLM instance
- Clear context manager
- Release temporary variables
- Force garbage collection
Purpose: Prevent context pollution between tasks
| Feature | v1 | v2 (Final) |
|---|---|---|
| Reset Weights | β | β |
| Blueprint Mode | β | β |
| 3-Tier Memory | β | β |
| Context Isolation | β | β |
| Parallel Workers | β | β |
| Checkpoint Recovery | β | β |
| Verification Pipeline | Basic | Full |
MIT License - see LICENSE
Kimi Code Explorer - Production-Grade AI Code Refactoring π