diff --git a/.claude/helpers/context-persistence-hook.mjs b/.claude/helpers/context-persistence-hook.mjs index fb6bfec395..32324fe65b 100644 --- a/.claude/helpers/context-persistence-hook.mjs +++ b/.claude/helpers/context-persistence-hook.mjs @@ -2,19 +2,28 @@ /** * Context Persistence Hook (ADR-051) * - * Intercepts Claude Code's PreCompact and SessionStart lifecycle events - * to persist conversation history in SQLite (primary) or JSON (fallback), - * enabling "infinite context" across compaction boundaries. + * Intercepts Claude Code's PreCompact, SessionStart, and UserPromptSubmit + * lifecycle events to persist conversation history in SQLite (primary), + * RuVector PostgreSQL (optional), or JSON (fallback), enabling "infinite + * context" across compaction boundaries. * * Backend priority: * 1. better-sqlite3 (native, WAL mode, indexed queries, ACID transactions) - * 2. AgentDB from @claude-flow/memory (HNSW vector search) - * 3. JsonFileBackend (zero dependencies, always works) + * 2. RuVector PostgreSQL (if RUVECTOR_* env vars set - TB-scale, GNN search) + * 3. AgentDB from @claude-flow/memory (HNSW vector search) + * 4. JsonFileBackend (zero dependencies, always works) + * + * Proactive archiving: + * - UserPromptSubmit hook archives on every prompt, BEFORE context fills up + * - PreCompact hook is a safety net that catches any remaining unarchived turns + * - SessionStart hook restores context after compaction + * - Together, compaction becomes invisible — no information is ever lost * * Usage: - * node context-persistence-hook.mjs pre-compact # PreCompact: archive transcript - * node context-persistence-hook.mjs session-start # SessionStart: restore context - * node context-persistence-hook.mjs status # Show archive stats + * node context-persistence-hook.mjs pre-compact # PreCompact: archive transcript + * node context-persistence-hook.mjs session-start # SessionStart: restore context + * node context-persistence-hook.mjs user-prompt-submit # UserPromptSubmit: proactive archive + * node context-persistence-hook.mjs status # Show archive stats */ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'; diff --git a/agents/architect.yaml b/agents/architect.yaml index f1f9a18ad0..78b89418f4 100644 --- a/agents/architect.yaml +++ b/agents/architect.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - context-caching - memory-persistence -createdAt: "2026-02-10T15:53:35.198Z" +createdAt: "2026-02-10T16:05:57.889Z" diff --git a/agents/coder.yaml b/agents/coder.yaml index c5cb74b162..37ae41ccb6 100644 --- a/agents/coder.yaml +++ b/agents/coder.yaml @@ -8,4 +8,4 @@ capabilities: optimizations: - flash-attention - token-reduction -createdAt: "2026-02-10T15:53:35.198Z" +createdAt: "2026-02-10T16:05:57.889Z" diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml index d14e9075b8..f46ce849cd 100644 --- a/agents/reviewer.yaml +++ b/agents/reviewer.yaml @@ -7,4 +7,4 @@ capabilities: - best-practices optimizations: - incremental-analysis -createdAt: "2026-02-10T15:53:35.199Z" +createdAt: "2026-02-10T16:05:57.889Z" diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml index 597f80d2ef..a434888617 100644 --- a/agents/security-architect.yaml +++ b/agents/security-architect.yaml @@ -7,4 +7,4 @@ capabilities: - security-review optimizations: - pattern-matching -createdAt: "2026-02-10T15:53:35.198Z" +createdAt: "2026-02-10T16:05:57.889Z" diff --git a/agents/tester.yaml b/agents/tester.yaml index 7125febdbd..26369a05b2 100644 --- a/agents/tester.yaml +++ b/agents/tester.yaml @@ -7,4 +7,4 @@ capabilities: - coverage optimizations: - parallel-execution -createdAt: "2026-02-10T15:53:35.198Z" +createdAt: "2026-02-10T16:05:57.889Z"