Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion memanto/cli/migrate/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
"""CLI migrate helpers β€” import memories from external providers into Memanto."""
"""
Memanto CLI - Migration package.

Provides tools for migrating memory records from external sources
(Mem0, Letta, Supermemory, OKF files) into Memanto.
"""

from memanto.cli.migrate.runner import MigrationRunner
from memanto.cli.migrate.okf_loader import OKFLoader
from memanto.cli.migrate.mappers import (
okf_record_to_memory,
mem0_record_to_memory,
letta_record_to_memory,
supermemory_record_to_memory,
)
Comment on lines +8 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ—„οΈ Data Integrity & Integration | 🟠 Major | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "=== migrate package contents ==="
fd . --type f --glob '*.py' | rg -n 'cli/migrate/' || echo "none"

echo
echo "=== callers of the provider mappers ==="
for fn in mem0_record_to_memory letta_record_to_memory supermemory_record_to_memory okf_record_to_memory; do
  echo "--- $fn ---"
  rg -nP --type=py -C3 "\b${fn}\s*\(" || echo "no call sites"
done

echo
echo "=== callers of MigrationRunner / OKFLoader ==="
rg -nP --type=py -C3 '\b(MigrationRunner|OKFLoader)\s*\(' || echo "no instantiations"

echo
echo "=== CLI command registration for migrate ==="
rg -nP --type=py -C4 '(add_parser|@(click|app|cli)\.(command|group)|typer\.Typer|argparse)' -g '**/cli/**' | rg -i -C4 'migrat' || echo "no migrate CLI wiring found"

echo
echo "=== tests referencing the migration package ==="
rg -nP --type=py -C2 'cli\.migrate|MigrationRunner|OKFLoader' -g '**/test*' -g '**/tests/**' || echo "no tests found"

echo
echo "=== examples/migrations deliverables ==="
fd . examples --type f 2>/dev/null | rg -i 'migrat' || echo "no examples/migrations content"

echo
echo "=== circular-import check: does runner/okf_loader/mappers import the package root? ==="
fd . --type f --glob '*.py' | rg 'cli/migrate/' | xargs rg -nP '^\s*(from|import)\s+memanto' || echo "no memanto imports"

Repository: moorcheh-ai/memanto

Length of output: 511


🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "=== repository root ==="
pwd
printf '\n=== top-level entries ===\n'
find . -maxdepth 2 -mindepth 1 -print | sort | head -200

printf '\n=== migration-related tracked files ===\n'
git ls-files | rg '(^|/)(memanto/cli/migrate|examples/migrations|tests?|test_)' || true

printf '\n=== migration symbols and CLI references ===\n'
rg -n -P --hidden --glob '!.git/**' \
  '\b(mem0_record_to_memory|letta_record_to_memory|supermemory_record_to_memory|okf_record_to_memory|MigrationRunner|OKFLoader|migrate)\b' . \
  || true

Repository: moorcheh-ai/memanto

Length of output: 16754


🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "=== package exports and migration implementation ==="
cat -n memanto/cli/migrate/__init__.py
sed -n '1,220p' memanto/cli/migrate/runner.py
sed -n '1,210p' memanto/cli/migrate/mappers.py
sed -n '1,130p' memanto/cli/migrate/okf_loader.py

echo
echo "=== CLI migration command ==="
sed -n '1,120p' memanto/cli/commands/migrate.py
sed -n '220,570p' memanto/cli/commands/migrate.py

echo
echo "=== migration tests ==="
sed -n '1210,1450p' tests/test_cli.py
sed -n '1,180p' tests/test_okf.py

echo
echo "=== examples and issue references ==="
find examples -maxdepth 4 -type f -print | sort | rg -i 'migrat|okf|mem0|letta|supermemory' || true
rg -n -i '1609|recall validation|migration summary|sample bundle|examples/migrations' README.md docs examples memanto tests .github || true

Repository: moorcheh-ai/memanto

Length of output: 47018


🏁 Script executed:

#!/bin/bash
set -uo pipefail

python3 - <<'PY'
import ast
from pathlib import Path

files = [
    Path("memanto/cli/migrate/__init__.py"),
    Path("memanto/cli/migrate/runner.py"),
    Path("memanto/cli/migrate/mappers.py"),
    Path("memanto/cli/migrate/okf_loader.py"),
    Path("memanto/cli/commands/migrate.py"),
    Path("memanto/cli/commands/__init__.py"),
    Path("memanto/cli/commands/_shared.py"),
    Path("tests/test_cli.py"),
    Path("tests/test_okf.py"),
]

for path in files:
    tree = ast.parse(path.read_text(), filename=str(path))
    definitions = []
    imports = []
    calls = []

    for node in ast.walk(tree):
        if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
            definitions.append((node.name, node.lineno))
        elif isinstance(node, ast.ImportFrom):
            imports.extend(
                (f"{node.module}.{alias.name}" if node.module else alias.name, node.lineno)
                for alias in node.names
            )
        elif isinstance(node, ast.Call):
            if isinstance(node.func, ast.Name):
                calls.append((node.func.id, node.lineno))
            elif isinstance(node.func, ast.Attribute):
                calls.append((node.func.attr, node.lineno))

    print(f"=== {path} ===")
    print("definitions:", definitions)
    print("imports:", imports)
    print("calls:", calls)

print("\n=== exported mapper reachability ===")
mapper_names = {
    "okf_record_to_memory",
    "mem0_record_to_memory",
    "letta_record_to_memory",
    "supermemory_record_to_memory",
}
for path in Path(".").rglob("*.py"):
    if ".git" in path.parts:
        continue
    tree = ast.parse(path.read_text(), filename=str(path))
    hits = [
        (node.lineno, node.func.id)
        for node in ast.walk(tree)
        if isinstance(node, ast.Call)
        and isinstance(node.func, ast.Name)
        and node.func.id in mapper_names
    ]
    if hits:
        print(path, hits)
PY

echo
echo "=== complete migration module contents ==="
wc -l memanto/cli/migrate/*.py
cat -n memanto/cli/migrate/runner.py
cat -n memanto/cli/migrate/mappers.py | tail -80

Repository: moorcheh-ai/memanto

Length of output: 29866


Fix the migration API wiring before merge.

memanto/cli/commands/migrate.py imports load_okf_bundle, load_export, run_migration, and write_preview, but the migration modules define none of these names. tests/test_okf.py also imports missing map_okf and load_okf_bundle symbols. This prevents the CLI and OKF tests from importing. Align the callers with the implemented APIs, or add the missing APIs. The CLI tests and memanto migrate registration already exist. The __init__ imports do not show a circular dependency. The provider mapper functions still have no direct callers. Add the required examples/migrations/ bundle and recall validation for issue #1609 if those deliverables are in scope.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@memanto/cli/migrate/__init__.py` around lines 8 - 15, The migration API
imports used by memanto/cli/commands/migrate.py and tests/test_okf.py do not
match the implemented symbols. Align those callers with the existing
MigrationRunner, OKFLoader, and mapper APIs, or add compatible load_okf_bundle,
load_export, run_migration, write_preview, and map_okf APIs; ensure the CLI and
OKF tests import successfully while preserving existing provider mappers. If
issue `#1609` deliverables are in scope, also add the examples/migrations bundle
and recall validation.


__all__ = [
"MigrationRunner",
"OKFLoader",
"okf_record_to_memory",
"mem0_record_to_memory",
"letta_record_to_memory",
"supermemory_record_to_memory",
]
Loading
Loading