npm package: @sno-ai/search
Description: AI-powered search from your terminal - Fast, intelligent answers with citations
Author: Sno AI Corporation
Latest version: 0.1.1

# Sno Search CLI

> AI-powered search from your terminal

Fast, intelligent search powered by Sno's AI engine. Get instant answers with citations, research topics, and explore knowledge—all from the command line.

[![npm version](https://img.shields.io/npm/v/@sno-ai/search.svg)](https://www.npmjs.com/package/@sno-ai/search)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## Features

- 🚀 **Fast AI-powered search** - Get answers in seconds
- 📚 **Cited sources** - Every answer includes references
- 🔄 **Streaming responses** - See results as they're generated
- 🎨 **Clean output** - Formatted markdown responses
- 🔐 **Secure API authentication** - Project-level API keys
- ⚡ **Lightweight** - Minimal dependencies

## Installation

### npm

```bash
npm install -g @sno-ai/search
```

### pnpm

```bash
pnpm add -g @sno-ai/search
```

### Yarn

```bash
yarn global add @sno-ai/search
```

## Setup

### 1. Get Your API Key

1. Visit [https://sno.ai/settings/api](https://sno.ai/settings/api)
2. Create a new project (if you don't have one)
3. Generate a **Nexus API key** for your project
4. Copy the generated key (starts with `sno-`)

### 2. Set Environment Variable

**Linux/macOS:**
```bash
export SNO_API_KEY='your-api-key-here'
```

**Windows (PowerShell):**
```powershell
$env:SNO_API_KEY='your-api-key-here'
```

**Windows (CMD):**
```cmd
set SNO_API_KEY=your-api-key-here
```

**Permanent Setup (recommended):**

Add to your shell profile (`~/.bashrc`, `~/.zshrc`, or `~/.profile`):
```bash
export SNO_API_KEY='your-api-key-here'
```

## Quick Start

```bash
# Ask a question
sno-search "What is TypeScript?"

# Multi-word queries (quotes optional)
sno-search How does React work

# Get help
sno-search --help

# Check version
sno-search --version
```

## Usage Examples

### General Knowledge

```bash
sno-search "Explain quantum computing"
```

### Technical Questions

```bash
sno-search "What are the differences between REST and GraphQL?"
```

### Current Events

```bash
sno-search "Latest developments in AI"
```

### Research

```bash
sno-search "Compare Next.js, Remix, and Astro frameworks"
```

### How-To Queries

```bash
sno-search "How to deploy a Next.js app to Vercel"
```

## Example Output

```bash
$ sno-search "What is Rust?"

## What is Rust?

Rust is a low-level statically-typed multi-paradigm programming language
focusing on safety and performance[1][2]. Developed by Mozilla and now
maintained by the Rust Foundation, it's designed for building fast,
reliable, and memory-safe systems[3][4].

### Key Features

- **Memory Safety**: No null pointer dereferences or data races[1]
- **Zero-cost Abstractions**: High-level features with no runtime overhead[2]
- **Concurrent Programming**: Built-in support for safe concurrency[3]
- **Rich Type System**: Prevents many bugs at compile time[4]

Rust is used by companies like Discord, Dropbox, and Microsoft for
performance-critical applications[5].

[1] https://rust-lang.org/
[2] https://doc.rust-lang.org/
[3] https://en.wikipedia.org/wiki/Rust_(programming_language)
...

Powered by Sno
```

## Configuration

### Custom API URL (for development)

```bash
# Use a different API endpoint
export SNO_API_URL=http://localhost:3000/api/v1/nexus/chat
sno-search "test query"
```

## Requirements

- **Node.js**: 18.0.0 or higher
- **Internet**: Active connection required

## Development

### Clone & Setup

```bash
git clone https://github.com/sno-ai/sno-ai.git
cd sno-ai/tools/sno-search-cli
pnpm install
```

### Build

```bash
pnpm build
```

### Test Locally

```bash
# Link for local testing
npm link

# Run
sno-search "test query"

# Unlink when done
npm unlink -g @sno-ai/search
```

### Test with Custom API

```bash
# Build and test against local dev server
pnpm build
SNO_API_URL=http://localhost:3000/api/v1/nexus/chat node dist/index.js "test"
```

## Troubleshooting

### "SNO_API_KEY environment variable is required"

You need to set your API key before using the CLI:

```bash
# Get your key from https://sno.ai/settings/api
export SNO_API_KEY='sno-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
```

Make it permanent by adding to your shell profile (`~/.bashrc`, `~/.zshrc`).

### "Unauthorized - Invalid or missing API key"

**Error 401:** Your API key is invalid, revoked, or expired.

**Solutions:**
- Check that `SNO_API_KEY` is set correctly: `echo $SNO_API_KEY`
- Verify the key format starts with `sno-`
- Generate a new API key at [https://sno.ai/settings/api](https://sno.ai/settings/api)
- Make sure you're using a **Nexus API key** (not Coretex or Source key)

### "Command not found: sno-search"

Make sure the package is installed globally and npm's global bin directory is in your PATH:

```bash
# Check installation
npm list -g @sno-ai/search

# Find npm global bin path
npm bin -g

# Add to PATH if needed (add to ~/.bashrc or ~/.zshrc)
export PATH="$(npm bin -g):$PATH"
```

### Connection Errors

```bash
Error: Unable to connect to Sno API. Check your internet connection.
```

**Solutions:**
- Verify internet connection
- Check if `sno.ai` is accessible
- Try again in a few moments

### Empty Responses

If you get no output, ensure your query is not empty:

```bash
# ❌ Won't work
sno-search ""

# ✅ Works
sno-search "your question here"
```

## API

### Command Line

```bash
sno-search [options] <query>
```

**Options:**

- `--help`, `-h` - Show help message
- `--version`, `-v` - Show version number

**Arguments:**

- `<query>` - Your search query (quotes optional for multi-word queries)

### Environment Variables

- `SNO_API_URL` - Override default API endpoint (default: `https://sno.ai/api/v1/nexus/chat`)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

MIT © [Sno AI Corporation](https://sno.ai)

## Support

- 🌐 Website: [sno.ai](https://sno.ai)
- 📧 Email: support@sno.ai
- 💬 Issues: [GitHub Issues](https://github.com/sno-ai/sno-ai/issues)

## Related

- [Sno.ai](https://sno.ai) - AI-powered knowledge platform
- [Sno Unify](https://sno.ai/u) - Collaborative AI workspace
- [Sno Nexus](https://sno.ai/s) - Advanced AI search

---

**Powered by Sno** - AI-powered search and knowledge management