{"id":47725939,"url":"https://github.com/nikuscs/scanr","last_synced_at":"2026-04-02T20:27:15.051Z","repository":{"id":348382376,"uuid":"1197535582","full_name":"nikuscs/scanr","owner":"nikuscs","description":"📡 Semantic codebase search + TypeScript structural analysis — embeddings, pgvector, oxc, tree-sitter. Agent-ready CLI skill.","archived":false,"fork":false,"pushed_at":"2026-03-31T23:09:23.000Z","size":144,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-01T01:27:13.988Z","etag":null,"topics":["ai-agent","claude-code","cli","embeddings","oxc","pgvector","rust","semantic-search","tree-sitter","typescript"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikuscs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T16:56:40.000Z","updated_at":"2026-03-31T22:40:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nikuscs/scanr","commit_stats":null,"previous_names":["nikuscs/scanr"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nikuscs/scanr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikuscs%2Fscanr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikuscs%2Fscanr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikuscs%2Fscanr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikuscs%2Fscanr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikuscs","download_url":"https://codeload.github.com/nikuscs/scanr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikuscs%2Fscanr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31315942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","claude-code","cli","embeddings","oxc","pgvector","rust","semantic-search","tree-sitter","typescript"],"created_at":"2026-04-02T20:27:14.418Z","updated_at":"2026-04-02T20:27:15.042Z","avatar_url":"https://github.com/nikuscs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📡 scanr\n\n[![Release](https://img.shields.io/github/v/release/nikuscs/scanr)](https://github.com/nikuscs/scanr/releases)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n**Semantic codebase search + TypeScript structural analysis. Works as a skill for [Claude Code](https://docs.anthropic.com/en/docs/claude-code), [Claude.ai](https://claude.ai), [OpenAI Codex](https://openai.com/index/openai-codex/), and any AI agent.**\n\nTwo modes: **semantic search** (OpenAI embeddings + pgvector) for finding code by meaning, and **structural scan** (oxc parser) for extracting functions, bindings, and exports from TypeScript/JavaScript projects.\n\n\u003e **Note:** This project was built with AI assistance. Review, test, and verify before using in production.\n\n### Features\n \n- 🔍 **Semantic search** — find code by meaning, not keywords (embeddings + pgvector)\n- 🧬 **TypeScript analysis** — extract functions, bindings \u0026 exports via oxc\n- 🌳 **Tree view** — compact project structure for fast orientation\n- ⚡ **Fast** — parallel chunking (rayon), HNSW index, batch embeddings\n- 📦 **Incremental** — SHA-256 dedup, only re-embeds changed files\n- 🔧 **Zero config** — auto-installs PostgreSQL + pgvector via Homebrew\n- 🌐 **Multi-language** — tree-sitter for TS/JS/Rust/Python/Go + plain chunking for data files\n- 🤖 **Agent-friendly** — JSON output, non-interactive setup, stale warnings to stderr\n\n## What scanr is\n\n- A **local CLI for codebase retrieval** that indexes the repository you already have on disk\n- A **semantic code search tool** built on OpenAI embeddings + pgvector\n- A **TypeScript/JavaScript structural scanner** powered by oxc, for extracting functions, bindings, and exports\n- An **agent-friendly interface** with JSON output, non-interactive setup, and stale index warnings\n- A **batteries-included retrieval pipeline**: file discovery, chunking, embedding, storage, and search in one tool\n\n## What scanr is not\n\n- Not a **vector database** or general-purpose retrieval backend like pgvector, Qdrant, Pinecone, Chroma, or turbopuffer\n- Not an **IDE** or editor plugin\n- Not a **hosted codebase Q\u0026A service** or PR review product\n- Not an **enterprise code intelligence platform** for organization-wide search across many repositories\n- Not a replacement for **grep**, **language servers**, or full code navigation tools\n- Not a fully offline tool today: semantic search depends on OpenAI embeddings, while `scan` and `tree` do not\n\n## Install\n\n```bash\n# From source (requires Rust 1.85+)\ncargo install --git https://github.com/nikuscs/scanr\n\n# Or clone and build\ngit clone https://github.com/nikuscs/scanr\ncd scanr\ncargo build --release\n```\n\nPre-built binaries available in [Releases](https://github.com/nikuscs/scanr/releases).\n\n## Quick Start\n\n```bash\n# One-time setup (auto-installs PostgreSQL + pgvector if needed)\nexport OPENAI_API_KEY=sk-...\nscanr setup\n\n# Index your project\ncd your-project\nscanr index\n\n# Search\nscanr search \"how does authentication work\"\n\n# Structural analysis (no setup needed)\nscanr scan --mode files\n\n# Quick structure overview\nscanr tree\n```\n\n## Commands\n\n### `scanr setup`\n\nCreate the database, install pgvector extension, and create all tables + HNSW index. Run once per machine.\n\nOn macOS, PostgreSQL and pgvector are auto-installed and started via Homebrew if not already present.\n\n```bash\nscanr setup                   # Interactive — prompts for PostgreSQL version\nscanr setup -y                # Non-interactive — accepts defaults (for agents)\nscanr setup --pg-version 17   # Specific PostgreSQL version (default: 18)\n```\n\n### `scanr index`\n\nIndex or re-index the project. Incremental by default — only files whose content changed since the last run are re-embedded.\n\n```bash\nscanr index                          # Index current directory\nscanr index --root /path/to/project  # Index a specific project\nscanr index --file src/main.rs       # Re-index a single file\nscanr index --force                  # Force re-embed everything\nscanr index --embedding openai:text-embedding-3-small\nscanr index --chunk-size 1500        # Custom chunk size (default: 1000)\nscanr index --chunk-overlap 200      # Custom overlap (default: 100)\nscanr index --max-bytes 204800       # Skip files larger than this (default: 512 KB)\nscanr index --gitignore /path/.gitignore  # Custom gitignore file\n```\n\nUse `--embedding \u003cprovider:model\u003e` to choose the embedding backend for a new index. Currently supported: `openai:text-embedding-3-large` (default) and `openai:text-embedding-3-small`.\n\n### `scanr search`\n\nSemantic search across the indexed codebase.\n\n```bash\nscanr search \"payment webhook handler\"\nscanr search \"error handling\" --limit 5\nscanr search \"auth middleware\" --lang ts --threshold 0.5\nscanr search \"database schema\" --files-only\nscanr search \"API routes\" --json\n```\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--root \u003cpath\u003e` | `.` | Project root directory |\n| `--limit \u003cn\u003e` | `10` | Number of results |\n| `--threshold \u003cn\u003e` | `0.0` | Minimum similarity score (0-1) |\n| `--lang \u003cext\u003e` | — | Filter by language: `ts`, `tsx`, `md`, etc. |\n| `--files-only` | — | Unique file paths only, no snippets |\n| `--json` | — | Structured JSON: `[{file, language, score, content}]` |\n\nIf stale files are detected (changed since last index), a warning is printed to stderr. Agents should detect this and call `index` before searching.\n\nThe embedding config is stored per project. `search` always uses the same provider/model that the project was indexed with.\n\n### `scanr tree`\n\nCompact project structure overview for fast orientation.\n\n```bash\nscanr tree\nscanr tree --path src/commands\nscanr tree --depth 4\nscanr tree --all\n```\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--root \u003cpath\u003e` | `.` | Project root directory |\n| `--path \u003csubdir\u003e` | — | Focus on a subdirectory within the project |\n| `--depth \u003cn\u003e` | `6` | Max branching depth before collapsing subtrees |\n| `--inline \u003cn\u003e` | `6` | Max files shown per line before wrapping |\n| `--all` | — | Include test directories and test files |\n\nThe output is tuned for agents: compact enough to fit in context, but detailed enough to surface the main folders and important top-level files quickly.\n\n### `scanr scan`\n\nStructural analysis of TypeScript/JavaScript codebases. Extracts functions, bindings, and exports — powered by [oxc](https://oxc.rs).\n\n```bash\nscanr scan                                    # Scan current directory (compact JSON)\nscanr scan --mode verbose                     # Detailed output with spans and metadata\nscanr scan --mode files                       # Group functions by file\nscanr scan --mode folders                     # Group functions by folder\nscanr scan --file src/api.ts                  # Scan a single file\nscanr scan --include ts,tsx                   # Only scan specific extensions\nscanr scan --exclude vendor,generated         # Exclude directories\nscanr scan --function-kinds top               # Only top-level declarations\nscanr scan --function-kinds top+arrow         # Declarations + arrow functions\nscanr scan --function-kinds top+arrow+class   # Include class methods\n```\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `--root \u003cpath\u003e` | `.` | Project root directory |\n| `--mode \u003cmode\u003e` | `compact` | Output format: `compact`, `verbose`, `files`, `folders` |\n| `--file \u003cpath\u003e` | — | Scan a single file instead of directory |\n| `--include \u003cexts\u003e` | `ts,tsx,js,jsx` | File extensions to include (comma-separated) |\n| `--exclude \u003cdirs\u003e` | — | Patterns to exclude (comma-separated) |\n| `--max-bytes \u003cn\u003e` | `1048576` | Skip files larger than this (bytes) |\n| `--function-kinds \u003cfilter\u003e` | `all` | Function kinds: `top`, `top+arrow`, `top+arrow+class`, `all` |\n\n**Output modes:**\n\n- **`compact`** — flat JSON arrays optimized for size: `{f: [[file, line, col, name, exported, kind], ...], b: [...], x: [...]}`\n- **`verbose`** — pretty-printed JSON with full metadata (spans, async/generator flags, export info)\n- **`files`** — functions grouped by file path with dot-notation for nested functions (e.g., `createActions.add`)\n- **`folders`** — functions grouped by parent directory with counts\n\n### `scanr status`\n\nShow indexing stats, active embedding config, and stale file count.\n\n```bash\nscanr status\nscanr status --root /path/to/project\n```\n\n### `scanr clear`\n\nRemove all indexed data for a project.\n\n```bash\nscanr clear\nscanr clear --root /path/to/project\n```\n\n### `scanr reindex`\n\nClear all data and re-index from scratch. Equivalent to `scanr clear \u0026\u0026 scanr index --force`.\n\n```bash\nscanr reindex\nscanr reindex --root /path/to/project\nscanr reindex --embedding openai:text-embedding-3-small\n```\n\n## Supported File Types\n\n| Type | Extensions |\n|------|-----------|\n| JavaScript/TypeScript | `.ts`, `.tsx`, `.js`, `.jsx`, `.mts`, `.cts`, `.mjs`, `.cjs` |\n| Rust | `.rs` |\n| Python | `.py` |\n| Go | `.go` |\n| Markdown | `.md`, `.mdx` |\n| Data | `.json`, `.yaml`, `.yml`, `.toml` |\n\nCode files are chunked using tree-sitter (syntax-aware, respects function/class boundaries). Data and markdown files use plain text splitting.\n\n## How It Works\n\n### Semantic Search (index + search)\n\n1. **File discovery** — `git ls-files --cached --others --exclude-standard` filtered by supported extensions, respects `.gitignore`\n2. **Parallel chunking** — rayon-parallelized file reading + tree-sitter AST splitting for code, heading-based splitting for markdown (configurable size/overlap)\n3. **Deduplication** — SHA-256 content hashing skips unchanged files\n4. **Embedding** — OpenAI embeddings, configurable per project (`text-embedding-3-large` by default, or `text-embedding-3-small`), batched (max 100 per call), with exponential backoff retry on 429/5xx\n5. **Storage** — pgvector with HNSW index for fast cosine similarity search\n6. **Search** — embed query, cosine similarity search, threshold filtering, stale detection\n\n### Structural Scan (scan)\n\n1. **File discovery** — walks project with `.gitignore` support, filters by extension (default: `.ts`, `.tsx`, `.js`, `.jsx`)\n2. **Parallel parsing** — rayon-parallelized oxc parsing (native speed, full TypeScript support)\n3. **Extraction** — functions (declarations, arrows, class methods, getters/setters), bindings (const/let/var/import/class/enum), exports (named, default, re-exports)\n4. **Output** — compact/verbose/files/folders JSON modes, dot-notation nesting for parent-child functions\n\n## Configuration\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `OPENAI_API_KEY` | — | Required for embedding |\n| `CODE_INDEX_DATABASE_URL` | `postgresql://postgres@localhost/code_index` | PostgreSQL connection URL |\n| `SCANR_EMBEDDING` | `openai:text-embedding-3-large` | Default embedding backend for `index` / `reindex` when not already stored for the project |\n\nThe embedding configuration used for a project is stored alongside its index metadata. `scanr status` shows the `provider:model` and dimensions currently associated with that project. To switch embeddings for an existing project, run `scanr reindex --embedding ...`.\n\nOverride the database URL:\n\n```bash\nCODE_INDEX_DATABASE_URL=postgresql://user:pass@host/code_index scanr index\n```\n\n## Reading Results\n\n- **\u003e85%** — very strong match, likely exactly what you're looking for\n- **70-85%** — relevant context, worth reading\n- **\u003c70%** — loosely related, use as breadcrumbs only\n\nIf results are poor, try rephrasing the query in terms of what the code *does*, not what you're *looking for* (e.g., \"debit wallet integer amount\" not \"where is money subtracted\").\n\n## Claude Code Plugin\n\nThis repo ships as a [Claude Code plugin](https://code.claude.com/docs/en/plugins) with a ready-to-use `/scanr:search` skill.\n\n### Install the plugin\n\n```bash\n# Add the marketplace\n/plugin marketplace add nikuscs/scanr\n\n# Install the plugin\n/plugin install scanr\n```\n\n### Usage\n\n```bash\n/scanr:search                              # check index state, orient\n/scanr:search how does auth work           # semantic search\n```\n\n\u003e **Requires** the `scanr` binary in your `$PATH`. See [Install](#install) above.\n\n### Manual skill setup\n\nIf you prefer not to use the plugin system, copy the skill file into your project:\n\n```bash\nmkdir -p .claude/skills/search\ncp plugin/skills/search/SKILL.md .claude/skills/search/SKILL.md\n```\n\n## AI Agents\n\nIf you are an AI agent (Claude Code, Claude.ai, OpenAI Codex, or any tool-calling agent), you can use `scanr` to semantically search any codebase. Download the binary and call it directly from your tool/shell integration.\n\n### Quick setup\n\n```bash\n# Download the pre-compiled binary for your platform from Releases\n# https://github.com/nikuscs/scanr/releases/latest\n\n# One-time setup (non-interactive for agents)\nscanr setup -y\n\n# Index the project\nscanr index\n\n# Search\nscanr search \"how does authentication work\" --json\n```\n\n### Tips for agents\n\n- Use `--json` for structured output you can parse: `[{file, language, score, content}]`\n- Use `tree` first for fast orientation before semantic search\n- Use `--files-only` for quick orientation before deep-reading files\n- Use `--limit` to control result count and stay within context limits\n- Run `scanr status` to check if the index is stale before searching\n- After editing files, re-index the changed file: `scanr index --file \u003cpath\u003e`\n- Phrase queries in terms of what the code *does*, not what you're looking for\n- Use `-y` flag on `setup` to skip interactive prompts\n\n## Credits\n\nscanr is built on top of excellent open-source projects:\n\n- [oxc](https://oxc.rs) — Blazing-fast JavaScript/TypeScript parser and linter, powers the `scan` command\n- [tree-sitter](https://tree-sitter.github.io/tree-sitter/) — Incremental parsing for syntax-aware code chunking\n- [pgvector](https://github.com/pgvector/pgvector) — Open-source vector similarity search for PostgreSQL\n- [sqlx](https://github.com/launchbadge/sqlx) — Async Rust SQL toolkit with compile-time checked queries\n- [clap](https://github.com/clap-rs/clap) — Command-line argument parser for Rust\n- [rayon](https://github.com/rayon-rs/rayon) — Data parallelism library for Rust\n- [ignore](https://github.com/BurntSushi/ripgrep/tree/master/crates/ignore) — `.gitignore`-aware file walking (from the ripgrep project)\n\nEmbeddings are currently generated via the [OpenAI API](https://platform.openai.com/docs/guides/embeddings) using either `text-embedding-3-large` (2000 dimensions, default) or `text-embedding-3-small` (1536 dimensions). Vectors are stored in a `vector(2000)` column — smaller models are zero-padded, which preserves cosine similarity.\n\n## Roadmap\n\n- [ ] Configurable embedding backends instead of a single hardcoded provider\n- [ ] Support for local embedding models, so semantic search can run without OpenAI\n- [ ] Better tradeoffs between cost, speed, and quality for indexing large repositories\n- [ ] Additional structural analysis beyond the current TypeScript/JavaScript scan\n- [ ] Broader language-aware retrieval improvements on top of the current chunking pipeline\n\n## Related Projects\n\n- [lauyer](https://github.com/nikuscs/lauyer) — CLI for Portuguese legal jurisprudence search\n- [crauler](https://github.com/nikuscs/crauler) — Web crawler with social media extraction\n- [ts-code-scan](https://github.com/nikuscs/ts-code-scan) — TypeScript/JavaScript codebase indexer\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikuscs%2Fscanr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikuscs%2Fscanr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikuscs%2Fscanr/lists"}