@bagdock/cli 0.1.4 → 0.3.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.
- package/README.md +580 -22
- package/dist/bagdock.js +875 -166
- package/package.json +14 -5
- package/skill-evals/bagdock-cli/evals.json +152 -0
- package/skills/bagdock-cli/SKILL.md +123 -0
- package/skills/bagdock-cli/references/auth.md +113 -0
- package/skills/bagdock-cli/references/deploy.md +91 -0
- package/skills/bagdock-cli/references/dev.md +45 -0
- package/skills/bagdock-cli/references/env.md +37 -0
- package/skills/bagdock-cli/references/error-codes.md +53 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagdock/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Bagdock developer CLI — build, test, and deploy apps and edges on the Bagdock platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bagdock",
|
|
@@ -28,8 +28,14 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
30
|
"README.md",
|
|
31
|
-
"LICENSE"
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"skills",
|
|
33
|
+
"skill-evals"
|
|
32
34
|
],
|
|
35
|
+
"skills": {
|
|
36
|
+
"name": "bagdock-cli",
|
|
37
|
+
"path": "skills/bagdock-cli"
|
|
38
|
+
},
|
|
33
39
|
"publishConfig": {
|
|
34
40
|
"access": "public"
|
|
35
41
|
},
|
|
@@ -37,15 +43,18 @@
|
|
|
37
43
|
"dev": "bun run bin/bagdock.ts",
|
|
38
44
|
"build": "bun build bin/bagdock.ts --outdir dist --target node --format esm && node -e \"const fs=require('fs');const f='dist/bagdock.js';let c=fs.readFileSync(f,'utf8');c=c.replace(/^#!.*\\n/,'').replace(/^\\/\\/ @bun\\n/,'');fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c)\"",
|
|
39
45
|
"prepublishOnly": "bun run build",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
40
48
|
"typecheck": "tsc --noEmit"
|
|
41
49
|
},
|
|
42
50
|
"dependencies": {
|
|
51
|
+
"chalk": "^5.4.1",
|
|
43
52
|
"commander": "^13.1.0",
|
|
44
|
-
"open": "^10.1.0"
|
|
45
|
-
"chalk": "^5.4.1"
|
|
53
|
+
"open": "^10.1.0"
|
|
46
54
|
},
|
|
47
55
|
"devDependencies": {
|
|
48
56
|
"@types/bun": "latest",
|
|
49
|
-
"typescript": "^5.3.3"
|
|
57
|
+
"typescript": "^5.3.3",
|
|
58
|
+
"vitest": "^3.2.4"
|
|
50
59
|
}
|
|
51
60
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": "bagdock-cli",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"evals": [
|
|
5
|
+
{
|
|
6
|
+
"id": "login-flow",
|
|
7
|
+
"description": "Agent should authenticate using bagdock login",
|
|
8
|
+
"input": "Log me into Bagdock",
|
|
9
|
+
"expected_commands": ["bagdock login"],
|
|
10
|
+
"expected_behavior": "Opens browser for OAuth device flow, waits for approval"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "create-api-key",
|
|
14
|
+
"description": "Agent should create an API key with proper flags",
|
|
15
|
+
"input": "Create a live API key named 'CI Deploy' for my GitHub Actions",
|
|
16
|
+
"expected_commands": ["bagdock keys create --name \"CI Deploy\" --environment live --json"],
|
|
17
|
+
"expected_behavior": "Creates key, captures raw key from JSON output for use in CI"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "create-test-key",
|
|
21
|
+
"description": "Agent should create a test environment key",
|
|
22
|
+
"input": "I need a test API key with read-only access to units and contacts",
|
|
23
|
+
"expected_commands": ["bagdock keys create --name \"Test Read-Only\" --environment test --category restricted --scopes units:read contacts:read --json"],
|
|
24
|
+
"expected_behavior": "Creates restricted test key with specified scopes"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "list-keys",
|
|
28
|
+
"description": "Agent should list API keys",
|
|
29
|
+
"input": "Show me all my live API keys",
|
|
30
|
+
"expected_commands": ["bagdock keys list --environment live"],
|
|
31
|
+
"expected_behavior": "Lists all active live-environment API keys"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "revoke-key",
|
|
35
|
+
"description": "Agent should revoke an API key with confirmation",
|
|
36
|
+
"input": "Delete the API key ak_abc123, it was compromised",
|
|
37
|
+
"expected_commands": ["bagdock keys delete ak_abc123 --yes --reason \"Key compromised\""],
|
|
38
|
+
"expected_behavior": "Revokes the specified key immediately"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "deploy-staging",
|
|
42
|
+
"description": "Agent should deploy to staging",
|
|
43
|
+
"input": "Deploy my adapter to staging",
|
|
44
|
+
"expected_commands": ["bagdock deploy"],
|
|
45
|
+
"expected_behavior": "Builds and deploys to staging environment"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "deploy-production",
|
|
49
|
+
"description": "Agent should deploy to production with confirmation",
|
|
50
|
+
"input": "Push this to production",
|
|
51
|
+
"expected_commands": ["bagdock deploy --production --yes"],
|
|
52
|
+
"expected_behavior": "Deploys to production, skipping prompt since agent is non-TTY"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "deploy-preview",
|
|
56
|
+
"description": "Agent should deploy a preview",
|
|
57
|
+
"input": "Create a preview deployment for this PR",
|
|
58
|
+
"expected_commands": ["bagdock deploy --preview --json"],
|
|
59
|
+
"expected_behavior": "Creates ephemeral preview URL, outputs JSON with URL"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "set-env-var",
|
|
63
|
+
"description": "Agent should set an environment variable",
|
|
64
|
+
"input": "Set the VENDOR_API_KEY to sk_live_abc123 for my adapter",
|
|
65
|
+
"expected_commands": ["bagdock env set VENDOR_API_KEY sk_live_abc123"],
|
|
66
|
+
"expected_behavior": "Sets the variable, notes it takes effect on next deploy"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "init-edge-adapter",
|
|
70
|
+
"description": "Agent should scaffold a new edge adapter project",
|
|
71
|
+
"input": "Create a new access control adapter called smart-entry",
|
|
72
|
+
"expected_commands": ["bagdock init --type edge --kind adapter --category access_control --slug smart-entry --name \"Smart Entry\""],
|
|
73
|
+
"expected_behavior": "Scaffolds project with bagdock.json and starter files"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "ci-cd-pipeline",
|
|
77
|
+
"description": "Agent should set up a CI/CD pipeline using API key",
|
|
78
|
+
"input": "Set up GitHub Actions to deploy my adapter on push to main",
|
|
79
|
+
"expected_behavior": "Creates workflow that uses BAGDOCK_API_KEY secret, runs bagdock deploy --production --yes --json"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "whoami-check",
|
|
83
|
+
"description": "Agent should check authentication status",
|
|
84
|
+
"input": "Am I logged into Bagdock?",
|
|
85
|
+
"expected_commands": ["bagdock whoami"],
|
|
86
|
+
"expected_behavior": "Shows current user email and operator ID"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": "submit-for-review",
|
|
90
|
+
"description": "Agent should submit app for marketplace review",
|
|
91
|
+
"input": "Submit my public adapter for review so I can deploy to production",
|
|
92
|
+
"expected_commands": ["bagdock submit"],
|
|
93
|
+
"expected_behavior": "Transitions review_status from draft to submitted"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "non-tty-detection",
|
|
97
|
+
"description": "Agent should use --json flag in non-interactive mode",
|
|
98
|
+
"input": "Get all my API keys in a script-friendly format",
|
|
99
|
+
"expected_commands": ["bagdock keys list --json"],
|
|
100
|
+
"expected_behavior": "Outputs JSON array of keys to stdout"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "doctor-check",
|
|
104
|
+
"description": "Agent should run diagnostics to verify environment",
|
|
105
|
+
"input": "Check if my Bagdock setup is working correctly",
|
|
106
|
+
"expected_commands": ["bagdock doctor"],
|
|
107
|
+
"expected_behavior": "Runs version, auth, config, and AI agent checks"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "doctor-json",
|
|
111
|
+
"description": "Agent should run diagnostics in JSON mode",
|
|
112
|
+
"input": "Get diagnostics as JSON to check my environment",
|
|
113
|
+
"expected_commands": ["bagdock doctor --json"],
|
|
114
|
+
"expected_behavior": "Returns { ok: boolean, checks: [...] } JSON to stdout"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": "profile-switch",
|
|
118
|
+
"description": "Agent should switch between operator profiles",
|
|
119
|
+
"input": "Switch to my production profile",
|
|
120
|
+
"expected_commands": ["bagdock auth switch production"],
|
|
121
|
+
"expected_behavior": "Switches active profile to 'production'"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "profile-list",
|
|
125
|
+
"description": "Agent should list available profiles",
|
|
126
|
+
"input": "What Bagdock profiles do I have?",
|
|
127
|
+
"expected_commands": ["bagdock auth list --json"],
|
|
128
|
+
"expected_behavior": "Lists all stored profiles with email and active status"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": "profile-flag",
|
|
132
|
+
"description": "Agent should use --profile flag for one-off commands",
|
|
133
|
+
"input": "Deploy to production using my prod profile",
|
|
134
|
+
"expected_commands": ["bagdock --profile prod deploy --production --yes"],
|
|
135
|
+
"expected_behavior": "Uses prod profile credentials for this deployment only"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "logs-tail",
|
|
139
|
+
"description": "Agent should tail live logs for debugging",
|
|
140
|
+
"input": "Show me the live logs for my smart-entry adapter",
|
|
141
|
+
"expected_commands": ["bagdock logs tail --app smart-entry"],
|
|
142
|
+
"expected_behavior": "Streams live execution logs for the specified app"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "apps-list",
|
|
146
|
+
"description": "Agent should list deployed applications",
|
|
147
|
+
"input": "What apps do I have deployed?",
|
|
148
|
+
"expected_commands": ["bagdock apps list --json"],
|
|
149
|
+
"expected_behavior": "Lists all deployed apps with slugs, types, and status"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Bagdock CLI Skill
|
|
2
|
+
|
|
3
|
+
The `@bagdock/cli` is the developer CLI for building, testing, and deploying apps and edges on the Bagdock self-storage operator platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @bagdock/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx @bagdock/cli <command>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Agent Protocol
|
|
18
|
+
|
|
19
|
+
When calling the Bagdock CLI from an AI agent, CI/CD pipeline, or non-interactive environment:
|
|
20
|
+
|
|
21
|
+
1. **JSON output is automatic** in non-TTY. Force it with `--json`.
|
|
22
|
+
2. **Errors** go to stderr as `{ "error": { "code": "...", "message": "..." } }`.
|
|
23
|
+
3. **Success** data goes to stdout as JSON.
|
|
24
|
+
4. **Exit codes**: `0` = success, `1` = error.
|
|
25
|
+
5. **Use `--quiet` / `-q`** to suppress all status/progress output (implies `--json`).
|
|
26
|
+
6. **Use `--api-key <key>`** to authenticate without `bagdock login` (overrides all other auth).
|
|
27
|
+
7. **Use `--yes`** on destructive commands (e.g., `keys delete`) in non-interactive mode.
|
|
28
|
+
|
|
29
|
+
### Authentication Priority
|
|
30
|
+
|
|
31
|
+
The CLI resolves credentials in this order:
|
|
32
|
+
|
|
33
|
+
1. `--api-key <key>` flag (highest priority)
|
|
34
|
+
2. `BAGDOCK_API_KEY` environment variable
|
|
35
|
+
3. `BAGDOCK_TOKEN` environment variable (M2M JWT)
|
|
36
|
+
4. `~/.bagdock/credentials.json` — active profile or `--profile` override (from `bagdock login`)
|
|
37
|
+
|
|
38
|
+
For CI/CD, set `BAGDOCK_API_KEY` in your environment. For interactive use, run `bagdock login`.
|
|
39
|
+
|
|
40
|
+
## Global Flags
|
|
41
|
+
|
|
42
|
+
| Flag | Description |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `--json` | Force JSON output (auto in non-TTY) |
|
|
45
|
+
| `-q, --quiet` | Suppress status messages (implies `--json`) |
|
|
46
|
+
| `--api-key <key>` | Override auth for this invocation |
|
|
47
|
+
| `-p, --profile <name>` | Use a named profile (overrides `BAGDOCK_PROFILE`) |
|
|
48
|
+
| `-V, --version` | Print version |
|
|
49
|
+
| `-h, --help` | Print help |
|
|
50
|
+
|
|
51
|
+
## Available Commands
|
|
52
|
+
|
|
53
|
+
| Command | Description |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `login` | Authenticate via OAuth2 device flow (opens browser) |
|
|
56
|
+
| `logout` | Clear stored credentials |
|
|
57
|
+
| `whoami` | Show current authenticated user |
|
|
58
|
+
| `init [dir]` | Scaffold a new project with `bagdock.json` |
|
|
59
|
+
| `dev` | Start local dev server |
|
|
60
|
+
| `deploy` | Build and deploy to Bagdock platform |
|
|
61
|
+
| `submit` | Submit app for marketplace review |
|
|
62
|
+
| `env list` | List app environment variables |
|
|
63
|
+
| `env set <key> <value>` | Set an environment variable |
|
|
64
|
+
| `env remove <key>` | Remove an environment variable |
|
|
65
|
+
| `keys create` | Create a new API key (raw key shown once) |
|
|
66
|
+
| `keys list` | List API keys |
|
|
67
|
+
| `keys delete <id>` | Revoke an API key |
|
|
68
|
+
| `doctor` | Run environment diagnostics (version, auth, config, agents) |
|
|
69
|
+
| `auth list` | List stored profiles |
|
|
70
|
+
| `auth switch [name]` | Switch active profile |
|
|
71
|
+
| `apps list` | List deployed applications |
|
|
72
|
+
| `apps get <slug>` | Show details for an application |
|
|
73
|
+
| `logs list` | List recent execution logs |
|
|
74
|
+
| `logs tail` | Tail live logs |
|
|
75
|
+
|
|
76
|
+
## Common Patterns
|
|
77
|
+
|
|
78
|
+
### Deploy to staging
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bagdock deploy
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Deploy to production
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
bagdock deploy --production
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Create an API key for CI/CD
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
bagdock keys create --name "GitHub Actions" --environment live --json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Use API key in CI/CD
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
BAGDOCK_API_KEY=sk_live_xxx bagdock deploy --production --yes
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### List keys as JSON (for scripting)
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bagdock keys list --json
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Common Mistakes
|
|
109
|
+
|
|
110
|
+
1. **Forgetting `--yes` in CI/CD** — Destructive commands like `keys delete` require `--yes` in non-interactive environments.
|
|
111
|
+
2. **Using wrong environment** — `sk_live_*` keys access production data, `sk_test_*` access sandbox. Match your intent.
|
|
112
|
+
3. **Missing `bagdock.json`** — `deploy`, `submit`, and `env` commands require a `bagdock.json` in the current directory. Run `bagdock init` first.
|
|
113
|
+
4. **Expired session** — If `whoami` fails, run `bagdock login` again. Sessions expire after 8 hours.
|
|
114
|
+
|
|
115
|
+
## When to Load References
|
|
116
|
+
|
|
117
|
+
Load specific reference files when the task involves:
|
|
118
|
+
|
|
119
|
+
- **Authentication, login, or API keys** → `references/auth.md`
|
|
120
|
+
- **Deploying, submitting, or managing apps** → `references/deploy.md`
|
|
121
|
+
- **Environment variables** → `references/env.md`
|
|
122
|
+
- **Local development** → `references/dev.md`
|
|
123
|
+
- **Error codes or troubleshooting** → `references/error-codes.md`
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Authentication Reference
|
|
2
|
+
|
|
3
|
+
## `bagdock login`
|
|
4
|
+
|
|
5
|
+
Starts an OAuth2 Device Authorization Grant (RFC 8628) flow:
|
|
6
|
+
|
|
7
|
+
1. CLI requests a device code from the Bagdock API
|
|
8
|
+
2. Opens the operator dashboard's device authorization page
|
|
9
|
+
3. Displays a user code (e.g., `ABCD-1234`)
|
|
10
|
+
4. Polls the token endpoint until the user approves
|
|
11
|
+
5. Stores an HS256 JWT in `~/.bagdock/credentials.json`
|
|
12
|
+
|
|
13
|
+
Sessions expire after 8 hours.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bagdock login
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## `bagdock logout`
|
|
20
|
+
|
|
21
|
+
Clears stored credentials from `~/.bagdock/credentials.json`.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bagdock logout
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## `bagdock whoami`
|
|
28
|
+
|
|
29
|
+
Shows the currently authenticated user. Uses the auth priority chain (see SKILL.md).
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bagdock whoami
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
JSON output:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"email": "dev@example.com",
|
|
40
|
+
"operator_id": "opreg_abc123",
|
|
41
|
+
"name": "Developer Name"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## `bagdock keys create`
|
|
46
|
+
|
|
47
|
+
Creates a new API key. The raw key is shown **once** — save it immediately.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bagdock keys create --name "Production CI" --environment live
|
|
51
|
+
bagdock keys create --name "Test key" --environment test --category restricted --scopes units:read contacts:read
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Options:
|
|
55
|
+
|
|
56
|
+
| Flag | Description | Default |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `--name <name>` | Key name (required) | — |
|
|
59
|
+
| `--type <type>` | `secret` or `publishable` | `secret` |
|
|
60
|
+
| `--category <cat>` | `standard`, `restricted`, `personal` | `standard` |
|
|
61
|
+
| `--environment <env>` | `live` or `test` | `live` |
|
|
62
|
+
| `--scopes <scopes...>` | Permission scopes | `[]` (full access for standard) |
|
|
63
|
+
|
|
64
|
+
Key prefixes follow the Stripe convention:
|
|
65
|
+
|
|
66
|
+
| Prefix | Meaning |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| `sk_live_` | Secret, live environment |
|
|
69
|
+
| `sk_test_` | Secret, test environment |
|
|
70
|
+
| `pk_live_` | Publishable, live |
|
|
71
|
+
| `pk_test_` | Publishable, test |
|
|
72
|
+
| `rk_live_` | Restricted, live |
|
|
73
|
+
| `rk_test_` | Restricted, test |
|
|
74
|
+
| `sk_personal_` | Personal key |
|
|
75
|
+
|
|
76
|
+
## `bagdock keys list`
|
|
77
|
+
|
|
78
|
+
Lists all active API keys (prefix + metadata only, never the raw key).
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
bagdock keys list
|
|
82
|
+
bagdock keys list --environment test --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## `bagdock keys delete <id>`
|
|
86
|
+
|
|
87
|
+
Revokes an API key (soft-delete). Requires `--yes` in non-interactive mode.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
bagdock keys delete ak_abc123 --yes --reason "Rotating keys"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Environment Variables
|
|
94
|
+
|
|
95
|
+
| Variable | Description |
|
|
96
|
+
| --- | --- |
|
|
97
|
+
| `BAGDOCK_API_KEY` | API key for all requests (overrides login) |
|
|
98
|
+
| `BAGDOCK_TOKEN` | M2M JWT for service-to-service auth |
|
|
99
|
+
| `BAGDOCK_API_URL` | Override API base URL (default: `https://api.bagdock.com`) |
|
|
100
|
+
| `BAGDOCK_DASHBOARD_URL` | Override dashboard URL (default: `https://dashboard.bagdock.com`) |
|
|
101
|
+
|
|
102
|
+
## Credential Storage
|
|
103
|
+
|
|
104
|
+
Credentials are stored at `~/.bagdock/credentials.json` with `0600` permissions (owner-only read/write). The directory is created with `0700` permissions.
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"accessToken": "<HS256 JWT>",
|
|
109
|
+
"expiresAt": 1700000000000,
|
|
110
|
+
"email": "dev@example.com",
|
|
111
|
+
"operatorId": "opreg_abc123"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Deploy & Apps Reference
|
|
2
|
+
|
|
3
|
+
## `bagdock deploy`
|
|
4
|
+
|
|
5
|
+
Builds locally and deploys via the Bagdock API to Cloudflare Workers for Platforms. You never need Cloudflare credentials.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bagdock deploy # staging (default)
|
|
9
|
+
bagdock deploy --preview # ephemeral preview URL
|
|
10
|
+
bagdock deploy --production # live production
|
|
11
|
+
bagdock deploy --production --yes # skip confirmation
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### URL Scheme
|
|
15
|
+
|
|
16
|
+
| Environment | URL Pattern |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| Preview | `{slug}-{hash}.pre.bdok.dev` |
|
|
19
|
+
| Staging | `{slug}.pre.bdok.dev` |
|
|
20
|
+
| Production | `{slug}.bdok.dev` |
|
|
21
|
+
|
|
22
|
+
### Governance
|
|
23
|
+
|
|
24
|
+
- **Private apps**: deploy freely to any environment
|
|
25
|
+
- **Public integrations**: production requires `review_status = 'approved'`
|
|
26
|
+
- Use `bagdock submit` to request marketplace review
|
|
27
|
+
|
|
28
|
+
### Deploy Flow
|
|
29
|
+
|
|
30
|
+
1. Reads `bagdock.json` from current directory
|
|
31
|
+
2. Bundles the entry point (`main` field) with Bun
|
|
32
|
+
3. Uploads the compiled Worker to `POST /developer/apps/:slug/deploy`
|
|
33
|
+
4. The API handles CF Workers for Platforms upload
|
|
34
|
+
|
|
35
|
+
### Options
|
|
36
|
+
|
|
37
|
+
| Flag | Description | Default |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `--env <environment>` | Target: `preview`, `staging`, `production` | `staging` |
|
|
40
|
+
| `--preview` | Shortcut for `--env preview` | — |
|
|
41
|
+
| `--production` | Shortcut for `--env production` | — |
|
|
42
|
+
| `-y, --yes` | Skip confirmation prompts | — |
|
|
43
|
+
|
|
44
|
+
## `bagdock submit`
|
|
45
|
+
|
|
46
|
+
Submits the current app for Bagdock marketplace review. Required for public integrations before production deploy.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bagdock submit
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Transitions `review_status` from `draft` to `submitted`.
|
|
53
|
+
|
|
54
|
+
## `bagdock init [dir]`
|
|
55
|
+
|
|
56
|
+
Scaffolds a new project with a `bagdock.json` configuration file.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
bagdock init
|
|
60
|
+
bagdock init my-adapter --type edge --kind adapter --category access_control
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Options
|
|
64
|
+
|
|
65
|
+
| Flag | Description |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `-t, --type <type>` | `edge` (backend worker) or `app` (UI extension) |
|
|
68
|
+
| `-k, --kind <kind>` | `adapter`, `comms`, `webhook`, `ui-extension`, `microfrontend` |
|
|
69
|
+
| `-c, --category <cat>` | Marketplace category |
|
|
70
|
+
| `-s, --slug <slug>` | Unique project slug (kebab-case) |
|
|
71
|
+
| `-n, --name <name>` | Display name |
|
|
72
|
+
|
|
73
|
+
## `bagdock.json` Spec
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"name": "My Adapter",
|
|
78
|
+
"slug": "my-adapter",
|
|
79
|
+
"version": "1.0.0",
|
|
80
|
+
"type": "edge",
|
|
81
|
+
"kind": "adapter",
|
|
82
|
+
"category": "access_control",
|
|
83
|
+
"maintainer": "operator",
|
|
84
|
+
"visibility": "private",
|
|
85
|
+
"main": "src/index.ts",
|
|
86
|
+
"compatibilityDate": "2024-09-23",
|
|
87
|
+
"env": {
|
|
88
|
+
"VENDOR_API_KEY": { "description": "API key for vendor", "required": true }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Local Development Reference
|
|
2
|
+
|
|
3
|
+
## `bagdock dev`
|
|
4
|
+
|
|
5
|
+
Starts a local development server using Wrangler, mimicking the Cloudflare Workers environment.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bagdock dev
|
|
9
|
+
bagdock dev --port 3000
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Options
|
|
13
|
+
|
|
14
|
+
| Flag | Description | Default |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| `-p, --port <port>` | Local dev server port | `8787` |
|
|
17
|
+
|
|
18
|
+
### How It Works
|
|
19
|
+
|
|
20
|
+
1. Reads `bagdock.json` from the current directory
|
|
21
|
+
2. Generates a temporary `wrangler.toml` from the project config
|
|
22
|
+
3. Starts `wrangler dev` with the appropriate settings
|
|
23
|
+
4. Hot-reloads on file changes
|
|
24
|
+
|
|
25
|
+
### Requirements
|
|
26
|
+
|
|
27
|
+
- Wrangler must be installed (globally or as a dev dependency)
|
|
28
|
+
- `bagdock.json` must exist with a valid `main` entry point
|
|
29
|
+
|
|
30
|
+
### Wrangler Overrides
|
|
31
|
+
|
|
32
|
+
Add a `wrangler` key to `bagdock.json` to override generated Wrangler config:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"name": "my-adapter",
|
|
37
|
+
"slug": "my-adapter",
|
|
38
|
+
"main": "src/index.ts",
|
|
39
|
+
"wrangler": {
|
|
40
|
+
"kv_namespaces": [
|
|
41
|
+
{ "binding": "CACHE", "id": "abc123" }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Environment Variables Reference
|
|
2
|
+
|
|
3
|
+
## `bagdock env list`
|
|
4
|
+
|
|
5
|
+
Lists environment variable keys (not values) for the current app.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bagdock env list
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires `bagdock.json` in the current directory (uses the `slug` field).
|
|
12
|
+
|
|
13
|
+
## `bagdock env set <key> <value>`
|
|
14
|
+
|
|
15
|
+
Sets an environment variable. Takes effect on the next deploy.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bagdock env set VENDOR_API_KEY sk_live_xxx
|
|
19
|
+
bagdock env set DATABASE_URL "postgres://..."
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Values are stored in Infisical (platform secret manager) and synced to the Worker's Cloudflare secrets on deploy.
|
|
23
|
+
|
|
24
|
+
## `bagdock env remove <key>`
|
|
25
|
+
|
|
26
|
+
Removes an environment variable. Takes effect on the next deploy.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bagdock env remove VENDOR_API_KEY
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Notes
|
|
33
|
+
|
|
34
|
+
- Environment variables are scoped to the app (by slug)
|
|
35
|
+
- Values are never returned by the API — only keys and last-updated timestamps
|
|
36
|
+
- Changes take effect on the next `bagdock deploy`, not immediately
|
|
37
|
+
- The API endpoint is `PUT /developer/apps/:slug/env` (set) and `DELETE /developer/apps/:slug/env/:key` (remove)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Error Codes Reference
|
|
2
|
+
|
|
3
|
+
All errors follow the structure:
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"error": {
|
|
8
|
+
"code": "ERROR_CODE",
|
|
9
|
+
"message": "Human-readable description"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Authentication Errors
|
|
15
|
+
|
|
16
|
+
| Code | Description | Resolution |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| `UNAUTHENTICATED` | No valid credentials found | Run `bagdock login` or set `BAGDOCK_API_KEY` |
|
|
19
|
+
| `UNAUTHORIZED` | Token is valid but lacks required permissions | Use a token with the correct scopes/role |
|
|
20
|
+
| `SESSION_EXPIRED` | OAuth session has expired | Run `bagdock login` again |
|
|
21
|
+
|
|
22
|
+
## Validation Errors
|
|
23
|
+
|
|
24
|
+
| Code | Description | Resolution |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `VALIDATION_ERROR` | Request body failed validation | Check the `details` array for specific field errors |
|
|
27
|
+
| `MISSING_CONFIG` | No `bagdock.json` found | Run `bagdock init` in the project directory |
|
|
28
|
+
| `CONFIRMATION_REQUIRED` | Destructive operation needs confirmation | Pass `--yes` flag |
|
|
29
|
+
|
|
30
|
+
## API Errors
|
|
31
|
+
|
|
32
|
+
| Code | Description | Resolution |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `NOT_FOUND` | Resource does not exist | Verify the ID or slug |
|
|
35
|
+
| `CONFLICT` | Operation conflicts with current state | e.g., revoking an already-revoked key |
|
|
36
|
+
| `REVIEW_REQUIRED` | Public app needs approval for production | Run `bagdock submit` first |
|
|
37
|
+
| `SERVICE_UNAVAILABLE` | Backend temporarily unavailable | Retry after a short delay |
|
|
38
|
+
| `INTERNAL_ERROR` | Unexpected server error | Report to support |
|
|
39
|
+
| `API_ERROR` | Generic API failure | Check the message for details |
|
|
40
|
+
|
|
41
|
+
## Deploy Errors
|
|
42
|
+
|
|
43
|
+
| Code | Description | Resolution |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `BUILD_FAILED` | Local build step failed | Check build output for errors |
|
|
46
|
+
| `UPLOAD_FAILED` | CF Workers upload failed | Check script size limits and compatibility |
|
|
47
|
+
|
|
48
|
+
## Exit Codes
|
|
49
|
+
|
|
50
|
+
| Code | Meaning |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `0` | Success |
|
|
53
|
+
| `1` | Error (details in stderr) |
|