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

Đang mở Phù hợp với người mới
#8 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, nodejs
Lĩnh vực
tooling

Hướng nghiên cứu

Mở hooks/zcode-mem-hook.mjs và đọc summarizeContextBundle quanh L245-250, nơi danh sách khóa render được kiểm tra trước khi quay về JSON.stringify. Tái hiện bằng cách cung cấp cho nó đầu ra của nmem --json context --source-app zcode và xác nhận rằng đầu ra hiển thị JSON thô với một chuỗi rendered_markdown ở cấp cao nhất. Thêm payload.rendered_markdown vào đầu danh sách tra cứu và chạy lại hook để xác nhận rằng ngữ cảnh được chèn bắt đầu bằng render Markdown thay vì một bản dump JSON.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
JavaScript
Star
3
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nowledge-co/zcode-plugin

Tất cả issue của nowledge-co/zcode-plugin

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.