|
| 1 | +# Setup Checklist for second-brain |
| 2 | + |
| 3 | +Complete guide for first-time setup after installation. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | + |
| 8 | +```bash |
| 9 | +uv tool install git+https://github.com/madebygps/second-brain.git |
| 10 | +``` |
| 11 | + |
| 12 | +Verify installation: |
| 13 | +```bash |
| 14 | +brain --version |
| 15 | +# Output: Brain CLI v0.1.0 |
| 16 | +``` |
| 17 | + |
| 18 | +## Configuration |
| 19 | + |
| 20 | +### Step 1: Create Directories |
| 21 | + |
| 22 | +Create directories for your diary and planner: |
| 23 | + |
| 24 | +```bash |
| 25 | +# Create diary directory (for reflection entries) |
| 26 | +mkdir -p ~/Documents/second-brain/diary |
| 27 | + |
| 28 | +# Create planner directory (for daily plans) |
| 29 | +mkdir -p ~/Documents/second-brain/planner |
| 30 | +``` |
| 31 | + |
| 32 | +> **Tip:** Best if used with Obsidian. Point `DIARY_PATH` to your vault directory. |
| 33 | +
|
| 34 | +### Step 2: Create .env File |
| 35 | + |
| 36 | +The `brain` CLI automatically searches for `.env` in these locations (in order): |
| 37 | + |
| 38 | +1. **Current directory** (`./.env`) |
| 39 | +2. **User config directory** (`~/.config/brain/.env`) ⭐ **Recommended** |
| 40 | +3. **Home directory** (`~/.brain/.env`) |
| 41 | + |
| 42 | +**Recommended Setup (works from anywhere):** |
| 43 | + |
| 44 | +```bash |
| 45 | +# Create config directory |
| 46 | +mkdir -p ~/.config/brain |
| 47 | + |
| 48 | +# Download the example .env template |
| 49 | +curl -o ~/.config/brain/.env https://raw.githubusercontent.com/madebygps/second-brain/main/.env.example |
| 50 | + |
| 51 | +# Set secure permissions (readable by you only) |
| 52 | +chmod 600 ~/.config/brain/.env |
| 53 | + |
| 54 | +# Edit with your settings |
| 55 | +nano ~/.config/brain/.env # or use your preferred editor |
| 56 | +``` |
| 57 | + |
| 58 | +That's it! No need for shell aliases or cd-ing around. The `brain` command will automatically find your config. |
| 59 | + |
| 60 | +> **Security Note:** Your `.env` file contains API keys. The `chmod 600` command ensures only you can read it. |
| 61 | +
|
| 62 | + |
| 63 | +The current directory's `.env` takes priority over the global config. |
| 64 | + |
| 65 | +### Step 3: Configure .env |
| 66 | + |
| 67 | +Edit your `.env` file with the following **required** variables: |
| 68 | + |
| 69 | +```bash |
| 70 | +# Required: Paths (created in Step 1) |
| 71 | +DIARY_PATH=/Users/yourname/Documents/second-brain/diary |
| 72 | +PLANNER_PATH=/Users/yourname/Documents/second-brain/planner |
| 73 | + |
| 74 | +# Required: Azure OpenAI (get from Azure Portal) |
| 75 | +AZURE_OPENAI_API_KEY=your-api-key-here |
| 76 | +AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/ |
| 77 | +AZURE_OPENAI_DEPLOYMENT=gpt-4o |
| 78 | +AZURE_OPENAI_API_VERSION=2024-02-15-preview |
| 79 | + |
| 80 | +# Required: Azure AI Search (for book notes search) |
| 81 | +AZURE_SEARCH_ENDPOINT=https://your-search-service.search.windows.net |
| 82 | +AZURE_SEARCH_API_KEY=your-search-api-key-here |
| 83 | +AZURE_SEARCH_INDEX_NAME=second-brain-notes |
| 84 | +``` |
| 85 | + |
| 86 | +**Optional variables** (with defaults): |
| 87 | + |
| 88 | +```bash |
| 89 | +# Cost tracking database location |
| 90 | +BRAIN_COST_DB_PATH=~/.brain/costs.db |
| 91 | + |
| 92 | +# Logging |
| 93 | +BRAIN_LOG_LEVEL=INFO |
| 94 | +BRAIN_LOG_FILE=~/.brain/logs/brain.log |
| 95 | +``` |
| 96 | + |
| 97 | +### Step 4: Get Azure Credentials |
| 98 | + |
| 99 | +#### Azure OpenAI (Required) |
| 100 | + |
| 101 | +1. Go to [Azure Portal](https://portal.azure.com) |
| 102 | +2. Navigate to your Azure OpenAI resource |
| 103 | +3. Go to **Keys and Endpoint** |
| 104 | +4. Copy: |
| 105 | + - **KEY 1** → `AZURE_OPENAI_API_KEY` |
| 106 | + - **Endpoint** → `AZURE_OPENAI_ENDPOINT` |
| 107 | +5. Go to **Model deployments** |
| 108 | +6. Copy your deployment name (e.g., "gpt-4o") → `AZURE_OPENAI_DEPLOYMENT` |
| 109 | + |
| 110 | +#### Azure AI Search (Required for notes search) |
| 111 | + |
| 112 | +1. Go to [Azure Portal](https://portal.azure.com) |
| 113 | +2. Navigate to your Azure AI Search resource |
| 114 | +3. Go to **Keys** |
| 115 | +4. Copy: |
| 116 | + - **Primary admin key** → `AZURE_SEARCH_API_KEY` |
| 117 | +5. Copy the URL from Overview page → `AZURE_SEARCH_ENDPOINT` |
| 118 | +6. Go to **Indexes** and copy your index name → `AZURE_SEARCH_INDEX_NAME` |
| 119 | + |
| 120 | +### Step 5: Test Configuration |
| 121 | + |
| 122 | +Test that everything is configured correctly: |
| 123 | + |
| 124 | +```bash |
| 125 | +# Test diary commands (uses DIARY_PATH) |
| 126 | +brain diary list |
| 127 | + |
| 128 | +# Test plan commands (uses PLANNER_PATH) |
| 129 | +brain plan create today |
| 130 | + |
| 131 | +# Test notes search (uses Azure AI Search) |
| 132 | +brain notes status |
| 133 | + |
| 134 | +# Test cost tracking (uses BRAIN_COST_DB_PATH) |
| 135 | +brain cost summary |
| 136 | +``` |
| 137 | + |
| 138 | +## Troubleshooting |
| 139 | + |
| 140 | +### "DIARY_PATH must be set in .env" |
| 141 | + |
| 142 | +The `brain` command cannot find your `.env` file. The error message will show where it's looking. |
| 143 | + |
| 144 | +Create `.env` in the recommended location: |
| 145 | +```bash |
| 146 | +mkdir -p ~/.config/brain |
| 147 | +nano ~/.config/brain/.env |
| 148 | +``` |
| 149 | + |
| 150 | +### "DIARY_PATH does not exist: /path/to/dir" |
| 151 | + |
| 152 | +The directory doesn't exist. Create it: |
| 153 | +```bash |
| 154 | +mkdir -p /path/to/dir |
| 155 | +``` |
| 156 | + |
| 157 | +### "Azure OpenAI credentials required" |
| 158 | + |
| 159 | +Your Azure OpenAI credentials are missing or incorrect. Double-check: |
| 160 | +1. `AZURE_OPENAI_API_KEY` is set correctly |
| 161 | +2. `AZURE_OPENAI_ENDPOINT` ends with a `/` |
| 162 | +3. `AZURE_OPENAI_DEPLOYMENT` matches your deployment name in Azure Portal |
| 163 | + |
| 164 | +### .env File Not Loading |
| 165 | + |
| 166 | +The `brain` CLI searches for `.env` in multiple locations automatically. If it's not loading: |
| 167 | + |
| 168 | +1. **Check file exists in a searched location:** |
| 169 | + ```bash |
| 170 | + ls -la ~/.config/brain/.env # Recommended location |
| 171 | + ls -la ~/.brain/.env # Alternative location |
| 172 | + ls -la .env # Current directory |
| 173 | + ``` |
| 174 | + |
| 175 | +2. **Check file permissions (should be 600):** |
| 176 | + ```bash |
| 177 | + ls -l ~/.config/brain/.env |
| 178 | + # Should show: -rw------- (readable/writable by you only) |
| 179 | + |
| 180 | + # Fix if needed: |
| 181 | + chmod 600 ~/.config/brain/.env |
| 182 | + ``` |
| 183 | + |
| 184 | +3. **Verify file has correct format:** |
| 185 | + ```bash |
| 186 | + cat ~/.config/brain/.env | grep DIARY_PATH |
| 187 | + # Should show: DIARY_PATH=/your/path |
| 188 | + ``` |
| 189 | + |
| 190 | +## Security Best Practices |
| 191 | + |
| 192 | +### Protect Your API Keys |
| 193 | + |
| 194 | +Your `.env` file contains sensitive Azure API keys. Follow these practices: |
| 195 | + |
| 196 | +1. **File Permissions:** |
| 197 | + ```bash |
| 198 | + chmod 600 ~/.config/brain/.env # Only you can read/write |
| 199 | + ``` |
| 200 | + |
| 201 | +2. **Never Commit to Git:** |
| 202 | + ```bash |
| 203 | + # If you accidentally staged it: |
| 204 | + git rm --cached .env |
| 205 | + echo ".env" >> .gitignore |
| 206 | + ``` |
| 207 | + |
| 208 | +3. **Regular Key Rotation:** |
| 209 | + - Rotate Azure API keys periodically (every 90 days) |
| 210 | + - Update `.env` with new keys |
| 211 | + - Revoke old keys in Azure Portal |
| 212 | + |
| 213 | +4. **Config Location Safety:** |
| 214 | + - `~/.config/brain/.env` is in your home directory (safe) |
| 215 | + - Current directory `.env` takes priority (be aware in shared directories) |
| 216 | + - Only load from trusted locations (the tool only searches these 3 paths) |
| 217 | + |
| 218 | +### What the Tool Does |
| 219 | + |
| 220 | +The `brain` CLI is designed with security in mind: |
| 221 | + |
| 222 | +✅ Only searches 3 specific paths (no arbitrary file loading) |
| 223 | +✅ Validates files are regular files (not directories or special files) |
| 224 | +✅ Resolves symlinks to prevent path traversal |
| 225 | +✅ Only reads text configuration (no code execution) |
| 226 | +✅ Uses `python-dotenv` (standard, audited library) |
| 227 | + |
| 228 | +### Data Privacy |
| 229 | + |
| 230 | +All your data stays local: |
| 231 | + |
| 232 | +- **Diary/Plan entries:** Stored in paths you specify (`DIARY_PATH`, `PLANNER_PATH`) |
| 233 | +- **Cost tracking:** SQLite database in `~/.brain/costs.db` (your machine only) |
| 234 | +- **No telemetry:** Nothing is sent except Azure OpenAI API calls (for LLM features) |
| 235 | +- **No cloud sync:** You control where files are stored (use Obsidian Sync, etc. if desired) |
| 236 | + |
| 237 | +## Next Steps |
| 238 | + |
| 239 | +Once configured: |
| 240 | + |
| 241 | +1. **Morning routine:** |
| 242 | + ```bash |
| 243 | + brain plan create today |
| 244 | + ``` |
| 245 | + |
| 246 | +2. **Evening routine:** |
| 247 | + ```bash |
| 248 | + brain diary create today |
| 249 | + # Write your reflection |
| 250 | + brain diary link today # Generate backlinks |
| 251 | + ``` |
| 252 | + |
| 253 | +3. **Weekly review:** |
| 254 | + ```bash |
| 255 | + brain diary report 7 |
| 256 | + brain diary patterns 7 |
| 257 | + ``` |
| 258 | + |
| 259 | +4. **Search your notes:** |
| 260 | + ```bash |
| 261 | + brain notes search "topic" |
| 262 | + ``` |
| 263 | + |
| 264 | +5. **Track costs:** |
| 265 | + ```bash |
| 266 | + brain cost summary |
| 267 | + brain cost trends 30 |
| 268 | + ``` |
| 269 | + |
| 270 | +## Updating |
| 271 | + |
| 272 | +To update to the latest version: |
| 273 | + |
| 274 | +```bash |
| 275 | +uv tool install --force git+https://github.com/madebygps/second-brain.git |
| 276 | +``` |
| 277 | + |
| 278 | +Your `.env` configuration file is not affected by updates. |
0 commit comments