Files
vectorize-io__hindsight/hindsight-docs/docs-integrations
Nicolò Boschi 1f513a6393 feat(coding-agents): add ZCode as a supported harness (#4240) (#4258)
feat(coding-agents): add ZCode as a supported harness (#4240)

Adds ZCode (Z.ai's GLM coding agent) to the shared coding-agents package, so its
users get the same knowledge-page, reflect and configuration experience as every
other supported agent instead of the standalone hindsight-zcode integration.

Three hook registrations, a stdio MCP server and the companion skill, all in
ZCode's own CLI config and home (~/.zcode) — never the user's real Claude Code
settings, even though ZCode embeds the Claude Code agent runtime and speaks its
hook protocol. Config hooks ship disabled, so the installer flips hooks.enabled;
uninstall removes the block again when nothing else is registered there.

The one genuinely new mechanism is a per-session TURN JOURNAL (core/turn-journal.ts).
Every other hook harness hands its Stop hook a file holding the whole conversation,
which is what the incremental write-back needs: retainLiveSession re-reads the full
transcript and the retain cursor sends only the turns added since the last write.
ZCode has no such file — Stop carries the reply plus a temp, assistant-only
transcript it deletes as the hook returns, and no user prompt at all. So the plugin
keeps the conversation itself: the prompt hook appends the user turn, the Stop hook
appends the reply, and retain then reads it exactly as any host transcript. Nothing
downstream changes.

Two host quirks worth knowing, both verified against the runtime rather than assumed:

- hook budgets are `timeoutMs` MILLISECONDS (30000/30000/60000), like qwen-code and
  unlike everything else; the declared timeoutUnit makes that checkable.
- registrations use ZCode's "process" argv shape, not a command string — it spawns
  hooks without a shell, so `node "…/zcode-hook.js"` would be looked up verbatim as
  one executable name and never run.

`--import-conversations` is deliberately unsupported and says why: ZCode persists no
session transcripts, so there is no history on disk to backfill from.

Verified against real ZCode 0.16.5: all three hooks fire with correct bank
derivation, the journal captures the user/assistant pair, `zcode skills list` finds
the companion skill, and all 8 hindsight MCP tools reach the model. A Docker E2E
(e2e/Dockerfile.zcode) asserts injection AND retention end to end against the
published tarball — fuller than grok-build, factory-droid and qwen-code, which are
retention-only. Its entry script merges the stub provider into the config rather
than rendering it, because that file is the same one the installer owns.

Guard tests, since the sibling that forgets is the one nobody tests: a family-wide
check that journalPrompt and retain.journal are declared together, and that a journal
harness parses neither a host transcript path nor a Stop-event reply — both would be
applied on top of the journal, and ZCode's own payload carries last_assistant_message.
2026-09-09 14:50:26 +02:00
..