Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,248 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Insights logo

Code Insights

Turn your AI coding sessions into actionable knowledge.

Ask DeepWiki License Upstream NPM Version FirstSun Build Status

Code Insights is a local-first analytics platform designed to extract structured decisions, learnings, prompt quality scores, and recurring patterns from AI coding sessions. Session data and derived insights are stored in a local SQLite database by default. Optional telemetry and user-configured remote LLM providers are the only features that may send data outside the machine.

Note

FirstSun-maintained fork

This repository is a maintained fork of melagiri/code-insights, originally created by Srikanth Rao M. It preserves the upstream local-first foundation while extending the product with additional session providers, semantic retrieval, prompt optimization, behavioral and personality analysis, reporting workflows, and containerized deployment.

Original authorship and license notices are retained. See FirstSun Fork Changes for a clearer distinction between the upstream foundation and the additions maintained in this repository.


Feature Lineage

Upstream foundation

The original project provides the core platform that this fork builds on:

  • session discovery and parsing for Claude Code, Cursor, Codex CLI, Copilot CLI, and VS Code Copilot Chat
  • local SQLite persistence for projects, sessions, messages, insights, usage, and cost data
  • terminal analytics, a Hono API server, and a React dashboard
  • structured insight extraction, prompt-quality analysis, cross-session reflection, and rule generation
  • Claude Code hook integration and optional local analysis through Ollama

FirstSun fork additions

This repository adds or substantially extends:

  • Additional Session Providers — Gemini CLI, Hermes Agent, OpenCode, Kilo, Crush, Antigravity, and Mistral Vibe integrations.
  • Extended Behavioral Analysis — Structural workflow narratives, rage-loop and repeated-friction detection, personality profiles, MBTI and cognitive-function views, and longitudinal trends.
  • Semantic Retrieval — Ollama embeddings with sqlite-vec, KNN similarity search, and vector-backed retrieval over insights and messages.
  • Prompt Optimization (GEPA) — Multi-objective optimization across coverage, precision, actionability, and brevity.
  • Vector-Based Recurring Insights — KNN retrieval and MMR-style deduplication before LLM theme synthesis, reducing repeated analysis work.
  • Richer Product Workflows — Reports, expanded filters, project and home grouping, editable metadata, analysis-cost visibility, and additional dashboard views.
  • Expanded Provider Support — OpenRouter, Mistral, OpenAI-compatible endpoints, and additional native agent runners.
  • Deployment and Operations — Docker, Docker Compose, multi-architecture GHCR images, repository CI, migrations, tests, architecture notes, and postmortems.
  • Privacy by Architecture — Local SQLite persistence at ~/.code-insights/data.db, with no account or cloud-sync requirement.

Supported AI Tools

Tool Data Location
Claude Code ~/.claude/projects/**/*.jsonl
Cursor Workspace storage SQLite (macOS, Linux, Windows)
Codex CLI ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl
Copilot CLI ~/.copilot/session-state/{id}/events.jsonl
VS Code Copilot Chat Platform-specific Copilot Chat storage
Gemini CLI ~/.gemini/tmp/<project_hash>/chats/*.json
Hermes Agent ~/.hermes/state.db and ~/.hermes/profiles/<profile_name>/state.db
OpenCode ~/.local/share/opencode/storage/session/*.json
Kilo ~/.local/share/kilo/kilo.db
Crush Project-specific .crush/crush.db

Demo

Session Analysis

Session Insight

Pattern Detection

Pattern Detection

Installation

Choose the distribution that matches the version you intend to run:

Distribution Tracks Notes
npx @code-insights/cli / npm Upstream package May not include FirstSun-only additions listed above.
ghcr.io/firstsun-dev/code-insights:latest FirstSun fork Multi-architecture container built from this repository.
Source build from this repository FirstSun fork Best choice for development and inspecting the complete fork implementation.
Upstream package: Quick Start with npx

The fastest way to try the upstream package without a permanent installation:

npx @code-insights/cli
Upstream package: Global NPM installation
npm install -g @code-insights/cli
code-insights
FirstSun fork: Docker

Multi-architecture images (linux/amd64, linux/arm64) are published to GitHub Container Registry:

docker pull ghcr.io/firstsun-dev/code-insights:latest
FirstSun fork: Build from source

Requires Node.js 20.19+ and pnpm 8+.

git clone https://github.com/firstsun-dev/code-insights.git
cd code-insights
pnpm install
pnpm build
node cli/dist/index.js

Usage

Code Insights operates through a unified command-line interface. Use code-insights --help for the full command reference.

Primary Workflow

code-insights install-hook    # Automated sync for Claude Code users
code-insights sync            # Manual discovery of new sessions
code-insights reflect         # Generate weekly pattern analysis
code-insights dashboard       # Launch visual analytics at localhost:7890

Options & Command Groups

Data & Synchronization

  • sync: Discovers and imports sessions from all supported providers.
    • --source [name]: Limit sync to a specific provider (for example, cursor or claude).
  • reset: Clears all synced data and resets the local SQLite database.

Analysis & Insights

  • insights [id]: Triggers a deep AI analysis of a specific session.
  • reflect: Synthesizes patterns across all sessions for a given timeframe.
    • --week [YYYY-W##]: Analyze a specific week (default: current).
  • stats: Displays terminal-based analytics for quick review.
    • today, cost, projects: Filtered views for terminal output.

Integration

  • install-hook: Installs an executable hook into Claude Code for zero-latency session analysis.
  • dashboard: Starts the Hono-based API server and serves the React frontend.
    • --port [num]: Set a custom server port (default: 7890).

Examples

Analyze cost breakdown for the current month:

code-insights stats cost

Generate a rule-set for the previous week:

code-insights reflect --week 2026-W13

Sync only from Cursor and open the dashboard:

code-insights sync --source cursor && code-insights dashboard

Embeddings & Semantic Search

Vector embeddings enable KNN similarity search over insights and messages. This workflow requires an Ollama instance with an embedding model.

# Backfill pending embeddings (insights, messages, or both)
code-insights embeddings backfill
code-insights embeddings backfill --entity insights
code-insights embeddings backfill --entity messages

# Show embedding coverage and vector index stats
code-insights embeddings status

# Force re-compute stale embeddings
code-insights embeddings recompute --all

# KNN similarity search (for testing/debugging)
code-insights embeddings search "how to handle auth"
code-insights embeddings search "error handling patterns" --top-k 10

Ollama configuration:

  • Set OLLAMA_BASE_URL (default: http://tinybot:11434).
  • The default embedding model is embeddinggemma:latest with 768 dimensions.

Prompt Optimization (GEPA)

Automatically evolve insight-generation prompts using multi-objective optimization powered by @ax-llm/ax.

# Run optimization on your session data
code-insights optimize run

# Customize student/teacher models
code-insights optimize run --provider openai --student-model gpt-4o-mini --teacher-model claude-sonnet-4-20250514

# Show current optimization state
code-insights optimize status

# List, apply, compare, and delete versions
code-insights optimize list
code-insights optimize apply <version-id>
code-insights optimize compare
code-insights optimize delete <version-id>

Optimization objectives (scored 0–1):

  • Coverage — Percentage of session content captured in generated insights.
  • Precision — Percentage of insights that are non-trivial rather than filler.
  • Actionability — Percentage of insights with concrete takeaways.
  • Brevity — Inverse of total insight token count, normalized for comparison.

Supported providers: openai, anthropic, mistral, deepseek, cohere, google-gemini

Configuration File

The system maintains its state and preferences in ~/.code-insights/config.json. Most configuration is handled through the CLI, but the file can also be edited directly for custom LLM providers or dashboard ports.

{
  "sync": {
    "autoAnalyze": true,
    "sources": ["claude", "cursor", "copilot"]
  },
  "dashboard": {
    "port": 7890,
    "llm": {
      "provider": "anthropic",
      "model": "claude-3-5-sonnet-latest"
    }
  }
}

Configuration Options

  • sync.autoAnalyze: Automatically trigger AI analysis upon session discovery (default: true).
  • dashboard.llm.provider: Primary provider for generating reflections and rules. Supports openai, anthropic, google, openrouter, and ollama.
  • dashboard.llm.apiKey: API key for the selected provider, stored locally.

Integration Deep-Dives

Claude Code Subscription Optimization

For developers using Claude Code, the install-hook command enables a high-efficiency workflow. By injecting a post-session hook, Code Insights can use the active Claude session context to perform analysis with no separate API charge and no manual trigger.

Ollama & Local Analysis

The platform can detect a configured local Ollama instance and use it for insight extraction and pattern synthesis. When both analysis and embeddings use local providers and telemetry is disabled, session content can remain within the local environment.


Architecture

Session Sources (Claude, Cursor, Copilot, Gemini CLI, Hermes, OpenCode, Crush)
             │
             ▼
      ┌─────────────┐
      │ CLI Engine  │  Discovery, Parsing, DB Persistence
      └──────┬──────┘
             │
             ▼
      ┌─────────────────────────────────────┐
      │ SQLite DB (V11)                     │  ~/.code-insights/data.db
      │  ┌──────────┐  ┌──────────────────┐ │
      │  │ Tables   │  │ Vector Tables    │ │
      │  │ projects │  │ vec_insights     │ │
      │  │ sessions │  │ vec_messages     │ │
      │  │ messages │  │ (sqlite-vec KNN) │ │
      │  │ insights │  └──────────────────┘ │
      │  └──────────┘                       │
      └──────┬──────────────────────────────┘
             │
      ┌──────┴───────────────┐
      ▼                      ▼
┌────────────┐        ┌──────────────┐
│ Terminal   │        │ Hono Server  │  LLM Proxy, REST API
│ Analytics  │        └──────┬───────┘
└────────────┘               │
                             ▼
                      ┌──────────────┐
                      │ React SPA    │  Visual Dashboard
                      └──────────────┘

── External Services (optional) ──
┌────────────┐  ┌──────────────┐  ┌─────────────┐
│ Ollama     │  │ LLM Provider │  │ GEPA        │
│ Embeddings │  │ (Analysis)   │  │ Optimization│
│ (768-dim)  │  │              │  │ (@ax-llm/ax)│
└────────────┘  └──────────────┘  └─────────────┘

Privacy

Code Insights follows a local-first model:

  • session data, metadata, and derived insights are stored in the local SQLite database
  • there is no account or built-in cloud-sync requirement
  • anonymous usage telemetry can be disabled with code-insights telemetry disable
  • analysis content is sent to a remote service only when the user configures a remote LLM provider
  • Ollama and other local providers can be used when content must remain within the local environment

Contributing

Contributions are welcome. See CONTRIBUTING.md for the monorepo structure and local development setup. Fork-specific direction and attribution are documented in FirstSun Fork Changes.

License

MIT. The original project copyright and license notices are retained. FirstSun fork modifications are contributed under the same license.

About

Turn your AI coding sessions into knowledge.

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages