@yswgaicx/yswg-img-cli 0.1.4 → 0.1.5
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 +15 -0
- package/package.json +1 -1
- package/src/api.js +4 -0
- package/src/cli.js +25 -1
package/README.md
CHANGED
|
@@ -61,6 +61,11 @@ yswg-img tasks recover --task-id <task-id-from-json> --out outputs/recovered --j
|
|
|
61
61
|
- For generated images, keep only local file paths and short summaries in agent
|
|
62
62
|
context. Do not paste image bytes, base64, `data:image/...`, or full tool
|
|
63
63
|
output into the conversation.
|
|
64
|
+
- To fetch an Amazon product gallery by ASIN, call:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
yswg-img amazon asin B0TEST1234 --max 7 --json
|
|
68
|
+
```
|
|
64
69
|
|
|
65
70
|
## Generate
|
|
66
71
|
|
|
@@ -72,6 +77,7 @@ Supported Monkey Genius options mirrored by the CLI:
|
|
|
72
77
|
- Reference images: `--ref ./a.png,https://example.com/b.jpg`
|
|
73
78
|
- Night/off-peak queue submission: `--night`
|
|
74
79
|
- AI tool/template payloads: `--template-code`, `--template-vars-json`
|
|
80
|
+
- Amazon ASIN product gallery lookup: `amazon asin <asin> --max 7`
|
|
75
81
|
- Generation history lookup and timeout recovery: `tasks search`, `tasks recover`
|
|
76
82
|
- History tabs/search/delete/night-cancel: `tasks search --tab ...`, `tasks delete`, `tasks cancel-night`
|
|
77
83
|
|
|
@@ -187,6 +193,15 @@ yswg-img tasks delete --id <record-id> --json
|
|
|
187
193
|
yswg-img tasks cancel-night --id <record-id> --json
|
|
188
194
|
```
|
|
189
195
|
|
|
196
|
+
Fetch Amazon product title and main image gallery by ASIN:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
yswg-img amazon asin B0TEST1234 --max 7 --json
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The command calls `/prod-api/web/amazon/asin/{asin}` and returns the backend
|
|
203
|
+
`AmazonProductVo` shape: `asin`, `title`, and `images`.
|
|
204
|
+
|
|
190
205
|
## Configuration
|
|
191
206
|
|
|
192
207
|
Flags override environment variables, which override the saved config.
|
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -65,6 +65,10 @@ export class YswgApi {
|
|
|
65
65
|
return this.request("/system/ai-prompt-templates/options", { params: { appId } });
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
amazonProductByAsin(asin, { max = 7 } = {}) {
|
|
69
|
+
return this.request(`/web/amazon/asin/${encodeURIComponent(asin)}`, { params: { max } });
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
createTasks(payload) {
|
|
69
73
|
return this.request("/web/ai/invoke/tasks", { method: "POST", data: payload });
|
|
70
74
|
}
|
package/src/cli.js
CHANGED
|
@@ -27,6 +27,7 @@ Commands:
|
|
|
27
27
|
auth login --email <name|email> --code <6 digits>
|
|
28
28
|
models [--app-id <id>]
|
|
29
29
|
templates [--app-id <id>] [--json]
|
|
30
|
+
amazon asin <asin> [--max 7] [--json]
|
|
30
31
|
tasks search [--size 10] [--keyword <text>] [--tab all|expiring1d|expiring2d|nightQueue] [--json]
|
|
31
32
|
tasks get --id <record-id> [--json]
|
|
32
33
|
tasks recover --task-id <invoke-task-id>[,<id>] [--out outputs] [--json]
|
|
@@ -40,6 +41,7 @@ Agent usage:
|
|
|
40
41
|
One generate request supports count 1-4. For larger batches, split calls.
|
|
41
42
|
For long tasks, use --no-wait first, then tasks recover --task-id <id>.
|
|
42
43
|
Keep generated image file paths and short summaries in agent context; do not paste image bytes or base64.
|
|
44
|
+
Amazon ASIN gallery lookup: amazon asin <asin> --max 7 --json returns asin, title, images.
|
|
43
45
|
|
|
44
46
|
Environment:
|
|
45
47
|
YSWG_TOKEN, YSWG_REFRESH_TOKEN, YSWG_APP_ID, YSWG_BASE_URL, YSWG_WS_PATH
|
|
@@ -221,6 +223,27 @@ async function handleTaskCommand({ api, config, flags, resolved, subcommand, jso
|
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
|
|
226
|
+
function normalizeAsin(value) {
|
|
227
|
+
const asin = String(value || "").trim().toUpperCase();
|
|
228
|
+
if (!asin) throw new Error("missing asin");
|
|
229
|
+
return asin;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function normalizeAmazonMax(value, fallback = 7) {
|
|
233
|
+
const max = Number(value ?? fallback);
|
|
234
|
+
if (!Number.isFinite(max) || max < 1) throw new Error("max must be a positive number");
|
|
235
|
+
return Math.floor(max);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function handleAmazonCommand({ api, flags, resolved, subcommand, positionals, json, write }) {
|
|
239
|
+
if (subcommand !== "asin") return false;
|
|
240
|
+
assertAuthenticated(resolved);
|
|
241
|
+
const asin = normalizeAsin(readFlag(flags, ["asin"], positionals[0]));
|
|
242
|
+
const max = normalizeAmazonMax(readFlag(flags, ["max"], 7));
|
|
243
|
+
writeOutput(write, await api.amazonProductByAsin(asin, { max }), json);
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
|
|
224
247
|
export async function runCli(argv, {
|
|
225
248
|
loadConfigFn = loadConfig,
|
|
226
249
|
saveConfigFn = saveConfig,
|
|
@@ -228,7 +251,7 @@ export async function runCli(argv, {
|
|
|
228
251
|
write = (text) => process.stdout.write(text),
|
|
229
252
|
} = {}) {
|
|
230
253
|
const parsed = parseArgs(argv);
|
|
231
|
-
const { command, subcommand, flags } = parsed;
|
|
254
|
+
const { command, subcommand, flags, positionals } = parsed;
|
|
232
255
|
const json = Boolean(flags.json);
|
|
233
256
|
if (command === "help" || flags.help) {
|
|
234
257
|
write(buildHelpText());
|
|
@@ -278,6 +301,7 @@ export async function runCli(argv, {
|
|
|
278
301
|
return;
|
|
279
302
|
}
|
|
280
303
|
|
|
304
|
+
if (command === "amazon" && await handleAmazonCommand({ api, flags, resolved, subcommand, positionals, json, write })) return;
|
|
281
305
|
if (command === "tasks" && await handleTaskCommand({ api, config, flags, resolved, subcommand, json, write })) return;
|
|
282
306
|
if (command === "generate") {
|
|
283
307
|
await handleGenerate({ api, config, flags, resolved, json, write });
|