codexmate 0.1.34 → 0.1.35
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 +15 -1
- package/README.vi.md +15 -1
- package/README.zh.md +15 -1
- package/cli/analytics-export-args.js +7 -0
- package/cli/session-usage.js +4 -1
- package/cli.js +29 -5
- package/lib/data/model-prices.json +1868 -0
- package/lib/session-context-health.js +5 -1
- package/lib/session-evidence-collections.js +85 -0
- package/lib/session-features.js +15 -0
- package/lib/session-project-git.js +65 -0
- package/lib/session-projects.js +12 -1
- package/lib/session-stories.js +67 -0
- package/lib/session-usage-ledger.js +77 -0
- package/lib/session-usage-pricing.js +42 -0
- package/lib/session-usage-report.js +101 -0
- package/package.json +4 -1
- package/plugins/prompt-templates/computed.mjs +9 -0
- package/web-ui/app.js +10 -0
- package/web-ui/logic.session-artifacts.mjs +39 -0
- package/web-ui/modules/app.methods.agents.mjs +3 -2
- package/web-ui/modules/app.methods.session-browser.mjs +35 -0
- package/web-ui/modules/app.methods.system-prompt.mjs +16 -7
- package/web-ui/modules/app.methods.web-ui-preferences.mjs +5 -0
- package/web-ui/modules/i18n/locales/en.mjs +116 -1
- package/web-ui/modules/i18n/locales/ja.mjs +116 -1
- package/web-ui/modules/i18n/locales/vi.mjs +116 -1
- package/web-ui/modules/i18n/locales/zh-tw.mjs +116 -1
- package/web-ui/modules/i18n/locales/zh.mjs +116 -1
- package/web-ui/modules/session-collections.mjs +65 -0
- package/web-ui/modules/session-evidence.mjs +81 -0
- package/web-ui/modules/session-features.mjs +15 -1
- package/web-ui/modules/session-git.mjs +39 -0
- package/web-ui/modules/session-stories.mjs +64 -0
- package/web-ui/modules/usage-pricing.mjs +30 -0
- package/web-ui/partials/index/layout-footer.html +1 -1
- package/web-ui/partials/index/panel-sessions.html +20 -20
- package/web-ui/partials/index/panel-usage.html +2 -0
- package/web-ui/partials/index/session-features.html +82 -2
- package/web-ui/partials/index/thread-handoff.html +73 -62
- package/web-ui/partials/index/usage-records.html +41 -0
- package/web-ui/res/web-ui-render.precompiled.js +772 -125
- package/web-ui/styles/session-features.css +63 -0
- package/web-ui/styles/sessions-list.css +74 -0
- package/web-ui/styles/sessions-preview.css +106 -68
- package/web-ui/styles/sessions-usage.css +8 -0
- package/web-ui/styles/theme-violet.css +9 -3
package/README.md
CHANGED
|
@@ -30,6 +30,14 @@ Codex Mate is a locally running CLI + Web tool for browsing, filtering, and expo
|
|
|
30
30
|
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
+
### Usage record breakdown
|
|
34
|
+
|
|
35
|
+
Expand UTC usage records on demand to separate recorded tokens, cache categories and full saved-text estimates. Record adapters cover Codex, Claude, Pi and Gemini JSON sessions; existing charts and default exports keep their original semantics. No cost calculation. Use `codexmate analytics export --attribution records`. See the [usage guide](https://sakurabytecore.github.io/codexmate/guide/sessions#%E7%94%A8%E9%87%8F%E8%AE%B0%E5%BD%95%E6%98%8E%E7%BB%86).
|
|
36
|
+
|
|
37
|
+
### File sharing
|
|
38
|
+
|
|
39
|
+
Select files or a folder, then upload explicitly. Download copies or copy LAN links valid for 60 minutes. Downloads use a separate port without management API access. Removing a batch or stopping the service invalidates its links and preserves the originals. See the [file-sharing guide](https://sakurabytecore.github.io/codexmate/guide/web-ui#%E6%96%87%E4%BB%B6%E5%85%B1%E4%BA%AB).
|
|
40
|
+
|
|
33
41
|
### Appearance themes
|
|
34
42
|
|
|
35
43
|
Choose Light, Dark, Ocean or Violet in Settings. Violet adapts [Catppuccin Latte](https://github.com/catppuccin/palette) with light surfaces and a purple accent. Your theme is saved automatically and restored after reload.
|
|
@@ -45,6 +53,12 @@ Tests use Codex UA/Originator or Pi SDK headers, with configured UA overrides ta
|
|
|
45
53
|
|
|
46
54
|
The session page adds message bookmarks with notes and tags, an incremental local full-text index, evidence-linked handoff drafts, a read-only project workspace, and model-window references. Bookmarks do not modify source sessions. The index covers discovered candidates only; refresh it for new messages. Historical text ratios are not actual request utilization. Settings offers local diagnostics and redacted JSON/Markdown exports. Only selected checks probe the current Codex route or start selected MCP servers; no write tools are called. See the [session guide](https://sakurabytecore.github.io/codexmate/guide/sessions).
|
|
47
55
|
|
|
56
|
+
Build cross-session evidence packs from indexed selections, verify source hashes, and download Markdown; reload clears only the new in-memory basket. Usage offers a separate cost reference using a bundled versioned snapshot from [Wei-Shaw/model-price-repo](https://github.com/Wei-Shaw/model-price-repo), with unknown rows separate from known subtotals, not a bill and no automatic network updates. The project workspace adds read-only Git state and commit file statistics; associations within 24 hours are time-based candidates, not causation. These features do not call models or send sessions automatically. Pricing excludes tiers, service levels, cache durations, tool and multimodal extras.
|
|
57
|
+
|
|
58
|
+
Evidence collections explicitly save named source references. Reopen them after reload to recheck originals; the temporary basket still clears, and full sessions are not backed up. Commit details add development stories: manually link sessions and reasons for changes, with project isolation. Only local metadata is written; Git is unchanged, and links do not prove authorship or passing tests. See the [session guide](https://sakurabytecore.github.io/codexmate/guide/sessions).
|
|
59
|
+
|
|
60
|
+
The material basket also generates development receipts and multi-agent relay packs. Choose a format, supply a goal and optional notes, then verify sources and download Markdown. Historical material only: no model calls, command execution or automatic delivery; the current version still needs acceptance. Notes are not saved in collections and clear when a collection opens.
|
|
61
|
+
|
|
48
62
|
---
|
|
49
63
|
|
|
50
64
|
> [!TIP]
|
|
@@ -197,7 +211,7 @@ After finding your conversations, manage the configuration, skills, and tasks us
|
|
|
197
211
|
| **Pi Provider Config** | ✅ | Manage Pi providers in the Web UI writing to `~/.pi/agent/models.json` (unknown fields preserved) and switch the default provider/model in `~/.pi/agent/settings.json` |
|
|
198
212
|
| **Provider Health Check** | ✅ | Probe local Codex/Claude provider routes, highlight failed configs, and bulk-remove selected broken providers safely |
|
|
199
213
|
| **Prompt Templates** | ✅ | Variable-fill dialog on invocation, one-template JSON sharing, and versioned plugin template configuration with history Diff and rollback. `git_diff` is pasted text, not an executed command. |
|
|
200
|
-
| **Prompt File Editor** | ✅ | Edit global and project-level CLAUDE.md / AGENTS.md with a shared preset pool. Presets fill variables before updating the editor; save manually to write files. History shows version Diff; confirmed rollback writes the selected version with an atomic backup and concurrent-change checks. Pi lists direct `.md` files in `~/.pi/agent/` or `<cwd>/.pi/`, refreshing on tab entry or file-picker opening. Listing does not auto-load prompts. |
|
|
214
|
+
| **Prompt File Editor** | ✅ | Edit global and project-level CLAUDE.md / AGENTS.md with a shared preset pool. Presets fill variables before updating the editor; save manually to write files. History shows version Diff; confirmed rollback writes the selected version with an atomic backup and concurrent-change checks. Editor tabs and target selections persist across refreshes. Pi restores the selected file when listed; a missing selection falls back to the first item only when no draft is pending. Pi lists direct `.md` files in `~/.pi/agent/` or `<cwd>/.pi/`, refreshing on tab entry or file-picker opening. Listing does not auto-load prompts. Initial config loading does not add a page spacer to the prompt editor or make scrolling jump when loading finishes. |
|
|
201
215
|
| **MCP Integration** | ✅ | Expose local tools and resources via MCP stdio |
|
|
202
216
|
| **Auto Update** | ✅ | Click the Web UI update notice to view versions and copy `codexmate update`. Run it on the service host, then restart the service after a successful update. Clicking or copying does not run updates |
|
|
203
217
|
|
package/README.vi.md
CHANGED
|
@@ -30,6 +30,14 @@ Codex Mate là công cụ CLI + Web chạy cục bộ, giúp xem, lọc và xu
|
|
|
30
30
|
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
+
### Chi tiết bản ghi sử dụng
|
|
34
|
+
|
|
35
|
+
Mở bản ghi UTC khi cần để tách token ghi nhận, các loại bộ nhớ đệm và ước tính toàn bộ văn bản đã lưu. Hỗ trợ bản ghi Codex, Claude, Pi và phiên Gemini JSON; biểu đồ và xuất mặc định giữ nguyên cách thống kê. Không tính chi phí. Dùng `codexmate analytics export --attribution records`. Xem [hướng dẫn sử dụng](https://sakurabytecore.github.io/codexmate/guide/sessions#%E7%94%A8%E9%87%8F%E8%AE%B0%E5%BD%95%E6%98%8E%E7%BB%86).
|
|
36
|
+
|
|
37
|
+
### Chia sẻ tệp
|
|
38
|
+
|
|
39
|
+
Chọn tệp hoặc thư mục rồi tải lên thủ công. Tải bản sao hoặc sao chép liên kết LAN có hiệu lực 60 phút. Tải xuống dùng cổng riêng, không cấp quyền API quản trị. Xóa lô hoặc dừng dịch vụ sẽ vô hiệu hóa liên kết và giữ nguyên tệp gốc. Xem [hướng dẫn chia sẻ tệp](https://sakurabytecore.github.io/codexmate/guide/web-ui#%E6%96%87%E4%BB%B6%E5%85%B1%E4%BA%AB).
|
|
40
|
+
|
|
33
41
|
### Chủ đề giao diện
|
|
34
42
|
|
|
35
43
|
Chọn Sáng, Tối, Đại dương hoặc Tím dịu trong phần cài đặt. Tím dịu tham khảo [Catppuccin Latte](https://github.com/catppuccin/palette), dùng nền sáng và điểm nhấn tím. Chủ đề được lưu tự động và khôi phục sau khi tải lại.
|
|
@@ -45,6 +53,12 @@ Yêu cầu kiểm thử dùng UA/Originator của Codex hoặc header SDK của
|
|
|
45
53
|
|
|
46
54
|
Trang phiên bổ sung dấu trang tin nhắn với ghi chú và nhãn, chỉ mục toàn văn cục bộ cập nhật tăng dần, bản nháp bàn giao có bằng chứng, không gian dự án chỉ đọc và tham chiếu cửa sổ mô hình. Dấu trang không sửa phiên gốc. Chỉ mục chỉ bao gồm phiên đã phát hiện; cần cập nhật để tìm tin nhắn mới. Tỷ lệ văn bản lịch sử không phải mức sử dụng thực tế của yêu cầu. Cài đặt cung cấp chẩn đoán cục bộ và xuất JSON/Markdown đã ẩn bí mật. Chỉ mục kiểm tra được chọn mới truy cập tuyến Codex hiện tại hoặc khởi động MCP; không gọi công cụ ghi. Xem [hướng dẫn phiên](https://sakurabytecore.github.io/codexmate/guide/sessions).
|
|
47
55
|
|
|
56
|
+
Tạo gói bằng chứng liên phiên từ kết quả chỉ mục, kiểm tra hash nguồn và tải Markdown; tải lại chỉ xóa giỏ tài liệu trong bộ nhớ. Usage có tham khảo chi phí riêng từ bản giá tích hợp có phiên bản của [Wei-Shaw/model-price-repo](https://github.com/Wei-Shaw/model-price-repo), tách dòng chưa rõ khỏi tổng đã biết, không phải hóa đơn và không tự cập nhật qua mạng. Không gian dự án bổ sung trạng thái Git chỉ đọc và thống kê tệp của commit; liên kết trong 24 giờ chỉ là ứng viên theo thời gian, không chứng minh nguyên nhân. Các tính năng không gọi mô hình hay tự gửi phiên. Giá không gồm bậc giá, tầng dịch vụ, thời hạn bộ nhớ đệm, công cụ hoặc đa phương thức.
|
|
57
|
+
|
|
58
|
+
Bộ sưu tập bằng chứng lưu tham chiếu nguồn có tên khi người dùng chọn lưu. Sau khi tải lại, mở thủ công để kiểm tra nguồn; giỏ tạm vẫn bị xóa và không sao lưu toàn bộ phiên. Chi tiết commit có câu chuyện phát triển để liên kết phiên và lý do thay đổi, tách biệt từng dự án. Chỉ ghi siêu dữ liệu cục bộ; không đổi Git, không chứng minh nguồn tạo mã hay kiểm thử đạt. Xem [hướng dẫn phiên](https://sakurabytecore.github.io/codexmate/guide/sessions).
|
|
59
|
+
|
|
60
|
+
Giỏ tài liệu cũng tạo phiếu phát triển và gói tiếp sức đa Agent. Chọn định dạng, nhập mục tiêu và ghi chú tùy chọn, kiểm tra nguồn rồi tải Markdown. Chỉ tổng hợp tài liệu lịch sử: không gọi mô hình, chạy lệnh hay tự gửi; phiên bản hiện tại vẫn cần nghiệm thu. Ghi chú không lưu vào bộ sưu tập và bị xóa khi mở bộ sưu tập.
|
|
61
|
+
|
|
48
62
|
---
|
|
49
63
|
|
|
50
64
|
> [!TIP]
|
|
@@ -189,7 +203,7 @@ Sau khi tìm lại cuộc trò chuyện, bạn có thể quản lý cấu hình,
|
|
|
189
203
|
| **Bridge OpenAI** | ✅ | Chuyển đổi Codex Responses API sang định dạng OpenAI chuẩn |
|
|
190
204
|
| **Kiểm tra sức khỏe Provider** | ✅ | Kiểm tra route provider Codex/Claude, đánh dấu cấu hình lỗi và xóa hàng loạt các provider hỏng đã chọn một cách an toàn |
|
|
191
205
|
| **Mẫu Prompt** | ✅ | Hộp thoại điền biến khi gọi, chia sẻ một mẫu bằng JSON, lịch sử Diff và khôi phục cấu hình mẫu plugin. `git_diff` là văn bản được dán, không thực thi lệnh. |
|
|
192
|
-
| **Trình sửa tệp prompt** | ✅ | Chỉnh sửa CLAUDE.md / AGENTS.md toàn cục và theo dự án với kho preset chung. Điền biến trước khi áp dụng preset; cần lưu thủ công để ghi tệp. Lịch sử hiển thị Diff; xác nhận khôi phục sẽ ghi phiên bản đã chọn với bản sao lưu nguyên tử và kiểm tra thay đổi bên ngoài. Tab Pi liệt kê tệp `.md` trực tiếp trong `~/.pi/agent/` hoặc `<cwd>/.pi/`, cập nhật khi mở tab hoặc danh sách tệp; không tự động nạp prompt. |
|
|
206
|
+
| **Trình sửa tệp prompt** | ✅ | Chỉnh sửa CLAUDE.md / AGENTS.md toàn cục và theo dự án với kho preset chung. Điền biến trước khi áp dụng preset; cần lưu thủ công để ghi tệp. Lịch sử hiển thị Diff; xác nhận khôi phục sẽ ghi phiên bản đã chọn với bản sao lưu nguyên tử và kiểm tra thay đổi bên ngoài. Tab và lựa chọn tệp đích được lưu và khôi phục sau khi tải lại. Pi giữ tệp đã chọn nếu còn trong danh sách; chỉ chuyển về mục đầu khi tệp không còn và không có bản nháp chưa lưu. Tab Pi liệt kê tệp `.md` trực tiếp trong `~/.pi/agent/` hoặc `<cwd>/.pi/`, cập nhật khi mở tab hoặc danh sách tệp; không tự động nạp prompt. Trang sửa prompt không thêm khoảng trống tải cấu hình, tránh nhảy vị trí cuộn khi quá trình tải hoàn tất. |
|
|
193
207
|
| **Tích hợp MCP** | ✅ | Expose tool và resource cục bộ qua MCP stdio |
|
|
194
208
|
| **Tự động cập nhật** | ✅ | Nhấp thông báo phiên bản mới trong Web UI để xem phiên bản và sao chép `codexmate update`. Chạy trên máy chủ dịch vụ rồi khởi động lại dịch vụ sau khi cập nhật thành công. Nhấp hoặc sao chép không thực thi cập nhật |
|
|
195
209
|
|
package/README.zh.md
CHANGED
|
@@ -30,6 +30,14 @@ Codex Mate 是本地运行的 CLI + Web 管理工具,在一个界面查看、
|
|
|
30
30
|
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
+
### 用量记录明细
|
|
34
|
+
|
|
35
|
+
在 Usage 页按需展开 UTC 记录明细,区分记录 Token、缓存分项与完整文本估算。当前适配 Codex、Claude、Pi 与 Gemini JSON 会话;旧图表和默认导出保持原口径,不计算费用。CLI 使用 `codexmate analytics export --attribution records`。详见[用量指南](https://sakurabytecore.github.io/codexmate/guide/sessions#用量记录明细)。
|
|
36
|
+
|
|
37
|
+
### 文件共享
|
|
38
|
+
|
|
39
|
+
选择文件或文件夹后手动上传,下载副本或复制 60 分钟有效的局域网文件链接。下载使用独立端口,不授权管理 API;移除批次或停止服务后链接失效,原文件保留。详见[文件共享指南](https://sakurabytecore.github.io/codexmate/guide/web-ui#文件共享)。
|
|
40
|
+
|
|
33
41
|
### 外观主题
|
|
34
42
|
|
|
35
43
|
在设置中选择浅色、深色、海洋蓝或柔紫。柔紫参考 [Catppuccin Latte](https://github.com/catppuccin/palette),使用浅底与紫色强调。主题自动保存,刷新后恢复。
|
|
@@ -45,6 +53,12 @@ Codex/Pi 子页签选择会保存,刷新后恢复。选择已有配置中的
|
|
|
45
53
|
|
|
46
54
|
会话页新增消息收藏、备注与标签、本地增量全文索引、带来源证据的交接草稿、只读项目聚合与模型窗口参考。收藏保存在本机,不改原会话;索引仅覆盖已发现候选,新增消息需更新索引;历史文本占比不是实际请求窗口占用。设置页提供本地诊断与脱敏 JSON/Markdown 导出,勾选后才探测当前 Codex 路由或启动选定 MCP,不调用写工具。详见[会话指南](https://sakurabytecore.github.io/codexmate/guide/sessions)。
|
|
47
55
|
|
|
56
|
+
跨会话证据包支持从索引结果累计材料,生成前核对原文哈希,下载 Markdown;刷新只清空新材料篮。Usage 可单独展开费用参考,使用 [Wei-Shaw/model-price-repo](https://github.com/Wei-Shaw/model-price-repo) 的内置版本快照,未知与已知小计分开,不是账单,不自动联网更新。项目工作台新增只读 Git 状态与提交文件统计;前后 24 小时关联仅为时间候选,不证明因果。三项功能不调用模型、不自动发送会话;价格不包含阶梯、服务层、缓存时长或工具及多模态附加费。
|
|
57
|
+
|
|
58
|
+
证据专题夹可显式保存命名材料引用,刷新后手动打开并复核原文;临时材料篮仍清空,不备份会话全文。Git 提交详情新增开发故事线,手工关联会话与改动原因,保留跨项目隔离;仅写本机元数据,不改 Git,不证明因果或测试通过。详见[会话指南](https://sakurabytecore.github.io/codexmate/guide/sessions)。
|
|
59
|
+
|
|
60
|
+
材料篮新增开发小票与多 Agent 接力包:选择输出格式,填写目标与可选说明,复核原文后下载 Markdown。只整理历史材料;不调用模型、不执行命令、不自动发送,当前版本仍待验收。说明不保存到专题,打开专题会清空。
|
|
61
|
+
|
|
48
62
|
---
|
|
49
63
|
|
|
50
64
|
> [!TIP]
|
|
@@ -195,7 +209,7 @@ node cli.js thread ack <thread-id> --handoff <id> --agent <target> --evidence <s
|
|
|
195
209
|
| **Pi Provider 配置** | ✅ | 在 Web UI 中管理 Pi 供应商,写入 `~/.pi/agent/models.json`(未知字段无损保留),并切换 `~/.pi/agent/settings.json` 中的默认供应商/模型 |
|
|
196
210
|
| **Provider 健康检查** | ✅ | 探测本地 Codex/Claude provider 路由,标记失败配置,并安全批量移除已选坏配置 |
|
|
197
211
|
| **提示词模板** | ✅ | 调用时弹窗填写变量,支持单模板 JSON 分享、插件模板配置历史 Diff 与回滚。`git_diff` 需粘贴差异文本,不执行命令。 |
|
|
198
|
-
| **提示词文件编辑器** | ✅ | 编辑全局及项目级 CLAUDE.md / AGENTS.md,支持通用预设池。应用预设先填写变量,只更新编辑器,需手动保存。历史支持版本 Diff
|
|
212
|
+
| **提示词文件编辑器** | ✅ | 编辑全局及项目级 CLAUDE.md / AGENTS.md,支持通用预设池。应用预设先填写变量,只更新编辑器,需手动保存。历史支持版本 Diff;确认回滚后写入所选版本,保留原子备份,校验外部修改。页签和编辑目标选择会保存,刷新后恢复。Pi 文件仍在列表时保留选择;选项失效且无未保存草稿时才回到首项。Pi 页签动态列出 `~/.pi/agent/` 或 `<cwd>/.pi/` 直属 `.md`,进入页签或展开文件列表时更新;不自动加载提示词。 提示词页不显示配置加载占位,避免加载完成后页面缩短导致滚动回跳。 |
|
|
199
213
|
| **MCP 集成** | ✅ | 通过 MCP stdio 暴露本地工具与资源 |
|
|
200
214
|
| **自动更新** | ✅ | 点击 Web UI 的新版本提示,弹窗查看版本与复制 `codexmate update`;在服务主机终端执行,更新成功后重启服务。点击与复制不执行更新 |
|
|
201
215
|
|
|
@@ -19,6 +19,10 @@ function parseAnalyticsExportArgs(args = []) {
|
|
|
19
19
|
options.format = String(readValue('--format') || '').trim().toLowerCase();
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
|
+
if (token === '--attribution' || token.startsWith('--attribution=')) {
|
|
23
|
+
options.attribution = String(readValue('--attribution') || '').trim().toLowerCase();
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
22
26
|
if (token === '--from' || token.startsWith('--from=')) {
|
|
23
27
|
options.from = String(readValue('--from') || '').trim();
|
|
24
28
|
continue;
|
|
@@ -54,6 +58,9 @@ function parseAnalyticsExportArgs(args = []) {
|
|
|
54
58
|
if (options.format !== 'csv' && options.format !== 'json') {
|
|
55
59
|
errors.push('--format 必须是 csv 或 json');
|
|
56
60
|
}
|
|
61
|
+
if (options.attribution !== undefined && !['session', 'records'].includes(options.attribution)) {
|
|
62
|
+
errors.push('--attribution 必须是 session 或 records');
|
|
63
|
+
}
|
|
57
64
|
if (options.source && !['codex', 'claude', 'gemini', 'codebuddy', 'pi', 'all'].includes(options.source)) {
|
|
58
65
|
errors.push('--source 必须是 codex、claude、gemini、codebuddy、pi 或 all');
|
|
59
66
|
}
|
package/cli/session-usage.js
CHANGED
|
@@ -309,5 +309,8 @@ module.exports = {
|
|
|
309
309
|
listSessionUsageCore,
|
|
310
310
|
buildUsageExportRows,
|
|
311
311
|
exportSessionUsageCore,
|
|
312
|
-
serializeUsageExportRowsToCsv
|
|
312
|
+
serializeUsageExportRowsToCsv,
|
|
313
|
+
parseUsageExportDate,
|
|
314
|
+
normalizeUsageExportModelFilters,
|
|
315
|
+
sessionMatchesUsageExportModelFilters
|
|
313
316
|
};
|
package/cli.js
CHANGED
|
@@ -147,6 +147,7 @@ const {
|
|
|
147
147
|
const { createFileSharingRoutes } = require('./lib/file-sharing');
|
|
148
148
|
const { createPluginConfigController } = require('./cli/plugin-config');
|
|
149
149
|
const { createSessionContextHealthController } = require('./lib/session-context-health');
|
|
150
|
+
const { createSessionUsageReportController, exportSessionUsageReport } = require('./lib/session-usage-report');
|
|
150
151
|
const { createSessionFeatures } = require('./lib/session-features');
|
|
151
152
|
const { listHandoffs } = require('./lib/thread-handoff');
|
|
152
153
|
const { discoverServers, probeServer } = require('./lib/handoff-mcp');
|
|
@@ -1188,7 +1189,7 @@ function normalizeUsageTimeRangePreference(value) {
|
|
|
1188
1189
|
function normalizePromptsSubTabPreference(value) {
|
|
1189
1190
|
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
1190
1191
|
if (normalized === 'claude-project') return normalized;
|
|
1191
|
-
if (normalized === 'system') return normalized;
|
|
1192
|
+
if (normalized === 'system' || normalized === 'opencode') return normalized;
|
|
1192
1193
|
return 'codex';
|
|
1193
1194
|
}
|
|
1194
1195
|
|
|
@@ -1280,6 +1281,7 @@ function normalizeWebUiPreferences(value = {}) {
|
|
|
1280
1281
|
promptsPreviewCollapsed: normalizeBooleanPreference(source.promptsPreviewCollapsed, true),
|
|
1281
1282
|
sysPromptScope: normalizeSysPromptScopePreference(source.sysPromptScope),
|
|
1282
1283
|
sysPromptMode: normalizeSysPromptModePreference(source.sysPromptMode),
|
|
1284
|
+
sysPromptFileName: typeof source.sysPromptFileName === 'string' ? source.sysPromptFileName : '',
|
|
1283
1285
|
projectClaudeMdPath: typeof source.projectClaudeMdPath === 'string' ? source.projectClaudeMdPath : '',
|
|
1284
1286
|
sidebarCollapsed: normalizeSidebarCollapsedPreference(source.sidebarCollapsed),
|
|
1285
1287
|
theme: normalizeThemePreference(source.theme),
|
|
@@ -7991,6 +7993,8 @@ async function listSessionUsage(params = {}) {
|
|
|
7991
7993
|
}
|
|
7992
7994
|
|
|
7993
7995
|
async function exportSessionUsage(params = {}) {
|
|
7996
|
+
if (params.attribution !== undefined && !['session', 'records'].includes(params.attribution)) return { error: 'Invalid attribution' };
|
|
7997
|
+
if (params.attribution === 'records') return exportSessionUsageReport(await sessionUsageReport.read(params), params.format);
|
|
7994
7998
|
return exportSessionUsageCore(params, {
|
|
7995
7999
|
listSessionUsage
|
|
7996
8000
|
});
|
|
@@ -10026,11 +10030,14 @@ async function extractMessagesFromFile(filePath, source, options = {}) {
|
|
|
10026
10030
|
return state;
|
|
10027
10031
|
}
|
|
10028
10032
|
|
|
10029
|
-
const { readSessionContextHealth, readSessionContextNode, iterateSessionContextNodes } = createSessionContextHealthController({
|
|
10033
|
+
const { readSessionContextHealth, readSessionContextNode, iterateSessionContextNodes, iterateSessionUsageRecords } = createSessionContextHealthController({
|
|
10030
10034
|
fs, normalizeSessionSourceName, resolveSessionFilePath, queryOpencodeSessionMessages, queryZedSessionMessages
|
|
10031
10035
|
});
|
|
10032
10036
|
|
|
10037
|
+
const sessionUsageReport = createSessionUsageReportController({ fs, listSessionUsage, iterateSessionUsageRecords });
|
|
10038
|
+
|
|
10033
10039
|
const sessionFeatures = createSessionFeatures({ root: path.join(CODEXMATE_DIR, 'session-features'),
|
|
10040
|
+
usageReport: sessionUsageReport,
|
|
10034
10041
|
readNode: readSessionContextNode, nodes: iterateSessionContextNodes,
|
|
10035
10042
|
diagnostics: {
|
|
10036
10043
|
home: os.homedir(),
|
|
@@ -13784,7 +13791,7 @@ async function cmdExportSession(args = []) {
|
|
|
13784
13791
|
|
|
13785
13792
|
function printAnalyticsUsage() {
|
|
13786
13793
|
console.log('\n用法:');
|
|
13787
|
-
console.log(' codexmate analytics export [--format csv|json] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--source <codex|claude|gemini|codebuddy|workbuddy|pi|opencode|all>] [--output <PATH|->] [-o <PATH|->]');
|
|
13794
|
+
console.log(' codexmate analytics export [--format csv|json] [--attribution session|records] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--source <codex|claude|gemini|codebuddy|workbuddy|pi|opencode|all>] [--output <PATH|->] [-o <PATH|->]');
|
|
13788
13795
|
console.log('');
|
|
13789
13796
|
}
|
|
13790
13797
|
|
|
@@ -15123,6 +15130,10 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15123
15130
|
}
|
|
15124
15131
|
}
|
|
15125
15132
|
break;
|
|
15133
|
+
case 'read-sessions-usage-report':
|
|
15134
|
+
if (params?.source && !isSessionSourceOrAll(params.source)) result = { error: 'Invalid source' };
|
|
15135
|
+
else result = await sessionUsageReport.read(isPlainObject(params) ? params : {});
|
|
15136
|
+
break;
|
|
15126
15137
|
case 'export-sessions-usage':
|
|
15127
15138
|
{
|
|
15128
15139
|
const usageParams = isPlainObject(params) ? params : {};
|
|
@@ -15191,9 +15202,19 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
|
|
|
15191
15202
|
case 'session-diagnostics-cancel':
|
|
15192
15203
|
case 'session-feature-settings-get':
|
|
15193
15204
|
case 'session-feature-settings-save':
|
|
15205
|
+
case 'session-collections-list':
|
|
15206
|
+
case 'session-collection-open':
|
|
15207
|
+
case 'session-collection-save':
|
|
15208
|
+
case 'session-collection-remove':
|
|
15209
|
+
case 'session-stories-list':
|
|
15210
|
+
case 'session-story-save':
|
|
15211
|
+
case 'session-story-remove':
|
|
15212
|
+
case 'session-project-git':
|
|
15213
|
+
case 'session-project-git-commit':
|
|
15194
15214
|
case 'session-projects':
|
|
15195
15215
|
case 'session-project-map':
|
|
15196
15216
|
case 'session-project-prompt':
|
|
15217
|
+
case 'session-usage-pricing':
|
|
15197
15218
|
case 'session-handoff-draft':
|
|
15198
15219
|
case 'session-index-status':
|
|
15199
15220
|
case 'session-index-refresh':
|
|
@@ -18179,7 +18200,7 @@ function printMainHelp() {
|
|
|
18179
18200
|
console.log(' codexmate delete-model <模型> 删除模型');
|
|
18180
18201
|
console.log(' codexmate workflow <list|get|validate|run|runs|submit|active-runs|detail|resume|cancel> MCP 工作流中心');
|
|
18181
18202
|
console.log(' codexmate thread <handoff|list|fallback|ack> 交接卡与共享记忆路由');
|
|
18182
|
-
console.log(' codexmate analytics export [--format csv|json] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--output <PATH|->] [-o <PATH|->] 导出 Usage 数据');
|
|
18203
|
+
console.log(' codexmate analytics export [--format csv|json] [--attribution session|records] [--from YYYY-MM-DD] [--to YYYY-MM-DD] [--model <MODEL>] [--output <PATH|->] [-o <PATH|->] 导出 Usage 数据');
|
|
18183
18204
|
console.log(' codexmate run [--host <HOST>] [--no-browser] 启动 Web 界面');
|
|
18184
18205
|
console.log(' codexmate update [--check] 检查并快速更新工具');
|
|
18185
18206
|
console.log(' codexmate codex [参数...] [--follow-up <文本>|--queued-follow-up <文本> 可重复] 等同于 codex --yolo');
|
|
@@ -18204,6 +18225,10 @@ async function main() {
|
|
|
18204
18225
|
await cmdThread(args.slice(1));
|
|
18205
18226
|
return;
|
|
18206
18227
|
}
|
|
18228
|
+
if (command === 'analytics') {
|
|
18229
|
+
await cmdAnalytics(args.slice(1));
|
|
18230
|
+
return;
|
|
18231
|
+
}
|
|
18207
18232
|
const isMcpCommand = command === 'mcp';
|
|
18208
18233
|
const shouldGateInitialBootstrap = command === 'run' || isMcpCommand;
|
|
18209
18234
|
const bootstrap = ensureManagedConfigBootstrap({
|
|
@@ -18282,7 +18307,6 @@ async function main() {
|
|
|
18282
18307
|
case 'auth': cmdAuth(args.slice(1)); break;
|
|
18283
18308
|
case 'proxy': await cmdProxy(args.slice(1)); break;
|
|
18284
18309
|
case 'workflow': await cmdWorkflow(args.slice(1)); break;
|
|
18285
|
-
case 'analytics': await cmdAnalytics(args.slice(1)); break;
|
|
18286
18310
|
case 'run': await cmdStart(parseStartOptions(args.slice(1))); break;
|
|
18287
18311
|
case 'update': await cmdToolUpdate(args.slice(1)); break;
|
|
18288
18312
|
case 'start':
|