codesearch 0.1.9

A fast, intelligent CLI tool with multiple search modes (regex, fuzzy, semantic), code analysis, and dead code detection for popular programming languages
Documentation
# Advanced Features Demo

This document demonstrates the advanced features that make our code search tool significantly better than traditional `grep`.

## 🎮 Interactive Search Mode

Unlike grep, our tool offers an interactive mode for iterative searching:

```bash
$ codesearch interactive --extensions py,js,ts
🎮 Interactive Search Mode
Type 'help' for commands, 'quit' to exit

codesearch> class
Found 15 matches in 3 files
# ... results ...

codesearch> extensions rs,go
Extensions updated!

codesearch> function
Found 8 matches in 2 files
# ... results ...

codesearch> history
Search History:
  1: class
  2: function

codesearch> quit
👋 Goodbye!
```

## 🔍 Fuzzy Search

Handle typos and variations intelligently:

```bash
# Traditional grep fails with typos
$ grep -r "usermanager" examples/
# No results

# Our fuzzy search finds matches
$ codesearch search "usrmngr" --fuzzy --extensions js
Found 10 matches in 1 files
# Finds: UserManager, userManager, etc.
```

## 📊 Comprehensive Codebase Analysis

Get deep insights into your codebase:

```bash
$ codesearch analyze --extensions rs,py,js,ts,go,java
📊 Codebase Analysis
────────────────────

📁 File Statistics:
  Total files: 8
  Total lines: 2211
  Total size: 64535 bytes

📋 File Type Breakdown:
  rs: 3 files (37%), 1142 lines, 36163 bytes
  js: 1 files (12%), 156 lines, 3856 bytes
  py: 1 files (12%), 115 lines, 3565 bytes
  ts: 1 files (12%), 252 lines, 6632 bytes
  go: 1 files (12%), 274 lines, 6233 bytes
  java: 1 files (12%), 272 lines, 8086 bytes

🔍 Code Pattern Analysis:
  Functions: 69 occurrences
  Classes: 15 occurrences
  Comments: 214 occurrences
  TODO: 1 occurrences
  Imports: 25 occurrences

⚠️  Large Files (>100 lines):
  main.rs: 922 lines
  go_example.go: 274 lines
  java_example.java: 272 lines
```

## 📈 Rich Search Statistics

Get detailed analytics on your search results:

```bash
$ codesearch search "class" --extensions py,js,ts,java --stats
Found 21 matches in 4 files

📁 ./examples/java_example.java (8 matches)
───────────────────────────────────────────
  12: public class User {
  72: class UserNotFoundException extends Exception {
  # ... more results ...

✨ Search completed!

📊 Search Statistics
────────────────────
Query: class
Total matches: 21
Files searched: 4

📁 Matches per file:
  ./examples/java_example.java: 8 matches (38%)
  ./examples/python_example.py: 7 matches (33%)
  ./examples/typescript_example.ts: 5 matches (23%)
  ./examples/javascript_example.js: 1 matches (4%)

📏 Line analysis:
  Earliest match: line 3
  Latest match: line 226
  Average line: 5
```

## 🎨 Enhanced Visual Output

Professional, color-coded output with better organization:

**Grep output:**
```
examples/typescript_example.ts:33:// Custom error class
examples/typescript_example.ts:34:class UserNotFoundError extends Error {
examples/javascript_example.js:3:class UserManager {
```

**Our tool output:**
```
Found 3 matches in 2 files

📁 ./examples/typescript_example.ts (2 matches)
───────────────────────────────────────────────
  33: // Custom error class
  34: class UserNotFoundError extends Error {

📁 ./examples/javascript_example.js (1 matches)
───────────────────────────────────────────────
  3: class UserManager {

✨ Search completed!
```

## 🚀 Performance Comparison

| Feature | Grep | Our Tool | Advantage |
|---------|------|----------|-----------|
| Basic Search ||| Equal |
| Regex Support ||| Equal |
| File Filtering | Basic | Advanced | 🏆 Better |
| Visual Output | Basic | Professional | 🏆 Much Better |
| Statistics ||| 🏆 New |
| Fuzzy Search ||| 🏆 New |
| Interactive Mode ||| 🏆 New |
| Code Analysis ||| 🏆 New |
| JSON Output ||| 🏆 New |
| Search History ||| 🏆 New |

## 🎯 Real-World Use Cases

### 1. Code Review
```bash
# Find all TODO comments
codesearch search "TODO|FIXME|HACK" --stats

# Find potential security issues
codesearch search "password|secret|key" --ignore-case --stats
```

### 2. Refactoring
```bash
# Find all instances of a function
codesearch search "oldFunctionName" --fuzzy --stats

# Analyze code complexity
codesearch analyze --extensions js,ts
```

### 3. Onboarding New Developers
```bash
# Interactive exploration
codesearch interactive

# Get codebase overview
codesearch analyze
```

### 4. Code Quality
```bash
# Find large files that might need refactoring
codesearch analyze --extensions py,js,ts

# Find unused imports
codesearch search "^import.*unused" --extensions py,js,ts
```

## 🔮 Future Potential

The foundation is in place for even more advanced features:

- **Semantic Code Understanding** - AST parsing for intelligent analysis
- **Context-Aware Search** - Search within specific functions/classes
- **Smart Refactoring** - Automated code improvement suggestions
- **Team Collaboration** - Shared search patterns and bookmarks
- **IDE Integration** - Real-time search in your editor
- **Machine Learning** - Learn from your search patterns

## 🏆 Why This Matters

Our code search tool represents a significant evolution beyond traditional text search:

1. **Developer Productivity** - Faster, more accurate code discovery
2. **Code Quality** - Better understanding of codebase structure
3. **Maintenance** - Easier refactoring and updates
4. **Onboarding** - New developers can understand codebases faster
5. **Code Review** - Better tools for reviewing changes
6. **Documentation** - Automatic code documentation generation

The goal is to move beyond simple text matching to intelligent code understanding and analysis, making developers more productive and codebases more maintainable.