lore-cli 0.1.4

Capture AI coding sessions and link them to git commits
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# Lore

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![CI](https://github.com/varalys/lore/actions/workflows/ci.yml/badge.svg)](https://github.com/varalys/lore/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/varalys/lore)](https://github.com/varalys/lore/releases)
![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20WSL2-blue)
![Windows](https://img.shields.io/badge/windows-planned-lightgrey)

Lore captures AI coding sessions and links them to git commits.

When you use AI coding tools like Claude Code or Aider, the conversation history contains valuable context. This includes everything from the prompts you wrote, the approaches you tried, and the decisions you made. Git captures the final code, but does not contain reasoning history for your commits. Lore preserves both.

**MCP Integration**: Lore includes an [MCP server](#mcp-server) that lets AI tools query your session history directly. Claude Code can search past sessions, retrieve context, and pick up where you left off.

## Table of Contents

- [Use Cases]#use-cases
- [How It Works]#how-it-works
- [Installation]#installation
- [Quick Start]#quick-start
- [Example Workflow]#example-workflow
- [MCP Server]#mcp-server
- [Search]#search
- [Blame]#blame
- [Export]#export
- [Session Awareness]#session-awareness
- [Command Reference]#command-reference
- [Supported Tools]#supported-tools
- [Background Daemon]#background-daemon
- [Git Hooks]#git-hooks
- [Output Formats]#output-formats
- [Configuration]#configuration
- [Database Management]#database-management
- [Session Deletion]#session-deletion
- [Shell Completions]#shell-completions
- [Data Location]#data-location
- [License]#license
- [Contributing]#contributing

## Use Cases

- **Code review**: See the AI conversation that produced a PR, not just the diff
- **Debugging**: Understand why code was written a certain way by reading the original discussion
- **Knowledge transfer**: When someone leaves a project, their AI conversations stay with the code
- **Learning**: Study how problems were solved by browsing linked sessions
- **Search**: Find that conversation where you solved a similar problem - search by keyword, project, tool, or date

## How It Works

Lore reads session data from AI coding tools, stores it in a local SQLite database, and creates links between sessions and git commits.

### Capture

Lore includes parsers for each [supported tool](#supported-tools). Import existing sessions with `lore import`, or run `lore daemon start` to watch for new sessions in real-time.

### Storage

Sessions and messages are stored in a SQLite database at `~/.lore/lore.db`. The schema includes:

- **sessions**: ID, tool, timestamps, working directory, message count
- **messages**: ID, session ID, role (user/assistant), content, timestamp
- **session_links**: Maps session IDs to git commit SHAs

Full-text search uses SQLite FTS5 to index message content.

### Linking

Links connect sessions to commits. You can create them:

- **Manually**: `lore link <session-id> --commit <sha>`
- **Via hooks**: `lore hooks install` adds a post-commit hook that prompts for linking

Links are bidirectional: given a session, find its commits; given a commit, find its sessions.

## Installation

### Homebrew (macOS)

```bash
brew install varalys/tap/lore
```

### From crates.io

```bash
cargo install lore-cli
```

### From Releases

Download the latest binary from [GitHub Releases](https://github.com/varalys/lore/releases) and add it to your PATH.

### From Source

```bash
git clone https://github.com/varalys/lore.git
cd lore
cargo install --path .
```

## Quick Start

```bash
# First time? Run init for guided setup
lore init

# Or just start using lore - it will prompt for setup automatically
lore sessions

# Example output - shows branch transitions during each session
# ID        STARTED           MESSAGES  BRANCH                    DIRECTORY
# c9731a91  2025-12-25 17:52       566  main -> feat/auth -> main myapp
# 24af9690  2025-12-22 19:13      1910  feat/phase-0-foundati...  lore

# View a session
lore show abc123

# Link a session to the current commit
lore link abc123

# Later, view what sessions informed a commit
lore show --commit HEAD
```

## Example Workflow

```bash
# You're reviewing a PR and want to understand a change
$ git log --oneline -1
a1b2c3d feat: add rate limiting to API

$ lore show --commit a1b2c3d
Sessions linked to commit a1b2c3d:

  Session: 7f3a2b1
  Tool: claude-code
  Duration: 45 minutes
  Messages: 23

# View the full conversation
$ lore show 7f3a2b1
```

## MCP Server

Lore includes an MCP (Model Context Protocol) server that allows AI coding tools to query your session history directly. This enables tools like Claude Code to access your past sessions and reasoning history.

### Claude Code

Add Lore as an MCP server:

```bash
claude mcp add lore -- lore mcp serve
```

Or manually edit `~/.claude/settings.json`:

```json
{
  "mcpServers": {
    "lore": {
      "command": "lore",
      "args": ["mcp", "serve"]
    }
  }
}
```

Restart Claude Code after adding the server.

### Claude Desktop

Edit `~/.claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "lore": {
      "command": "lore",
      "args": ["mcp", "serve"]
    }
  }
}
```

Restart Claude Desktop after editing the configuration.

### Available Tools

The MCP server exposes these tools to AI assistants:

| Tool | Description |
|------|-------------|
| `lore_search` | Search session messages for text content |
| `lore_get_session` | Get full details of a session by ID |
| `lore_list_sessions` | List recent sessions with optional filters |
| `lore_get_context` | Get recent session context for a repository |
| `lore_get_linked_sessions` | Get sessions linked to a git commit |

### Example Usage

Once configured, Claude Code can use Lore tools naturally:

- "Search my sessions for authentication code"
- "Show me the last session in this project"
- "What sessions are linked to the previous commit?"

The AI assistant will automatically call the appropriate Lore tools and incorporate the results into its responses.

## Search

Find any conversation across all your AI coding sessions:

```bash
# Basic search
lore search "authentication"

# Filter by tool
lore search "bug fix" --tool claude-code

# Filter by date range
lore search "refactor" --since 2025-12-01 --until 2025-12-15

# Filter by project or branch
lore search "api" --project myapp
lore search "feature" --branch main

# Combine filters
lore search "database" --tool aider --project backend --since 2025-12-01

# Show more context around matches
lore search "error handling" --context 3
```

Search matches message content, project names, branches, and tool names. Results show surrounding context so you can understand the conversation flow.

## Blame

See which AI session led to a specific line of code:

```bash
# Find the session that produced line 42 of main.rs
lore blame src/main.rs:42

# Example output:
# Line 42 of src/main.rs
#   Content: pub fn initialize_database() -> Result<Database> {
#   Commit:  a1b2c3d (2025-01-05)
#   Author:  Jane Developer
#   Message: feat: add database initialization
#
# Linked Sessions:
#   Session 7f3a2b1 (claude-code, 23 messages)
#
# Relevant Excerpts:
#   [User] Can you help me write a function to initialize the database?
#   [Assistant] I'll create an initialize_database function that...
```

This connects git blame to your AI reasoning history. For any line of code, you can trace back to the conversation that produced it.

```bash
# Output as JSON for scripting
lore blame src/lib.rs:100 --format json

# Output as markdown
lore blame src/lib.rs:100 --format markdown
```

## Export

Export sessions for sharing, archiving, or backup:

```bash
# Export as markdown (default)
lore export abc123

# Export as JSON
lore export abc123 --format json

# Write to a file
lore export abc123 -o session.md
lore export abc123 --format json -o session.json
```

### Redaction

Remove sensitive content before sharing:

```bash
# Automatic redaction of common secrets
lore export abc123 --redact

# Add custom patterns
lore export abc123 --redact --redact-pattern "internal_\w+"
```

Built-in redaction patterns:
- API keys and tokens (`sk-`, `Bearer`, `api_key=`)
- AWS credentials (`AKIA...`, `aws_secret_access_key`)
- GitHub tokens (`ghp_`, `gho_`, `ghu_`, `ghs_`, `ghr_`)
- Email addresses
- IPv4 addresses
- Private keys (RSA, DSA, EC headers)
- Connection strings (mysql://, postgres://, mongodb://, redis://)

Redacted content is replaced with `[REDACTED]`.

## Session Awareness

Lore helps you pick up where you left off and organize your sessions:

```bash
# See what session is active in the current directory
lore current

# Get quick context on recent sessions in this repo
lore context

# Get detailed summary of the last session (for "continue where we left off")
lore context --last

# Add a bookmark or note to the current session
lore annotate "Implemented auth, need to add tests"

# Tag sessions for organization
lore tag abc123 needs-review
lore tag abc123 feature-auth
lore sessions --tag needs-review    # Filter by tag

# Add a summary to a session for future reference
lore summarize abc123 "Added OAuth2 login flow with Google and GitHub providers"
lore summarize abc123 --show        # View existing summary
```

Tags, annotations, and summaries appear in `lore show` output and help you quickly understand past sessions.

## Command Reference

Essential commands to get started:

```bash
lore init             # First-run setup (auto-detects AI tools)
lore import           # Import sessions from enabled tools
lore sessions         # List recent sessions
lore show <id>        # View session details
lore search <query>   # Full-text search
lore blame <file:ln>  # Find session that produced a line of code
lore export <id>      # Export session for sharing
lore context --last   # Quick summary of last session
lore daemon start     # Start real-time capture
```

Run `lore --help` for the full command list, or `lore <command> --help` for details on any command.

## Supported Tools

Lore targets Linux, macOS, and WSL2. Windows native support is planned for a
future release. For WSL2, CLI-based tools work as long as the sessions live in
the Linux filesystem. VS Code extension sessions are only discovered when the
extensions run in WSL (Remote - WSL); if you run VS Code natively on Windows,
those sessions live under `%APPDATA%` and are not detected today.

| Tool | Format | Storage Location |
|------|--------|------------------|
| Claude Code | JSONL | `~/.claude/projects/` |
| Codex CLI | JSONL | `~/.codex/sessions/` |
| Gemini CLI | JSON | `~/.gemini/tmp/*/chats/` |
| Amp | JSON | `~/.local/share/amp/threads/` |
| Aider | Markdown | `.aider.chat.history.md` |
| Continue.dev | JSON | `~/.continue/sessions/` |
| Cline | JSON | VS Code extension storage |
| Roo Code | JSON | VS Code extension storage |
| Kilo Code | JSON | VS Code extension storage |
| OpenCode | JSON | `~/.local/share/opencode/storage/` |

**Building an AI coding tool?** We welcome contributions to support additional tools. Open an issue with your tool's session storage location and format, or submit a PR adding a watcher. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.

## Background Daemon

The daemon watches for new sessions in real-time and imports them automatically.

### Manual Start

```bash
lore daemon start    # Start watching
lore daemon status   # Check what's being watched
lore daemon logs     # View daemon logs
lore daemon stop     # Stop watching
```

### Run as a Service

Install the daemon as a system service to start automatically on login.

#### macOS with Homebrew (Recommended)

If you installed via Homebrew, use brew services:

```bash
brew services start lore
brew services stop lore
```

#### Linux with systemd

Use the built-in service installer:

```bash
lore daemon install    # Install and enable systemd service
lore daemon uninstall  # Remove systemd service
```

The service restarts automatically on failure.

#### Manual systemd Setup (Linux)

If you prefer to configure systemd yourself:

```bash
mkdir -p ~/.config/systemd/user
```

Create `~/.config/systemd/user/lore.service`:

```ini
[Unit]
Description=Lore AI session capture daemon
After=default.target

[Service]
Type=simple
ExecStart=%h/.cargo/bin/lore daemon start --foreground
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target
```

Then enable and start:

```bash
systemctl --user daemon-reload
systemctl --user enable --now lore.service
systemctl --user status lore.service
```

## Git Hooks

Install hooks to automatically record session links on commit:

```bash
lore hooks install   # Install post-commit hook
lore hooks status    # Check hook status
lore hooks uninstall # Remove hooks
```

## Output Formats

Commands support `--format` for scripting and integration:

```bash
lore sessions --format json
lore show abc123 --format json
lore show abc123 --format markdown
lore status --format json
```

## Configuration

On first run, Lore prompts for setup automatically. You can also run `lore init` manually.

The init wizard:
1. Detects installed AI coding tools
2. Shows which tools have existing sessions
3. Lets you choose which watchers to enable
4. Offers to import existing sessions
5. Offers to install shell completions
6. Offers to start the background service (for real-time capture)

Configure which tools to track:

```bash
lore config set watchers claude-code,aider,gemini
lore config get watchers
```

For scripting, use `--no-init` to skip the first-run prompt:

```bash
lore --no-init sessions --format json
```

## Database Management

Lore provides commands for managing the database:

```bash
# View database statistics
lore db stats

# Example output:
# Database Statistics
#
#   Sessions:  142
#   Messages:  8934
#   Links:     67
#   File size: 12.45 MB
#
# Date Range
#   Oldest:   2024-06-15 09:23
#   Newest:   2025-01-02 14:56
#
# Sessions by Tool
#    claude-code:  98
#          aider:  31
#         gemini:  13

# Reclaim unused disk space
lore db vacuum

# Delete old sessions (preview first with --dry-run)
lore db prune --older-than 90d --dry-run
lore db prune --older-than 6m --force
```

Duration formats for `--older-than`:
- `Nd` - days (e.g., `90d`)
- `Nw` - weeks (e.g., `12w`)
- `Nm` - months (e.g., `6m`)
- `Ny` - years (e.g., `1y`)

## Session Deletion

Delete a single session and all its data:

```bash
lore delete abc123
```

This permanently removes the session, its messages, and any commit links.

## Shell Completions

The easiest way to install completions is to let Lore auto-detect your shell:

```bash
lore completions install
```

Or specify a shell explicitly:

```bash
lore completions install --shell fish
```

You can also output completions to stdout for manual installation:

```bash
lore completions bash > ~/.local/share/bash-completion/completions/lore
lore completions zsh > ~/.zfunc/_lore
lore completions fish > ~/.config/fish/completions/lore.fish
```

After installing, restart your shell or source the completion file.

PowerShell and Elvish completions are also available (`lore completions powershell`, `lore completions elvish`) and will be documented when Windows support is added.

## Data Location

```
~/.lore/
├── lore.db       # SQLite database
├── config.yaml   # Configuration
└── logs/         # Daemon logs
```

All data stays on your machine. There is no cloud sync or external service.

## License

Apache 2.0

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).