Skip to content

feat(cli): import DeepSeek Harness sessions - #29

Open
Lumea-art wants to merge 1 commit into
EverMind-AI:mainfrom
Lumea-art:feat/dsh-conversation-importer
Open

Lumea-art wants to merge 1 commit into
EverMind-AI:mainfrom
Lumea-art:feat/dsh-conversation-importer

Conversation

@Lumea-art

Copy link
Copy Markdown

Summary

evercli import conversations had no reader for DeepSeek Harness, even though dsh is already an install target — so the only EverMe memory a dsh user could get was what the native plugin captured after install, never the history that made the agent worth talking to. This adds the reader, the scan root, and the token resolver, so scan and run both work.

Changes

  • cli/internal/importer/conversation/dsh.go — the scanner. DSH keeps one zstd-compressed JSONL log per session at <DSH_HOME>/sessions/<workspace>/<session-id>/session.v4.jsonl.zstd; the reader streams it through zstd.Reader and maps the event-sourced records onto the existing AgentMemoryMessage DTO.
  • cli/internal/importer/conversation/types.go, platforms.go, registry.go — register dsh: platform id, known-platform set, default registry, and DefaultRoots (<DSH_HOME>/sessions, honoring the same DSH_HOME the installer uses). The two "Use one of: …" hints in cli/cmd/imports/conversations.go now list it too.
  • cli/internal/importer/conversation/evt.go — ResolveEvt(dsh) reads <DSH_HOME>/.env, the dotenv file evercli plugin install dsh already writes, so run resolves a token exactly like Claude Code / Hermes / Kimi Code do.
  • cli/internal/importer/conversation/dsh_test.go — six test functions covering the record mapping, duplicate suppression, standalone tool calls, format-version drift, missing root, and token resolution. Fixtures are generated in t.TempDir() with the zstd writer, so no binary blob is committed.
  • cli/go.mod — github.com/klauspost/compress was already in the module graph as an indirect dependency; it is promoted to a direct one at the same version (no bump).
  • CHANGELOG.md.

What gets imported

DSH record Handling
user/message role user; text blocks joined, image blocks skipped (the text still carries the question)
assistant/message role assistant; text plus the tool-call blocks the message carries, attached as toolCalls so a call stays next to what asked for it
tool/result role tool, paired by toolCallId; isError results are prefixed [error]
tool/call only used when no assistant message carried that callId — the record duplicates the message's own block one-for-one (206 of 206 ids on a real session), so importing both would double-write every round-trip
system/message, reasoning blocks skipped: instructions and compaction context, not conversation
agent/inbox/spliced skipped: it replays a user/message recorded separately under the same id (11/11 ids on a real session)
step/turn boundaries, approvals, sandbox mode, jobs, todo writes, slash-command output, delivery receipts, compaction events bookkeeping, skipped

A session whose header version is newer than the v4 this reader knows still imports the records it understands and adds a warning, so a future dsh release degrades to "some records skipped" rather than a silently partial conversation. Every unknown event type warns once per session — that is how the skip list above was completed (first run of the reader surfaced 14 types I had not seen).

Test Plan

go1.27.4, linux/amd64, commit 3e345b7:

go test ./... -count=1                       ok    (all packages)
go test -race ./internal/importer/conversation/ -count=1   ok
go vet ./...                                 exit 0
gofmt -l .                                   (no output)
go mod tidy                                  (no change to go.mod / go.sum)
go test -run DSH -v ./internal/importer/conversation/      6/6 PASS

Manual verification against real session logs on a development machine (read locally; scan uploads nothing):

26 session logs on disk
  → 19 importable (17,416 messages / 7,968 tool calls, dates 2026-10-18 … 2026-11-10)
  →  6 empty logs (header + permission/sandbox/approval only) — correctly excluded as "no parseable messages"
  →  1 actively-written log — excluded by the shared skippedActive rule
all 26 parse with 0 warnings
  • CLI tests pass, if cli/ changed
  • Plugin workspace tests pass, if plugins/ changed — not applicable, this PR does not touch plugins/
  • Manual verification completed, if behavior changed — the scan above, plus a per-record check that assistant tool-call ids match the tool/call records 1:1

Security

  • No real emk_*, evt_*, cookies, private URLs, or production logs are included. Test fixtures are synthetic; the end-to-end check above only counted messages locally and uploaded nothing.

Known limitation (worth a reviewer decision)

DSH's session.v4 is a versioned internal format. The reader treats it defensively (version warning + per-type warnings + tolerant parsing) but it is still coupled to that schema. If maintainers would rather wait for a stable format, this PR can sit until then — the scanner is isolated in one file and registers nothing else.

Related Issues

  • None open for this. It is the importer counterpart of the existing evercli plugin install dsh, in the same shape as the SeekMoon importer.

`evercli import conversations` had no reader for dsh, even though dsh is
already an install target — so the only EverMe memory a dsh user could get
was whatever the native plugin captured after install, never the history
that made the agent useful in the first place.

The harness keeps one zstd-compressed JSONL log per session at
`<DSH_HOME>/sessions/<workspace>/<session-uuid>/session.v4.jsonl.zstd`.
The reader maps its event stream onto the existing importer DTO:

  user/message                 -> role user (text blocks)
  assistant/message            -> role assistant (text + its tool-call blocks)
  tool/result                  -> role tool, paired by toolCallId

`tool/call` records duplicate the assistant message's own tool-call blocks
one-for-one (206 of 206 call ids on a real session), so a call is only
imported from that record when no assistant message carried it. Everything
else is bookkeeping: `system/message` (instructions and compaction context),
`reasoning` blocks, step/turn boundaries, approvals, sandbox mode, jobs,
todo writes, slash-command output and delivery receipts. `agent/inbox/spliced`
replays a `user/message` recorded separately under the same id.

A newer session `version` still imports the records it understands and warns,
so a future dsh release degrades to "some records skipped" instead of a
silently partial session. Every unknown event type warns once per session,
which is how the known-skip list above was completed: 26 real sessions on a
development machine import with zero warnings.

`ResolveEvt(dsh)` reads `<DSH_HOME>/.env`, the dotenv file
`evercli plugin install dsh` already writes, so `run` works as well as `scan`.

github.com/klauspost/compress was already in the module graph as an indirect
dependency; it is promoted to a direct one at the same version, with no bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant