|
oc_chat
|
Functions | |
| _ensure_dirs () | |
| list[Path] | _migrate_root_chat_logs () |
| dict|None | _convert_old_session_to_metadata (Path old_path) |
| list[Path] | _migrate_old_sessions_dir () |
| None | main () |
Variables | |
| PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent | |
| str | NEW_SESSIONS_DIR = PROJECT_ROOT / "oc_chat" / "sessions" |
| str | NEW_CHAT_LOGS_DIR = NEW_SESSIONS_DIR / "Chat_logs" |
| str | OLD_SESSIONS_DIR = PROJECT_ROOT / "sessions" |
One-time migration script — legacy session-file relocation.
Purpose
-------
Moves legacy files into the new ``oc_chat/sessions/`` structure so
older installs upgrade cleanly:
1. Root-level ``chat_log_*.json`` → ``oc_chat/sessions/Chat_logs/``
2. Root-level ``sessions/*.json`` → ``oc_chat/sessions/`` (as
lightweight metadata files)
Run with: ``python -m oc_chat.tools.migrate_sessions``. Safe to
re-run — files already in the target structure are skipped.
Responsibilities
----------------
- :func:`_ensure_dirs` — create target directories idempotently.
- :func:`_migrate_root_chat_logs` — relocate legacy chat-log files.
- :func:`_migrate_old_sessions_dir` — relocate the legacy
``sessions/`` directory.
- :func:`main` — CLI entry point that prints a human-readable summary.
Diagnostics
-----------
Domain: OC_CHAT.TOOLS
Levels:
L2 — lifecycle events
L3 — semantic details
L4 — deep tracing
Contracts
---------
- Idempotent: running twice on an already-migrated tree is a no-op.
- Never overwrites a destination file silently — duplicate names are
preserved by skipping with a warning.
- All ``print()`` calls are user-facing CLI output, not diagnostic.
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
|
protected |
Convert a legacy session JSON (full conversation) to lightweight metadata format.
Definition at line 80 of file migrate_sessions.py.
|
protected |
Create target directories if they don't exist.
Definition at line 60 of file migrate_sessions.py.
|
protected |
Convert old ``sessions/*.json`` → new lightweight metadata in ``oc_chat/sessions/`` and move messages as chat logs.
Definition at line 128 of file migrate_sessions.py.
|
protected |
Move ``chat_log_*.json`` from project root into ``Chat_logs/``.
Definition at line 66 of file migrate_sessions.py.
| None oc_chat.tools.migrate_sessions.main | ( | ) |
Run the one-time session migration.
Definition at line 183 of file migrate_sessions.py.
| str oc_chat.tools.migrate_sessions.NEW_CHAT_LOGS_DIR = NEW_SESSIONS_DIR / "Chat_logs" |
Definition at line 56 of file migrate_sessions.py.
| str oc_chat.tools.migrate_sessions.NEW_SESSIONS_DIR = PROJECT_ROOT / "oc_chat" / "sessions" |
Definition at line 55 of file migrate_sessions.py.
| str oc_chat.tools.migrate_sessions.OLD_SESSIONS_DIR = PROJECT_ROOT / "sessions" |
Definition at line 57 of file migrate_sessions.py.
| oc_chat.tools.migrate_sessions.PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent |
Definition at line 54 of file migrate_sessions.py.