Skip to content

Commit db0f3ef

Browse files
committed
Release v0.2.0
1 parent 485c239 commit db0f3ef

16 files changed

Lines changed: 800 additions & 119 deletions

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: windows-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
- name: Run checks
18+
shell: pwsh
19+
run: ./scripts/check.ps1

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
- name: Build release package
20+
shell: pwsh
21+
run: ./scripts/build_release.ps1 -InstallPyInstaller
22+
- name: Upload artifact
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: CodexUsageWidget
26+
path: dist/*.zip
27+
- name: Publish GitHub release
28+
if: startsWith(github.ref, 'refs/tags/')
29+
uses: softprops/action-gh-release@v2
30+
with:
31+
files: dist/*.zip

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ last_usage.json
88
widget_config.json
99
widget_start.log
1010
screen_check*.png
11+
*.bak
12+
*.lock
13+
dist/
14+
build/
15+
*.spec
1116

1217
# local debug helpers
1318
unlock_try.ps1

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changelog
2+
3+
## 0.2.0
4+
5+
- Move generated config and cache to `%LOCALAPPDATA%\CodexUsageWidget`.
6+
- Refresh usage in a background PowerShell job so the widget stays responsive.
7+
- Back up and atomically update auth files when refreshing tokens.
8+
- Add readable light/dark adaptive widget colors.
9+
- Add packaging scripts, tests, and GitHub Actions CI/release workflow.
10+
11+
## 0.1.0
12+
13+
- Initial Windows floating widget for Codex usage.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 WeikangLin93
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ A lightweight **Windows desktop floating widget** for monitoring Codex usage.
1111
Shows usage for both 5-hour and 7-day windows (used/remaining).
1212
- 每 60 秒自动刷新
1313
Auto-refreshes every 60 seconds.
14+
- 后台刷新,不因网络请求卡住悬浮窗
15+
Refreshes in the background so the widget UI stays responsive.
1416
- 支持透明度调节(20%~100%)
1517
Adjustable opacity (20%~100%).
1618
- 支持图层切换(始终置顶 / 普通层级)
@@ -21,6 +23,10 @@ A lightweight **Windows desktop floating widget** for monitoring Codex usage.
2123
Game mode (auto full-screen detection + manual force show/hide, manual override has priority).
2224
- 网络异常时使用本地缓存数据显示
2325
Falls back to cached data when network requests fail.
26+
- 配置与缓存保存到用户 AppData,不污染项目目录
27+
Stores generated config/cache under the user's AppData folder.
28+
- token 刷新写回前会备份并原子写入认证文件
29+
Backs up and atomically writes auth files when refreshing tokens.
2430

2531
---
2632

@@ -33,9 +39,11 @@ A lightweight **Windows desktop floating widget** for monitoring Codex usage.
3339
- `启动Codex用量桌显.bat`:一键启动入口(Windows)
3440
One-click launcher on Windows.
3541
- `widget_config.json`:界面配置(自动生成)
36-
UI config file (auto-generated).
42+
UI config file (auto-generated, stored in `%LOCALAPPDATA%\CodexUsageWidget`).
3743
- `last_usage.json`:最近一次成功数据缓存(自动生成)
38-
Last successful usage cache (auto-generated).
44+
Last successful usage cache (auto-generated, stored in `%LOCALAPPDATA%\CodexUsageWidget`).
45+
- `tests/`:核心 Python 逻辑的轻量测试
46+
Lightweight tests for the Python usage parser/cache behavior.
3947

4048
---
4149

@@ -63,12 +71,42 @@ A lightweight **Windows desktop floating widget** for monitoring Codex usage.
6371

6472
---
6573

74+
## 开发与验证 / Development
75+
76+
运行完整检查:
77+
78+
```powershell
79+
.\scripts\check.ps1
80+
```
81+
82+
构建便携 zip 包:
83+
84+
```powershell
85+
.\scripts\build_release.ps1
86+
```
87+
88+
如果想把 Python 抓取脚本打成单文件 exe,一起放入 release 包:
89+
90+
```powershell
91+
.\scripts\build_release.ps1 -InstallPyInstaller
92+
```
93+
94+
生成的 zip 位于 `dist\CodexUsageWidget-<version>.zip`。如果包内存在 `tools\codex_usage_fetch.exe`,小组件会优先使用它;否则会回退到本机 Python。
95+
96+
CI 会在 GitHub Actions 上运行 `scripts/check.ps1`。推送 `v*` tag 时会自动构建 zip 并发布到 GitHub Releases。
97+
98+
---
99+
66100
## 说明 / Notes
67101

102+
- 本项目依赖 ChatGPT/Codex 的本地认证文件与非公开 usage 接口;这些结构可能随官方客户端更新而变化。
103+
This project depends on local ChatGPT/Codex auth files and non-public usage endpoints, so it may need updates when the official client changes.
68104
- 本项目读取本机已有认证文件,不需要在代码里硬编码 token。
69105
This project uses local existing auth files and does not require hardcoding tokens in code.
70106
- 建议不要提交个人认证文件到仓库。
71107
Do not commit personal auth credentials to the repository.
108+
- 如果 access token 过期,脚本会使用 refresh token 刷新,并在写回认证文件前创建 `.bak` 备份。
109+
When the access token expires, the script refreshes it and creates a `.bak` backup before writing the auth file.
72110

73111
---
74112

README.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Codex 用量桌面显示(Windows)
66
1) 启动Codex用量桌显.bat 双击启动(黑色命令行窗口已隐藏)
77
2) codex_usage_widget.ps1 桌面悬浮窗(右下角)
88
3) codex_usage_fetch.py 负责请求接口并返回用量
9-
4) last_usage.json 最近一次成功数据缓存(自动生成)
10-
5) widget_config.json 你的样式配置(自动生成)
9+
4) last_usage.json 最近一次成功数据缓存(自动生成到 AppData)
10+
5) widget_config.json 你的样式配置(自动生成到 AppData)
11+
6) tests/ Python 核心逻辑测试
1112

1213
可调功能:
1314
1) 右键悬浮窗 -> 透明度(20%~100%)
@@ -17,6 +18,8 @@ Codex 用量桌面显示(Windows)
1718

1819
背景颜色会自动跟随系统任务栏风格(明/暗主题)。
1920
以上设置会自动保存,下次启动保持不变。
21+
刷新会在后台执行,网络慢时不会卡住悬浮窗。
22+
配置和缓存位置:%LOCALAPPDATA%\CodexUsageWidget
2023

2124
使用方法:
2225
1. 先确认你已登录 Codex
@@ -27,3 +30,13 @@ Codex 用量桌面显示(Windows)
2730
4. 每60秒自动刷新一次
2831
5. 右键可切换图层(桌面最顶端/活动窗口后)
2932
6. 双击悬浮窗可关闭
33+
34+
说明:
35+
1. 本工具依赖本机已有 Codex/ChatGPT 登录信息。
36+
2. 如果 access token 过期,脚本会刷新 token,并在写回认证文件前生成 .bak 备份。
37+
3. usage 接口不是公开稳定 API,官方客户端更新后可能需要跟着调整。
38+
39+
开发/打包:
40+
1. 运行检查:powershell -ExecutionPolicy Bypass -File scripts\check.ps1
41+
2. 构建 zip:powershell -ExecutionPolicy Bypass -File scripts\build_release.ps1
42+
3. 构建带 exe 的 zip:powershell -ExecutionPolicy Bypass -File scripts\build_release.ps1 -InstallPyInstaller

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.0

0 commit comments

Comments
 (0)