Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ node_modules
.pnp
.pnp.js

# Python virtual environment
venv/
__pycache__/
*.py[cod]
*$py.class

# Environment variables
.env
.env.local
Expand Down Expand Up @@ -133,4 +139,4 @@ logs/
# Misc
*.pem
*.key
*.cert
*.cert
206 changes: 206 additions & 0 deletions AI_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# AI Features Documentation

Blueberry Browser now includes an intelligent memory system that understands your browsing patterns, synthesizes information across tabs, and helps you find relevant past work.

## Features

### Tab Synthesis
Analyze and combine information from multiple tabs simultaneously. The AI reads all your tabs, extracts key information, and provides a coherent synthesis with source attribution.

Examples:
- "Summarize all my open tabs"
- "Compare the pricing on these 3 SaaS sites"
- "What are the common themes across these articles?"

### Context Memory
Automatic session tracking with AI-generated descriptive names. Sessions auto-save every minute with full navigation history and chat queries.

Examples:
- "Restore my React research from yesterday"
- "Show me past sessions about TypeScript"
- "What was I working on last Tuesday?"

### Semantic Search
Find tabs and past sessions by meaning, not just keywords. Uses embeddings to understand semantic similarity between your query and tab contents.

Examples:
- "Find tabs about authentication"
- "Show tabs related to database optimization"

### Smart Recommendations
Proactive suggestions based on current browsing context using multi-factor scoring (content similarity, workflow patterns, recency). View recommendations in the History tab.

### Pattern Recognition
Identifies recurring topics and workflows in your browsing history. View insights in the History tab to see:
- Recurring research topics
- Workflow patterns
- Behavioral trends

### Tab Groups
AI-assisted tab organization with color-coded groups and collapsible sections.

Examples:
- "Group these 5 tabs about React"
- "Organize my tabs by topic"
- "Create a group with all documentation tabs"

## Setup

### API Key Configuration

Create `.env` in project root:

```bash
# Choose ONE provider:

# OpenAI (recommended)
LLM_PROVIDER=openai
OPENAI_API_KEY=sk-...

# Anthropic
LLM_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Azure OpenAI
LLM_PROVIDER=azure
AZURE_API_KEY=...
AZURE_RESOURCE_NAME=your-resource
AZURE_API_VERSION=2024-02-15-preview
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-ada-002

# Optional: Specify model
LLM_MODEL=gpt-4o-mini # Default, fast and cheap
# LLM_MODEL=claude-3-5-sonnet-20241022 # Better quality
```

### Enable Semantic Search (Optional)

For semantic search and recommendations:

**OpenAI users:** Works automatically with `text-embedding-3-small`

**Azure users:** Add to `.env`:
```bash
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-ada-002
```

## Usage

### Chat Interface

**Tab Operations:**
```
"Close all LinkedIn tabs"
"Open github, react, and stackoverflow"
"Create a group called 'React Docs' with the first 3 tabs"
```

**Information Synthesis:**
```
"Summarize all tabs"
"What are the main points from these articles?"
"Compare the features across these product pages"
```

**Context Restoration:**
```
"Restore my latest session"
"Show me TypeScript sessions from this week"
"What was I researching yesterday about databases?"
```

### History Interface

Switch to "History" tab in sidebar to:
- Browse past sessions
- View AI-generated insights
- See smart recommendations
- Restore previous work

## Architecture

### Core Components

**AI Tools** (`src/main/tools/`)
- `synthesisTools.ts` - Tab synthesis & semantic search
- `contextTools.ts` - Context memory & session restore
- `tabTools.ts` - Tab creation, closing, organization
- `groupTools.ts` - Tab group management

**Intelligence Layer** (`src/main/`)
- `LLMClient.ts` - Multi-provider LLM integration
- `ContentProcessor.ts` - Tab content extraction with caching
- `ContextMemory.ts` - Session storage & semantic recall
- `RecommendationEngine.ts` - Multi-factor scoring
- `PatternAnalyzer.ts` - Workflow pattern detection
- `SessionTracker.ts` - Auto-save browsing sessions
- `ContextNamingService.ts` - AI-generated names

**Data Layer**
- `DataManager.ts` - Persistent JSON storage
- `SemanticSearch.ts` - Embedding-based similarity search

## Data Storage

**Location:**
```
~/Library/Application Support/blueberry-browser/blueberry-contexts/store.json
```

**What's stored:**
- Session metadata (timestamp, duration)
- Tab snapshots (URLs, titles)
- Full navigation history per tab
- User chat queries
- Tab groups

**Privacy:**
- All data stored locally
- Only API calls to OpenAI/Anthropic/Azure
- No third-party analytics

## Configuration

All settings in `src/main/config.ts`:
- Session timeout (30 min default)
- Auto-save interval (60s default)
- Cache sizes and TTLs
- Recommendation thresholds
- Data retention (90 days default)

## Troubleshooting

### "LLM service is not configured"
- Verify `.env` file exists in project root
- Check API key format is correct
- Ensure `LLM_PROVIDER` matches your key type

### "AZURE_EMBEDDING_DEPLOYMENT must be set"
Azure users need embeddings configured:
```bash
AZURE_EMBEDDING_DEPLOYMENT=text-embedding-ada-002
```

### Recommendations not showing
- Need at least 5 browsing sessions
- Semantic search requires embeddings configured
- Check interval is 5 minutes

### Session names are generic
- AI naming needs page content access
- Try browsing more pages per session
- Model quality affects naming (gpt-4o-mini vs claude-3-5-sonnet)

## Testing

```bash
# All tests
pnpm test

# Watch mode
pnpm test:watch

# With coverage
pnpm test -- --coverage
```

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"scripts": {
"format": "prettier --write .",
"lint": "eslint --cache .",
"test": "vitest run",
"test:watch": "vitest",
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "npm run typecheck:node && npm run typecheck:web",
Expand All @@ -22,6 +24,7 @@
},
"dependencies": {
"@ai-sdk/anthropic": "^2.0.17",
"@ai-sdk/azure": "^2.0.69",
"@ai-sdk/openai": "^2.0.30",
"@electron-toolkit/preload": "^3.0.2",
"@electron-toolkit/utils": "^4.0.0",
Expand All @@ -30,9 +33,11 @@
"class-variance-authority": "^0.7.1",
"dotenv": "^17.2.2",
"lucide-react": "^0.544.0",
"openai": "^4.77.3",
"react-markdown": "^10.1.0",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1"
"remark-gfm": "^4.0.1",
"zod": "^3.24.1"
},
"devDependencies": {
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
Expand All @@ -58,7 +63,8 @@
"tailwind-merge": "^3.3.1",
"tailwindcss": "^3.4.0",
"typescript": "^5.8.3",
"vite": "^7.0.5"
"vite": "^7.0.5",
"vitest": "^2.1.8"
},
"pnpm": {
"onlyBuiltDependencies": [
Expand Down
Loading