mirror of https://github.com/garrytan/gstack.git
Plan-tune cathedral T12. Extends the PreToolUse hook to inject matching
free-text-memory.json nuggets into AskUserQuestion responses, giving the
agent + user the distilled context from past 'Other' answers right when
the related question fires.
Per-session cache (D13 perf): first read of free-text-memory.json writes
~/.gstack/sessions/<id>/memory-cache.json. Subsequent hooks on the same
session take the cached path. Invalidation is by file-missing: when the
canonical file changes (via gstack-distill-apply), the per-session cache
either reflects the staler view for the rest of the session or the
session restarts and the cache rebuilds. Cheap, correct enough for v1.
Matching logic:
- Walk this AUQ batch's questions, extract marker question_ids.
- Look up signal_key in scripts/question-registry.ts.
- Collect nuggets whose applies_to_signal_keys include any of the
matched signal_keys.
- Cap to 3 most-recent (by applied_at) so the additionalContext stays
short.
- Surface as additionalContext on the hookSpecificOutput response.
Memory + enforcement interact cleanly: the same hook can both surface
nuggets AND deny the tool when a never-ask preference matches. Memory
context isn't doubled in the deny reason — the auto-decided option name
in the deny path is sufficient signal.
6 new tests cover injection on defer, no-match silence, 3-most-recent cap,
memory-alongside-deny enforcement, cache file write-through, empty-canonical
graceful degradation. Existing 15 preference-hook tests still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| claude/hooks | ||
| claude.ts | ||
| codex.ts | ||
| cursor.ts | ||
| factory.ts | ||
| gbrain.ts | ||
| hermes.ts | ||
| index.ts | ||
| kiro.ts | ||
| openclaw.ts | ||
| opencode.ts | ||
| slate.ts | ||