| phase | design |
|---|---|
| title | System Design & Architecture |
| description | Resolve memory database path from project config with default fallback |
graph TD
ProjectConfig[./.ai-devkit.json] --> ConfigManager
ConfigManager --> Resolver[CLI memory path resolver]
CLI[ai-devkit memory *] --> Resolver
Resolver --> MemoryAPI[@ai-devkit/memory API]
DefaultPath[~/.ai-devkit/memory.db] --> MemoryAPI
MemoryAPI --> DatabasePath[Effective DB path]
DatabasePath --> SQLite[(SQLite memory.db)]
- Keep
DEFAULT_DB_PATHas the baseline fallback in the memory package. - Add a CLI-owned resolver that can return a project override from
.ai-devkit.json. - Pass the resolved path from the CLI into
@ai-devkit/memorybefore opening SQLite. - Leave the standalone
@ai-devkit/memoryMCP server unchanged so it continues usingDEFAULT_DB_PATH.
- Extend
DevKitConfigwith an optional memory section:interface DevKitConfig { memory?: { path?: string; }; }
- Extend CLI-to-memory command options with optional
dbPath?: string. - Resolver output is either:
- an absolute filesystem path derived from
memory.path undefined, which means the memory package falls back toDEFAULT_DB_PATH
- an absolute filesystem path derived from
- Add
ConfigManager.getMemoryDbPath(): Promise<string | undefined>to read project config safely. - Resolve
memory.pathinside the CLI command layer, not insidepackages/memory. - Add optional
dbPathsupport to the memory package command APIs used by the CLI:memoryStoreCommand(options)memorySearchCommand(options)memoryUpdateCommand(options)
- Keep
packages/memory/src/server.tsand theai-devkit-memorybinary unchanged in this feature.
packages/cli/src/types.ts- Add optional
memory.pathtyping to project config.
- Add optional
packages/cli/src/lib/Config.ts- Parse and validate
memory.pathfrom project config. - Resolve relative paths against the config file directory.
- Parse and validate
packages/cli/src/commands/memory.ts- Load the project config once per command invocation.
- Pass resolved
dbPathinto the imported memory command API.
packages/memory/src/database/connection.ts- Continue exposing
DEFAULT_DB_PATH. - Accept explicit
dbPathfrom callers without changing fallback semantics.
- Continue exposing
packages/memory/src/api.ts- Accept optional
dbPathon CLI-facing command option types. - Call
getDatabase({ dbPath })so the explicit path only affects CLI-triggered operations that pass it.
- Accept optional
- Tests
- Config parsing tests in CLI package.
- Memory command resolution tests in CLI and memory package.
- No standalone MCP server behavior change tests are needed beyond regression confidence.
- Keep fallback logic in the memory package and config parsing in the CLI package to preserve clear responsibilities.
- Resolve relative paths from the project root so checked-in config behaves consistently across shells and CI.
- Treat missing, blank, or non-string
memory.pathas unset and fall back silently toDEFAULT_DB_PATHto preserve backward compatibility. - Keep the package boundary intact by passing
dbPathexplicitly from the CLI rather than makingpackages/memorydepend onConfigManager. - Apply the configured path to
store,search, andupdateso CLI memory subcommands stay consistent.
- No change to default behavior for projects without
memory.path. - No additional network or external service dependency.
- Path resolution must be deterministic across macOS and Linux path semantics already supported by Node's
pathmodule. - Database initialization and schema migration behavior remain unchanged once the final path is selected.
- Standalone
@ai-devkit/memoryserver startup and runtime behavior remain unchanged in this feature.