Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
OpenViking onboarding guide: importing history on other hosts (for agents)
The import script reads Claude Code and Codex history directly. On other hosts, when the user chose to import in Step 3 of the onboarding guide, you first convert this host's sessions to JSONL and hand that to the same script. Choosing the scope, confirming and reporting the result work as in the onboarding guide; this page covers only the conversion.
Run
echo "${TMPDIR:-/tmp}"and note the directory; below it is<tmp>. Use that absolute path for every file you write and every command, not${TMPDIR:-/tmp}. Download the import script:curl -fsSL https://docs.openviking.ai/dl/memory-plugin-shared/import-history.mjs -o "<tmp>/ov-import-history.mjs"Find where this host keeps its sessions on this machine. The table is a hint; go by what is actually there. Read only; change nothing.
Host --harnessWhere sessions are TraeCode CLI 2.0 trae-cli~/.trae/cli/sessions/, the same rollout format as CodexKimi Code kimicode~/.kimi-code/sessions/(under$KIMI_CODE_HOMEif set); each session'sstate.jsonhas the cwd, the messages are inagents/main/wire.jsonlOpenCode opencodethe SQLite database ~/.local/share/opencode/opencode.db; withoutsqlite3, Node 22'snode:sqlitecan open it read-only;synthetictext is injected content, and sessions with a non-emptyparent_idare sub-agentspi pi~/.pi/agent/sessions/*/*.jsonl; the first line of each file,{"type":"session"}, has the id and cwdDeepSeek Harness dsh~/.dsh/sessions/Cursor, TRAE, TRAE CN, ZCode cursor,trae,trae-cn,zcodenot confirmed Write a small converter under
<tmp>that writes the sessions to<tmp>/ov-sessions.jsonl, one session per line:{"id": "<the host's own session id>", "cwd": "<absolute path of the directory the session ran in>", "messages": [{"role": "user", "text": "...", "created_at": "2026-10-16T08:00:00Z"}, {"role": "assistant", "text": "...", "created_at": "2026-10-16T08:00:05Z"}]}idis the native session id from the host's records; don't make one up.cwdis the directory the session actually ran in. Give every message its ISO 8601 time. Mark sub-agent sessions with"subagent": true.- Include only what the user and the assistant said: no tool calls, tool output, system prompts or reasoning, and nothing the host or a plugin injected (such as
<openviking-context>, reminders or notifications). - Write every session in the store; don't filter by project, directory or time. The script decides which sessions belong to this project from
--cwd(subdirectories included) and applies--since, and--listand--sessionwork as usual. The one session to leave out is this conversation, because it contains the key from the install command; if you can't tell which one it is, leave out sessions updated in the last 2 hours. - Don't remove keys yourself; the script does. Don't check the JSONL for keys either, and never put the key or any part of it in a command. The converter only reads local files and writes this one JSONL file; it sends nothing.
- To check the result, look at a summary only, such as the line count and each line's id, cwd and message count. Don't print the whole JSONL into the conversation: it holds other projects' conversations.
Dry run: add
--input "<tmp>/ov-sessions.jsonl"to the onboarding guide's command, with--harnessfrom the table, for example:node "<tmp>/ov-import-history.mjs" --harness <value> --input "<tmp>/ov-sessions.jsonl" --cwd "$PWD" --since 14d --max-sessions 20 --dry-run --jsonIf the script reports a malformed line, fix the converter, regenerate the file and dry-run again. If the counts are clearly off (no sessions at all in scope, or far fewer messages than the real conversations), check the conversion before importing anything. If 0 sessions are to be uploaded but some have the state
importedorlive, the content is already in OpenViking and the conversion is not at fault; go straight to the read-back, as in 3b of the onboarding guide.From here it's the same as in the onboarding guide: ask the user to confirm as in 3b (this conversation was left out by the converter, so it won't show up as still active), and after they confirm, replace
--dry-runwith--yes --waitto import, then read back as in 3c. Whether you import or not, delete the JSONL file and the converter afterwards, from every place you wrote them, and check withlsthat they are gone.
If you can't find where the sessions are kept, or the conversion is still wrong after two or three tries, tell the user that their history from this host couldn't be imported this time and that OpenViking builds up from their conversations once the plugin is active, then go back to Step 4 of the onboarding guide.