@blinkdotnew/cli 0.3.7 → 0.4.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/README.md CHANGED
@@ -1,427 +1,258 @@
1
- # @blinkdotnew/cli
1
+ # Blink CLI
2
2
 
3
- The Blink platform CLI. Deploy apps, query databases, generate AI content, manage storage, and control Blink Claw agents all from your terminal or agent scripts.
3
+ The command-line interface for [Blink](https://blink.new) full-stack cloud infrastructure from your terminal.
4
+
5
+ Create projects, deploy frontends, manage databases, configure auth, set up custom domains, and more. Designed for developers and AI coding agents alike.
6
+
7
+ ```bash
8
+ npx @blinkdotnew/cli --help
9
+ ```
10
+
11
+ ## Install
4
12
 
5
13
  ```bash
6
14
  npm install -g @blinkdotnew/cli
7
- blink --help
8
15
  ```
9
16
 
10
- ---
17
+ Requires Node.js 22+.
11
18
 
12
19
  ## Quick Start
13
20
 
14
21
  ```bash
15
- # Install
16
- npm install -g @blinkdotnew/cli
17
-
18
- # Authenticate (enter your blnk_ak_... API key from blink.new → Settings → API Keys)
22
+ # Authenticate
19
23
  blink login --interactive
20
24
 
21
- # See full context: agent + project + auth
22
- blink status
23
-
24
- # Manage Claw agents
25
- blink agent list
26
- eval $(blink agent use clw_xxx --export)
27
- blink secrets set GITHUB_TOKEN ghp_xxx
28
- blink secrets list
25
+ # Create and link a project
26
+ blink init --name "my-app"
29
27
 
30
- # Deploy an app
28
+ # Deploy
31
29
  npm run build && blink deploy ./dist --prod
32
30
 
33
- # Query your database
34
- blink db query "SELECT count(*) FROM users"
35
-
36
- # Generate AI content
37
- blink ai image "a glowing blink logo on dark background"
38
- blink ai text "Summarize this article: ..."
39
-
40
- # Scrape websites
41
- blink scrape https://lovable.dev --extract "pricing tiers and costs"
42
- blink scrape https://example.com --text
31
+ # Done your app is live
43
32
  ```
44
33
 
45
- ---
34
+ ## What You Can Do
46
35
 
47
- ## Authentication
36
+ | Command | Description |
37
+ |---------|-------------|
38
+ | `blink init` | Create a new project and link it to the current directory |
39
+ | `blink deploy ./dist --prod` | Deploy your built app to production |
40
+ | `blink db query "SELECT * FROM users"` | Run SQL against your project's database |
41
+ | `blink env set STRIPE_KEY sk_live_xxx` | Set environment variables (secrets) |
42
+ | `blink backend deploy` | Deploy a Hono backend to Cloudflare Workers |
43
+ | `blink auth-config set --provider google --enabled true` | Configure authentication providers |
44
+ | `blink domains add myapp.com` | Connect a custom domain |
45
+ | `blink hosting activate` | Activate production hosting |
46
+ | `blink storage upload ./photo.jpg` | Upload files to project storage |
47
+ | `blink ai image "a logo for my app"` | Generate images, text, video, speech |
48
48
 
49
- The CLI resolves credentials in this order (highest priority first):
49
+ ## Full Command Reference
50
50
 
51
- | Source | How |
52
- |---|---|
53
- | `--token <key>` flag | One-off override per command |
54
- | `BLINK_API_KEY` env var | CI/CD and Claw agents (set automatically) |
55
- | `~/.config/blink/config.toml` | Stored after `blink login` |
51
+ ### Project Management
56
52
 
57
53
  ```bash
58
- # Interactive login (saves to ~/.config/blink/config.toml)
59
- blink login --interactive
60
-
61
- # One-off with token flag
62
- blink deploy --token blnk_ak_xxx ./dist
63
-
64
- # CI / GitHub Actions
65
- BLINK_API_KEY=blnk_ak_xxx blink deploy ./dist --prod
54
+ blink init # Create project + link to current dir
55
+ blink init --name "My App" # Create with custom name
56
+ blink link # Link existing project (interactive picker)
57
+ blink link proj_xxx # Link to specific project
58
+ blink project list # List all projects
59
+ blink project create "My App" # Create without linking
60
+ blink project delete proj_xxx --yes # Delete a project
61
+ blink status # Show current context (project + auth)
66
62
  ```
67
63
 
68
- Your API key lives at **blink.new → Settings → API Keys** (`blnk_ak_...`).
69
-
70
- ### Multiple accounts
71
-
72
- ```toml
73
- # ~/.config/blink/config.toml
74
- [default]
75
- api_key = "blnk_ak_personal"
76
-
77
- [work]
78
- api_key = "blnk_ak_work"
79
- ```
64
+ ### Deploy
80
65
 
81
66
  ```bash
82
- blink --profile work deploy ./dist
67
+ blink deploy ./dist --prod # Deploy to production
68
+ blink deploy ./dist # Preview deployment
69
+ blink deployments # List past deployments
70
+ blink rollback # Rollback to previous version
83
71
  ```
84
72
 
85
- ---
73
+ ### Database
86
74
 
87
- ## Commands
88
-
89
- ### `blink deploy` — Deploy to Blink hosting
75
+ Each project gets its own SQLite database powered by libSQL.
90
76
 
91
77
  ```bash
92
- blink deploy # Deploy CWD, use linked project
93
- blink deploy ./dist # Deploy specific build dir
94
- blink deploy proj_xxx ./dist # Explicit project + dir
95
- blink deploy ./dist --prod # Production (live domain)
96
- blink deploy ./dist --preview # Preview URL (default)
97
- blink deploy ./dist --name "v2 beta" # Label this deployment
98
-
99
- blink deployments # List deployments
100
- blink rollback # Rollback production to previous deploy
78
+ blink db query "SELECT * FROM users LIMIT 10"
79
+ blink db exec schema.sql # Run a SQL file
80
+ blink db list # Show all tables
81
+ blink db list users # Show rows in a table
101
82
  ```
102
83
 
103
- The CLI packages your **pre-built** output directory and uploads it. Run your build first:
84
+ ### Environment Variables
104
85
 
105
86
  ```bash
106
- npm run build && blink deploy ./dist --prod
87
+ blink env list # List all env vars
88
+ blink env set DATABASE_URL postgres://...
89
+ blink env delete OLD_KEY
90
+ blink env push .env # Bulk import from .env file
91
+ blink env pull > .env.local # Export to file
107
92
  ```
108
93
 
109
- Preview deploys get a URL like `preview-a1b2c3d4.sites.blink.new`.
110
- Production deploys go to your custom domain or `{id}.sites.blink.new`.
111
-
112
- ---
94
+ ### Backend (Cloudflare Workers)
113
95
 
114
- ### `blink project`Project management
96
+ Deploy a Hono server to Cloudflare Workers for Platforms each project gets its own isolated V8 worker.
115
97
 
116
98
  ```bash
117
- blink project list # List all workspace projects
118
- blink project create "My App" # Create a new project
119
- blink project delete proj_xxx # Delete a project (confirms first)
120
-
121
- blink link # Link current dir to a project (interactive picker)
122
- blink link proj_xxx # Link to specific project
123
- blink unlink # Remove .blink/project.json
124
- blink status # Show linked project + auth source
99
+ blink backend deploy # Deploy backend/ folder
100
+ blink backend deploy ./server # Deploy from custom directory
101
+ blink backend status # Check deployment status
102
+ blink backend logs # View request logs
103
+ blink backend delete --yes # Remove backend
125
104
  ```
126
105
 
127
- Once linked, commands that need a project ID use `.blink/project.json` automatically.
128
-
129
- ---
130
-
131
- ### `blink use` — Set active project for a shell session
106
+ ### Auth Configuration
132
107
 
133
108
  ```bash
134
- blink use proj_xxx # Prints the export command
135
- eval $(blink use proj_xxx --export) # Actually sets it in your shell
136
- export BLINK_ACTIVE_PROJECT=proj_xxx # Or set manually
109
+ blink auth-config get # Show current auth config
110
+ blink auth-config set --provider google --enabled true
111
+ blink auth-config set --mode managed
112
+ blink auth-config byoc-set --provider google --client-id X --client-secret Y
113
+ blink auth-config byoc-remove --provider google
137
114
  ```
138
115
 
139
- After this, omit `proj_xxx` from any command — it's inferred from the env var.
140
-
141
- ---
142
-
143
- ### `blink db` — Database (Turso/SQLite per project)
116
+ ### Custom Domains
144
117
 
145
118
  ```bash
146
- # Query (two forms)
147
- blink db query "SELECT * FROM users LIMIT 10"
148
- blink db query proj_xxx "SELECT * FROM users LIMIT 10"
149
-
150
- # Execute a SQL file
151
- blink db exec schema.sql
152
- blink db exec proj_xxx migrations/001.sql
153
-
154
- # List tables
155
- blink db list
119
+ blink domains list # List project domains
120
+ blink domains add myapp.com # Add a custom domain
121
+ blink domains verify <domain_id> # Verify DNS configuration
122
+ blink domains remove <domain_id> --yes # Remove a domain
123
+ blink domains search "myapp" # Search available domains
124
+ blink domains purchase myapp.com --yes # Purchase a domain
125
+ blink domains connect myapp.com # Connect purchased domain to project
126
+ blink domains my # List your purchased domains
127
+ ```
156
128
 
157
- # List rows in a table
158
- blink db list users
159
- blink db list proj_xxx users --limit 50
129
+ ### Hosting
160
130
 
161
- # Machine-readable output
162
- blink db query "SELECT id, email FROM users" --json
131
+ ```bash
132
+ blink hosting status # Check hosting state + URLs
133
+ blink hosting activate # Activate production hosting
134
+ blink hosting deactivate --yes # Deactivate hosting
135
+ blink hosting reactivate # Reactivate after deactivation
163
136
  ```
164
137
 
165
- ---
166
-
167
- ### `blink storage` — File storage
138
+ ### Storage
168
139
 
169
140
  ```bash
170
- # Upload
171
- blink storage upload ./logo.png
172
- blink storage upload proj_xxx ./logo.png --path images/logo.png
173
-
174
- # List
141
+ blink storage upload ./photo.jpg
175
142
  blink storage list
176
- blink storage list images/
177
-
178
- # Download
179
- blink storage download images/logo.png ./local-logo.png
180
-
181
- # Get public URL
182
- blink storage url images/logo.png
183
-
184
- # Delete
185
- blink storage delete images/old-logo.png
143
+ blink storage url images/photo.jpg # Get CDN URL
144
+ blink storage download images/photo.jpg ./local.jpg
145
+ blink storage delete images/old.jpg
186
146
  ```
187
147
 
188
- ---
189
-
190
- ### `blink ai` — AI generation
148
+ ### AI
191
149
 
192
150
  ```bash
193
- # Text
194
- blink ai text "Summarize this in 3 bullets: ..."
195
- blink ai text "Write a product description" --model anthropic/claude-sonnet-4.5
196
-
197
- # Image
151
+ blink ai text "Summarize this: ..."
198
152
  blink ai image "a futuristic city at sunset"
199
- blink ai image "a futuristic city" --model fal-ai/nano-banana-pro --n 4
200
- blink ai image "a city at sunset" --output ./city.jpg
201
-
202
- # Image editing
203
- blink ai image-edit "make it night time" https://example.com/city.jpg
204
-
205
- # Video (text-to-video)
206
- blink ai video "a drone flyover of a neon city"
207
- blink ai video "timelapse of clouds" --model fal-ai/veo3.1 --duration 10s --aspect 9:16
208
-
209
- # Video (image-to-video) — local file or URL
210
- blink ai animate "make it come alive" ./photo.jpg
211
- blink ai animate "pan slowly to the right" https://example.com/photo.jpg
212
-
213
- # Speech (text-to-speech)
214
- blink ai speech "Hello, welcome to Blink."
215
- blink ai speech "Hello world" --voice nova --output ./greeting.mp3
216
- # Voices: alloy, echo, fable, onyx, nova, shimmer
217
-
218
- # Transcription
153
+ blink ai video "ocean waves" --duration 10s
154
+ blink ai speech "Hello world" --voice nova --output hello.mp3
219
155
  blink ai transcribe ./meeting.mp3
220
- blink ai transcribe https://example.com/audio.mp3 --language en
221
156
  ```
222
157
 
223
- ---
224
-
225
- ### `blink fetch`, `blink search`, `blink scrape` — Web & data
158
+ ### Security & CORS
226
159
 
227
160
  ```bash
228
- # Fetch any URL via Blink proxy (handles CORS, auth headers)
229
- blink fetch https://api.github.com/users/octocat
230
- blink fetch https://api.example.com/data --method POST --body '{"key":"val"}'
231
- blink fetch https://api.example.com --header "X-API-Key: secret"
232
-
233
- # Web search
234
- blink search "latest AI news"
235
- blink search "React Server Components" --count 10 --json
236
-
237
- # Scrape web pages
238
- blink scrape https://example.com # Raw response
239
- blink scrape https://example.com --text # Clean text (strips HTML)
240
- blink scrape https://example.com --extract "all prices" # AI-extract specific data
241
- blink scrape https://news.ycombinator.com --extract "top 10 story titles and URLs"
242
- blink scrape https://example.com --extract "contact email" --json
161
+ blink security get # Show per-module auth policy
162
+ blink security set --module db --require-auth true
163
+ blink cors get # Show allowed origins
164
+ blink cors set --origins https://example.com https://app.example.com
243
165
  ```
244
166
 
245
- No project key needed — `blink scrape` uses your workspace key only.
246
-
247
- - `--text` — strips all HTML tags, returns readable text
248
- - `--extract <instructions>` — uses AI (Gemini Flash) to extract exactly what you ask for
249
- - Combine with `--json` for `{ url, content }` or `{ url, extracted }` output
250
-
251
- ---
252
-
253
- ### `blink realtime` — Pub/sub
167
+ ### Workspace Management
254
168
 
255
169
  ```bash
256
- # Publish an event to a channel
257
- blink realtime publish updates '{"type":"refresh"}'
258
- blink realtime publish proj_xxx updates '{"type":"refresh","data":{"count":42}}'
170
+ blink workspace list # List workspaces
171
+ blink workspace create "My Team" # Create a workspace
172
+ blink workspace switch wsp_xxx # Switch active workspace
173
+ blink workspace members wsp_xxx # List members
174
+ blink workspace invite user@example.com wsp_xxx --role admin
259
175
  ```
260
176
 
261
- ---
262
-
263
- ### `blink rag` — Knowledge base / RAG
177
+ ### Versions
264
178
 
265
179
  ```bash
266
- # Search
267
- blink rag search "how does billing work"
268
- blink rag search "billing" --ai # AI-enhanced search
269
- blink rag search proj_xxx "billing" --limit 10
270
-
271
- # Upload a document
272
- blink rag upload ./docs/faq.md
273
- blink rag upload proj_xxx ./docs/faq.md --collection coll_xxx
274
-
275
- # List collections
276
- blink rag collections
180
+ blink versions list # List saved snapshots
181
+ blink versions save --message "v1.0" # Save a snapshot
182
+ blink versions restore ver_xxx --yes # Restore to a snapshot
277
183
  ```
278
184
 
279
- ---
280
-
281
- ### `blink notify` — Email
185
+ ### Billing
282
186
 
283
187
  ```bash
284
- blink notify email user@example.com "Welcome!" "Thanks for signing up."
285
- blink notify email user@example.com "Newsletter" --file ./email.html
286
- blink notify email proj_xxx user@example.com "Subject" "Body"
188
+ blink credits # Check credit usage
189
+ blink usage # Usage breakdown
190
+ blink usage --period month # Monthly summary
287
191
  ```
288
192
 
289
- ---
290
-
291
- ### `blink connector` — OAuth connectors
193
+ ### Personal Access Tokens
292
194
 
293
195
  ```bash
294
- # Execute a connector action (Notion, Google, Slack, HubSpot, etc.)
295
- blink connector exec notion search_pages '{"query":"meeting notes"}'
296
- blink connector exec google_calendar list_events '{}'
297
- blink connector exec slack post_message '{"channel":"C123","text":"Hello"}' --method POST
298
- blink connector exec notion create_page '{"title":"New Page"}' --account acct_xxx
196
+ blink tokens list # List all PATs
197
+ blink tokens create --name "CI key" # Create a new token (shown once)
198
+ blink tokens revoke tok_xxx --yes # Revoke a token
299
199
  ```
300
200
 
301
- ---
302
-
303
- ## Global Flags
304
-
305
- Available on every command:
306
-
307
- | Flag | Description |
308
- |---|---|
309
- | `--token <key>` | Override API key for this command only |
310
- | `--json` | Output raw JSON (no colors, no spinners — great for scripting) |
311
- | `--yes` | Skip confirmation prompts |
312
- | `--profile <name>` | Use a named profile from `config.toml` |
313
- | `--debug` | Print full request/response details |
314
- | `--version` | Print CLI version |
315
- | `--help` | Show help for any command |
201
+ ## Authentication
316
202
 
317
- ---
203
+ Three ways to authenticate, checked in this order:
318
204
 
319
- ## Scripting & CI/CD
205
+ 1. **`--token` flag** — per-command override
206
+ 2. **`BLINK_API_KEY` env var** — for CI/CD and coding agents
207
+ 3. **Config file** — saved by `blink login --interactive` at `~/.config/blink/config.toml`
320
208
 
321
- The `--json` flag makes every command machine-readable:
209
+ Get your API key at [blink.new/settings?tab=api-keys](https://blink.new/settings?tab=api-keys).
322
210
 
323
211
  ```bash
324
- # Get deployment URL from a deploy
325
- URL=$(blink deploy ./dist --prod --json | jq -r '.url')
326
- echo "Deployed to: $URL"
327
-
328
- # Query database and pipe to jq
329
- blink db query "SELECT id, email FROM users" --json | jq '.[].email'
330
-
331
- # Generate image and get URL
332
- IMG=$(blink ai image "a logo" --json | jq -r '.url')
333
- blink storage upload ./banner.png --json | jq -r '.url'
334
- ```
335
-
336
- ### GitHub Actions example
337
-
338
- ```yaml
339
- - name: Deploy to Blink
340
- env:
341
- BLINK_API_KEY: ${{ secrets.BLINK_API_KEY }}
342
- run: |
343
- npm install -g @blinkdotnew/cli
344
- blink deploy ./dist --prod --json
345
- ```
346
-
347
- ---
348
-
349
- ## Config Files
350
-
351
- | File | Purpose |
352
- |---|---|
353
- | `~/.config/blink/config.toml` | Auth tokens, workspace ID, named profiles |
354
- | `.blink/project.json` | Per-directory project link (like `.vercel/project.json`) |
355
-
356
- `.blink/project.json` is created by `blink link` — add it to `.gitignore`.
357
-
358
- ---
359
-
360
- ## Blink Claw Agents
212
+ # Interactive saves to config file
213
+ blink login --interactive
361
214
 
362
- The CLI is **pre-installed** in every Blink Claw agent (Fly.io Firecracker VM). These env vars are already injected no login needed:
215
+ # Environment variablefor CI/agents
216
+ export BLINK_API_KEY=blnk_ak_...
363
217
 
364
- ```
365
- BLINK_API_KEY auth token (workspace-scoped)
366
- BLINK_AGENT_ID this agent's ID — auto-used by blink agent/secrets commands
367
- BLINK_APIS_URL https://core.blink.new
368
- BLINK_APP_URL https://blink.new
218
+ # Per-command
219
+ blink deploy ./dist --prod --token blnk_ak_...
369
220
  ```
370
221
 
371
- Agents use the CLI directly in skill scripts:
222
+ ## Project Context
372
223
 
373
- ```bash
374
- # In openclaw/skills/blink-image/scripts/generate.sh
375
- blink ai image "$PROMPT" --model "$MODEL" --json
376
- ```
377
-
378
- ### `blink agent` — Manage agents
224
+ Commands that operate on a project resolve it in this order:
379
225
 
380
- ```bash
381
- blink agent list # List all agents in workspace
382
- blink agent use clw_xxx # Show how to set active agent
383
- eval $(blink agent use clw_xxx --export) # Set active agent for this session
384
- blink agent status # Show current agent details
385
- blink agent status clw_xxx # Show specific agent details
386
- ```
226
+ 1. **Positional argument** — `blink db query proj_xxx "SELECT 1"`
227
+ 2. **`BLINK_ACTIVE_PROJECT` env var** `eval $(blink use proj_xxx --export)`
228
+ 3. **`.blink/project.json`** created by `blink link` or `blink init`
387
229
 
388
- On Claw machines, `BLINK_AGENT_ID` is already set — `blink agent status` works with zero config.
230
+ ## Machine-Readable Output
389
231
 
390
- ### `blink secrets` Agent encrypted vault
232
+ Every command supports `--json` for scripting and AI agent integration:
391
233
 
392
234
  ```bash
393
- # All commands auto-use BLINK_AGENT_ID on Claw machines
394
- blink secrets list # List secret key names (values never shown)
395
- blink secrets set GITHUB_TOKEN ghp_xxx # Add or update a secret
396
- blink secrets delete OLD_KEY # Remove a secret (--yes to skip prompt)
397
-
398
- # Cross-agent management (agent manager pattern)
399
- blink secrets list --agent clw_other # Another agent's keys
400
- blink secrets set --agent clw_other OPENAI_KEY sk-xxx # Set on another agent
235
+ blink deploy ./dist --prod --json | jq '.url'
236
+ blink db query "SELECT email FROM users" --json | jq '.[].email'
237
+ blink env list --json | jq '.[].key'
401
238
  ```
402
239
 
403
- Secrets are stored encrypted and available as `$KEY_NAME` in all agent shell commands.
240
+ ## For Coding Agents
404
241
 
405
- Agent ID resolution for `blink agent` and `blink secrets`:
406
- 1. `--agent <id>` flag
407
- 2. `BLINK_AGENT_ID` env var ← always set on Claw Fly machines
408
- 3. `BLINK_ACTIVE_AGENT` env var ← from `eval $(blink agent use clw_xxx --export)`
242
+ The Blink CLI is designed to work seamlessly with AI coding agents like Cursor, Claude Code, and Codex:
409
243
 
410
- ### `blink status`Full context at a glance
244
+ - **Non-interactive by default** all inputs are flags, no menus or prompts
245
+ - **`--json` mode** — structured output for every command
246
+ - **`--yes` flag** — skip confirmations for automation
247
+ - **Actionable errors** — every error message includes the exact command to fix it
248
+ - **Layered help** — `blink --help` for overview, `blink backend --help` for a group, `blink backend deploy --help` for full details
411
249
 
412
- ```bash
413
- $ BLINK_AGENT_ID=clw_xxx blink status
414
-
415
- Agent clw_xxx (BLINK_AGENT_ID env)
416
- Project proj_yyy (.blink/project.json)
417
- Auth ~/.config/blink/config.toml
418
- ```
250
+ ## Links
419
251
 
420
- ---
252
+ - [Blink](https://blink.new) — Build full-stack apps with AI
253
+ - [Documentation](https://blink.new/docs/cli)
254
+ - [SDK](https://www.npmjs.com/package/@blinkdotnew/sdk)
421
255
 
422
- ## Links
256
+ ## License
423
257
 
424
- - **npm**: https://www.npmjs.com/package/@blinkdotnew/cli
425
- - **Blink platform**: https://blink.new
426
- - **Docs**: https://blink.new/docs
427
- - **Source**: `blink-sdk/packages/cli/` in the `blink-new/blink-sdk` repo
258
+ MIT