UNPKG

research-cli

Version:

AI-powered research assistant with web search capabilities and beautiful terminal UI

552 lines (434 loc) โ€ข 16.6 kB
# ๐Ÿ” Research CLI > **AI-powered research assistant with web search capabilities** > Transform any question into comprehensive research in seconds. [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT) ## โœจ What Makes This Special Research CLI is a **zero-install TypeScript CLI tool** that brings the power of multiple AI providers to your terminal with beautiful, professional output and secure credential management. ### ๐ŸŽฏ Perfect For - **Developers** researching APIs, frameworks, and best practices - **Researchers** gathering information with citations and sources - **Content creators** exploring topics with web-enhanced AI responses - **Students** getting quick explanations with optional deep-dives - **Teams** standardizing research workflows with shared configurations --- ## ๐Ÿš€ Quick Start ### Option 1: Interactive Setup (Recommended for New Users) ```bash npx research-cli easymode ``` Guides you through provider selection, API key setup, and your first query! ### Option 2: Direct Usage (For Quick Queries) ```bash # Basic research npx research-cli "What are the latest developments in quantum computing?" # With web search npx research-cli "TypeScript 5.0 new features" --web # Specific provider and model npx research-cli "Explain React hooks" --provider openai --model gpt-4o ``` --- ## ๐ŸŽจ Beautiful Terminal Experience ### Professional Output Formatting ```bash research-cli "Explain GraphQL" --web ``` Features beautiful colored output with: - ๐ŸŽจ **Semantic Color Themes** - Provider-specific branding - ๐Ÿ“Š **Real-time Progress Bars** - Visual feedback during API calls - ๐Ÿ” **Web Search Indicators** - See when tools are being used - โšก **Streaming Responses** - Watch results appear in real-time ### Interactive Setup Flow ```bash research-cli easymode ``` Beautiful guided setup with: - ๐ŸŽฏ **Provider Selection Menu** - Choose from OpenAI, Claude, Perplexity, Gemini - ๐Ÿ” **Secure Key Entry** - Masked input with format validation - ๐Ÿงช **Connection Testing** - Automatic API key validation - ๐Ÿš€ **Quick Demo** - Try your first query immediately --- ## ๐Ÿ›  Comprehensive Features ### ๐Ÿค– Multi-Provider AI Support - **OpenAI** - GPT-4, GPT-4o, o3 models - **Anthropic Claude** - Claude 3.5 Sonnet, Haiku models - **Perplexity** - Research-focused with built-in web search - **Google Gemini** - Gemini Pro, Ultra models ### ๐Ÿ” Enterprise-Grade Security - **Secure Storage** - API keys stored in system keychain (macOS, Windows, Linux) - **Environment Support** - Respects `OPENAI_API_KEY`, `CLAUDE_API_KEY`, etc. - **Never Logged** - Credentials redacted in dry-run mode - **Migration Tools** - Safely move from config files to secure storage ### ๐Ÿ“Š Multiple Output Formats - **Markdown** (`--format md`) - Beautiful terminal rendering (default) - **JSON** (`--format json`) - Structured data for automation - **JSONL** (`--format jsonl`) - Event stream for real-time processing - **Raw** (`--format raw`) - Plain text for simple integration ### ๐ŸŒ Web Search Integration ```bash # Enable web search for current information research-cli "Latest AI research papers 2024" --web # Control search depth research-cli "Stock market today" --web --web-search-context-size high ``` ### โš™๏ธ Flexible Configuration ```bash # Save preferences research-cli config set defaultProvider openai research-cli config set defaultModel gpt-4o # View current config research-cli config show # Reset to defaults research-cli config reset ``` --- ## ๐Ÿ“š Complete Command Reference ### ๐Ÿ” Research Commands ```bash # Basic usage (default command) research-cli "your question here" research-cli research "your question here" # explicit # Research options research-cli "question" \ --provider openai \ # openai, claude, perplexity, gemini --model gpt-4o \ # provider-specific models --web \ # enable web search --format json \ # md, json, jsonl, raw --output results.md \ # save to file --temperature 0.7 \ # generation creativity --max-tokens 1000 \ # response length limit --verbose # detailed logging ``` ### ๐ŸŽฏ Setup & Onboarding ```bash research-cli easymode # Interactive guided setup research-cli easymode --provider openai # Skip provider selection research-cli setup # Alternative command name research-cli easy # Short alias ``` ### ๐Ÿ” Authentication Management ```bash # Setup and login research-cli auth login openai # Interactive API key setup research-cli auth login openai --key sk-... # Direct key provision # Status and testing research-cli auth list # Show all configured providers research-cli auth status # Legacy status command research-cli auth test openai # Test specific provider research-cli auth keyring-status # Check system keyring # Key management research-cli auth logout openai # Remove API key research-cli auth logout openai --force # Skip confirmation research-cli auth migrate # Move from config to keyring ``` ### โš™๏ธ Configuration ```bash # Configuration management research-cli config init # Create default config research-cli config show # Display current settings research-cli config get defaultProvider # Get specific value research-cli config set theme dark # Set configuration value research-cli config reset # Reset to defaults research-cli config reset --force # Skip confirmation ``` ### ๐Ÿ›  Utility & Debug ```bash # Debug and development research-cli "test query" --dry-run # Preview request payload research-cli "question" --verbose # Detailed execution logging research-cli --version # Show version info research-cli --help # Comprehensive help ``` --- ## ๐Ÿ— Advanced Usage Patterns ### ๐Ÿ”„ Automation & Scripting ```bash # Batch processing with JSONL output echo "Question 1\nQuestion 2\nQuestion 3" | \ while read question; do research-cli "$question" --format jsonl >> results.jsonl done # CI/CD integration OPENAI_API_KEY=$SECRET research-cli \ "Analyze this codebase for security issues" \ --format json \ --output security-report.json ``` ### ๐ŸŽจ Custom Workflows ```bash # Research pipeline with web search research-cli "Latest React patterns 2024" --web --format json | \ jq '.content' | \ research-cli "Summarize this in 3 bullet points" --format md ``` ### ๐Ÿ”ง Development Integration ```bash # IDE integration (VS Code task) { "label": "Research Topic", "type": "shell", "command": "research-cli", "args": ["${input:topic}", "--web", "--format", "md"], "group": "build" } ``` --- ## ๐Ÿง  Smart Features ### ๐ŸŽฏ Progressive Disclosure Design - **Beginners**: Start with `easymode` for guided setup - **Intermediate**: Use basic commands with helpful defaults - **Advanced**: Access full option set for complex workflows ### ๐Ÿ” Intelligent Defaults - **Auto-detect** best provider based on query type - **Smart formatting** based on output destination (TTY vs file) - **Context-aware** web search activation - **Graceful fallbacks** when providers are unavailable ### ๐Ÿ“ฑ Cross-Platform Excellence - **macOS**: Native keychain integration - **Windows**: Windows Credential Store support - **Linux**: Secret Service API compatibility - **CI/CD**: Environment variable fallbacks --- ## ๐Ÿ›ก Security & Privacy ### ๐Ÿ” Credential Security - โœ… **Never stored in plaintext** - System keychain only - โœ… **Automatic redaction** - Sensitive data masked in logs - โœ… **Secure transmission** - HTTPS/TLS for all API calls - โœ… **Local processing** - No data sent to third parties ### ๐Ÿ”’ Best Practices - API keys stored using native OS credential managers - Environment variables supported for ephemeral use - Dry-run mode for testing without API calls - Comprehensive error handling with specific error codes --- ## ๐Ÿš€ Installation & Setup ### System Requirements - **Node.js 20+** (required for stable fetch and stream APIs) - **TypeScript** (included in dependencies) - **System keychain** (macOS Keychain, Windows Credential Store, Linux Secret Service) ### Installation Options #### Option 1: Direct Usage (Recommended) ```bash npx research-cli easymode ``` Zero installation required - downloads and runs latest version. #### Option 2: Global Installation ```bash npm install -g research-cli research-cli easymode ``` #### Option 3: Local Development ```bash git clone https://github.com/your-username/research-cli.git cd research-cli pnpm install pnpm build pnpm dev "your question here" ``` ### First-Time Setup 1. **Run easymode**: `research-cli easymode` 2. **Choose provider**: OpenAI, Claude, Perplexity, or Gemini 3. **Add API key**: Securely stored in system keychain 4. **Test connection**: Automatic validation 5. **Start researching**: You're ready to go! --- ## ๐Ÿ”ง Development ### Tech Stack - **TypeScript** - Strict mode, ESM modules - **Clipanion** - Modern CLI framework with decorators - **Chalk** - Terminal styling and semantic colors - **terminal-kit** - Interactive prompts and progress - **keytar** - Cross-platform credential storage - **Biome** - Code formatting and linting ### Development Commands ```bash # Development pnpm dev "test query" # Run with ts-node pnpm build # Compile TypeScript pnpm clean # Remove dist/ # Quality assurance pnpm typecheck # TypeScript checking pnpm lint # ESLint + Biome pnpm biome check --write # Format and fix # Testing pnpm test # Run test suite node dist/cli.js --dry-run # Manual testing ``` ### Project Structure ``` src/ โ”œโ”€โ”€ cli.ts # Clipanion CLI entry point โ”œโ”€โ”€ types.ts # Core TypeScript interfaces โ”œโ”€โ”€ auth/ โ”‚ โ””โ”€โ”€ keyring-manager.ts # Secure credential storage โ”œโ”€โ”€ commands/ โ”‚ โ”œโ”€โ”€ auth.ts # Authentication commands โ”‚ โ”œโ”€โ”€ config.ts # Configuration management โ”‚ โ”œโ”€โ”€ easymode.ts # Interactive setup โ”‚ โ”œโ”€โ”€ query.ts # Core research logic โ”‚ โ””โ”€โ”€ research.ts # Main research command โ”œโ”€โ”€ providers/ โ”‚ โ””โ”€โ”€ openai.ts # OpenAI API integration โ”œโ”€โ”€ render/ โ”‚ โ””โ”€โ”€ markdown.ts # Terminal output formatting โ”œโ”€โ”€ ui/ โ”‚ โ”œโ”€โ”€ styles.ts # Chalk color system โ”‚ โ”œโ”€โ”€ formatters.ts # Message formatting โ”‚ โ”œโ”€โ”€ progress.ts # Progress bar management โ”‚ โ”œโ”€โ”€ interactive.ts # Terminal-kit prompts โ”‚ โ””โ”€โ”€ boxes.ts # Layout components โ””โ”€โ”€ utils/ โ””โ”€โ”€ credentials.ts # API key utilities ``` --- ## ๐ŸŽ“ Examples & Tutorials ### Academic Research ```bash # Literature review with citations research-cli "Recent advances in machine learning 2024" \ --web \ --web-search-context-size high \ --output literature-review.md # Technical deep-dive research-cli "Explain transformer architecture in detail" \ --provider claude \ --model claude-3-5-sonnet \ --max-tokens 2000 ``` ### Development Workflow ```bash # API documentation research research-cli "How to use React Server Components" --web # Framework comparison research-cli "Next.js vs Nuxt.js vs SvelteKit comparison 2024" \ --format json \ --output framework-comparison.json # Debugging assistance research-cli "Why is my TypeScript build failing with module resolution error?" \ --provider openai \ --temperature 0.1 ``` ### Content Creation ```bash # Blog post research research-cli "Latest trends in web development 2024" \ --web \ --format md \ --output blog-research.md # Social media content research-cli "Create engaging tweet about AI developments" \ --max-tokens 280 \ --temperature 0.8 ``` --- ## ๐Ÿ› Troubleshooting ### Common Issues #### API Key Problems ```bash # Check API key status research-cli auth list # Test specific provider research-cli auth test openai # Re-setup provider research-cli auth logout openai research-cli auth login openai ``` #### Connection Issues ```bash # Verbose logging for debugging research-cli "test query" --verbose # Test with dry-run (no API call) research-cli "test query" --dry-run # Check keyring status research-cli auth keyring-status ``` #### Configuration Problems ```bash # Reset configuration research-cli config reset --force # Reinitialize research-cli config init # Manual configuration check cat ~/.config/research-cli/config.json ``` ### Error Codes - `PROVIDER_TIMEOUT` - API request timeout - `API_KEY_MISSING` - No API key found - `INVALID_PROVIDER` - Unsupported provider specified - `KEYRING_UNAVAILABLE` - System keychain access failed - `CONFIG_PARSE_ERROR` - Configuration file corruption --- ## ๐Ÿ“Š Comparison ### vs. ChatGPT Web Interface โœ… **Terminal-native** - No browser switching โœ… **Scriptable** - Automation and CI/CD integration โœ… **Multiple providers** - Not locked to one service โœ… **Local storage** - Your data stays on your machine ### vs. curl + API โœ… **User-friendly** - No JSON payload construction โœ… **Secure credentials** - Automatic key management โœ… **Beautiful output** - Formatted for humans โœ… **Error handling** - Meaningful error messages ### vs. Other CLI Tools โœ… **Multi-provider** - OpenAI, Claude, Perplexity, Gemini โœ… **Web search** - Enhanced with real-time information โœ… **Professional UI** - Progress bars, colors, interactivity โœ… **TypeScript native** - Type-safe from the ground up --- ## ๐Ÿ—บ Roadmap ### ๐Ÿšง Coming Soon - [ ] **Plugin System** - Custom providers and formatters - [ ] **Template Engine** - Reusable prompt templates - [ ] **Conversation Mode** - Multi-turn research sessions - [ ] **File Input** - Research documents and codebases - [ ] **Export Formats** - PDF, DOCX, HTML output ### ๐Ÿ”ฎ Future Ideas - [ ] **Voice Input** - Speech-to-text research queries - [ ] **Visual Output** - Charts and graphs generation - [ ] **Collaboration** - Shared research sessions - [ ] **Analytics** - Usage metrics and insights - [ ] **Mobile App** - iOS/Android companion --- ## ๐Ÿค Contributing We welcome contributions! Here's how to get started: ### ๐Ÿ› Bug Reports - Use the issue template - Include command that failed - Attach error output (with credentials redacted) - Specify your OS and Node.js version ### โœจ Feature Requests - Describe the use case - Explain the expected behavior - Consider backward compatibility - Provide implementation ideas if possible ### ๐Ÿ”ง Development Contributions 1. **Fork the repository** 2. **Create feature branch**: `git checkout -b feature/amazing-feature` 3. **Follow code style**: Run `pnpm biome check --write` 4. **Add tests**: Ensure new features are tested 5. **Update docs**: Keep README and help text current 6. **Submit PR**: Include detailed description --- ## ๐Ÿ™ Acknowledgments ### Technologies That Made This Possible - **[Clipanion](https://github.com/arcanis/clipanion)** - Elegant CLI framework - **[Chalk](https://github.com/chalk/chalk)** - Terminal styling - **[terminal-kit](https://github.com/cronvel/terminal-kit)** - Interactive components - **[keytar](https://github.com/atom/node-keytar)** - Secure credential storage - **[OpenAI](https://openai.com)** - GPT models and API - **[Anthropic](https://anthropic.com)** - Claude models - **[Perplexity](https://perplexity.ai)** - Research-focused AI ### Inspiration - **[GitHub CLI](https://cli.github.com/)** - Excellence in CLI design - **[Vercel CLI](https://vercel.com/cli)** - Developer experience focus - **[Stripe CLI](https://stripe.com/docs/stripe-cli)** - Professional API tooling --- ## ๐Ÿ“„ License **MIT License** - Feel free to use this in your personal and commercial projects. See [LICENSE](LICENSE) for full details. --- <div align="center"> **Made with โค๏ธ for developers, researchers, and curious minds everywhere** โญ **Star this repo** โ€ข ๐Ÿ› **Report bugs** โ€ข ๐Ÿ’ก **Request features** </div>