kenn-io / agentsview

kenn-io / agentsview

agentsview allows you to browse, search, and track costs across all your AI coding agents. It is a single binary, requires no accounts, and keeps everything local. agentsview 是一款可以让你浏览、搜索并追踪所有 AI 编程代理(AI coding agents)成本的工具。它是一个单一二进制文件,无需注册账号,所有数据均在本地处理。

Install / 安装

macOS / Linux

curl -fsSL https://agentsview.io/install.sh | bash

Windows

powershell -ExecutionPolicy ByPass -c "irm https://agentsview.io/install.ps1 | iex"

Or download the desktop app (macOS / Windows) from GitHub Releases or via homebrew: 或者从 GitHub Releases 下载桌面应用(macOS / Windows),也可以通过 homebrew 安装:

brew install --cask agentsview

Or run the published Docker image: 或者运行已发布的 Docker 镜像:

docker run --rm -p 127.0.0.1:8080:8080 \
  -v agentsview-data:/data \
  -v "$HOME/.claude/projects:/agents/claude:ro" \
  -v "$HOME/.forge:/agents/forge:ro" \
  -e CLAUDE_PROJECTS_DIR=/agents/claude \
  -e FORGE_DIR=/agents/forge \
  ghcr.io/kenn-io/agentsview:latest

Quick Start / 快速开始

agentsview serve # start server, open web UI / 启动服务器并打开 Web UI
agentsview usage daily # print daily cost summary / 打印每日成本汇总

On first run, agentsview discovers sessions from every supported agent on your machine, syncs them into a local SQLite database, and opens a web UI at http://127.0.0.1:8080. 首次运行时,agentsview 会自动发现你机器上所有受支持代理的会话,将它们同步到本地 SQLite 数据库中,并在 http://127.0.0.1:8080 打开 Web UI。

Remote / forwarded access / 远程或转发访问

agentsview binds to loopback and validates the request Host header to guard against DNS-rebinding attacks. When you reach it through SSH port-forwarding, a reverse proxy, or a remote dev environment (exe.dev, Codespaces, Coder, WSL2), the browser sends a Host that the server does not recognize, so API requests such as /api/v1/settings are rejected with 403 Forbidden. agentsview 默认绑定到回环地址(loopback),并验证请求的 Host 标头以防止 DNS 重绑定攻击。当你通过 SSH 端口转发、反向代理或远程开发环境(如 exe.dev, Codespaces, Coder, WSL2)访问时,浏览器发送的 Host 标头可能无法被服务器识别,导致 API 请求(如 /api/v1/settings)被拒绝并返回 403 Forbidden。

To fix this, restart the server with —public-url set to the exact origin you open in the browser: 要解决此问题,请使用 --public-url 参数重启服务器,并将其设置为你在浏览器中打开的确切来源地址:

# Browser opens http://127.0.0.1:18080 via `ssh -L 18080:127.0.0.1:8080 host`
# 通过 `ssh -L 18080:127.0.0.1:8080 host` 在浏览器打开 http://127.0.0.1:18080
agentsview serve --public-url http://127.0.0.1:18080

# Browser opens a forwarded hostname
# 浏览器打开转发的主机名
agentsview serve --public-url https://your-workspace.exe.dev

Use —public-origin (repeatable or comma-separated) to trust additional browser origins. If you expose the UI beyond loopback, also enable —require-auth. 使用 --public-origin(可重复使用或用逗号分隔)来信任额外的浏览器来源。如果你将 UI 暴露在回环地址之外,请务必启用 --require-auth

Docker

The container image defaults to local agentsview serve. Set PG_SERVE=1 to switch the startup command to agentsview pg serve instead. 容器镜像默认执行本地 agentsview serve。设置 PG_SERVE=1 可将启动命令切换为 agentsview pg serve

docker-compose.prod.yaml is included as a production example: 随附的 docker-compose.prod.yaml 可作为生产环境示例:

docker compose -f docker-compose.prod.yaml up -d

The included compose file persists the agentsview data directory in a named volume and mounts Claude, Codex, Forge, and OpenCode session roots read-only. 该 compose 文件将 agentsview 数据目录持久化在命名卷中,并以只读方式挂载 Claude、Codex、Forge 和 OpenCode 的会话根目录。

Token Usage and Cost Tracking / Token 使用量与成本追踪

agentsview usage is a fast, local replacement for ccusage and similar tools. It tracks token consumption and compute costs across all your coding agents — not just Claude Code. Because session data is already indexed in SQLite, queries are over 100x faster than tools that re-parse raw session files on every run. agentsview usageccusage 及类似工具的快速本地替代方案。它能追踪所有编程代理的 Token 消耗和计算成本,而不仅仅是 Claude Code。由于会话数据已在 SQLite 中索引,其查询速度比每次运行都重新解析原始会话文件的工具快 100 倍以上。

# Daily cost summary (default: last 30 days)
# 每日成本汇总(默认:最近 30 天)
agentsview usage daily

# Per-model breakdown
# 按模型细分
agentsview usage daily --breakdown

# Filter by agent and date range
# 按代理和日期范围过滤
agentsview usage daily --agent claude --since 2026-04-01

# One-line summary for shell prompts / status bars
# 用于 Shell 提示符或状态栏的单行摘要
agentsview usage daily --all --json
agentsview usage statusline

Features / 功能特性

  • Automatic pricing via LiteLLM rates (with offline fallback) / 通过 LiteLLM 费率自动计算价格(支持离线回退)
  • Prompt-caching-aware cost calculation (cache creation / read tokens) / 支持提示词缓存的成本计算(缓存创建/读取 Token)
  • Per-model breakdown with --breakdown / 使用 --breakdown 进行按模型细分
  • Date filtering (--since, --until, --all), agent filtering (--agent) / 日期过滤(--since, --until, --all)及代理过滤(--agent
  • JSON output (--json) for scripting / 用于脚本编写的 JSON 输出(--json
  • Timezone-aware date bucketing (--timezone) / 支持时区的日期分组(--timezone
  • Works standalone — no server required, just run the command / 独立运行——无需服务器,直接运行命令即可

Per-Session Details / 会话详情

agentsview session usage <id> prints per-session token statistics plus a cost estimate for a single session. agentsview session usage <id> 可打印单个会话的 Token 统计信息及成本估算。

# Print token usage and cost for a specific session
# 打印特定会话的 Token 使用量和成本
agentsview session usage <id>

# JSON output for scripting
# 用于脚本编写的 JSON 输出
agentsview session usage <id> --format json