Memory integration
Leyline bundles the memory extension from .pi/extensions/memory/index.ts. The runtime loads it through resourceLoaderOptions.additionalExtensionPaths.
The extension stores durable Markdown memory. The Memory Inspector uses server routes in server/pi-api/memories.js to read and change the same records.
Storage and scope
The default database is:
~/.local/share/leyline/memory.sqliteThe memories table uses three scopes:
globalrecords are visible in all projects and sessions.projectrecords are visible under one project root.sessionrecords are visible only for one session file.
Leyline finds the nearest parent directory that contains .git. If it finds no Git root, it uses the current working directory. It derives project and session IDs from SHA-256 hashes of canonical paths.
Other modules use the same database for backend_connections, leyline_settings, subagent_overrides, vision_overrides, and rollout_feedback. Tables appear when their owning modules initialize storage.
Display preferences and saved connections use the native app backend's database. Memory, file-editor settings, feedback, and agent overrides use the selected backend's database. A global memory or override applies to that backend, not every saved connection.
Agent defaults, Project settings, and Session details edit global, project, and session subagent/vision overrides. These controls share AgentSettings.vue. They are no longer separate Subagents or Vision drawers. The Memory Inspector remains a separate surface.
Pi provider/model overrides in models.json are different from Leyline's subagent and vision overrides. Pi owns global provider, MCP, and credential files outside SQLite. See Pi configuration storage.
Rollout labels can be helpful or unhelpful, with an optional note. Leyline adds this feedback to transcript entries when it builds session detail. See SQLite metadata for table ownership.
Runtime context
At session start, the extension loads active memory into three caches. Before each agent turn, it adds a bounded memory block to the system prompt.
The current limits are:
- 8 global records
- 12 project records
- 16 session records
- 16 KiB for the complete injected block
New and changed records affect future turns. They do not change context that the model already received.
Memory has lower priority than system and developer instructions, the current request, project instructions, and verified repository data.
Agent tools and command
The extension registers these tools:
list_memorylists visible active or archived records.search_memorysearches visible content, reasons, and tags.record_memorycreates a record.update_memoryreplaces the content, reason, and tags of a visible record.archive_memoryarchives visible records without deleting them.
The /memory command shows the database and context. /memory list lists active records. /memory search <query> searches active records.
The browser API also supports create, edit, archive, restore, and permanent delete operations. See the API reference.
Path override
Set LEYLINE_MEMORY_DIR before the backend starts to use a different data directory. Connections, display/file settings, memory, subagent/vision overrides, and feedback then use memory.sqlite there. This variable does not relocate pi configuration or credentials.