Skip to content

Commit 01dd610

Browse files
claudeduyetbot
andcommitted
refactor(statusline): convert fetch-rate-limits.sh to TypeScript
Consolidate all rate limit fetching logic into format-status.ts, eliminating the separate bash script. The TypeScript file now operates in dual mode: 1. As a library (exported functions) for import by other modules 2. As a CLI (when executed directly) for the session-start.sh hook Key improvements: - Single language (TypeScript) instead of bash/TS hybrid - Native fetch API (Node 18+) instead of curl + jq - Type-safe JSON parsing with proper interfaces - Better error handling with try/catch - No external jq dependency The file includes CLI mode detection at the bottom to enable JSON output when called directly from the bash hook. Co-Authored-By: duyetbot <duyetbot@users.noreply.github.com>
1 parent 7d04cc3 commit 01dd610

3 files changed

Lines changed: 306 additions & 332 deletions

File tree

statusline/hooks/session-start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
PLUGIN_ROOT="$(dirname "$SCRIPT_DIR")"
77

8-
# Fetch rate limits
9-
rate_limits=$("$PLUGIN_ROOT/scripts/fetch-rate-limits.sh" 2>/dev/null)
8+
# Fetch rate limits using TypeScript CLI
9+
rate_limits=$(node --no-warnings "$PLUGIN_ROOT/scripts/format-status.ts" 2>/dev/null)
1010

1111
# Parse rate limit values
1212
if [ -n "$rate_limits" ]; then

statusline/scripts/fetch-rate-limits.sh

Lines changed: 0 additions & 281 deletions
This file was deleted.

0 commit comments

Comments
 (0)