@blinkdotnew/cli 0.1.1 → 0.1.3

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 CHANGED
@@ -254,38 +254,51 @@ Always use `<arg1> [arg2]` and disambiguate in the action handler:
254
254
 
255
255
  ## Publishing
256
256
 
257
- **GitHub Actions**: `.github/workflows/publish-cli.yml` in the `blink-new/blink-sdk` repo.
257
+ ### Normal release flow (automated use this every time)
258
258
 
259
- **Trigger**: push to `main` with a change to `packages/cli/package.json` (version bump).
260
- **Auth**: OIDC Trusted Publisher — no NPM_TOKEN stored. Configured on npmjs.com: org `blinkdotnew`, package `cli`, repo `blink-new/blink-sdk`, workflow `publish-cli.yml`, environment `npm`.
259
+ 1. Edit `packages/cli/package.json` bump version
260
+ 2. Build locally to verify: `npm run build`
261
+ 3. Commit and push to `blink-new/blink-sdk` main:
261
262
 
262
- **To release a new version:**
263
263
  ```bash
264
264
  cd blink-sdk
265
265
  git checkout main && git pull origin main
266
- # Edit packages/cli/package.json — bump version (e.g. 0.1.0 → 0.1.1)
267
- npm run build # verify it builds
268
- git commit -am "chore(cli): bump version to 0.1.1"
266
+ # bump version in packages/cli/package.json
267
+ npm run build
268
+ git commit -am "chore(cli): bump version to X.X.X"
269
269
  git push origin main
270
- # → GitHub Actions publishes @blinkdotnew/cli@0.1.1 to npm (~60s)
270
+ # → GitHub Actions (publish-cli.yml) publishes to npm in ~60s. Done.
271
271
  ```
272
272
 
273
- **Version convention:**
274
- - `0.1.x`patch: bug fixes, minor arg/output improvements
275
- - `0.x.0` — minor: new commands, new capabilities
276
- - `x.0.0` — major: breaking changes to command syntax
273
+ **Workflow**: `.github/workflows/publish-cli.yml`. Fires on any push to `main` that touches `packages/cli/package.json`.
274
+ **Auth**: OIDC Trusted Publisher no `NPM_TOKEN` needed, no login required.
277
275
 
278
- **Docker image update**: after publishing, update the `RUN npm install -g @blinkdotnew/cli@X.X.X` line in the Blink Claw Dockerfile (in `openclaw/`) and push to main to trigger a Docker rebuild.
276
+ ### Version convention
279
277
 
280
- ---
278
+ | Bump | When |
279
+ |---|---|
280
+ | `0.1.x` patch | Bug fixes, output/flag tweaks |
281
+ | `0.x.0` minor | New commands, new capabilities |
282
+ | `x.0.0` major | Breaking command syntax changes |
283
+
284
+ ### After publishing — update the Claw Docker image
285
+
286
+ The CLI is pre-installed in the Blink Claw Docker image via `npm install -g @blinkdotnew/cli`. After publishing a new version, update the install line in the Claw Dockerfile (`openclaw/Dockerfile`) and push to `openclaw` main to trigger a Docker rebuild.
287
+
288
+ ### First-time publish (already done — for reference only)
281
289
 
282
- ## npmjs.com Setup (one-time, already done)
290
+ The very first publish cannot use OIDC (package must exist on npm first). It was done manually:
291
+ ```bash
292
+ cd blink-sdk/packages/cli
293
+ npm run build
294
+ npm login # browser 2FA prompt
295
+ npm publish --access public
296
+ ```
297
+ Package `@blinkdotnew/cli` now exists on npm. All future publishes use the automated workflow above.
283
298
 
284
- OIDC Trusted Publisher must be configured at npmjs.com:
285
- - Organization: `blinkdotnew`
286
- - Package: `cli`
287
- - GitHub repo: `blink-new/blink-sdk`
288
- - Workflow file: `publish-cli.yml`
289
- - Environment: `npm`
299
+ ### OIDC setup (already configured do not repeat)
290
300
 
291
- GitHub repo must have environment `npm` created (Settings → Environments → New environment → `npm`).
301
+ Trusted Publisher is live:
302
+ - npmjs.com → package `@blinkdotnew/cli` → Settings → Trusted Publishers
303
+ - Repo: `blink-new/blink-sdk`, workflow: `publish-cli.yml`, environment: `npm`
304
+ - GitHub → `blink-new/blink-sdk` → Settings → Environments → `npm` (exists)
package/README.md ADDED
@@ -0,0 +1,361 @@
1
+ # @blinkdotnew/cli
2
+
3
+ The Blink platform CLI. Deploy apps, query databases, generate AI content, manage storage — all from your terminal or agent scripts.
4
+
5
+ ```bash
6
+ npm install -g @blinkdotnew/cli
7
+ blink --help
8
+ ```
9
+
10
+ ---
11
+
12
+ ## Quick Start
13
+
14
+ ```bash
15
+ # Install
16
+ npm install -g @blinkdotnew/cli
17
+
18
+ # Authenticate (enter your blnk_ak_... API key)
19
+ blink login --interactive
20
+
21
+ # Link a project
22
+ blink link
23
+
24
+ # Deploy a built app
25
+ blink deploy ./dist --prod
26
+
27
+ # Query your database
28
+ blink db query "SELECT count(*) FROM users"
29
+
30
+ # Generate an image
31
+ blink ai image "a glowing blink logo on dark background"
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Authentication
37
+
38
+ The CLI resolves credentials in this order (highest priority first):
39
+
40
+ | Source | How |
41
+ |---|---|
42
+ | `--token <key>` flag | One-off override per command |
43
+ | `BLINK_API_KEY` env var | CI/CD and Claw agents (set automatically) |
44
+ | `~/.config/blink/config.toml` | Stored after `blink login` |
45
+
46
+ ```bash
47
+ # Interactive login (saves to ~/.config/blink/config.toml)
48
+ blink login --interactive
49
+
50
+ # One-off with token flag
51
+ blink deploy --token blnk_ak_xxx ./dist
52
+
53
+ # CI / GitHub Actions
54
+ BLINK_API_KEY=blnk_ak_xxx blink deploy ./dist --prod
55
+ ```
56
+
57
+ Your API key lives at **blink.new → Settings → API Keys** (`blnk_ak_...`).
58
+
59
+ ### Multiple accounts
60
+
61
+ ```toml
62
+ # ~/.config/blink/config.toml
63
+ [default]
64
+ api_key = "blnk_ak_personal"
65
+
66
+ [work]
67
+ api_key = "blnk_ak_work"
68
+ ```
69
+
70
+ ```bash
71
+ blink --profile work deploy ./dist
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Commands
77
+
78
+ ### `blink deploy` — Deploy to Blink hosting
79
+
80
+ ```bash
81
+ blink deploy # Deploy CWD, use linked project
82
+ blink deploy ./dist # Deploy specific build dir
83
+ blink deploy proj_xxx ./dist # Explicit project + dir
84
+ blink deploy ./dist --prod # Production (live domain)
85
+ blink deploy ./dist --preview # Preview URL (default)
86
+ blink deploy ./dist --name "v2 beta" # Label this deployment
87
+
88
+ blink deployments # List deployments
89
+ blink rollback # Rollback production to previous deploy
90
+ ```
91
+
92
+ The CLI packages your **pre-built** output directory and uploads it. Run your build first:
93
+
94
+ ```bash
95
+ npm run build && blink deploy ./dist --prod
96
+ ```
97
+
98
+ Preview deploys get a URL like `preview-a1b2c3d4.sites.blink.new`.
99
+ Production deploys go to your custom domain or `{id}.sites.blink.new`.
100
+
101
+ ---
102
+
103
+ ### `blink project` — Project management
104
+
105
+ ```bash
106
+ blink project list # List all workspace projects
107
+ blink project create "My App" # Create a new project
108
+ blink project delete proj_xxx # Delete a project (confirms first)
109
+
110
+ blink link # Link current dir to a project (interactive picker)
111
+ blink link proj_xxx # Link to specific project
112
+ blink unlink # Remove .blink/project.json
113
+ blink status # Show linked project + auth source
114
+ ```
115
+
116
+ Once linked, commands that need a project ID use `.blink/project.json` automatically.
117
+
118
+ ---
119
+
120
+ ### `blink use` — Set active project for a shell session
121
+
122
+ ```bash
123
+ blink use proj_xxx # Prints the export command
124
+ eval $(blink use proj_xxx --export) # Actually sets it in your shell
125
+ export BLINK_ACTIVE_PROJECT=proj_xxx # Or set manually
126
+ ```
127
+
128
+ After this, omit `proj_xxx` from any command — it's inferred from the env var.
129
+
130
+ ---
131
+
132
+ ### `blink db` — Database (Turso/SQLite per project)
133
+
134
+ ```bash
135
+ # Query (two forms)
136
+ blink db query "SELECT * FROM users LIMIT 10"
137
+ blink db query proj_xxx "SELECT * FROM users LIMIT 10"
138
+
139
+ # Execute a SQL file
140
+ blink db exec schema.sql
141
+ blink db exec proj_xxx migrations/001.sql
142
+
143
+ # List tables
144
+ blink db list
145
+
146
+ # List rows in a table
147
+ blink db list users
148
+ blink db list proj_xxx users --limit 50
149
+
150
+ # Machine-readable output
151
+ blink db query "SELECT id, email FROM users" --json
152
+ ```
153
+
154
+ ---
155
+
156
+ ### `blink storage` — File storage
157
+
158
+ ```bash
159
+ # Upload
160
+ blink storage upload ./logo.png
161
+ blink storage upload proj_xxx ./logo.png --path images/logo.png
162
+
163
+ # List
164
+ blink storage list
165
+ blink storage list images/
166
+
167
+ # Download
168
+ blink storage download images/logo.png ./local-logo.png
169
+
170
+ # Get public URL
171
+ blink storage url images/logo.png
172
+
173
+ # Delete
174
+ blink storage delete images/old-logo.png
175
+ ```
176
+
177
+ ---
178
+
179
+ ### `blink ai` — AI generation
180
+
181
+ ```bash
182
+ # Text
183
+ blink ai text "Summarize this in 3 bullets: ..."
184
+ blink ai text "Write a product description" --model anthropic/claude-sonnet-4.5
185
+
186
+ # Image
187
+ blink ai image "a futuristic city at sunset"
188
+ blink ai image "a futuristic city" --model fal-ai/nano-banana-pro --n 4
189
+ blink ai image "a city at sunset" --output ./city.jpg
190
+
191
+ # Image editing
192
+ blink ai image-edit "make it night time" https://example.com/city.jpg
193
+
194
+ # Video (text-to-video)
195
+ blink ai video "a drone flyover of a neon city"
196
+ blink ai video "timelapse of clouds" --model fal-ai/veo3.1 --duration 10s --aspect 9:16
197
+
198
+ # Video (image-to-video) — local file or URL
199
+ blink ai animate "make it come alive" ./photo.jpg
200
+ blink ai animate "pan slowly to the right" https://example.com/photo.jpg
201
+
202
+ # Speech (text-to-speech)
203
+ blink ai speech "Hello, welcome to Blink."
204
+ blink ai speech "Hello world" --voice nova --output ./greeting.mp3
205
+ # Voices: alloy, echo, fable, onyx, nova, shimmer
206
+
207
+ # Transcription
208
+ blink ai transcribe ./meeting.mp3
209
+ blink ai transcribe https://example.com/audio.mp3 --language en
210
+ ```
211
+
212
+ ---
213
+
214
+ ### `blink fetch` and `blink search` — Web & data
215
+
216
+ ```bash
217
+ # Fetch any URL via Blink proxy (handles CORS, auth headers)
218
+ blink fetch https://api.github.com/users/octocat
219
+ blink fetch https://api.example.com/data --method POST --body '{"key":"val"}'
220
+ blink fetch https://api.example.com --header "X-API-Key: secret"
221
+
222
+ # Web search
223
+ blink search "latest AI news"
224
+ blink search "React Server Components" --count 10 --json
225
+ ```
226
+
227
+ ---
228
+
229
+ ### `blink realtime` — Pub/sub
230
+
231
+ ```bash
232
+ # Publish an event to a channel
233
+ blink realtime publish updates '{"type":"refresh"}'
234
+ blink realtime publish proj_xxx updates '{"type":"refresh","data":{"count":42}}'
235
+ ```
236
+
237
+ ---
238
+
239
+ ### `blink rag` — Knowledge base / RAG
240
+
241
+ ```bash
242
+ # Search
243
+ blink rag search "how does billing work"
244
+ blink rag search "billing" --ai # AI-enhanced search
245
+ blink rag search proj_xxx "billing" --limit 10
246
+
247
+ # Upload a document
248
+ blink rag upload ./docs/faq.md
249
+ blink rag upload proj_xxx ./docs/faq.md --collection coll_xxx
250
+
251
+ # List collections
252
+ blink rag collections
253
+ ```
254
+
255
+ ---
256
+
257
+ ### `blink notify` — Email
258
+
259
+ ```bash
260
+ blink notify email user@example.com "Welcome!" "Thanks for signing up."
261
+ blink notify email user@example.com "Newsletter" --file ./email.html
262
+ blink notify email proj_xxx user@example.com "Subject" "Body"
263
+ ```
264
+
265
+ ---
266
+
267
+ ### `blink connector` — OAuth connectors
268
+
269
+ ```bash
270
+ # Execute a connector action (Notion, Google, Slack, HubSpot, etc.)
271
+ blink connector exec notion search_pages '{"query":"meeting notes"}'
272
+ blink connector exec google_calendar list_events '{}'
273
+ blink connector exec slack post_message '{"channel":"C123","text":"Hello"}' --method POST
274
+ blink connector exec notion create_page '{"title":"New Page"}' --account acct_xxx
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Global Flags
280
+
281
+ Available on every command:
282
+
283
+ | Flag | Description |
284
+ |---|---|
285
+ | `--token <key>` | Override API key for this command only |
286
+ | `--json` | Output raw JSON (no colors, no spinners — great for scripting) |
287
+ | `--yes` | Skip confirmation prompts |
288
+ | `--profile <name>` | Use a named profile from `config.toml` |
289
+ | `--debug` | Print full request/response details |
290
+ | `--version` | Print CLI version |
291
+ | `--help` | Show help for any command |
292
+
293
+ ---
294
+
295
+ ## Scripting & CI/CD
296
+
297
+ The `--json` flag makes every command machine-readable:
298
+
299
+ ```bash
300
+ # Get deployment URL from a deploy
301
+ URL=$(blink deploy ./dist --prod --json | jq -r '.url')
302
+ echo "Deployed to: $URL"
303
+
304
+ # Query database and pipe to jq
305
+ blink db query "SELECT id, email FROM users" --json | jq '.[].email'
306
+
307
+ # Generate image and get URL
308
+ IMG=$(blink ai image "a logo" --json | jq -r '.url')
309
+ blink storage upload ./banner.png --json | jq -r '.url'
310
+ ```
311
+
312
+ ### GitHub Actions example
313
+
314
+ ```yaml
315
+ - name: Deploy to Blink
316
+ env:
317
+ BLINK_API_KEY: ${{ secrets.BLINK_API_KEY }}
318
+ run: |
319
+ npm install -g @blinkdotnew/cli
320
+ blink deploy ./dist --prod --json
321
+ ```
322
+
323
+ ---
324
+
325
+ ## Config Files
326
+
327
+ | File | Purpose |
328
+ |---|---|
329
+ | `~/.config/blink/config.toml` | Auth tokens, workspace ID, named profiles |
330
+ | `.blink/project.json` | Per-directory project link (like `.vercel/project.json`) |
331
+
332
+ `.blink/project.json` is created by `blink link` — add it to `.gitignore`.
333
+
334
+ ---
335
+
336
+ ## Blink Claw Agents
337
+
338
+ The CLI is **pre-installed** in every Blink Claw agent (Fly.io Firecracker VM). These env vars are already injected — no login needed:
339
+
340
+ ```
341
+ BLINK_API_KEY auth token
342
+ BLINK_AGENT_ID per-agent billing identity
343
+ BLINK_APIS_URL https://core.blink.new
344
+ BLINK_APP_URL https://blink.new
345
+ ```
346
+
347
+ Agents use the CLI directly in skill scripts:
348
+
349
+ ```bash
350
+ # In openclaw/skills/blink-image/scripts/generate.sh
351
+ blink ai image "$PROMPT" --model "$MODEL" --json
352
+ ```
353
+
354
+ ---
355
+
356
+ ## Links
357
+
358
+ - **npm**: https://www.npmjs.com/package/@blinkdotnew/cli
359
+ - **Blink platform**: https://blink.new
360
+ - **Docs**: https://blink.new/docs
361
+ - **Source**: `blink-sdk/packages/cli/` in the `blink-new/blink-sdk` repo