On this page
Import Claude Code session data from an external directory into the shared store.
#claudewheel.import_
#claudewheel.import_
Import Claude Code session data from an external directory into the shared store.
#ImportResult
Counters tracking the outcome of an import operation.
#_normalize_cwd
def _normalize_cwd(cwd: str) -> strNormalize a cwd for comparison.
Case-folds the drive letter (C:\ -> c:\), strips trailing / and \.
#_build_rewriters
def _build_rewriters(mappings: list[tuple[str, str]]) -> list[tuple[re.Pattern[str], str]]Compile regex patterns for JSON-level path rewriting.
Returns a list of (pattern, to_path) pairs, sorted longest from_path first so that longer prefixes match before shorter ones.
#_apply_rewrites
def _apply_rewrites(line: str, rewriters: list[tuple[re.Pattern[str], str]]) -> tuple[str, bool]Apply all path rewriters to a single line of text.
Returns (new_line, changed).
#_rewrite_jsonl
def _rewrite_jsonl(src_path: Path, dst_path: Path, rewriters: list[tuple[re.Pattern[str], str]], old_uuid: str | None, new_uuid: str | None, dry_run: bool) -> intRead a JSONL file, apply path rewrites (and optional UUID reid), write atomically.
Returns the number of lines where at least one replacement was made.
#_SessionBundle
A session's JSONL file plus its optional companion directory.
#_scan_source
def _scan_source(source: Path) -> list[_SessionBundle]Walk and collect session bundles.
#run_import
def run_import(source: str, mappings: list[tuple[str, str]], reid: bool=False, dry_run: bool=False) -> ImportResultImport session data from an external directory into the shared store.
Parameters
source: Path to the external directory (must contain a projects/ subdir). mappings: List of (from_path, to_path) pairs. to_path values are already resolved to absolute paths on the current machine. reid: If True, assign new UUIDs to sessions that collide with existing ones in the shared store. dry_run: If True, report what would happen without writing anything.
#_copy_simple_artifacts
def _copy_simple_artifacts(source_root: Path, dirname: str, old_uuid: str, effective_uuid: str, is_reided: bool, result: ImportResult, dry_run: bool) -> NoneCopy UUID-keyed artifacts from a simple directory (todos, session-env, etc.).