savethis
Version:
CLI tool to download and organize Gmail attachments with AI document summarization
204 lines (143 loc) • 5.45 kB
Markdown
# Saveth.is CLI
Download, organize, and analyze Gmail attachments with AI document summarization.
**Website:** [https://saveth.is](https://saveth.is)
**Documentation:** [https://saveth.is/cli](https://saveth.is/cli)
## Development
```bash
# Install dependencies
bun install
# Run directly
bun src/index.ts accounts add
bun src/index.ts accounts
bun src/index.ts gmail export --query "has:attachment"
bun src/index.ts gmail ask "What documents do I have about project X?"
bun src/index.ts document summarize contract.pdf
# Build
bun run build
```
## Quick Start
```bash
# Install
npm install -g savethis
# Set your Google Generative AI API key (for AI analysis)
savethis config:set googleApiKey your-api-key-here
# Authenticate with your first Gmail account
savethis accounts add
# List all authenticated accounts
savethis accounts
# Download, index, and analyze attachments in one step
savethis gmail export --query "has:attachment" --output ./my-docs
# Generate Gmail search query with AI
savethis gmail query
# Chat with your email data using AI
savethis gmail ask "What documents did I receive last week?"
# Summarize any document with AI
savethis document summarize contract.pdf
# Export database to markdown
savethis export markdown --output export.md
```
## Features
- Download and search Gmail attachments across accounts
- Extract text from any file format (PDF, Office, images)
- Skip duplicates and only process new content
- Full-text search of documents
- AI chat interface for natural language queries
- Document summarization with AI
- Gmail query generation with AI
- Export database to markdown for AI analysis
- Persistent settings and authentication
## Supported File Formats
- **Documents**: PDF, DOCX, TXT, RTF, Markdown
- **Images**: JPG, PNG, WebP, GIF (with automatic OCR)
- **Spreadsheets**: XLSX, CSV, TSV
- **Presentations**: PPTX, PPT
- **Code**: Any text-based code files
## Gmail Commands
### Generate Search Query
```bash
# Generate Gmail search query with AI
savethis gmail query
# Example: "important emails with attachments from last week"
# Generates: "is:important has:attachment newer_than:2w older_than:1w"
```
Learn more about the [AI-powered Gmail Query Generator](https://saveth.is/gmail-query-generator).
### Download and Index
```bash
# Download from all accounts with default settings
savethis gmail export
# Download with a specific query
savethis gmail export --query "has:attachment from:important@example.com"
# Download to a specific folder
savethis gmail export --output ./my-documents
# Download from a specific account
savethis gmail export --account user@gmail.com
```
### AI Chat Interface
```bash
# Start an AI chat session about your emails and documents
savethis gmail ask
# Ask a specific question directly
savethis gmail ask "What PDFs did I receive from John last month?"
savethis gmail ask "Find my tax documents from 2023"
savethis gmail ask "Summarize my medical expenses"
savethis gmail ask "What contracts expire this year?"
savethis gmail ask "How much did I spend on software?"
# Specify a folder to use
savethis gmail ask --folder ./my-documents "How much did I spend on food last month?"
```
## Document Summarization
```bash
# Summarize any document with AI
savethis document summarize contract.pdf
# See OCR results and summary
savethis document summarize receipt.jpg --show-extraction
# Control extraction display
savethis document summarize report.docx --max-extraction 100
# Use different AI models
savethis document summarize code.js --model gemini-pro
```
Learn more about [AI-Powered Document Summarization](https://saveth.is/document-summarization).
## Export Commands
```bash
# Export database to markdown
savethis export markdown
```
The markdown export creates a single file containing all emails and attachments, perfect for uploading to AI tools like [Google AI Studio](https://aistudio.google.com).
## Configuration
The CLI uses a configuration file stored in `~/.savethis/config.json`. You can manage your configuration with these commands:
```bash
# View current configuration
savethis config
# Set a configuration value
savethis config:set googleApiKey your-api-key-here
savethis config:set outputDir ~/Downloads/email-attachments
savethis config:set model gemini-1.5-flash
# Get a specific configuration value
savethis config:get googleApiKey
```
Available configuration options:
- `googleApiKey`: Your Google Generative AI API key
- `outputDir`: Default directory for saving attachments
- `model`: Default AI model for analysis
## Account Management
```bash
# List all authenticated accounts
savethis accounts
# Add a new Gmail account
savethis accounts add
# Remove an account
savethis accounts remove user@gmail.com
```
## Privacy & Security
- All data stays on your computer
- Uses your own API keys
- No cloud storage of your documents
- Open source and transparent
## Troubleshooting
If you see "Gmail API has not been used in project..." error, visit the URL in the error message to enable the Gmail API.
For issues with the AI chat interface, ensure you have set a valid Google API key using `savethis config:set googleApiKey`.
## Related Documentation
- [SaveThis Website](https://saveth.is)
- [CLI Documentation](https://saveth.is/cli)
- [AI-powered Gmail Query Generator](https://saveth.is/gmail-query-generator)
- [AI-Powered Document Summarization](https://saveth.is/document-summarization)