brainiac 0.4.0 → 0.4.1

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: 1e2fc609dfdad411c1262f53783c3d6d88de4dbb75c83ccb9cedf6b935555a42
4
- data.tar.gz: 6c7f6aed1727d45ba3bd953554598a20222c3ed47a81879b66108fbe2e7abb98
3
+ metadata.gz: 1edc9fb64e331daacfa390596ce230ee37f6739e91efc72438434110e88d24de
4
+ data.tar.gz: 0fdf11e2eace81f2ce56f6f562e675d7c67598232a23b020fcc982f7ac20db58
5
5
  SHA512:
6
- metadata.gz: 68db7910a0cca76489408685a40f1fe549eaa6462ddefad4b532160b2ef8bd80c798a79b84c4daaeb538e52cc4df3412fca8f61862c39d94a49e9c080cb83e95
7
- data.tar.gz: ab36e6f636e4ac76b28bfa55a418d1c00f2251adc36663e9fe21786150d3a27aa7d870bf4c225ffc47303873af38c76ed7601166be9d9ce88a2f30e372770e3b
6
+ metadata.gz: ca3e17f678f0207947da8fda7af7711788cacdf377e2496b04c82a1aed303faa3cc57e6c3b32be3227a98bc12b86bb28b25d523ab817514b396a249955cc226a
7
+ data.tar.gz: 2cab777438aa1b245b037a46f6fdf9dcfe16120eca888528dd045f7e70fed699c850bfe76b858601f9f7708a61c213f3be96cb4173a3f2fae81d83f7f4fcc36b
data/bin/brainiac CHANGED
@@ -668,6 +668,9 @@ def generate_plugin_skill_md(plugin_name, pascal_name)
668
668
  | `:create_work_item` | Create card/issue/ticket |
669
669
  | `:detect_cli_provider` | Detect CLI provider |
670
670
  | `:detect_effort` | Detect effort level |
671
+ | `:agent_added` | New agent in agents.json (after reload) |
672
+ | `:agent_updated` | Existing agent's entry changed (after reload) |
673
+ | `:agent_removed` | Agent removed from agents.json (after reload) |
671
674
 
672
675
  ## Agent Onboarding (`on_agent_created`)
673
676
 
@@ -731,6 +734,13 @@ def generate_plugin_skill_md(plugin_name, pascal_name)
731
734
  asked during create). Core filters on the plugin name before calling you, so
732
735
  plugins don't need to handle this.
733
736
 
737
+ **Going live without a restart.** `agent create` / `agent setup` tell the running
738
+ server to reload `agents.json`. The server may already have seen the agent before
739
+ your hook wrote its token, so a server-side plugin that starts something per agent
740
+ (a gateway connection, a poller) must handle `:agent_updated` as well as
741
+ `:agent_added`: start it when the credential appears or changes, stop it when it's
742
+ removed.
743
+
734
744
  ## Channel Prompts
735
745
 
736
746
  For communication channel plugins:
@@ -2606,8 +2616,12 @@ when "agent"
2606
2616
  notify_plugins_agent_created(agent_key, agent_hook_payload(agent_key, entry, open_browser: open_browser),
2607
2617
  skip: skip_plugins, only: only_plugins, confirm: confirm)
2608
2618
  if skip_plugins.any? && entry["skip_plugins"] != skip_plugins.uniq
2609
- entry["skip_plugins"] = skip_plugins.uniq
2610
- registry[agent_key] = entry
2619
+ # Re-read: the plugin hooks above wrote their tokens (DISCORD_BOT_TOKEN,
2620
+ # FIZZY_TOKEN, ...) into agents.json, and the copy we loaded at the start
2621
+ # would clobber them.
2622
+ registry = JSON.parse(File.read(agent_registry_file))
2623
+ registry[agent_key] ||= entry
2624
+ registry[agent_key]["skip_plugins"] = skip_plugins.uniq
2611
2625
  File.write(agent_registry_file, JSON.pretty_generate(registry))
2612
2626
  puts " Skipping #{skip_plugins.uniq.join(", ")} for #{name} (undo: brainiac agent setup #{agent_key} --only <plugin>)"
2613
2627
  end
@@ -50,6 +50,7 @@ AGENT_REGISTRY = load_agent_registry
50
50
  def reload_agent_registry!(force: false)
51
51
  return unless file_changed?(AGENT_REGISTRY_FILE, force: force)
52
52
 
53
+ old_registry = AGENT_REGISTRY.dup
53
54
  old_keys = AGENT_REGISTRY.keys.to_set
54
55
  AGENT_REGISTRY.replace(load_agent_registry)
55
56
  new_keys = AGENT_REGISTRY.keys.to_set
@@ -70,6 +71,17 @@ def reload_agent_registry!(force: false)
70
71
  LOG.info "Agent removed: #{key}"
71
72
  Brainiac.emit(:agent_removed, agent_key: key)
72
73
  end
74
+
75
+ # Agents that already existed but whose entry changed — e.g. `agent create`
76
+ # wrote the entry first and a plugin added its token a few seconds later.
77
+ (old_keys & new_keys).each do |key|
78
+ entry = AGENT_REGISTRY[key]
79
+ next if entry == old_registry[key]
80
+
81
+ display_name = entry.is_a?(Hash) ? (entry["display_name"] || key.capitalize) : key.capitalize
82
+ Brainiac.emit(:agent_updated, agent_key: key, display_name: display_name, entry: entry,
83
+ previous_entry: old_registry[key])
84
+ end
73
85
  end
74
86
 
75
87
  # Default environment for all agent processes. Prevents git from hanging
@@ -11,6 +11,7 @@
11
11
  # :agent_completed — After an agent session finishes (success or failure)
12
12
  # :agent_added — When a new agent appears in the registry (after reload)
13
13
  # :agent_removed — When an agent is removed from the registry (after reload)
14
+ # :agent_updated — When an existing agent's entry changes (after reload; has :previous_entry)
14
15
  # :pr_merged — After a GitHub PR is merged
15
16
  # :pr_opened — After a GitHub PR is opened
16
17
  # :pr_reviewed — After a PR review is submitted
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Brainiac
4
4
  # @return [String] the current gem version
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
6
6
  end
@@ -109,6 +109,9 @@ Available hooks:
109
109
  | `:create_work_item` | Create a card/issue/ticket | title, body, project |
110
110
  | `:detect_cli_provider` | Detect CLI provider | metadata hash |
111
111
  | `:detect_effort` | Detect effort level | metadata hash |
112
+ | `:agent_added` | New key in agents.json (after reload) | agent_key, display_name, entry |
113
+ | `:agent_updated` | Existing agent's entry changed (after reload) | agent_key, display_name, entry, previous_entry |
114
+ | `:agent_removed` | Key gone from agents.json (after reload) | agent_key |
112
115
 
113
116
  ## Agent Onboarding (`on_agent_created`)
114
117
 
@@ -172,6 +175,13 @@ Users choose which plugins run with `--skip` / `--only` (or by answering "n" whe
172
175
  asked during create). Core filters on the plugin name before calling you, so
173
176
  plugins don't need to handle this.
174
177
 
178
+ **Going live without a restart.** `agent create` / `agent setup` tell the running
179
+ server to reload `agents.json`. The server may already have seen the agent before
180
+ your hook wrote its token, so a server-side plugin that starts something per agent
181
+ (a gateway connection, a poller) must handle `:agent_updated` as well as
182
+ `:agent_added`: start it when the credential appears or changes, stop it when it's
183
+ removed.
184
+
175
185
  ## Channel Prompts
176
186
 
177
187
  If your plugin is a communication channel (like Discord, Fizzy), register a prompt:
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis