claudewheel v0.20.1 /claudewheel.import_
Edit
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

python
def _normalize_cwd(cwd: str) -> str

Normalize a cwd for comparison.

Case-folds the drive letter (C:\ -> c:\), strips trailing / and \.

#_build_rewriters

python
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

python
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

python
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) -> int

Read 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

python
def _scan_source(source: Path) -> list[_SessionBundle]

Walk /projects/*/ and collect session bundles.

#run_import

python
def run_import(source: str, mappings: list[tuple[str, str]], reid: bool=False, dry_run: bool=False) -> ImportResult

Import 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

python
def _copy_simple_artifacts(source_root: Path, dirname: str, old_uuid: str, effective_uuid: str, is_reided: bool, result: ImportResult, dry_run: bool) -> None

Copy UUID-keyed artifacts from a simple directory (todos, session-env, etc.).