[#17e] jcode session migrate subcommand: idempotent v1 → tree-aware schema upgrade
Sub-issue of #17. The user-facing command that upgrades existing JSONL session files to the new tree-aware / v2-sidecar-compatible schema.
Hard dependencies
Subcommand surface
jcode session migrate (default: all sessions in ~/.jcode/agent/sessions/).
jcode session migrate --session <id-or-path> — single file.
jcode session migrate --dry-run — report what would change without writing.
jcode session migrate --all — same as default; explicit form.
Behavior
- For each session file:
- Detect schema version (top-line metadata or absent → infer v1).
- If already current → skip with
up-to-date.
- Else rewrite using the temp-then-rename helper from #17b.
- Re-index in the sidecar DB from #17a.
- Idempotent: running twice produces the same result.
- Atomic per file: a migration failure on one file does not touch the rest; previous version is preserved as
<file>.v1.bak.
Output
- Concise summary:
Migrated 13 sessions, 0 skipped, 1 failed (see ~/.jcode/logs/migrate.log).
Acceptance criteria
migrate --dry-run writes nothing.
migrate --all on a fresh dir does nothing the second time.
- A linear v1 session round-trips to the new schema with identical visible content.
Cross-references
Reference
- pi_agent_rust →
pi migrate subcommand.
[#17e]
jcode session migratesubcommand: idempotent v1 → tree-aware schema upgradeHard dependencies
/tree,/fork,/clonein-place navigation #2 (tree branching defines the target schema).Subcommand surface
jcode session migrate(default: all sessions in~/.jcode/agent/sessions/).jcode session migrate --session <id-or-path>— single file.jcode session migrate --dry-run— report what would change without writing.jcode session migrate --all— same as default; explicit form.Behavior
up-to-date.<file>.v1.bak.Output
Migrated 13 sessions, 0 skipped, 1 failed (see ~/.jcode/logs/migrate.log).Acceptance criteria
migrate --dry-runwrites nothing.migrate --allon a fresh dir does nothing the second time.Cross-references
jcode session migrate: session storage migration & v2 sidecar fast-path for large sessions #17/tree,/fork,/clonein-place navigation #2 (schema), Add general-purposejcode doctordiagnostic command #8 (doctor --only sessionsshould suggest running this when stale files are detected).Reference
pi migratesubcommand.