codex-work-receipt 0.7.3 → 0.8.0
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/CHANGELOG.md +18 -2
- package/README.en.md +27 -7
- package/README.md +27 -7
- package/docs/cli.en.md +55 -5
- package/docs/cli.md +55 -5
- package/docs/codex-pet.en.md +1 -1
- package/docs/codex-pet.md +1 -1
- package/docs/codex-skill.en.md +2 -0
- package/docs/codex-skill.md +2 -0
- package/docs/data-schema.en.md +29 -4
- package/docs/data-schema.md +29 -4
- package/docs/fixtures/cwr-file-v1.json +33 -0
- package/docs/miniprogram-file-import.en.md +67 -0
- package/docs/miniprogram-file-import.md +67 -0
- package/docs/mobile-import.en.md +19 -11
- package/docs/mobile-import.md +18 -10
- package/docs/privacy.en.md +20 -5
- package/docs/privacy.md +20 -5
- package/package.json +2 -2
- package/skills/ai-work-receipt/SKILL.md +2 -2
- package/src/auto-hook.mjs +46 -0
- package/src/auto-runner.mjs +172 -0
- package/src/cli.mjs +158 -60
- package/src/core/args.mjs +34 -0
- package/src/core/auto-mode.mjs +364 -0
- package/src/core/file-payload.mjs +74 -0
- package/src/core/generator.mjs +98 -0
- package/src/core/mode-selector.mjs +31 -0
- package/src/core/open-source.mjs +13 -0
- package/src/core/presentation.mjs +64 -28
- package/src/core/qr-payload.mjs +7 -178
- package/src/core/receipt-record.mjs +18 -10
- package/src/core/transfer-record.mjs +137 -0
- package/src/lib/files.mjs +52 -0
- package/src/parsers/codex.mjs +6 -6
- package/src/renderers/html.mjs +352 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
- 首次交互式运行新增“自动保存 / 仅手动”选择;显式范围命令继续保持非交互兼容。
|
|
6
|
+
- 自动保存通过 Codex `Stop` Hook 静默刷新当天同一张 HTML、完整 JSON 和 `.cwr.json` 微信导入文件,不使用定时器、空闲判断或常驻监听。
|
|
7
|
+
- 新增 `--setup`、`--enable-auto`、`--disable-auto` 和 `--auto-status`,支持安全合并、检查和移除本工具自己的用户级 Hook。
|
|
8
|
+
- 自动模式安装可离线运行的稳定本地执行器,合并前备份现有 Hooks,并在并发触发时合并任务、保护同一日输出。
|
|
9
|
+
- 新增 `cwr-file-v1` 微信导入文件:每张小票在 HTML 旁边输出一个带完整 SHA-256 校验的 `.cwr.json`,网页也可直接下载同一份文件。
|
|
10
|
+
- 桌面导入流程改为“下载文件 → 发送到文件传输助手 → 小程序选择聊天文件”,并补充小程序接入规范和跨仓库兼容夹具。
|
|
11
|
+
- 数据二维码降级为可选单码:只有完整载荷能放进安全 QR version 时才显示扫码入口,不再生成或轮播新的 multipart 二维码。
|
|
12
|
+
- 保留 `cwr1`、`cwr2` 和历史 `cwr2p` 解码兼容;二维码容量不足不再阻止 HTML、JSON、导入文件或本地历史生成。
|
|
13
|
+
- 修复 HTML 长图导出时文字节点被固化宽高后发生的数值换行与错位问题。
|
|
14
|
+
- 更新 HTML 工具栏并新增响应式侧栏,集中展示 GitHub、更新日志和赞助伙伴入口;这些网页控件不会进入导出图片。
|
|
15
|
+
- 更新中英文 CLI、手机导入、协议、隐私和 Codex Skill 文档。
|
|
16
|
+
|
|
17
|
+
## 0.7.4
|
|
18
|
+
|
|
19
|
+
- 修复部分 bug。
|
|
20
|
+
|
|
3
21
|
## 0.7.3
|
|
4
22
|
|
|
5
23
|
- Codex 会话日志改为分块逐行解析,避免超大 `.jsonl` 在转成单个 JavaScript 字符串时触发 V8 长度上限。
|
|
6
24
|
- 会话行解析后立即丢弃 Prompt、回复、图片和工具输出,只在内存中保留统计所需的时间、事件、模型与 Token 字段。
|
|
7
25
|
- 单行异常过大时带文件路径和行号跳过;文件读取失败时补充路径与体积,便于定位具体日志。
|
|
8
26
|
- 本地 `history.jsonl` 改为逐条写入,避免历史增长后形成同类的大字符串拼接风险。
|
|
9
|
-
- 小票生成或票仔安装成功后在终端展示开源仓库地址,并用对应的中英文文案邀请用户为项目点 Star。
|
|
10
|
-
- 修正 npm 包的 repository、homepage 和 issues 地址,使其统一指向 `a-bai-2026/codex-work-receipt`。
|
|
11
27
|
|
|
12
28
|
## 0.7.2
|
|
13
29
|
|
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<strong>Turn local Codex activity into a work receipt you can keep and share.</strong><br>
|
|
9
|
-
One command · Local-first · Codex pet · Three themes ·
|
|
9
|
+
One command · Local-first · Codex pet · Three themes · WeChat file import
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
Codex Work Receipt summarizes turns, tool calls, Tokens, duration, and models, then turns them into playful AI work points, a job title, and a review. Receipts never include prompts, responses, source code, project paths, or file names.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The cwr2 protocol creates stable privacy-safe facts for each session and calendar day, allowing overlapping today, last-seven-days, and this-week receipts to be deduplicated. Every receipt also produces one `.cwr.json` WeChat import file. Scan import appears only when the complete payload fits in one data QR code.
|
|
26
26
|
|
|
27
27
|
## Meet Ticket Buddy
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@ Version `0.6.0` uses the cwr2 protocol to create stable privacy-safe facts for e
|
|
|
36
36
|
|
|
37
37
|
## Quickstart
|
|
38
38
|
|
|
39
|
-
Requires Node.js 20+ and local Codex session records. No clone required
|
|
39
|
+
Requires Node.js 20+ and local Codex session records. No clone is required. The first interactive run asks whether to save automatically or use manual-only mode. Manual mode then offers today, the last 3 hours, the last 7 days, this week, or a specific session:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
npx codex-work-receipt@latest --lang en
|
|
@@ -56,7 +56,27 @@ npx codex-work-receipt@latest --hours 3 --lang en
|
|
|
56
56
|
|
|
57
57
|
“Last N hours” is a rolling summary for private history only. It does not participate in AI Work Cooperative deduplicated accounting. Use today, this week, the last seven days, or a specific session when you want accountable canonical facts.
|
|
58
58
|
|
|
59
|
-
HTML
|
|
59
|
+
HTML, structured data, and the WeChat import file are written to `./codex-work-receipt-output/` by default. The page can download its `.cwr.json` file and save a high-resolution PNG containing only the full receipt and WeChat mini-program code. See the [CLI guide](docs/cli.en.md).
|
|
60
|
+
|
|
61
|
+
## Automatic saving or manual only
|
|
62
|
+
|
|
63
|
+
Automatic saving uses the Codex `Stop` hook. Whenever a Codex turn stops, it quietly refreshes the same daily HTML, full JSON, and `.cwr.json` WeChat import file on this computer. It does not open a browser, upload files, or run a persistent watcher. The automatic path is file-first and does not generate a data QR.
|
|
64
|
+
|
|
65
|
+
Choose the mode again:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx codex-work-receipt@latest --setup --lang en
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or enable, disable, and inspect automatic saving directly:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx codex-work-receipt@latest --enable-auto --lang en
|
|
75
|
+
npx codex-work-receipt@latest --disable-auto --lang en
|
|
76
|
+
npx codex-work-receipt@latest --auto-status --lang en
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Automatic receipts live under `~/.codex-work-receipt/auto/YYYY-MM-DD/`. Switching to manual-only mode removes only the AI Work Receipt hook; it keeps existing receipts and unrelated Codex hooks. Restart Codex after installing the hook. If Codex asks you to review it, use `/hooks` to inspect and trust it. See the official [Codex hooks documentation](https://learn.chatgpt.com/docs/hooks).
|
|
60
80
|
|
|
61
81
|
## Ask Codex directly
|
|
62
82
|
|
|
@@ -86,15 +106,15 @@ Codex will choose the range and theme, run the CLI, and open the receipt. See th
|
|
|
86
106
|
|
|
87
107
|
## Desktop to mobile
|
|
88
108
|
|
|
89
|
-
The desktop page generates one
|
|
109
|
+
The desktop page generates one privacy-safe `.cwr.json` file. Send it to WeChat File Transfer, then choose “Import from chat file” in the companion mini program. A single data QR remains available only for receipts that fit completely in one code. See [mobile import](docs/mobile-import.en.md).
|
|
90
110
|
|
|
91
111
|
## Docs
|
|
92
112
|
|
|
93
113
|
- [CLI usage and options](docs/cli.en.md)
|
|
94
114
|
- [Codex Skill](docs/codex-skill.en.md)
|
|
95
115
|
- [Ticket Buddy Codex pet](docs/codex-pet.en.md)
|
|
96
|
-
- [Mobile QR import](docs/mobile-import.en.md)
|
|
97
|
-
- [Data schema and QR protocol](docs/data-schema.en.md)
|
|
116
|
+
- [Mobile file and single-QR import](docs/mobile-import.en.md)
|
|
117
|
+
- [Data schema, file, and QR protocol](docs/data-schema.en.md)
|
|
98
118
|
- [Local data and privacy](docs/privacy.en.md)
|
|
99
119
|
- [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md) · [Changelog](CHANGELOG.md)
|
|
100
120
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<strong>把本机 Codex 的工作记录,开成一张可以带走的 AI 打工小票。</strong><br>
|
|
9
|
-
一行命令 · 完全本地 · Codex 桌宠 · 三种主题 ·
|
|
9
|
+
一行命令 · 完全本地 · Codex 桌宠 · 三种主题 · 微信聊天文件导入
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
它会统计 Codex 会话中的轮次、工具调用、Token、时长和模型,生成带有 AI 工分、今日工种和点评的小票。不会把 Prompt、回复正文、代码、项目路径或文件名写入小票。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
cwr2 协议按“会话 × 自然日”生成稳定的脱敏事实。今日、近 7 日和本周小票即使范围重叠,接收端也能识别相同工作。每张小票还会生成一个 `.cwr.json` 微信导入文件;只有完整数据能放进一个二维码时,网页才额外提供扫码导入。
|
|
26
26
|
|
|
27
27
|
## 认识票仔
|
|
28
28
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
## Quickstart
|
|
38
38
|
|
|
39
|
-
需要 Node.js 20 或更高版本,并且本机已经使用过 Codex
|
|
39
|
+
需要 Node.js 20 或更高版本,并且本机已经使用过 Codex。无需克隆仓库。首次交互式运行会先让你选择“自动保存”或“仅手动”;选择手动后,再选择“今天 / 最近 3 小时 / 近 7 日 / 本周 / 指定会话”:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
npx codex-work-receipt@latest
|
|
@@ -56,7 +56,27 @@ npx codex-work-receipt@latest --hours 3
|
|
|
56
56
|
|
|
57
57
|
“最近 N 小时”是滚动摘要,只用于查看和保存私人历史,不参与 AI 供销社的去重统计。需要进入供销社时,请生成“今日 / 本周 / 近 7 日 / 指定会话”小票。
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
网页、结构数据和微信导入文件默认保存在 `./codex-work-receipt-output/`。生成的网页支持一键下载 `.cwr.json`,也可以保存只包含完整小票和微信小程序码的高清长图。数据二维码不会进入图片。详见 [CLI 使用文档](docs/cli.md)。
|
|
60
|
+
|
|
61
|
+
## 自动保存或仅手动
|
|
62
|
+
|
|
63
|
+
自动保存使用 Codex 的 `Stop` Hook:每当 Codex 完成一轮工作,就在本机静默刷新当天同一张 HTML、完整 JSON 和 `.cwr.json` 微信导入文件。它不会打开浏览器、不会上传文件,也不会常驻监听进程。自动路径以微信文件导入为主,不生成数据二维码。
|
|
64
|
+
|
|
65
|
+
重新选择模式:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npx codex-work-receipt@latest --setup
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
也可以直接启用、关闭或检查自动保存:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx codex-work-receipt@latest --enable-auto
|
|
75
|
+
npx codex-work-receipt@latest --disable-auto
|
|
76
|
+
npx codex-work-receipt@latest --auto-status
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
自动小票统一保存在 `~/.codex-work-receipt/auto/YYYY-MM-DD/`。切换为仅手动只会移除 AI 打工小票自己的 Hook,不会删除历史小票或其他 Codex Hook。安装 Hook 后请重启 Codex;如果 Codex 提示审查新 Hook,请使用 `/hooks` 确认并信任。Codex Hook 机制见 [官方文档](https://learn.chatgpt.com/docs/hooks)。
|
|
60
80
|
|
|
61
81
|
## 直接跟 Codex 说
|
|
62
82
|
|
|
@@ -86,15 +106,15 @@ Codex 会选择统计范围和主题、执行命令并打开小票。详见 [Cod
|
|
|
86
106
|
|
|
87
107
|
## 从电脑到手机
|
|
88
108
|
|
|
89
|
-
|
|
109
|
+
桌面网页会生成一个脱敏 `.cwr.json` 文件。把它发送到微信文件传输助手后,可在配套小程序中通过“从聊天文件导入”选择;数据足够小时也可以使用唯一的数据二维码快速导入。详见 [手机导入](docs/mobile-import.md)。
|
|
90
110
|
|
|
91
111
|
## 文档
|
|
92
112
|
|
|
93
113
|
- [CLI 使用与全部参数](docs/cli.md)
|
|
94
114
|
- [Codex Skill](docs/codex-skill.md)
|
|
95
115
|
- [Codex 桌宠“票仔”](docs/codex-pet.md)
|
|
96
|
-
- [
|
|
97
|
-
- [
|
|
116
|
+
- [手机文件与单码导入](docs/mobile-import.md)
|
|
117
|
+
- [数据结构、文件与二维码协议](docs/data-schema.md)
|
|
98
118
|
- [本地数据与隐私说明](docs/privacy.md)
|
|
99
119
|
- [参与贡献](CONTRIBUTING.md) · [安全说明](SECURITY.md) · [更新日志](CHANGELOG.md)
|
|
100
120
|
|
package/docs/cli.en.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
No clone or global installation is required.
|
|
11
11
|
|
|
12
|
-
## Interactive range selector
|
|
12
|
+
## Interactive mode and range selector
|
|
13
13
|
|
|
14
14
|
Run:
|
|
15
15
|
|
|
@@ -17,7 +17,43 @@ Run:
|
|
|
17
17
|
npx codex-work-receipt@latest --lang en
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The first interactive run asks you to choose:
|
|
21
|
+
|
|
22
|
+
- `Automatic saving`: quietly refresh today's receipt and `.cwr.json` WeChat import file whenever a Codex turn stops
|
|
23
|
+
- `Manual only`: generate only when you run the command or ask Ticket Buddy
|
|
24
|
+
|
|
25
|
+
After choosing manual-only mode, choose all activity today, the last 3 hours, the last 7 calendar days, this week, or a specific recent session. Session choices include their time range, turns, tool calls, and model for identification. Explicit range flags such as `--today` and `--latest` never trigger mode setup.
|
|
26
|
+
|
|
27
|
+
## Automatic saving
|
|
28
|
+
|
|
29
|
+
Open the mode selector again:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx codex-work-receipt@latest --setup --lang en
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Enable, switch to manual-only mode, or inspect status directly:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx codex-work-receipt@latest --enable-auto --lang en
|
|
39
|
+
npx codex-work-receipt@latest --disable-auto --lang en
|
|
40
|
+
npx codex-work-receipt@latest --auto-status --lang en
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Automatic saving uses a user-level Codex `Stop` hook. When a turn stops, the hook launches one short-lived local generation process. It does not use a timer, idle detection, or a persistent watcher. Nearby triggers are coalesced, and a local lock protects concurrent generation.
|
|
44
|
+
|
|
45
|
+
Automatic mode refreshes only the today range. It does not open a browser, print routine prompts, or generate a data QR. Each refresh updates:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
~/.codex-work-receipt/auto/YYYY-MM-DD/
|
|
49
|
+
├── codex-receipt-today-YYYY-MM-DD.html
|
|
50
|
+
├── codex-receipt-today-YYYY-MM-DD.json
|
|
51
|
+
└── codex-receipt-today-YYYY-MM-DD.cwr.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The `.cwr.json` file is the mobile import path for automatic receipts. Send it to WeChat File Transfer, then choose “Import from chat file” in the mini program. Automatic saving never sends or uploads the file itself.
|
|
55
|
+
|
|
56
|
+
Enabling automatic saving installs a stable offline runtime under `~/.codex-work-receipt/runtime/` and safely merges `~/.codex/hooks.json`. Existing hook configuration is backed up first. If the current file cannot be parsed, setup stops instead of replacing it. Restart Codex and use `/hooks` to inspect and trust the hook if prompted. Manual-only mode removes only this tool's hook while preserving history, the local runtime, and unrelated hooks. After upgrading the npm package, run `--enable-auto` again to refresh the local runtime; repeated setup does not duplicate the hook.
|
|
21
57
|
|
|
22
58
|
## Non-interactive ranges
|
|
23
59
|
|
|
@@ -82,12 +118,17 @@ Default output:
|
|
|
82
118
|
```text
|
|
83
119
|
./codex-work-receipt-output/
|
|
84
120
|
├── codex-receipt-today-2026-07-18.html
|
|
85
|
-
|
|
121
|
+
├── codex-receipt-today-2026-07-18.json
|
|
122
|
+
└── codex-receipt-today-2026-07-18.cwr.json
|
|
86
123
|
```
|
|
87
124
|
|
|
88
125
|
Default filenames include the calendar range. Latest-session and selected-session receipts include a short identifier so receipts from different dates or sessions do not overwrite one another.
|
|
89
126
|
|
|
90
|
-
|
|
127
|
+
In the generated HTML:
|
|
128
|
+
|
|
129
|
+
- “Download WeChat import file” downloads the same `.cwr.json` file. Send it to WeChat File Transfer, then choose “Import from chat file” in the mini program.
|
|
130
|
+
- “Or import by scanning” appears only when the complete payload safely fits in one data QR code. The desktop no longer generates multipart QR codes.
|
|
131
|
+
- “Save full PNG” downloads a high-resolution image containing only the complete receipt and WeChat mini-program code. File controls, data QR codes, theme controls, the page background, and footer notes are excluded.
|
|
91
132
|
|
|
92
133
|
Set a timezone and output path:
|
|
93
134
|
|
|
@@ -121,6 +162,10 @@ npx codex-work-receipt@latest --latest --lang en --no-open
|
|
|
121
162
|
| `--install-pet` | Install only the Ticket Buddy Codex pet |
|
|
122
163
|
| `--uninstall-pet` | Remove Ticket Buddy without deleting the skill or receipts |
|
|
123
164
|
| `--install-companion` | Install both the skill and Ticket Buddy Codex pet |
|
|
165
|
+
| `--setup` | Interactively choose automatic saving or manual-only mode |
|
|
166
|
+
| `--enable-auto` | Install the local runtime and Codex hook, then enable automatic saving |
|
|
167
|
+
| `--disable-auto` | Remove this tool's hook and switch to manual-only mode |
|
|
168
|
+
| `--auto-status` | Show the mode, runtime, hook, and latest automatic-run status |
|
|
124
169
|
| `--no-open` | Do not open the generated page |
|
|
125
170
|
|
|
126
171
|
Run the built-in help at any time:
|
|
@@ -135,11 +180,15 @@ Each run creates or updates:
|
|
|
135
180
|
|
|
136
181
|
- `codex-work-receipt-output/codex-receipt-*.html`: theme-switchable receipt page
|
|
137
182
|
- `codex-work-receipt-output/codex-receipt-*.json`: versioned receipt data
|
|
183
|
+
- `codex-work-receipt-output/codex-receipt-*.cwr.json`: privacy-safe file to send through WeChat and select in the mini program
|
|
138
184
|
- `~/.codex-work-receipt/receipts/*.json`: local snapshots
|
|
139
185
|
- `~/.codex-work-receipt/latest.json`: latest receipt
|
|
140
186
|
- `~/.codex-work-receipt/history.jsonl`: deduplicated local history
|
|
187
|
+
- `~/.codex-work-receipt/config.json`: automatic or manual-only configuration
|
|
188
|
+
- `~/.codex-work-receipt/auto-state.json`: latest automatic-run status
|
|
189
|
+
- `~/.codex-work-receipt/auto/YYYY-MM-DD/`: automatically refreshed daily HTML, JSON, and WeChat import file
|
|
141
190
|
|
|
142
|
-
See the [data schema and QR protocol](data-schema.en.md).
|
|
191
|
+
See the [data schema, file, and QR protocol](data-schema.en.md).
|
|
143
192
|
|
|
144
193
|
## Current limitations
|
|
145
194
|
|
|
@@ -147,3 +196,4 @@ See the [data schema and QR protocol](data-schema.en.md).
|
|
|
147
196
|
- Changed-file and line counts are intentionally omitted until they can be measured consistently
|
|
148
197
|
- Calendar ranges filter events by local date, rolling-hour ranges use exact timestamps, and both calculate per-session Token deltas
|
|
149
198
|
- Desktop PNG export is rendered locally in the browser and does not upload receipt data
|
|
199
|
+
- Automatic saving depends on a local Codex client firing the `Stop` hook; cloud tasks do not directly invoke the local hook
|
package/docs/cli.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
无需克隆仓库或全局安装。
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## 交互选择保存方式与统计范围
|
|
13
13
|
|
|
14
14
|
直接运行:
|
|
15
15
|
|
|
@@ -17,7 +17,43 @@
|
|
|
17
17
|
npx codex-work-receipt@latest
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
首次交互式运行会先让你选择:
|
|
21
|
+
|
|
22
|
+
- `自动保存`:Codex 每完成一轮工作,就静默刷新今天的小票和 `.cwr.json` 微信导入文件
|
|
23
|
+
- `仅手动`:只有执行命令或告诉票仔时才生成
|
|
24
|
+
|
|
25
|
+
选择仅手动后,命令行会继续让你选择今天全部活动、最近 3 小时、最近 7 个自然日、本周,或最近的某个具体会话。选择具体会话时会展示起止时间、轮次、工具调用和模型,帮助辨认。显式使用 `--today`、`--latest` 等范围参数时不会触发模式问答。
|
|
26
|
+
|
|
27
|
+
## 自动保存
|
|
28
|
+
|
|
29
|
+
重新打开模式选择:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx codex-work-receipt@latest --setup
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
直接启用、切换为仅手动或查看状态:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx codex-work-receipt@latest --enable-auto
|
|
39
|
+
npx codex-work-receipt@latest --disable-auto
|
|
40
|
+
npx codex-work-receipt@latest --auto-status
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
自动保存通过用户级 Codex `Stop` Hook 触发。Hook 收到一轮工作停止事件后只启动一个短生命周期的本地生成进程;没有定时器、空闲判断或常驻监听服务。短时间内的重复触发会被合并,并发生成使用本地锁保护。
|
|
44
|
+
|
|
45
|
+
自动模式只刷新“今日”范围,并且不打开浏览器、不打印日常提示、不生成数据二维码。每次刷新都会更新同一天的以下文件:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
~/.codex-work-receipt/auto/YYYY-MM-DD/
|
|
49
|
+
├── codex-receipt-today-YYYY-MM-DD.html
|
|
50
|
+
├── codex-receipt-today-YYYY-MM-DD.json
|
|
51
|
+
└── codex-receipt-today-YYYY-MM-DD.cwr.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`.cwr.json` 是自动模式的手机导入入口:把它发送到微信文件传输助手,再在小程序中选择“从聊天文件导入”。自动保存不会自动发送文件或上传数据。
|
|
55
|
+
|
|
56
|
+
启用时会把不依赖网络的稳定运行器安装到 `~/.codex-work-receipt/runtime/`,并安全合并 `~/.codex/hooks.json`。如果已有 Hooks,原文件会先备份;无法解析现有配置时安装会停止,不会覆盖它。重启 Codex 后,如果出现 Hook 审查提示,请使用 `/hooks` 检查并信任。切换为仅手动只移除本工具自己的 Hook,保留历史、运行器和其他 Hooks。npm 包升级后重新执行 `--enable-auto` 即可更新本地运行器;重复执行不会重复添加 Hook。
|
|
21
57
|
|
|
22
58
|
## 非交互统计范围
|
|
23
59
|
|
|
@@ -82,12 +118,17 @@ npx codex-work-receipt@latest --latest --theme diner
|
|
|
82
118
|
```text
|
|
83
119
|
./codex-work-receipt-output/
|
|
84
120
|
├── codex-receipt-today-2026-07-18.html
|
|
85
|
-
|
|
121
|
+
├── codex-receipt-today-2026-07-18.json
|
|
122
|
+
└── codex-receipt-today-2026-07-18.cwr.json
|
|
86
123
|
```
|
|
87
124
|
|
|
88
125
|
默认文件名会携带统计日期范围;最近会话和指定会话则携带短编号,避免不同日期或会话的小票互相覆盖。
|
|
89
126
|
|
|
90
|
-
打开生成的 HTML
|
|
127
|
+
打开生成的 HTML 后:
|
|
128
|
+
|
|
129
|
+
- 点击“下载微信导入文件”会下载同一份 `.cwr.json`。把它发送到微信文件传输助手,再在小程序中点击“从聊天文件导入”。
|
|
130
|
+
- 只有完整数据能安全放进一个二维码时,页面才显示“也可以扫码导入”;桌面端不会再生成多分片二维码。
|
|
131
|
+
- 点击“保存完整长图”会下载高清 PNG。图片只包含完整主小票和微信小程序码,不包含导入文件按钮、数据二维码、主题按钮、网页背景或底部说明。
|
|
91
132
|
|
|
92
133
|
指定时区和输出路径:
|
|
93
134
|
|
|
@@ -121,6 +162,10 @@ npx codex-work-receipt@latest --latest --no-open
|
|
|
121
162
|
| `--install-pet` | 只安装“票仔”Codex 桌宠 |
|
|
122
163
|
| `--uninstall-pet` | 卸载“票仔”,不删除 Skill 或历史小票 |
|
|
123
164
|
| `--install-companion` | 同时安装 Skill 和“票仔”Codex 桌宠 |
|
|
165
|
+
| `--setup` | 交互选择自动保存或仅手动模式 |
|
|
166
|
+
| `--enable-auto` | 安装运行器和 Codex Hook,启用自动保存 |
|
|
167
|
+
| `--disable-auto` | 移除本工具 Hook,切换为仅手动模式 |
|
|
168
|
+
| `--auto-status` | 查看模式、运行器、Hook 和最近自动生成状态 |
|
|
124
169
|
| `--no-open` | 生成后不自动打开浏览器 |
|
|
125
170
|
|
|
126
171
|
也可以随时运行:
|
|
@@ -135,11 +180,15 @@ npx codex-work-receipt@latest --help
|
|
|
135
180
|
|
|
136
181
|
- `codex-work-receipt-output/codex-receipt-*.html`:可切换主题的小票网页
|
|
137
182
|
- `codex-work-receipt-output/codex-receipt-*.json`:当前小票的版本化结构数据
|
|
183
|
+
- `codex-work-receipt-output/codex-receipt-*.cwr.json`:发送到微信聊天后由小程序选择的脱敏导入文件
|
|
138
184
|
- `~/.codex-work-receipt/receipts/*.json`:本机历史快照
|
|
139
185
|
- `~/.codex-work-receipt/latest.json`:最近生成的小票
|
|
140
186
|
- `~/.codex-work-receipt/history.jsonl`:去重后的本地历史
|
|
187
|
+
- `~/.codex-work-receipt/config.json`:自动保存或仅手动配置
|
|
188
|
+
- `~/.codex-work-receipt/auto-state.json`:最近一次自动运行状态
|
|
189
|
+
- `~/.codex-work-receipt/auto/YYYY-MM-DD/`:自动刷新的今日 HTML、JSON 和微信导入文件
|
|
141
190
|
|
|
142
|
-
结构说明见 [
|
|
191
|
+
结构说明见 [数据结构、文件与二维码协议](data-schema.md)。
|
|
143
192
|
|
|
144
193
|
## 当前限制
|
|
145
194
|
|
|
@@ -147,3 +196,4 @@ npx codex-work-receipt@latest --help
|
|
|
147
196
|
- 暂不统计修改文件数和代码行数,避免不同工具调用方式产生误导
|
|
148
197
|
- 自然日范围按本地日期筛选,滚动小时范围按精确时间戳筛选,并分别计算每个会话的 Token 区间增量
|
|
149
198
|
- 桌面网页导出 PNG 使用浏览器本地渲染,不上传小票数据
|
|
199
|
+
- 自动保存依赖本机 Codex 客户端触发 `Stop` Hook;云端任务不会直接调用本机 Hook
|
package/docs/codex-pet.en.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
“Ticket Buddy · AI Work Receipt” is a custom companion for Codex's native Pets feature. It is a night-green thermal receipt printer with tiny ox horns and animated idle, working, waiting, ready, failed, and review states.
|
|
6
6
|
|
|
7
|
-
Ticket Buddy only presents Codex activity and provides companionship. It does not collect extra data,
|
|
7
|
+
Ticket Buddy itself only presents Codex activity and provides companionship. It does not collect extra data, run the CLI, or alter the current task. Manual receipts use the AI Work Receipt skill. If [automatic saving](cli.en.md#automatic-saving) is enabled separately, an independent Codex `Stop` hook quietly refreshes today's receipt; that behavior is not controlled by the pet animation.
|
|
8
8
|
|
|
9
9
|
## Install the skill and pet together
|
|
10
10
|
|
package/docs/codex-pet.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
“票仔 · AI 小票工”是 AI 打工小票为 Codex 原生 Pets 功能制作的自定义桌宠。它是一台长着小牛角的夜班绿热敏打印机,会跟随 Codex 的空闲、工作、等待、完成和失败状态切换动画。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
票仔本身只负责状态展示和陪伴,不会读取额外数据、运行 CLI 或改变 Codex 的任务。手动开票通过 AI 打工小票 Skill 完成;如果另外启用了[自动保存](cli.md#自动保存),则由独立的 Codex `Stop` Hook 静默刷新今日小票,与桌宠动画无关。
|
|
8
8
|
|
|
9
9
|
## 一次安装 Skill 和票仔
|
|
10
10
|
|
package/docs/codex-skill.en.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
AI Work Receipt includes a Codex Skill that converts natural-language requests into the appropriate CLI options.
|
|
6
6
|
|
|
7
|
+
The skill remains a manual receipt entry point in either saving mode. With automatic saving enabled, you can still ask Codex for another range such as the latest session or this week. Manual-only mode does not disable the skill. Configure automatic saving with `npx codex-work-receipt@latest --setup --lang en`; see [automatic saving in the CLI guide](cli.en.md#automatic-saving).
|
|
8
|
+
|
|
7
9
|
## Install
|
|
8
10
|
|
|
9
11
|
```bash
|
package/docs/codex-skill.md
CHANGED
package/docs/data-schema.en.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Data schema and QR protocol
|
|
1
|
+
# Data schema, file, and QR protocol
|
|
2
2
|
|
|
3
3
|
<p><a href="./data-schema.md">中文</a> · <strong>English</strong> · <a href="../README.en.md">Back to README</a></p>
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The full receipt schema is currently version `2`; rolling-hour summaries remain on compatible version `1`. Each run saves both the full local record and a privacy-safe WeChat import file.
|
|
6
6
|
|
|
7
7
|
## Main fields
|
|
8
8
|
|
|
@@ -18,6 +18,29 @@ The current schema version is `1`. Each generation saves a structured receipt re
|
|
|
18
18
|
|
|
19
19
|
The `id` remains stable for the same session, day, or calendar-boundary pair. Regeneration updates the record rather than creating duplicate history. `source.snapshot_hash` detects metric changes.
|
|
20
20
|
|
|
21
|
+
## WeChat import file
|
|
22
|
+
|
|
23
|
+
Each run writes a `*.cwr.json` file beside the HTML:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"format": "codex-work-receipt",
|
|
28
|
+
"file_version": 1,
|
|
29
|
+
"payload_schema": "cwr2",
|
|
30
|
+
"payload": {},
|
|
31
|
+
"integrity": {
|
|
32
|
+
"algorithm": "sha256",
|
|
33
|
+
"digest": "..."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`payload` is exactly the compact structure obtained after decoding a QR payload. `integrity.digest` is a full SHA-256 over canonical payload JSON. It detects corruption but is not a source signature. The mini program must treat every file as untrusted input, enforce a size limit, validate versions, fields, numeric bounds, unique fact IDs, manifests, and content hashes, then persist atomically only after confirmation.
|
|
39
|
+
|
|
40
|
+
Canonicalization recursively sorts every object's keys using JavaScript's default string order (UTF-16 code units), preserves array order, uses JSON primitive types, and emits no whitespace or trailing newline. Calculate SHA-256 over the resulting UTF-8 bytes. Use the digest in `docs/fixtures/cwr-file-v1.json` to cross-check another implementation.
|
|
41
|
+
|
|
42
|
+
A cross-repository compatibility fixture is available at `docs/fixtures/cwr-file-v1.json`.
|
|
43
|
+
|
|
21
44
|
## QR format
|
|
22
45
|
|
|
23
46
|
The QR payload uses compact fields:
|
|
@@ -28,7 +51,9 @@ cwr2.<checksum>.<Base64URL of deflateRaw(JSON)>
|
|
|
28
51
|
cwr2p.<transferId>.<partIndex>.<partCount>.<totalChecksum>.<partChecksum>.<chunk>
|
|
29
52
|
```
|
|
30
53
|
|
|
31
|
-
`cwr1` and `cwr2` are complete single-code payloads.
|
|
54
|
+
`cwr1` and `cwr2` are complete single-code payloads. The desktop generates one data QR only when the complete payload stays within the safe QR version; otherwise it provides only the `.cwr.json` file and does not generate new multipart codes.
|
|
55
|
+
|
|
56
|
+
`cwr2p` is the legacy reorderable cwr2 multipart format, limited to 12 parts. Updated mini programs should still collect historical parts by transferId, validate part and total checksums, reconstruct cwr2, and decompress it so existing receipts remain importable.
|
|
32
57
|
|
|
33
58
|
The mini program validates the prefix and checksum before decompressing and parsing the payload. Future schema versions use the compact `v` field for compatibility.
|
|
34
59
|
|
|
@@ -38,4 +63,4 @@ When the same Codex session has multiple append-only log revisions, the generato
|
|
|
38
63
|
|
|
39
64
|
`presentation.compensation` contains playful AI work points, not real API cost. For compatibility with the current Chinese mini program, QR display copy remains Chinese while compact fields `l` and `r` carry the desktop locale and language-neutral role ID. English HTML and local JSON remain fully localized.
|
|
40
65
|
|
|
41
|
-
See [mobile QR import](mobile-import.en.md).
|
|
66
|
+
See [mobile file and single-QR import](mobile-import.en.md).
|
package/docs/data-schema.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 数据结构、文件与二维码协议
|
|
2
2
|
|
|
3
3
|
<p><strong>中文</strong> · <a href="./data-schema.en.md">English</a> · <a href="../README.md">返回 README</a></p>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
当前完整记录结构版本为 `2`;滚动小时摘要为了兼容继续使用版本 `1`。每次生成都会在本机保存完整结构记录和一份脱敏微信导入文件。
|
|
6
6
|
|
|
7
7
|
## 主要字段
|
|
8
8
|
|
|
@@ -18,6 +18,29 @@
|
|
|
18
18
|
|
|
19
19
|
同一个会话、同一天或同一组自然日边界的 `id` 保持稳定;重复生成会更新该记录。`source.snapshot_hash` 用于识别统计内容是否发生变化。
|
|
20
20
|
|
|
21
|
+
## 微信导入文件
|
|
22
|
+
|
|
23
|
+
每次生成都会在 HTML 旁边写入一个 `*.cwr.json`:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"format": "codex-work-receipt",
|
|
28
|
+
"file_version": 1,
|
|
29
|
+
"payload_schema": "cwr2",
|
|
30
|
+
"payload": {},
|
|
31
|
+
"integrity": {
|
|
32
|
+
"algorithm": "sha256",
|
|
33
|
+
"digest": "..."
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`payload` 与二维码解压后的精简结构完全相同。`integrity.digest` 是对规范化 payload JSON 计算的完整 SHA-256,用于发现损坏,但不是来源签名。小程序必须把文件视为不可信输入,限制文件大小,校验版本、字段、数值范围、factId 唯一性、manifest 和 content hash,并在用户确认后原子入库。
|
|
39
|
+
|
|
40
|
+
规范化规则是:递归按 JavaScript 默认字符串排序(UTF-16 code unit 顺序)排列每个对象的键,保持数组元素顺序,使用 JSON 原始类型,不添加空白或换行,再对生成的 UTF-8 字节计算 SHA-256。兼容实现可用 `docs/fixtures/cwr-file-v1.json` 的 digest 做交叉验证。
|
|
41
|
+
|
|
42
|
+
兼容测试夹具见 `docs/fixtures/cwr-file-v1.json`。
|
|
43
|
+
|
|
21
44
|
## 二维码格式
|
|
22
45
|
|
|
23
46
|
二维码使用精简字段:
|
|
@@ -28,7 +51,9 @@ cwr2.<checksum>.<deflateRaw(JSON) 的 Base64URL>
|
|
|
28
51
|
cwr2p.<transferId>.<partIndex>.<partCount>.<totalChecksum>.<partChecksum>.<chunk>
|
|
29
52
|
```
|
|
30
53
|
|
|
31
|
-
`cwr1` 和 `cwr2`
|
|
54
|
+
`cwr1` 和 `cwr2` 是完整单码。桌面端只有在完整载荷不超过安全 QR version 时才生成一个数据二维码;否则只提供 `.cwr.json` 文件,不再生成新的分片二维码。
|
|
55
|
+
|
|
56
|
+
`cwr2p` 是旧版桌面端生成的可乱序 cwr2 分片,最多 12 片。新版小程序仍应收集相同 transferId 的历史分片、校验分片和总 checksum、拼回 cwr2 并解压,以兼容已经生成的小票。
|
|
32
57
|
|
|
33
58
|
小程序应检查前缀和校验值,再解压并解析数据。未来结构升级通过 `v` 字段兼容。
|
|
34
59
|
|
|
@@ -38,4 +63,4 @@ cwr2p.<transferId>.<partIndex>.<partCount>.<totalChecksum>.<partChecksum>.<chunk
|
|
|
38
63
|
|
|
39
64
|
`presentation.compensation` 是娱乐化 AI 工分,不代表真实 API 费用。为兼容当前中文小程序,二维码展示文案继续使用中文,并通过精简字段 `l` 和 `r` 携带桌面语言及工种语义 ID;英文 HTML 和本地 JSON 不受影响。
|
|
40
65
|
|
|
41
|
-
手机端流程见 [
|
|
66
|
+
手机端流程见 [手机文件与单码导入](mobile-import.md)。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "codex-work-receipt",
|
|
3
|
+
"file_version": 1,
|
|
4
|
+
"payload_schema": "cwr1",
|
|
5
|
+
"payload": {
|
|
6
|
+
"v": 1,
|
|
7
|
+
"i": "cwr_fixture",
|
|
8
|
+
"g": "2026-07-22T00:00:00.000Z",
|
|
9
|
+
"o": "latest",
|
|
10
|
+
"d": [
|
|
11
|
+
"2026-07-22T00:00:00.000Z",
|
|
12
|
+
"2026-07-22T01:00:00.000Z",
|
|
13
|
+
"Asia/Shanghai",
|
|
14
|
+
"2026-07-22",
|
|
15
|
+
"2026-07-22"
|
|
16
|
+
],
|
|
17
|
+
"s": [1, 2, 2, 3, 0, 60000, 1200],
|
|
18
|
+
"t": [100, 80, 20, 10, 120],
|
|
19
|
+
"m": ["test-model"],
|
|
20
|
+
"l": "zh-CN",
|
|
21
|
+
"r": null,
|
|
22
|
+
"p": [
|
|
23
|
+
"classic",
|
|
24
|
+
"测试工种",
|
|
25
|
+
"测试点评",
|
|
26
|
+
["本单工资", 12, "AI 工分", "测试数据", "work_points_v1"]
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"integrity": {
|
|
30
|
+
"algorithm": "sha256",
|
|
31
|
+
"digest": "08fc2306dfc6c6520c9889b0a40db24bb340c7cc7b8d1637f06436a4c925879c"
|
|
32
|
+
}
|
|
33
|
+
}
|