@brokkai/bug-bot 0.1.0

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 (4) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +194 -0
  3. package/bin/bbb.cjs +49 -0
  4. package/package.json +33 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # Brokk Bug Bot
2
+
3
+ Find new bugs in a repository and file useful GitHub issues. `bbb` follows the
4
+ same Go CLI, no-config discovery, managed workspace, and shared
5
+ [ACP runner](https://github.com/BrokkAi/acp-go) pattern as
6
+ [issue-bot](https://github.com/BrokkAi/issue-bot) (`bib`) and
7
+ [release-bot](https://github.com/BrokkAi/release-bot) (`brb`).
8
+
9
+ **The LLM decides whether a finding duplicates an existing issue.** It compares
10
+ root causes, triggering inputs, behavior, and discussion across open and closed
11
+ issues. There are no title similarity thresholds or bug fingerprint rules.
12
+
13
+ ## Install and run
14
+
15
+ Install with npm (Node.js 18+; no Go toolchain required):
16
+
17
+ ```sh
18
+ npm install -g @brokkai/bug-bot
19
+ bbb /path/to/your-repo
20
+ ```
21
+
22
+ For a single invocation, use `npx --yes @brokkai/bug-bot`. Keep npm optional
23
+ dependencies enabled: they supply the native Linux/macOS x64 or arm64 binary.
24
+
25
+ Or install a native binary with its SHA-256 checksum verified:
26
+
27
+ ```sh
28
+ curl -fsSL https://raw.githubusercontent.com/BrokkAi/bug-bot/master/install.sh | sh
29
+ ```
30
+
31
+ The installer puts `bbb` in `~/.local/bin`; add that directory to `PATH`.
32
+ Set `INSTALL_DIR` to change the destination. To pin a version, download the
33
+ script and run `sh install.sh v0.1.0`.
34
+
35
+ With Go 1.27.1 or newer:
36
+
37
+ ```sh
38
+ go install github.com/BrokkAi/bug-bot/cmd/bbb@latest
39
+ ```
40
+
41
+ Go installs `bbb` in `GOBIN`, or `$(go env GOPATH)/bin` by default.
42
+ From a source checkout:
43
+
44
+ ```sh
45
+ make build
46
+ ./bin/bbb /path/to/your-repo
47
+ ./bin/bbb once /path/to/your-repo --dry-run
48
+ ./bin/bbb once /path/to/your-repo --focus "parser and input validation"
49
+ ./bin/bbb /path/to/your-repo --max-issues 2 --label bug
50
+ ./bin/bbb /path/to/your-repo --model YOUR_MODEL_ID --effort low
51
+ ./bin/bbb status /path/to/your-repo
52
+ ./bin/bbb retry /path/to/your-repo --once
53
+ ```
54
+
55
+ Source builds require Go 1.27.1. To install the local source as `bbb`, run
56
+ `go install ./cmd/bbb` and put your Go bin directory on `PATH`.
57
+ Running `bbb` from inside any target repository discovers its remote and default
58
+ branch. A Git URL also works. Flags can precede or follow the repository argument.
59
+
60
+ Runtime requirements: Git, authenticated `gh` with repository/issue read and
61
+ issue creation access, and an authenticated ACP agent. By default it uses an
62
+ installed `codex-acp`, falling back to `npx --yes @agentclientprotocol/codex-acp`.
63
+ Explicit `--agent` commands are used as supplied; repeat `--agent-arg` for arguments.
64
+
65
+ Starting `bbb` authorizes unattended local investigation, test execution, and
66
+ creation of issues for the selected repository. `--dry-run` performs discovery
67
+ and review, prints the proposed issue bodies, and saves them without filing.
68
+
69
+ ## How it works
70
+
71
+ 1. Fetch the target branch into a managed clone and make an isolated detached
72
+ worktree for the scan. The original checkout and uncommitted work are preserved.
73
+ 2. Download all open and closed issues and their comments with pagination. Give
74
+ the investigator the complete snapshot and recent scan summaries so it can
75
+ avoid known bugs and explore new areas on subsequent scans.
76
+ 3. Have the agent inspect source and run relevant checks. Each candidate must
77
+ include a root cause, source paths, concrete reproduction, expected/actual
78
+ behavior, and observed evidence or a precise code proof. Zero findings is valid.
79
+ 4. Start separate LLM review sessions to verify the evidence and compare each
80
+ candidate against the issue history. Large histories are supplied in batches;
81
+ every issue and comment is included, and each response must identify all issue
82
+ numbers it reviewed. A duplicate verdict links the existing report in local
83
+ state. Uncertain and invalid findings are saved without filing.
84
+ 5. Refresh issues before publication. New or edited reports go back to the LLM
85
+ for comparison. Recheck the source commit and tracked files. An optional
86
+ operator verifier can provide an additional gate.
87
+ 6. Create issues sequentially, including reproduction, evidence, and the review
88
+ explanation. Each newly created issue is available to the next candidate's
89
+ LLM review, including candidates from the same scan.
90
+
91
+ Closed issues count as known reports, including fixed, duplicate, or rejected
92
+ bugs. The reviewer is instructed to treat a regression of an existing report as
93
+ belonging to that report. The bot does not reopen or comment on it.
94
+
95
+ The default is at most **three issues per scan**, a **two-hour attempt budget**,
96
+ and another scan **30 minutes after completion**, even if the commit is unchanged.
97
+ Recent summaries guide exploration; this is not a claim of exhaustive coverage.
98
+ `once` runs or resumes one scan and exits. Failed scans retain their candidates,
99
+ workspace, and diagnostics; retries wait at least 15 minutes and run on the next
100
+ poll, with three attempts before requiring `retry`. Agent setup errors stop the
101
+ daemon without consuming an attempt. An advanced branch invalidates pending
102
+ findings so the next eligible attempt scans the new commit.
103
+
104
+ ## Duplicate handling and interrupted requests
105
+
106
+ Semantic duplicate detection is an LLM judgment, so it is not a guarantee.
107
+ Incomplete history, malformed review responses, and uncertain comparisons stop
108
+ publication. Same-title reports still reach the LLM: identical wording can hide
109
+ different bugs, and different wording can describe the same bug.
110
+
111
+ Every planned issue gets a random request ID, saved **before** sending its create
112
+ request and embedded as a hidden comment in the issue body. This ID identifies
113
+ one publication attempt; it is not derived from bug content or used to classify
114
+ duplicates. After a crash or lost response, `bbb` looks for that ID and records
115
+ the existing issue. If its outcome is unknown and the ID is not visible, it
116
+ refuses to send another create request. Run `once` to try reconciliation again.
117
+ If it never appears, inspect GitHub and the saved state before repairing the
118
+ pending entry; `retry` intentionally cannot blindly resend an ambiguous request.
119
+
120
+ A per-repository local lock coordinates instances across branches and config
121
+ paths using the same state home. Different machines/accounts and simultaneous
122
+ human reports cannot be locked atomically with GitHub issue creation. Run one
123
+ active `bbb` per repository to avoid that race.
124
+
125
+ ## Optional configuration
126
+
127
+ `bbb --config bug-bot.json` loads a strict JSON object. No file is loaded or
128
+ generated implicitly. Paths are resolved relative to the configuration file.
129
+ See [bug-bot.example.json](bug-bot.example.json).
130
+
131
+ ```json
132
+ {
133
+ "remote": "https://github.com/OWNER/REPO.git",
134
+ "branch": "main",
135
+ "directory": "var/checkout",
136
+ "state_directory": "var/state",
137
+ "poll": "30m",
138
+ "timeout": "2h",
139
+ "retry_delay": "15m",
140
+ "attempts": 3,
141
+ "max_issues": 3,
142
+ "focus": "",
143
+ "labels": [],
144
+ "dry_run": false,
145
+ "agent": {"command": ["codex-acp"]}
146
+ }
147
+ ```
148
+
149
+ Labels are optional and added only to new issues; they never filter the history.
150
+ Use labels that already exist in the target repository. `github.host` supports
151
+ Enterprise, and `github.repo` (`OWNER/REPO`) identifies a local mirror's GitHub
152
+ repository. `agent` also supports `environment`, `auth_method`, `mode`, `model`,
153
+ and `effort`, with selection handled by the shared ACP runner.
154
+
155
+ `verify` accepts an argument array, such as `["/opt/checks/verify-bug"]`, executed
156
+ in the scan worktree with `BUG_COMMIT` and JSON `BUG_FINDING` in its environment.
157
+ Keep operator verifiers outside the writable worktree. A nonzero exit blocks filing.
158
+
159
+ ## State and execution
160
+
161
+ State defaults to `$XDG_STATE_HOME/bug-bot` or `~/.local/state/bug-bot`, keyed by
162
+ remote and branch. JSON state is replaced atomically with fsync; private session
163
+ transcripts live under the state directory. `status` prints saved JSON without
164
+ starting an agent. `--json` selects structured progress logs.
165
+
166
+ Scan worktrees and reproduction files are retained for inspection. Manage their
167
+ retention along with transcripts externally. Agent instructions prohibit fixes,
168
+ commits, pushes, and direct GitHub writes; tracked source changes or a changed
169
+ HEAD invalidate the scan. Evidence is independently reviewed by the LLM, not
170
+ proof that tests are correct. As in the sibling bots, ACP permission requests
171
+ are automatically approved and agent commands run with the account's OS rights.
172
+ This is not a sandbox; use an appropriate account/container for the repository.
173
+
174
+ ## Development and packaging
175
+
176
+ ```sh
177
+ make check build
178
+ ./bin/bbb --help
179
+ python3 -m unittest discover -s scripts -p '*_test.py'
180
+ node --test --test-isolation=none npm/bbb.test.cjs
181
+ ```
182
+
183
+ Tests use local Git fixtures and simulated ACP/GitHub outcomes; they do not run
184
+ a paid model or create real issues. They cover semantic closed duplicates,
185
+ same-title distinct bugs, concurrent reports, partial histories, source changes,
186
+ dry runs, retries, ambiguous POSTs, receipt coverage, configuration, and locks.
187
+
188
+ The inherited release workflow packages Linux/macOS amd64/arm64 archives with
189
+ checksums. The npm launcher and packaging workflow target `@brokkai/bug-bot`
190
+ and install `bbb`. See [RELEASING.md](RELEASING.md) for publication and verification.
191
+
192
+ API references: [GitHub issues](https://docs.github.com/en/rest/issues/issues),
193
+ [issue comments](https://docs.github.com/en/rest/issues/comments).
194
+ Licensed under [Apache-2.0](LICENSE).
package/bin/bbb.cjs ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("node:child_process");
5
+
6
+ function packageName(platform = process.platform, arch = process.arch) {
7
+ if (!["linux", "darwin"].includes(platform) || !["x64", "arm64"].includes(arch)) {
8
+ throw new Error(`Brokk Bug Bot does not support ${platform}/${arch}.`);
9
+ }
10
+ return `@brokkai/bug-bot-${platform}-${arch}`;
11
+ }
12
+
13
+ function main() {
14
+ const name = packageName();
15
+ let binary;
16
+ try {
17
+ binary = require.resolve(`${name}/bin/bbb`);
18
+ } catch {
19
+ throw new Error(`Missing ${name}. Reinstall @brokkai/bug-bot with optional dependencies enabled.`);
20
+ }
21
+ const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
22
+ const handlers = new Map();
23
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
24
+ const handler = () => child.kill(signal);
25
+ handlers.set(signal, handler);
26
+ process.on(signal, handler);
27
+ }
28
+ const cleanup = () => {
29
+ for (const [signal, handler] of handlers) process.off(signal, handler);
30
+ };
31
+ child.on("error", (error) => {
32
+ cleanup();
33
+ console.error(`bbb: ${error.message}`);
34
+ process.exitCode = 1;
35
+ });
36
+ child.on("exit", (code, signal) => {
37
+ cleanup();
38
+ if (signal) process.kill(process.pid, signal);
39
+ else process.exitCode = code ?? 1;
40
+ });
41
+ }
42
+
43
+ module.exports = { packageName };
44
+ if (require.main === module) {
45
+ try { main(); } catch (error) {
46
+ console.error(`bbb: ${error.message}`);
47
+ process.exitCode = 1;
48
+ }
49
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "license": "Apache-2.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/BrokkAi/bug-bot.git"
7
+ },
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "name": "@brokkai/bug-bot",
12
+ "description": "Brokk Bug Bot: autonomous bug discovery and duplicate-aware GitHub issue reporting",
13
+ "bin": {
14
+ "bbb": "bin/bbb.cjs"
15
+ },
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "os": [
20
+ "linux",
21
+ "darwin"
22
+ ],
23
+ "cpu": [
24
+ "x64",
25
+ "arm64"
26
+ ],
27
+ "optionalDependencies": {
28
+ "@brokkai/bug-bot-linux-x64": "0.1.0",
29
+ "@brokkai/bug-bot-linux-arm64": "0.1.0",
30
+ "@brokkai/bug-bot-darwin-x64": "0.1.0",
31
+ "@brokkai/bug-bot-darwin-arm64": "0.1.0"
32
+ }
33
+ }