Class: ClaudeMemory::Dashboard::Knowledge
- Inherits:
-
Object
- Object
- ClaudeMemory::Dashboard::Knowledge
- Defined in:
- lib/claude_memory/dashboard/knowledge.rb
Overview
Groups active facts into the categories a human cares about: decisions, conventions/principles, quality guards, architecture, and hard constraints. This is the bridge between internal predicate vocabulary and the value categories the user expects to see —“what decisions has Claude learned?” not “show me facts where predicate=‘decision’”.
Quality guards are a heuristic split inside the conventions section: convention-predicate facts whose object text starts with a prohibitive or imperative (“Never”, “Always”, “Must”, “Do not”, “Don’t”). These are the rules that catch mistakes, not just describe preferences.
Constant Summary collapse
- QUALITY_GUARD_RE =
/\A\s*(never|always|must|do not|don't)\b/i- SECTIONS =
Order matches how they appear in the UI — decisions first (highest signal to a skeptical reader), references last (study notes about external projects, kept distinct from conventions the user applies).
[ {key: :decisions, label: "Decisions", description: "Explicit choices with a reason"}, {key: :quality_guards, label: "Quality guards", description: "Rules that prevent mistakes"}, {key: :conventions, label: "Conventions & principles", description: "Style, patterns, preferences"}, {key: :architecture, label: "Architecture", description: "Structural knowledge"}, {key: :constraints, label: "Constraints", description: "Hard tech-stack facts"}, {key: :references, label: "References", description: "Study notes about external projects"} ].freeze
- TOP_PER_SECTION =
6
Instance Method Summary collapse
-
#initialize(manager) ⇒ Knowledge
constructor
A new instance of Knowledge.
- #summary(params = {}) ⇒ Object
Constructor Details
#initialize(manager) ⇒ Knowledge
Returns a new instance of Knowledge.
33 34 35 |
# File 'lib/claude_memory/dashboard/knowledge.rb', line 33 def initialize(manager) @manager = manager end |
Instance Method Details
#summary(params = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/claude_memory/dashboard/knowledge.rb', line 42 def summary(params = {}) scope = params["scope"] || "all" limit = (params["limit"] || TOP_PER_SECTION).to_i section_filter = params["section"]&.to_sym rows = collect_rows(scope) sections = SECTIONS.map do || all_in_section = rows.select { |r| classify_row(r[:fact]) == [:key] } shown = section_filter ? all_in_section : all_in_section.first(limit) { key: [:key], label: [:label], description: [:description], count: all_in_section.size, facts: shown.map { |r| r[:presented] } } end if section_filter sections = sections.select { |s| s[:key] == section_filter } end { scope: scope, section: section_filter, totals: { project: count_for_scope("project"), global: count_for_scope("global") }, sections: sections } end |