Metadata-Version: 2.4
Name: hygrep
Version: 0.0.7
Summary: Grep + neural reranking for code search
Project-URL: Homepage, https://github.com/nijaru/hygrep
Project-URL: Repository, https://github.com/nijaru/hygrep
Author: nijaru
License-Expression: MIT
License-File: LICENSE
Keywords: cli,code,grep,reranking,search
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Filters
Requires-Python: >=3.11
Requires-Dist: huggingface-hub>=0.20
Requires-Dist: numpy>=1.24
Requires-Dist: onnxruntime>=1.16
Requires-Dist: pathspec>=0.11
Requires-Dist: rich>=13.0
Requires-Dist: tokenizers>=0.15
Requires-Dist: tree-sitter-bash>=0.23
Requires-Dist: tree-sitter-c-sharp>=0.23
Requires-Dist: tree-sitter-c>=0.23
Requires-Dist: tree-sitter-cpp>=0.23
Requires-Dist: tree-sitter-elixir>=0.3
Requires-Dist: tree-sitter-go>=0.23
Requires-Dist: tree-sitter-java>=0.23
Requires-Dist: tree-sitter-javascript>=0.23
Requires-Dist: tree-sitter-json>=0.24
Requires-Dist: tree-sitter-kotlin>=1.0
Requires-Dist: tree-sitter-lua>=0.2
Requires-Dist: tree-sitter-php>=0.23
Requires-Dist: tree-sitter-python>=0.23
Requires-Dist: tree-sitter-ruby>=0.23
Requires-Dist: tree-sitter-rust>=0.23
Requires-Dist: tree-sitter-svelte>=1.0
Requires-Dist: tree-sitter-swift>=0.0.1
Requires-Dist: tree-sitter-toml>=0.7
Requires-Dist: tree-sitter-typescript>=0.23
Requires-Dist: tree-sitter-yaml>=0.7
Requires-Dist: tree-sitter-zig>=1.0
Requires-Dist: tree-sitter>=0.24
Requires-Dist: typer>=0.9
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Provides-Extra: semantic
Requires-Dist: omendb>=0.0.1a1; extra == 'semantic'
Description-Content-Type: text/markdown

# hygrep (hhg)

**Semantic code search with automatic indexing**

```bash
pip install hygrep
hhg "authentication flow" ./src
```

## What it does

Search your codebase using natural language. Results are functions and classes ranked by relevance:

```
$ hhg "error handling" ./tests/golden
No index found. Building...
Found 4 files (0.0s)
✓ Indexed 59 blocks from 4 files (5.4s)

Searching for: error handling
api_handlers.ts:127 function errorHandler
  function errorHandler(err: Error, req: Request, res: Response, next: NextFunc...
    console.error('API Error:', err.message);

errors.rs:7 class AppError
  pub enum AppError {
      /// Database operation failed.
      Database(DatabaseError),

2 results (0.60s)
```

## Search Modes

| Mode         | Flag      | Use Case                              |
| ------------ | --------- | ------------------------------------- |
| **Semantic** | (default) | Best quality, uses embeddings + index |
| **Fast**     | `-f`      | No index, grep + neural rerank        |
| **Exact**    | `-e`      | Fastest, literal string match         |
| **Regex**    | `-r`      | Pattern matching                      |

```bash
hhg "auth flow" ./src           # Semantic (auto-indexes on first run)
hhg -f "validate" ./src         # Grep + neural rerank (no index needed)
hhg -e "TODO" ./src             # Exact match (fastest)
hhg -r "TODO.*fix" ./src        # Regex match
```

## Install

```bash
pip install hygrep
# or
uv tool install hygrep
# or
pipx install hygrep
```

First search builds an index automatically (stored in `.hhg/`). Models are downloaded from HuggingFace and cached.

## Usage

```bash
hhg "query" [path]              # Search (default: current dir)
hhg -n 5 "error handling" .     # Limit results
hhg --json "auth" .             # JSON output for scripts/agents
hhg -l "config" .               # List matching files only
hhg -t py,js "api" .            # Filter by file type
hhg --exclude "tests/*" "fn" .  # Exclude patterns
hhg status [path]               # Check index status
hhg rebuild [path]              # Rebuild index from scratch
hhg clean [path]                # Delete index
```

**Note:** Options must come before positional arguments.

## Output

Default:

```
src/auth.py:42 function login
  def login(user, password):
      """Authenticate user and create session."""
      ...
```

JSON (`--json`):

```json
[
  {
    "file": "src/auth.py",
    "type": "function",
    "name": "login",
    "line": 42,
    "end_line": 58,
    "content": "def login(user, password): ...",
    "score": 0.87
  }
]
```

Compact JSON (`--json --compact`): Same fields without `content`.

## How it Works

**Semantic mode (default):**

```
Query → Embed → Vector search → Results
         ↓
    Auto-indexes on first run (.hhg/)
    Auto-updates when files change
```

**Fast mode (`-f`):**

```
Query → Grep scan → Tree-sitter extract → Neural rerank → Results
```

**Exact/Regex mode (`-e`/`-r`):**

```
Pattern → Grep scan → Tree-sitter extract → Results
```

## Supported Languages

Bash, C, C++, C#, Elixir, Go, Java, JavaScript, JSON, Kotlin, Lua, Mojo, PHP, Python, Ruby, Rust, Svelte, Swift, TOML, TypeScript, YAML, Zig

## Development

```bash
git clone https://github.com/nijaru/hygrep && cd hygrep
pixi install && pixi run build-ext && pixi run test
```

## License

MIT
