Skip to content

chose166/CasperAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CasperAI

Link code to conversations. Get full context for any symbol or ticket.

CasperAI connects your team discussions (Slack), code repositories (GitHub), and project tickets (Linear) to give you complete context about any piece of code. Ask "What's the story behind this function?" and get back discussions, commits, PRs, and tickets—all in one structured response.

// Get everything related to a function
const context = await getContext('handlePayment');

// Returns:
{
  "symbol": "handlePayment",
  "codeLocations": [{ filePath: "src/payments.ts", line: 127 }],
  "discussions": [{ platform: "slack", text: "Let's add retry logic...", author: "john" }],
  "pullRequests": [{ number: 456, title: "Add payment retry logic" }],
  "commits": [{ sha: "a1b2c3", message: "Implement payment retry" }],
  "tickets": [{ id: "LIN-123", title: "Payment failures on retry" }]
}

License: MIT Node.js

Why CasperAI?

Problem: Code has a story, but it's scattered across Slack threads, GitHub PRs, and Linear tickets. Finding context means searching multiple tools.

Solution: CasperAI indexes everything once, links it to your code, and gives you instant access via simple APIs.

Core Features

🔍 Context Retrieval

  • getContext(symbol) - Get all discussions, commits, PRs, and tickets for any function/class
  • Batch queries - Query multiple symbols at once
  • Smart search - Semantic search + full-text search (FTS5)

🎫 Ticket Enrichment

  • enrichTicket(ticketId) - Auto-populate ticket descriptions with relevant code context
  • Saves time - No more manually linking code references in tickets

⚡ Real-Time Updates

  • Webhooks - Slack, GitHub, Linear events processed automatically
  • Smart deduplication - No duplicate indexing
  • Polling fallback - Catches any missed webhook events
  • Signature verification - HMAC-SHA256 validation for security

🔒 Privacy First

  • 100% local - All data in SQLite on your machine
  • No tracking - Zero telemetry, no phone-home behavior
  • Your API keys stay local - Never transmitted to external servers
  • Open source - MIT License, inspect every line

🛠️ Developer Tools

  • REST API - /api/context, /api/search, /api/index/*, /health
  • npm SDK - getContext(), enrichTicket(), search(), indexSlack(), indexGithub(), indexLinear()
  • MCP Server - Claude Desktop integration

Quick Start

1. Install

git clone https://github.com/chose166/CasperAI.git
cd CasperAI
npm install
npm run build

2. Configure

cp .env.example .env
# Edit .env with your tokens:
# - SLACK_API_TOKEN (required)
# - GITHUB_TOKEN (optional)
# - LINEAR_API_KEY (optional)

3. Start

# Start the server
npm start

# In another terminal, index your data
curl -X POST http://localhost:3000/api/index/slack \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-super-brain-key" \
  -d '{"channel": "C12345"}'

4. Query

# Get context for a symbol
curl -X POST http://localhost:3000/api/context \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-super-brain-key" \
  -d '{"symbol": "handlePayment"}'

# Search your knowledge base
curl -X POST http://localhost:3000/api/search \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-super-brain-key" \
  -d '{"query": "authentication bug", "type": "keyword"}'

API Reference

REST Endpoints

Endpoint Method Description
/api/context POST Get context for a single symbol
/api/context/batch POST Get context for multiple symbols
/api/context/enrich POST Enrich a ticket with code context
/api/search POST Search indexed content
/api/index/slack POST Index a Slack channel
/api/index/github POST Index a GitHub repository
/api/index/linear POST Index a Linear team
/health GET Health check

npm SDK

npm install casperai
import { CasperAI } from 'casperai';

const casper = new CasperAI({
  apiUrl: 'http://localhost:3000',
  apiKey: 'your-super-brain-key'
});

// Get context
const context = await casper.getContext('handlePayment');

// Batch query
const contexts = await casper.getContextBatch(['handlePayment', 'processRefund']);

// Enrich ticket
const enriched = await casper.enrichTicket('LIN-123');

// Search
const results = await casper.search({ query: 'authentication', type: 'semantic' });

// Index
await casper.indexSlack({ channel: 'C12345' });
await casper.indexGithub({ repository: 'myorg/myrepo' });
await casper.indexLinear({ teamId: 'TEAM-123' });

MCP Server

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "casperai": {
      "command": "node",
      "args": ["/path/to/CasperAI/dist/index.js"],
      "env": {
        "SLACK_API_TOKEN": "xoxb-your-token",
        "SUPER_BRAIN_KEY": "your-key"
      }
    }
  }
}

Then use in Claude:

  • "Search CasperAI for discussions about authentication"
  • "Get context for the handlePayment function"
  • "Index our #engineering Slack channel"

Supported Platforms

Platform Indexing Webhooks What's Indexed
Slack Messages, threads, code references
GitHub Issues, PRs, commits, discussions
Linear Issues, comments, project updates

How It Works

┌─────────────┐
│   Slack     │──┐
│   GitHub    │──┼─→ Webhooks ─→ Queue ─→ Indexer ─→ SQLite + FTS5
│   Linear    │──┘                                      ↓
└─────────────┘                                    Code Mapper
                                                        ↓
┌─────────────┐                              ┌──────────────────┐
│ Your Code   │←─────────── Links ───────────│ Context Graph    │
└─────────────┘                              └──────────────────┘
                                                        ↓
                                              ┌──────────────────┐
                                              │ getContext()     │
                                              │ enrichTicket()   │
                                              │ search()         │
                                              └──────────────────┘
  1. Webhook events from Slack/GitHub/Linear arrive at CasperAI
  2. Queue system deduplicates and processes events
  3. Code mapper extracts code references (functions, files, classes)
  4. Indexer stores everything in SQLite with FTS5 for fast search
  5. Graph builder creates relationships between code, discussions, and tickets
  6. Query APIs retrieve comprehensive context in milliseconds

Configuration

Environment Variables

# Required
SLACK_API_TOKEN=xoxb-your-slack-token
SUPER_BRAIN_KEY=your-secure-api-key

# Optional Platform Integrations
GITHUB_TOKEN=ghp_your-github-token
LINEAR_API_KEY=lin_api_your-linear-key

# Optional AI Features (for semantic search)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

# Optional Webhook Secrets (for signature verification)
ENABLE_WEBHOOK_RECEIVERS=true
SLACK_SIGNING_SECRET=your_slack_secret
GITHUB_WEBHOOK_SECRET=your_github_secret
LINEAR_WEBHOOK_SECRET=your_linear_secret

# Server Configuration
PORT=3000
DATABASE_PATH=./data/knowledge-brain.db
ENABLE_PII_REDACTION=true

Webhook Setup

Enable real-time ingestion by configuring webhooks in each platform:

Slack: App Settings → Event Subscriptions → https://your-server/webhooks/slack GitHub: Repo Settings → Webhooks → https://your-server/webhooks/github Linear: Settings → Webhooks → https://your-server/webhooks/linear

See docs/WEBHOOK_SETUP.md for detailed instructions.

Privacy & Open Source

CasperAI is 100% open-source (MIT License) with zero phone-home behavior.

All data stays in local SQLite. No telemetry, no tracking, no external servers. Developers who care can audit every line of code.

Roadmap

Currently Shipping (v1.0):

  • ✅ Slack, GitHub, Linear integration
  • getContext() and enrichTicket() APIs
  • ✅ Webhook ingestion with dedup
  • ✅ Semantic search + FTS5
  • ✅ npm SDK and MCP server

Planned (future versions):

  • 🔄 More platforms (GitLab, Jira, Notion, Sentry, Datadog)
  • 🔄 Background workers for auto-indexing
  • 🔄 CI/CD integration (GitHub Actions, GitLab CI)
  • 🔄 IDE extensions (VS Code, JetBrains)
  • 🔄 Git hooks integration
  • 🔄 GraphQL API
  • 🔄 Expertise tracking ("who knows what")
  • 🔄 Temporal awareness (code evolution timeline)
  • 🔄 Staleness detection (outdated docs)
  • 🔄 Impact analysis (dependency tracking)

See ROADMAP.md for detailed plans.

Real-World Example

Enrich a bug ticket automatically:

const ticket = await enrichTicket('LIN-456');

// Auto-populates the ticket with:
// - Functions mentioned in related Slack threads
// - PRs that touched the same code
// - Recent commits to affected files
// - Similar past issues and their resolutions

No more manually searching Slack, GitHub, and Linear to add context to tickets. CasperAI does it instantly.

Documentation

Support

License

MIT License - see LICENSE for details.


About

Tribal Knowledge Super-Brain

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors