# Atlas - Quick Start Guide

## Starting the System

### 1. Start the Broker Server

```bash
cd Atlas/broker
npm install
npm start
```

The server will start on port 3001. You'll see:
```
✓ Atlas Broker Server running on port 3001
  PWA: http://localhost:3001/
  Health check: http://localhost:3001/health
  WebSocket: ws://localhost:3001/agent
```

### 2. (Optional) Start the PC Agent

```bash
cd Atlas/pc-agent
npm install

# First, configure your .env file
copy .env.example .env
# Edit .env and set your ALLOWED_DIRS

npm start
```

The PC Agent will connect to the broker and show:
```
✓ Registered with broker as agent [id]
  Capability level: standard
  Allowed directories: C:\Users\...\Documents\Atlas, ...
```

## Accessing from Your iPhone

### Option 1: Local Network (Both devices on same WiFi)

1. Find your computer's IP address:
   - Windows: Open Command Prompt and type `ipconfig`
   - Look for "IPv4 Address" (e.g., 192.168.1.100)

2. On your iPhone, open Safari and go to:
   ```
   http://[YOUR-IP-ADDRESS]:3001/
   ```
   Example: `http://192.168.1.100:3001/`

3. Install as PWA:
   - Tap the Share button (square with arrow)
   - Scroll down and tap "Add to Home Screen"
   - Tap "Add"
   - The Atlas icon will appear on your home screen

### Option 2: Using ngrok (Remote Access)

If you want to access Atlas from anywhere:

1. Install ngrok: https://ngrok.com/download

2. Start ngrok tunnel:
   ```bash
   ngrok http 3001
   ```

3. Ngrok will show you a URL like:
   ```
   Forwarding: https://abc123.ngrok.io -> http://localhost:3001
   ```

4. Open that URL on your iPhone and install as PWA

**Note:** The free ngrok URL changes each time. For permanent URLs, use ngrok's paid plan or deploy to a cloud server.

## First Time Setup

1. **Pair Your iPhone:**
   - Open the PWA on your iPhone
   - Tap "Pair Device"
   - Enter the 6-digit code shown on screen
   - You're now authenticated!

2. **Add Your First Task:**
   - Go to the Tasks tab
   - Tap the "+" button
   - Enter your task title
   - Choose NOW, NEXT, or LATER

3. **Start a Focus Sprint:**
   - Go to the Sprints tab
   - Select duration (15, 25, 45, or 60 minutes)
   - Tap "Start Sprint"
   - Focus on your NOW task!

4. **Use Voice:**
   - Tap the microphone icon
   - Grant microphone permission when prompted
   - Speak your thoughts, tasks, or questions
   - Atlas will transcribe and process them

## What You Built

### Phase 1-3: Core Infrastructure ✅
- Device pairing & authentication
- Voice input (Whisper) & output (TTS)
- Context management
- PWA with offline support

### Phase 4: ADHD Features ✅
- **NOW/NEXT/LATER** task system
- **Focus sprints** with timer
- **Resume system** (pick up where you left off)
- **3-tier memory** (short/working/long-term)

### Phase 5: PC Agent ✅
- File operations (read/write/delete/list)
- Script execution (whitelisted commands)
- Capability levels (read_only → admin)
- Job queue (3 concurrent jobs)

## Troubleshooting

**Can't access from iPhone:**
- Make sure both devices are on the same WiFi
- Check firewall settings (allow port 3001)
- Try using your computer's IP instead of localhost

**PC Agent won't connect:**
- Make sure broker is running first
- Check BROKER_URL in pc-agent/.env
- Verify WebSocket connection in broker logs

**Voice not working:**
- Make sure you granted microphone permissions
- Check that OPENAI_API_KEY is set in broker/.env
- Test with /health/detailed endpoint

## Next Steps

Once everything is running, try:
1. Add a few tasks to get familiar with NOW/NEXT/LATER
2. Start a 25-minute focus sprint
3. Use voice to capture thoughts as memories
4. Promote important memories to long-term
5. Set up PC Agent to manage files from your phone

Enjoy your ADHD-friendly AI operating system! 🎯
