Skip to content

Add Rust CLI with code statistics, timing, file changes, and diff tracking#1

Draft
Copilot wants to merge 20 commits intomainfrom
copilot/add-code-statistics-timer
Draft

Add Rust CLI with code statistics, timing, file changes, and diff tracking#1
Copilot wants to merge 20 commits intomainfrom
copilot/add-code-statistics-timer

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 16, 2026

  • Fix sqlite feature build failure and clippy warnings
  • First-principles review - bugs identified and fixed:
    • Config pricing overrides never loaded at runtime - now threaded through entire parsing chain
    • Unused anyhow removed from codeburn-core Cargo.toml and workspace Cargo.toml
    • Non-UTF8-safe byte slicing fixed in display.rs - extracted to last_n_chars() helper
    • Non-UTF8-safe byte slicing fixed in TUI fit() function
    • mcp_tools extraction source clarified (correct behavior, raw names)

Copilot AI and others added 2 commits April 16, 2026 01:57
…nges, and code diff tracking

Agent-Logs-Url: https://github.com/tuchg/codeburn/sessions/8f8c4e98-2e32-4b89-94c4-012162895b51

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add functionality for code statistics and timing Add Rust CLI with code statistics, timing, file changes, and diff tracking Apr 16, 2026
Copilot AI requested a review from tuchg April 16, 2026 02:01
…lassifier, export, and tests

- Add bash_utils.rs: extract shell sub-commands from Bash tool_use blocks (strip quotes, split &&/;/|, basename, filter cd)
- Add classifier.rs: full 13-category classifier matching TS (coding, debugging, feature, refactoring, testing, exploration, planning, delegation, git, build/deploy, conversation, brainstorming, general) with regex patterns, retry/oneshot tracking
- Add models.rs: complete model pricing for Claude (Opus 4.6/4.5/4.1/4, Sonnet 4.6/4.5/4/3.7/3.5, Haiku), GPT (4o, 5, 5.3-codex, 5.4), Gemini with cache write/read rates, web search cost, and fast speed multiplier
- Add export.rs: CSV export with injection prevention (=, +, -, @ prefixes), multi-period output, daily/activity/model/tool/bash/project sections
- Rewrite parser.rs: Claude + Codex provider support, MCP tool tracking, bash command extraction, deduplication keys
- Rewrite types.rs: add mcp_breakdown, bash_breakdown, model_breakdown to SessionSummary; retries, has_edits, edit_turns, one_shot_turns to CategoryStats; provider, mcp_tools, bash_commands, deduplication_key to ParsedApiCall; total_sessions, cache_hit_pct, mcp_breakdown, bash_breakdown to Report
- Rewrite display.rs: show Shell Commands section, MCP Servers section, cache hit %, session counts, one-shot rates
- Rewrite stats.rs: aggregate from session-level breakdowns, compute cache hit percentage
- Update main.rs: register all modules, add export subcommand
- 14 bash_utils unit tests, 13 classifier tests, 5 model tests, 4 export tests, 17 integration tests (including codex, bash, mcp, retry, dedup)

Agent-Logs-Url: https://github.com/tuchg/codeburn/sessions/4f77d982-991d-4728-a7ff-b481cc98312a

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Copilot AI and others added 2 commits April 16, 2026 02:42
…OpenCode providers

Restructure to match TS codebase directory layout with src/providers/.
Each provider implements the Provider trait with discover_sessions()
and parse_session(). Cursor and OpenCode use SQLite (behind 'sqlite' feature).
Refactored parser.rs to use providers for Codex/Cursor/OpenCode sessions.

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/d9a1d051-40e7-4659-a1b6-8681716ee80b

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
25 new tests covering all providers: registry, model/tool display names,
session discovery, JSONL parsing, deduplication for Claude/Codex/Cursor/OpenCode.

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/d9a1d051-40e7-4659-a1b6-8681716ee80b

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
- Remove dead providers/claude.rs (parser.rs handles Claude directly)
- Remove claude_dir param from provider registry (use CLAUDE_CONFIG_DIR env var)
- Remove redundant provider field from ParsedProviderCall, speed field
- Remove discover_all_sessions dead function from providers/mod.rs
- Add providers/gemini.rs: reads ~/.gemini/tmp/{proj}/chats/*.json
- Add providers/copilot.rs: reads ~/.copilot/session-state/*/events.jsonl
- Add providers/pi.rs: reads ~/.pi/agent/sessions/*/*.jsonl
- Add gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-5-mini, o3, o4-mini,
  gemini-3-flash, gemini-3-pro, gemini-2.5-flash, gemini-2.0-flash pricing
- Add providers list subcommand to CLI
- Add --provider filter to report/today/month commands
- Wire model_display_name and tool_display_name into parse_provider_sessions
- Update discover_and_parse to accept optional provider filter
- Update all tests: remove Claude provider tests, add Gemini/Copilot/Pi tests

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/66eb37b2-6da0-408d-bbe2-ac7020b11186

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Copilot AI and others added 2 commits April 16, 2026 04:12
…, upstream test cases

- Add thiserror 2.0 + anyhow 1.0 + rayon 1.12 to Cargo.toml
- Add Period enum (Week/Today/Days30/Month/All) with clap::ValueEnum to types.rs
- Add ProviderKind enum (Claude/Codex/Cursor/Opencode/Gemini/Copilot/Pi) with clap::ValueEnum to types.rs
- Add codeburn::Error type with thiserror in lib.rs
- Rewrite main.rs to use Period and ProviderKind enums throughout
- Add Send+Sync bounds to Provider trait and all provider boxes
- Use rayon::par_iter to parallelize non-Claude provider parsing in discover_and_parse
- Add lowercase 'bash' to BASH_TOOL_NAMES (matches Pi provider tool names)
- Add lowercase 'edit','write','read','grep','glob' to classifier tool lists
- Add 17 new provider_test.rs tests ported from upstream PRs getagentseal#41/getagentseal#44/getagentseal#45:
  Pi: multi-project discovery, zero-token skip, multi-turn, bash extraction, dedup
  Copilot: model-change tracking, zero-token skip, dedup, tool display names, missing file
  Gemini: multi-message session, plain-string user message
  Types: Period enum values, ProviderKind::as_str, ProviderKind CLI parsing
- Fix tempdir() in provider_test.rs to use atomic counter (unique per test)
- 102 tests total (36 unit + 17 integration + 49 provider), all passing
- cargo clippy -- -D warnings: clean

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/c9f2c300-e57c-487e-a117-10a592eee4c1

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
…ge() helpers

- Add ratatui 0.30, crossterm 0.29, dashmap 6.1 to Cargo.toml
- Add Period::date_range(), Period::label(), Period::prev(), Period::next() to types.rs
  (removes duplicated date-range logic from main.rs)
- Replace Mutex<HashMap> with DashMap in parser.rs discover_and_parse:
  rayon threads write directly to DashMap with no external lock
- Create src/tui.rs - full interactive TUI dashboard:
  - 8 panels: Overview, Daily Activity, Projects, Activity Breakdown,
    Models, Tools, Shell Commands, MCP Servers
  - 2-column layout in wide mode (>=90 cols), single-column in narrow
  - Period tabs with keyboard shortcuts (←/→, 1-4)
  - Provider cycling with 'p' key (all/claude/codex/cursor/opencode/gemini/copilot/pi)
  - Scroll with ↑↓/j/k/PgUp/PgDn, quit with q/Esc
  - Color palette matching TS dashboard (ORANGE, GOLD, BLUE, GREEN, etc.)
  - Block borders with Unicode box-drawing (rounded style)
  - Gradient bar charts (█░ fill/empty)
- Update main.rs: 'codeburn' (no subcommand) launches TUI when stdout is TTY;
  'report'/'today'/'month' always print static text (for piping/scripting)
  New 'dashboard' subcommand for explicit TUI launch
- 102 tests pass, cargo clippy -- -D warnings clean

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/03a10a1f-c0ff-45b5-a1c3-9aac368d27a4

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/46c022a0-71ea-447d-a7e9-7bec9c893e76

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Copilot AI and others added 2 commits April 16, 2026 07:13
…face

- Add tracing to parser.rs (discover_and_parse, discover_claude_sessions,
  parse_session_file, parse_provider_sessions)
- Add tracing to config.rs (load, load_from)
- Add tracing to all 6 providers (codex, copilot, cursor, gemini,
  opencode, pi) in discover_sessions error paths
- Initialize tracing-subscriber with env-filter in CLI main.rs
- Create high-level analyze() facade function as primary API entry point
- Re-export key types (Report, Period, DateSpec, etc.) at crate root
- Make bash_utils pub(crate) since it is internal-only
- Re-export category_label and format_duration at crate root

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/d748e7b0-e2d7-4a05-be5e-d9328637ed88

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
- Cache all 12 classifier regex patterns using std::sync::LazyLock
  instead of recompiling on every classify_turn call
- Derive Copy for TokenUsage, CategoryStats, ModelStats (all-numeric types)
- Remove unnecessary .clone() calls on Copy types in parser.rs and stats.rs
- Eliminate redundant Vec<SessionSummary> clone in merge_into_dashmap
  by using explicit match on Entry instead of and_modify/or_insert

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/d748e7b0-e2d7-4a05-be5e-d9328637ed88

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
- Add #[cfg(feature = "sqlite")] guard to `use crate::models` in cursor.rs
  to fix unresolved module error when building with --features sqlite
- Remove needless `return` statements in cursor.rs and opencode.rs cfg blocks
- Collapse nested if-let statements in cursor.rs using let-chains (edition 2024)
- Replace useless format!() with a string literal for the SQLite query
- Guard `tracing::debug` import in opencode.rs behind
  #[cfg(not(feature = "sqlite"))] to eliminate unused-import warning

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/46034fb7-b282-4337-8cf7-38ab375a8074

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Copilot AI and others added 2 commits April 16, 2026 09:26
1. Config pricing overrides now loaded in discover_and_parse() and
   threaded through the entire parsing chain - Claude via
   calculate_cost_with_overrides(), non-Claude providers via a
   re-computation at ParsedApiCall construction using the raw model name.
   Previously ~/.config/codeburn/config.toml pricing entries were parsed
   but silently ignored at runtime.

2. Remove unused `anyhow` dependency from codeburn-core/Cargo.toml.

3. Fix non-UTF8-safe byte slicing in display.rs project name truncation.
   The old `&path[len-30..]` panics on multibyte (e.g. CJK) chars at a
   non-char-boundary byte offset. Replaced with char_indices().rev()
   to find a safe byte offset 30 chars from the end.

4. Keep mcp_tools extracted from raw call.tools (correct - MCP tool
   server names come from the raw mcp__server__tool format, which
   display_name mapping does not alter for real MCP tools).

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/6a433c50-0d5e-4cfe-ac7f-62d18a3038d6

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
…rs helper, remove anyhow from workspace deps

Agent-Logs-Url: https://github.com/tuchg/codeburn-rs/sessions/6a433c50-0d5e-4cfe-ac7f-62d18a3038d6

Co-authored-by: tuchg <24775733+tuchg@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants