codex-work-receipt 0.6.1 → 0.7.1
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 +12 -1
- package/README.en.md +33 -4
- package/README.md +33 -4
- package/assets/codex-pet/ai-work-receipt/pet.json +6 -0
- package/assets/codex-pet/ai-work-receipt/spritesheet.webp +0 -0
- package/docs/cli.en.md +16 -4
- package/docs/cli.md +16 -4
- package/docs/codex-pet.en.md +60 -0
- package/docs/codex-pet.md +64 -0
- package/docs/codex-skill.en.md +9 -1
- package/docs/codex-skill.md +9 -1
- package/docs/data-schema.en.md +1 -1
- package/docs/data-schema.md +1 -1
- package/docs/images/codex-pet-showcase.png +0 -0
- package/package.json +2 -2
- package/skills/ai-work-receipt/SKILL.md +5 -1
- package/skills/ai-work-receipt/agents/openai.yaml +2 -2
- package/src/cli.mjs +42 -7
- package/src/core/args.mjs +33 -3
- package/src/core/fact-identity.mjs +7 -0
- package/src/core/metrics.mjs +13 -3
- package/src/core/pet-installer.mjs +50 -0
- package/src/core/presentation.mjs +11 -0
- package/src/core/range.mjs +40 -2
- package/src/core/receipt-record.mjs +24 -9
- package/src/core/selector.mjs +9 -7
- package/src/renderers/html.mjs +67 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.7.1 - 2026-07-19
|
|
4
|
+
|
|
5
|
+
- 修正 HTML 长图导出:PNG 只保留完整小票和微信小程序码,不再包含数据二维码或分片数据码。
|
|
6
|
+
|
|
7
|
+
## 0.7.0 - 2026-07-19
|
|
8
|
+
|
|
9
|
+
- 新增 Codex 原生桌宠“票仔 · AI 小票工”,提供夜班绿票风格的核心状态与左右移动动画,并支持通过 `--install-pet`、`--uninstall-pet` 和 `--install-companion` 安装管理。
|
|
10
|
+
- AI 打工小票 Skill 新增“票仔,开今天的票”等自然语言入口。
|
|
11
|
+
- 新增 `--hours <1-168>` 滚动小时统计;“最近几个小时”默认按最近 3 小时处理。
|
|
12
|
+
- 滚动小时小票使用兼容 cwr1 摘要,避免与 cwr2 的“会话 × 自然日”规范事实冲突。
|
|
13
|
+
|
|
14
|
+
## 0.6.1
|
|
4
15
|
|
|
5
16
|
- 将 HTML 小票底部的重复渐变装饰替换为按小票编号生成的真实 Code 128 B 条形码,并保留适合浏览器和长图导出的静区与清晰度。
|
|
6
17
|
- 优化 multipart 扫码交互:单数据码继续与小程序码并排,多分片时先展示小程序码,再自动逐张轮播唯一可见的数据码,避免镜头同时识别多个二维码。
|
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 ·
|
|
9
|
+
One command · Local-first · Codex pet · Three themes · Mobile QR import
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -24,9 +24,19 @@ Codex Work Receipt summarizes turns, tool calls, Tokens, duration, and models, t
|
|
|
24
24
|
|
|
25
25
|
Version `0.6.0` uses the cwr2 protocol to create stable privacy-safe facts for each session and calendar day. Overlapping today, last-seven-days, and this-week receipts can be deduplicated by the receiver, and oversized payloads are automatically split into reorderable multipart QR codes that rotate one at a time in the HTML so the camera never sees multiple data codes at once.
|
|
26
26
|
|
|
27
|
+
## Meet Ticket Buddy
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="docs/codex-pet.en.md"><img src="docs/images/codex-pet-showcase.png" alt="Ticket Buddy in idle, working, needs-input, ready, and failed states" width="920"></a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<sub>Ticket Buddy changes expression as Codex becomes idle, runs a task, needs input, finishes, or gets blocked. Select the image for setup and state details.</sub>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
27
37
|
## Quickstart
|
|
28
38
|
|
|
29
|
-
Requires Node.js 20+ and local Codex session records. No clone required; choose today, the last 7 days, this week, or a specific session:
|
|
39
|
+
Requires Node.js 20+ and local Codex session records. No clone required; choose today, the last 3 hours, the last 7 days, this week, or a specific session:
|
|
30
40
|
|
|
31
41
|
```bash
|
|
32
42
|
npx codex-work-receipt@latest --lang en
|
|
@@ -38,11 +48,29 @@ Summarize all Codex activity from today:
|
|
|
38
48
|
npx codex-work-receipt@latest --today --lang en
|
|
39
49
|
```
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
Summarize the last 3 hours:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx codex-work-receipt@latest --hours 3 --lang en
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
HTML and structured data are written to `./codex-work-receipt-output/` by default. The generated page can save a high-resolution PNG containing only the full receipt and WeChat mini-program code; data QR codes are excluded. Non-interactive options such as `--latest` and `--today` remain available; see the [CLI guide](docs/cli.en.md).
|
|
42
58
|
|
|
43
59
|
## Ask Codex directly
|
|
44
60
|
|
|
45
|
-
Install the AI Work Receipt skill
|
|
61
|
+
Install the AI Work Receipt skill and Ticket Buddy Codex pet together:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx codex-work-receipt@latest --install-companion --lang en
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Restart Codex, open `Settings > Pets`, select Refresh, choose “票仔 · AI 小票工” (Ticket Buddy), and use `/pet` to wake it. Then ask:
|
|
68
|
+
|
|
69
|
+
> Ticket Buddy, create today's receipt.
|
|
70
|
+
|
|
71
|
+
> Ticket Buddy, create a receipt for the last three hours.
|
|
72
|
+
|
|
73
|
+
To install only the skill:
|
|
46
74
|
|
|
47
75
|
```bash
|
|
48
76
|
npx codex-work-receipt@latest --install-skill --lang en
|
|
@@ -62,6 +90,7 @@ The desktop page generates one or more privacy-safe data QR codes. The companion
|
|
|
62
90
|
|
|
63
91
|
- [CLI usage and options](docs/cli.en.md)
|
|
64
92
|
- [Codex Skill](docs/codex-skill.en.md)
|
|
93
|
+
- [Ticket Buddy Codex pet](docs/codex-pet.en.md)
|
|
65
94
|
- [Mobile QR import](docs/mobile-import.en.md)
|
|
66
95
|
- [Data schema and QR protocol](docs/data-schema.en.md)
|
|
67
96
|
- [Local data and privacy](docs/privacy.en.md)
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
<strong>把本机 Codex 的工作记录,开成一张可以带走的 AI 打工小票。</strong><br>
|
|
9
|
-
一行命令 · 完全本地 ·
|
|
9
|
+
一行命令 · 完全本地 · Codex 桌宠 · 三种主题 · 扫码传到手机
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -24,9 +24,19 @@
|
|
|
24
24
|
|
|
25
25
|
`0.6.0` 使用 cwr2 协议,按“会话 × 自然日”生成稳定的脱敏事实。今日、近 7 日和本周小票即使范围重叠,接收端也能识别相同工作;数据过大时会自动生成多张可重组的分片二维码,并在 HTML 中逐张自动轮播,避免镜头同时识别多个数据码。
|
|
26
26
|
|
|
27
|
+
## 认识票仔
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="docs/codex-pet.md"><img src="docs/images/codex-pet-showcase.png" alt="票仔 AI 小票工的待机、打工、等待确认、完成和失败状态" width="920"></a>
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<sub>票仔会跟随 Codex 的空闲、执行、等待确认、完成和失败状态切换表情。点击图片查看安装与状态说明。</sub>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
27
37
|
## Quickstart
|
|
28
38
|
|
|
29
|
-
需要 Node.js 20 或更高版本,并且本机已经使用过 Codex。无需克隆仓库,运行后选择“今天 / 近 7 日 / 本周 / 指定会话”:
|
|
39
|
+
需要 Node.js 20 或更高版本,并且本机已经使用过 Codex。无需克隆仓库,运行后选择“今天 / 最近 3 小时 / 近 7 日 / 本周 / 指定会话”:
|
|
30
40
|
|
|
31
41
|
```bash
|
|
32
42
|
npx codex-work-receipt@latest
|
|
@@ -38,11 +48,29 @@ npx codex-work-receipt@latest
|
|
|
38
48
|
npx codex-work-receipt@latest --today
|
|
39
49
|
```
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
查看最近 3 小时的工作:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx codex-work-receipt@latest --hours 3
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
网页和结构数据默认保存在 `./codex-work-receipt-output/`。生成的网页支持一键保存只包含完整小票和微信小程序码的高清长图,数据二维码不会进入图片。也可以继续使用 `--latest`、`--today` 等非交互参数,详见 [CLI 使用文档](docs/cli.md)。
|
|
42
58
|
|
|
43
59
|
## 直接跟 Codex 说
|
|
44
60
|
|
|
45
|
-
|
|
61
|
+
一次安装 AI 打工小票 Skill 和“票仔”Codex 桌宠:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npx codex-work-receipt@latest --install-companion
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
重启 Codex 后,在 `Settings > Pets` 中点击 Refresh,选择“票仔 · AI 小票工”,再输入 `/pet` 唤醒。以后可以说:
|
|
68
|
+
|
|
69
|
+
> 票仔,开今天的票。
|
|
70
|
+
|
|
71
|
+
> 票仔,开最近三个小时的票。
|
|
72
|
+
|
|
73
|
+
如果只想安装 Skill:
|
|
46
74
|
|
|
47
75
|
```bash
|
|
48
76
|
npx codex-work-receipt@latest --install-skill
|
|
@@ -62,6 +90,7 @@ Codex 会选择统计范围和主题、执行命令并打开小票。详见 [Cod
|
|
|
62
90
|
|
|
63
91
|
- [CLI 使用与全部参数](docs/cli.md)
|
|
64
92
|
- [Codex Skill](docs/codex-skill.md)
|
|
93
|
+
- [Codex 桌宠“票仔”](docs/codex-pet.md)
|
|
65
94
|
- [手机扫码导入](docs/mobile-import.md)
|
|
66
95
|
- [数据结构与二维码协议](docs/data-schema.md)
|
|
67
96
|
- [本地数据与隐私说明](docs/privacy.md)
|
|
Binary file
|
package/docs/cli.en.md
CHANGED
|
@@ -17,7 +17,7 @@ Run:
|
|
|
17
17
|
npx codex-work-receipt@latest --lang en
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Choose all activity today, 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.
|
|
20
|
+
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.
|
|
21
21
|
|
|
22
22
|
## Non-interactive ranges
|
|
23
23
|
|
|
@@ -33,6 +33,14 @@ Summarize all Codex activity from today in your local timezone:
|
|
|
33
33
|
npx codex-work-receipt@latest --today --lang en
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
Summarize the last 3 hours:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx codex-work-receipt@latest --hours 3 --lang en
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`--hours` accepts an integer from 1 to 168 and filters exact timestamps, including windows that cross midnight. Rolling-hour receipts use the compatible cwr1 summary protocol and do not create cwr2 session-day canonical facts.
|
|
43
|
+
|
|
36
44
|
Last 7 calendar days, including today:
|
|
37
45
|
|
|
38
46
|
```bash
|
|
@@ -79,7 +87,7 @@ Default output:
|
|
|
79
87
|
|
|
80
88
|
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.
|
|
81
89
|
|
|
82
|
-
Open the generated HTML and click “Save full PNG” to download a high-resolution image. It
|
|
90
|
+
Open the generated HTML and click “Save full PNG” to download a high-resolution image. It contains only the complete main receipt and WeChat mini-program code in the currently selected theme. Data QR codes, multipart data codes, theme controls, the page background, and the footer note are excluded. The HTML page still presents data codes normally: a single code stays beside the mini-program code, while oversized cwr2 payloads rotate their parts after the mini program has been opened so they can be imported on the phone.
|
|
83
91
|
|
|
84
92
|
Set a timezone and output path:
|
|
85
93
|
|
|
@@ -99,7 +107,8 @@ npx codex-work-receipt@latest --latest --lang en --no-open
|
|
|
99
107
|
|
|
100
108
|
| Option | Description |
|
|
101
109
|
| --- | --- |
|
|
102
|
-
| `--range <name>` | `latest`, `today`, `last-7-days`, or `this-week` |
|
|
110
|
+
| `--range <name>` | `latest`, `last-hours`, `today`, `last-7-days`, or `this-week` |
|
|
111
|
+
| `--hours <number>` | Summarize the last 1-168 hours |
|
|
103
112
|
| `--latest` | Summarize the latest active Codex session; default mode |
|
|
104
113
|
| `--today` | Summarize activity from today in the selected timezone |
|
|
105
114
|
| `--session <id>` | Summarize one specific Codex session |
|
|
@@ -109,6 +118,9 @@ npx codex-work-receipt@latest --latest --lang en --no-open
|
|
|
109
118
|
| `--output <file>` | Set the HTML output path |
|
|
110
119
|
| `--data-dir <directory>` | Set the local structured-history directory |
|
|
111
120
|
| `--install-skill` | Install the Codex AI Work Receipt skill |
|
|
121
|
+
| `--install-pet` | Install only the Ticket Buddy Codex pet |
|
|
122
|
+
| `--uninstall-pet` | Remove Ticket Buddy without deleting the skill or receipts |
|
|
123
|
+
| `--install-companion` | Install both the skill and Ticket Buddy Codex pet |
|
|
112
124
|
| `--no-open` | Do not open the generated page |
|
|
113
125
|
|
|
114
126
|
Run the built-in help at any time:
|
|
@@ -133,5 +145,5 @@ See the [data schema and QR protocol](data-schema.en.md).
|
|
|
133
145
|
|
|
134
146
|
- Codex is the only supported data source; Cursor and WorkBuddy are planned
|
|
135
147
|
- Changed-file and line counts are intentionally omitted until they can be measured consistently
|
|
136
|
-
- Calendar ranges filter
|
|
148
|
+
- Calendar ranges filter events by local date, rolling-hour ranges use exact timestamps, and both calculate per-session Token deltas
|
|
137
149
|
- Desktop PNG export is rendered locally in the browser and does not upload receipt data
|
package/docs/cli.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
npx codex-work-receipt@latest
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
命令行会让你选择:今天全部活动、最近 7 个自然日、本周,或最近的某个具体会话。选择具体会话时会展示起止时间、轮次、工具调用和模型,帮助辨认。
|
|
20
|
+
命令行会让你选择:今天全部活动、最近 3 小时、最近 7 个自然日、本周,或最近的某个具体会话。选择具体会话时会展示起止时间、轮次、工具调用和模型,帮助辨认。
|
|
21
21
|
|
|
22
22
|
## 非交互统计范围
|
|
23
23
|
|
|
@@ -33,6 +33,14 @@ npx codex-work-receipt@latest --latest
|
|
|
33
33
|
npx codex-work-receipt@latest --today
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
最近 3 小时:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx codex-work-receipt@latest --hours 3
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`--hours` 支持 1~168 的整数,并按精确时间戳筛选,可以跨越午夜。滚动小时小票使用兼容的 cwr1 摘要协议,不会写入 cwr2 的“会话 × 自然日”规范事实。
|
|
43
|
+
|
|
36
44
|
最近 7 个自然日(含今天):
|
|
37
45
|
|
|
38
46
|
```bash
|
|
@@ -79,7 +87,7 @@ npx codex-work-receipt@latest --latest --theme diner
|
|
|
79
87
|
|
|
80
88
|
默认文件名会携带统计日期范围;最近会话和指定会话则携带短编号,避免不同日期或会话的小票互相覆盖。
|
|
81
89
|
|
|
82
|
-
打开生成的 HTML 后,点击“保存完整长图”即可下载高清 PNG
|
|
90
|
+
打开生成的 HTML 后,点击“保存完整长图”即可下载高清 PNG。图片只包含完整主小票和微信小程序码,并自动使用当前选择的主题;数据二维码、分片数据码、主题按钮、网页背景和底部说明都不会进入图片。网页本身仍会正常展示数据二维码:单码时与小程序码并排,cwr2 超出单码安全容量时则在打开小程序后自动逐张轮播分片数据码,供用户在小程序中完成导入。
|
|
83
91
|
|
|
84
92
|
指定时区和输出路径:
|
|
85
93
|
|
|
@@ -99,7 +107,8 @@ npx codex-work-receipt@latest --latest --no-open
|
|
|
99
107
|
|
|
100
108
|
| 参数 | 说明 |
|
|
101
109
|
| --- | --- |
|
|
102
|
-
| `--range <name>` | `latest`、`today`、`last-7-days` 或 `this-week` |
|
|
110
|
+
| `--range <name>` | `latest`、`last-hours`、`today`、`last-7-days` 或 `this-week` |
|
|
111
|
+
| `--hours <number>` | 统计最近 1~168 小时;等价于 `last-hours` 范围 |
|
|
103
112
|
| `--latest` | 统计最近活跃的 Codex 会话,默认模式 |
|
|
104
113
|
| `--today` | 汇总指定时区今天发生的 Codex 活动 |
|
|
105
114
|
| `--session <id>` | 统计指定的 Codex 会话 |
|
|
@@ -109,6 +118,9 @@ npx codex-work-receipt@latest --latest --no-open
|
|
|
109
118
|
| `--output <file>` | 指定 HTML 输出路径 |
|
|
110
119
|
| `--data-dir <directory>` | 指定本地结构历史目录 |
|
|
111
120
|
| `--install-skill` | 安装 AI 打工小票 Codex Skill |
|
|
121
|
+
| `--install-pet` | 只安装“票仔”Codex 桌宠 |
|
|
122
|
+
| `--uninstall-pet` | 卸载“票仔”,不删除 Skill 或历史小票 |
|
|
123
|
+
| `--install-companion` | 同时安装 Skill 和“票仔”Codex 桌宠 |
|
|
112
124
|
| `--no-open` | 生成后不自动打开浏览器 |
|
|
113
125
|
|
|
114
126
|
也可以随时运行:
|
|
@@ -133,5 +145,5 @@ npx codex-work-receipt@latest --help
|
|
|
133
145
|
|
|
134
146
|
- 当前只支持 Codex;Cursor、WorkBuddy 等数据源仍在规划中
|
|
135
147
|
- 暂不统计修改文件数和代码行数,避免不同工具调用方式产生误导
|
|
136
|
-
-
|
|
148
|
+
- 自然日范围按本地日期筛选,滚动小时范围按精确时间戳筛选,并分别计算每个会话的 Token 区间增量
|
|
137
149
|
- 桌面网页导出 PNG 使用浏览器本地渲染,不上传小票数据
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Ticket Buddy Codex Pet
|
|
2
|
+
|
|
3
|
+
<p><a href="./codex-pet.md">中文</a> · <strong>English</strong> · <a href="../README.en.md">Back to README</a></p>
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
Ticket Buddy only presents Codex activity and provides companionship. It does not collect extra data, generate receipts automatically, or alter the current task. Receipt generation continues through the AI Work Receipt skill.
|
|
8
|
+
|
|
9
|
+
## Install the skill and pet together
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx codex-work-receipt@latest --install-companion --lang en
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
After installation:
|
|
16
|
+
|
|
17
|
+
1. Restart Codex.
|
|
18
|
+
2. Open `Settings > Pets`.
|
|
19
|
+
3. Select Refresh.
|
|
20
|
+
4. Choose “票仔 · AI 小票工” (Ticket Buddy).
|
|
21
|
+
5. Use `/pet` to wake it.
|
|
22
|
+
|
|
23
|
+
Then ask:
|
|
24
|
+
|
|
25
|
+
> Ticket Buddy, create today's receipt.
|
|
26
|
+
|
|
27
|
+
> Ticket Buddy, create a receipt for the latest session.
|
|
28
|
+
|
|
29
|
+
> Ticket Buddy, create a receipt for the last three hours.
|
|
30
|
+
|
|
31
|
+
“The last few hours” defaults to three hours.
|
|
32
|
+
|
|
33
|
+
## Install or remove only the pet
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx codex-work-receipt@latest --install-pet --lang en
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx codex-work-receipt@latest --uninstall-pet --lang en
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Removal only deletes `~/.codex/pets/ai-work-receipt/`. It leaves the skill, saved receipts, and other pets untouched.
|
|
44
|
+
|
|
45
|
+
## States
|
|
46
|
+
|
|
47
|
+
- Idle: quiet breathing and blinking.
|
|
48
|
+
- Running: focused button work shows that Codex is executing a task.
|
|
49
|
+
- Needs input: an open paw and head tilt show that Codex needs approval, a choice, or an answer.
|
|
50
|
+
- Ready: the pet scans the attached receipt to show that the task is complete and waiting for review.
|
|
51
|
+
- Failed or blocked: the pet looks deflated.
|
|
52
|
+
- Movement: separate leftward and rightward walking loops follow its movement direction.
|
|
53
|
+
|
|
54
|
+
Codex automatically controls state transitions and movement direction; a command cannot select an individual action row. A custom pet currently supplies only its name, description, and animation atlas. Selecting the pet returns to Codex or opens activity; it cannot run the receipt CLI directly.
|
|
55
|
+
|
|
56
|
+
## Availability
|
|
57
|
+
|
|
58
|
+
- Codex desktop app: floating companion and activity states.
|
|
59
|
+
- Codex CLI: terminal pets in compatible iTerm2, Kitty Graphics, or Sixel terminals.
|
|
60
|
+
- Codex IDE extension: no pet picker or floating pet overlay currently.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Codex 桌宠“票仔”
|
|
2
|
+
|
|
3
|
+
<p><strong>中文</strong> · <a href="./codex-pet.en.md">English</a> · <a href="../README.md">返回 README</a></p>
|
|
4
|
+
|
|
5
|
+
“票仔 · AI 小票工”是 AI 打工小票为 Codex 原生 Pets 功能制作的自定义桌宠。它是一台长着小牛角的夜班绿热敏打印机,会跟随 Codex 的空闲、工作、等待、完成和失败状态切换动画。
|
|
6
|
+
|
|
7
|
+
票仔只负责状态展示和陪伴,不会自动读取额外数据、生成小票或改变 Codex 的任务。开票仍然通过 AI 打工小票 Skill 完成。
|
|
8
|
+
|
|
9
|
+
## 一次安装 Skill 和票仔
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx codex-work-receipt@latest --install-companion
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
安装完成后:
|
|
16
|
+
|
|
17
|
+
1. 重启 Codex。
|
|
18
|
+
2. 打开 `Settings > Pets`。
|
|
19
|
+
3. 点击 Refresh。
|
|
20
|
+
4. 选择“票仔 · AI 小票工”。
|
|
21
|
+
5. 输入 `/pet` 唤醒票仔。
|
|
22
|
+
|
|
23
|
+
以后可以直接说:
|
|
24
|
+
|
|
25
|
+
> 票仔,开今天的票。
|
|
26
|
+
|
|
27
|
+
> 票仔,开最近一个会话的票。
|
|
28
|
+
|
|
29
|
+
> 票仔,开最近三个小时的票。
|
|
30
|
+
|
|
31
|
+
“最近几个小时”默认表示最近 3 小时。
|
|
32
|
+
|
|
33
|
+
## 只安装或卸载桌宠
|
|
34
|
+
|
|
35
|
+
只安装票仔:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx codex-work-receipt@latest --install-pet
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
卸载票仔:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx codex-work-receipt@latest --uninstall-pet
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
卸载只会删除 `~/.codex/pets/ai-work-receipt/`,不会删除 Skill、历史小票或其他宠物。
|
|
48
|
+
|
|
49
|
+
## 状态
|
|
50
|
+
|
|
51
|
+
- 空闲:安静呼吸和眨眼。
|
|
52
|
+
- 正在打工:专注操作打印按钮,表示 Codex 正在执行任务。
|
|
53
|
+
- 等你确认:抬手并歪头等待,表示 Codex 需要批准、选择或回答。
|
|
54
|
+
- 任务完成:查看票纸并左右扫视,表示任务已经完成、等待你回来查看。
|
|
55
|
+
- 失败或阻塞:小票工露出沮丧表情。
|
|
56
|
+
- 左右移动:根据移动方向播放对应步行动画。
|
|
57
|
+
|
|
58
|
+
Codex 会自动决定状态和移动方向,不能通过命令指定播放某一行动画。当前自定义 Pet 只能提供名称、描述和动画图集;点击票仔会返回 Codex 或打开活动列表,不能改成直接运行 CLI。
|
|
59
|
+
|
|
60
|
+
## 使用范围
|
|
61
|
+
|
|
62
|
+
- Codex 桌面端:支持悬浮桌宠和活动状态。
|
|
63
|
+
- Codex CLI:在支持 iTerm2、Kitty Graphics 或 Sixel 的终端里提供终端宠物。
|
|
64
|
+
- Codex IDE 扩展:当前不提供宠物选择器或悬浮桌宠。
|
package/docs/codex-skill.en.md
CHANGED
|
@@ -26,16 +26,24 @@ After installation, ask Codex:
|
|
|
26
26
|
|
|
27
27
|
> Generate today's AI work receipt with the diner theme.
|
|
28
28
|
|
|
29
|
+
> Ticket Buddy, create a receipt for the last three hours.
|
|
30
|
+
|
|
31
|
+
> Ticket Buddy, create a receipt for the last few hours.
|
|
32
|
+
|
|
29
33
|
> Generate an AI work receipt for the last seven days.
|
|
30
34
|
|
|
31
35
|
> Show how much Codex worked this week.
|
|
32
36
|
|
|
33
37
|
> Create a Chinese receipt for my latest session.
|
|
34
38
|
|
|
35
|
-
Codex will choose a specific session, today, the last seven days, or this week, plus the language and theme, then run the CLI and open the generated page.
|
|
39
|
+
Codex will choose a specific session, the last 1-168 hours, today, the last seven days, or this week, plus the language and theme, then run the CLI and open the generated page. “The last few hours” defaults to three hours.
|
|
40
|
+
|
|
41
|
+
If another Codex task is still running and you want the receipt immediately, start a separate local Codex chat. A message sent to the active chat may steer the current run or wait in its queue, depending on Follow-up behavior.
|
|
36
42
|
|
|
37
43
|
You can also invoke the skill explicitly with `$ai-work-receipt`.
|
|
38
44
|
|
|
45
|
+
See [Ticket Buddy Codex pet](codex-pet.en.md) for the companion setup.
|
|
46
|
+
|
|
39
47
|
## Update
|
|
40
48
|
|
|
41
49
|
Run the installation command again to safely replace an older version:
|
package/docs/codex-skill.md
CHANGED
|
@@ -26,16 +26,24 @@ Skill 会安装到:
|
|
|
26
26
|
|
|
27
27
|
> 生成我今天的 AI 打工小票,使用复古粉票。
|
|
28
28
|
|
|
29
|
+
> 票仔,开最近三个小时的票。
|
|
30
|
+
|
|
31
|
+
> 票仔,开最近几个小时的票。
|
|
32
|
+
|
|
29
33
|
> 生成我最近七天的 AI 打工小票。
|
|
30
34
|
|
|
31
35
|
> 看看本周 Codex 一共打了多少工。
|
|
32
36
|
|
|
33
37
|
> 用英文生成刚刚这次工作的 AI 打工小票。
|
|
34
38
|
|
|
35
|
-
Codex
|
|
39
|
+
Codex 会根据表达选择单次会话、最近 1~168 小时、今天、近七日或本周,以及语言和主题,然后执行命令并打开生成的网页。“最近几个小时”默认统计最近 3 小时。
|
|
40
|
+
|
|
41
|
+
如果当前 Codex 任务仍在运行,而你希望立刻查看小票,建议新开一个本地 Codex 会话再说“开今天的票”;在当前运行会话中发送的消息可能根据 Follow-up behavior 被用于 Steer 或 Queue。
|
|
36
42
|
|
|
37
43
|
也可以通过 `$ai-work-receipt` 显式调用这个 Skill。
|
|
38
44
|
|
|
45
|
+
桌宠安装和使用见 [Codex 桌宠“票仔”](codex-pet.md)。
|
|
46
|
+
|
|
39
47
|
## 更新
|
|
40
48
|
|
|
41
49
|
重新运行安装命令即可安全覆盖旧版本:
|
package/docs/data-schema.en.md
CHANGED
|
@@ -32,7 +32,7 @@ cwr2p.<transferId>.<partIndex>.<partCount>.<totalChecksum>.<partChecksum>.<chunk
|
|
|
32
32
|
|
|
33
33
|
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
34
|
|
|
35
|
-
Compact field `o` explicitly carries `latest`, `session`, `today`, `last-7-days`, or `this-week`. `d[3]` and `d[4]` carry
|
|
35
|
+
Compact field `o` explicitly carries `latest`, `session`, `last-hours`, `today`, `last-7-days`, or `this-week`. `d[3]` and `d[4]` carry date boundaries. Today, last-seven-days, and this-week receipts continue to use cwr2 canonical facts. `last-hours` is a rolling window, so it uses the compatible cwr1 summary payload to avoid colliding with session-day fact identities. The updated mini program can still import older QR codes.
|
|
36
36
|
|
|
37
37
|
`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.
|
|
38
38
|
|
package/docs/data-schema.md
CHANGED
|
@@ -32,7 +32,7 @@ cwr2p.<transferId>.<partIndex>.<partCount>.<totalChecksum>.<partChecksum>.<chunk
|
|
|
32
32
|
|
|
33
33
|
小程序应检查前缀和校验值,再解压并解析数据。未来结构升级通过 `v` 字段兼容。
|
|
34
34
|
|
|
35
|
-
精简字段 `o` 显式携带 `latest`、`session`、`today`、`last-7-days` 或 `this-week`;`d[3]` 和 `d[4]`
|
|
35
|
+
精简字段 `o` 显式携带 `latest`、`session`、`last-hours`、`today`、`last-7-days` 或 `this-week`;`d[3]` 和 `d[4]` 携带日期边界。今日、近 7 日和本周继续使用 cwr2 canonical facts。`last-hours` 是滚动时间窗,为避免与“会话 × 自然日”事实发生身份冲突,使用兼容的 cwr1 摘要载荷。旧二维码仍可由新版小程序导入。
|
|
36
36
|
|
|
37
37
|
`presentation.compensation` 是娱乐化 AI 工分,不代表真实 API 费用。为兼容当前中文小程序,二维码展示文案继续使用中文,并通过精简字段 `l` 和 `r` 携带桌面语言及工种语义 ID;英文 HTML 和本地 JSON 不受影响。
|
|
38
38
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-work-receipt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Generate a privacy-first Codex work receipt from local session metadata.",
|
|
6
6
|
"author": "a-bai-2026",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"receipt": "node src/cli.mjs",
|
|
29
29
|
"test": "node --test",
|
|
30
|
-
"check": "node --check src/cli.mjs && node --check src/core/skill-installer.mjs",
|
|
30
|
+
"check": "node --check src/cli.mjs && node --check src/core/skill-installer.mjs && node --check src/core/pet-installer.mjs && node --check src/core/range.mjs",
|
|
31
31
|
"prepublishOnly": "npm test && npm run check"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ai-work-receipt
|
|
3
|
-
description: Generate and open a privacy-first local AI work receipt from Codex session metadata. Use when the user asks Codex to create, regenerate, open, or locate an “AI
|
|
3
|
+
description: Generate and open a privacy-first local AI work receipt from Codex session metadata. Use when the user asks Codex or 票仔 to create, regenerate, open, or locate an “AI 打工小票”, “工票”, or “AI work receipt” for the latest session, the last few hours, today, the last seven days, or this week, in Chinese or English. Do not use for real invoices, salary calculations, API billing, or non-Codex activity.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AI 打工小票
|
|
@@ -10,6 +10,9 @@ Use the published `codex-work-receipt` CLI as the only statistics and rendering
|
|
|
10
10
|
## Interpret the request
|
|
11
11
|
|
|
12
12
|
- Use `--latest` for “刚刚”“这次”“最近一次”“上一段工作” or an unspecified request for one receipt.
|
|
13
|
+
- Use `--hours <N>` for “最近 N 小时”“过去 N 小时” or “近 N 小时”. Accept integers from 1 to 168.
|
|
14
|
+
- Use `--hours 3` for an unspecified “最近几个小时”“过去几个小时” request.
|
|
15
|
+
- Use `--hours 12` for “最近半天”.
|
|
13
16
|
- Use `--today` for “今天”“今日”“今天全部工作” or a daily summary.
|
|
14
17
|
- Use `--range last-7-days` for “最近七天”“近 7 日” or a rolling seven-calendar-day summary.
|
|
15
18
|
- Use `--range this-week` for “本周”“这周” or a Monday-to-now summary.
|
|
@@ -21,6 +24,7 @@ Use the published `codex-work-receipt` CLI as the only statistics and rendering
|
|
|
21
24
|
- Use `--lang en` when the user requests English or asks for the receipt in English. Use `--lang zh-CN` otherwise.
|
|
22
25
|
- If the user asks to choose interactively, run the CLI without a range flag so it can show the local selector.
|
|
23
26
|
- If the user asks for an unsupported custom date range, explain the available ranges and do not invent flags.
|
|
27
|
+
- Treat requests addressed to “票仔” the same as direct AI work receipt requests, for example “票仔,开今天的票”.
|
|
24
28
|
|
|
25
29
|
## Execute
|
|
26
30
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "AI 打工小票"
|
|
3
|
-
short_description: "
|
|
4
|
-
default_prompt: "使用 $ai-work-receipt
|
|
3
|
+
short_description: "让票仔按会话、小时或自然日生成 AI 打工小票"
|
|
4
|
+
default_prompt: "使用 $ai-work-receipt 让票仔给我刚刚这次 Codex 工作生成一张 AI 打工小票。"
|
package/src/cli.mjs
CHANGED
|
@@ -9,12 +9,13 @@ import QRCode from "qrcode";
|
|
|
9
9
|
import { parseArgs, printHelp } from "./core/args.mjs";
|
|
10
10
|
import { buildCanonicalFacts } from "./core/fact-buckets.mjs";
|
|
11
11
|
import { collectMetrics } from "./core/metrics.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { getScopeLabel } from "./core/presentation.mjs";
|
|
13
13
|
import { encodeReceiptPayloads } from "./core/qr-payload.mjs";
|
|
14
14
|
import { outputSlugForRange, resolveRange } from "./core/range.mjs";
|
|
15
15
|
import { buildReceiptRecord, persistReceiptRecord } from "./core/receipt-record.mjs";
|
|
16
16
|
import { promptForRange } from "./core/selector.mjs";
|
|
17
17
|
import { installCodexSkill } from "./core/skill-installer.mjs";
|
|
18
|
+
import { installCodexPet, uninstallCodexPet } from "./core/pet-installer.mjs";
|
|
18
19
|
import { formatNumber } from "./lib/time.mjs";
|
|
19
20
|
import { listRecentCodexSessions, loadCodexSessions } from "./parsers/codex.mjs";
|
|
20
21
|
import { renderHtml } from "./renderers/html.mjs";
|
|
@@ -64,6 +65,33 @@ async function main() {
|
|
|
64
65
|
}
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
68
|
+
if (options.installPet || options.installCompanion) {
|
|
69
|
+
const installedPet = installCodexPet({ projectDir: PROJECT_DIR });
|
|
70
|
+
const installedSkill = options.installCompanion
|
|
71
|
+
? installCodexSkill({ projectDir: PROJECT_DIR })
|
|
72
|
+
: null;
|
|
73
|
+
if (options.locale === "en") {
|
|
74
|
+
if (installedSkill) console.log(`AI Work Receipt skill installed: ${installedSkill.targetDir}`);
|
|
75
|
+
console.log(`Codex pet installed: ${installedPet.targetDir}`);
|
|
76
|
+
console.log("Restart Codex, open Settings > Pets, select Refresh, then choose 票仔 · AI 小票工 (Ticket Buddy).");
|
|
77
|
+
console.log("Use /pet to wake it. You can then ask: Ticket Buddy, create a receipt for today.");
|
|
78
|
+
} else {
|
|
79
|
+
if (installedSkill) console.log(`AI 打工小票 Skill 已安装:${installedSkill.targetDir}`);
|
|
80
|
+
console.log(`Codex 桌宠已安装:${installedPet.targetDir}`);
|
|
81
|
+
console.log("请重启 Codex,打开 Settings > Pets,点击 Refresh 后选择“票仔 · AI 小票工”。");
|
|
82
|
+
console.log("输入 /pet 唤醒票仔;以后可以说:票仔,开今天的票。");
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (options.uninstallPet) {
|
|
87
|
+
const removed = uninstallCodexPet();
|
|
88
|
+
if (options.locale === "en") {
|
|
89
|
+
console.log(removed.existed ? `Codex pet removed: ${removed.targetDir}` : "Codex pet was not installed.");
|
|
90
|
+
} else {
|
|
91
|
+
console.log(removed.existed ? `Codex 桌宠已卸载:${removed.targetDir}` : "尚未安装 AI 打工小票桌宠。");
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
67
95
|
|
|
68
96
|
if (!options.modeExplicit && process.stdin.isTTY && process.stdout.isTTY) {
|
|
69
97
|
const selected = await promptForRange({
|
|
@@ -73,13 +101,16 @@ async function main() {
|
|
|
73
101
|
});
|
|
74
102
|
options.mode = selected.mode;
|
|
75
103
|
options.sessionId = selected.sessionId;
|
|
104
|
+
options.hours = selected.hours || options.hours;
|
|
76
105
|
}
|
|
77
106
|
|
|
78
|
-
const range = resolveRange(options.mode, options.timezone, new Date(), options.sessionId);
|
|
107
|
+
const range = resolveRange(options.mode, options.timezone, new Date(), options.sessionId, options.hours);
|
|
79
108
|
const sessions = loadCodexSessions(range);
|
|
80
109
|
const metrics = collectMetrics(sessions, range);
|
|
81
110
|
const observedAt = new Date().toISOString();
|
|
82
|
-
const canonical =
|
|
111
|
+
const canonical = range.scope === "last-hours"
|
|
112
|
+
? {}
|
|
113
|
+
: buildCanonicalFacts(sessions, range, { observedAt });
|
|
83
114
|
const record = buildReceiptRecord(metrics, options.theme, options.locale, canonical);
|
|
84
115
|
const qrPayloads = encodeReceiptPayloads(record);
|
|
85
116
|
const dataQrDataUrls = await Promise.all(qrPayloads.map((payload) => QRCode.toDataURL(payload, {
|
|
@@ -109,17 +140,21 @@ async function main() {
|
|
|
109
140
|
console.log(`Generated HTML: ${outputFile}`);
|
|
110
141
|
console.log(`Structured data: ${persisted.companionPath}`);
|
|
111
142
|
console.log(`Local history: ${persisted.receiptPath}`);
|
|
112
|
-
console.log(`Range: ${
|
|
143
|
+
console.log(`Range: ${getScopeLabel(record.source.scope, options.locale, record.source.hours)} · ${record.stats.session_count} session(s)`);
|
|
113
144
|
console.log(`Stats: ${record.stats.completed_turns} turns · ${formatNumber(record.stats.tokens.total_tokens, options.locale)} Tokens · ${record.stats.tool_calls} tool calls`);
|
|
114
|
-
console.log(
|
|
145
|
+
console.log(record.manifest
|
|
146
|
+
? `Data QR: ${qrPayloads.length} code(s) · ${record.manifest.fact_count} canonical fact(s) · schema v${record.schema_version}`
|
|
147
|
+
: `Data QR: ${qrPayloads.length} code(s) · rolling summary · schema v${record.schema_version}`);
|
|
115
148
|
if (!miniProgramCodeDataUrl) console.log("Mini-program code: not configured; using the explicit placeholder");
|
|
116
149
|
} else {
|
|
117
150
|
console.log(`已生成网页:${outputFile}`);
|
|
118
151
|
console.log(`结构数据:${persisted.companionPath}`);
|
|
119
152
|
console.log(`本地历史:${persisted.receiptPath}`);
|
|
120
|
-
console.log(`统计范围:${
|
|
153
|
+
console.log(`统计范围:${getScopeLabel(record.source.scope, options.locale, record.source.hours)} · ${record.stats.session_count} 个会话`);
|
|
121
154
|
console.log(`统计:${record.stats.completed_turns} 轮 · ${formatNumber(record.stats.tokens.total_tokens, options.locale)} Token · ${record.stats.tool_calls} 次工具调用`);
|
|
122
|
-
console.log(
|
|
155
|
+
console.log(record.manifest
|
|
156
|
+
? `数据二维码:${qrPayloads.length} 个 · ${record.manifest.fact_count} 条规范事实 · schema v${record.schema_version}`
|
|
157
|
+
: `数据二维码:${qrPayloads.length} 个 · 滚动摘要 · schema v${record.schema_version}`);
|
|
123
158
|
if (!miniProgramCodeDataUrl) console.log("小程序码:尚未配置,页面使用明确占位符");
|
|
124
159
|
}
|
|
125
160
|
if (options.open) openFile(outputFile);
|