Class: ClaudeMemory::Hook::ContextInjector
- Inherits:
-
Object
- Object
- ClaudeMemory::Hook::ContextInjector
- Defined in:
- lib/claude_memory/hook/context_injector.rb
Overview
Generates context for SessionStart hook injection. Queries both global and project databases for key facts and formats them as concise context for Claude.
Constant Summary collapse
- MAX_DECISIONS =
5- MAX_CONVENTIONS =
5- MAX_ARCHITECTURE =
5- MAX_UNDISTILLED =
3- MAX_TEXT_PER_ITEM =
1500- FRESH_SESSION_SOURCES =
%w[startup resume clear].freeze
- QUERIES =
{ decisions: {query: "decision constraint rule requirement", scope: "all"}, conventions: {query: "convention style format pattern prefer", scope: "all"}, architecture: {query: "uses framework implements architecture pattern", scope: "all"} }.freeze
Instance Method Summary collapse
- #generate_context ⇒ Object
-
#initialize(manager, source: nil) ⇒ ContextInjector
constructor
A new instance of ContextInjector.
Constructor Details
#initialize(manager, source: nil) ⇒ ContextInjector
Returns a new instance of ContextInjector.
23 24 25 26 27 |
# File 'lib/claude_memory/hook/context_injector.rb', line 23 def initialize(manager, source: nil) @manager = manager @source = source @recall = Recall.new(manager) end |
Instance Method Details
#generate_context ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/claude_memory/hook/context_injector.rb', line 29 def generate_context sections = [] decisions = fetch(:decisions, MAX_DECISIONS) sections << format_section("Decisions", decisions) if decisions.any? conventions = fetch(:conventions, MAX_CONVENTIONS) sections << format_section("Conventions", conventions) if conventions.any? architecture = fetch(:architecture, MAX_ARCHITECTURE) sections << format_section("Architecture", architecture) if architecture.any? if fresh_session? undistilled = fetch_undistilled(MAX_UNDISTILLED) sections << format_distillation_prompt(undistilled) if undistilled.any? end return nil if sections.empty? sections.join("\n") end |