quickmagic-cli 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Quick Magic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,337 @@
1
+ # quickmagic-cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/quickmagic-cli.svg)](https://www.npmjs.com/package/quickmagic-cli)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
5
+ [![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
6
+
7
+ **English** — Command-line client for [Quick Magic](https://quickmagic.vn): generate AI
8
+ images/videos, product photoshoots, virtual try-on, hook ad videos, auto-subtitles/dubbing
9
+ and more, through the Quick Magic REST API. Sign-in is browser-based **OAuth PKCE** — no API
10
+ keys to copy around. Requires Node.js **≥ 18** (uses built-in `fetch`/`crypto`/`http`, no
11
+ `axios`). Also ships with 8 Claude **Agent Skills** and an **MCP server** integration for
12
+ coding agents. Everything below this line is in Vietnamese (tiếng Việt) — quickstart only:
13
+
14
+ ```bash
15
+ npm install -g quickmagic-cli # once published to npm — see "Cài đặt" below for today
16
+ qm auth login # opens your browser to sign in
17
+ qm generate image --prompt "a red apple on a table" --model qimi_3 --wait --out ./out
18
+ ```
19
+
20
+ Full command reference, MCP setup, Agent Skills, troubleshooting: keep reading, or run
21
+ `qm <command> --help`.
22
+
23
+ ---
24
+
25
+ ## Giới thiệu
26
+
27
+ CLI tạo ảnh/video AI qua REST API Quick Magic, đăng nhập bằng **OAuth PKCE** (mở trình
28
+ duyệt, không cần dán API key).
29
+
30
+ - Node **>= 18** (dùng `fetch`/`crypto`/`http` built-in — không cần axios).
31
+ - Bin: `quickmagic` và alias `qm`.
32
+ - REST base: `https://api.quickmagic.vn/public/v1`. Discovery OAuth ở root
33
+ `https://api.quickmagic.vn/.well-known/oauth-authorization-server`.
34
+
35
+ ## Cài đặt
36
+
37
+ **Cách 1 — npm (sau khi publish):**
38
+
39
+ ```bash
40
+ npm install -g quickmagic-cli
41
+ ```
42
+
43
+ **Cách 2 — cài từ source (dùng ngay bây giờ):**
44
+
45
+ ```bash
46
+ git clone https://github.com/Tungbillee/cli-quickmagic.git
47
+ cd cli-quickmagic
48
+ npm install
49
+ npm install -g .
50
+ ```
51
+
52
+ **Cách 3 — dev local (symlink, sửa code chạy luôn):**
53
+
54
+ ```bash
55
+ cd cli-quickmagic
56
+ npm install
57
+ npm link # tạo lệnh global `quickmagic` / `qm` trỏ về source
58
+ ```
59
+
60
+ Gỡ cài đặt: `npm rm -g quickmagic-cli` (Cách 1/2) hoặc `npm unlink -g quickmagic-cli` (Cách 3).
61
+
62
+ ## Bắt đầu nhanh (3 lệnh)
63
+
64
+ ```bash
65
+ npm install -g quickmagic-cli
66
+ qm auth login
67
+ qm generate image --prompt "a red apple on a table" --model qimi_3 --wait --out ./out
68
+ ```
69
+
70
+ `qm auth login` mở trình duyệt đăng nhập 1 lần; các lệnh sau tự dùng token đã lưu (tự
71
+ refresh khi sắp hết hạn hoặc gặp HTTP 401 — không cần đăng nhập lại).
72
+
73
+ ## Xác thực
74
+
75
+ ```bash
76
+ qm auth login # mở trình duyệt, đăng nhập, lưu token
77
+ qm auth login --api-url https://api.quickmagic.vn # chỉ định URL gốc khác
78
+ qm auth status # in email / số dư
79
+ qm auth logout # xoá credentials
80
+ ```
81
+
82
+ Credentials lưu tại `~/.quickmagic/credentials.json` (quyền `600`, thư mục `700`).
83
+ Access token tự refresh khi sắp hết hạn hoặc khi gặp HTTP 401 — không cần đăng nhập lại.
84
+
85
+ ## Bảng lệnh đầy đủ
86
+
87
+ Ghi chú chung trước khi xem bảng:
88
+
89
+ - Tham số nhận ảnh/video (`--ref`, `--image`, `--garment`, `--character`, `--product`...)
90
+ nhận **URL** (giữ nguyên) hoặc **file local** (tự đọc → `data:image/*;base64,...`). File
91
+ local lớn (> ~8MB) sẽ bị cảnh báo — nên dùng URL vì body giới hạn ~10MB.
92
+ - `--crid <id>` (`client_request_id`) dùng cho **idempotency** — truyền cùng giá trị khi
93
+ retry để không bị tạo job / trừ tiền 2 lần.
94
+ - Cột **Credit** đánh dấu lệnh có giữ/trừ credit hay không; xem giá chính xác bằng
95
+ `qm models list`, `qm hook presets`, `qm marketing modes` trước khi chạy thật.
96
+ - Xem đầy đủ cờ (flags) của từng lệnh: `qm <lệnh> --help` (vd `qm hook video --help`).
97
+
98
+ ### Xác thực & tài khoản
99
+
100
+ | Lệnh | Mô tả | Credit |
101
+ |---|---|---|
102
+ | `qm auth login` | Đăng nhập qua trình duyệt (OAuth PKCE) | — |
103
+ | `qm auth logout` | Đăng xuất, xoá credentials | — |
104
+ | `qm auth status` | Xem email / số dư | — |
105
+ | `qm credits` | Số dư / tạm giữ / gói / Qimi free-window | — |
106
+ | `qm models list --type image\|video` | Bảng model + giá credit | — |
107
+
108
+ ### Tạo ảnh / video + theo dõi job
109
+
110
+ | Lệnh | Mô tả | Credit |
111
+ |---|---|---|
112
+ | `qm generate image` | Tạo ảnh AI (text-to-image, tối đa nhiều ảnh tham chiếu) | Có |
113
+ | `qm generate video` | Tạo video AI (text-to-video / ảnh đầu vào) | Có |
114
+ | `qm jobs get <id>` | Xem chi tiết 1 job (JSON) | — |
115
+ | `qm jobs wait <id> [--out dir]` | Chờ job hoàn tất + tải kết quả | — |
116
+
117
+ ### Sản phẩm / Thời trang
118
+
119
+ | Lệnh | Mô tả | Credit |
120
+ |---|---|---|
121
+ | `qm product --refs <r...>` | Ảnh sản phẩm AI (packshot/poster/infographic/composite) | Có |
122
+ | `qm fashion --outfit <id...>` | Ảnh thời trang từ outfit đã lưu + KOL | Có |
123
+ | `qm tryon --model-image <img>` | Thử đồ ảo (virtual try-on) trên ảnh người cụ thể | Có |
124
+
125
+ ### Ảnh nâng cao
126
+
127
+ | Lệnh | Mô tả | Credit |
128
+ |---|---|---|
129
+ | `qm cutout` | Tách nền / PNG trong suốt / remix scene | Có |
130
+ | `qm edit <image> --tool <t>` | restore / upscale (2k,4k) / beauty / muscle / color_boost | Có |
131
+
132
+ ### Video quảng cáo / Marketing
133
+
134
+ | Lệnh | Mô tả | Credit |
135
+ |---|---|---|
136
+ | `qm hook presets` | Liệt kê preset Hook Studio + giá | — |
137
+ | `qm hook video --preset <id>` | Video hài quảng cáo từ ảnh nhân vật + sản phẩm | Có |
138
+ | `qm marketing modes` | Liệt kê mode + bảng giá theo duration | — |
139
+ | `qm marketing video --mode <id>` | Video marketing (giá theo duration) | Có |
140
+ | `qm analyze <video_url>` | Phân tích video quảng cáo đối thủ → kịch bản | Có (15cr) |
141
+
142
+ ### Audio / Video dài
143
+
144
+ | Lệnh | Mô tả | Credit |
145
+ |---|---|---|
146
+ | `qm stt <audio_url>` | Chuyển giọng nói → văn bản (+ dịch) | Có |
147
+ | `qm subtitle <video_url>` | Thêm phụ đề (+ lồng tiếng, dịch) | Có |
148
+ | `qm split <video_url>` | Cắt video dài → clip ngắn | Có |
149
+ | `qm motion <video_url> --image <url...>` | Áp chuyển động video vào ảnh (Kling) | Có |
150
+
151
+ ### Nhập liệu (miễn phí)
152
+
153
+ | Lệnh | Mô tả | Credit |
154
+ |---|---|---|
155
+ | `qm scrape <url>` | Quét ảnh + tên sản phẩm từ link trang | — |
156
+ | `qm import <url>` | Nhập ảnh/video từ link TikTok/Instagram | — |
157
+ | `qm assets <kind>` | Liệt kê tài sản đã lưu: `products`\|`outfits`\|`kols` | — |
158
+
159
+ ## Tạo ảnh
160
+
161
+ ```bash
162
+ qm generate image --prompt "a red apple on a table" --model qimi_3
163
+ qm generate image --prompt "a cat" --model qimi_3 --n 4 --quality high --aspect-ratio 1:1
164
+ qm generate image --prompt "same style" --ref https://x.com/a.png --ref ./local.jpg
165
+ qm generate image --prompt "a dog" --model qimi_3 --wait --out ./out # chờ + tải file
166
+ ```
167
+
168
+ - `--ref` nhận **URL** (giữ nguyên) hoặc **file local** (đọc thành `data:image/*;base64,...`). Lặp nhiều lần để gửi nhiều ảnh.
169
+ - Ảnh local lớn (> ~8MB) sẽ bị cảnh báo — nên dùng URL vì body giới hạn ~10MB.
170
+
171
+ ## Tạo video
172
+
173
+ ```bash
174
+ qm generate video --prompt "a waving flag" --model grok-imagine
175
+ qm generate video --prompt "zoom in" --model <m> --duration 8 --resolution 720p --image ./first.jpg
176
+ qm generate video --prompt "..." --model grok-imagine --wait --out ./out
177
+ ```
178
+
179
+ - `--image` cũng nhận URL hoặc file local (như `--ref`).
180
+ - `--mode reference|frames` — `reference` (nhiều ảnh tham chiếu) hoặc `frames` (khung
181
+ đầu/cuối, tối đa 2). Một số model (họ Seedance 2.x) **từ chối ảnh chứa người thật** ở mọi
182
+ `--mode` — xem cột `IMAGES` của `qm models list --type video` (đánh dấu `*`).
183
+
184
+ ## Job
185
+
186
+ ```bash
187
+ qm jobs get img_12 # in JSON chi tiết job
188
+ qm jobs wait vid_7 --out ./out # poll mỗi 2.5s tới khi xong, tải kết quả về ./out
189
+ ```
190
+
191
+ ## Model & Credit
192
+
193
+ ```bash
194
+ qm models list --type image # bảng key | label | credit
195
+ qm models list --type video
196
+ qm credits # số dư / tạm giữ / gói
197
+ ```
198
+
199
+ ## Ví dụ nhanh — các tính năng khác
200
+
201
+ ```bash
202
+ # Ảnh sản phẩm AI (product_id trong tủ đồ, hoặc URL/base64 — tối đa 3 ref)
203
+ qm product --refs 42 --types product poster --count 2
204
+
205
+ # Ảnh thời trang từ outfit đã lưu
206
+ qm fashion --outfit 7 12 --mode kol_outfit --kol-id 3
207
+
208
+ # Thử đồ ảo trên ảnh người cụ thể
209
+ qm tryon --model-image ./me.jpg --garment ./ao.jpg --type full
210
+
211
+ # Tách nền / tạo PNG trong suốt từ ảnh tham chiếu
212
+ qm cutout --operation from_ref --ref ./product.jpg --model nano-banana-2
213
+
214
+ # Video hài quảng cáo — xem preset + giá trước khi chạy
215
+ qm hook presets
216
+ qm hook video --preset <id> --character ./face.jpg --product ./product.jpg --speech-lang vi
217
+
218
+ # Phụ đề tự động (+ dịch), cắt video dài thành clip ngắn
219
+ qm subtitle https://cdn.example.com/video.mp4 --translate en
220
+ qm split https://www.tiktok.com/@user/video/123 --mode auto
221
+
222
+ # Giọng nói → văn bản, áp chuyển động video vào ảnh
223
+ qm stt https://cdn.example.com/audio.mp3 --translate vi
224
+ qm motion https://cdn.example.com/dance.mp4 --image ./photo.jpg
225
+
226
+ # Video marketing theo mode + phân tích video đối thủ → kịch bản
227
+ qm marketing modes
228
+ qm marketing video --mode 3 --product-id 42 --duration 10
229
+
230
+ # Nhập liệu — không tốn credit
231
+ qm scrape https://shop.example.com/product/123
232
+ qm import https://www.tiktok.com/@user/video/123 --media image
233
+ qm assets products --limit 20
234
+ qm analyze https://cdn.example.com/ad.mp4 --product-id 42
235
+ ```
236
+
237
+ ## Biến môi trường
238
+
239
+ | Biến | Ý nghĩa |
240
+ |---|---|
241
+ | `QUICKMAGIC_URL` | Ghi đè URL gốc API (mặc định `https://api.quickmagic.vn`). |
242
+ | `QUICKMAGIC_TOKEN` | **CI headless** — access token. Có biến này thì bỏ qua bước mở trình duyệt. |
243
+ | `QUICKMAGIC_REFRESH_TOKEN` | **CI headless** — refresh token (kèm access token). |
244
+
245
+ Khi chạy bằng env token, CLI **chỉ đọc** token từ env, **không** ghi xuống `~/.quickmagic/credentials.json`.
246
+
247
+ ```bash
248
+ # Ví dụ CI
249
+ export QUICKMAGIC_TOKEN="<access_token>"
250
+ export QUICKMAGIC_REFRESH_TOKEN="<refresh_token>"
251
+ qm credits # chạy không cần browser
252
+ ```
253
+
254
+ ## Mã thoát (exit code)
255
+
256
+ - `0` — thành công.
257
+ - `1` — lỗi (chưa đăng nhập, job thất bại, HTTP lỗi, ...). Thân thiện CI.
258
+
259
+ ## Agent Skills
260
+
261
+ CLI này đi kèm 8 **Agent Skills** (`skills/quickmagic-*/SKILL.md`) để coding agent
262
+ (Claude Code...) dùng CLI trực tiếp — báo giá + xin xác nhận trước khi tốn credit,
263
+ tự `jobs wait` thay vì poll tay, chủ động báo Qimi free-window. Danh sách đầy đủ và quy ước
264
+ chung: xem `skills/README.md`.
265
+
266
+ **Yêu cầu:** cài CLI trước (xem mục Cài đặt) + `qm auth login` một lần trên máy.
267
+
268
+ Cách 1 — `npx skills` (nếu dùng công cụ [`skills`](https://www.npmjs.com/package/skills) để
269
+ quản lý Agent Skills từ GitHub):
270
+
271
+ ```bash
272
+ npx skills add Tungbillee/cli-quickmagic --skills quickmagic-account,quickmagic-generate,quickmagic-product-photoshoot,quickmagic-fashion,quickmagic-cutout,quickmagic-hook-video,quickmagic-edit-image,quickmagic-subtitle-split
273
+ ```
274
+
275
+ Cách 2 — copy thủ công vào thư mục skills của Claude Code:
276
+
277
+ ```bash
278
+ cp -r skills/quickmagic-* .claude/skills/ # project (chỉ áp dụng cho project này)
279
+ cp -r skills/quickmagic-* ~/.claude/skills/ # user (mọi project trên máy)
280
+ ```
281
+
282
+ ## MCP (Model Context Protocol)
283
+
284
+ Quick Magic cũng có MCP server dùng **chung tài khoản/ví credit** — cho phép Claude Code
285
+ (và các MCP client khác) gọi thẳng `generate_image`, `generate_video`, `get_job`,
286
+ `wait_for_job`, `list_models`, `get_credit_balance`... mà không cần qua CLI. Xác thực OAuth
287
+ 2.1 qua trình duyệt, không cần API key.
288
+
289
+ - MCP endpoint: `https://api.quickmagic.vn/mcp`
290
+
291
+ **Claude Code:**
292
+
293
+ ```bash
294
+ claude mcp add --transport http quickmagic https://api.quickmagic.vn/mcp
295
+ ```
296
+
297
+ Lần đầu dùng sẽ mở trình duyệt → đăng nhập Quick Magic → **Cho phép**. Kiểm tra:
298
+ `claude mcp list` hoặc gõ `/mcp` trong phiên Claude Code.
299
+
300
+ **Cursor** — thêm vào `.cursor/mcp.json`:
301
+
302
+ ```json
303
+ { "mcpServers": { "quickmagic": { "url": "https://api.quickmagic.vn/mcp" } } }
304
+ ```
305
+
306
+ **claude.ai (web connector):** Settings → Connectors → Add custom connector → dán URL
307
+ `https://api.quickmagic.vn/mcp` → Connect → đăng nhập Quick Magic.
308
+
309
+ CLI và MCP dùng chung tài khoản: đăng nhập 1 bên không tự đăng nhập bên kia (mỗi bên lưu
310
+ token riêng), nhưng số dư credit/lịch sử job là chung.
311
+
312
+ ## Bảo mật
313
+
314
+ - PKCE S256 (không lưu client secret trên máy). `state` chống CSRF ở callback.
315
+ - Loopback chỉ nghe `127.0.0.1` (không `0.0.0.0`), `redirect_uri` gắn port cụ thể của phiên login.
316
+ - `credentials.json` quyền `600`, ghi kiểu temp→rename (atomic, không hỏng JSON).
317
+ - Refresh bọc lockfile `~/.quickmagic/refresh.lock` chống 2 tiến trình refresh đồng thời.
318
+ - Không in access/refresh token ra stdout/log.
319
+
320
+ ## Khắc phục sự cố
321
+
322
+ | Vấn đề | Xử lý |
323
+ |---|---|
324
+ | `Chưa đăng nhập. Chạy: quickmagic auth login` | Chạy `qm auth login`. |
325
+ | Trình duyệt không tự mở khi login | Dán URL được in ra terminal vào trình duyệt bất kỳ. |
326
+ | Đăng nhập quá 2 phút (timeout) | Chạy lại `qm auth login`. |
327
+ | Lỗi HTTP 401 lặp lại dù đã đăng nhập | Token bị thu hồi/hết hạn refresh — `qm auth logout` rồi `qm auth login` lại. |
328
+ | `Không đủ credit: ... thiếu Zcr` | Nạp thêm tại https://quickmagic.vn/pricing. |
329
+ | Cảnh báo file > 8MB khi dùng `--ref`/`--image` | Body giới hạn ~10MB — ưu tiên dùng URL public thay vì file local. |
330
+ | Muốn trỏ CLI vào domain/môi trường khác | Cờ `--api-url <url>` (khi login) hoặc biến môi trường `QUICKMAGIC_URL`. |
331
+ | Máy CI/server không có trình duyệt | Đặt `QUICKMAGIC_TOKEN` (+ `QUICKMAGIC_REFRESH_TOKEN`) — xem mục Biến môi trường. |
332
+ | Cài `-g` xong gõ `qm`/`quickmagic` báo "command not found" | Kiểm tra `npm config get prefix`, thêm `<prefix>/bin` vào `PATH`. |
333
+
334
+ ## Giấy phép
335
+
336
+ [MIT](./LICENSE) © Quick Magic. Issue/góp ý:
337
+ https://github.com/Tungbillee/cli-quickmagic/issues.
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "quickmagic-cli",
3
+ "version": "1.0.0",
4
+ "description": "Quick Magic CLI — generate AI images/videos, product photoshoots, virtual try-on, hook ad videos, subtitles and more via the Quick Magic REST API, with browser-based OAuth PKCE login (no API keys to manage). Ships with 8 Claude Agent Skills and an MCP server integration.",
5
+ "bin": {
6
+ "quickmagic": "src/index.js",
7
+ "qm": "src/index.js"
8
+ },
9
+ "main": "src/index.js",
10
+ "files": [
11
+ "src",
12
+ "skills",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "check": "node --check src/index.js"
18
+ },
19
+ "keywords": [
20
+ "quickmagic",
21
+ "cli",
22
+ "ai",
23
+ "image-generation",
24
+ "video-generation",
25
+ "text-to-image",
26
+ "text-to-video",
27
+ "generative-ai",
28
+ "oauth",
29
+ "oauth-pkce",
30
+ "mcp",
31
+ "model-context-protocol",
32
+ "claude-code",
33
+ "agent-skills",
34
+ "product-photography",
35
+ "virtual-try-on"
36
+ ],
37
+ "homepage": "https://github.com/Tungbillee/cli-quickmagic#readme",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/Tungbillee/cli-quickmagic.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/Tungbillee/cli-quickmagic/issues"
44
+ },
45
+ "author": "Quick Magic",
46
+ "license": "MIT",
47
+ "engines": {
48
+ "node": ">=18"
49
+ },
50
+ "dependencies": {
51
+ "commander": "^12",
52
+ "open": "^8.4.2"
53
+ }
54
+ }
@@ -0,0 +1,67 @@
1
+ # Quick Magic CLI — Agent Skills
2
+
3
+ 8 Agent Skills that wrap the `quickmagic` / `qm` CLI so a coding agent (Claude
4
+ Code and compatible tools) can drive Quick Magic directly from the terminal —
5
+ mirroring the `npx skills add higgsfield-ai/skills` pattern (`/higgsfield:generate`
6
+ etc.), tailored to Quick Magic's own REST API and CLI.
7
+
8
+ Each skill is a `skills/<name>/SKILL.md` (frontmatter `name` + `description` —
9
+ the `description` doubles as the router/trigger contract an agent uses to decide
10
+ when to load the skill).
11
+
12
+ ## Install
13
+
14
+ **Requires the CLI itself first** — see `cli-quickmagic/README.md`
15
+ (`npm install -g .` or `npm link` from the `cli-quickmagic/` folder), then
16
+ `qm auth login` once per machine.
17
+
18
+ Option 1 — `npx skills` (if this repo is published as a skills package):
19
+
20
+ ```bash
21
+ npx skills add Tungbillee/cli-quickmagic --skills quickmagic-account,quickmagic-generate,quickmagic-product-photoshoot,quickmagic-fashion,quickmagic-cutout,quickmagic-hook-video,quickmagic-edit-image,quickmagic-subtitle-split
22
+ ```
23
+
24
+ Option 2 — copy directly into a project's or your user's Claude skills folder:
25
+
26
+ ```bash
27
+ # project-level (this repo, active for anyone working in it)
28
+ mkdir -p .claude/skills && cp -r cli-quickmagic/skills/quickmagic-* .claude/skills/
29
+
30
+ # user-level (active in every project)
31
+ mkdir -p ~/.claude/skills && cp -r cli-quickmagic/skills/quickmagic-* ~/.claude/skills/
32
+ ```
33
+
34
+ ## Skills
35
+
36
+ | Skill | Wraps | Use for |
37
+ |---|---|---|
38
+ | `quickmagic-account` | `auth`, `credits`, `models list`, `jobs get/wait` | login/status, credit balance + Qimi free-window benefit, model catalog, job polling — **foundation** the other 7 skills reference |
39
+ | `quickmagic-generate` | `generate image`, `generate video` | text/reference-to-image or -video |
40
+ | `quickmagic-product-photoshoot` | `product` | studio/marketing photos of a product (packshot/poster/infographic/composite) |
41
+ | `quickmagic-fashion` | `fashion`, `tryon` | outfit lookbook shoots vs. virtual try-on on a specific person photo |
42
+ | `quickmagic-cutout` | `cutout` | transparent PNG cutouts / scene remix |
43
+ | `quickmagic-hook-video` | `hook presets`, `hook video` | ~10s comedy ad video from a character + product photo (18 presets) |
44
+ | `quickmagic-edit-image` | `edit` | restore / upscale (2k/4k) / beauty / muscle / color_boost on an existing image |
45
+ | `quickmagic-subtitle-split` | `subtitle`, `split` | auto subtitles/dubbing, long-video → short clips |
46
+
47
+ ## Shared conventions (all 8 skills)
48
+
49
+ - Check `qm auth status` first; if not logged in, tell the user to run
50
+ `qm auth login`.
51
+ - Quote the credit cost (from `qm models list` / a preset's `credit_cost`) and
52
+ get explicit user confirmation **before** running any command that spends
53
+ credit — submission holds credit immediately. `subtitle`/`split` are the one
54
+ exception: price is duration-based and only known after submission, so the
55
+ skill asks for a go-ahead instead of a number.
56
+ - Surface `insufficient_credit` (`Không đủ credit: ... thiếu Zcr`) with the exact
57
+ shortfall and a link to top up (https://quickmagic.vn/pricing).
58
+ - Never poll `jobs get` manually — use `qm jobs wait <id> [--out dir]`. Note that
59
+ `--out` only auto-downloads for job types with a single `result_url`
60
+ (image/video/tryon/edit/hook/subtitle); product/fashion/cutout/split return
61
+ arrays and must be read back with `qm jobs get <id>` after completion.
62
+ See `quickmagic-account` for the full job-id-prefix table.
63
+ - Always end with the final result URL(s) plus the credit amount already
64
+ charged/held.
65
+
66
+ See each skill's `SKILL.md` for exact CLI flags and feature-specific
67
+ error-handling.
@@ -0,0 +1,137 @@
1
+ ---
2
+ name: quickmagic-account
3
+ description: >-
4
+ Foundation skill for the Quick Magic CLI: login/logout/status (`qm auth`),
5
+ credit balance + Qimi free-window benefit (`qm credits`), model catalog
6
+ (`qm models list`), and job status/waiting (`qm jobs`). Every other
7
+ quickmagic-* skill depends on this one for auth checks, pricing lookups,
8
+ job-id prefixes, and the common error-code table. Triggers: "đăng nhập
9
+ quickmagic", "kiểm tra số dư credit", "danh sách model AI", "theo dõi
10
+ trạng thái job", "quickmagic login", "check my credits".
11
+ ---
12
+
13
+ # quickmagic-account — Auth, Credits, Models, Jobs (Foundation)
14
+
15
+ Wraps `qm auth`, `qm credits`, `qm models list`, and `qm jobs`. Every `quickmagic-*`
16
+ skill relies on this one — read it first if this is your first Quick Magic CLI task
17
+ in a session. Bin name: `quickmagic` (alias `qm`).
18
+
19
+ ## Auth
20
+
21
+ ```bash
22
+ qm auth login [--api-url <url>] # opens a browser, OAuth PKCE, saves credentials
23
+ qm auth status # prints email / balance / plan / api url
24
+ qm auth logout # clears saved credentials
25
+ ```
26
+
27
+ - `qm auth status` prints `Chưa đăng nhập. Chạy: quickmagic auth login` and exits
28
+ **1** when there is no saved (or env) token. Always check auth (run this, or
29
+ attempt the real command and read stderr) before any other quickmagic command in
30
+ a fresh session — if it fails, tell the user to run `qm auth login` and stop.
31
+ - Credentials live in `~/.quickmagic/credentials.json`; access tokens auto-refresh
32
+ in the background, no manual re-login needed once logged in.
33
+ - CI/headless: set `QUICKMAGIC_TOKEN` (+ optionally `QUICKMAGIC_REFRESH_TOKEN`) env
34
+ vars to skip the browser step entirely; nothing is written to disk in that mode.
35
+ - `QUICKMAGIC_URL` overrides the API root (default `https://api.quickmagic.vn`).
36
+
37
+ ## Credits & the Qimi free-image window
38
+
39
+ ```bash
40
+ qm credits
41
+ ```
42
+
43
+ Prints `Số dư (balance)`, `Tạm giữ (held)`, `Gói (plan)`, and — only when active —
44
+ `Qimi miễn phí: còn N ngày (chế độ: ...)`.
45
+
46
+ - This benefit gives free `qimi_3`/`qimi_2.5` image generations for a limited
47
+ window (Business/Enterprise plans).
48
+ - Mode **"Miễn phí — 1 ảnh/lần"**: one image per call is free; requesting more than
49
+ one in parallel (or `--n` > 1) costs credits.
50
+ - Mode **"Nhanh — trả credit, chạy song song"**: the account chose speed over the
51
+ free tier — parallel generations always cost credits.
52
+ - Any skill that generates `qimi_3`/`qimi_2.5` images should call `qm credits`
53
+ first and proactively surface this to the user before quoting a price.
54
+
55
+ Note: `qm auth status` also prints a balance line, but only `qm credits` reports
56
+ `held` and the Qimi benefit — use `qm credits` for anything pricing-related.
57
+
58
+ ## Browsing models
59
+
60
+ ```bash
61
+ qm models list --type image # columns: KEY | LABEL | CREDIT
62
+ qm models list --type video # columns: KEY | LABEL | CREDIT | IMAGES
63
+ ```
64
+
65
+ - `IMAGES` (video only) shows the max reference images per input mode, e.g.
66
+ `ref 9 · frames 2`. A trailing `*` means that mode **rejects photos containing
67
+ real people** for that model — switch models (e.g. `gemini-omni`, a `seedance
68
+ 1.x` key, `wan-2-7`) if the user's reference photos have people in them.
69
+ - The table does not print quality tiers or max-ref-image counts for image
70
+ models — image quality levels are commonly `1K`/`2K`/`4K`, priced per level; if
71
+ the exact enum for a model is unknown, omit `--quality` and let the server
72
+ default, or ask the user.
73
+ - Always check this before quoting a price in any generate/edit/product/fashion/
74
+ cutout/hook skill — prices vary per model and change over time; never reuse a
75
+ remembered price from a previous session.
76
+
77
+ ## Job status & waiting
78
+
79
+ ```bash
80
+ qm jobs get <id> # prints the full job JSON
81
+ qm jobs wait <id> [--out dir] # polls every 2.5s until a terminal status; downloads on success if --out is set
82
+ ```
83
+
84
+ Never poll `jobs get` manually in a loop — always use `jobs wait` (or the
85
+ generating command's own `--wait` flag, where available).
86
+
87
+ **Job id prefixes** (dispatch table used by every `qm jobs` call):
88
+
89
+ | Prefix | Feature | Result shape |
90
+ |---|---|---|
91
+ | `img_` | `generate image` | single `result_url` |
92
+ | `vid_` | `generate video` | single `result_url` + `thumbnail_url` |
93
+ | `pai_` | `product` | **array** `images[]` `{status, image_url, image_type}` |
94
+ | `fsh_` | `fashion` | **array** `results[]` `{status, url, pose_index}` |
95
+ | `vto_` | `tryon` | single `result_url` |
96
+ | `edt_` | `edit` | single `result_url` |
97
+ | `cut_` | `cutout` | **array** `images[]` `{status, result_url, operation}` |
98
+ | `hok_` | `hook video` | single `result_url` + `thumbnail_url` |
99
+ | `sub_` | `subtitle` | single `result_url` |
100
+ | `spl_` | `split` | **array** `clips[]` `{title, url, thumbnail_url, start_time, end_time, status}` |
101
+ | `mkt_` | `marketing video` | single result (no dedicated skill) |
102
+ | `mot_` | `motion` | single result (no dedicated skill) |
103
+ | `stt_` | `stt` | text result (no dedicated skill) |
104
+
105
+ **Important caveat**: `jobs wait --out <dir>` only **auto-downloads** for the
106
+ single-`result_url` types (`img_`/`vid_`/`vto_`/`edt_`/`hok_`/`sub_`). For the
107
+ array types (`pai_`/`fsh_`/`cut_`/`spl_`), `--out` still polls status correctly
108
+ but downloads nothing — after status is `completed`, call `qm jobs get <id>` and
109
+ read the array field yourself, then report each URL to the user.
110
+
111
+ Statuses: `queued` → `in_progress` → `completed` (success) or `failed` (relay the
112
+ job's `error` field). A `queued` status stuck past ~15 minutes is reported as
113
+ `stalled` with a hint that the queue may be backed up — suggest retrying later
114
+ rather than resubmitting immediately.
115
+
116
+ ## Common errors (any command)
117
+
118
+ | CLI message (stderr, exit 1) | Meaning | What to do |
119
+ |---|---|---|
120
+ | `Chưa đăng nhập. Chạy: quickmagic auth login` | no local/env token | tell the user to run `qm auth login` |
121
+ | `Không đủ credit: cần Xcr, hiện có Ycr, thiếu Zcr. Vui lòng nạp thêm để tiếp tục.` | `insufficient_credit` (HTTP 402) | state the exact shortfall (Z) and suggest topping up at https://quickmagic.vn/pricing |
122
+ | `Tài khoản đang âm N credit. Vui lòng nạp thêm để tiếp tục sử dụng.` | `negative_balance` (HTTP 402) | same — must top up before any new paid job |
123
+ | `Bạn đã có N job đang xử lý (giới hạn M job đồng thời cho gói ...)` | `concurrent_limit` (HTTP 429) | wait for an in-flight job to finish (`jobs wait`) before submitting more |
124
+ | `Bạn thao tác quá nhanh. Chờ Ns.` | `rate_limited` (HTTP 429) | wait N seconds, then retry |
125
+ | any other `Lỗi: <message>` | validation error (bad model/ref/prompt/URL — HTTP 400/413/502) | read the message, fix the offending flag, retry — don't blindly resubmit unchanged |
126
+
127
+ Exit code is always `1` on any failure, `0` on success — safe to script around.
128
+
129
+ ## Example
130
+
131
+ ```bash
132
+ qm auth status || qm auth login
133
+ qm credits
134
+ qm models list --type image
135
+ qm jobs get img_12
136
+ qm jobs wait vid_7 --out ./out
137
+ ```