-
Notifications
You must be signed in to change notification settings - Fork 2
docs: Add migrate_filenames module to library reference #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ Comprehensive reference for the mnemonic Python library modules. | |||||
| - [paths](#paths) - Path resolution and filesystem layout | ||||||
| - [config](#config) - Configuration management | ||||||
| - [memory_reader](#memory_reader) - Memory file parsing | ||||||
| - [migrate_filenames](#migrate_filenames) - Memory file migration utilities | ||||||
| - [search](#search) - Memory search and ranking | ||||||
| - [relationships](#relationships) - Relationship types and linking | ||||||
| - [ontology](#ontology) - Custom ontology support | ||||||
|
|
@@ -156,6 +157,112 @@ Dictionary with keys: | |||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ### migrate_filenames | ||||||
|
|
||||||
| **File**: `lib/migrate_filenames.py` | ||||||
|
|
||||||
| Migration utilities for transitioning memory files from `{uuid}-{slug}.memory.md` to `{slug}.memory.md` naming convention. Handles collision detection, content merging, and idempotent execution. | ||||||
|
|
||||||
| **Key Functions**: | ||||||
|
|
||||||
| ````python | ||||||
| from lib.migrate_filenames import migrate_all, is_migration_complete, migrate_file | ||||||
| from pathlib import Path | ||||||
|
|
||||||
| # Check if migration already completed | ||||||
| memory_root = Path.home() / ".claude" / "mnemonic" | ||||||
| if not is_migration_complete(memory_root): | ||||||
| # Perform dry run first | ||||||
| results = migrate_all(memory_root, dry_run=True) | ||||||
| print(f"Would migrate {len(results)} files") | ||||||
|
|
||||||
| # Execute migration | ||||||
| results = migrate_all(memory_root, dry_run=False) | ||||||
| for result in results: | ||||||
| print(f"{result.action}: {result.original.name} → {result.target.name}") | ||||||
| ```` | ||||||
|
|
||||||
| **Migration Behavior**: | ||||||
| - **Rename**: `{uuid}-decision.memory.md` → `decision.memory.md` (preserves git history) | ||||||
|
||||||
| - **Rename**: `{uuid}-decision.memory.md` → `decision.memory.md` (preserves git history) | |
| - **Rename**: `{uuid}-decision.memory.md` → `decision.memory.md` (attempts to preserve git history via `git mv` when available) |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Collision handling says the provenance note includes the incoming UUID, but the implementation’s provenance note is based on the incoming frontmatter id: (and doesn’t use the filename UUID). Please update this section to reflect what is actually recorded.
| 3. Adding provenance note with incoming UUID | |
| 3. Adding provenance note with incoming frontmatter `id` |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migration_summary() is used in the bulk migration example, but it isn’t included anywhere in the API reference for migrate_filenames. Either document migration_summary(results: list[MigrationResult]) -> dict alongside the other functions or avoid using it in the example to keep the section self-contained.
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bulk migration example prints a “Skipped” count, but migrate_all() only processes UUID-prefixed files (should_migrate() filter), so results from migrate_all() will never include the "skipped" action (it’s only returned by migrate_file() when called on a non-UUID file). Consider removing/adjusting the skipped count in this example or clarifying when "skipped" can occur.
| print(f" Skipped: {summary['skipped']} files") |
Copilot
AI
Feb 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI note suggests running python -m lib.migrate_filenames --dry-run but the module’s __main__ currently hardcodes the root to Path.home() / ".claude" / "mnemonic" (and also supports --force). Consider documenting the hardcoded root and/or mentioning --force so readers understand the CLI’s limitations and available flags.
| - CLI support: `python -m lib.migrate_filenames --dry-run` | |
| - CLI support (operates on `~/.claude/mnemonic`): `python -m lib.migrate_filenames --dry-run` (add `--force` to bypass the idempotency marker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples hardcode
memory_root = Path.home() / ".claude" / "mnemonic", but this repo’s canonical way to locate the memory root islib.config.get_memory_root()(supports user-configuredmemory_store_path). Consider updating the examples to useget_memory_root()to avoid documenting a potentially incorrect path for users with custom configs.