byob-cli 0.2.9

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "byob-cli",
3
+ "version": "0.1.0",
4
+ "description": "Codex connector for BYOB projects, backed by Agent MCP with project context, deployment helpers, and coding tools.",
5
+ "skills": "./skills/byob_cli/",
6
+ "mcpServers": "./.mcp.json"
7
+ }
package/.mcp.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "byob": {
3
+ "command": "npx",
4
+ "args": ["-y", "byob-cli", "mcp"],
5
+ "env_vars": [
6
+ "BYOB_PROJECT_ID",
7
+ "BYOB_PROJECT_IDS",
8
+ "BYOB_MCP_MULTI_PROJECT",
9
+ "BYOB_AGENT_TOKEN",
10
+ "BYOB_AIR_URL",
11
+ "BYOB_PRIM_URL"
12
+ ]
13
+ }
14
+ }
package/README.md ADDED
@@ -0,0 +1,426 @@
1
+ # BYOB CLI
2
+
3
+ BYOB CLI is the Codex connector for BYOB. It installs a local `byob` command, configures Codex MCP, and installs the `byob_cli` skill so Codex can safely edit approved BYOB projects.
4
+
5
+ Under the hood, `byob mcp` starts a stdio MCP server that forwards JSON-RPC to BYOB's hosted Agent MCP endpoint in AIR using a user-approved agent token. The package does not contain BYOB platform credentials.
6
+
7
+ ## Install
8
+
9
+ Use the package directly from npm. Codex is the primary supported client, and other MCP clients can use the same standard `command` + `args` + `env` model:
10
+
11
+ ```bash
12
+ npx -y byob-cli --help
13
+ ```
14
+
15
+ Install and authorize BYOB for Codex in one command:
16
+
17
+ ```bash
18
+ npx -y byob-cli codex install --client-name "Codex"
19
+ ```
20
+
21
+ The command starts the BYOB OAuth device flow, waits for browser approval, then runs `codex mcp add` with the approved project scope.
22
+ It also installs the `byob_cli` skill into `~/.agents/skills/byob_cli` so Codex can discover it in `/skills` or `$` skill invocation.
23
+ `byob_cli` is the Codex platform contract: it tells Codex how to establish active project context, route tools, handle preview/editor/deployment URLs, protect BYOB-managed files, test changes, and use deployment/billing/domain tools.
24
+ After authentication, the installer also downloads BYOB AIR coding skills into local Codex skill folders with `byob_` prefixes. Those synced skills hold reusable implementation knowledge for SvelteKit, Supabase, BYOB DB, UI quality, SEO, PWA, payments, animations, image generation, and integrations.
25
+ The wizard prints a BYOB banner, auto-opens the approval URL when possible, shows progress steps, and prints the final Codex server/skill install locations. Pass `--no-open` to suppress browser opening, `--no-skill` to skip local skill installation, or `--no-air-skills` to skip downloading AIR coding skills.
26
+
27
+ Refresh synced coding skills later without rerunning OAuth or changing MCP config:
28
+
29
+ ```bash
30
+ npx -y byob-cli codex sync-skills --project-id <project_id> --token <agent_access_token>
31
+ ```
32
+
33
+ Or install it globally:
34
+
35
+ ```bash
36
+ npm install -g byob-cli
37
+ byob --help
38
+ ```
39
+
40
+ Requirements:
41
+
42
+ - Node.js 18 or newer.
43
+ - A BYOB agent access token from the OAuth device flow.
44
+ - One or more project ids approved during the OAuth flow.
45
+
46
+ ## URLs And Environments
47
+
48
+ There are two classes of URLs:
49
+
50
+ - **Control-plane URLs** are configured by the user or deployment:
51
+ - `BYOB_AIR_URL`: Agent MCP broker. Production is always `https://air.api.byob.studio`.
52
+ - `--prim-url` / `BYOB_PRIM_URL`: OAuth/token API. Production is always `https://prim.api.byob.studio`.
53
+ - **Project URLs** are returned by BYOB at runtime:
54
+ - `preview_url`
55
+ - `editor_url`
56
+ - `deployment_url`
57
+
58
+ Do not hardcode preview or editor hostnames when making tool decisions. Local development often returns VM/host URLs such as `http://10.0.3.1:<port>`. Production project runtime URLs normally use these host patterns:
59
+
60
+ - Editor: `https://editor.<project_id>.api.byob.studio`
61
+ - Preview: `https://preview.<project_id>.api.byob.studio`
62
+
63
+ Always prefer the exact URLs returned by `byob_current_project_context`, `byob context`, or `_meta.byob_project`, because custom domains, gateways, or future deployment routing can change the canonical URL.
64
+
65
+ ## Standard MCP Client Config
66
+
67
+ Most MCP clients accept a `mcpServers` entry with `command`, `args`, and `env`. Add:
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "byob": {
73
+ "command": "npx",
74
+ "args": ["-y", "byob-cli", "mcp"],
75
+ "env": {
76
+ "BYOB_PROJECT_ID": "<project_id>",
77
+ "BYOB_AGENT_TOKEN": "<agent_access_token>"
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ Generate the same shape locally:
85
+
86
+ ```bash
87
+ byob config --project-id <project_id>
88
+ ```
89
+
90
+ `https://air.api.byob.studio` and `https://prim.api.byob.studio` are the package defaults. Set `BYOB_AIR_URL`, `BYOB_PRIM_URL`, `--air-url`, or `--prim-url` only for local development or staging.
91
+
92
+ Use `npx.cmd` as the command on Windows if your MCP client does not resolve `npx`.
93
+
94
+ ## Codex Setup
95
+
96
+ For Codex users, prefer installing the BYOB Codex plugin. The plugin bundles:
97
+
98
+ - `skills/byob_cli/SKILL.md`
99
+ - `.mcp.json`, which starts the `byob` MCP server with `npx -y byob-cli mcp`
100
+
101
+ Plugin install makes the BYOB skills and MCP server available from one package. The user still needs to provide their project id and agent token, because those are user/project-specific secrets.
102
+
103
+ For the common MCP setup path, use the installer:
104
+
105
+ ```bash
106
+ npx -y byob-cli codex install --client-name "Codex"
107
+ ```
108
+
109
+ This follows the same wizard pattern used by many MCP providers: the npm package performs auth, writes the Codex MCP config, and installs the BYOB Codex skill into `~/.agents/skills/byob_cli`. It makes BYOB tools available immediately through MCP server instructions and tool discovery, and makes `$byob_cli` available after Codex reloads skills or starts a new session.
110
+
111
+ Publishing `byob-cli` to npm makes the `byob` binary available to `npx`; it does not automatically create a Codex plugin marketplace. `codex plugin add byob-cli@npm` will fail unless a marketplace named `npm` has been configured and contains a plugin entry.
112
+
113
+ For local repo testing, add this repository marketplace from the repo root:
114
+
115
+ ```bash
116
+ codex plugin marketplace add /path/to/byob
117
+ codex plugin add byob --marketplace byob-local
118
+ ```
119
+
120
+ For distribution, publish a Codex marketplace JSON from a Git repo or share the plugin through the Codex app. Then users install from that marketplace, while the bundled `.mcp.json` uses npm only to launch the MCP binary.
121
+
122
+ Example plugin-scoped MCP config:
123
+
124
+ ```toml
125
+ [plugins."<installed_byob_plugin_id>".mcp_servers.byob.env]
126
+ BYOB_PROJECT_ID = "<project_id>"
127
+ BYOB_AGENT_TOKEN = "<agent_access_token>"
128
+ ```
129
+
130
+ For multiple projects:
131
+
132
+ ```toml
133
+ [plugins."<installed_byob_plugin_id>".mcp_servers.byob.env]
134
+ BYOB_PROJECT_IDS = "<project_id_1>,<project_id_2>"
135
+ BYOB_CLI_MULTI_PROJECT = "1"
136
+ BYOB_AGENT_TOKEN = "<agent_access_token>"
137
+ ```
138
+
139
+ Use the plugin id Codex shows after installation, for example `byob` or a marketplace-qualified id.
140
+
141
+ The bundled MCP server forwards `BYOB_AIR_URL` and `BYOB_PRIM_URL` when set, but production defaults are already `https://air.api.byob.studio` and `https://prim.api.byob.studio`.
142
+
143
+ ### Manual MCP Setup
144
+
145
+ If the user does not install the plugin, they can still add the stdio MCP server directly:
146
+
147
+ ```bash
148
+ codex mcp add byob \
149
+ --env BYOB_PROJECT_ID=<project_id> \
150
+ --env BYOB_AGENT_TOKEN=<agent_access_token> \
151
+ -- npx -y byob-cli mcp
152
+ ```
153
+
154
+ Equivalent `config.toml`:
155
+
156
+ ```toml
157
+ [mcp_servers.byob]
158
+ command = "npx"
159
+ args = ["-y", "byob-cli", "mcp"]
160
+
161
+ [mcp_servers.byob.env]
162
+ BYOB_PROJECT_ID = "<project_id>"
163
+ BYOB_AGENT_TOKEN = "<agent_access_token>"
164
+ ```
165
+
166
+ Codex reads MCP server `instructions` returned during initialization. BYOB uses those instructions to tell Codex to establish project context on first BYOB use and after project switches. Context can come from `_meta.byob_project`, resource `byob://project/<project_id>/context`, `byob_current_project_context`, or `byob context`. Codex should show the user the active project name/id and preview URL when the active project was not already clear.
167
+
168
+ Important: `npx -y byob-cli mcp` starts the MCP server; it does not install Codex skills by itself. With only the MCP server configured, Codex learns about BYOB at runtime from:
169
+
170
+ - MCP `initialize.instructions`
171
+ - MCP `tools/list`
172
+ - MCP resources and `_meta.byob_project` where the host supports them
173
+
174
+ To make the `SKILL.md` workflow available to Codex as a skill, run `byob codex install`, install the BYOB Codex plugin, or place the skill folder in a Codex-scanned skills location. The installer copies the skill to `~/.agents/skills/byob_cli`; the MCP server alone does not register that skill name. The main skill installs `CODEX_CORE.md` as a sidecar file and uses synced `byob_*` skills for reusable styling, framework, backend, and integration guidance.
175
+
176
+ This package includes Codex plugin scaffolding for that:
177
+
178
+ - `.codex-plugin/plugin.json`
179
+ - `.mcp.json`
180
+ - `skills/byob_cli/SKILL.md`
181
+
182
+ The local developer skill lives under `local-skills/byob_cli_local/` and is not included in the production plugin manifest.
183
+
184
+ During local development, the repo marketplace is at `.agents/plugins/marketplace.json`.
185
+
186
+ ### Refreshing Codex Skills
187
+
188
+ Use this after BYOB updates AIR coding skills or when a Codex machine already has MCP configured:
189
+
190
+ ```bash
191
+ npx -y byob-cli codex sync-skills --project-id <project_id> --token <agent_access_token>
192
+ ```
193
+
194
+ `codex sync-skills` downloads AIR coding-skill resources and rewrites their local skill names with `byob_` prefixes. It does not run OAuth, does not call `codex mcp add`, and does not change the active MCP server config.
195
+
196
+ ## Multiple Projects
197
+
198
+ BYOB grants can cover more than one approved project. There are two supported install shapes.
199
+
200
+ ### Recommended: One Server Per Project
201
+
202
+ Use one MCP entry per project when the client supports multiple servers. This is the clearest mode because every server has a stable project target and no tool-call routing ambiguity.
203
+
204
+ ```json
205
+ {
206
+ "mcpServers": {
207
+ "byob-web": {
208
+ "command": "npx",
209
+ "args": ["-y", "byob-cli", "mcp"],
210
+ "env": {
211
+ "BYOB_PROJECT_ID": "<web_project_id>",
212
+ "BYOB_AGENT_TOKEN": "<agent_access_token>"
213
+ }
214
+ },
215
+ "byob-admin": {
216
+ "command": "npx",
217
+ "args": ["-y", "byob-cli", "mcp"],
218
+ "env": {
219
+ "BYOB_PROJECT_ID": "<admin_project_id>",
220
+ "BYOB_AGENT_TOKEN": "<agent_access_token>"
221
+ }
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Single Entry: Multi-Project Routing
228
+
229
+ Use one MCP entry only when the client cannot manage multiple BYOB servers cleanly. The bridge routes `tools/call` by `arguments.project_id`. Non-tool methods such as `initialize`, `tools/list`, and `ping` use the first configured project.
230
+
231
+ ```json
232
+ {
233
+ "mcpServers": {
234
+ "byob": {
235
+ "command": "npx",
236
+ "args": ["-y", "byob-cli", "mcp", "--multi-project"],
237
+ "env": {
238
+ "BYOB_PROJECT_IDS": "<project_id_1>,<project_id_2>",
239
+ "BYOB_CLI_MULTI_PROJECT": "1",
240
+ "BYOB_AGENT_TOKEN": "<agent_access_token>"
241
+ }
242
+ }
243
+ }
244
+ }
245
+ ```
246
+
247
+ For project-specific tools, pass `project_id` in the tool arguments:
248
+
249
+ ```bash
250
+ byob call byob_project_status '{"project_id":"<project_id_2>"}'
251
+ ```
252
+
253
+ Without `project_id`, the first configured project is the default. Use:
254
+
255
+ ```bash
256
+ byob projects
257
+ ```
258
+
259
+ to list projects approved for the grant.
260
+
261
+ Project switching is intentionally explicit. The bridge does not persist a mutable "current project" on disk; pass `--project-id`, set `BYOB_PROJECT_ID`, or include `project_id` in tool arguments.
262
+
263
+ ## OAuth
264
+
265
+ Request a device code:
266
+
267
+ ```bash
268
+ byob device-code --client-name "My coding agent"
269
+ ```
270
+
271
+ Open the returned `verification_uri_complete`, approve the project, then exchange:
272
+
273
+ ```bash
274
+ byob token <device_code>
275
+ ```
276
+
277
+ Refresh:
278
+
279
+ ```bash
280
+ byob refresh <refresh_token>
281
+ ```
282
+
283
+ Do not paste access or refresh tokens into chat, logs, or issue reports.
284
+
285
+ If the needed project is missing from `byob projects`, reconnect with the device flow and approve that project in BYOB.
286
+
287
+ ## CLI Smoke Checks
288
+
289
+ ```bash
290
+ BYOB_PROJECT_ID=<project_id> \
291
+ BYOB_AGENT_TOKEN=<agent_access_token> \
292
+ byob tools
293
+ ```
294
+
295
+ Common aliases:
296
+
297
+ ```bash
298
+ byob status
299
+ byob context
300
+ byob start
301
+ byob deploy
302
+ byob billing
303
+ byob payment-url '{"topup":500}'
304
+ byob env-status
305
+ byob grants
306
+ byob dns
307
+ ```
308
+
309
+ `billing` returns the current credit balance and plan. `payment-url` returns a BYOB pricing/top-up URL that can be shown directly to the user.
310
+
311
+ Call any tool directly:
312
+
313
+ ```bash
314
+ byob call byob_project_status '{}'
315
+ ```
316
+
317
+ Target another approved project for one command:
318
+
319
+ ```bash
320
+ byob --project-id <other_project_id> status
321
+ byob call byob_project_status '{"project_id":"<other_project_id>"}'
322
+ ```
323
+
324
+ ## Project Context Metadata
325
+
326
+ The MCP server exposes project metadata as both a real tool and a resource.
327
+
328
+ For Codex reliability, prefer the tool:
329
+
330
+ ```bash
331
+ byob context
332
+ ```
333
+
334
+ The underlying MCP tool is:
335
+
336
+ ```text
337
+ byob_current_project_context
338
+ ```
339
+
340
+ Codex sees MCP tools reliably and receives BYOB server instructions telling it to call this tool when project context is needed.
341
+
342
+ Read another approved project:
343
+
344
+ ```bash
345
+ byob context '{"project_id":"<other_project_id>"}'
346
+ ```
347
+
348
+ For host UIs that support MCP resources, read the resource:
349
+
350
+ ```bash
351
+ byob context-resource
352
+ byob context-resource '{"project_id":"<other_project_id>"}'
353
+ ```
354
+
355
+ List resources:
356
+
357
+ ```bash
358
+ byob resources
359
+ ```
360
+
361
+ Resource URI shape:
362
+
363
+ ```text
364
+ byob://project/<project_id>/context
365
+ ```
366
+
367
+ The context payload includes:
368
+
369
+ - project name
370
+ - project id
371
+ - status
372
+ - preview URL
373
+ - editor URL
374
+ - deployment URL
375
+ - publish slug
376
+ - updated/started timestamps
377
+
378
+ MCP responses also include `_meta.byob_project` where useful. Hosts can use that `_meta` for display without injecting it into model-visible text. Do not put the editor URL into prompts unless the user explicitly needs it.
379
+
380
+ ## Tool Notes
381
+
382
+ BYOB platform tools are exposed by Agent MCP:
383
+
384
+ - `byob_current_project_context`
385
+ - `byob_list_projects`
386
+ - `byob_project_status`
387
+ - `byob_start_project`
388
+ - `byob_billing_status`
389
+ - `byob_payment_url`
390
+ - `byob_project_env_status`
391
+ - `byob_list_agent_grants`
392
+ - `byob_revoke_agent_grant`
393
+ - `byob_deploy_project`
394
+ - `byob_deployment_status`
395
+ - `byob_deployment_analytics`
396
+ - `byob_get_custom_domain`
397
+ - `byob_custom_domain_dns_instructions`
398
+ - `byob_set_custom_domain`
399
+ - `byob_delete_custom_domain`
400
+ - `byob_testing_browsers`
401
+ - `byob_browser_session_start`
402
+ - `byob_browser_action`
403
+ - `byob_browser_session_close`
404
+
405
+ Project coding tools are discovered with `tools/list` and proxied into the selected project's private container MCP.
406
+ After successful mutating coding tools such as `edit_file`, `write_file`, `apply_patch`, package changes, file moves, copies, or deletes, BYOB appends the current preview URL to the tool response when available. Agents should surface that preview URL after code changes.
407
+
408
+ Codex-driven browser testing is exposed as BYOB platform tools, not as raw container tools. `byob_browser_action` routes browser commands through the connected BYOB browser extension and supports navigation, screenshots, clicks, typing, DOM evaluation, selector waits, viewport resizing, console logs, and network capture. BYOB's internal `delegate_testing` chat/modal flow remains separate and is not advertised through Agent MCP.
409
+
410
+ Codex does not need BYOB browser tools for every test. For basic smoke checks, it can directly fetch or inspect the `preview_url` and combine that with BYOB preview/browser log tools. Use the BYOB Testing extension only when real browser interaction is needed: screenshots, clicks, typing, viewport checks, DOM evaluation, fresh console logs, or network capture.
411
+
412
+ If browser-extension testing is needed and no BYOB testing browser is connected, ask the user to install or open the BYOB Testing extension:
413
+
414
+ ```text
415
+ https://chromewebstore.google.com/detail/byob-testing/ncnaebcfklfpcapminohoiekcemmaalj
416
+ ```
417
+
418
+ When a long-running build, image generation, package install, or deploy is already in progress, tell the user they can install the extension during that wait so Codex can test the preview afterward.
419
+
420
+ ## Included Skills
421
+
422
+ The production plugin includes one Codex skill:
423
+
424
+ - `skills/byob_cli/SKILL.md`
425
+
426
+ The local-only developer skill is kept at `local-skills/byob_cli_local/SKILL.md` for BYOB contributors testing a local stack. Do not include it in the production plugin build.