feat(agents): add --status flag to display live session info in Claude Code status bar#154
feat(agents): add --status flag to display live session info in Claude Code status bar#154codemie-ai merged 3 commits intomainfrom
Conversation
…ssues - Rename CLI flag --statusline → --status and CODEMIE_STATUSLINE → CODEMIE_STATUS - Convert codemie-statusline.js to codemie-statusline.mjs (ESM, removes require()) - Fix path quoting in statusLine command to handle spaces in home directory - Fix settings.json data loss: abort injection on JSON parse failure instead of overwriting - Replace CODEMIE_STATUSLINE_MANAGED env var with module-level flag to avoid subprocess leakage - Sanitize logger.warn args with sanitizeLogArgs in afterRun cleanup - Add mkdirSync before copyFileSync in copy-plugins.js to prevent ENOENT in clean builds - Add 13 unit tests covering beforeRun and afterRun statusline lifecycle hooks Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
The file is now picked up by the existing recursive cpSync in copy-plugins.js, removing the redundant copyFiles loop and copyFileSync import. Update read path in claude.plugin.ts and test constant accordingly. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
8nevil8
left a comment
There was a problem hiding this comment.
Code Review — Approved
Files reviewed: src/agents/core/AgentCLI.ts, src/agents/plugins/claude/claude.plugin.ts, src/agents/plugins/claude/plugin/codemie-statusline.mjs, src/agents/plugins/claude/__tests__/claude.plugin.statusline.test.ts, scripts/copy-plugins.js
Summary
The --status flag implementation is clean, well-scoped, and follows project conventions correctly. The code introduces a live status bar for Claude Code sessions with proper lifecycle management, cross-platform guards, and good error handling. All critical areas pass review.
What was checked
Cross-Platform Compatibility — The chmod call is correctly gated behind process.platform !== 'win32', and path.join() is used consistently throughout. The statusline script itself uses execSync with a stdio: ['pipe', 'pipe', 'ignore'] option that works cross-platform. No hardcoded path separators.
Architecture Adherence — The feature lives entirely within the Claude plugin's lifecycle hooks (beforeRun/afterRun), which is the correct layer for session-scoped setup. No layer violations.
Settings Safety — The beforeRun hook correctly parses settings.json before writing and bails out with a warning on malformed JSON, preventing data loss. The afterRun hook restores original state and handles the no-settings case gracefully.
Module-level flag design — Using statuslineManagedThisSession at module scope (instead of an env var) is the right call — it keeps internal state out of subprocess environments. The flag is reset to false at the start of afterRun, so a second call is correctly a no-op.
Security — sanitizeLogArgs is used on all logger.warn calls that include path or error context. No credentials or sensitive data are logged.
Error Handling — Uses logger.warn (not logger.error or throw) for non-critical failures like parse errors and cleanup failures, which is appropriate since the status bar is an optional feature. Silent fail in the statusline script itself is correct — crashes must not propagate to Claude Code.
Standalone script justification — The comment in codemie-statusline.mjs explaining why child_process and path are imported directly (the script runs in isolation without the project runtime) is accurate and appreciated.
Previously raised comment — The redundant copyFiles loop flagged by 8nevil8 on scripts/copy-plugins.js has been fully addressed: codemie-statusline.mjs is now in the plugin/ subfolder and is picked up by the existing cpSync, with the copyFiles loop and copyFileSync import removed entirely. Resolved the thread.
Tests — 13 tests cover the meaningful paths: no-op when flag is absent, script deployment, directory creation, path quoting, idempotency on existing statusLine, malformed JSON safety, afterRun cleanup, double-call no-op, and cleanup failure logging. Test isolation via vi.resetModules() in beforeEach is correct for resetting the module-level flag.
Positive observations
- The module-level flag approach for session tracking is a thoughtful alternative to polluting subprocess env vars.
- Quoting the script path in the
commandfield (node "${scriptPath}") correctly handles home directories with spaces. - The
afterRuncleanup is unconditional on exit code, ensuring settings are always restored even after failed sessions. - Build integration via the existing
cpSyncmechanism (scripts/copy-plugins.js) is clean and minimal.
LGTM. Ready to merge.
Path constants derived via path.join() so they use backslashes on Windows and forward slashes on Unix, matching what the production code produces. CLAUDE_HOME is kept as the raw mock string (not path.join'd) since it is passed directly to mkdir without normalization. Generated with AI Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Summary
Adds a new
--statusflag tocodemie-claudethat enables a live status bar inside Claude Code, showing real-time session info: AI model, current directory, git branch, context window usage, cost, and elapsed time.Changes
--statusCLI flag — added toAgentCLIand wired into the Claude plugin lifecyclecodemie-statusline.mjs) — standalone Node.js script deployed to~/.claude/at session start; reads Claude Code's JSON hook payload via stdin and renders a two-line status bar with ANSI colorsbeforeRundeploys the script and injectsstatusLineconfig into~/.claude/settings.json;afterRunrestores the original settings after the session endsCLAUDE_SUPPORTED_VERSIONupdated from2.1.31to2.1.41beforeRunandafterRunhooks (script deployment, path quoting, settings injection/cleanup, parse error safety, flag idempotency)Impact
--statusChecklist