feat: v0.4.0 — Agent Status Line Integration#2
Merged
Conversation
Add Claude Code status bar support so DevLog can display real-time cost and activity data in the terminal's status line area. New files: - src/core/cache.ts — Stats cache with atomic writes and freshness tracking - src/core/fast-discovery.ts — Today-only fast scan using fs.stat() mtime filtering - src/commands/statusline.ts — Plain-text status line output (stdin-aware) - src/commands/setup-statusline.ts — Auto-configure ~/.claude/settings.json Modified files: - src/core/types.ts — Added StatsCache interface - src/commands/dashboard.ts — Piggyback cache update after full scan - src/commands/stats.ts — Piggyback cache update after full scan - src/cli.ts — Register statusline + setup-statusline commands, update help text - src/index.ts — Export cache and fast-discovery modules - package.json — Version bump to 0.4.0 Performance: statusline responds in ~200ms (cached) vs >1s full scan, achieved by caching + scanning only today-modified JSONL files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code sends {context_window, model, turn_number, session_id}
via stdin, not {costUSD}. Updated StdinSession interface and
formatStatusLine to show context window usage percentage.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DevLog v0.4.0 adds Claude Code status bar integration, letting DevLog display real-time cost and activity data in the terminal's status line area. The core challenge was performance: scanning 2000+ JSONL files takes >1s, but the status bar requires <300ms response.
What was done
Part A: Cache Infrastructure
StatsCacheinterface tosrc/core/types.tswith today/allTime stats and cache freshness metadata (todayDate for day-change invalidation, timestamp for 5-minute TTL)src/core/cache.ts(~60 lines): atomic write via.tmp+rename,isCacheFresh()with day-change detection,updateCacheFromStats()helper to populate cache from full scanssrc/core/fast-discovery.ts(~70 lines): usesfs.stat()mtime to skip files not modified today, then calls existingscanSession()only on today's files — reduces scan set from 2000+ to ~10-50 filesdashboard.tsandstats.tsto callupdateCacheFromStats()as a side effect of their full scans (piggyback caching)Part B: The
statuslineCommandsrc/commands/statusline.ts(~100 lines):Promise.racewith 50ms timeout (Claude Code pipes session JSON)$2.10 this session · $12.34 today (7 sessions) · $2,906 totalstatuslinecommand incli.tswith--no-cacheoptionPart C: Setup Automation
src/commands/setup-statusline.ts(~55 lines):which~/.claude/settings.json(preserving existing settings)statusLine: { type: "command", command: "devlog statusline" }setup-statuslinecommand incli.tsPart D: Polish
cache.tsandfast-discovery.tsfromsrc/index.tscli.ts,dashboard.ts,package.jsonPerformance Results
Files Changed
src/core/types.tssrc/core/cache.tssrc/core/fast-discovery.tssrc/commands/statusline.tssrc/commands/setup-statusline.tssrc/commands/dashboard.tssrc/commands/stats.tssrc/cli.tssrc/index.tspackage.jsonTest Plan
npx tsupbuilds without errorsnpx tsc --noEmittype-checks cleandevlog statuslineoutputs plain text status line (standalone mode)echo '{"costUSD": 0.5}' | devlog statuslineoutputs with session data from stdindevlog statusline --no-cacheforces fresh scandevlogdashboard still works, cache gets updateddevlog --versionshows 0.4.0devlog --helpshows Agent Integration sectiontime devlog statusline~200ms (cached)🤖 Generated with Claude Code