Architecture Overview

A comprehensive breakdown of how the Lore CLI is structured internally across its five core layers.

The Directory Structure

The lore-memory codebase is split into five main conceptual areas inside the src/ directory, designed around the Unix philosophy: do one thing well, be highly modular, and enable standard piping.

Lore/
├── bin/
│   └── lore.js          # The CLI entry point and interactive menu
├── src/
│   ├── commands/        # CLI wrappers for every command (e.g. `lore log`, `lore why`)
│   ├── lib/             # The core "engine" (file parsing, AI embeddings, scoring)
│   ├── watcher/         # The passive automation engine (AST parsing, graph building)
│   ├── mcp/             # The Model Context Protocol integration for Claude/Cursor
│   └── ui/              # The local web dashboard frontend
└── package.json

1. The Entry Point (bin/)

This acts as the front door for the application.

2. The Core Engine (src/lib/)

This directory is the absolute backbone of Lore, containing the business logic for reading, writing, and scoring knowledge entries.

3. The Commands (src/commands/)

These files act as thin wrappers. They parse user input from the CLI, format the output with chalk, and pass the real work down into src/lib/.

4. The Passive Engine (src/watcher/)

This directory is what enables Lore's automated "magical" feeling.

5. The MCP Server (src/mcp/)

Allows Lore to talk directly to AI coding assistants using the Model Context Protocol.