Skip to content

[#17e] jcode session migrate subcommand: idempotent v1 → tree-aware schema upgrade #37

@quangdang46

Description

@quangdang46

[#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:
    1. Detect schema version (top-line metadata or absent → infer v1).
    2. If already current → skip with up-to-date.
    3. Else rewrite using the temp-then-rename helper from #17b.
    4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions