[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80507":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":12,"openIssues":13,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":14,"forks30d":14,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":9,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":14,"starSnapshotCount":14,"syncStatus":15,"lastSyncTime":28,"discoverSource":29},80507,"zap","bitan-del\u002Fzap","bitan-del","Zap — high-performance CLI proxy that filters command output to save 60-90% AI tokens",null,"Rust",174,85,1,0,2,44,84,14,5.8,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:04:03","# Zap\n\n> **Snip noisy command output before it hits your AI.**\n> 60–90% fewer tokens. Zero quality loss. Runs entirely on-device.\n\nZap is a high-performance CLI proxy written in Rust. It sits between your AI\ncoding assistant (Claude, Copilot, Cursor, Gemini, …) and the shell, then\nfilters, groups, deduplicates, and truncates command output so the AI gets a\ncompact summary instead of thousands of noisy lines.\n\n```\nWithout Zap                                    With Zap\n\nAI  --git status-->  shell  -->  git           AI  --git status-->  zap  -->  git\n  ^                              |               ^                   |        |\n  |  ~2,000 tokens (raw)         |               |   ~200 tokens     | filter |\n  +------------------------------+               +-------(filtered)--+--------+\n```\n\n---\n\n## Token Savings (real-world session)\n\n| Operation              | Frequency | Raw    | Zap    | Savings |\n| ---------------------- | --------- | ------ | ------ | ------- |\n| `ls` \u002F `tree`          | 10×       | 2,000  | 400    | -80%    |\n| `cat` \u002F `read`         | 20×       | 40,000 | 12,000 | -70%    |\n| `grep` \u002F `rg`          | 8×        | 16,000 | 3,200  | -80%    |\n| `git status`           | 10×       | 3,000  | 600    | -80%    |\n| `git diff`             | 5×        | 10,000 | 2,500  | -75%    |\n| `git log`              | 5×        | 2,500  | 500    | -80%    |\n| `git add\u002Fcommit\u002Fpush`  | 8×        | 1,600  | 120    | -92%    |\n| `cargo test`\u002F`npm test`| 5×        | 25,000 | 2,500  | -90%    |\n| `pytest`               | 4×        | 8,000  | 800    | -90%    |\n| `go test`              | 3×        | 6,000  | 600    | -90%    |\n| `docker ps`            | 3×        | 900    | 180    | -80%    |\n| **Total**              |           | **~115,000** | **~23,400** | **-80%** |\n\n---\n\n## Installation\n\n### Prerequisites\n\n> **⚠️ Rust toolchain is required.** Zap is a Rust binary you build from source.\n> If you don't already have Rust installed, install it first (takes ~2 minutes):\n\n```bash\n# Install Rust via rustup (official installer)\ncurl --proto '=https' --tlsv1.2 -sSf https:\u002F\u002Fsh.rustup.rs | sh\n\n# Activate it in the current shell (only needed for this terminal session)\nsource \"$HOME\u002F.cargo\u002Fenv\"\n\n# Verify\ncargo --version    # should print: cargo 1.xx.x\n```\n\nWhen the rustup installer asks, just press **Enter** to accept the default options. It installs to `~\u002F.cargo` and `~\u002F.rustup` — no `sudo` needed, nothing system-wide.\n\nAlready have Rust? Make sure it's reasonably current:\n```bash\nrustup update stable\n```\n\n### Build & install Zap\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fbitan-del\u002Fzap.git\ncd zap\ncargo install --path .\n```\n\nThis compiles Zap in release mode (~1–2 minutes first time) and puts the `zap` binary in `~\u002F.cargo\u002Fbin\u002F`. Make sure that's on your `PATH`:\n\n```bash\necho 'export PATH=\"$HOME\u002F.cargo\u002Fbin:$PATH\"' >> ~\u002F.zshrc   # or ~\u002F.bashrc\nsource ~\u002F.zshrc\n```\n\n### Verify\n\n```bash\nzap --version       # → zap 0.1.0\nzap --help\nzap git status      # inside any git repo\n```\n\n### Troubleshooting\n\n| Problem | Fix |\n|---------|-----|\n| `command not found: cargo` | Run `source \"$HOME\u002F.cargo\u002Fenv\"` or restart your terminal |\n| `command not found: zap` after install | `export PATH=\"$HOME\u002F.cargo\u002Fbin:$PATH\"` |\n| `cargo install` fails with compiler errors | `rustup update stable` to update Rust |\n| Build is slow first time | Normal (~2 min). Subsequent builds are seconds. |\n\n---\n\n## Quick Start\n\n```bash\n# Files\nzap ls .\nzap read src\u002Fmain.rs\nzap grep \"pattern\" .\nzap find \"*.rs\" .\n\n# Git\nzap git status\nzap git log -n 10\nzap git diff\nzap git push           # → \"ok main\"\n\n# Tests\nzap cargo test\nzap pytest\nzap go test\nzap jest \u002F zap vitest\n\n# Build & lint\nzap cargo build\nzap cargo clippy\nzap lint               # ESLint, grouped by rule\nzap tsc                # TypeScript errors, grouped by file\nzap ruff check\nzap golangci-lint run\n\n# Cloud\nzap docker ps\nzap kubectl pods\nzap aws ec2 describe-instances\n\n# Analytics (see \"Check Your Savings\" section below for full reference)\nzap gain               # See token savings stats\nzap gain --graph       # ASCII graph (last 30 days)\nzap gain --history     # Recent command history\n```\n\n---\n\n## How It Works\n\nZap applies **12 filtering strategies** depending on the command:\n\n| # | Strategy            | Example                                              | Reduction |\n| - | ------------------- | ---------------------------------------------------- | --------- |\n| 1 | Stats Extraction    | 5000 diff lines → `\"3 files, +142\u002F-89\"`              | 90–99%    |\n| 2 | Error Only          | mixed stdout+stderr → stderr only                    | 60–80%    |\n| 3 | Grouping            | 100 lint errors → `\"no-unused-vars: 23, semi: 45\"`   | 80–90%    |\n| 4 | Deduplication       | repeated logs → `\"[ERROR] ... (×5)\"`                 | 70–85%    |\n| 5 | Structure Only      | huge JSON → keys + types, values stripped            | 80–95%    |\n| 6 | Code Filtering      | source → strip comments\u002Fbodies (level-based)         | 20–90%    |\n| 7 | Failure Focus       | 100 tests → only failures                            | 94–99%    |\n| 8 | Tree Compression    | flat list → tree with counts                         | 50–70%    |\n| 9 | Progress Filtering  | ANSI progress bars → final result                    | 85–95%    |\n| 10| JSON\u002FText Dual Mode | uses tool's `--format json` when available           | 80%+      |\n| 11| State Machine       | pytest output → counts + failures                    | 90%+      |\n| 12| NDJSON Streaming    | `go test` events → aggregated summary                | 90%+      |\n\n---\n\n## Hook Integration (Claude Code)\n\nFor zero-friction usage, install the hook so every `git status` is auto-rewritten\nto `zap git status` before execution:\n\n```bash\nzap init -g           # Install global hook for Claude Code\n```\n\nThen restart Claude Code. After that, the AI's normal shell commands get\nfiltered transparently — no need to type `zap` yourself.\n\nHooks are also available for Cursor, Gemini CLI, Copilot, Windsurf, Cline, and\nmore. Run `zap init --help` for the full list.\n\n---\n\n## Check Your Savings\n\nEvery command Zap filters is logged to a local SQLite database. Four ways to inspect it:\n\n### 1. Quick summary\n\n```bash\nzap gain\n```\n\nSample output:\n\n```\nZap Token Savings (Global Scope)\n════════════════════════════════════════════════════════════\n\nTotal commands:    127\nInput tokens:      48,302\nOutput tokens:     9,142\nTokens saved:      39,160 (81.1%)\nTotal exec time:   612ms (avg 4ms)\nEfficiency meter: ████████████████████░░░░ 81.1%\n```\n\n### 2. Recent command history\n\nSee which commands got filtered and how much they each saved:\n\n```bash\nzap gain --history\n```\n\n```\n05-25 14:22 ▲ zap git log -n 10         -82% (412)\n05-25 14:21 ▲ zap cargo test            -94% (1,830)\n05-25 14:20 ▲ zap git status            -75% (76)\n05-25 14:18 ■ zap ls -la .              -89% (57)\n```\n\nSymbols: `▲` high savings · `■` medium · `•` low \u002F passthrough.\n\n### 3. 30-day ASCII graph\n\n```bash\nzap gain --graph\n```\n\nVisual bar chart of daily savings — satisfying to watch grow over time.\n\n### 4. Per-project scope\n\nBy default `zap gain` shows global savings. To see only the project you're in:\n\n```bash\ncd \u002Fpath\u002Fto\u002Fyour-project\nzap gain --scope project\n```\n\n### More flags\n\n```bash\nzap gain --daily              # Day-by-day breakdown\nzap gain --weekly             # Week-by-week\nzap gain --top 10             # Top 10 most-used commands\nzap gain --since 7            # Last 7 days only\nzap gain --format json        # Machine-readable (for dashboards)\nzap gain --all                # All-time stats\n```\n\n### Watch savings live\n\nOpen a terminal next to your AI assistant and run:\n\n```bash\nwatch -n 2 'zap gain | head -8'\n```\n\nThe numbers tick up every time your AI runs a shell command.\n\n> **Heads up:** If `zap gain` shows `Total commands: 0` even though you've been using Zap, the hook may not be loaded. Run `zap init --show` to verify the hook is registered, then restart your AI tool. See [Troubleshooting](#troubleshooting) above.\n\n---\n\n## Global Flags\n\n```\n-v, --verbose          # Increase verbosity (-v, -vv, -vvv)\n-u, --ultra-compact    # ASCII icons + inline format (maximum compression)\n```\n\n---\n\n## Configuration\n\nConfig lives at `~\u002F.config\u002Fzap\u002Fconfig.toml` (or `~\u002FLibrary\u002FApplication Support\u002Fzap\u002Fconfig.toml` on macOS).\n\n```toml\n[hooks]\nexclude_commands = [\"curl\", \"playwright\"]   # skip rewrite for these\n\n[tee]\nenabled = true        # save raw output on failure (default: true)\nmode = \"failures\"     # \"failures\", \"always\", or \"never\"\n```\n\nWhen a command fails, Zap saves the full unfiltered output to a `tee` file\nso the AI can read it without re-executing the command.\n\n---\n\n## Performance\n\n- Binary: ~4 MB stripped\n- Startup: \u003C10ms cold\n- Memory: \u003C5 MB typical\n- Filter overhead: 2–15ms depending on strategy\n\n---\n\n## Architecture\n\n- `src\u002Fmain.rs` — Clap router, command dispatch\n- `src\u002Fcmds\u002F` — 42 command filter modules (git, cargo, npm, pytest, docker, …)\n- `src\u002Fcore\u002F` — Shared infra (utils, tracking, tee, config, TOML filter engine)\n- `src\u002Ffilters\u002F` — 60+ declarative TOML filter recipes\n- `src\u002Fhooks\u002F` — Hook installer (`zap init`) for 10+ AI tools\n- `src\u002Fanalytics\u002F` — Token savings reporting (`zap gain`)\n\n---\n\n## Contributing\n\nPRs welcome. New filters are easy to add — see `src\u002Fcmds\u002FREADME.md` for the\nstep-by-step checklist.\n\n---\n\n## License\n\nApache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).\n","Zap 是一个高性能的命令行界面代理工具，旨在通过过滤命令输出来减少60-90%的AI令牌消耗。它使用Rust语言编写，能够截取、分组、去重和截断命令输出，为AI提供紧凑的摘要而非冗长的原始数据流，从而在不牺牲信息质量的前提下显著节省成本。适用于与AI编码助手（如Claude, Copilot等）协同工作的场景中，尤其当需要频繁执行会产生大量输出的命令时，Zap能有效提高效率并降低成本。","2026-06-11 04:01:01","CREATED_QUERY"]