hook-augment is spawned per tool call even with an empty index; expose a cheap "is cwd indexed" gate

Abierto
#3,005 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, sqlite

Línea de trabajo

Start with src/store/store.c, which the issue names for the cache layout and project database invariant, then trace the hook-augment entry point and generated OpenCode plugin hook. Decide which proposed gate fits the existing interfaces and make its behavior machine-readable or skip work when no project is indexed. Done means the client can avoid repeated useless launches; include windowsHide: true for generated plugin spawns as described.

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

Descripción

editor/integration windows

Summary

A generated client hook spawns codebase-memory-mcp hook-augment on every tool result, even when the current directory is not covered by any indexed project. In that state the call cannot produce anything useful: it walks up ancestors, falls back to scanning the whole cache and opening every project DB, and then returns the same generic hint every time:

[codebase-memory] Session context: no indexed graph project matched this working directory.
Run index_repository before structural exploration. ...

A no-op should cost nothing. Today it costs a process spawn, a cache scan, an on-access AV scan, and — on Windows — a console window.

Environment

  • codebase-memory-mcp 0.12.1, Windows 11
  • OpenCode 2 (V2 setup(ctx) surface, execute.after tool hook); the plugin calls the standalone CLI with stdin JSON: SessionStart, PreToolUse (Grep/Glob), PostToolUse (Read)
  • Cache state during measurement: list_projects → projects: 0, i.e. nothing indexed on the machine

Observed

  • One hook-augment process per tool result (measured 10–20 spawns per minute in an active session).
  • On Windows the client runs as a detached service process without a console, so each spawn allocates a fresh console window (conhost / OpenConsole -Embedding) that appears and closes; the user sees a terminal flicker per tool call.
  • Every launch of the executable is also picked up by on-access AV scanning.
  • The answer does not depend on the tool or the payload: for a directory with no index the outcome is always the same hint, and nothing in the payload can change that until the project is indexed.

Proposal (any one is enough for a client-side gate)

  1. Exit before the ancestor walk and the cache scan when the cache contains no project DBs at all — in that state neither step can succeed.
  2. A machine-readable gate: e.g. hook-augment --if-indexed (or a documented exit code) that answers "is cwd covered by an indexed project?" without emitting augmentation text, so a client can skip the call entirely.
  3. A documented, stable offline check. The cache layout is already effectively a contract — <cache>/<project>.db, table projects, single row with root_path (src/store/store.c, incl. the "no ghost .db for unknown/unindexed projects" invariant) — but it is not documented as public API. If it were, a client could verify with the host runtime's built-in SQLite and spawn nothing.
  4. Generated plugins: register the hook only when the project is indexed, and/or cache the answer. Workaround used today: read root_path from the project DBs in the cache via the runtime's built-in SQLite (bun:sqlite / node:sqlite), fail open when verification is impossible, re-check every 5 minutes.

Independently of the gating, generated plugins should spawn with windowsHide: true: a console window per tool call is user-visible noise (same class of problem as #1427).

Related

  • #2058 — hook-augment restarts the daemon on every invocation (~3 s per call)
  • #1427 — detached daemon spawns focus-stealing console windows (closed)
Lenguaje dominante
C
Estrellas
45.8k
Forks
3.8k
Merge medio
2 d 18 h
PR fusionados (30 d)
108

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 DeusData/codebase-memory-mcp

Todos los issues de DeusData/codebase-memory-mcp

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.