brainiac-github 0.3.4 → 0.3.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: 49d9d73cefe9f24ff840f683ea53a4ff2276cbd89495037765dcc65fb3370fae
4
- data.tar.gz: 9de4f939b32f3f7c6f802d64e5a5280cc2de108fc771212b865bb17b8a12d21e
3
+ metadata.gz: 460a875b7a10748b20c7c446ca8c1ea3e1e7210a4c7f83582530fb02b5d2979e
4
+ data.tar.gz: 7a25fe851195a7b85eab61803ae1e7befaecf98192bf5b741ec1a1b40b04c7f5
5
5
  SHA512:
6
- metadata.gz: f3b54d02be22dbc9072aa3170a7073ef912b40f9555b5fdfde9a0cea3c4212fcf84c5e797026cdf094b1ef4e220804784a30361e64377e00470a785e6481d2e6
7
- data.tar.gz: 6cc367893d43b6276e141902e21b17e48c416a84c76e989bc0d34620223ee47b52fd02ec01650684e3adde7410d39ac42e9de8eeece11a895c43aea2e7d1b414
6
+ metadata.gz: 5ef1cdca60d2f6b38891954d4ceeb548ac362c1e3f8d872e4a3d359124ab8e7581f22ec011b6283e73f893d332ede1d49d4af91e3a6384861e20c66c8e5b34e3
7
+ data.tar.gz: 7066eab52546b19d6809dcfcab22af44e26a88f32fd2b28f43c11c490aef835eceac48310ea3acaeafcf00d77fef71c30a17fba94e05e68c59737c4741083850
data/README.md CHANGED
@@ -6,9 +6,11 @@ GitHub webhook plugin for [Brainiac](https://github.com/stowzilla/brainiac) —
6
6
 
7
7
  - **PR Reviews** — dispatches agents to address review feedback
8
8
  - **PR Comments** — routes PR conversation to the assigned agent
9
+ - **PR Opens / Pushes** — tracks new PRs against work items; redeploys ephemeral envs and emits hooks on new pushes
9
10
  - **PR Merges** — cleans up worktrees, emits hooks for card management plugins
10
- - **Workflow Runs** — notifies on CI failures and deploy completions
11
- - **Issues** — logs new issues for tracking
11
+ - **Workflow Runs** — matches workflows by name: `Deploy to Production` failure → notify; `Deploy to UAT` success → notify; `Deploy to Production` success → emits `:production_deployed`
12
+ - **Issues** — logs new issues (no dispatch)
13
+ - **Agent crashes** — posts a crash comment on the PR the agent was working on
12
14
 
13
15
  ## Installation
14
16
 
@@ -17,9 +19,12 @@ brainiac install github
17
19
  brainiac restart
18
20
  ```
19
21
 
22
+ Install creates `~/.brainiac/github.json` from `templates/github.json.example`
23
+ (or run `brainiac github setup` to create it later).
24
+
20
25
  ## Configuration
21
26
 
22
- Config lives at `~/.brainiac/github.json`:
27
+ Config lives at `~/.brainiac/github.json` (under `$BRAINIAC_DIR` if set):
23
28
 
24
29
  ```json
25
30
  {
@@ -110,7 +115,10 @@ identity — so the webhook-receiver app doubles as the brainiac agent's identit
110
115
 
111
116
  #### Step 2: Create Agent Identity Apps (One Per Agent)
112
117
 
113
- For each agent that should have its own avatar on PR comments:
118
+ For each agent that should have its own avatar on PR comments. This is still
119
+ manual: `brainiac agent create` (in Brainiac core) creates the agent, but this
120
+ plugin has no `on_agent_created` hook, so create the app and add its `apps` entry
121
+ yourself. `github.json` is re-read when it changes, so no restart is needed.
114
122
 
115
123
  1. Go to **Settings → Developer settings → GitHub Apps → New GitHub App**
116
124
  2. Set the following:
@@ -166,7 +174,21 @@ For each agent that should have its own avatar on PR comments:
166
174
  ```
167
175
 
168
176
  Each key in `apps` matches the agent's registry key (lowercase). The
169
- `installations` hash maps account/org names to their Installation IDs.
177
+ `installations` hash maps account/org names to their Installation IDs (a flat
178
+ `installation_id` also works for a single account).
179
+
180
+ #### Single-App Mode
181
+
182
+ Instead of `apps`, you can configure one shared app under `app` (the template's
183
+ default shape). It's used for any agent without an `apps` entry:
184
+
185
+ ```json
186
+ "app": {
187
+ "id": "100000",
188
+ "private_key_path": "~/.brainiac/github-app-private-key.pem",
189
+ "installation_id": "11111111"
190
+ }
191
+ ```
170
192
 
171
193
  #### Private Key Details
172
194
 
@@ -189,12 +211,14 @@ commit `.pem` files to version control.
189
211
 
190
212
  #### Fallback
191
213
 
192
- If no app credentials are configured for an agent, the plugin falls back to
193
- using the `gh` CLI (which authenticates as your personal GitHub account).
214
+ If no app credentials are configured for an agent (no `apps` entry, `app`
215
+ section, or env vars), the plugin falls back to using the `gh` CLI (which
216
+ authenticates as your personal GitHub account).
194
217
 
195
218
  ### Environment Variables
196
219
 
197
- As an alternative to config file values, you can set (applies to single-app mode only):
220
+ Used when the config file doesn't set the value. The `GITHUB_APP_*` variables
221
+ describe one shared app and are the last fallback after `apps.<agent>` and `app`:
198
222
 
199
223
  - `GITHUB_WEBHOOK_SECRET` — webhook signature secret
200
224
  - `GITHUB_APP_ID` — GitHub App ID
@@ -215,19 +239,21 @@ avoid duplicate event deliveries.
215
239
  ## CLI
216
240
 
217
241
  ```bash
218
- brainiac github setup # Create config file from template
219
- brainiac github config # Show current configuration
220
- brainiac github status # Check if webhook endpoint is active
242
+ brainiac github setup # Create config file from template (if missing)
243
+ brainiac github config # Show webhook secret, repos, and shared `app` credentials
244
+ brainiac github status # Check the Brainiac server is up (POST /github active)
221
245
  ```
222
246
 
223
247
  ## Hooks Emitted
224
248
 
225
249
  | Hook | When | Payload |
226
250
  |------|------|---------|
251
+ | `:pr_opened` | PR opened on a tracked work item branch | card_number, pr_number, repo_name, branch, base_branch, ... |
227
252
  | `:pr_merged` | PR merged to default branch | card_number, pr_url, project_key, ... |
253
+ | `:pr_merged_to_branch` | Any merge of a `fizzy-<n>-…` branch (incl. epic branches) | card_number, branch, base_branch, pr_url, ... |
228
254
  | `:pr_review_received` | Review submitted | card_number, reviewer, agent_name, ... |
229
- | `:pr_synchronized` | PR updated (force push) | card_number, worktree, branch, ... |
230
- | `:production_deployed` | Deploy workflow succeeds | project_key, project_config |
255
+ | `:pr_synchronized` | New commits pushed to a PR | card_number, worktree, branch, ... |
256
+ | `:production_deployed` | `Deploy to Production` workflow succeeds | project_key, project_config |
231
257
 
232
258
  ## Development
233
259
 
@@ -810,7 +810,8 @@ module Brainiac
810
810
  pid, log_file = run_agent(prompt, **run_agent_opts)
811
811
  return unless pid
812
812
 
813
- register_session(card_key, pid, log_file: log_file, agent_name: agent_name)
813
+ register_session(card_key, pid, log_file: log_file, agent_name: agent_name,
814
+ title: "PR ##{pr_number}: #{comment_body}")
814
815
  end
815
816
 
816
817
  def dispatch_pr_review(card_number, card_key, card_info, pr_number, review, reviewer,
@@ -862,7 +863,8 @@ module Brainiac
862
863
  pid, log_file = run_agent(prompt, **run_agent_opts)
863
864
  return unless pid
864
865
 
865
- register_session(card_key, pid, log_file: log_file, agent_name: agent_name)
866
+ register_session(card_key, pid, log_file: log_file, agent_name: agent_name,
867
+ title: "PR ##{pr_number} review: #{review["body"]}")
866
868
  end
867
869
 
868
870
  # run_agent options for the CLI provider, model, effort and profile of a dispatch.
@@ -3,7 +3,7 @@
3
3
  module Brainiac
4
4
  module Plugins
5
5
  module Github
6
- VERSION = "0.3.4"
6
+ VERSION = "0.3.5"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainiac-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Davis
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.0.14
18
+ version: 0.7.1
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 0.0.14
25
+ version: 0.7.1
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: jwt
28
28
  requirement: !ruby/object:Gem::Requirement