token-reporter

每日自动统计 OpenClaw 实例 Token 消耗和工作产出,上报到飞书多维表格。扫描 JSONL 日志按模型聚合 token,收集各 agent 当日工作摘要,写入飞书 Bitable。触发:'token报告'、'token report'、'日报'、'每日汇报'、'飞书上报'。

33 stars

Best use case

token-reporter is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

每日自动统计 OpenClaw 实例 Token 消耗和工作产出,上报到飞书多维表格。扫描 JSONL 日志按模型聚合 token,收集各 agent 当日工作摘要,写入飞书 Bitable。触发:'token报告'、'token report'、'日报'、'每日汇报'、'飞书上报'。

Teams using token-reporter should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/token-reporter/SKILL.md --create-dirs "https://raw.githubusercontent.com/aAAaqwq/AGI-Super-Team/main/skills/token-reporter/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/token-reporter/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How token-reporter Compares

Feature / Agenttoken-reporterStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

每日自动统计 OpenClaw 实例 Token 消耗和工作产出,上报到飞书多维表格。扫描 JSONL 日志按模型聚合 token,收集各 agent 当日工作摘要,写入飞书 Bitable。触发:'token报告'、'token report'、'日报'、'每日汇报'、'飞书上报'。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Token Reporter — 每日 Token 消耗 + 产出上报

- Author: Daniel Li
- Copyright © Daniel Li. All rights reserved.

## 功能概述

每天自动统计本机 OpenClaw 实例的 Token 消耗和 Agent 工作产出,格式化后写入飞书多维表格。

## 实例对应关系

| 实例 | CEO Agent | 上报人 |
|------|-----------|--------|
| aa (本机) | 小a (main) | Daniel |
| Peter Mini | 小兔 (xiaotu) | Peter |
| 小m | 小m bot | 小m |

## 执行流程

### Step 1: 扫描 JSONL 日志

扫描 `~/.openclaw/agents/*/sessions/*.jsonl` 中当日增量数据。

每条 assistant 消息携带 `usage` 对象:
```json
{
  "usage": {
    "input": 27813,
    "output": 246,
    "cacheRead": 6720,
    "cacheWrite": 0,
    "totalTokens": 34779,
    "cost": {
      "input": 0, "output": 0,
      "cacheRead": 0, "cacheWrite": 0,
      "total": 0
    }
  }
}
```

### Step 2: 按 Agent + Model 聚合

重点追踪 4 个模型(其他模型归入"其他"):

| 模型 | 匹配规则 |
|------|---------|
| opus4.6 | `claude-opus-4-6` (xingsuancode, xingjiabiapi) |
| glm-5 | `zai/glm-5` |
| minimax-M2.5 | `minimax/MiniMax-M2.5` |
| gemini-3-pro | `gemini-3-pro` (xingjiabiapi) |

### Step 3: 格式化 Token 明细

```
opus4.6: input 320K / output 18K / cache 82% / $4.2
glm-5: input 1.2M / output 85K / cache 78% / $0.3
minimax-M2.5: input 200K / output 12K / cache 0% / $0.1
gemini: — (当日未使用)
```

cache% = cacheRead / (input + cacheRead + cacheWrite) × 100

### Step 4: 收集产出

汇总各 agent 当日工作摘要,格式:
```
code: KGKB工厂30/30完成, 5平台发布脚本 | content: 小红书×2, 选题推荐 | ops: cron改造, 服务器巡检
```

产出收集方式:
1. 读取当日 memory 文件 `~/clawd/memory/$(date +%Y-%m-%d).md`
2. 解析 `## Agent名` 段落或关键词匹配
3. 如无 memory 文件,从 JSONL 最后一条 user/assistant 消息摘要推断

### Step 5: 写入飞书多维表格

使用 `lark-mcp` 工具写入 Bitable:

| 字段 | 类型 | 填写者 | 说明 |
|------|------|--------|------|
| 员工名称 | 文本 | config | config.json 写死 `person` |
| Token明细 | 文本 | 脚本统计 | 4模型格式化文本 |
| 产出 | 文本 | 脚本统计 | 各agent当日工作摘要 |
| 个人总结 | 文本 | 人填 | 员工手动填写(留空) |
| 评分 | 单选 | 高层选 | 优秀/良好/不及格(留空) |
| 时间 | 日期 | 脚本自动 | 当天日期 |

### 飞书 API

- 参考 skill: `~/clawd/skills/feishu-automation/SKILL.md`
- 工具前缀: `mcp__lark-mcp_*`
- 新增记录: `mcp__lark-mcp_createRecord`
- 查询记录: `mcp__lark-mcp_listRecords`

## 脚本用法

```bash
# 统计当日 Token(只看数据,不上报)
python scripts/report.py --scan-only

# 统计 + 上报飞书
python scripts/report.py --report

# 指定日期
python scripts/report.py --date 2026-03-17 --scan-only

# 使用指定配置
python scripts/report.py --config /path/to/config.json --report
```

## Cron 配置建议

```json
{
  "name": "📊 每日 Token 报告 + 飞书上报",
  "schedule": { "kind": "cron", "expr": "0 23 * * *", "tz": "Asia/Shanghai" },
  "payload": {
    "kind": "agentTurn",
    "message": "执行每日 Token 报告任务:\n1. 运行 python3 ~/clawd/skills/token-reporter/scripts/report.py --scan-only\n2. 查看输出,确认数据合理\n3. 运行 python3 ~/clawd/skills/token-reporter/scripts/report.py --report\n4. 确认飞书写入成功后,用 message(action=send, channel=telegram, target=-1003890797239) 简要汇报\n5. 如果失败,报告错误原因"
  }
}
```

## 配置

安装时复制 `config.example.json` → `config.json` 并填写:

```json
{
  "person": "Daniel",
  "instance": "aa",
  "lark_app_id": "cli_a83467f9ecba5013",
  "bitable_app_token": "your_bitable_token",
  "bitable_table_id": "your_table_id"
}
```

## 文件结构

```
token-reporter/
├── SKILL.md
├── config.example.json    # 配置模板(安装时复制为 config.json)
├── scripts/
│   └── report.py          # 核心统计脚本
└── references/
    └── jsonl-structure.md # JSONL 数据结构参考
```

## 错误处理

| 错误 | 处理 |
|------|------|
| JSONL 文件损坏 | 跳过该行,记录警告 |
| 无当日数据 | 报告"当日无数据" |
| 飞书 API 失败 | 重试3次,失败后本地缓存结果 |
| config.json 不存在 | 提示复制 config.example.json |
| Memory 文件不存在 | 产出标记为"无记录" |

Related Skills

token-guard

33
from aAAaqwq/AGI-Super-Team

> Token 用量防护与限制——API 调用成本监控与预算保护

token-budget-advisor

33
from aAAaqwq/AGI-Super-Team

Intercept the response flow to offer the user a choice about response depth **before** Claude answers

clawbio-pharmgx-reporter

33
from aAAaqwq/AGI-Super-Team

Pharmacogenomic report from DTC genetic data (23andMe/AncestryDNA)

wemp-operator

33
from aAAaqwq/AGI-Super-Team

> 微信公众号全功能运营——草稿/发布/评论/用户/素材/群发/统计/菜单/二维码 API 封装

Content & Documentation

zsxq-smart-publish

33
from aAAaqwq/AGI-Super-Team

Publish and manage content on 知识星球 (zsxq.com). Supports talk posts, Q&A, long articles, file sharing, digest/bookmark, homework tasks, and tag management. Use when publishing content to 知识星球, creating/editing posts, uploading files/images/audio, managing digests, batch publishing, or formatting content for 知识星球.

zoom-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zoom meeting creation, management, recordings, webinars, and participant tracking via Rube MCP (Composio). Always search tools first for current schemas.

zoho-crm-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zoho CRM tasks via Rube MCP (Composio): create/update records, search contacts, manage leads, and convert leads. Always search tools first for current schemas.

ziliu-publisher

33
from aAAaqwq/AGI-Super-Team

字流(Ziliu) - AI驱动的多平台内容分发工具。用于一次创作、智能适配排版、一键分发到16+平台(公众号/知乎/小红书/B站/抖音/微博/X等)。当用户需要多平台发布、内容排版、格式适配时使用。触发词:字流、ziliu、多平台发布、一键分发、内容分发、排版发布。

zhihu-post-skill

33
from aAAaqwq/AGI-Super-Team

> 知乎文章发布——知乎平台内容创作与发布自动化

zendesk-automation

33
from aAAaqwq/AGI-Super-Team

Automate Zendesk tasks via Rube MCP (Composio): tickets, users, organizations, replies. Always search tools first for current schemas.

youtube-knowledge-extractor

33
from aAAaqwq/AGI-Super-Team

This skill performs deep analysis of YouTube videos through **both information channels** Multimodal YouTube video analysis through both audio (transcript) and visual (frame extraction + image analysis) channels. Especially powerful for HowTo videos, tutorials, demos, and explainer videos where what is SHOWN (screenshots, UI demos, diagrams, code, physical actions) is just as important as what is SAID. Use this skill whenever a user wants to analyze, summarize, or create step-by-step guides from YouTube videos, or when they share a YouTube URL and want to understand what happens in the video. Triggers on requests like "Analyze this YouTube video", "Create a step-by-step guide from this video", "What does this video show?", "Summarize this tutorial", or any YouTube URL shared with analysis intent.

youtube-factory

33
from aAAaqwq/AGI-Super-Team

Generate complete YouTube videos from a single prompt - script, voiceover, stock footage, captions, thumbnail. Self-contained, no external modules. 100% free tools.