feat: add ZCode platform plugin - #714
Open
karthick-kk wants to merge 4 commits into
Open
Conversation
added 2 commits
September 1, 2026 21:26
Add native memsearch support for ZCode, a terminal coding agent with a
plugin marketplace and shell hook system. ZCode uses the same Stop-hook
capture pattern as Claude Code and Codex, but stores conversations in a
SQLite database (~/.zcode/cli/db/db.sqlite) instead of JSONL transcripts,
requiring a custom parse-session.py.
Changes:
- plugins/zcode/: full plugin (hooks, scripts, skills, prompts, manifest)
- hooks/common.sh: env var resolution (CLAUDE_SESSION_ID, ZCODE_DB_PATH,
ZCODE_PROJECT_DIR), orphan cleanup, Milvus Lite lock handling
- hooks/stop.sh: async capture via claude -p, SQLite session parsing,
recursion prevention (CLAUDECODE= + MEMSEARCH_IN_STOP_WORKER=1)
- hooks/session-start.sh: bootstrap, watch/index, cold-start injection
- hooks/user-prompt-submit.sh: memory availability hint
- scripts/parse-session.py: SQLite session parser (message+part tables,
turn grouping, text/tool-call rendering, reasoning omission)
- src/memsearch/config.py: add zcode to PluginsConfig + key mappings
- src/memsearch/cli.py: add zcode to --plugin help, init wizard, summarize
- plugins/_shared/scripts/maintenance-runner.py: add zcode to
DEFAULT_NATIVE_MODELS
- .claude-plugin/marketplace.json: add memsearch-zcode marketplace entry
- plugins/_shared/skills/: add zcode to platform lists + references/zcode.md
- scripts/sync-skills.sh, sync-prompts.sh: add zcode to sync arrays
- tests/: test_zcode_parse_session.py, test_zcode_stop_hook.py, zcode
assertions in test_config, test_maintenance_runner, test_skills_sync
- docs/platforms/zcode/: index, installation, how-it-works, memory-recall
- docs/platforms/index.md: add zcode to comparison table
The Stop hook fires after every assistant turn, and parse-session.py always extracts the latest turn. Session-level dedup meant only the first turn of each session was ever captured — all subsequent turns were silently skipped because the session ID was already in today's memory file. Remove the dedup entirely, matching the codex plugin's approach: capture on every Stop fire. Each fire captures a different turn since the parser extracts the latest exchange.
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
yhmo
reviewed
Sep 7, 2026
added 2 commits
September 7, 2026 23:20
- maintenance-runner.py: add zcode to --platform choices and add a zcode
branch to run_native_provider() mirroring the claude-code claude -p path.
Without both, common.sh's --platform zcode call exited 2 and maintenance
never ran.
- session-start.sh: run the Lite-mode index in a background subshell with
dimension-mismatch reset/re-index recovery so it survives the 10s hook
timeout, matching the documented behaviour.
- session-start.sh: emit memory-file count/date range, the PyPI update
check, and index/skill warnings inside a single JSON systemMessage
instead of printing raw text before echo '{}'.
- session-start.sh: write the '## Session HH:MM' heading so journals match
the documented format and the recall skill's '^## ' grep.
- memory-config SKILL.md: check ~/.zcode before CLAUDE_PLUGIN_ROOT, which
ZCode also exports.
- memory-config references/zcode.md: drop the reference to a non-existent
plugins/zcode/scripts/install.sh.
- Add _resolve_symlinks, _installed_version_from_dist_info, and _pypi_latest_version to zcode/common.sh (were called but not defined). - Add echo $! > "$INDEX_PIDFILE" after background index subshell so kill_orphaned_index can find and kill stale index processes. - Wrap long argparse line (126 chars -> <120 chars) for ruff format. - Sync maintenance-runner.py to all 6 platform copies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native memsearch support for ZCode, a terminal coding agent with a plugin marketplace and shell hook system. ZCode is the sixth supported platform alongside Claude Code, Codex, DeepSeek Harness, OpenClaw, and OpenCode.
ZCode uses the same Stop-hook capture pattern as Claude Code and Codex, but stores conversations in a SQLite database (
~/.zcode/cli/db/db.sqlite) instead of JSONL transcripts, requiring a customparse-session.pyto extract turns.What ZCode provides for hooks
ZCode fires hooks on 3 lifecycle events (no
SessionEnd, like Codex):SessionStartUserPromptSubmitStopclaude -p, save to daily.mdKey env vars injected by ZCode:
CLAUDE_SESSION_ID— session ID (template variable)ZCODE_PROJECT_DIR/CLAUDE_PROJECT_DIR— project working directoryCLAUDE_PLUGIN_ROOT— plugin install directory (resolves${CLAUDE_PLUGIN_ROOT}inhooks.json)Architecture
The ZCode plugin closely follows the Codex plugin (shell hooks, no SessionEnd, main-context skill), with one key difference: session storage is SQLite, not JSONL. The
parse-session.pyscript queries themessageandparttables, groups messages into turns (user prompt → assistant response), renders text and tool-call parts, and omits reasoning blocks.Summarization uses
claude -p --model haiku(same as the Claude Code plugin) with recursion prevention viaCLAUDECODE=andMEMSEARCH_IN_STOP_WORKER=1. Falls back to truncated raw text ifclaude -pis unavailable.Memory anchors use the format
<!-- session:<id> db:<path> -->(instead ofrollout:/transcript:), enabling the memory-recall skill to drill back into the SQLite session database.Changes
New:
plugins/zcode/.claude-plugin/plugin.json— plugin manifesthooks/hooks.json— declares 3 hooks using${CLAUDE_PLUGIN_ROOT}path resolutionhooks/common.sh— env var resolution, JSON helpers, orphan cleanup, Milvus Lite lock handlinghooks/stop.sh— async capture: SQLite session parsing →claude -psummarization → daily.mdappendhooks/session-start.sh— bootstrap, watch/index, cold-start injectionhooks/user-prompt-submit.sh— memory availability hintscripts/parse-session.py— ZCode SQLite session parserscripts/derive-collection.sh,maintenance-runner.py— synced from_sharedprompts/,skills/— synced from_sharedModified: core library
src/memsearch/config.py— addedzcodetoPluginsConfig+ key mappingssrc/memsearch/cli.py— addedzcodeto--pluginhelp, init wizard, summarize promptsplugins/_shared/scripts/maintenance-runner.py— addedzcodetoDEFAULT_NATIVE_MODELSModified: marketplace + shared sources
.claude-plugin/marketplace.json— addedmemsearch-zcodeentryplugins/_shared/skills/— added zcode to platform lists +references/zcode.mdscripts/sync-skills.sh,sync-prompts.sh— added zcode to sync arraysTests
tests/test_zcode_parse_session.py— 4 tests (last turn, specific turn, nonexistent session, reasoning omission)tests/test_zcode_stop_hook.py— 3 tests (UTF-8 fallback, empty content skip, no session id)tests/test_config.py— zcode assertions in set/get roundtriptests/test_maintenance_runner.py— zcode added to platform listtests/test_skills_sync.py— zcode added toFS_PLATFORMSDocs
docs/platforms/zcode/— index, installation, how-it-works, memory-recalldocs/platforms/index.md— added zcode to comparison table and cross-platform sharing sectionTest results
All existing tests pass, plus 7 new zcode-specific tests. Ruff is clean on all new/modified Python files (the 16 pre-existing ruff warnings in
maintenance-runner.pyandclaude-code/transcript.pyare unchanged).Checklist
parse-session.pyhandles the SQLite session storage unique to ZCode_shared(not hand-edited in platform copies)uv run python -m pytest)