Skip to content

Commit c234cb3

Browse files
runonthespotclaude
andcommitted
Add MCP server with pagination and TUI refactoring
This commit adds comprehensive MCP (Model Context Protocol) support and refactors the TUI into a dedicated crate. ## MCP Server Features - Full stdio transport implementation with tool discovery - Pagination support with cursor-based navigation (1-200 results per page) - Session management with TTL and automatic cleanup (60s expiration) - Search tools: semantic_search, regex_search, hybrid_search, lexical_search - Index tools: index_status, reindex, health_check - Fallback strategies: automatic semantic → lexical when embeddings unavailable - 7 comprehensive integration tests for pagination and edge cases ## TUI Refactoring - Extracted 3,084 lines of TUI code into dedicated ck-tui crate - Clean modular architecture with public API - Config persistence to ~/.config/ck/tui.json - Multiple preview modes (Heatmap, Syntax, Chunks) - Multiple search modes (Semantic, Regex, Hybrid) - Multi-select workflow and editor integration - Real-time indexing progress with file/chunk counts ## CLI Enhancements - Color-coded similarity scores with RGB gradient heatmap - Enhanced visual output with Unicode box drawing - Near-miss tracking for threshold queries ## Core Improvements - Span validation with Span::new() to prevent invalid spans - Mixed line ending support (Unix \n, Windows \r\n, Mac \r) - Memory-efficient streaming file operations - Better PDF content path resolution ## Technical Details - Session cleanup: LRU-based eviction with periodic task (30s) - Line ending tracking: split_lines_with_endings() for byte precision - SearchResults enhancement: closest_below_threshold field - Full test coverage with integration tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cd5ad76 commit c234cb3

81 files changed

Lines changed: 12372 additions & 14331 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,40 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.6.0] - 2025-10-12
6+
7+
### Added
8+
- **MCP Server**: Full Model Context Protocol implementation with stdio transport for AI agent integration
9+
- **Pagination Support**: Cursor-based pagination for all search modes (page_size: 1-200, default: 50)
10+
- **Session Management**: TTL-based session cleanup for paginated results with automatic expiration (60s)
11+
- **MCP Search Tools**: `semantic_search`, `regex_search`, `hybrid_search`, `lexical_search` with unified interface
12+
- **MCP Index Tools**: `index_status`, `reindex`, `health_check` for index management
13+
- **CLI Heatmap Visualization**: Color-coded similarity scores with RGB gradient highlighting (red→yellow→green)
14+
- **Enhanced Visual Output**: Unicode box drawing and sophisticated match highlighting in CLI
15+
- **Near-Miss Tracking**: Track closest result below threshold for better search feedback
16+
- **Fallback Strategies**: Automatic fallback from semantic to lexical search when embeddings unavailable
17+
- **Graceful Error Handling**: Skip stale index entries when files no longer exist
18+
19+
### Fixed
20+
- **Mixed Line Endings**: Proper handling of Unix (\n), Windows (\r\n), and Mac (\r) line endings
21+
- **Span Validation**: Prevent invalid spans with zero line numbers using `Span::new()` validation
22+
- **Streaming File Operations**: Memory-efficient line extraction without loading entire files
23+
- **PDF Content Resolution**: Better content path resolution and caching for PDF files
24+
25+
### Technical
26+
- **MCP Protocol**: Full implementation with tool discovery, validation, and error handling
27+
- **Session Cleanup**: LRU-based eviction with periodic cleanup task (every 30s)
28+
- **Streaming Reads**: Optimized `extract_lines_from_file()` for minimal memory footprint
29+
- **SearchResults Enhancement**: Added `closest_below_threshold` field for improved UX
30+
- **Comprehensive Testing**: 7 new MCP integration tests covering pagination, validation, and edge cases
31+
- **Line Ending Support**: `split_lines_with_endings()` tracks exact byte lengths per line
32+
- **TUI Refactoring**: Extracted TUI functionality into dedicated `ck-tui` crate (3,084 lines)
33+
- **Modular Architecture**: Clean separation of TUI components with public API
34+
- **Config Persistence**: TUI preferences saved to `~/.config/ck/tui.json`
35+
36+
### Breaking Changes
37+
- **Span Construction**: Use `Span::new()` for validated construction instead of struct literals (backward compatible via `Span::new_unchecked()`)
38+
539
## [0.5.3] - 2025-09-29
640

741
### Added

Cargo.lock

Lines changed: 29 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ members = [
99
"ck-embed",
1010
"ck-ann",
1111
"ck-models",
12+
"ck-tui",
1213
]
1314

1415
[workspace.package]
15-
version = "0.5.3"
16+
version = "0.6.0"
1617
edition = "2024"
1718
authors = ["Mike Renwick"]
1819
license = "MIT OR Apache-2.0"

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ claude mcp list # or use /mcp in Claude Code
6767

6868
**Built-in Pagination:** Handles large result sets gracefully with page_size controls, cursors, and snippet length management.
6969

70+
### 🎨 **Interactive TUI (Terminal User Interface)**
71+
Launch an interactive search interface with real-time results and multiple preview modes:
72+
73+
```bash
74+
# Start TUI for current directory
75+
ck --tui
76+
77+
# Start with initial query
78+
ck --tui "error handling"
79+
```
80+
81+
**Features:**
82+
- **Multiple Search Modes**: Toggle between Semantic, Regex, and Hybrid search with `Tab`
83+
- **Preview Modes**: Switch between Heatmap, Syntax highlighting, and Chunk view with `Ctrl+V`
84+
- **View Options**: Toggle between snippet and full-file view with `Ctrl+F`
85+
- **Multi-select**: Select multiple files with `Ctrl+Space`, open all in editor with `Enter`
86+
- **Search History**: Navigate with `Ctrl+Up/Down`
87+
- **Editor Integration**: Opens files in `$EDITOR` with line numbers (Vim, VS Code, Cursor, etc.)
88+
- **Progress Tracking**: Live indexing progress with file and chunk counts
89+
- **Config Persistence**: Preferences saved to `~/.config/ck/tui.json`
90+
91+
See [TUI.md](TUI.md) for keyboard shortcuts and detailed usage.
92+
7093
### 🔍 **Semantic Search**
7194
Find code by concept, not keywords. Understands synonyms, related terms, and conceptual similarity:
7295

@@ -348,6 +371,7 @@ ck --json --sem "public API" src/ | generate_docs.py
348371
ck uses a modular Rust workspace:
349372

350373
- **`ck-cli`** - Command-line interface and MCP server
374+
- **`ck-tui`** - Interactive terminal user interface (ratatui-based)
351375
- **`ck-core`** - Shared types, configuration, and utilities
352376
- **`ck-engine`** - Search engine implementations (regex, semantic, hybrid)
353377
- **`ck-index`** - File indexing, hashing, and sidecar management

0 commit comments

Comments
 (0)