Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/macos-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ jobs:
run: |
bash tests/test-notifier-sound.sh

- name: Test usage alerts and reset reminders
run: |
bash tests/test-usage-alerts.sh

- name: Test enable/disable notifications
run: |
export PATH="$HOME/.local/bin:$PATH"
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cn update
code-notify version
```

Usage reset alerts are still available for Codex and Claude: `cn usage setup --watch`.
Usage reset alerts and advance reminders are available for Codex and Claude: `cn usage setup --watch`.

Voice samples: [Daily reset](https://cdn.jsdelivr.net/gh/mylee04/code-notify@main/assets/audio/codex-token-daily-limit-reset.m4a) · [Weekly reset](https://cdn.jsdelivr.net/gh/mylee04/code-notify@main/assets/audio/codex-token-weekly-limit-reset.m4a)

Expand Down Expand Up @@ -270,20 +270,29 @@ cn usage setup --watch
cn usage status
```

That enables usage alerts, sets the default 20% and 10% warning thresholds, enables distinct reset voice/sound, and starts a background watcher.
That enables usage alerts, sets the default 20% and 10% warning thresholds, schedules reset reminders at 48h, 24h, 12h, 6h, 2h, and 30m, enables distinct reset voice/sound, and starts a background watcher.

Manual setup:

```bash
cn usage on # Enable usage alerts
cn usage thresholds set 20,10 # Warn at 20% and 10% remaining
cn usage reset-reminders set 48,24,12,6,2,0.5
cn usage reset-alerts voice on # Speak reset alerts
cn usage reset-alerts sound default # Use the reset sound
cn usage check # Run one check now
cn usage watch start --interval 300 # Keep watching in the background
```

Code-Notify checks the daily (5h) and weekly (7d) usage windows. It sends a warning when remaining usage crosses 20% or 10%, and sends a reset notification when a window returns to 100%.
Code-Notify checks the daily (5h) and weekly (7d) usage windows. It sends a warning when remaining usage crosses 20% or 10%, advance reminders while unused quota is approaching its reset, and a reset notification when a window returns to 100%. Weekly windows use all default reminder stages; 5h windows use the 2h and 30m stages.

Each reminder is sent once per reset cycle. If the watcher was stopped while several stages passed, Code-Notify sends only the most urgent catch-up reminder instead of a burst. Customize or disable the schedule with:

```bash
cn usage reset-reminders set 24,6,1
cn usage reset-reminders off
cn usage reset-reminders reset
```

`cn usage check` runs once and exits. `cn usage watch start` keeps watching in the background on macOS/Linux. Use `cn usage watch stop` to stop it.

Expand All @@ -302,7 +311,7 @@ cn usage reset-alerts voice off
cn usage reset-alerts sound set ~/sounds/tokens-reset.wav
```

Send reset alerts to Slack or Discord too:
Send warnings, advance reminders, and reset alerts to Slack or Discord too:

```bash
cn channels add slack https://hooks.slack.com/services/...
Expand Down
5 changes: 4 additions & 1 deletion lib/code-notify/utils/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ ${BOLD}USAGE ALERT COMMANDS:${RESET}
${GREEN}usage check${RESET} [tool] Check now and notify on threshold/reset changes
${GREEN}usage watch${RESET} [tool] [--interval seconds]
${GREEN}usage watch start${RESET} [tool] [--interval seconds]
${GREEN}usage reset-reminders${RESET} set|off|reset
${GREEN}usage watch stop${RESET} Stop background usage watcher
${GREEN}usage thresholds set${RESET} 20,10
${GREEN}usage reset-state${RESET} Clear usage alert dedupe state
Expand Down Expand Up @@ -200,11 +201,13 @@ ${BOLD}USAGE:${RESET}
cn usage watch stop|restart|status
cn usage thresholds set 20,10
cn usage thresholds reset
cn usage reset-reminders set 48,24,12,6,2,0.5
cn usage reset-reminders on|off|reset
cn usage reset-alerts on|off
cn usage reset-alerts voice on|off
cn usage reset-alerts sound on|off|set <path>|default
cn usage reset-state

Usage alerts are opt-in. Use 'cn usage setup --watch' for the fastest setup. Low-usage warnings use normal Code-Notify delivery. Reset alerts have separate voice/sound controls so token reset can feel distinct from task-complete notifications.
Usage alerts are opt-in. Use 'cn usage setup --watch' for the fastest setup. Low-usage warnings and advance reset reminders use normal Code-Notify delivery. Reset alerts have separate voice/sound controls so token reset can feel distinct from task-complete notifications.
EOF
}
Loading