tokenmetre 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tokenmetre-0.2.0/PKG-INFO +189 -0
- tokenmetre-0.2.0/README.md +156 -0
- tokenmetre-0.2.0/pyproject.toml +58 -0
- tokenmetre-0.2.0/setup.cfg +4 -0
- tokenmetre-0.2.0/src/tokenmetre/__init__.py +1 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/__init__.py +1 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/__init__.py +1 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/adapter.py +498 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/commands/tokenmetre-report.md +69 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/commands/tokenmetre-scan.md +92 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/install.py +248 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/skills/tokenmetre/SKILL.md +158 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/claude-code/skills/tokenmetre-pricing/SKILL.md +131 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/trae/__init__.py +8 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/trae/adapter.py +263 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/trae/decrypt.py +394 -0
- tokenmetre-0.2.0/src/tokenmetre/adapters/trae/extractor.py +244 -0
- tokenmetre-0.2.0/src/tokenmetre/cli/__init__.py +0 -0
- tokenmetre-0.2.0/src/tokenmetre/cli/main.py +586 -0
- tokenmetre-0.2.0/src/tokenmetre/core/__init__.py +1 -0
- tokenmetre-0.2.0/src/tokenmetre/core/bind.py +328 -0
- tokenmetre-0.2.0/src/tokenmetre/core/core.py +24 -0
- tokenmetre-0.2.0/src/tokenmetre/core/db.py +534 -0
- tokenmetre-0.2.0/src/tokenmetre/core/domain.py +497 -0
- tokenmetre-0.2.0/src/tokenmetre/core/emit.py +302 -0
- tokenmetre-0.2.0/src/tokenmetre/core/gconfig.py +103 -0
- tokenmetre-0.2.0/src/tokenmetre/core/loader.py +86 -0
- tokenmetre-0.2.0/src/tokenmetre/core/registry.py +622 -0
- tokenmetre-0.2.0/src/tokenmetre/data/weights.yaml +128 -0
- tokenmetre-0.2.0/src/tokenmetre/web/__init__.py +0 -0
- tokenmetre-0.2.0/src/tokenmetre/web/fonts/ibmplexmono-400.woff2 +0 -0
- tokenmetre-0.2.0/src/tokenmetre/web/fonts/ibmplexmono-500.woff2 +0 -0
- tokenmetre-0.2.0/src/tokenmetre/web/frontend/dist/assets/index-DpkkjUZ8.css +1 -0
- tokenmetre-0.2.0/src/tokenmetre/web/frontend/dist/assets/index-yIGPRcR5.js +18 -0
- tokenmetre-0.2.0/src/tokenmetre/web/frontend/dist/index.html +14 -0
- tokenmetre-0.2.0/src/tokenmetre/web/server.py +732 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/PKG-INFO +189 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/SOURCES.txt +40 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/dependency_links.txt +1 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/entry_points.txt +2 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/requires.txt +13 -0
- tokenmetre-0.2.0/src/tokenmetre.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tokenmetre
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Local-first token usage collector for AI coding agents (Claude Code): passive transcript scan, per-project stats, optional cloud sync
|
|
5
|
+
Author: bsawang
|
|
6
|
+
Project-URL: Homepage, https://github.com/bsawang/tokenMetreCom
|
|
7
|
+
Project-URL: Repository, https://github.com/bsawang/tokenMetreCom
|
|
8
|
+
Keywords: token,usage,claude-code,ai,metrics,cost
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: fastapi>=0.110
|
|
23
|
+
Requires-Dist: uvicorn>=0.29
|
|
24
|
+
Requires-Dist: pydantic>=2.6
|
|
25
|
+
Requires-Dist: pyjwt>=2.8
|
|
26
|
+
Requires-Dist: psycopg[binary,pool]>=3.1
|
|
27
|
+
Requires-Dist: alembic>=1.13
|
|
28
|
+
Requires-Dist: python-dotenv>=1.0
|
|
29
|
+
Provides-Extra: trae
|
|
30
|
+
Requires-Dist: pycryptodome>=3.20; extra == "trae"
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: tokenmetre[trae]; extra == "all"
|
|
33
|
+
|
|
34
|
+
# tokenMetre
|
|
35
|
+
|
|
36
|
+
AI 时代的开发工作量计量器。把 LLM 消耗的 token 作为衡量开发工作量的参考指标。
|
|
37
|
+
|
|
38
|
+
> 参考值,非权威计价标准。零 hook、纯 transcript 采集、按项目统计、可选云端协作。
|
|
39
|
+
|
|
40
|
+
## 它做什么
|
|
41
|
+
|
|
42
|
+
1. **注册项目**: `tokenmetre register add <cwd>` 登记目录
|
|
43
|
+
2. **扫描 transcript**: `tokenmetre scan` 纯文件读取 `~/.claude/projects/**/*.jsonl`
|
|
44
|
+
3. **确定性分类**: 同 token 合并成 LLM 调用组 → 工具→5 类映射
|
|
45
|
+
4. **落盘 SQLite**: 14 字段 Record,UNIQUE(session_id, ts) 天然去重
|
|
46
|
+
5. **Web 面板**: `tokenmetre web` 启动瘦统计面板
|
|
47
|
+
6. **可选云端协作**: 注册后可连 tokenmetre.umap.earth 多成员汇聚
|
|
48
|
+
|
|
49
|
+
## 线上入口
|
|
50
|
+
|
|
51
|
+
**https://tokenmetre.umap.earth** — 营销站 `/` · 用户工作台 `/app` · 运维后台 `/admin`。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 本地端安装
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install tokenmetre
|
|
59
|
+
tokenmetre install claude-code --verify
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `pip install` 把 CLI 装进系统
|
|
63
|
+
- `tokenmetre install claude-code` 做数据侧部署:幂等写 `~/.claude/settings.json` 的 cleanupPeriodDays + 软链 skill/command markdown
|
|
64
|
+
- 运行时数据落在 `~/.tokenmetre/`(SQLite / 配置缓存)
|
|
65
|
+
|
|
66
|
+
验证: `tokenmetre install claude-code --verify`
|
|
67
|
+
|
|
68
|
+
## 使用流程
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 1. 登记要计量的项目
|
|
72
|
+
tokenmetre register add E:\work\ai\some-project
|
|
73
|
+
tokenmetre register add E:\work\ai\another-project
|
|
74
|
+
|
|
75
|
+
# 2. 扫描(register add 已自动 scan;定期手动补扫)
|
|
76
|
+
tokenmetre scan
|
|
77
|
+
|
|
78
|
+
# 3. 看 Web 面板
|
|
79
|
+
tokenmetre web # http://127.0.0.1:8080
|
|
80
|
+
|
|
81
|
+
# 4. 或 CLI 报表
|
|
82
|
+
tokenmetre report --all
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## CLI 命令速查
|
|
86
|
+
|
|
87
|
+
| 命令 | 作用 |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `install claude-code [--verify]` | 安装/验证 CC adapter |
|
|
90
|
+
| `register add <cwd>` | 登记激活目录(自动 scan) |
|
|
91
|
+
| `register remove <cwd>` | 取消登记 |
|
|
92
|
+
| `register list` | 查看已登记项目 |
|
|
93
|
+
| `register claim <cwd> --id <tm_xxx>` | 显式认领(目录搬家后归位) |
|
|
94
|
+
| `scan [--force] [--project <cwd>]` | 扫描 transcript → SQLite |
|
|
95
|
+
| `report [--all] [--project <slug>]` | CLI 统计摘要 |
|
|
96
|
+
| `web [--port]` | 启动本地 Web 面板 |
|
|
97
|
+
| `cloud add [cwd] --base <url> --token <token>` | 启用某项目云端协作 |
|
|
98
|
+
| `cloud show / cloud remove` | 查看/关闭 cloud 配置 |
|
|
99
|
+
| `sync [--project <slug>]` | push 本地 pending records 到云端 |
|
|
100
|
+
| `config sync [--base <url>]` | 拉取云端全局配置 |
|
|
101
|
+
|
|
102
|
+
## 分类规则
|
|
103
|
+
|
|
104
|
+
5 类确定性映射(采集端不调 LLM),优先级: documentation > coding > execution > exploration > discussion
|
|
105
|
+
|
|
106
|
+
| category | 含义 |
|
|
107
|
+
|---|---|
|
|
108
|
+
| **文档** documentation | 写 markdown 文件 |
|
|
109
|
+
| **编码** coding | 写/改代码文件 |
|
|
110
|
+
| **实施** execution | 跑命令: 安装/构建/执行/文件操作 |
|
|
111
|
+
| **调研** exploration | 读文件/搜索/查 git/上网 |
|
|
112
|
+
| **讨论** discussion | 纯对话交互 |
|
|
113
|
+
|
|
114
|
+
详细判定规则见 `docs/spec.md §I.3`。
|
|
115
|
+
|
|
116
|
+
## 数据位置
|
|
117
|
+
|
|
118
|
+
| 路径 | 用途 |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `~/.tokenmetre/tokenmetre.db` | SQLite 主库 — records + processed_sessions |
|
|
121
|
+
| `~/.tokenmetre/projects.json` | 项目注册表(active/ignored/claims) |
|
|
122
|
+
| `~/.tokenmetre/config.json` | 云端全局配置缓存(config sync 拉取) |
|
|
123
|
+
| `~/.tokenmetre/weights.yaml` | provider 计价比重(无云端缓存时回退用) |
|
|
124
|
+
|
|
125
|
+
## 数据安全
|
|
126
|
+
|
|
127
|
+
Claude Code 默认 30 天清理 transcript。install 自动确保 `cleanupPeriodDays` ≥ 1(默认 365)。想长期保留就设大数字,无哨兵值。
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 云端部署(运维侧)
|
|
132
|
+
|
|
133
|
+
### 本地启动
|
|
134
|
+
|
|
135
|
+
```powershell
|
|
136
|
+
# 1. 配置 .env(参考 .env.example):
|
|
137
|
+
# DATABASE_URL / TMCOM_API_TOKEN / TMCOM_JWT_SECRET / TMCOM_ADMIN_PASSWORD
|
|
138
|
+
# 2. 安装依赖
|
|
139
|
+
pip install -e .
|
|
140
|
+
# 3. 从项目根启动(不能 cd api/)
|
|
141
|
+
python -m api.server --port 9000
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
首次启动自动: Alembic 迁移建表 + 种子 admin。
|
|
145
|
+
|
|
146
|
+
### Vercel + Supabase(生产)
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
# schema 变更后本地直连线上库执行迁移
|
|
150
|
+
python -c "from api import db; db.init()"
|
|
151
|
+
|
|
152
|
+
# 部署(CLI 直推,GitHub 自动部署已断开)
|
|
153
|
+
vercel deploy --prod --yes
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
环境变量(Vercel Dashboard): `DATABASE_URL`(Supabase pooler :6543) / `TMCOM_API_TOKEN` / `TMCOM_JWT_SECRET` / `TMCOM_ADMIN_PASSWORD` / `TMCOM_OPEN_REGISTER`(默认关) / 可选邮件 OAuth 配置。
|
|
157
|
+
|
|
158
|
+
### 前端构建
|
|
159
|
+
|
|
160
|
+
```powershell
|
|
161
|
+
cd api/web/site; npm install; npm run build # 营销站
|
|
162
|
+
cd ../user; npm install; npm run build # 用户工作台
|
|
163
|
+
cd ../admin; npm install; npm run build # 运维后台
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 数据库
|
|
167
|
+
|
|
168
|
+
PostgreSQL(Supabase 免费档)。连接串用 pooler :6543 transaction mode;密码含特殊字符需 percent-encode。
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 机器端接入
|
|
173
|
+
|
|
174
|
+
用户登录 `/app/projects` → 引导卡复制自己的 token:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
tokenmetre cloud add --base https://tokenmetre.umap.earth --token tm_xxxx
|
|
178
|
+
tokenmetre sync
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 配套文档
|
|
184
|
+
|
|
185
|
+
- [docs/spec.md](docs/spec.md) — 规约全文(Record/分类/公式 + 云端服务规约 + F 编号)
|
|
186
|
+
- [docs/api-contract.md](docs/api-contract.md) — 接口契约(本地端 + 机器端 API + 云端内部)
|
|
187
|
+
- [docs/architecture.md](docs/architecture.md) — 整体架构 + pip 打包边界
|
|
188
|
+
- [docs/README.md](docs/README.md) — 开发文档(目录结构 + 踩坑备忘)
|
|
189
|
+
- [docs/ROADMAP.md](docs/ROADMAP.md) — 进度表(Phase 分组 + F 编号贯穿,唯一权威源)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# tokenMetre
|
|
2
|
+
|
|
3
|
+
AI 时代的开发工作量计量器。把 LLM 消耗的 token 作为衡量开发工作量的参考指标。
|
|
4
|
+
|
|
5
|
+
> 参考值,非权威计价标准。零 hook、纯 transcript 采集、按项目统计、可选云端协作。
|
|
6
|
+
|
|
7
|
+
## 它做什么
|
|
8
|
+
|
|
9
|
+
1. **注册项目**: `tokenmetre register add <cwd>` 登记目录
|
|
10
|
+
2. **扫描 transcript**: `tokenmetre scan` 纯文件读取 `~/.claude/projects/**/*.jsonl`
|
|
11
|
+
3. **确定性分类**: 同 token 合并成 LLM 调用组 → 工具→5 类映射
|
|
12
|
+
4. **落盘 SQLite**: 14 字段 Record,UNIQUE(session_id, ts) 天然去重
|
|
13
|
+
5. **Web 面板**: `tokenmetre web` 启动瘦统计面板
|
|
14
|
+
6. **可选云端协作**: 注册后可连 tokenmetre.umap.earth 多成员汇聚
|
|
15
|
+
|
|
16
|
+
## 线上入口
|
|
17
|
+
|
|
18
|
+
**https://tokenmetre.umap.earth** — 营销站 `/` · 用户工作台 `/app` · 运维后台 `/admin`。
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 本地端安装
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install tokenmetre
|
|
26
|
+
tokenmetre install claude-code --verify
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `pip install` 把 CLI 装进系统
|
|
30
|
+
- `tokenmetre install claude-code` 做数据侧部署:幂等写 `~/.claude/settings.json` 的 cleanupPeriodDays + 软链 skill/command markdown
|
|
31
|
+
- 运行时数据落在 `~/.tokenmetre/`(SQLite / 配置缓存)
|
|
32
|
+
|
|
33
|
+
验证: `tokenmetre install claude-code --verify`
|
|
34
|
+
|
|
35
|
+
## 使用流程
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 1. 登记要计量的项目
|
|
39
|
+
tokenmetre register add E:\work\ai\some-project
|
|
40
|
+
tokenmetre register add E:\work\ai\another-project
|
|
41
|
+
|
|
42
|
+
# 2. 扫描(register add 已自动 scan;定期手动补扫)
|
|
43
|
+
tokenmetre scan
|
|
44
|
+
|
|
45
|
+
# 3. 看 Web 面板
|
|
46
|
+
tokenmetre web # http://127.0.0.1:8080
|
|
47
|
+
|
|
48
|
+
# 4. 或 CLI 报表
|
|
49
|
+
tokenmetre report --all
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## CLI 命令速查
|
|
53
|
+
|
|
54
|
+
| 命令 | 作用 |
|
|
55
|
+
|---|---|
|
|
56
|
+
| `install claude-code [--verify]` | 安装/验证 CC adapter |
|
|
57
|
+
| `register add <cwd>` | 登记激活目录(自动 scan) |
|
|
58
|
+
| `register remove <cwd>` | 取消登记 |
|
|
59
|
+
| `register list` | 查看已登记项目 |
|
|
60
|
+
| `register claim <cwd> --id <tm_xxx>` | 显式认领(目录搬家后归位) |
|
|
61
|
+
| `scan [--force] [--project <cwd>]` | 扫描 transcript → SQLite |
|
|
62
|
+
| `report [--all] [--project <slug>]` | CLI 统计摘要 |
|
|
63
|
+
| `web [--port]` | 启动本地 Web 面板 |
|
|
64
|
+
| `cloud add [cwd] --base <url> --token <token>` | 启用某项目云端协作 |
|
|
65
|
+
| `cloud show / cloud remove` | 查看/关闭 cloud 配置 |
|
|
66
|
+
| `sync [--project <slug>]` | push 本地 pending records 到云端 |
|
|
67
|
+
| `config sync [--base <url>]` | 拉取云端全局配置 |
|
|
68
|
+
|
|
69
|
+
## 分类规则
|
|
70
|
+
|
|
71
|
+
5 类确定性映射(采集端不调 LLM),优先级: documentation > coding > execution > exploration > discussion
|
|
72
|
+
|
|
73
|
+
| category | 含义 |
|
|
74
|
+
|---|---|
|
|
75
|
+
| **文档** documentation | 写 markdown 文件 |
|
|
76
|
+
| **编码** coding | 写/改代码文件 |
|
|
77
|
+
| **实施** execution | 跑命令: 安装/构建/执行/文件操作 |
|
|
78
|
+
| **调研** exploration | 读文件/搜索/查 git/上网 |
|
|
79
|
+
| **讨论** discussion | 纯对话交互 |
|
|
80
|
+
|
|
81
|
+
详细判定规则见 `docs/spec.md §I.3`。
|
|
82
|
+
|
|
83
|
+
## 数据位置
|
|
84
|
+
|
|
85
|
+
| 路径 | 用途 |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `~/.tokenmetre/tokenmetre.db` | SQLite 主库 — records + processed_sessions |
|
|
88
|
+
| `~/.tokenmetre/projects.json` | 项目注册表(active/ignored/claims) |
|
|
89
|
+
| `~/.tokenmetre/config.json` | 云端全局配置缓存(config sync 拉取) |
|
|
90
|
+
| `~/.tokenmetre/weights.yaml` | provider 计价比重(无云端缓存时回退用) |
|
|
91
|
+
|
|
92
|
+
## 数据安全
|
|
93
|
+
|
|
94
|
+
Claude Code 默认 30 天清理 transcript。install 自动确保 `cleanupPeriodDays` ≥ 1(默认 365)。想长期保留就设大数字,无哨兵值。
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 云端部署(运维侧)
|
|
99
|
+
|
|
100
|
+
### 本地启动
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
# 1. 配置 .env(参考 .env.example):
|
|
104
|
+
# DATABASE_URL / TMCOM_API_TOKEN / TMCOM_JWT_SECRET / TMCOM_ADMIN_PASSWORD
|
|
105
|
+
# 2. 安装依赖
|
|
106
|
+
pip install -e .
|
|
107
|
+
# 3. 从项目根启动(不能 cd api/)
|
|
108
|
+
python -m api.server --port 9000
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
首次启动自动: Alembic 迁移建表 + 种子 admin。
|
|
112
|
+
|
|
113
|
+
### Vercel + Supabase(生产)
|
|
114
|
+
|
|
115
|
+
```powershell
|
|
116
|
+
# schema 变更后本地直连线上库执行迁移
|
|
117
|
+
python -c "from api import db; db.init()"
|
|
118
|
+
|
|
119
|
+
# 部署(CLI 直推,GitHub 自动部署已断开)
|
|
120
|
+
vercel deploy --prod --yes
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
环境变量(Vercel Dashboard): `DATABASE_URL`(Supabase pooler :6543) / `TMCOM_API_TOKEN` / `TMCOM_JWT_SECRET` / `TMCOM_ADMIN_PASSWORD` / `TMCOM_OPEN_REGISTER`(默认关) / 可选邮件 OAuth 配置。
|
|
124
|
+
|
|
125
|
+
### 前端构建
|
|
126
|
+
|
|
127
|
+
```powershell
|
|
128
|
+
cd api/web/site; npm install; npm run build # 营销站
|
|
129
|
+
cd ../user; npm install; npm run build # 用户工作台
|
|
130
|
+
cd ../admin; npm install; npm run build # 运维后台
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 数据库
|
|
134
|
+
|
|
135
|
+
PostgreSQL(Supabase 免费档)。连接串用 pooler :6543 transaction mode;密码含特殊字符需 percent-encode。
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 机器端接入
|
|
140
|
+
|
|
141
|
+
用户登录 `/app/projects` → 引导卡复制自己的 token:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
tokenmetre cloud add --base https://tokenmetre.umap.earth --token tm_xxxx
|
|
145
|
+
tokenmetre sync
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 配套文档
|
|
151
|
+
|
|
152
|
+
- [docs/spec.md](docs/spec.md) — 规约全文(Record/分类/公式 + 云端服务规约 + F 编号)
|
|
153
|
+
- [docs/api-contract.md](docs/api-contract.md) — 接口契约(本地端 + 机器端 API + 云端内部)
|
|
154
|
+
- [docs/architecture.md](docs/architecture.md) — 整体架构 + pip 打包边界
|
|
155
|
+
- [docs/README.md](docs/README.md) — 开发文档(目录结构 + 踩坑备忘)
|
|
156
|
+
- [docs/ROADMAP.md](docs/ROADMAP.md) — 进度表(Phase 分组 + F 编号贯穿,唯一权威源)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tokenmetre"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Local-first token usage collector for AI coding agents (Claude Code): passive transcript scan, per-project stats, optional cloud sync"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [{ name = "bsawang" }]
|
|
12
|
+
keywords = ["token", "usage", "claude-code", "ai", "metrics", "cost"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Environment :: Web Environment",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"fastapi>=0.110",
|
|
28
|
+
"uvicorn>=0.29",
|
|
29
|
+
"pydantic>=2.6",
|
|
30
|
+
"pyjwt>=2.8",
|
|
31
|
+
"psycopg[binary,pool]>=3.1",
|
|
32
|
+
"alembic>=1.13",
|
|
33
|
+
"python-dotenv>=1.0",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
trae = ["pycryptodome>=3.20"]
|
|
38
|
+
all = ["tokenmetre[trae]"]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/bsawang/tokenMetreCom"
|
|
42
|
+
Repository = "https://github.com/bsawang/tokenMetreCom"
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
tokenmetre = "tokenmetre.cli.main:main"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
|
49
|
+
include = ["tokenmetre*"]
|
|
50
|
+
|
|
51
|
+
[tool.setuptools.package-data]
|
|
52
|
+
tokenmetre = [
|
|
53
|
+
"data/*.yaml",
|
|
54
|
+
"web/fonts/*",
|
|
55
|
+
"web/frontend/dist/**",
|
|
56
|
+
"adapters/**/*.md",
|
|
57
|
+
"adapters/**/*.py",
|
|
58
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|