Skip to content

Kripu77/term-research

Repository files navigation

term-research

Multi-Agent Deep Research CLI - Terminal-based research tool with intelligent breadth/depth exploration.

Use it two ways:

  1. Terminal CLI - Interactive TUI for deep research
  2. Claude Code & OpenCode Skills - Load as a skill/command in AI assistants

Quick Start

# Install dependencies
bun install

# Set up environment
cp .env.example .env
# Edit .env with your API keys

Required environment variables:

# Anthropic Claude API
ANTHROPIC_AUTH_TOKEN=your_token
ANTHROPIC_BASE_URL=https://api.anthropic.com

# Web search (Exa API)
EXA_API_KEY=your_exa_key

Getting API Keys:


Troubleshooting

Common Issues

"EXA_API_KEY not set" error

  • Ensure your .env file is in the project root
  • Restart your terminal after creating .env
  • Verify the key has no extra spaces when copying

Rate limiting errors

  • Reduce breadth/depth parameters: bun run research "topic" --breadth 10 --depth 2
  • Check your Exa API plan limits at https://exa.ai/dashboard
  • Wait a few seconds before retrying

Research appears stuck

  • The AI is thinking - this can take 10-30 seconds for scope planning
  • Check debug.log for errors: cat debug.log
  • Verify network connectivity
  • Try reducing complexity with --mode quick

TypeScript build errors

  • Run bun run typecheck to see specific errors
  • Ensure all dependencies are installed: bun install
  • Try cleaning build artifacts: rm -rf dist/ && bun run build:only

TUI not displaying correctly

  • Ensure your terminal supports Unicode characters
  • Try a different terminal app (iTerm2, Terminal.app)
  • Check your terminal font settings

Use Case 1: Terminal CLI

Interactive terminal UI with real-time progress tracking.

# Start the CLI
bun run cli.ts
# or
bun run start

# Development with auto-reload
bun run dev

Features:

  • Beautiful TUI with progress bars, task tracking, and metrics
  • Auto mode - AI determines optimal breadth (10-30) and depth (1-10)
  • Multiple modes: quick, standard, deep, ultradeep
  • Real-time phase updates and progress tracking

Interactive Commands:

Command Description
:help Show all commands
:export <file> Save report to markdown file
:status Show current research status
:restart Start new research session
:quit Exit the application

Use Case 2: Claude Code & OpenCode Skills

Load as a skill in Claude Code or use as a command in OpenCode.

For Claude Code

The skill file is at .claude/skills/deep-research.md.

Claude Code will automatically discover it. Just ask:

/deep-research "your research question"
/deep-research "complex topic" --mode deep
/deep-research "topic" --breadth 20 --depth 5

For OpenCode

The command file is at .opencode/commands/deep-research.md.

Registered in opencode.json - available as:

/deep-research <query> [options]

Options:

Flag Description
--mode, -m auto
--breadth, -b Number of sources (1-50)
--depth, -d Number of depth rounds (0-10)
--out <path> Save report to file

Examples:

/deep-research "How does Redis clustering work?"
/deep-research "PostgreSQL vs MySQL" --mode deep
/deep-research "Microservices patterns" --breadth 25 --depth 5
/deep-research "GraphQL best practices" --out ./research/graphql.md

How It Works

Research Phases

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│ SCOPE PLANNING  │ →  │ BREADTH SEARCH  │ →  │ DEPTH DECISION  │
│ LLM analyzes    │    │ 10-30 sources   │    │ LLM evaluates   │
│ query complexity│    │ Extract 3x each │    │ if depth needed  │
└─────────────────┘    └─────────────────┘    └─────────────────┘
                                                      ↓
                                        ┌─────────────────────────┐
                                        │      DEPTH SEARCH        │
                                        │ Iterative deep dives    │
                                        │ 1-10 rounds             │
                                        │ Domain-specific search  │
                                        └─────────────────────────┘
                                                      ↓
                                        ┌─────────────────────────┐
                                        │   REPORT GENERATION     │
                                        │ Comprehensive markdown  │
                                        │ with citations          │
                                        └─────────────────────────┘

Mode Configuration

Mode Breadth Depth Best For
auto AI (10-30) AI (1-10) Most queries (default)
quick 10 0 Fast overview, breadth only
standard 15 3 General research
deep 20 5 Complex topics
ultradeep 25 10 Academic/thesis level

Key Design Principles

  1. No Context Bloat - Each result truncated to 25KB, only 3 key learnings stored per source
  2. Dynamic Scope - AI determines optimal breadth/depth based on query complexity
  3. Aggressive Depth Bias - Defaults toward continuing research vs. stopping early
  4. Evidence-Based Reports - All findings include source citations

NPM Scripts

# Terminal CLI
bun run start          # Start interactive CLI
bun run dev            # Development mode with auto-reload
bun run build          # Full build
bun run build:only     # TypeScript compilation only

# Skill/Research commands
bun run research "query"              # Run research via skill handler
bun run research:quick "query"        # Quick mode
bun run research:deep "query"         # Deep mode

Project Structure

term-research/
├── cli.ts                    # Terminal CLI entry point
├── src/
│   ├── skill-handler.ts      # Unified skill handler for Claude Code/OpenCode
│   ├── workflow/
│   │   └── research-orchestrator.ts  # Core research engine
│   ├── search/
│   │   └── search-manager.ts  # Exa API integration
│   ├── state/
│   │   └── research-state.ts  # State management
│   ├── ui/
│   │   └── streaming-event-bus.ts  # Event system for UI updates
│   ├── model.ts               # LLM integration
│   ├── prompts.ts             # Prompt templates
│   └── terminal-ui.ts         # Blessed-based TUI
├── .claude/
│   └── skills/
│       └── deep-research.md   # Claude Code skill definition
├── .opencode/
│   └── commands/
│       └── deep-research.md   # OpenCode command definition
├── opencode.json              # OpenCode configuration
└── package.json               # NPM configuration

Dependencies

  • bun - Runtime and package manager
  • @ai-sdk/anthropic - Anthropic API client
  • blessed - Terminal UI framework
  • zod - Schema validation
  • p-limit - Rate limiting

License

MIT

About

Terminal based DeepResearch

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •