commit d5c193c20941d448f3c583a31ec78dedf27c6332 Author: Matthew Breedlove Date: Fri Aug 8 07:20:28 2025 -0400 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a14702c --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +# dependencies (bun install) +node_modules + +# output +out +dist +*.tgz + +# code coverage +coverage +*.lcov + +# logs +logs +_.log +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# caches +.eslintcache +.cache +*.tsbuildinfo + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..26d710b --- /dev/null +++ b/.npmignore @@ -0,0 +1,35 @@ +# Source files +src/ +*.ts +*.tsx + +# Development files +bun.lock +CLAUDE.md +.claude/ +test-settings.json + +# Build files +tsconfig.json + +# Test and example files +*.test.* +*.spec.* + +# Git files +.git/ +.gitignore + +# Editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS files +.DS_Store +Thumbs.db + +# Node modules (in case someone uses npm instead of bun) +node_modules/ \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1eda233 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,90 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +ccstatusline is a customizable status line formatter for Claude Code CLI that displays model info, git branch, token usage, and other metrics. It functions as both: +1. A piped command processor for Claude Code status lines +2. An interactive TUI configuration tool when run without input + +## Development Commands + +```bash +# Install dependencies +bun install + +# Run locally (TUI mode) +bun run src/ccstatusline.ts + +# Test with piped input +echo '{"model":{"display_name":"Claude 3.5 Sonnet"},"transcript_path":"test.jsonl"}' | bun run src/ccstatusline.ts + +# Build for npm distribution +bun run build # Creates dist/ccstatusline.js + +# Test npm package locally +npm link +echo '{"model":{"display_name":"Claude 3.5 Sonnet"},"transcript_path":"test.jsonl"}' | ccstatusline +``` + +## Architecture + +The project has dual runtime compatibility - it works with both Bun and Node.js: + +- **src/ccstatusline.ts**: Main entry point that detects piped vs interactive mode + - Piped mode: Parses JSON from stdin and renders formatted status line + - Interactive mode: Launches React/Ink TUI for configuration + +- **src/tui.tsx**: React-based terminal UI using Ink for configuration interface + - Item management (add/remove/reorder status items) + - Color customization for different elements + +- **src/config.ts**: Settings management + - Loads from `~/.config/ccstatusline/settings.json` + - Handles migration from old settings format + - Default configuration if no settings exist + +- **npm publishing**: Uses `--packages=external` to keep dependencies external for cross-platform compatibility + +## Key Implementation Details + +- **Cross-platform stdin reading**: Code detects Bun vs Node.js environment and uses appropriate stdin API +- **Token metrics**: Parses Claude Code transcript files (JSONL format) to calculate token usage +- **Git integration**: Uses child_process.execSync to get current branch +- **80-char limit**: Status line always formats to exactly 80 characters for Claude Code compatibility +- **Flex separators**: Special separator type that expands to fill available space + +## Bun Usage Preferences + +Default to using Bun instead of Node.js. + +- Use `bun ` instead of `node ` or `ts-node ` +- Use `bun test` instead of `jest` or `vitest` +- Use `bun build ` instead of `webpack` or `esbuild` +- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install` +- Use `bun run