Kode features a state-of-the-art intelligent completion system that revolutionizes terminal interaction with AI agents and commands. The system uses advanced fuzzy matching algorithms inspired by Chinese input methods, modern IDEs, and terminal fuzzy finders.
Our custom advancedFuzzyMatcher combines multiple matching strategies:
- Exact Prefix Matching - Highest priority for exact starts
- Hyphen-Aware Matching - Treats hyphens as optional word boundaries
- Word Boundary Detection - Matches characters at word starts
- Abbreviation Matching - Supports shortcuts like
dq→dao-qi - Numeric Suffix Handling - Intelligently matches
py3→python3 - Subsequence Matching - Characters appear in order
- Fuzzy Segment Matching - Flexible segment matching
The system automatically detects context without requiring special prefixes:
# Type without @, system adds it automatically
gp5 → @ask-gpt-5
daoqi → @run-agent-dao-qi-harmony-designer
py3 → python3
# Tab key fills the match with appropriate prefix
# Enter key completes and adds space- 500+ curated common Unix/Linux commands
- Categories: File operations, text processing, development tools, network utilities, etc.
- Smart intersection with system PATH - only shows commands that actually exist
Commands are ranked by:
- Match quality score
- Common usage frequency
- Position in command database
The system seamlessly combines completions from:
- Slash Commands (
/help,/model, etc.) - Agent Mentions (
@run-agent-*) - Model Consultations (
@ask-*) - Unix Commands (from system PATH)
- File Paths (directories and files)
src/
├── utils/
│ ├── advancedFuzzyMatcher.ts # Advanced matching algorithms
│ ├── fuzzyMatcher.ts # Original matcher (facade)
│ └── commonUnixCommands.ts # Unix command database
└── hooks/
└── useUnifiedCompletion.ts # Main completion hook
// Handles: dao → dao-qi-harmony-designer
// Split by hyphens and match flexibly
const words = text.split('-')
// Check concatenated version (ignoring hyphens)
const concatenated = words.join('')// Handles: py3 → python3
const patternMatch = pattern.match(/^(.+?)(\d+)$/)
if (text.endsWith(suffix) && textWithoutSuffix.startsWith(prefix)) {
// High score for numeric suffix match
}// Handles: dq → dao-qi
// Match characters at word boundaries
for (const word of words) {
if (word[0] === pattern[patternIdx]) {
score += 50 // Bonus for word boundary
}
}# Abbreviations
nde → node
np → npm
dk → docker
# Partial matches
kub → kubectl
vim → vim, nvim
# Numeric patterns
py3 → python3
n18 → node18# Without @ prefix (auto-added on completion)
gp5 → @ask-gpt-5
claude → @ask-claude-sonnet-4
dao → @run-agent-dao-qi-harmony-designer
daoqi → @run-agent-dao-qi-harmony-designer# Input: "doc"
1. docker (common command, high priority)
2. document (if exists)
3. doctor (if exists)
# Input: "g"
1. git (most common)
2. grep (common)
3. go (if installed)The system uses a minimum score of 5 (very low) to allow flexible matching while filtering noise.
Results are sorted by:
- Match algorithm score
- Command priority (for Unix commands)
- Type priority (agents/models > files > commands)
- Sub-millisecond matching - Optimized algorithms for instant feedback
- Lazy loading - Commands loaded on first use
- Smart caching - Results cached per session
- Efficient filtering - Early termination for obvious non-matches
- Learning from user selections
- Project-specific command priorities
- Custom abbreviation definitions
- Typo correction with edit distance
- Context-aware suggestions based on recent commands