ChatLab Import
Import local chat exports through the clb CLI. Always preview the exact write. Treat an explicit request to import as authorization to continue after a successful preview; do not ask for a second confirmation.
Follow the user's requested response language; otherwise use the conversation language, preserving the user's Chinese variant when applicable. Keep commands, field names, IDs, and evidence markers unchanged.
For analysis of imported records, use chatlab-analyze when available. For an unsupported source, use chatlab-convert when available; neither skill is required for a supported import.
Workflow
- Check the CLI and resolve one exact file path:
clb --help
If the CLI is missing, tell the user to install it with npm install -g chatlab-cli. Do not install software without approval. Reuse the user's specified file and target. Ask only if the path remains ambiguous, and quote it in every command.
- Preview the import without writing:
clb import "/absolute/path/to/chat-export.json" --dry-run --json
If the user selected an existing session, include --session-id <session-id> in both preview and import.
Summarize only the plan: create or update mode, target session ID, scanned messages, new messages, duplicates, and match method or create reason. Never quote message bodies.
Require ok: true, then read the plan from data and decide:
- If the user asked only to preview or inspect, stop without writing.
- If
importMode is incremental and newMessageCount is 0, report that the session is already up to date and stop.
- If
importMode is incremental and there are new messages, continue automatically without another confirmation.
- If
importMode is created, continue automatically. When createReason is ambiguous, preserve existing sessions by creating a new one and explain this choice in the final result.
- If the result does not identify a safe action, stop and explain what is missing.
- When the decision permits writing, run the same command without
--dry-run, keeping the file, target, and format unchanged:
clb import "/absolute/path/to/chat-export.json" --json
Report the resulting session ID, import mode, new-message count, and duplicate count from the final JSON envelope.
Guardrails
- Never skip the preview, edit ChatLab databases directly, or delete or merge sessions.
- Never reveal a full chat export or message bodies.
- Never invent a file path, parser format, or session ID.
- Follow
error.hint only when the correction is unambiguous.
- For
FILE_NOT_FOUND or INVALID_SESSION_ID, resolve from available context or request the correct value. For UNRECOGNIZED_FORMAT, inspect clb formats. For IMPORT_IN_PROGRESS, retry once after the active import finishes; if still blocked, report it instead of polling indefinitely.
1---2name: chatlab-import3description: Preview and import supported local chat exports into ChatLab, including incremental updates. 预览并导入 ChatLab 支持的本地聊天导出,支持增量更新。4---56# ChatLab Import78Import local chat exports through the `clb` CLI. Always preview the exact write. Treat an explicit request to import as authorization to continue after a successful preview; do not ask for a second confirmation.910Follow the user's requested response language; otherwise use the conversation language, preserving the user's Chinese variant when applicable. Keep commands, field names, IDs, and evidence markers unchanged.1112For analysis of imported records, use `chatlab-analyze` when available. For an unsupported source, use `chatlab-convert` when available; neither skill is required for a supported import.1314## Workflow15161. Check the CLI and resolve one exact file path:1718```bash19clb --help20```2122If the CLI is missing, tell the user to install it with `npm install -g chatlab-cli`. Do not install software without approval. Reuse the user's specified file and target. Ask only if the path remains ambiguous, and quote it in every command.23242. Preview the import without writing:2526```bash27clb import "/absolute/path/to/chat-export.json" --dry-run --json28```2930If the user selected an existing session, include `--session-id <session-id>` in both preview and import.31323. Summarize only the plan: create or update mode, target session ID, scanned messages, new messages, duplicates, and match method or create reason. Never quote message bodies.33344. Require `ok: true`, then read the plan from `data` and decide:3536- If the user asked only to preview or inspect, stop without writing.37- If `importMode` is `incremental` and `newMessageCount` is `0`, report that the session is already up to date and stop.38- If `importMode` is `incremental` and there are new messages, continue automatically without another confirmation.39- If `importMode` is `created`, continue automatically. When `createReason` is `ambiguous`, preserve existing sessions by creating a new one and explain this choice in the final result.40- If the result does not identify a safe action, stop and explain what is missing.41425. When the decision permits writing, run the same command without `--dry-run`, keeping the file, target, and format unchanged:4344```bash45clb import "/absolute/path/to/chat-export.json" --json46```4748Report the resulting session ID, import mode, new-message count, and duplicate count from the final JSON envelope.4950## Guardrails5152- Never skip the preview, edit ChatLab databases directly, or delete or merge sessions.53- Never reveal a full chat export or message bodies.54- Never invent a file path, parser format, or session ID.55- Follow `error.hint` only when the correction is unambiguous.56- For `FILE_NOT_FOUND` or `INVALID_SESSION_ID`, resolve from available context or request the correct value. For `UNRECOGNIZED_FORMAT`, inspect `clb formats`. For `IMPORT_IN_PROGRESS`, retry once after the active import finishes; if still blocked, report it instead of polling indefinitely.