brainiac 0.0.5 → 0.0.7

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +136 -6
  4. data/bin/brainiac +385 -19
  5. data/bin/brainiac-completion.bash +1 -1
  6. data/lib/brainiac/agents.rb +15 -38
  7. data/lib/brainiac/config.rb +40 -11
  8. data/lib/brainiac/handlers/discord/api.rb +196 -0
  9. data/lib/brainiac/handlers/discord/config.rb +134 -0
  10. data/lib/brainiac/handlers/discord/delivery.rb +196 -0
  11. data/lib/brainiac/handlers/discord/gateway.rb +212 -0
  12. data/lib/brainiac/handlers/discord/message.rb +933 -0
  13. data/lib/brainiac/handlers/discord/reactions.rb +215 -0
  14. data/lib/brainiac/handlers/discord.rb +14 -1892
  15. data/lib/brainiac/handlers/fizzy/assignment.rb +125 -0
  16. data/lib/brainiac/handlers/fizzy/comments.rb +730 -0
  17. data/lib/brainiac/handlers/fizzy/dedup.rb +74 -0
  18. data/lib/brainiac/handlers/fizzy/deploy.rb +152 -0
  19. data/lib/brainiac/{deployments.rb → handlers/fizzy/deployments.rb} +4 -2
  20. data/lib/brainiac/handlers/fizzy.rb +12 -1290
  21. data/lib/brainiac/handlers/github.rb +149 -212
  22. data/lib/brainiac/handlers/shared/git.rb +203 -0
  23. data/lib/brainiac/handlers/shared/inline_tags.rb +89 -0
  24. data/lib/brainiac/handlers/zoho.rb +79 -76
  25. data/lib/brainiac/helpers.rb +2 -121
  26. data/lib/brainiac/planning.rb +2 -2
  27. data/lib/brainiac/plugins.rb +129 -0
  28. data/lib/brainiac/restart.rb +94 -0
  29. data/lib/brainiac/routes/api.rb +427 -0
  30. data/lib/brainiac/version.rb +1 -1
  31. data/lib/brainiac/zoho_mail_api.rb +2 -1
  32. data/lib/brainiac.rb +7 -0
  33. data/monitor/daemon.rb +4 -27
  34. data/monitor/shared.rb +247 -0
  35. data/monitor/{waybar-deploy-env.rb → waybar/deploy_env.rb} +14 -86
  36. data/monitor/waybar/setup.rb +232 -0
  37. data/monitor/waybar/status.rb +51 -0
  38. data/monitor/{view-logs-rofi.rb → waybar/view_logs.rb} +21 -88
  39. data/monitor/{deploy-env-macos.rb → xbar/deploy_env.rb} +3 -2
  40. data/monitor/xbar/plugin.rb +155 -0
  41. data/monitor/{setup-menubar.rb → xbar/setup.rb} +14 -30
  42. data/receiver.rb +91 -450
  43. data/templates/brainiac.json.example +9 -0
  44. data/templates/cli-providers/kiro.json.example +8 -2
  45. data/templates/plugins.json.example +3 -0
  46. metadata +30 -20
  47. data/lib/user_registry.rb +0 -159
  48. data/monitor/menubar.rb +0 -295
  49. data/monitor/setup-waybar-deploy-envs.rb +0 -121
  50. data/monitor/setup-waybar-deployments.rb +0 -96
  51. data/monitor/setup-waybar-module.rb +0 -113
  52. data/monitor/setup-xbar-plugin.rb +0 -35
  53. data/monitor/view-logs.rb +0 -119
  54. data/monitor/waybar-config-updater.rb +0 -56
  55. data/monitor/waybar-deployments.rb +0 -239
  56. data/monitor/waybar.rb +0 -146
  57. data/monitor/xbar.3s.rb +0 -179
  58. /data/lib/brainiac/{card_index.rb → handlers/fizzy/card_index.rb} +0 -0
  59. /data/monitor/{open-action.sh → xbar/open_action.sh} +0 -0
  60. /data/monitor/{view-logs-macos.rb → xbar/view_logs.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d349dd4297beb2e1970aaff969c468ea088cc58142391e738f0dbefa7736fcb
4
- data.tar.gz: 79b008e8823b2c4289f48a4356e4bd9271c5d3564518ec9bd42f24c460870822
3
+ metadata.gz: 6fa0fbfcf61f48755a21588273779a67326f98b7be00eaa187573ec35366f80e
4
+ data.tar.gz: 8cb76479c7fe1ddd5961600a11cf5d9c63b8e7b31dddb4fed24584836e5772fa
5
5
  SHA512:
6
- metadata.gz: c2c7b7448242a508c1cbb3d58c1d4a8cea72218d886fc2db60c9c5a2913ad8737300ef3cd897a44333af4cbad44dc92d046f8e3ca20cb792edb552868ea6a4d4
7
- data.tar.gz: b0a838dbd6b1ab90f65004cc4f420eb87632c2a8e60ee95e456f9e6bede3a7184a1130981740024166936730eb7df5ff4d7a3365d65315d7e3a871514b9b6d72
6
+ metadata.gz: 125e924e7e697358aee58aca6b81893e9c418cce718e35b4236a6d45c44c0b2899ccbefb978e279819e3355aaca3598794cdc89025ebce1f07dd9dba60f706e9
7
+ data.tar.gz: d6f2c642bf78db0de88e36f7dcf7d3d6194f4f66a453d5219940ef259d942cbb03a723ad13db97d6bff751124596602a1a47e29dc5352f3b88349e990ab27dc3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- brainiac (0.0.5)
4
+ brainiac (0.0.7)
5
5
  puma (~> 7.2)
6
6
  rackup (~> 2.3)
7
7
  sinatra (~> 4.1)
@@ -90,7 +90,7 @@ DEPENDENCIES
90
90
  CHECKSUMS
91
91
  ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
92
92
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
93
- brainiac (0.0.5)
93
+ brainiac (0.0.7)
94
94
  event_emitter (0.2.6) sha256=c72697bd5cce9d36594be1972c17f1c9a573236f44303a4d1d548080364e1391
95
95
  json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
96
96
  language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
data/README.md CHANGED
@@ -136,6 +136,16 @@ brainiac setup
136
136
 
137
137
  This creates the `~/.brainiac/` directory structure and copies example config files. Then edit the configs with your actual secrets and IDs (see below).
138
138
 
139
+ Optionally, install handler plugins for additional integrations:
140
+
141
+ ```bash
142
+ brainiac install whatsapp # WhatsApp Business API
143
+ brainiac install slack # Slack (when available)
144
+ brainiac restart # Restart to activate
145
+ ```
146
+
147
+ See [Plugins](#plugins-gem-based-handlers) for details.
148
+
139
149
  ### Prerequisites
140
150
 
141
151
  | Dependency | Required | Install |
@@ -211,7 +221,7 @@ kiro-cli agent create # Interactive
211
221
 
212
222
  The `webhook_secret` verifies incoming GitHub webhook requests. Generate one with `ruby -rsecurerandom -e 'puts SecureRandom.hex(20)'`.
213
223
 
214
- **Legacy:** `GITHUB_WEBHOOK_SECRET` env var works as fallback.
224
+ `GITHUB_WEBHOOK_SECRET` env var works as fallback.
215
225
 
216
226
  #### 4. Fizzy (`~/.brainiac/fizzy.json`)
217
227
 
@@ -246,10 +256,16 @@ When a human is @mentioned on a card assigned to an agent, the agent will skip t
246
256
 
247
257
  #### 5. Environment Variables
248
258
 
249
- Most config lives in JSON files now. The only env var you might want:
259
+ Most config lives in JSON files now. The default agent is set in `brainiac.json`:
260
+
261
+ ```json
262
+ { "default_agent": "Galen" }
263
+ ```
264
+
265
+ Or via environment variable (takes precedence):
250
266
 
251
267
  ```bash
252
- export AI_AGENT_NAME="Galen" # Defaults to Galen (Linux) or Kaylee (macOS)
268
+ export AI_AGENT_NAME="Galen"
253
269
  ```
254
270
 
255
271
  #### 6. Register Projects
@@ -362,8 +378,6 @@ The `local` flag controls which agents pick up card assignments on this machine.
362
378
 
363
379
  Agents without an `env` block (like Kaylee above on a Linux box) still appear in the agent roster so local agents spell @mentions correctly.
364
380
 
365
- A legacy format with top-level `fizzy_token` / `discord_bot_token` keys is auto-migrated into the `env` hash at load time. A legacy `~/.brainiac/agent_tokens.json` format (flat `{ "galen": "token" }`) is supported as a fallback and auto-migrated.
366
-
367
381
  The registry reloads on every webhook and via `POST /api/reload`.
368
382
 
369
383
  ### Step 3: Seed Agent Persona and Knowledge
@@ -413,7 +427,7 @@ Agents also update knowledge themselves during sessions (when they learn somethi
413
427
  ### Step 4: Initialize Each Agent's Brain
414
428
 
415
429
  ```bash
416
- brainiac brain init # Default agent (Galen on Linux, Kaylee on macOS)
430
+ brainiac brain init # Default agent (from brainiac.json or AI_AGENT_NAME)
417
431
  brainiac brain init SecurityBot # Additional agent
418
432
  brainiac brain list # Verify all agents
419
433
  ```
@@ -946,6 +960,113 @@ The `hook_secret` is auto-captured from Zoho's initial handshake request — no
946
960
 
947
961
  **Requires:** Discord integration must be enabled (at least one agent with a `DISCORD_BOT_TOKEN`).
948
962
 
963
+ ## Plugins (Gem-Based Handlers)
964
+
965
+ Brainiac supports a plugin system that lets you extend functionality via Ruby gems. Instead of dropping handler files into `~/.brainiac/handlers/`, you install gems named `brainiac-<name>` that register themselves automatically at server startup.
966
+
967
+ ### Installing Plugins
968
+
969
+ ```bash
970
+ brainiac install whatsapp # Installs brainiac-whatsapp gem + registers it
971
+ brainiac install slack # Installs brainiac-slack gem + registers it
972
+ brainiac restart # Restart server to load new plugins
973
+ ```
974
+
975
+ This runs `gem install brainiac-<name>`, adds the plugin to `~/.brainiac/plugins.json`, and enables the handler.
976
+
977
+ You can also install a specific version:
978
+
979
+ ```bash
980
+ brainiac install whatsapp --version 0.2.0
981
+ ```
982
+
983
+ ### Managing Plugins
984
+
985
+ ```bash
986
+ brainiac plugins # List installed plugins with status
987
+ brainiac uninstall <name> # Remove plugin from config (gem stays installed)
988
+ ```
989
+
990
+ To fully remove the gem after uninstalling:
991
+
992
+ ```bash
993
+ brainiac uninstall whatsapp
994
+ gem uninstall brainiac-whatsapp
995
+ ```
996
+
997
+ ### Configuration
998
+
999
+ Installed plugins are tracked in `~/.brainiac/plugins.json`:
1000
+
1001
+ ```json
1002
+ {
1003
+ "plugins": [
1004
+ { "name": "whatsapp", "gem": "brainiac-whatsapp", "installed_at": "2026-06-30T14:00:00-04:00" }
1005
+ ]
1006
+ }
1007
+ ```
1008
+
1009
+ At server startup, `load_plugins!` iterates this list, requires each gem, and calls `.register(app)`.
1010
+
1011
+ ### Creating a Plugin
1012
+
1013
+ Any Ruby gem named `brainiac-<name>` can be a Brainiac plugin. The gem must:
1014
+
1015
+ 1. **Define a module** at `Brainiac::Plugins::<Name>`
1016
+ 2. **Implement `.register(app)`** — receives the Sinatra app instance for defining routes and starting threads
1017
+
1018
+ Example plugin structure:
1019
+
1020
+ ```
1021
+ brainiac-whatsapp/
1022
+ ├── lib/
1023
+ │ ├── brainiac-whatsapp.rb # Gem entry point (loaded by RubyGems)
1024
+ │ └── brainiac/plugins/whatsapp/
1025
+ │ ├── whatsapp.rb # Main module with .register(app)
1026
+ │ ├── version.rb
1027
+ │ ├── config.rb
1028
+ │ ├── handler.rb
1029
+ │ └── messages.rb
1030
+ ├── brainiac-whatsapp.gemspec
1031
+ └── test/
1032
+ ```
1033
+
1034
+ Example `.register(app)` implementation:
1035
+
1036
+ ```ruby
1037
+ module Brainiac
1038
+ module Plugins
1039
+ module Whatsapp
1040
+ def self.register(app)
1041
+ app.get "/whatsapp" do
1042
+ # Webhook verification
1043
+ end
1044
+
1045
+ app.post "/whatsapp" do
1046
+ # Handle incoming messages
1047
+ end
1048
+
1049
+ Thread.new { start_background_poller }
1050
+ end
1051
+ end
1052
+ end
1053
+ end
1054
+ ```
1055
+
1056
+ Plugins have full access to the Sinatra app — they can define routes, start background threads, access shared constants (`LOG`, `BRAINIAC_DIR`, etc.), and use all core Brainiac modules (agents, brain, sessions, etc.).
1057
+
1058
+ The `Brainiac::Plugins` namespace is defined in `lib/brainiac.rb`. Plugin module resolution is flexible — it tries PascalCase first (e.g., `whatsapp` → `Whatsapp`) and falls back to case-insensitive matching.
1059
+
1060
+ ### Available Plugins
1061
+
1062
+ | Plugin | Gem | Description |
1063
+ |--------|-----|-------------|
1064
+ | whatsapp | `brainiac-whatsapp` | WhatsApp Business API integration |
1065
+
1066
+ ### Backward Compatibility
1067
+
1068
+ The old `~/.brainiac/handlers/*.rb` drop-in system still works. Custom handler files are loaded before gem plugins. Over time, built-in handlers (Discord, Fizzy, GitHub) may be extracted into their own gems.
1069
+
949
1070
  ## Version Check
950
1071
 
951
1072
  On startup, Brainiac checks if the local repo is behind `origin/master`. If it detects the local version is outdated, it logs a warning. This helps ensure agents are always running the latest code.
@@ -993,6 +1114,15 @@ brainiac brain search --persona <query> # Search agent persona
993
1114
  brainiac brain list # List everything
994
1115
  ```
995
1116
 
1117
+ ### Plugins
1118
+
1119
+ ```bash
1120
+ brainiac install <name> # Install a plugin gem (e.g., whatsapp)
1121
+ brainiac install <name> --version 0.2.0 # Install specific version
1122
+ brainiac uninstall <name> # Remove plugin from config
1123
+ brainiac plugins # List installed plugins
1124
+ ```
1125
+
996
1126
  ## Project Configuration
997
1127
 
998
1128
  Projects are stored in `~/.brainiac/projects.json`: