cc-statistics 0.1.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.
- cc_statistics-0.1.0/LICENSE +21 -0
- cc_statistics-0.1.0/PKG-INFO +158 -0
- cc_statistics-0.1.0/README.md +140 -0
- cc_statistics-0.1.0/cc_statistics.egg-info/PKG-INFO +158 -0
- cc_statistics-0.1.0/cc_statistics.egg-info/SOURCES.txt +13 -0
- cc_statistics-0.1.0/cc_statistics.egg-info/dependency_links.txt +1 -0
- cc_statistics-0.1.0/cc_statistics.egg-info/entry_points.txt +2 -0
- cc_statistics-0.1.0/cc_statistics.egg-info/top_level.txt +1 -0
- cc_statistics-0.1.0/cc_stats/__init__.py +3 -0
- cc_statistics-0.1.0/cc_stats/analyzer.py +480 -0
- cc_statistics-0.1.0/cc_stats/cli.py +191 -0
- cc_statistics-0.1.0/cc_stats/formatter.py +186 -0
- cc_statistics-0.1.0/cc_stats/parser.py +179 -0
- cc_statistics-0.1.0/pyproject.toml +27 -0
- cc_statistics-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 androidZzT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cc-statistics
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Claude Code 会话统计工具 — 分析 AI Coding 工程指标
|
|
5
|
+
Author: androidZzT
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/androidZzT/cc-statistics
|
|
8
|
+
Project-URL: Repository, https://github.com/androidZzT/cc-statistics
|
|
9
|
+
Keywords: claude-code,statistics,ai-coding,cli
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# cc-statistics
|
|
20
|
+
|
|
21
|
+
Claude Code 会话统计工具 — 从本地 `~/.claude/` 数据中提取 AI Coding 工程指标。
|
|
22
|
+
|
|
23
|
+
## 统计指标
|
|
24
|
+
|
|
25
|
+
| # | 指标 | 说明 |
|
|
26
|
+
|---|------|------|
|
|
27
|
+
| ① | 用户指令数 | 对话轮次(不含工具返回和系统消息) |
|
|
28
|
+
| ② | AI 工具调用 | 总次数 + 按工具拆分(附带柱状图和工具说明) |
|
|
29
|
+
| ③ | 开发时长 | 总时长 / AI 处理时长 / 用户活跃时长 / 活跃率 / 平均轮次耗时 |
|
|
30
|
+
| ④ | 代码变更 | Git 已提交变更 + AI 工具变更(Edit/Write),按语言拆分 |
|
|
31
|
+
| ⑤ | Token 消耗 | input / output / cache,按模型拆分 |
|
|
32
|
+
|
|
33
|
+
### 时长计算方式
|
|
34
|
+
|
|
35
|
+
将会话切分为**对话轮次**(用户发消息 → AI 处理 → AI 回复),分别统计:
|
|
36
|
+
|
|
37
|
+
- **AI 处理时长**:每轮从用户消息到 AI 最后一条响应的耗时
|
|
38
|
+
- **用户活跃时长**:上轮 AI 回复到下轮用户消息的间隔(超过 5 分钟视为离开,不计入)
|
|
39
|
+
- **活跃时长** = AI 处理 + 用户活跃
|
|
40
|
+
|
|
41
|
+
### 代码变更来源
|
|
42
|
+
|
|
43
|
+
- **Git 已提交**:会话时间段内 `git log --numstat` 的所有 commit(包含用户和 AI 的提交)
|
|
44
|
+
- **AI 工具变更**:从 JSONL 中 `Edit`/`Write` 工具调用的参数提取(仅 AI 侧)
|
|
45
|
+
|
|
46
|
+
## 安装
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python3 -m venv .venv
|
|
50
|
+
source .venv/bin/activate
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
无第三方依赖,仅使用 Python 标准库。
|
|
55
|
+
|
|
56
|
+
## 使用
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 列出所有项目
|
|
60
|
+
cc-stats --list
|
|
61
|
+
|
|
62
|
+
# 分析当前目录的所有会话
|
|
63
|
+
cc-stats
|
|
64
|
+
|
|
65
|
+
# 按关键词匹配项目
|
|
66
|
+
cc-stats compose-album
|
|
67
|
+
|
|
68
|
+
# 分析指定项目目录
|
|
69
|
+
cc-stats /path/to/project
|
|
70
|
+
|
|
71
|
+
# 分析指定 JSONL 文件
|
|
72
|
+
cc-stats ~/.claude/projects/-Users-foo-bar/SESSION_ID.jsonl
|
|
73
|
+
|
|
74
|
+
# 只看最近 N 个会话
|
|
75
|
+
cc-stats compose-album --last 3
|
|
76
|
+
|
|
77
|
+
# 时间范围过滤
|
|
78
|
+
cc-stats --all --since 3d # 最近 3 天
|
|
79
|
+
cc-stats --all --since 2w # 最近 2 周
|
|
80
|
+
cc-stats --all --since 1h # 最近 1 小时
|
|
81
|
+
cc-stats --all --since 2026-03-01 --until 2026-03-15 # 指定日期区间
|
|
82
|
+
cc-stats sailor --since 2026-03-13T10:00 # 精确到分钟
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 示例输出
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
╔══════════════════════════════════════════════════════════╗
|
|
89
|
+
║ Claude Code 会话统计报告 ║
|
|
90
|
+
╚══════════════════════════════════════════════════════════╝
|
|
91
|
+
|
|
92
|
+
会话数: 3
|
|
93
|
+
时间范围: 2026-03-13 07:24 ~ 2026-03-14 14:16
|
|
94
|
+
|
|
95
|
+
① 用户指令数
|
|
96
|
+
────────────────────────────────────────────────────────────
|
|
97
|
+
对话轮次: 58
|
|
98
|
+
|
|
99
|
+
② AI 工具调用
|
|
100
|
+
────────────────────────────────────────────────────────────
|
|
101
|
+
总调用次数: 336
|
|
102
|
+
|
|
103
|
+
Bash ███████████████ 90 执行 Shell 命令
|
|
104
|
+
Read ██████████░░░░░ 61 读取文件内容
|
|
105
|
+
Edit █████████░░░░░░ 56 编辑文件(精确替换)
|
|
106
|
+
TaskUpdate ███████░░░░░░░░ 44 更新任务状态
|
|
107
|
+
Agent ████░░░░░░░░░░░ 24 启动子代理执行子任务
|
|
108
|
+
Grep ████░░░░░░░░░░░ 24 按内容搜索文件
|
|
109
|
+
TaskCreate ██░░░░░░░░░░░░░ 17 创建任务
|
|
110
|
+
|
|
111
|
+
③ 开发时长
|
|
112
|
+
────────────────────────────────────────────────────────────
|
|
113
|
+
总时长: 30h 51m 52s
|
|
114
|
+
活跃时长: 2h 13m 5s
|
|
115
|
+
AI 处理: 1h 42m 42s
|
|
116
|
+
用户活跃: 30m 22s
|
|
117
|
+
活跃率: 7%
|
|
118
|
+
AI 占比: 77%
|
|
119
|
+
平均轮次耗时: 2m 13s/轮 (46 轮)
|
|
120
|
+
|
|
121
|
+
④ 代码变更
|
|
122
|
+
────────────────────────────────────────────────────────────
|
|
123
|
+
[Git 已提交] 60 个 commit
|
|
124
|
+
总新增: +30342 总删除: -18228 净增: +12114
|
|
125
|
+
|
|
126
|
+
Kotlin +11472 -1894 net +9578
|
|
127
|
+
Markdown +490 -50 net +440
|
|
128
|
+
|
|
129
|
+
[AI 工具变更] 来自 Edit/Write 调用
|
|
130
|
+
总新增: +1538 总删除: -315 净增: +1223
|
|
131
|
+
|
|
132
|
+
Kotlin +810 -196 net +614
|
|
133
|
+
Markdown +591 -43 net +548
|
|
134
|
+
Swift +137 -76 net +61
|
|
135
|
+
|
|
136
|
+
⑤ Token 消耗
|
|
137
|
+
────────────────────────────────────────────────────────────
|
|
138
|
+
Input tokens: 924
|
|
139
|
+
Output tokens: 98.0K
|
|
140
|
+
Cache read tokens: 53.6M
|
|
141
|
+
Cache creation tokens: 814.3K
|
|
142
|
+
────────────────────────────────────────
|
|
143
|
+
合计: 54.6M
|
|
144
|
+
|
|
145
|
+
按模型拆分:
|
|
146
|
+
claude-opus-4-6: input=924 output=98.0K cache_read=53.6M total=54.6M
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 数据来源
|
|
150
|
+
|
|
151
|
+
所有数据读取自 `~/.claude/` 本地文件,不联网,不上传:
|
|
152
|
+
|
|
153
|
+
| 数据 | 来源 |
|
|
154
|
+
|------|------|
|
|
155
|
+
| 会话消息 | `~/.claude/projects/<project>/<session>.jsonl` |
|
|
156
|
+
| 工具调用 | JSONL 中 assistant 消息的 `tool_use` 块 |
|
|
157
|
+
| Token 用量 | JSONL 中 assistant 消息的 `usage` 字段 |
|
|
158
|
+
| Git 变更 | 项目目录的 `git log --numstat` |
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# cc-statistics
|
|
2
|
+
|
|
3
|
+
Claude Code 会话统计工具 — 从本地 `~/.claude/` 数据中提取 AI Coding 工程指标。
|
|
4
|
+
|
|
5
|
+
## 统计指标
|
|
6
|
+
|
|
7
|
+
| # | 指标 | 说明 |
|
|
8
|
+
|---|------|------|
|
|
9
|
+
| ① | 用户指令数 | 对话轮次(不含工具返回和系统消息) |
|
|
10
|
+
| ② | AI 工具调用 | 总次数 + 按工具拆分(附带柱状图和工具说明) |
|
|
11
|
+
| ③ | 开发时长 | 总时长 / AI 处理时长 / 用户活跃时长 / 活跃率 / 平均轮次耗时 |
|
|
12
|
+
| ④ | 代码变更 | Git 已提交变更 + AI 工具变更(Edit/Write),按语言拆分 |
|
|
13
|
+
| ⑤ | Token 消耗 | input / output / cache,按模型拆分 |
|
|
14
|
+
|
|
15
|
+
### 时长计算方式
|
|
16
|
+
|
|
17
|
+
将会话切分为**对话轮次**(用户发消息 → AI 处理 → AI 回复),分别统计:
|
|
18
|
+
|
|
19
|
+
- **AI 处理时长**:每轮从用户消息到 AI 最后一条响应的耗时
|
|
20
|
+
- **用户活跃时长**:上轮 AI 回复到下轮用户消息的间隔(超过 5 分钟视为离开,不计入)
|
|
21
|
+
- **活跃时长** = AI 处理 + 用户活跃
|
|
22
|
+
|
|
23
|
+
### 代码变更来源
|
|
24
|
+
|
|
25
|
+
- **Git 已提交**:会话时间段内 `git log --numstat` 的所有 commit(包含用户和 AI 的提交)
|
|
26
|
+
- **AI 工具变更**:从 JSONL 中 `Edit`/`Write` 工具调用的参数提取(仅 AI 侧)
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python3 -m venv .venv
|
|
32
|
+
source .venv/bin/activate
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
无第三方依赖,仅使用 Python 标准库。
|
|
37
|
+
|
|
38
|
+
## 使用
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# 列出所有项目
|
|
42
|
+
cc-stats --list
|
|
43
|
+
|
|
44
|
+
# 分析当前目录的所有会话
|
|
45
|
+
cc-stats
|
|
46
|
+
|
|
47
|
+
# 按关键词匹配项目
|
|
48
|
+
cc-stats compose-album
|
|
49
|
+
|
|
50
|
+
# 分析指定项目目录
|
|
51
|
+
cc-stats /path/to/project
|
|
52
|
+
|
|
53
|
+
# 分析指定 JSONL 文件
|
|
54
|
+
cc-stats ~/.claude/projects/-Users-foo-bar/SESSION_ID.jsonl
|
|
55
|
+
|
|
56
|
+
# 只看最近 N 个会话
|
|
57
|
+
cc-stats compose-album --last 3
|
|
58
|
+
|
|
59
|
+
# 时间范围过滤
|
|
60
|
+
cc-stats --all --since 3d # 最近 3 天
|
|
61
|
+
cc-stats --all --since 2w # 最近 2 周
|
|
62
|
+
cc-stats --all --since 1h # 最近 1 小时
|
|
63
|
+
cc-stats --all --since 2026-03-01 --until 2026-03-15 # 指定日期区间
|
|
64
|
+
cc-stats sailor --since 2026-03-13T10:00 # 精确到分钟
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 示例输出
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
╔══════════════════════════════════════════════════════════╗
|
|
71
|
+
║ Claude Code 会话统计报告 ║
|
|
72
|
+
╚══════════════════════════════════════════════════════════╝
|
|
73
|
+
|
|
74
|
+
会话数: 3
|
|
75
|
+
时间范围: 2026-03-13 07:24 ~ 2026-03-14 14:16
|
|
76
|
+
|
|
77
|
+
① 用户指令数
|
|
78
|
+
────────────────────────────────────────────────────────────
|
|
79
|
+
对话轮次: 58
|
|
80
|
+
|
|
81
|
+
② AI 工具调用
|
|
82
|
+
────────────────────────────────────────────────────────────
|
|
83
|
+
总调用次数: 336
|
|
84
|
+
|
|
85
|
+
Bash ███████████████ 90 执行 Shell 命令
|
|
86
|
+
Read ██████████░░░░░ 61 读取文件内容
|
|
87
|
+
Edit █████████░░░░░░ 56 编辑文件(精确替换)
|
|
88
|
+
TaskUpdate ███████░░░░░░░░ 44 更新任务状态
|
|
89
|
+
Agent ████░░░░░░░░░░░ 24 启动子代理执行子任务
|
|
90
|
+
Grep ████░░░░░░░░░░░ 24 按内容搜索文件
|
|
91
|
+
TaskCreate ██░░░░░░░░░░░░░ 17 创建任务
|
|
92
|
+
|
|
93
|
+
③ 开发时长
|
|
94
|
+
────────────────────────────────────────────────────────────
|
|
95
|
+
总时长: 30h 51m 52s
|
|
96
|
+
活跃时长: 2h 13m 5s
|
|
97
|
+
AI 处理: 1h 42m 42s
|
|
98
|
+
用户活跃: 30m 22s
|
|
99
|
+
活跃率: 7%
|
|
100
|
+
AI 占比: 77%
|
|
101
|
+
平均轮次耗时: 2m 13s/轮 (46 轮)
|
|
102
|
+
|
|
103
|
+
④ 代码变更
|
|
104
|
+
────────────────────────────────────────────────────────────
|
|
105
|
+
[Git 已提交] 60 个 commit
|
|
106
|
+
总新增: +30342 总删除: -18228 净增: +12114
|
|
107
|
+
|
|
108
|
+
Kotlin +11472 -1894 net +9578
|
|
109
|
+
Markdown +490 -50 net +440
|
|
110
|
+
|
|
111
|
+
[AI 工具变更] 来自 Edit/Write 调用
|
|
112
|
+
总新增: +1538 总删除: -315 净增: +1223
|
|
113
|
+
|
|
114
|
+
Kotlin +810 -196 net +614
|
|
115
|
+
Markdown +591 -43 net +548
|
|
116
|
+
Swift +137 -76 net +61
|
|
117
|
+
|
|
118
|
+
⑤ Token 消耗
|
|
119
|
+
────────────────────────────────────────────────────────────
|
|
120
|
+
Input tokens: 924
|
|
121
|
+
Output tokens: 98.0K
|
|
122
|
+
Cache read tokens: 53.6M
|
|
123
|
+
Cache creation tokens: 814.3K
|
|
124
|
+
────────────────────────────────────────
|
|
125
|
+
合计: 54.6M
|
|
126
|
+
|
|
127
|
+
按模型拆分:
|
|
128
|
+
claude-opus-4-6: input=924 output=98.0K cache_read=53.6M total=54.6M
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 数据来源
|
|
132
|
+
|
|
133
|
+
所有数据读取自 `~/.claude/` 本地文件,不联网,不上传:
|
|
134
|
+
|
|
135
|
+
| 数据 | 来源 |
|
|
136
|
+
|------|------|
|
|
137
|
+
| 会话消息 | `~/.claude/projects/<project>/<session>.jsonl` |
|
|
138
|
+
| 工具调用 | JSONL 中 assistant 消息的 `tool_use` 块 |
|
|
139
|
+
| Token 用量 | JSONL 中 assistant 消息的 `usage` 字段 |
|
|
140
|
+
| Git 变更 | 项目目录的 `git log --numstat` |
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cc-statistics
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Claude Code 会话统计工具 — 分析 AI Coding 工程指标
|
|
5
|
+
Author: androidZzT
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/androidZzT/cc-statistics
|
|
8
|
+
Project-URL: Repository, https://github.com/androidZzT/cc-statistics
|
|
9
|
+
Keywords: claude-code,statistics,ai-coding,cli
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# cc-statistics
|
|
20
|
+
|
|
21
|
+
Claude Code 会话统计工具 — 从本地 `~/.claude/` 数据中提取 AI Coding 工程指标。
|
|
22
|
+
|
|
23
|
+
## 统计指标
|
|
24
|
+
|
|
25
|
+
| # | 指标 | 说明 |
|
|
26
|
+
|---|------|------|
|
|
27
|
+
| ① | 用户指令数 | 对话轮次(不含工具返回和系统消息) |
|
|
28
|
+
| ② | AI 工具调用 | 总次数 + 按工具拆分(附带柱状图和工具说明) |
|
|
29
|
+
| ③ | 开发时长 | 总时长 / AI 处理时长 / 用户活跃时长 / 活跃率 / 平均轮次耗时 |
|
|
30
|
+
| ④ | 代码变更 | Git 已提交变更 + AI 工具变更(Edit/Write),按语言拆分 |
|
|
31
|
+
| ⑤ | Token 消耗 | input / output / cache,按模型拆分 |
|
|
32
|
+
|
|
33
|
+
### 时长计算方式
|
|
34
|
+
|
|
35
|
+
将会话切分为**对话轮次**(用户发消息 → AI 处理 → AI 回复),分别统计:
|
|
36
|
+
|
|
37
|
+
- **AI 处理时长**:每轮从用户消息到 AI 最后一条响应的耗时
|
|
38
|
+
- **用户活跃时长**:上轮 AI 回复到下轮用户消息的间隔(超过 5 分钟视为离开,不计入)
|
|
39
|
+
- **活跃时长** = AI 处理 + 用户活跃
|
|
40
|
+
|
|
41
|
+
### 代码变更来源
|
|
42
|
+
|
|
43
|
+
- **Git 已提交**:会话时间段内 `git log --numstat` 的所有 commit(包含用户和 AI 的提交)
|
|
44
|
+
- **AI 工具变更**:从 JSONL 中 `Edit`/`Write` 工具调用的参数提取(仅 AI 侧)
|
|
45
|
+
|
|
46
|
+
## 安装
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python3 -m venv .venv
|
|
50
|
+
source .venv/bin/activate
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
无第三方依赖,仅使用 Python 标准库。
|
|
55
|
+
|
|
56
|
+
## 使用
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 列出所有项目
|
|
60
|
+
cc-stats --list
|
|
61
|
+
|
|
62
|
+
# 分析当前目录的所有会话
|
|
63
|
+
cc-stats
|
|
64
|
+
|
|
65
|
+
# 按关键词匹配项目
|
|
66
|
+
cc-stats compose-album
|
|
67
|
+
|
|
68
|
+
# 分析指定项目目录
|
|
69
|
+
cc-stats /path/to/project
|
|
70
|
+
|
|
71
|
+
# 分析指定 JSONL 文件
|
|
72
|
+
cc-stats ~/.claude/projects/-Users-foo-bar/SESSION_ID.jsonl
|
|
73
|
+
|
|
74
|
+
# 只看最近 N 个会话
|
|
75
|
+
cc-stats compose-album --last 3
|
|
76
|
+
|
|
77
|
+
# 时间范围过滤
|
|
78
|
+
cc-stats --all --since 3d # 最近 3 天
|
|
79
|
+
cc-stats --all --since 2w # 最近 2 周
|
|
80
|
+
cc-stats --all --since 1h # 最近 1 小时
|
|
81
|
+
cc-stats --all --since 2026-03-01 --until 2026-03-15 # 指定日期区间
|
|
82
|
+
cc-stats sailor --since 2026-03-13T10:00 # 精确到分钟
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 示例输出
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
╔══════════════════════════════════════════════════════════╗
|
|
89
|
+
║ Claude Code 会话统计报告 ║
|
|
90
|
+
╚══════════════════════════════════════════════════════════╝
|
|
91
|
+
|
|
92
|
+
会话数: 3
|
|
93
|
+
时间范围: 2026-03-13 07:24 ~ 2026-03-14 14:16
|
|
94
|
+
|
|
95
|
+
① 用户指令数
|
|
96
|
+
────────────────────────────────────────────────────────────
|
|
97
|
+
对话轮次: 58
|
|
98
|
+
|
|
99
|
+
② AI 工具调用
|
|
100
|
+
────────────────────────────────────────────────────────────
|
|
101
|
+
总调用次数: 336
|
|
102
|
+
|
|
103
|
+
Bash ███████████████ 90 执行 Shell 命令
|
|
104
|
+
Read ██████████░░░░░ 61 读取文件内容
|
|
105
|
+
Edit █████████░░░░░░ 56 编辑文件(精确替换)
|
|
106
|
+
TaskUpdate ███████░░░░░░░░ 44 更新任务状态
|
|
107
|
+
Agent ████░░░░░░░░░░░ 24 启动子代理执行子任务
|
|
108
|
+
Grep ████░░░░░░░░░░░ 24 按内容搜索文件
|
|
109
|
+
TaskCreate ██░░░░░░░░░░░░░ 17 创建任务
|
|
110
|
+
|
|
111
|
+
③ 开发时长
|
|
112
|
+
────────────────────────────────────────────────────────────
|
|
113
|
+
总时长: 30h 51m 52s
|
|
114
|
+
活跃时长: 2h 13m 5s
|
|
115
|
+
AI 处理: 1h 42m 42s
|
|
116
|
+
用户活跃: 30m 22s
|
|
117
|
+
活跃率: 7%
|
|
118
|
+
AI 占比: 77%
|
|
119
|
+
平均轮次耗时: 2m 13s/轮 (46 轮)
|
|
120
|
+
|
|
121
|
+
④ 代码变更
|
|
122
|
+
────────────────────────────────────────────────────────────
|
|
123
|
+
[Git 已提交] 60 个 commit
|
|
124
|
+
总新增: +30342 总删除: -18228 净增: +12114
|
|
125
|
+
|
|
126
|
+
Kotlin +11472 -1894 net +9578
|
|
127
|
+
Markdown +490 -50 net +440
|
|
128
|
+
|
|
129
|
+
[AI 工具变更] 来自 Edit/Write 调用
|
|
130
|
+
总新增: +1538 总删除: -315 净增: +1223
|
|
131
|
+
|
|
132
|
+
Kotlin +810 -196 net +614
|
|
133
|
+
Markdown +591 -43 net +548
|
|
134
|
+
Swift +137 -76 net +61
|
|
135
|
+
|
|
136
|
+
⑤ Token 消耗
|
|
137
|
+
────────────────────────────────────────────────────────────
|
|
138
|
+
Input tokens: 924
|
|
139
|
+
Output tokens: 98.0K
|
|
140
|
+
Cache read tokens: 53.6M
|
|
141
|
+
Cache creation tokens: 814.3K
|
|
142
|
+
────────────────────────────────────────
|
|
143
|
+
合计: 54.6M
|
|
144
|
+
|
|
145
|
+
按模型拆分:
|
|
146
|
+
claude-opus-4-6: input=924 output=98.0K cache_read=53.6M total=54.6M
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 数据来源
|
|
150
|
+
|
|
151
|
+
所有数据读取自 `~/.claude/` 本地文件,不联网,不上传:
|
|
152
|
+
|
|
153
|
+
| 数据 | 来源 |
|
|
154
|
+
|------|------|
|
|
155
|
+
| 会话消息 | `~/.claude/projects/<project>/<session>.jsonl` |
|
|
156
|
+
| 工具调用 | JSONL 中 assistant 消息的 `tool_use` 块 |
|
|
157
|
+
| Token 用量 | JSONL 中 assistant 消息的 `usage` 字段 |
|
|
158
|
+
| Git 变更 | 项目目录的 `git log --numstat` |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
cc_statistics.egg-info/PKG-INFO
|
|
5
|
+
cc_statistics.egg-info/SOURCES.txt
|
|
6
|
+
cc_statistics.egg-info/dependency_links.txt
|
|
7
|
+
cc_statistics.egg-info/entry_points.txt
|
|
8
|
+
cc_statistics.egg-info/top_level.txt
|
|
9
|
+
cc_stats/__init__.py
|
|
10
|
+
cc_stats/analyzer.py
|
|
11
|
+
cc_stats/cli.py
|
|
12
|
+
cc_stats/formatter.py
|
|
13
|
+
cc_stats/parser.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cc_stats
|