{"id":47398175,"url":"https://github.com/agent-sh/agent-analyzer","last_synced_at":"2026-04-01T23:51:56.323Z","repository":{"id":344480792,"uuid":"1181969961","full_name":"agent-sh/agent-analyzer","owner":"agent-sh","description":"Static analysis binary for agent-sh ecosystem - git history, AST mapping, collectors","archived":false,"fork":false,"pushed_at":"2026-03-22T20:49:32.000Z","size":222,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-23T04:55:38.224Z","etag":null,"topics":["ai","ai-detection","bus-factor","code-analysis","code-ownership","coupling","git","hotspots","llm","repository","rust","static-analysis"],"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/agent-sh.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-03-14T21:43:51.000Z","updated_at":"2026-03-22T20:49:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/agent-sh/agent-analyzer","commit_stats":null,"previous_names":["agent-sh/agent-analyzer"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/agent-sh/agent-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-sh%2Fagent-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-sh%2Fagent-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-sh%2Fagent-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-sh%2Fagent-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agent-sh","download_url":"https://codeload.github.com/agent-sh/agent-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agent-sh%2Fagent-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: 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","ai-detection","bus-factor","code-analysis","code-ownership","coupling","git","hotspots","llm","repository","rust","static-analysis"],"created_at":"2026-03-20T08:00:41.324Z","updated_at":"2026-04-01T23:51:56.315Z","avatar_url":"https://github.com/agent-sh.png","language":"Rust","funding_links":[],"categories":["Command Details"],"sub_categories":["/git-map"],"readme":"# agent-analyzer\n\n[![CI](https://github.com/agent-sh/agent-analyzer/actions/workflows/ci.yml/badge.svg)](https://github.com/agent-sh/agent-analyzer/actions/workflows/ci.yml)\n[![Release](https://github.com/agent-sh/agent-analyzer/actions/workflows/release.yml/badge.svg)](https://github.com/agent-sh/agent-analyzer/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\nStatic analysis binary for the [agent-sh](https://github.com/agent-sh) ecosystem. Extracts temporal, social, and behavioral signals from git history - who changed what, when, how often, and whether AI tools were involved.\n\nProduces a single cached JSON artifact that answers questions like \"which files change together?\", \"who owns this module?\", and \"what percentage of commits are AI-generated?\" - without touching git again after the initial scan.\n\n## Why this project\n\n- Use this when you need git-based code intelligence (hotspots, coupling, ownership) without shelling out to `git log` on every query\n- Use this when you want to detect and quantify AI-generated commits across a repository\n- Use this when you need incremental updates - only process new commits since the last scan\n- Use this when building developer tools that need structured repository history as JSON\n\n## Installation\n\n### Pre-built binaries\n\nDownload from [GitHub Releases](https://github.com/agent-sh/agent-analyzer/releases) for your platform:\n\n| Platform | Target |\n|----------|--------|\n| Linux x64 | `x86_64-unknown-linux-gnu` |\n| Linux x64 (static) | `x86_64-unknown-linux-musl` |\n| Linux ARM64 | `aarch64-unknown-linux-gnu` |\n| macOS ARM64 | `aarch64-apple-darwin` |\n| Windows x64 | `x86_64-pc-windows-msvc` |\n\n### From source\n\n```bash\ncargo install --path crates/analyzer-cli\n```\n\n### Via agent-sh plugins\n\nIf you use the [git-map](https://github.com/agent-sh/git-map) plugin, the binary is downloaded automatically on first use. No manual install needed.\n\n## Quick start\n\n```bash\n# Scan a repository's full git history\nagent-analyzer repo-intel init ./my-repo \u003e repo-intel.json\n\n# Query the cached result - no git access needed\nagent-analyzer repo-intel query hotspots ./my-repo --map-file repo-intel.json --top 5\n```\n\nOutput (JSON to stdout):\n\n```json\n[\n  { \"path\": \"src/engine.rs\", \"changes\": 142, \"authors\": 5, \"lastChanged\": \"2026-03-10\" },\n  { \"path\": \"src/api/handler.rs\", \"changes\": 98, \"authors\": 3, \"lastChanged\": \"2026-03-14\" }\n]\n```\n\nProgress and errors go to stderr, so piping and redirection work as expected.\n\n## Core concepts\n\n**Two-phase architecture**: First, `init` or `update` walks git history and produces a `RepoIntelData` JSON artifact. Then, `query` subcommands operate entirely on that cached artifact - no repository access required.\n\n**Incremental by default**: After the initial scan, `update` only processes commits after `analyzedUpTo`. If a force-push is detected (the recorded SHA is no longer in history), it falls back to a full rebuild automatically.\n\n**AI-aware from the ground up**: Every commit is checked against a multi-signal detection pipeline. The signature registry (`ai_signatures.json`) is data, not code - add new AI tools by editing a JSON file.\n\n## Features\n\n- **Git history extraction** - commit metadata, per-file diff stats, rename tracking, deletion tracking via libgit2 (no subprocess calls)\n- **AI commit detection** - identifies commits from Claude, Cursor, Copilot, Aider, Replit, Windsurf, Devin, and bots like Dependabot and Renovate using trailers, author patterns, and message signatures\n- **Hotspot analysis** - find the most frequently changed files, optionally filtered by time window\n- **Coupling analysis** - discover files that change together (co-change frequency with configurable thresholds)\n- **Ownership queries** - primary author, contributor breakdown, and bus factor per file or directory\n- **Bus factor** - how many people cover 80% of commits, with optional AI-adjustment\n- **Convention detection** - conventional commit style, prefix frequency, scope patterns\n- **Release tracking** - tag-based release cadence, unreleased commit count\n- **Health scoring** - composite metric combining activity, bus factor, frequency, and AI ratio\n- **Noise filtering** - automatically excludes lockfiles, minified assets, `dist/`, `build/`, `vendor/` from analysis\n\n## Usage\n\n### Full scan\n\n```bash\nagent-analyzer repo-intel init /path/to/repo \u003e repo-intel.json\n```\n\n### Incremental update\n\n```bash\nagent-analyzer repo-intel update /path/to/repo --map-file repo-intel.json \u003e git-map-updated.json\n```\n\n### Check status\n\n```bash\nagent-analyzer repo-intel status /path/to/repo --map-file repo-intel.json\n```\n\nReturns `current`, `stale`, or `rebuild_needed`.\n\n### Queries\n\nAll queries read from the cached JSON - no git access.\n\n```bash\n# Most-changed files\nagent-analyzer repo-intel query hotspots . --map-file repo-intel.json --top 10\n\n# Files that change together with a given file\nagent-analyzer repo-intel query coupling src/engine.rs . --map-file repo-intel.json\n\n# Who owns a file or directory\nagent-analyzer repo-intel query ownership src/core/ . --map-file repo-intel.json\n\n# Bus factor (people covering 80% of commits)\nagent-analyzer repo-intel query bus-factor . --map-file repo-intel.json --adjust-for-ai\n\n# Newcomer orientation summary\nagent-analyzer repo-intel query onboard . --map-file repo-intel.json\n\n# Outside contributor guidance\nagent-analyzer repo-intel query can-i-help . --map-file repo-intel.json\n```\n\n## Architecture\n\nRust workspace with 6 crates:\n\n```\nanalyzer-core             shared types, git2 wrapper, AI detection, file walking, JSON output\n    |\n    +-- analyzer-git-map      git history extraction, aggregation, queries, incremental\n    +-- analyzer-repo-map     AST-based symbol mapping (Phase 2)\n    +-- analyzer-collectors   project data gathering (Phase 3)\n    +-- analyzer-sync-check   doc-code sync analysis (Phase 4)\n    |\nanalyzer-cli              unified binary, clap dispatch\n```\n\n### AI detection pipeline\n\nChecks are ordered by confidence (highest first):\n\n1. Trailer emails (`Co-Authored-By` containing known AI service emails)\n2. Author emails (known AI tool domains)\n3. Bot authors (exact match: `dependabot[bot]`, `renovate[bot]`)\n4. Author name patterns (regex: `\\(aider\\)$`, `\\[bot\\]$`)\n5. Message body patterns (`Generated with Claude Code`, `^aider: `)\n6. Trailer names (`Co-Authored-By` name field: Claude, Cursor, Copilot)\n\nSignatures are loaded from an embedded JSON registry (`ai_signatures.json`). To add a new AI tool, update that file - no code changes needed.\n\n## Limitations\n\n- **Merge commits are skipped** - only non-merge commits are analyzed, which matches how most tools attribute changes\n- **Shallow clones** - work but produce incomplete history; the output includes a `shallow: true` flag\n- **Large monorepos** - initial scan scales linearly with commit count; use `--max-commits` to bound the scan\n- **Stub crates** - `repo-map`, `collectors`, and `sync-check` subcommands print \"not yet implemented\" (Phases 2-4)\n\n## Development\n\n```bash\ncargo test                            # 77 tests across all crates\ncargo clippy -- -D warnings           # lint\ncargo fmt --check                     # format check\ncargo build --release                 # optimized binary (LTO + stripped)\n```\n\n## Integration\n\nThis binary is consumed by JS plugins in the agent-sh ecosystem via a binary resolver in [agent-core](https://github.com/agent-sh/agent-core):\n\n- JS calls `binary.ensureBinary()` which auto-downloads from GitHub releases\n- Binary location: `~/.agent-sh/bin/agent-analyzer[.exe]`\n- No manual install - lazy download on first use\n\nCurrent consumers:\n- [git-map](https://github.com/agent-sh/git-map) plugin (JS wrapper for `/git-map` command)\n\nPlanned consumers (Phases 2-4):\n- `repo-map` plugin (replace ast-grep subprocess)\n- `agent-core/lib/collectors/` (replace JS implementations)\n- `sync-docs` plugin (replace JS analysis)\n\n## Contributing\n\n1. Fork and create a feature branch\n2. Write tests for new functionality\n3. Ensure `cargo test`, `cargo clippy -- -D warnings`, and `cargo fmt --check` all pass\n4. Open a PR - direct pushes to main are not allowed\n\nTo add a new AI tool signature, edit `crates/analyzer-core/src/ai_signatures.json` and add a test case.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-sh%2Fagent-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagent-sh%2Fagent-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagent-sh%2Fagent-analyzer/lists"}