@bugbug-io/cli 13.39.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.
package/AGENTS.md ADDED
@@ -0,0 +1,103 @@
1
+ # CLI Package Guide
2
+
3
+ ## Scope
4
+
5
+ These instructions apply to `public-tools/packages/cli/`, the `@bugbug-io/cli` package. The root `public-tools/AGENTS.md` still applies; this file only adds CLI-specific rules. User-facing usage lives in `README.md`; the human developer guide lives in `DEVELOPMENT.md`.
6
+
7
+ ## Project Structure
8
+
9
+ ```
10
+ packages/cli/
11
+ ├── bin/bugbug.mjs # Published binary shim to built dist entrypoint
12
+ ├── src/
13
+ │ ├── index.ts # CLI entry: Commander setup, global options, command registration
14
+ │ ├── instrument.ts # Sentry bootstrap (imported first)
15
+ │ ├── app/ # Ink TUI: Navigator, router, views, components, contexts, hooks
16
+ │ ├── features/ # Feature commands, services, actions, formatters, types
17
+ │ │ └── tui/ # Shared terminal UI primitives (shortcuts, layouts)
18
+ │ ├── testUtils/ # Fake factories and test helpers
19
+ │ └── utils/ # Auth, config, output, reporters, SDK wiring, startup routing
20
+ ├── docs/ # CLI-facing docs/prompts
21
+ ├── scripts/ # Package-local validation helpers
22
+ ├── tsconfig.json
23
+ ├── tsup.config.ts
24
+ └── vitest.config.ts
25
+ ```
26
+
27
+ Command domains under `src/features/`: `auth`, `init`, `install`, `profiles`,
28
+ `project`, `shorthands`, `suiteRuns`, `suites`, `testRuns`, `tests`, `tui`.
29
+
30
+ ## Architecture
31
+
32
+ - `src/index.ts` owns global options, startup routing, and command registration.
33
+ - `src/features/{feature}/{feature}.command.ts` registers Commander commands.
34
+ - `src/features/{feature}/{feature}.service.ts` contains API orchestration through the SDK.
35
+ - `src/features/{feature}/{feature}.tui.tsx` and `src/features/{feature}/*.actions.tsx` contain interactive terminal flows.
36
+ - `src/features/{feature}/{feature}.formatters.tsx` contains plain/JSON/terminal presentation helpers.
37
+ - `src/app/` owns the interactive no-args navigator (`Navigator.tsx`, `router.tsx`, `views/`); `src/features/tui/` owns shared terminal UI primitives.
38
+ - `src/utils/startup.ts` detects the startup mode (navigator / help / commander / shorthand).
39
+ - `src/utils/sdk.ts` is the SDK construction boundary. Do not instantiate SDK clients directly in feature modules.
40
+
41
+ ## Coding Rules
42
+
43
+ - This package is TypeScript, ESM, Node `>=24`.
44
+ - Use the `~/` alias for package-local imports. It resolves to this package's `src/` directory.
45
+ - Do not end import specifiers or `vi.mock(...)` module strings with `.js`; keep local and alias imports extensionless.
46
+ - Prefer named exports and small typed helpers.
47
+ - Keep command parsing in command files, business/API behavior in services, and output rendering in formatters or TUI components.
48
+ - Preserve existing global modes: `--json`, `--ci`, `--token`, and `--verbose`.
49
+ - CLI output must remain usable in non-interactive CI. Do not force Ink rendering where plain output is expected.
50
+
51
+ ## Adding Commands
52
+
53
+ - Add new features under `src/features/{feature}/`.
54
+ - Register top-level command groups from `index.ts`.
55
+ - For commands that start runs, respect reporter options, wait/no-wait behavior, timeout handling, and exit codes.
56
+ - For list/get commands, support structured output through the existing output/render helpers.
57
+ - Update `README.md` or docs when public command behavior changes.
58
+
59
+ ## Adding new global config params
60
+
61
+ While adding a new global params, remember to handle it in many places.
62
+ It could be always:
63
+
64
+ - new `BUGBUG_` prefixed environment variable
65
+ - new command-line flag
66
+ - new config file field
67
+
68
+ ## Testing
69
+
70
+ - Use Vitest from this package or the root workspace scripts.
71
+ - Put tests beside the code or under the feature's `__tests__/` directory.
72
+ - Test startup routing under `src/utils/__tests__/` when changing no-args, shorthand, help, CI, or JSON behavior.
73
+ - Test names must start with `should ...` or `should not ...`; fakers use the `createFake*` prefix and live in `src/testUtils/`.
74
+ - Test command registration and service behavior separately where possible.
75
+ - Mock SDK/network boundaries. Normal CLI tests should not call live BugBug APIs.
76
+ - For Ink/TUI components, use the existing component tests as the local pattern.
77
+
78
+ ## Scripts
79
+
80
+ Run package-specific commands from `public-tools/`:
81
+
82
+ - Build CLI: `npm run build:cli`
83
+ - Test CLI: `npm run test:cli`
84
+ - Start CLI from TypeScript: `npm run start:cli`
85
+
86
+ Or from `public-tools/packages/cli/`:
87
+
88
+ - Build: `npm run build`
89
+ - Test: `npm run test`
90
+ - Test (CI): `npm run test:ci`
91
+ - Coverage: `npm run coverage`
92
+ - Type check: `npm run typecheck`
93
+ - Lint (oxfmt + oxlint): `npm run lint`
94
+ - Lint auto-fix: `npm run lint:fix`
95
+ - Lint (CI, no cache, `--max-warnings=0`): `npm run lint:ci`
96
+ - Format check only: `npm run format:check`
97
+ - Oxlint check only: `npm run oxlint:check`
98
+ - Start built CLI: `npm start`
99
+
100
+ ## Security and Config
101
+
102
+ - Load user project `.env` through the existing startup path; do not add ad hoc dotenv loading in feature files.
103
+ - Pass API credentials through existing global state and SDK helpers.
package/README.md ADDED
@@ -0,0 +1,229 @@
1
+ <div align="center">
2
+
3
+ ![BugBug Logo](https://bugbug.io/favicon-96x96.png)
4
+
5
+ # BugBug CLI
6
+
7
+ An enhanced command-line interface for [BugBug](https://bugbug.io) that provides better developer experience and extended capabilities for browser test automation.
8
+
9
+ </div>
10
+
11
+ ## Features
12
+
13
+ - **Rich Terminal UI**: Interactive navigator and readable error messages built with Ink
14
+ - **Flexible Token Management**: Multiple ways to configure your API token (CLI flags, `bugbug.yaml`, environment variables, and `bugbug login`)
15
+ - **Project Export & Import**: Export your entire project (tests, suites, profiles) to a ZIP archive and import it back
16
+ - **Test & Suite Execution**: Run individual tests or entire test suites in the cloud, waiting for results by default
17
+ - **Reporters**: Inline or JUnit XML reports for CI pipelines
18
+ - **Verbose Logging**: Optional detailed HTTP request logging for debugging
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install -g @bugbug-io/cli
24
+ bugbug --help
25
+ ```
26
+
27
+ Or run it without installing:
28
+
29
+ ```bash
30
+ npx @bugbug-io/cli --help
31
+ ```
32
+
33
+ ## Requirements
34
+
35
+ - Node.js v24 or higher
36
+ - BugBug account or API token
37
+
38
+ ## Quick Start
39
+
40
+ 1. **Authenticate** (opens the browser and stores a user token in the global config):
41
+
42
+ ```bash
43
+ bugbug login
44
+ ```
45
+
46
+ Or pass a token explicitly with `--token`, `BUGBUG_API_TOKEN`, or `bugbug.yaml` (see [Authentication](#authentication)).
47
+
48
+ 2. **Export your project**:
49
+
50
+ ```bash
51
+ bugbug project export
52
+ ```
53
+
54
+ 3. **Run a test** (waits for completion by default):
55
+ ```bash
56
+ bugbug tests run <testId>
57
+ ```
58
+
59
+ ## Authentication
60
+
61
+ The CLI resolves configuration from several layered sources. The first match wins:
62
+
63
+ 1. **Command line flag** (highest priority):
64
+
65
+ ```bash
66
+ bugbug project export --token YOUR_TOKEN
67
+ ```
68
+
69
+ 2. **Environment variable**:
70
+
71
+ ```bash
72
+ export BUGBUG_API_TOKEN=YOUR_TOKEN
73
+ ```
74
+
75
+ 3. **Local project config file** (`bugbug.yaml` in the current directory or an ancestor):
76
+
77
+ ```yaml
78
+ # bugbug.yaml
79
+ token: YOUR_TOKEN
80
+ projectId: YOUR_PROJECT_ID
81
+ apiUrl: https://app.bugbug.io/api/v2
82
+ ```
83
+
84
+ 4. **Environment file** (`.env`, or `.env.${NODE_ENV}`, walking up the directory tree):
85
+
86
+ ```bash
87
+ BUGBUG_API_TOKEN=YOUR_TOKEN
88
+ ```
89
+
90
+ 5. **Global config** (`~/.bugbug/config.yaml`), populated by `bugbug login`. The token is
91
+ looked up by `projectId` (falling back to the stored user token).
92
+
93
+ Running `bugbug login` starts a local loopback callback, opens BugBug in the
94
+ browser, completes the OAuth authorization-code flow, and stores the issued user
95
+ token in the global config. `bugbug logout` clears it. Run `bugbug init` in a
96
+ project directory to create a `bugbug.yaml` that links current directory/repository with selected BugBug project.
97
+
98
+ ## Environment Variables
99
+
100
+ | Variable | Description |
101
+ | ------------------- | --------------------------------------------------------------------- |
102
+ | `BUGBUG_API_TOKEN` | API token used to authenticate requests |
103
+ | `BUGBUG_PROJECT_ID` | Project ID (required for organization tokens in non-interactive mode) |
104
+ | `BUGBUG_LOG_LEVEL` | Log level; set to `debug` to enable verbose logging |
105
+ | `BUGBUG_TELEMETRY` | Set to `false` to disable telemetry |
106
+ | `DO_NOT_TRACK` | Standard opt-out; set to `1`/`true` to disable telemetry |
107
+ | `CI` | When `true`, forces plain (non-interactive) output |
108
+
109
+ ## Commands
110
+
111
+ Run `bugbug` with no arguments for the interactive navigator, or `bugbug <command> --help`
112
+ for details on any command.
113
+
114
+ ### Auth
115
+
116
+ ```bash
117
+ bugbug login # Authenticate and store a user token in the global config
118
+ bugbug logout # Clear the stored user token and current project
119
+ ```
120
+
121
+ ### Project
122
+
123
+ ```bash
124
+ bugbug init # Create bugbug.yaml pinning this directory to a project
125
+ bugbug project export # Export project as a ZIP (bugbug-project-export-<timestamp>.zip)
126
+ bugbug project export -o out.zip # Export to a specific file
127
+ bugbug project import out.zip # Import a project from a ZIP archive
128
+ ```
129
+
130
+ ### Tests
131
+
132
+ ```bash
133
+ bugbug tests list # List tests
134
+ bugbug tests list -s "login" # Filter tests by name
135
+ bugbug tests show <testId> # Show test details
136
+ bugbug tests run <testId> # Run a test (waits for completion by default)
137
+ bugbug tests run <testId> --profile "Production"
138
+ bugbug tests run <testId> --variable FOO=bar --variable BAZ=qux
139
+ bugbug tests run <testId> --no-wait # Queue the run and exit immediately
140
+ bugbug tests run <testId> --reporter junit --output-path report.xml
141
+ bugbug tests export <testId> --format yaml
142
+ bugbug tests export <testId> --format zip -o test.zip
143
+ bugbug tests import test.yaml # Import a test from YAML or ZIP
144
+ ```
145
+
146
+ ### Test Runs
147
+
148
+ ```bash
149
+ bugbug testruns show <runId> # Show the result of a test run
150
+ bugbug testruns logs <runId> # Get logs for a test run
151
+ bugbug testruns stop <runId> # Stop a running test run
152
+ bugbug testruns report <runId> -o out.xml # Get the JUnit XML report
153
+ ```
154
+
155
+ ### Suites
156
+
157
+ ```bash
158
+ bugbug suites list # List suites
159
+ bugbug suites list -s "checkout" # Filter suites by name
160
+ bugbug suites show <suiteId> # Show suite details
161
+ bugbug suites run <suiteId> # Run a suite (waits for completion by default)
162
+ bugbug suites run <suiteId> --profile "Production" --variable FOO=bar
163
+ bugbug suites run <suiteId> --no-wait
164
+ ```
165
+
166
+ ### Suite Runs
167
+
168
+ ```bash
169
+ bugbug suiteruns show <runId> # Show the result of a suite run
170
+ bugbug suiteruns stop <runId> # Stop a running suite run
171
+ bugbug suiteruns report <runId> -o out.xml # Get the JUnit XML report
172
+ ```
173
+
174
+ ### Profiles
175
+
176
+ ```bash
177
+ bugbug profiles list # List run profiles
178
+ ```
179
+
180
+ ### AI Clients (plugin: MCP + Skills)
181
+
182
+ ```bash
183
+ bugbug plugin --agent=cursor # Install skills + MCP into Cursor
184
+ bugbug plugin --agent=codex --dry-run # Show what would be installed, writing nothing
185
+ ```
186
+
187
+ Supported `--agent` values: `cursor`, `claude`, `vscode`, `codex`, `windsurf`,
188
+ `copilot`.
189
+ Windsurf gets
190
+ an MCP server config plus the BugBug skills written into the agent's skills
191
+ directory.
192
+
193
+ The token is resolved from your existing CLI auth (`bugbug login`, `--token`, or
194
+ `BUGBUG_API_TOKEN`).
195
+
196
+ ### Shorthands
197
+
198
+ Verb-first shorthands map onto the namespaced commands above:
199
+
200
+ ```bash
201
+ bugbug run test <testId>
202
+ bugbug run suite <suiteId>
203
+ bugbug list test
204
+ bugbug list suite
205
+ bugbug list profile
206
+ bugbug stop test <runId>
207
+ bugbug stop suite <runId>
208
+ bugbug report test <runId>
209
+ bugbug report suite <runId>
210
+ bugbug logs test <runId>
211
+ bugbug export project
212
+ bugbug export test <testId>
213
+ bugbug import project export.zip
214
+ bugbug import test test.yaml
215
+ ```
216
+
217
+ ## Global Options
218
+
219
+ - `-t, --token <token>`: API token for BugBug (overrides config)
220
+ - `-p, --project-id <projectId>`: Project ID (required only for organization tokens in non-interactive mode)
221
+ - `-v, --verbose`: Enable verbose logging including HTTP requests
222
+ - `--ci`: CI-friendly output (plain logs, no interactive UI, exit 1 on failure)
223
+ - `--json`: Emit JSON output (implies non-interactive)
224
+ - `--disable-telemetry`: Disable telemetry
225
+ - `-h, --help`: Show help information
226
+
227
+ ## License
228
+
229
+ MIT
package/bin/bugbug.mjs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ const entrypoint = new URL(`../dist/index.${'js'}`, import.meta.url);
3
+ import(entrypoint.href);