Skip to content

feat: add ZCode platform plugin - #714

Open
karthick-kk wants to merge 4 commits into
zilliztech:mainfrom
karthick-kk:feat/zcode-platform-plugin
Open

feat: add ZCode platform plugin#714
karthick-kk wants to merge 4 commits into
zilliztech:mainfrom
karthick-kk:feat/zcode-platform-plugin

Conversation

@karthick-kk

Copy link
Copy Markdown

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 custom parse-session.py to extract turns.

What ZCode provides for hooks

ZCode fires hooks on 3 lifecycle events (no SessionEnd, like Codex):

Hook Async Timeout Purpose
SessionStart no 10s Orphan cleanup, bootstrap memsearch, watch/index, cold-start injection
UserPromptSubmit no 15s Memory availability hint
Stop yes 120s Parse last turn from SQLite DB, summarize via claude -p, save to daily .md

Key env vars injected by ZCode:

  • CLAUDE_SESSION_ID — session ID (template variable)
  • ZCODE_PROJECT_DIR / CLAUDE_PROJECT_DIR — project working directory
  • CLAUDE_PLUGIN_ROOT — plugin install directory (resolves ${CLAUDE_PLUGIN_ROOT} in hooks.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.py script queries the message and part tables, 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 via CLAUDECODE= and MEMSEARCH_IN_STOP_WORKER=1. Falls back to truncated raw text if claude -p is unavailable.

Memory anchors use the format <!-- session:<id> db:<path> --> (instead of rollout:/transcript:), enabling the memory-recall skill to drill back into the SQLite session database.

Changes

New: plugins/zcode/

  • .claude-plugin/plugin.json — plugin manifest
  • hooks/hooks.json — declares 3 hooks using ${CLAUDE_PLUGIN_ROOT} path resolution
  • hooks/common.sh — env var resolution, JSON helpers, orphan cleanup, Milvus Lite lock handling
  • hooks/stop.sh — async capture: SQLite session parsing → claude -p summarization → daily .md append
  • hooks/session-start.sh — bootstrap, watch/index, cold-start injection
  • hooks/user-prompt-submit.sh — memory availability hint
  • scripts/parse-session.py — ZCode SQLite session parser
  • scripts/derive-collection.sh, maintenance-runner.py — synced from _shared
  • prompts/, skills/ — synced from _shared

Modified: core library

  • src/memsearch/config.py — added zcode to PluginsConfig + key mappings
  • src/memsearch/cli.py — added zcode to --plugin help, init wizard, summarize prompts
  • plugins/_shared/scripts/maintenance-runner.py — added zcode to DEFAULT_NATIVE_MODELS

Modified: marketplace + shared sources

  • .claude-plugin/marketplace.json — added memsearch-zcode entry
  • plugins/_shared/skills/ — added zcode to platform lists + references/zcode.md
  • scripts/sync-skills.sh, sync-prompts.sh — added zcode to sync arrays

Tests

  • 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 roundtrip
  • tests/test_maintenance_runner.py — zcode added to platform list
  • tests/test_skills_sync.py — zcode added to FS_PLATFORMS

Docs

  • docs/platforms/zcode/ — index, installation, how-it-works, memory-recall
  • docs/platforms/index.md — added zcode to comparison table and cross-platform sharing section

Test results

365 passed, 7 skipped, 3 warnings in 48.98s

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.py and claude-code/transcript.py are unchanged).

Checklist

  • Plugin follows the same architecture as existing shell-hook platforms (Codex)
  • parse-session.py handles the SQLite session storage unique to ZCode
  • Skills synced from _shared (not hand-edited in platform copies)
  • Tests cover parse-session.py and stop.sh edge cases
  • Docs follow the same structure as other platform docs
  • All tests pass (uv run python -m pytest)
  • Ruff passes on new/modified files
  • Conventional commit message used

ekrkaxx 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.
Comment thread plugins/zcode/scripts/maintenance-runner.py Outdated
Comment thread plugins/zcode/hooks/session-start.sh Outdated
Comment thread plugins/zcode/hooks/session-start.sh Outdated
Comment thread plugins/zcode/scripts/parse-session.py
Comment thread docs/platforms/zcode/how-it-works.md
Comment thread plugins/_shared/skills/memory-config/SKILL.md Outdated
Comment thread plugins/_shared/skills/memory-config/references/zcode.md Outdated
ekrkaxx 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.
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.

2 participants