Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sessiontrove ~/Backups/agent-sessions --machine macbookpro-m4
| --- | --- |
| Claude Code | Project transcripts and `history.jsonl` under `$CLAUDE_CONFIG_DIR` or `~/.claude` |
| Codex | `~/.codex/sessions`, `~/.codex/archived_sessions`, and `~/.codex/history.jsonl` |
| Oh My Pi (OMP) | `sessions` under `$PI_CODING_AGENT_DIR` or `~/.omp/agent` |
| OpenClaw | Every agent's `sessions` directory under `$OPENCLAW_STATE_DIR/agents` or `~/.openclaw/agents` |
| Pi | `~/.pi/agent/sessions` |

Expand Down
9 changes: 9 additions & 0 deletions src/sessiontrove/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def default_sources(
home = (home or Path.home()).expanduser()
environ = os.environ if environ is None else environ
claude_home = Path(environ.get("CLAUDE_CONFIG_DIR", home / ".claude")).expanduser()
omp_override = environ.get("PI_CODING_AGENT_DIR", "").strip()
omp_home = Path(omp_override or home / ".omp/agent").expanduser()
openclaw_override = environ.get("OPENCLAW_STATE_DIR", "").strip()
openclaw_home = Path(openclaw_override or home / ".openclaw").expanduser()
openclaw_agents = openclaw_home / "agents"
Expand Down Expand Up @@ -85,6 +87,13 @@ def default_sources(
Path("sessions"),
("*.jsonl",),
),
Source(
"omp",
omp_home / "sessions",
Path("sessions"),
("*",),
("*.lock", "*.tmp"),
),
*openclaw_sources,
)

Expand Down
31 changes: 31 additions & 0 deletions tests/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def test_source_registry_covers_each_persistent_conversation_store(
Path("sessions"),
("*.jsonl",),
),
Source(
"omp",
home / ".omp/agent/sessions",
Path("sessions"),
("*",),
("*.lock", "*.tmp"),
),
)


Expand All @@ -84,13 +91,21 @@ def test_archives_complete_agent_layouts_without_unrelated_state(
write(home / ".pi/agent/sessions/project/session.jsonl")
write(home / ".pi/agent/settings.json", "not a conversation")

write(home / ".omp/agent/sessions/project/session.jsonl")
write(home / ".omp/agent/sessions/project/session/worker.jsonl")
write(home / ".omp/agent/sessions/project/session/worker.md")
write(home / ".omp/agent/sessions/project/session/1.bash.log")
write(home / ".omp/agent/sessions/project/session.jsonl.lock", "ephemeral")
write(home / ".omp/agent/history.db", "not a conversation")

destination = tmp_path / "archive"
results = archive(destination, MACHINE, default_sources(home, {}))

assert results == {
"claude-code": 4,
"codex": 3,
"pi": 1,
"omp": 4,
}
archived = {
path.relative_to(destination).as_posix()
Expand All @@ -106,9 +121,25 @@ def test_archives_complete_agent_layouts_without_unrelated_state(
"macbookpro-m4/codex/history.jsonl",
"macbookpro-m4/codex/sessions/2026/08/24/rollout.jsonl",
"macbookpro-m4/pi/sessions/project/session.jsonl",
"macbookpro-m4/omp/sessions/project/session.jsonl",
"macbookpro-m4/omp/sessions/project/session/worker.jsonl",
"macbookpro-m4/omp/sessions/project/session/worker.md",
"macbookpro-m4/omp/sessions/project/session/1.bash.log",
}


def test_omp_honors_custom_agent_directory(tmp_path: Path) -> None:
agent_dir = tmp_path / "omp-agent"

assert [
source.path
for source in default_sources(
tmp_path / "home", {"PI_CODING_AGENT_DIR": str(agent_dir)}
)
if source.agent == "omp"
] == [agent_dir / "sessions"]


def test_discovers_and_archives_openclaw_session_directories(tmp_path: Path) -> None:
home = tmp_path / "home"
state = tmp_path / "openclaw-state"
Expand Down