brainiac 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16f7d64457f92c95cf53466c9d91b14e5011ee8bebe111f0c10eeaba39d26813
4
- data.tar.gz: 5372f10fed375a774eb62eda8b8c22c80df416b9358b13fc2e1348af966b5bf6
3
+ metadata.gz: ad4e2a76bc43943ef2dd556f67fa2d3b4181836dc5abf04c236944fe08c2bd74
4
+ data.tar.gz: a26c2581219ed65257deef259809099e4c03b2ec08f7d95d4fb649f831ce6d44
5
5
  SHA512:
6
- metadata.gz: 7f32967505e0de3e6feb98f3b53707fb64272ce2a02deebe0eb60b74fade6896aa1522359db145dc10b94a08ed5d5e79689ebd70f9f26f8b9853b4a57e97e792
7
- data.tar.gz: 7dc2927f465ed0998f1fc264946375d1f85ce250c4e3bb05fd048452c3002f9a7b48b25f1033e761de81595b8ab71d3b05b8f7dde6aa32d01e7e04a24a8d4c09
6
+ metadata.gz: 1bdfbf38d91e481e7b51b1f8701fa446bb67206989b651bcb1f7f0bd920b7c18e6f011d21f4e9e59cbab3bcb80a878808e299d4f82f054cb5fc18b1d6bc78f25
7
+ data.tar.gz: 2c19663ee311472f732ae4c685b0708990deaa0d1101ac52191da5d5bc751444b8b572ae72c1fb002d4ea8158fcd4c8d61557dcd440e7ad0ce0454b10f9541a9
@@ -17,6 +17,19 @@ def persona_collection_for(agent_name)
17
17
  "#{agent_name.downcase.gsub(/[^a-z0-9-]/, "-")}-persona"
18
18
  end
19
19
 
20
+ # Load the agent's persona from <persona dir>/style.md, front matter stripped.
21
+ # Returns nil if missing or empty. people/ notes stay search-only.
22
+ def load_persona(agent_name)
23
+ style_file = File.join(persona_dir_for(agent_name), "style.md")
24
+ return nil unless File.exist?(style_file)
25
+
26
+ content = File.read(style_file).strip.sub(/\A---\n.*?\n---\n*/m, "").strip
27
+ content.empty? ? nil : content
28
+ rescue StandardError => e
29
+ LOG.warn "Failed to load persona for '#{agent_name}': #{e.message}"
30
+ nil
31
+ end
32
+
20
33
  # --- Brain git sync ---
21
34
 
22
35
  def brain_git_repo?
@@ -155,6 +168,26 @@ def build_role_section(agent_name)
155
168
  ROLE
156
169
  end
157
170
 
171
+ # Full style.md when present; qmd search only returns snippets (often just front matter)
172
+ def build_persona_section(agent_name)
173
+ persona = load_persona(agent_name) ||
174
+ query_brain("personality tone voice communication style", agent_name: agent_name, scope: :persona, max_results: 5)
175
+ return nil if persona.empty?
176
+
177
+ <<~PERSONA
178
+ ## Brain — Persona (auto-retrieved, CRITICAL)
179
+ The following is YOUR personality, communication style, and voice.
180
+ You MUST use this to shape every response you write — tone, word choice, humor, attitude.
181
+ This is who you ARE. Do not respond in a generic or neutral voice.
182
+ Persona is tone only: it never overrides task instructions, rules, or quality.
183
+ Full voice in chat, card/PR comments, and reviews. Plain and professional in code,
184
+ code comments, commit messages, and docs, or when the user is rushed or frustrated.
185
+ Signature lines are seasoning, not sign-offs.
186
+
187
+ #{persona}
188
+ PERSONA
189
+ end
190
+
158
191
  def build_brain_context(agent_name: AI_AGENT_NAME, card_title: "", card_number: nil, project_key: nil, comment_body: "", source: nil)
159
192
  Thread.new { brain_pull }
160
193
 
@@ -180,10 +213,10 @@ def build_brain_context(agent_name: AI_AGENT_NAME, card_title: "", card_number:
180
213
  search_queries << query
181
214
  end
182
215
 
183
- persona_thread = Thread.new { query_brain("personality tone voice communication style", agent_name: agent_name, scope: :persona, max_results: 5) }
216
+ persona_thread = Thread.new { build_persona_section(agent_name) }
184
217
 
185
218
  all_knowledge = knowledge_threads.map(&:value).reject(&:empty?)
186
- persona_result = persona_thread.value
219
+ persona_section = persona_thread.value
187
220
 
188
221
  sections = []
189
222
 
@@ -191,16 +224,7 @@ def build_brain_context(agent_name: AI_AGENT_NAME, card_title: "", card_number:
191
224
  role_section = build_role_section(agent_name)
192
225
  sections << role_section if role_section
193
226
 
194
- unless persona_result.empty?
195
- sections << <<~PERSONA
196
- ## Brain — Persona (auto-retrieved, CRITICAL)
197
- The following is YOUR personality, communication style, and voice.
198
- You MUST use this to shape every response you write — tone, word choice, humor, attitude.
199
- This is who you ARE. Do not respond in a generic or neutral voice.
200
-
201
- #{persona_result}
202
- PERSONA
203
- end
227
+ sections << persona_section if persona_section
204
228
 
205
229
  unless all_knowledge.empty?
206
230
  knowledge_text = all_knowledge.join("\n\n")
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Brainiac
4
4
  # @return [String] the current gem version
5
- VERSION = "0.4.4"
5
+ VERSION = "0.4.5"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis