SessionStart injects raw JSON bundle: key list misses the engine's rendered_markdown field

Open Beginner friendly
#8 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, nodejs
Domain
tooling

Research direction

Open hooks/zcode-mem-hook.mjs and read summarizeContextBundle around L245-250, where the render key list is checked before falling back to JSON.stringify. Reproduce by feeding it the output of nmem --json context --source-app zcode and confirming the output shows raw JSON with a top-level rendered_markdown string. Add payload.rendered_markdown to the front of the lookup list and re-run the hook to confirm the injected context starts with the Markdown render instead of a JSON dump.

Written by the indexing model from the issue text.

Description

Environment
  • nowledge-mem-zcode: 0.2.2 (installed via ZCode plugin marketplace)
  • nmem CLI / engine: 0.10.119
  • OS: macOS (darwin 25.6.0, arm64)
What happens

On SessionStart, the hook's injected additionalContext is the entire context bundle pretty-printed as raw JSON (truncated to MAX_CONTEXT_CHARS = 6000), instead of the human-readable render the engine already provides.

Root cause

summarizeContextBundle (hooks/zcode-mem-hook.mjs, L245-250 in 0.2.2):

const rendered = payload.markdown || payload.content || payload.context || payload.working_memory;
if (typeof rendered === "string" && rendered.trim()) return rendered.trim();
return JSON.stringify(payload, null, 2);

The engine's context bundle (nmem --json context --source-app zcode) carries the human-readable render under a key this list does not cover:

  • top-level keys observed: active_space, agent_profile, authorship, bundle_kind, compiled_hash, generated_at, kfs_roots, owner_profile, rendered_markdown, rule_stack, schema_version, warnings, working_memory
  • rendered_markdown: string, ~11.7k chars — a finished Markdown render (first line # Nowledge Mem Context Bundle)
  • working_memory: object, so it fails the typeof rendered === "string" check

All four lookups miss → the fallback dumps the whole bundle as JSON.

The engine clearly intends this surface to be human-readable: nmem context without --json (help text: "Emit raw JSON instead of human-readable output") outputs the same rendered Markdown, line-identical to rendered_markdown apart from two blank lines.

Suggested fix (one line)

Add the engine's key to the lookup list:

const rendered = payload.rendered_markdown || payload.markdown || payload.content || payload.context;

(working_memory can stay last or be dropped from the string path — it is an object in current engine output.)

Local workaround in place

A companion hook injecting nmem context plain-mode output as session-start additionalContext (coexists with the official hook until this is fixed). Verified on 0.2.2 + nmem 0.10.119: official hook output is the 6000-char JSON dump; plain-mode output is the clean render.

Notes
  • 0.2.2 release notes do not mention SessionStart / rendered_markdown, so this appears unreported.
  • Side observation: the SessionStart matcher (startup|clear|compact) does not cover resume, which the ZCode host also fires for SessionStart hooks.
Dominant language
JavaScript
Stars
3
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nowledge-co/zcode-plugin

All issues in nowledge-co/zcode-plugin

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.