Skip to content

Commit 292c5fc

Browse files
committed
Add full docs (diary, planning, cost tracking, entry format, philosophy) and refresh README
- Add comprehensive guides: docs/DIARY.md, docs/PLANNING.md, docs/COST_TRACKING.md, docs/ENTRY_FORMAT.md, docs/PHILOSOPHY.md - Revise README to focus on journaling workflow, clarify Ollama vs Azure support, and streamline Quick Start/Usage sections - Document logging behavior: file logs with rotation (10MB, 5 backups) and always-capture DEBUG to file; mention BRAIN_LOG_FILE and cost DB - Simplify development/setup instructions and update examples for configuration and testing
1 parent d242b02 commit 292c5fc

File tree

6 files changed

+1763
-186
lines changed

6 files changed

+1763
-186
lines changed

README.md

Lines changed: 90 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Tests](https://github.com/madebygps/second-brain/actions/workflows/test.yml/badge.svg)](https://github.com/madebygps/second-brain/actions/workflows/test.yml)
44

5-
AI-powered personal knowledge system with daily planning, reflective journaling, and semantic backlinks.
5+
AI-powered journaling with semantic backlinks. Extracts actionable tasks from reflections. Works with Azure OpenAI or local Ollama.
66

77
## Installation
88

@@ -44,242 +44,146 @@ uv run brain --help
4444

4545
## Features
4646

47-
**Planning** (`brain plan`)
48-
- LLM extracts actionable tasks from yesterday's diary
49-
- Auto-carries forward unchecked todos from yesterday's plan
50-
- Saves to `PLANNER_PATH` with backlinks to source entries
47+
- **Morning planning** - LLM extracts tasks from yesterday's diary + carries forward uncompleted todos
48+
- **Evening reflection** - AI prompts based on your past 3 days
49+
- **Semantic backlinks** - LLM finds thematic connections (not keyword matching)
50+
- **Emotional patterns** - Tracks psychological themes over time
51+
- **Local or cloud** - Works with Ollama (free, private) or Azure OpenAI
52+
- **Obsidian-compatible** - Plain markdown with wiki-style links
5153

52-
**Diary** (`brain diary`)
53-
- Evening reflection with AI-generated prompts from past 3 days
54-
- Semantic backlinks via LLM analysis (not keyword matching)
55-
- Automatic topic tags and temporal connections
56-
- Obsidian-compatible markdown format
57-
58-
**Cost Tracking** (`brain cost`)
59-
- Real-time Azure OpenAI usage tracking in local SQLite database
60-
- Comprehensive metadata: temperature, max_tokens, prompt/response lengths
61-
- Summaries, trends, projections, and per-operation breakdowns
54+
**Documentation:**
55+
- [PHILOSOPHY.md](docs/PHILOSOPHY.md) - Design principles
56+
- [PLANNING.md](docs/PLANNING.md) - Planning guide
57+
- [DIARY.md](docs/DIARY.md) - Diary guide
58+
- [COST_TRACKING.md](docs/COST_TRACKING.md) - Cost tracking guide
6259

6360
## Quick Start
6461

65-
### First-Time Setup
66-
67-
1. **Install** (see [Installation](#installation) above)
68-
69-
2. **Configure** - Create `~/.config/brain/.env` with your settings:
70-
7162
```bash
63+
# 1. Install
64+
uv tool install git+https://github.com/madebygps/second-brain.git
65+
66+
# 2. Configure
7267
mkdir -p ~/.config/brain
7368
curl -o ~/.config/brain/.env https://raw.githubusercontent.com/madebygps/second-brain/main/.env.example
74-
nano ~/.config/brain/.env # Edit with your paths and Azure credentials
69+
nano ~/.config/brain/.env # Edit with your paths and LLM provider
70+
71+
# 3. Use
72+
brain plan create today # Morning: actionable tasks
73+
brain diary create today # Evening: reflection
74+
brain diary link today # Add semantic backlinks
7575
```
7676

77-
See [SETUP_CHECKLIST.md](SETUP_CHECKLIST.md) for detailed setup instructions.
77+
See [SETUP_CHECKLIST.md](SETUP_CHECKLIST.md) for detailed configuration.
7878

79-
3. **Use**:
79+
## Usage
8080

81+
**Daily workflow:**
8182
```bash
82-
# Morning: Create your planning entry (saves to PLANNER_PATH)
83-
brain plan create today
84-
85-
# Evening: Create your reflection entry (saves to DIARY_PATH)
86-
brain diary create today
83+
brain plan create today # Morning planning
84+
brain diary create today # Evening reflection
85+
brain diary link today # Add semantic backlinks
8786
```
8887

89-
> **Note:** The `.env` file is automatically searched in `~/.config/brain/.env`, `~/.brain/.env`, or current directory.
90-
>
91-
> **For developers:** When running locally, prefix commands with `uv run` (e.g., `uv run brain plan create today`)
92-
93-
## Usage
94-
88+
**Analysis:**
9589
```bash
96-
# Planning
97-
brain plan create today # Create daily plan with LLM task extraction
98-
brain plan create tomorrow # Plan for tomorrow
99-
100-
# Diary management
101-
brain diary create today # Create reflection entry
102-
brain diary link today # Generate semantic backlinks
103-
brain diary refresh 30 # Bulk refresh past 30 days
104-
brain diary list 7 # List recent entries
105-
106-
# Analysis
107-
brain diary report 30 # Memory trace report (activities & connections)
108-
brain diary patterns 7 # Emotional & psychological patterns
109-
110-
# Cost tracking and analysis
111-
brain cost summary # Usage summary for last 30 days
112-
brain cost trends 30 # Daily cost trends
113-
brain cost estimate # Monthly cost projection
114-
brain cost breakdown # Per-operation breakdown
115-
brain cost export data.json # Export to JSON
116-
brain cost pricing # Show pricing
117-
118-
# Logging (Rich-formatted, colored output)
119-
brain --verbose <command> # Show key operations
120-
brain --debug <command> # Full diagnostics with LLM details
90+
brain diary report 7 # Memory trace for past week
91+
brain diary patterns 7 # Emotional/psychological themes
92+
brain diary list # List all entries
12193
```
12294

123-
> **Console Logs:** By default, logs are suppressed during operations to avoid interrupting spinners. Use `--verbose` or `--debug` for detailed information with beautiful Rich formatting.
95+
**Cost tracking** (Azure OpenAI only):
96+
```bash
97+
brain cost summary # Usage stats
98+
brain cost trends 30 # Daily costs
99+
brain cost breakdown # Per-operation costs
100+
```
124101

125-
> **File Logs:** Optional. Set `BRAIN_LOG_FILE` in `.env` to enable persistent logging with automatic rotation (max 10MB per file, 5 backups). File logs always capture full DEBUG details regardless of console log level.
102+
**Debugging:**
103+
```bash
104+
brain --verbose <command> # Show key operations
105+
brain --debug <command> # Full diagnostics
106+
```
126107

127-
> **Cost Tracking:** All Azure OpenAI usage is automatically tracked in a local SQLite database (`~/.brain/costs.db`). Data stays private and grows ~10-50 MB/year for typical use.
108+
Run `brain --help` for all commands.
128109

129110
## Configuration
130111

131-
The `brain` CLI automatically searches for `.env` in these locations (in priority order):
132-
1. Current directory (`./.env`)
133-
2. User config directory (`~/.config/brain/.env`) ⭐ **Recommended**
134-
3. Home directory (`~/.brain/.env`)
135-
136-
Create `~/.config/brain/.env` with these settings:
137-
138-
**Required Paths:**
139-
- `DIARY_PATH` - Path to Obsidian vault or markdown directory for reflection entries
140-
- `PLANNER_PATH` - Path to directory for daily plan files (separate from diary)
141-
142-
**LLM Provider** (choose one):
143-
- `LLM_PROVIDER` - Set to `azure` or `ollama` (default: `azure`)
144-
145-
**Option 1: Azure OpenAI** (cloud-based, requires API key):
146-
- `AZURE_OPENAI_API_KEY` - Your Azure OpenAI API key
147-
- `AZURE_OPENAI_ENDPOINT` - Your Azure OpenAI endpoint
148-
- `AZURE_OPENAI_DEPLOYMENT` - Deployment name (default: `gpt-4o`)
149-
- `AZURE_OPENAI_API_VERSION` - API version (default: `2024-02-15-preview`)
150-
151-
**Option 2: Ollama** (local, free, private):
152-
- `OLLAMA_BASE_URL` - Ollama API URL (default: `http://localhost:11434`)
153-
- `OLLAMA_MODEL` - Model name (default: `llama3.1`)
154-
- First install Ollama from https://ollama.com
155-
- Then pull a model: `ollama pull llama3.1`
156-
157-
> **Switching Providers:** Just change `LLM_PROVIDER` in your `.env` file and restart. No code changes needed!
158-
>
159-
> **Privacy:** Ollama runs completely locally. Your journal entries never leave your machine.
160-
161-
**Logging & Cost Tracking** (optional configuration):
162-
- `BRAIN_COST_DB_PATH` - Path to cost tracking database (default: ~/.brain/costs.db)
163-
- `BRAIN_LOG_LEVEL` - Logging level: DEBUG, INFO, WARNING, ERROR (default: INFO)
164-
- `BRAIN_LOG_FILE` - Path to log file with automatic rotation (optional, logs to console if not set)
165-
- When enabled: captures all DEBUG logs to file regardless of console log level
166-
- Automatic rotation: max 10MB per file, keeps 5 backups (~50MB total)
167-
- Example: `BRAIN_LOG_FILE=~/.brain/logs/brain.log`
168-
169-
**Custom Pricing** (optional - override Azure OpenAI pricing):
170-
- `AZURE_GPT4O_INPUT_PRICE` - Price per 1K input tokens for gpt-4o (default: 0.03)
171-
- `AZURE_GPT4O_OUTPUT_PRICE` - Price per 1K output tokens for gpt-4o (default: 0.06)
172-
- `AZURE_GPT4O_MINI_INPUT_PRICE` - Price per 1K input tokens for gpt-4o-mini (default: 0.0015)
173-
- `AZURE_GPT4O_MINI_OUTPUT_PRICE` - Price per 1K output tokens for gpt-4o-mini (default: 0.006)
174-
- `AZURE_GPT4_INPUT_PRICE` - Price per 1K input tokens for gpt-4 (default: 0.03)
175-
- `AZURE_GPT4_OUTPUT_PRICE` - Price per 1K output tokens for gpt-4 (default: 0.06)
176-
- `AZURE_GPT35_TURBO_INPUT_PRICE` - Price per 1K input tokens for gpt-35-turbo (default: 0.0015)
177-
- `AZURE_GPT35_TURBO_OUTPUT_PRICE` - Price per 1K output tokens for gpt-35-turbo (default: 0.002)
112+
**Required:**
113+
```bash
114+
DIARY_PATH=/path/to/diary # Reflection entries
115+
PLANNER_PATH=/path/to/planner # Daily plans (separate)
116+
LLM_PROVIDER=ollama # or "azure"
117+
```
178118

179-
## Entry Format
119+
**Ollama** (local, free, private):
120+
```bash
121+
OLLAMA_BASE_URL=http://localhost:11434
122+
OLLAMA_MODEL=llama3.1
123+
```
180124

181-
**Morning Plan Entry** (`YYYY-MM-DD-plan.md`):
125+
**Azure OpenAI** (cloud):
126+
```bash
127+
AZURE_OPENAI_API_KEY=your-key
128+
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
129+
AZURE_OPENAI_DEPLOYMENT=gpt-4o
130+
```
182131

183-
Saved to `PLANNER_PATH`. Created with `brain plan create`, which intelligently:
184-
- Extracts actionable tasks from yesterday's diary using LLM
185-
- Carries forward unchecked todos from yesterday's plan
186-
- Adds backlinks to source entries
132+
See [SETUP_CHECKLIST.md](SETUP_CHECKLIST.md) for full configuration options.
187133

134+
## Entry Format
135+
136+
**Morning Plan** (`YYYY-MM-DD-plan.md` in `PLANNER_PATH`):
188137
```markdown
189138
## Action Items
190-
- [ ] Follow up with team about project (from [[2025-01-14]])
191-
- [ ] Review pull requests (from [[2025-01-14]])
192-
- [ ] Uncompleted task from yesterday (from [[2025-01-14]])
139+
- [ ] Task from yesterday's diary (from [[2025-10-14]])
140+
- [ ] Unchecked task from yesterday's plan (from [[2025-10-13-plan]])
193141
```
194142

195-
**Evening Reflection Entry** (`YYYY-MM-DD.md`):
196-
197-
Saved to `DIARY_PATH`. Created with `brain diary create`:
198-
143+
**Evening Reflection** (`YYYY-MM-DD.md` in `DIARY_PATH`):
199144
```markdown
200145
## Reflection Prompts
201-
**1. Based on [[2025-01-14]], how did X work out?**
146+
**1. AI-generated prompt based on past 3 days**
202147

203148
---
204149

205150
## Brain Dump
206-
Your reflections...
207-
```
208-
209-
After writing, run `brain diary link today` to add semantic backlinks:
151+
Your free-form reflection...
210152

211-
```markdown
212153
---
213154

214155
## Memory Links
215-
**Temporal:** [[2025-01-14]] • [[2025-01-13]]
216-
**Topics:** #focus #energy
156+
[Generated by: brain diary link today]
157+
**Temporal:** [[2025-10-14]] • [[2025-10-13]]
158+
**Topics:** #self-doubt #growth #perfectionism
217159
```
218160

161+
See [ENTRY_FORMAT.md](docs/ENTRY_FORMAT.md) for quick reference.
162+
219163
## Requirements
220164

221165
- Python 3.13+
222-
- uv package manager (ALWAYS use `uv`, never `pip`)
223-
- **LLM Provider** (choose one):
224-
- **Azure OpenAI** - Cloud-based, requires API key and subscription
225-
- **Ollama** - Local, free, completely private (requires installation from https://ollama.com)
226-
- All LLM features supported with either provider:
227-
- Diary prompt generation
228-
- Task extraction from diary entries
229-
- Semantic backlinks and tags
230-
- Analysis reports and patterns
166+
- uv package manager
167+
- LLM Provider (choose one):
168+
- **Ollama** - Local, free, private ([install](https://ollama.com))
169+
- **Azure OpenAI** - Cloud, requires API key
231170

232171
## Development
233172

234-
### Testing
235-
236-
Minimal test suite focused on preventing data loss:
237-
238173
```bash
239-
uv run pytest # Run all tests
240-
uv run pytest --cov # Run with coverage
241-
```
242-
243-
**Coverage**: 7 essential tests covering:
244-
- Configuration validation (missing paths)
245-
- File naming (reflection vs. plan entries)
246-
- Write/read cycles (prevent data loss)
247-
- Path separation (diary vs. planner)
248-
249-
### Code Quality
250-
251-
Pre-commit hooks automatically run before each commit:
252-
253-
```bash
254-
# Install hooks (one-time setup)
255-
uv run pre-commit install
256-
257-
# Run manually on all files
258-
uv run pre-commit run --all-files
174+
git clone https://github.com/madebygps/second-brain.git
175+
cd second-brain
176+
uv sync # Install dependencies
177+
uv run pre-commit install # Setup hooks
178+
cp .env.example .env # Configure
179+
uv run brain --help # Test
180+
181+
# Testing
182+
uv run pytest # Run tests
183+
uv run pytest --cov # With coverage
259184
```
260185

261-
**Hooks include:**
262-
- `ruff` - Fast Python linter with auto-fix
263-
- `ruff-format` - Auto-format Python code
264-
- `pytest` - Run test suite (prevents data loss bugs)
265-
- File checks (trailing whitespace, file endings, large files)
266-
267-
**[pre-commit.ci](https://pre-commit.ci) integration:**
268-
- ✅ Automatically fixes PRs (formatting, imports, etc.)
269-
- ✅ Weekly dependency updates
270-
- ✅ Zero configuration needed
271-
272-
### CI/CD
273-
274-
**GitHub Actions** runs on push/PR:
275-
- ✅ Tests with coverage reporting
276-
- ✅ Test count validation (ensures 7 tests)
277-
- ✅ Python 3.13 compatibility check
278-
279-
**[pre-commit.ci](https://pre-commit.ci)** runs on PRs:
280-
- ✅ Auto-fixes formatting and linting issues
281-
- ✅ Weekly dependency updates (automated PRs)
282-
- ✅ Faster than GitHub Actions for simple checks
186+
See [PHILOSOPHY.md](docs/PHILOSOPHY.md) for architecture and design decisions.
283187

284188
## License
285189

0 commit comments

Comments
 (0)