Skip to content

feat: cora gain — local productivity stats + viral sharing #161

@ajianaz

Description

@ajianaz

Summary

Add cora gain subcommand that tracks local review statistics and enables viral sharing of productivity gains — all privacy-first (no telemetry, local SQLite).

Motivation

  • User engagement: Shows tangible value (time saved, issues caught)
  • Virality: --share generates screenshot-ready TUI output for Twitter/LinkedIn
  • Retention: Users see ROI, less likely to churn
  • Community: --badge generates markdown badge for README

Data Model

~/.cora/gain.db (SQLite)

CREATE TABLE reviews (
    id TEXT PRIMARY KEY,
    timestamp TEXT NOT NULL,
    mode TEXT NOT NULL,          -- staged, branch, scan, unpushed
    files_changed INTEGER,
    lines_changed INTEGER,
    issues_found INTEGER,
    issues_by_severity TEXT,     -- JSON: {"critical":1,"major":3}
    tokens_used INTEGER,
    duration_ms INTEGER,
    provider TEXT,
    model TEXT,
    project_hash TEXT,           -- hashed project path (privacy)
    has_rules_fired BOOLEAN,
    has_context_chain BOOLEAN
);

CREATE TABLE issues (
    id TEXT PRIMARY KEY,
    review_id TEXT REFERENCES reviews(id),
    severity TEXT,
    category TEXT,
    file_path TEXT,
    rule_id TEXT,
    was_fixed BOOLEAN
);

CLI Interface

# Dashboard (default)
cora gain
# TUI-style output:
# ┌─ Cora Gain ─────────────────────┐
# │ Reviews: 142   Issues caught: 89│
# │ Time saved: ~14h   Tokens: 2.1M │
# │ Top provider: openai/gpt-4o     │
# └─────────────────────────────────┘

# Period stats
cora gain --week
cora gain --month

# Share (copy-ready text for social)
cora gain --share

# Markdown badge for README
cora gain --badge

Tracking Hooks

Hook into review.rs pipeline:

  1. Pre-review: record mode, files_changed, lines_changed, start timer
  2. Post-review: record issues_found, tokens_used, duration_ms, provider, model
  3. Per-issue: record severity, category, rule_id (from rules engine)

Privacy

  • All data local at ~/.cora/gain.db
  • Project paths hashed (not stored in plain)
  • No network calls, no telemetry
  • --share output includes NO file paths or code content

Implementation

  1. Add Gain variant to Commands enum in main.rs
  2. Create src/commands/gain.rs with dashboard, period, share, badge sub-commands
  3. Add tracking hooks in src/commands/review.rs
  4. Schema migration in src/gain/mod.rs
  5. TUI output formatting
  6. Tests for all modes

Acceptance Criteria

  • cora gain shows dashboard with all-time stats
  • cora gain --week/--month shows period stats
  • cora gain --share generates social-ready text
  • cora gain --badge generates markdown badge
  • Review pipeline records stats to SQLite
  • Zero network calls / telemetry
  • Tests pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions