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

Abierto Apto para principiantes
#8 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
Menos de una hora
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, nodejs
Área
tooling

Línea de trabajo

Abre hooks/zcode-mem-hook.mjs y lee summarizeContextBundle alrededor de L245-250, donde se comprueba la lista de claves de render antes de recurrir a JSON.stringify. Reproduce esto pasándole la salida de nmem --json context --source-app zcode y confirmando que la salida muestra JSON sin procesar con una cadena rendered_markdown de nivel superior. Añade payload.rendered_markdown al principio de la lista de búsqueda y vuelve a ejecutar el hook para confirmar que el contexto inyectado empieza con el render de Markdown en lugar de un volcado de JSON.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
JavaScript
Estrellas
3
Forks
1
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nowledge-co/zcode-plugin

Todos los issues de nowledge-co/zcode-plugin

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.