Kode-cli/debug-completion.js
CrazyBoyM 926df2cfaf feat: Ultra-redesign completion system with @mention integration
- Complete architectural overhaul of useUnifiedCompletion hook
- Unified state management: 8 separate states → single CompletionState interface
- Simplified core logic: getWordAtCursor 194 lines → 42 lines (78% reduction)
- Fixed infinite React update loops with ref-based input tracking
- Smart triggering mechanism replacing aggressive auto-completion
- Integrated @agent and @file mention system with system reminders
- Added comprehensive agent loading and mention processing
- Enhanced Tab/Arrow/Enter key handling with clean event management
- Maintained 100% functional compatibility across all completion types

Key improvements:
• File path completion (relative, absolute, ~expansion, @references)
• Slash command completion (/help, /model, etc.)
• Agent completion (@agent-xxx with intelligent descriptions)
• System command completion (PATH scanning with fallback)
• Terminal-style Tab cycling, Enter confirmation, Escape cancellation
• Preview mode with boundary calculation
• History navigation compatibility
• Empty directory handling with user feedback

Architecture: Event-driven @mention detection → system reminder injection → LLM tool usage
Performance: Eliminated 7-layer nested conditionals, reduced state synchronization issues
Reliability: Fixed maximum update depth exceeded warnings, stable state management
2025-08-21 01:21:12 +08:00

27 lines
691 B
JavaScript

#!/usr/bin/env node
// 临时调试脚本 - 测试补全系统是否工作
console.log('Debug: Testing completion system...')
// 测试文件是否存在
const fs = require('fs')
const path = require('path')
const testFiles = ['package.json', 'package-lock.json', 'README.md']
testFiles.forEach(file => {
if (fs.existsSync(file)) {
console.log(`✅ Found file: ${file}`)
} else {
console.log(`❌ Missing file: ${file}`)
}
})
// 测试目录读取
try {
const entries = fs.readdirSync('.').filter(f => f.startsWith('pa'))
console.log(`Files starting with 'pa':`, entries)
} catch (err) {
console.log('Error reading directory:', err)
}
console.log('Debug completed.')