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

オープン 初心者向け
#8 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, nodejs
領域
tooling

調査の方向性

hooks/zcode-mem-hook.mjs を開き、L245-250 付近の summarizeContextBundle を読んでください。ここでは、JSON.stringify にフォールバックする前に render キーのリストがチェックされます。nmem --json context --source-app zcode の出力を渡し、出力がトップレベルの rendered_markdown 文字列を含む生の JSON を表示することを確認して再現してください。payload.rendered_markdown をルックアップリストの先頭に追加し、フックを再実行して、注入されるコンテキストが JSON ダンプではなく Markdown レンダーで始まることを確認してください。

索引モデルが 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 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.
主要言語
JavaScript
スター
3
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nowledge-co/zcode-plugin のほかの issue

nowledge-co/zcode-plugin の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。