Skip to content

增加 token 计算 & 计费 & 优化 UI#6

Merged
expAdd3 merged 3 commits into
mainfrom
feat/add_token_and_dollar
Jun 29, 2026
Merged

增加 token 计算 & 计费 & 优化 UI#6
expAdd3 merged 3 commits into
mainfrom
feat/add_token_and_dollar

Conversation

@expAdd3

@expAdd3 expAdd3 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本 PR 为 CC Monitor 增加 transcript token 解析与按模型计费能力,并在菜单栏 UI 中展示“今日用量/成本”和历史趋势,同时完善 hooks 事件覆盖与打包资源。

Changes:

  • 新增 cc_pricing.py 与内置/可覆盖价格表,实现 token 统计、去重与成本计算
  • cc_monitor.py 增强:DB schema 扩展、每日用量落库、通知激活、菜单栏展示 token/成本与历史趋势
  • 打包/分发更新:py2app / PyInstaller 资源补齐、构建脚本改进、README 重写并补充 Token & Pricing 说明

Reviewed changes

Copilot reviewed 11 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
setup.py py2app 增加 cc_pricingprices.builtin.json 资源打包
scripts/build_app.sh py2app 构建输出改为临时目录并避免覆盖已有产物
README.md 文档重构:新增 Token/Pricing、Quick Start、Safety Notes、截图等
prices.json.example 新增用户自定义价格覆盖示例
prices.builtin.json 新增内置模型价格表
install_hooks.py hooks 覆盖扩展(含 PreToolUse/AskUserQuestion matcher)并复制依赖模块
CCMonitor.spec PyInstaller 增加价格资源与隐藏导入声明
cc_pricing.py 新增:usage 解析、去重、按日/按模型汇总、价格加载与格式化
cc_monitor.py DB/汇总/UI/通知大幅增强:token/成本与历史趋势展示、后台刷新用量
cc_hook.py hook 写库增强:记录 client bundle id、AskUserQuestion 处理、通知边沿逻辑调整
assets/menubar_white.svg 新增图标资源(白色)
assets/menubar_mono.svg 新增图标资源(mono/currentColor)
assets/app_icon_color.svg 新增彩色应用图标 SVG
.vscode/changelists.json 新增 VS Code 本地变更清单文件
.gitignore 忽略 .vscode/ 与(意图).DS_Store

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cc_pricing.py
Comment on lines +31 to +37
# py2app / PyInstaller bundled app
if getattr(sys, "frozen", False):
exe_dir = os.path.dirname(os.path.abspath(sys.executable))
cands.extend([
os.path.join(exe_dir, "..", "Resources"),
os.path.join(exe_dir, "Resources"),
])
Comment thread cc_monitor.py
Comment on lines +331 to +337
FROM sessions
WHERE source='hook'
AND transcript_path IS NOT NULL
AND transcript_path != ''
AND (
status != 'ENDED'
OR last_event_ts >= ?
Comment thread cc_monitor.py
else:
for s in sessions:
parent = rumps.MenuItem(_session_item_text(s))
if cc_pricing:
Comment thread cc_hook.py
Comment on lines +64 to +78
def _frontmost_bundle_id():
bid = _bundle_id_from_env()
if bid:
return bid
try:
cp = subprocess.run([
"osascript", "-e",
'tell application "System Events" to get bundle identifier of first process whose frontmost is true'
], check=False, capture_output=True, text=True)
out = (cp.stdout or "").strip()
if out:
return out
except Exception:
pass
return ""
Comment thread .vscode/changelists.json
Comment on lines +1 to +6
{
"changelists": [
{
"name": "Default",
"files": [
"CCMonitor.spec",

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@expAdd3 expAdd3 merged commit 5c381d1 into main Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants