@yswgaicx/yswg-img-cli 0.1.2 → 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/README.md +5 -8
- package/bin/yswg-img.js +6 -5
- package/package.json +1 -1
- package/src/generate.js +7 -0
package/README.md
CHANGED
|
@@ -59,8 +59,6 @@ Dry-run the backend payload:
|
|
|
59
59
|
```bash
|
|
60
60
|
yswg-img generate \
|
|
61
61
|
--prompt "一张白底产品图,柔和自然光,高级电商摄影" \
|
|
62
|
-
--group-id 5 \
|
|
63
|
-
--model gemini-2.5-flash-image \
|
|
64
62
|
--ratio 1:1 \
|
|
65
63
|
--count 1 \
|
|
66
64
|
--dry-run \
|
|
@@ -72,8 +70,6 @@ Submit and wait for output images:
|
|
|
72
70
|
```bash
|
|
73
71
|
yswg-img generate \
|
|
74
72
|
--prompt "一张白底产品图,柔和自然光,高级电商摄影" \
|
|
75
|
-
--group-id 5 \
|
|
76
|
-
--model gemini-2.5-flash-image \
|
|
77
73
|
--ratio 1:1 \
|
|
78
74
|
--count 1 \
|
|
79
75
|
--out outputs \
|
|
@@ -85,7 +81,6 @@ Use reference images:
|
|
|
85
81
|
```bash
|
|
86
82
|
yswg-img generate \
|
|
87
83
|
--prompt "参考产品主体,生成室内生活方式场景图" \
|
|
88
|
-
--group-id 5 \
|
|
89
84
|
--ref ./product.png,https://example.com/ref.jpg \
|
|
90
85
|
--out outputs \
|
|
91
86
|
--json
|
|
@@ -95,7 +90,7 @@ Use an AI tool/template payload:
|
|
|
95
90
|
|
|
96
91
|
```bash
|
|
97
92
|
yswg-img generate \
|
|
98
|
-
--group-id
|
|
93
|
+
--group-id 6 \
|
|
99
94
|
--template-code tool_code \
|
|
100
95
|
--template-vars-json '{"color":"red"}' \
|
|
101
96
|
--display-prompt "AI 工具生成" \
|
|
@@ -106,7 +101,7 @@ yswg-img generate \
|
|
|
106
101
|
Submit only and return task IDs:
|
|
107
102
|
|
|
108
103
|
```bash
|
|
109
|
-
yswg-img generate --prompt "..." --
|
|
104
|
+
yswg-img generate --prompt "..." --no-wait --json
|
|
110
105
|
```
|
|
111
106
|
|
|
112
107
|
If a long generation times out or the WebSocket disconnects, the CLI now checks
|
|
@@ -116,7 +111,7 @@ submitting the same prompt again when the image was already produced.
|
|
|
116
111
|
Tune the wait timeout:
|
|
117
112
|
|
|
118
113
|
```bash
|
|
119
|
-
yswg-img generate --prompt "..." --
|
|
114
|
+
yswg-img generate --prompt "..." --timeout 900 --json
|
|
120
115
|
```
|
|
121
116
|
|
|
122
117
|
Query recent task history without creating a new generation task:
|
|
@@ -163,3 +158,5 @@ Flags override environment variables, which override the saved config.
|
|
|
163
158
|
- `YSWG_WS_PATH`
|
|
164
159
|
|
|
165
160
|
Default app ID: `2014153035982319618`.
|
|
161
|
+
Default ratio: `1:1`.
|
|
162
|
+
Default generation model: `gemini-3.1-flash-image-preview` (`groupId=6`, 三代).
|
package/bin/yswg-img.js
CHANGED
|
@@ -4,6 +4,7 @@ import { loadConfig, normalizeEmail, resolveConfig, saveConfig, DEFAULT_CONFIG_P
|
|
|
4
4
|
import { YswgApi } from "../src/api.js";
|
|
5
5
|
import {
|
|
6
6
|
buildGeneratePayload,
|
|
7
|
+
DEFAULT_GENERATE_OPTIONS,
|
|
7
8
|
downloadImages,
|
|
8
9
|
extractImageUrls,
|
|
9
10
|
findModelByGroupId,
|
|
@@ -31,7 +32,7 @@ Commands:
|
|
|
31
32
|
tasks recover --task-id <invoke-task-id>[,<id>] [--out outputs] [--json]
|
|
32
33
|
tasks delete --id <record-id> [--json]
|
|
33
34
|
tasks cancel-night --id <record-id> [--json]
|
|
34
|
-
generate --prompt <text> --group-id
|
|
35
|
+
generate --prompt <text> [--group-id 6] [--model gemini-3.1-flash-image-preview] [--ratio 1:1] [--count 1] [--ref a.png,b.jpg] [--template-code <code>] [--template-vars-json '{}'] [--no-compress] [--out outputs]
|
|
35
36
|
|
|
36
37
|
Environment:
|
|
37
38
|
YSWG_TOKEN, YSWG_REFRESH_TOKEN, YSWG_APP_ID, YSWG_BASE_URL, YSWG_WS_PATH
|
|
@@ -162,10 +163,10 @@ async function main() {
|
|
|
162
163
|
const prompt = String(readFlag(flags, ["prompt", "p"], "")).trim();
|
|
163
164
|
const refs = splitCsv(readFlag(flags, ["ref", "refs"], ""));
|
|
164
165
|
const refImages = await uploadReferences(api, refs, { compress: !flags.noCompress });
|
|
165
|
-
const groupId = String(readFlag(flags, ["groupId", "group"],
|
|
166
|
-
const model = String(readFlag(flags, ["model", "m"],
|
|
167
|
-
const ratio = String(readFlag(flags, ["ratio", "r"],
|
|
168
|
-
const imageCount = Number(readFlag(flags, ["count", "imageCount"],
|
|
166
|
+
const groupId = String(readFlag(flags, ["groupId", "group"], DEFAULT_GENERATE_OPTIONS.groupId));
|
|
167
|
+
const model = String(readFlag(flags, ["model", "m"], DEFAULT_GENERATE_OPTIONS.model));
|
|
168
|
+
const ratio = String(readFlag(flags, ["ratio", "r"], DEFAULT_GENERATE_OPTIONS.ratio));
|
|
169
|
+
const imageCount = Number(readFlag(flags, ["count", "imageCount"], DEFAULT_GENERATE_OPTIONS.imageCount));
|
|
169
170
|
const templateInput = parseTemplateInput({
|
|
170
171
|
code: String(readFlag(flags, ["templateCode", "template"], "")),
|
|
171
172
|
varsJson: String(readFlag(flags, ["templateVarsJson", "varsJson"], "")),
|
package/package.json
CHANGED
package/src/generate.js
CHANGED
|
@@ -2,6 +2,13 @@ import { basename } from "node:path";
|
|
|
2
2
|
import { readFile, mkdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { compressImageBuffer } from "./image-compress.js";
|
|
4
4
|
|
|
5
|
+
export const DEFAULT_GENERATE_OPTIONS = {
|
|
6
|
+
groupId: "6",
|
|
7
|
+
model: "gemini-3.1-flash-image-preview",
|
|
8
|
+
ratio: "1:1",
|
|
9
|
+
imageCount: 1,
|
|
10
|
+
};
|
|
11
|
+
|
|
5
12
|
export function buildGeneratePayload({
|
|
6
13
|
appId,
|
|
7
14
|
groupId,
|