SessionStart injects raw JSON bundle: key list misses the engine's rendered_markdown field
還沒有人認領這個 Issue。
評估
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 新手友好度
- 88/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, nodejs
- 領域
- tooling
研究方向
開啟 hooks/zcode-mem-hook.mjs,閱讀 L245-250 附近的 summarizeContextBundle,此處會先檢查 render 鍵清單,然後再回退到 JSON.stringify。透過將 nmem --json context --source-app zcode 的輸出餵給它來重現,並確認輸出顯示的是帶有頂層 rendered_markdown 字串的原始 JSON。將 payload.rendered_markdown 加到查詢清單的最前面,並重新執行該 hook,以確認注入的上下文以 Markdown 渲染開頭,而不是 JSON dump。
由索引模型根據 Issue 內容生成。
描述
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 thetypeof 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 coverresume, which the ZCode host also fires for SessionStart hooks.
- 主要語言
- JavaScript
- 星號
- 3
- 分支
- 1
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nowledge-co/zcode-plugin 的其他 Issue
-
UserPromptSubmit recall regex is English-only: Chinese prompts never trigger auto-recall可能已有人在做 @ThaddeusJiang 於 3 天前認領。 未關閉bug
難度 1/5 1-3 小時 新手友好度 82/100
nowledge-co/zcode-plugin#4 · 1 則留言 · 已指派 1 人 ·
-
Hooks silently not loaded from a local directory marketplace; ZCode 0.16.5 Stop transcript is assistant-only so stock sync always fails可能已有人在做 @ThaddeusJiang 於 3 天前認領。 未關閉bug
難度 4/5 3-5 天 新手友好度 45/100
nowledge-co/zcode-plugin#2 · 2 則留言 · 已指派 1 人 ·
查看 nowledge-co/zcode-plugin 的全部 Issue
相似的 Issue
-
nip27: long hashtag swallows the rest of the content, lone # gives an empty hashtag可能已有人在做 @bardrop 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
nbd-wtf/nostr-tools#578 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
h5bp/html5-boilerplate#3512 ·
-
documentation
難度 1/5 1-3 小時 新手友好度 85/100
githubnext/gh-aw-workshop#5752 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 70/100
維護者通常 1 天內回覆