feat(store): hierarchical database path resolution with per-project support#257
Open
Acharnite wants to merge 3 commits into
Open
feat(store): hierarchical database path resolution with per-project support#257Acharnite wants to merge 3 commits into
Acharnite wants to merge 3 commits into
Conversation
Add 6-level database path resolution chain that eliminates the need for wrapper scripts or hardcoded paths: 1. --db CLI flag (highest priority) 2. ICM_DB environment variable (new) 3. Global config [store].path (was parsed but unused — now wired up) 4. Project-local .icm/config.toml [store].path (auto-detected via git root) 5. Project-local .icm/memories.db (auto-detected via git root, if file exists) 6. Default platform data directory (unchanged fallback) Also adds: - detect_project_root() helper using git rev-parse --show-toplevel - icm init --per-project now creates .icm/config.toml with project-local DB - icm config shows full resolution chain with source tracing - Updated config/default.toml to document resolution order
Change icm init --per-project to write [store] path = ".icm/memories.db" instead of "memories.db", so the database lives inside .icm/ alongside config.toml. Update README with --per-project docs.
Add comprehensive docs for the 6-level database path resolution chain: - resolve_db_path() algorithm and priority flow - detect_project_root() and git-aware auto-detection - Per-project .icm/ setup - icm config display with source tracing Also update the user guide with per-project setup instructions and add noise-tool filtering to the opencode plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the simple
--db-or-default path logic with a 6-level hierarchical database path resolution chain. This eliminates the need for wrapper scripts or hardcoded paths when working across multiple projects.Resolution chain (highest priority first)
--dbCLI flagicm --db /tmp/test.db store ...ICM_DBenv varICM_DB=/tmp/icm.db icm recall ...[store].path~/.config/icm/config.toml.icm/config.toml[store].path.icm/memories.db~/.local/share/icm/memories.dbKey changes
crates/icm-cli/src/main.rs(+165/−19):resolve_db_path(cli_db, cfg) → PathBufwith the 6-level chaindetect_project_root() → Option<PathBuf>usinggit rev-parse --show-toplevelicm init --per-projectnow creates.icm/config.tomlwith[store] path = "memories.db"icm configshows the full resolution chain with source tracing (resolved path, config path, env var, project root, .icm/ state)open_store()simplified fromopen_store(db: Option<PathBuf>)toopen_store(db: PathBuf)— resolution happens before the store is openedconfig/default.toml(+11):icm init --per-projectcreates project-local configOpenCode plugin improvements (
plugins/opencode-icm.ts, +17/−10)NOISE_TOOLSset to skip extraction for Edit/Write/Question/todowrite calls (reduces noise)EXTRACT_EVERYfrom 3 to 10 (reduces extraction frequency)cwdparameter to all ICM subprocess calls so the plugin respects per-project databasesrecall-projectto use named flags (--project,--limit) instead of positional argsDocumentation
docs/architecture.md: NewDatabase Path Resolutionsection with the full algorithm, priority flow diagram, andicm configoutput exampledocs/guide.md: Per-project setup instructions and resolution priority tableREADME.md: Already updated with--per-projectsetup,ICM_DBenv var mention, and per-project storage sectionBackward compatibility
Fully backward compatible. The existing
--dbflag still works at the same priority. The default platform path (level 6) is unchanged. Existing setups see no behavioral difference.Closes the gap where users had to set
--dbon every invocation or write wrapper scripts to use per-project databases.