spiral-cli
A command-line interface for interacting with the Spiral API from your terminal.
Installation
Prerequisites
- macOS (Safari/Chrome/Firefox cookie extraction)
- Bun >= 1.1.0
- Full Disk Access for terminal (macOS Sonoma+)
Install from npm (recommended)
bun add -g @every-env/spiral-cli
bunx @every-env/spiral-cli chat "Write a tweet about AI"
After installation, the spiral command is available globally:
spiral chat "Your prompt here"
Install from source
git clone https://github.com/EveryInc/spiral-next.git
cd spiral-next/spiral-cli
bun install
Build standalone binary
bun run build
Quick Start
bun run src/cli.ts chat
bun run src/cli.ts send "Write a haiku about coding"
Usage
Core Commands
spiral chat [--session <id>] [--new]
spiral send <message> [--session <id>] [--json] [--attach file...]
spiral sessions [--json] [--limit N]
spiral history <session-id> [--json] [--limit N]
spiral auth status
spiral auth clear
Content Management
spiral styles [--json]
spiral workspaces [--json]
spiral drafts --session <id> [--json]
spiral draft view <id> --session <id>
spiral draft edit <id> --session <id>
spiral draft update <id> --session <id> --content "New text"
spiral draft versions <id> --session <id>
spiral draft restore <id> --session <id> --versionId <vid>
Notes & Suggestions
spiral notes
spiral notes add "Remember X"
spiral notes clear
spiral notes remove <id>
spiral suggestions
spiral suggestions preview <id>
spiral suggestions apply <id> --session <id>
spiral suggestions dismiss <id>
Options
--help, -h | Show help |
--version, -v | Show version |
--session, -s <id> | Resume session by ID |
--json | Output as JSON (for scripting) |
--quiet, -q | Suppress spinners and progress |
--new, -n | Start new session |
--limit <N> | Limit results |
--debug, -d | Enable debug output |
--attach, -a <files> | Attach files to message |
--style <id> | Use writing style |
--workspace <id> | Use workspace context |
--force, -f | Skip confirmations |
--content <text> | Content for agent-native draft update |
--title <text> | Title for draft |
--versionId <id> | Version ID for restore |
REPL Commands (in chat mode)
/help | Show all commands |
/exit | Exit chat |
/clear | Clear screen |
/history | Show session history |
/sessions | List all sessions |
/new | Start new session |
/session <id> | Switch to session |
/debug | Toggle debug mode |
Content Management:
/drafts | List drafts in session |
/draft view <id> | View a draft |
/draft edit <id> | Edit in $EDITOR |
/draft versions <id> | Show version history |
/styles | List writing styles |
/style <id> | Set writing style |
/workspaces | List workspaces |
/workspace <id> | Set workspace |
Notes & Suggestions:
/note <text> | Add a note |
/notes | List all notes |
/notes clear | Clear all notes |
/suggestions | List pending suggestions |
/apply <id> | Apply a suggestion |
/dismiss <id> | Dismiss a suggestion |
/attach <files> | Queue files for next message |
Agent-Native Usage
spiral-cli is designed for use by AI agents and scripts:
spiral send "Summarize this article" --json
echo "Explain quantum computing" | spiral send --json
spiral send "Analyze this data" --attach data.csv --json
spiral draft update <id> --session <sid> --content "Updated content"
spiral send "Hello" && echo "Success" || echo "Failed"
Exit Codes
| 0 | Success |
| 1 | General error |
| 2 | Authentication failed |
| 3 | API error |
| 4 | Network error |
| 5 | Invalid arguments |
Environment Variables
SPIRAL_API_URL | Override API endpoint |
SPIRAL_TOKEN | Provide auth token directly (for CI) |
EDITOR | Editor for draft editing (default: vi) |
DEBUG | Enable verbose logging |
Configuration
spiral-cli stores local configuration in ~/.config/spiral-cli/:
- Current workspace and style preferences
- Local notes/scratchpad
- Draft cache for offline editing
Authentication
API Key Authentication (Recommended)
The recommended way to authenticate is with an API key:
spiral auth login
spiral auth status
spiral auth logout
Get your API key:
Environment Variable (CI/CD)
For scripts and CI/CD pipelines, use the SPIRAL_TOKEN environment variable:
export SPIRAL_TOKEN=spiral_sk_your_key_here
spiral send "Generate a summary" --json
Browser Cookie Fallback
If no API key is configured, spiral-cli can extract your session from browser cookies (Safari/Chrome/Firefox). This requires:
To grant Full Disk Access:
- Open System Preferences > Privacy & Security
- Click Full Disk Access
- Add your terminal app
Security Notes
- $EDITOR Integration: Only trusted editors (vim, nvim, nano, code, etc.) are allowed
- File Attachments: Path traversal and sensitive paths are blocked
- Temp Files: Created with restrictive permissions, securely deleted
Development
bun run src/cli.ts --help
bun run typecheck
bun test
bun run lint
bun run build:all
License
MIT