@anthonyhan/token-pilot 0.3.2 → 0.3.4

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center">
2
2
 
3
- <img src="docs/assets/icon.png" width="96" alt="token-pilot —— 所有 AI 工具的本地账单,本月实测 ¥2,546 / 810M tokens">
3
+ <img src="docs/assets/icon.png" width="96" alt="token-pilot —— 所有 AI 工具的本地账单,本月实测 ¥7,328 / 38 亿 tokens">
4
4
 
5
5
  # token-pilot ⚡
6
6
 
@@ -21,7 +21,7 @@
21
21
 
22
22
  ![状态栏面板](docs/assets/menubar-panel.png)
23
23
 
24
- > 状态栏常驻 `⚡ ¥今日 · 预算%`。左键弹面板,「打开完整看板」看全部。我的真实 10 月:**810M tokens · ¥2,546 · 12,685 次调用**([怎么算的](#-数据准确性))。
24
+ > 状态栏常驻 `⚡ ¥今日 · 预算%`。左键弹面板,「打开完整看板」看全部。我的真实 10 月:**38.1 亿 tokens · ¥7,328 · 27,450 次调用**([怎么算的](#-数据准确性))。
25
25
 
26
26
  > ⚠️ npm 上另有一个**别人家的** `token-pilot`(MCP 代码导航工具,会往 Claude Code 写 hooks)。我们的包是 **`@anthonyhan/token-pilot`**,下面命令都带 scope,照抄即可。
27
27
 
@@ -83,7 +83,7 @@ xattr -dr com.apple.quarantine /Applications/token-pilot.app
83
83
  ```bash
84
84
  python3 scripts/reconcile.py month # 第三方视角独立重算原始日志,与 CLI 逐项对账
85
85
  python3 scripts/verify-dashboard.py # 看板 36 项算法不变量校验
86
- npm test # 42 个单元测试(定价/采集口径/聚合/注入/熔断)
86
+ npm test # 49 个单元测试(定价/采集口径/聚合/注入/熔断/RTK)
87
87
  ```
88
88
 
89
89
  实测修过的口径坑(2026-10-21,本机 4787 个日志文件):
@@ -96,8 +96,8 @@ npm test # 42 个单元测试(定价/采集口径
96
96
 
97
97
  ## 📊 凭什么信我
98
98
 
99
- - 我自己的 AI 账单就是它管的:本月 **¥2,546 / 810M tokens**(2026-10-21,上方截图即本机实时数据)
100
- - 36 项看板算法不变量 + 42 个单测 + 独立对账脚本,全部开箱可跑
99
+ - 我自己的 AI 账单就是它管的:本月 **¥7,328 / 38.1 亿 tokens**(2026-10-27 本机实时数据)
100
+ - 36 项看板算法不变量 + 49 个单测 + 独立对账脚本,全部开箱可跑
101
101
  - 诚实披露速率口径:日志按「调用完成时刻」记账,生成中的调用完成前不计入(看板内有注明)
102
102
 
103
103
  ## ⚠️ 什么时候别用它
@@ -128,6 +128,10 @@ token-pilot 免费且 MIT。如果它帮你省下了 AI 账单,可以请我喝
128
128
 
129
129
  完整分版本说明见 [RELEASE_NOTES.md](RELEASE_NOTES.md)(也是客户端自动更新弹窗的文案来源)。
130
130
 
131
+ - **v0.3.2** RTK 改用含压缩引擎的完整版,装完自动接 hook(备份/回滚保护);新增发布数据回流脚本
132
+ - **v0.3.1** npm 包缺 web 目录修复、看板前端编入 app 二进制
133
+ - **v0.3.0** 新增「压缩潜力」板块,修省钱建议卡被静默丢弃
134
+ - **v0.2.9** 自动发布链路修复(三平台产物上传与命名)
131
135
  - **v0.2.6** 激活自动更新链路 + 打转熔断主动通知(含防轰炸)
132
136
  - **v0.2.5** npm scope 校正为 `@anthonyhann`,包可运行性修复
133
137
  - **v0.2.3** 2B 压缩执行第一层(自动压缩 + autoCompact 写入 + RTK)、价格核对台
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthonyhan/token-pilot",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "你所有 AI 工具的本地账单 + 预算控制器 — 只读本地日志,零入侵,不出本机",
5
5
  "type": "module",
6
6
  "bin": {
@@ -333,6 +333,23 @@ footer .notes{max-width:560px}
333
333
  .m-row input:focus-visible{outline:2px solid var(--info);outline-offset:1px}
334
334
  .m-headr{color:var(--muted);font-size:10.5px;font-weight:700}
335
335
  .addrow{color:var(--info);font-weight:700;font-size:12px;padding:4px 0}
336
+
337
+ /* 设置项:复选框 + 标题 + 说明的三层结构 */
338
+ .opt{display:flex;align-items:flex-start;gap:10px;padding:9px 10px;margin:2px 0;border:1px solid transparent;border-radius:9px;cursor:pointer;transition:background .14s var(--ease),border-color .14s var(--ease)}
339
+ .opt:hover{background:color-mix(in oklab,var(--fg) 4%,transparent);border-color:var(--border)}
340
+ .opt input[type="checkbox"]{width:15px;height:15px;margin:1px 0 0;flex:none;accent-color:var(--info);cursor:pointer}
341
+ .opt-main{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
342
+ .opt-title{font-size:12.5px;font-weight:700;line-height:1.45;display:flex;align-items:center;gap:6px;flex-wrap:wrap;color:var(--fg)}
343
+ .opt-desc{font-size:11.5px;color:color-mix(in oklab,var(--muted) 78%,var(--fg));line-height:1.7}
344
+ .opt-desc code{font-size:11px;background:color-mix(in oklab,var(--fg) 7%,transparent);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
345
+ .opt-badge{font-size:10px;font-weight:700;color:var(--pos);background:color-mix(in oklab,var(--pos) 13%,transparent);border-radius:5px;padding:1px 6px;letter-spacing:.2px}
346
+ .opt-status{font-size:11px;font-weight:600;color:var(--muted)}
347
+ /* 带输入框的选项行:与复选框行左对齐(15px 复选框 + 10px gap = 25px) */
348
+ .opt-field{display:flex;align-items:center;gap:8px;padding:2px 10px 8px 35px;margin:0}
349
+ .opt-field .opt-title{font-size:12.5px;font-weight:700;flex:none}
350
+ .opt-field input{width:96px;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:6px 8px;font:inherit;font-size:12px;color:var(--fg)}
351
+ .opt-field input:focus-visible{outline:2px solid var(--info);outline-offset:1px}
352
+ .opt-unit{font-size:11.5px;color:var(--muted)}
336
353
  .delrow{color:var(--muted);border:0;background:none;cursor:pointer;font-size:14px;line-height:1;padding:2px}
337
354
  .modal-foot{display:flex;justify-content:flex-end;align-items:center;gap:12px;padding:12px 18px;border-top:1px solid var(--gridln)}
338
355
  .saved-hint{color:var(--pos-text);font-size:12px;font-weight:700;opacity:0;transition:opacity .2s var(--ease)}
@@ -666,23 +683,36 @@ footer .notes{max-width:560px}
666
683
  </div>
667
684
  <div class="m-sec">
668
685
  <div class="m-lab">自动压缩 <span>超阈值的活跃会话提醒/处理</span></div>
669
- <div class="m-row" style="display:flex;align-items:center;gap:8px">
670
- <input type="checkbox" id="mAutoCompact" aria-label="开启自动压缩" style="width:auto">
671
- <label for="mAutoCompact" style="font-size:12px">开启(会话上下文超阈值时系统通知提醒)</label>
672
- </div>
673
- <div class="m-row" style="display:flex;align-items:center;gap:8px;margin-top:6px">
674
- <span style="font-size:12px;color:var(--muted);white-space:nowrap">阈值(K tokens)</span>
675
- <input id="mCompactK" type="number" min="20" step="10" placeholder="100" aria-label="压缩阈值(千 tokens)" style="width:90px">
676
- </div>
677
- <div class="m-row" style="display:flex;align-items:center;gap:8px;margin-top:6px">
678
- <input type="checkbox" id="mApplyCc" aria-label="同时写入 Claude Code 自动压缩配置" style="width:auto">
679
- <label for="mApplyCc" style="font-size:12px">同时写入 Claude Code 的 autoCompactEnabled(改宿主配置,影响新会话)</label>
680
- </div>
681
- <div class="m-row" style="display:flex;align-items:center;gap:8px;margin-top:6px">
682
- <input type="checkbox" id="mInstallRtk" aria-label="安装 RTK 输出压缩层" style="width:auto">
683
- <label for="mInstallRtk" style="font-size:12px">安装 RTK 输出压缩层(含压缩引擎,brew/winget)<span id="rtkStatus" style="color:var(--muted);margin-left:6px"></span></label>
684
- <div style="font-size:11.5px;color:var(--muted);margin-top:4px;line-height:1.6">勾选后点「保存」才会真正执行:安装 rtk 并自动执行 <code>rtk init -g</code> 接入 Claude Code hook(会修改 ~/.claude/settings.json,已做备份)。若系统里已装有 rtk-oss,需先卸载(两者占用同一命令、会冲突)。</div>
686
+
687
+ <label class="opt" for="mAutoCompact">
688
+ <input type="checkbox" id="mAutoCompact" aria-label="开启自动压缩">
689
+ <span class="opt-main">
690
+ <span class="opt-title">开启自动压缩</span>
691
+ <span class="opt-desc">会话上下文超过阈值时发系统通知提醒</span>
692
+ </span>
693
+ </label>
694
+
695
+ <div class="opt-field">
696
+ <span class="opt-title">提醒阈值</span>
697
+ <input id="mCompactK" type="number" min="20" step="10" placeholder="100" aria-label="压缩阈值(千 tokens)">
698
+ <span class="opt-unit">K tokens</span>
685
699
  </div>
700
+
701
+ <label class="opt" for="mApplyCc">
702
+ <input type="checkbox" id="mApplyCc" aria-label="同时写入 Claude Code 自动压缩配置">
703
+ <span class="opt-main">
704
+ <span class="opt-title">同时写入 Claude Code 的 autoCompactEnabled</span>
705
+ <span class="opt-desc">会修改宿主配置,对之后新建的会话生效</span>
706
+ </span>
707
+ </label>
708
+
709
+ <label class="opt" for="mInstallRtk">
710
+ <input type="checkbox" id="mInstallRtk" aria-label="安装 RTK 输出压缩层">
711
+ <span class="opt-main">
712
+ <span class="opt-title">安装 RTK 输出压缩层 <span class="opt-badge">含压缩引擎</span><span id="rtkStatus" class="opt-status"></span></span>
713
+ <span class="opt-desc">勾选后点「保存」才执行:装 rtk 并自动跑 <code>rtk init -g</code> 接入 Claude Code hook。会修改 <code>~/.claude/settings.json</code>(已做备份可还原)。若系统里已有 rtk-oss,需先卸载,两者互斥。</span>
714
+ </span>
715
+ </label>
686
716
  </div>
687
717
  </div>
688
718
  <div class="modal-foot"><span class="saved-hint" id="saveHint">已保存</span><button class="btn-ghost" id="settingsSave" type="button">保存</button></div>