gaoding-cli 1.0.0-alpha.7 → 1.0.0-alpha.8
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/CHANGELOG.md +20 -0
- package/README.md +18 -14
- package/dist/src/api/app-runner.js +1 -2
- package/dist/src/api/creative-client.d.ts +34 -0
- package/dist/src/api/creative-client.js +184 -0
- package/dist/src/api/direct-client.d.ts +9 -2
- package/dist/src/api/direct-client.js +45 -18
- package/dist/src/api/hub-client.d.ts +11 -8
- package/dist/src/api/hub-client.js +17 -18
- package/dist/src/api/usage-client.d.ts +4 -4
- package/dist/src/api/usage-client.js +9 -49
- package/dist/src/auth/credential-store-v2.d.ts +0 -1
- package/dist/src/auth/credential-store-v2.js +0 -6
- package/dist/src/commands/auth.js +13 -13
- package/dist/src/commands/creative.d.ts +8 -0
- package/dist/src/commands/creative.js +186 -0
- package/dist/src/commands/dam.js +27 -22
- package/dist/src/commands/org.js +20 -14
- package/dist/src/commands/skills.js +9 -4
- package/dist/src/commands/update.js +6 -2
- package/dist/src/commands/usage.d.ts +1 -1
- package/dist/src/commands/usage.js +6 -4
- package/dist/src/commands/workflows.js +31 -13
- package/dist/src/core/auth/auth-guard.d.ts +21 -0
- package/dist/src/core/auth/auth-guard.js +121 -0
- package/dist/src/core/auth/org-manager.d.ts +2 -1
- package/dist/src/core/auth/org-manager.js +61 -6
- package/dist/src/creative/contract.d.ts +1112 -0
- package/dist/src/creative/contract.js +743 -0
- package/dist/src/creative/media.d.ts +19 -0
- package/dist/src/creative/media.js +83 -0
- package/dist/src/creative/protocol.d.ts +60 -0
- package/dist/src/creative/protocol.js +337 -0
- package/dist/src/middleware/auth.d.ts +6 -2
- package/dist/src/middleware/auth.js +25 -63
- package/dist/src/middleware/error-handler.d.ts +2 -0
- package/dist/src/middleware/error-handler.js +3 -4
- package/dist/src/program.js +7 -89
- package/dist/src/registry/agent-contracts.d.ts +3 -11
- package/dist/src/registry/agent-contracts.js +5 -243
- package/dist/src/registry/direct-registry.d.ts +0 -5
- package/dist/src/registry/direct-registry.js +0 -19
- package/dist/src/registry/registry-client.d.ts +0 -21
- package/dist/src/registry/registry-client.js +1 -40
- package/dist/src/utils/config.d.ts +2 -2
- package/dist/src/utils/config.js +1 -1
- package/dist/src/utils/help-verify.d.ts +1 -3
- package/dist/src/utils/help-verify.js +1 -25
- package/package.json +3 -3
- package/skills/gd-cli/SKILL.md +10 -9
- package/skills/gd-cli/references/auth.md +6 -0
- package/skills/gd-cli/references/creative.md +47 -0
- package/skills/gd-cli/references/entitlement.md +2 -2
- package/skills/gd-cli/references/errors.md +7 -0
- package/skills/gd-cli/references/sop.md +4 -4
- package/skills/gd-cli/references/workflows.md +1 -1
- package/dist/src/commands/models.d.ts +0 -2
- package/dist/src/commands/models.js +0 -78
- package/dist/src/commands/tools.d.ts +0 -4
- package/dist/src/commands/tools.js +0 -383
- package/skills/gd-cli/references/tools.md +0 -29
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
/** 各工具一条可复制命令(与 registry 中 tool id 一致) */
|
|
2
|
-
const TOOL_QUICK_LINES = {
|
|
3
|
-
"asset.upload": "gd-cli tools call upload --file ./demo.jpg -f json",
|
|
4
|
-
upload: "gd-cli tools call upload --file ./demo.jpg -f json",
|
|
5
|
-
chat: 'gd-cli tools call chat --prompt "运动品牌主图要点" -f json',
|
|
6
|
-
cutout: "gd-cli tools call cutout --image https://www.gaoding.art/favicon.ico -f json",
|
|
7
|
-
title: 'gd-cli tools call title --prompt "北欧实木餐桌" -f json',
|
|
8
|
-
prompt: 'gd-cli tools call prompt --prompt "一只猫" -f json',
|
|
9
|
-
generate: 'gd-cli tools call generate --prompt "产品白底图,极简" --ratio 1:1 -f json',
|
|
10
|
-
edit: "gd-cli tools call edit --image https://www.gaoding.art/favicon.ico --style <风格> -f json",
|
|
11
|
-
expand: "gd-cli tools call expand --image https://www.gaoding.art/favicon.ico --width 1920 --height 1080 -f json",
|
|
12
|
-
erase: "gd-cli tools call erase --image https://www.gaoding.art/favicon.ico --mask https://example.com/mask.png -f json",
|
|
13
|
-
upscale: "gd-cli tools call upscale --image https://www.gaoding.art/favicon.ico -f json",
|
|
14
|
-
vectorize: "gd-cli tools call vectorize --image https://www.gaoding.art/favicon.ico -f json",
|
|
15
|
-
video: 'gd-cli tools call video --prompt "运动品牌短片" -f json',
|
|
16
|
-
"video-hd": "gd-cli tools call video-hd --file https://example.com/video.mp4 -f json",
|
|
17
|
-
};
|
|
18
1
|
const APP_RUN_QUICK_LINE = 'gd-cli workflows run listing-gallery --image ./product.jpg --brief "运动鞋" -f json';
|
|
19
2
|
/**
|
|
20
|
-
* 在命令 `-h`
|
|
3
|
+
* 在命令 `-h` 底部追加一段「快速验证」单行示例(用于 Workflow 子命令)。
|
|
21
4
|
*/
|
|
22
5
|
export function appendVerifySnippet(cmd, line) {
|
|
23
6
|
const text = `
|
|
@@ -27,13 +10,6 @@ ${line.trim()}
|
|
|
27
10
|
`;
|
|
28
11
|
cmd.addHelpText("after", text);
|
|
29
12
|
}
|
|
30
|
-
/** 按工具 id 附加对应示例;无映射则不加(避免误导) */
|
|
31
|
-
export function appendToolQuickExample(cmd, toolName) {
|
|
32
|
-
const line = TOOL_QUICK_LINES[toolName];
|
|
33
|
-
if (!line)
|
|
34
|
-
return;
|
|
35
|
-
appendVerifySnippet(cmd, line);
|
|
36
|
-
}
|
|
37
13
|
/** `gd-cli workflows run -h` 专用 */
|
|
38
14
|
export function appendAppRunQuickExample(cmd, _legacyPrefix) {
|
|
39
15
|
void _legacyPrefix;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gaoding-cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "稿定 GD CLI -
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
|
+
"description": "稿定 GD CLI - Creative / Workflows / DAM 命令行工具",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Gaoding",
|
|
7
7
|
"type": "module",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"gd-cli",
|
|
79
79
|
"cli",
|
|
80
80
|
"visual-creation",
|
|
81
|
-
"
|
|
81
|
+
"creative",
|
|
82
82
|
"dam"
|
|
83
83
|
]
|
|
84
84
|
}
|
package/skills/gd-cli/SKILL.md
CHANGED
|
@@ -18,25 +18,26 @@ description: 当用户需要使用稿定生成图片、视频、电商素材或
|
|
|
18
18
|
- 错误处理和停止规则读 `references/errors.md`。
|
|
19
19
|
- 图片、视频和交付包处理读 `references/deliverables.md`。
|
|
20
20
|
- CLI 与 Skill 升级读 `references/update.md`。
|
|
21
|
-
-
|
|
21
|
+
- 统一创作读 `references/creative.md`,多步骤场景读 `references/workflows.md`。
|
|
22
22
|
|
|
23
|
-
Agent 只根据公开的 `
|
|
23
|
+
Agent 只根据公开的 `creative`、`workflows` 和 `dam` 命令完成用户需求。普通生成任务中不要切换组织、环境或模型,不要调用内部运行时类、`raw.dify` 或未文档化接口。
|
|
24
24
|
|
|
25
25
|
## 能力选择
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
先读取 Creative 契约和 Workflow 列表,再按用户意图组织输入:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
|
-
gd-cli
|
|
30
|
+
gd-cli creative schema --format json
|
|
31
|
+
gd-cli creative examples --format json
|
|
31
32
|
gd-cli workflows list --format json
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
| 用户意图 | 命令 |
|
|
35
36
|
| --- | --- |
|
|
36
|
-
| 生图、商品主图、海报、场景图 | `gd-cli
|
|
37
|
-
| 抠图、去背景、透明底 | `gd-cli
|
|
38
|
-
| 高清、放大、变清晰 | `gd-cli
|
|
39
|
-
| 文生视频、图生视频、动画短片 | `gd-cli
|
|
37
|
+
| 生图、商品主图、海报、场景图 | `gd-cli creative run --prompt "..."` |
|
|
38
|
+
| 抠图、去背景、透明底 | `gd-cli creative run --input request.json` |
|
|
39
|
+
| 高清、放大、变清晰 | `gd-cli creative run --input request.json` |
|
|
40
|
+
| 文生视频、图生视频、动画短片 | `gd-cli creative run --input request.json` |
|
|
40
41
|
| Listing、商品图库、上架素材 | `gd-cli workflows run listing-gallery` |
|
|
41
42
|
| 详情页、A+、PDP | `gd-cli workflows run pdp-a-plus` |
|
|
42
43
|
| 小红书种草图文 | `gd-cli workflows run social-seeding-pack` |
|
|
@@ -53,5 +54,5 @@ gd-cli workflows list --format json
|
|
|
53
54
|
- `references/errors.md`
|
|
54
55
|
- `references/deliverables.md`
|
|
55
56
|
- `references/update.md`
|
|
56
|
-
- `references/
|
|
57
|
+
- `references/creative.md`
|
|
57
58
|
- `references/workflows.md`
|
|
@@ -21,6 +21,12 @@ Agent 必须立即把 `verification_uri_complete` 原样发送给用户,并保
|
|
|
21
21
|
gd-cli auth status --format json
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
状态输出只区分登录凭证与当前组织:
|
|
25
|
+
|
|
26
|
+
- `logged_in=false`:执行 `gd-cli auth login`。
|
|
27
|
+
- `logged_in=true` 且 `organization=null`:凭证仍有效,按 `org.md` 让用户选择当前组织。
|
|
28
|
+
- `organization` 存在时只读取公开的 `id` 和 `name`,不要依赖其他未公开字段。
|
|
29
|
+
|
|
24
30
|
## 禁止动作
|
|
25
31
|
|
|
26
32
|
- 不向用户索要 Token、Cookie 或 AK/SK。
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# GD CLI Creative
|
|
2
|
+
|
|
3
|
+
Creative 是统一的创作入口。使用者只描述期望的最终结果并提供必要素材与约束,不需要在命令中选择具体实现能力。
|
|
4
|
+
|
|
5
|
+
## 发现契约
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gd-cli creative schema --format json
|
|
9
|
+
gd-cli creative examples --format json
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`creative schema` 和 `creative examples` 是本地静态输出,不请求生成接口。`--format json` 只控制最终序列化格式。
|
|
13
|
+
|
|
14
|
+
## 发起创作
|
|
15
|
+
|
|
16
|
+
纯文本请求:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
gd-cli creative run --prompt "为轻量跑鞋写三条简洁的电商标题" --format json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
需要媒体、比例、分辨率、时长或连续会话时,把完整 JSON 写入文件或 stdin:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
gd-cli creative run --input request.json --format json
|
|
26
|
+
cat request.json | gd-cli creative run --input - --format json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
输入中使用:
|
|
30
|
+
|
|
31
|
+
- `prompt` 详细描述主体、用途、内容、风格、场景、构图或镜头,以及必须保留和避免的事项。
|
|
32
|
+
- `media[]` 传入本地路径或 HTTP(S) URL,并用 `role` 标明 `reference`、`first_frame` 或 `last_frame`。
|
|
33
|
+
- `parameters` 传入可结构化表达的 `ratio`、`resolution` 和 `duration_seconds`。这些约束优先于 prompt 中相同主题的文字描述。
|
|
34
|
+
- `conversation_id` 仅在继续已有创作或回答追问时传入;首次请求不传。
|
|
35
|
+
- 回答追问时传入上一次结果中的 `last_tool_message_id` 和 `answers[]`。`answers[].values` 可以是推荐选项之外的自定义值。
|
|
36
|
+
|
|
37
|
+
`media` 不能单独提交;`first_frame` 和 `last_frame` 各最多一份且必须是图片。视频、音频只能作为 `reference`。
|
|
38
|
+
|
|
39
|
+
## 解析结果
|
|
40
|
+
|
|
41
|
+
机器调用只读取一次最终 JSON:
|
|
42
|
+
|
|
43
|
+
- `status=completed` 且 `data.finish_reason=completed`:本轮完成。
|
|
44
|
+
- `status=completed` 且 `data.finish_reason=requires_input`:按 `data.questions` 组织回答,并将 `conversation_id`、`last_tool_message_id` 原样带回下一次请求。
|
|
45
|
+
- `status=failed`:读取 `error.code`、`error.message`、`error.hint` 和 `error.retryable`,按 `references/errors.md` 处理。
|
|
46
|
+
|
|
47
|
+
CLI 只输出一次最终结果,不输出中间过程。最终媒体位于 `data.outputs[]`,文本位于 `data.message` 或 `data.outputs[]` 的 `type=text` 项。
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
## 查询稿豆余额
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
用户询问剩余稿豆、权益余额或还能生成几次时,执行:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
gd-cli
|
|
18
|
+
gd-cli org credits --format json
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
只根据 `organization`、`credits.total`、`credits.used`、`credits.wait` 和 `credits.surplus` 回复。若用户要求查看其他组织,先执行 `gd-cli org list --format json`,等待用户明确选择后再切换。
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
除非用户明确要求诊断,否则失败后不要切换组织、模型或环境,不查询 `raw.dify`,也不探测未文档化接口。
|
|
14
14
|
|
|
15
|
+
## 授权与当前组织
|
|
16
|
+
|
|
17
|
+
- `AUTH_MISSING`、`AUTH_EXPIRED`:停止当前操作,按 `auth.md` 让用户登录。
|
|
18
|
+
- `ORG_REQUIRED`:执行 `gd-cli org list --format json`,等待用户明确选择后再执行 `org switch`。
|
|
19
|
+
- `ORG_INVALID`:当前组织已被 CLI 清除;重新列出组织并等待用户选择,不自动重放刚才的生成或 DAM 操作。
|
|
20
|
+
- CLI 会在需要时内部维护当前组织访问;不要读取或解释内部刷新时间,也不要要求用户为此反复切换组织。
|
|
21
|
+
|
|
15
22
|
## 回复结构
|
|
16
23
|
|
|
17
24
|
- 发生了什么:使用 `error.message`。
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
1. 用户要图片、视频、电商物料或 DAM 素材时,优先使用 `gd-cli`。
|
|
6
6
|
2. 需要解析结果、错误、URL、`task_id` 或 schema 时,使用 `--format json`。
|
|
7
7
|
3. stdout JSON 用于解析结果,stderr 仅用于进度和排错。
|
|
8
|
-
4. 普通生成任务只使用公开的 `
|
|
8
|
+
4. 普通生成任务只使用公开的 `creative`、`workflows` 和 `dam` 命令。
|
|
9
9
|
5. 不替用户切换组织、环境或模型;涉及账号、组织、充值或授权时,把选择交给用户。
|
|
10
10
|
|
|
11
11
|
## 推荐流程
|
|
12
12
|
|
|
13
13
|
1. 必要时执行 `gd-cli auth status --format json` 检查授权状态。
|
|
14
14
|
2. 未登录时按 `auth.md` 发起授权,并立即把授权链接交给用户。
|
|
15
|
-
3. 使用 `gd-cli
|
|
16
|
-
4.
|
|
15
|
+
3. 使用 `gd-cli creative schema --format json`、`gd-cli creative examples --format json` 和 `gd-cli workflows list --format json` 发现能力。
|
|
16
|
+
4. 图片、视频和文本创作统一使用 Creative,多步骤交付使用 Workflow。
|
|
17
17
|
5. 执行命令后等待终态,解析 `status`、`outputs`、`assets`、`task_id` 和交付路径。
|
|
18
18
|
6. 按 `deliverables.md` 交付预览、链接、本地文件或完整交付包。
|
|
19
19
|
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
- 用户未指定模型时,直接调用目标能力,不主动查询或切换模型。
|
|
23
23
|
- 用户未要求诊断时,不探测内部 endpoint、工具路由或组织权限。
|
|
24
24
|
- 一次调用失败后按 `errors.md` 处理,不扩展为无关诊断。
|
|
25
|
-
- Workflow
|
|
25
|
+
- Workflow 可能连续调用多个内部能力;不要在 Workflow 运行中并行发起重复任务。
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { formatOutput } from "../middleware/output.js";
|
|
2
|
-
import { withErrorHandler } from "../middleware/error-handler.js";
|
|
3
|
-
import { Prompt } from "../core/prompt/index.js";
|
|
4
|
-
import { resolveInvokeOutputFormat, resolveListOutputFormat } from "../utils/list-output-format.js";
|
|
5
|
-
import { getConfiguredModel, getDefaultModelOrder, listModels, modelEntriesForType, parseModelType, publicModelByCode, resolveModelOrder, setConfiguredModel, } from "../models/model-catalog.js";
|
|
6
|
-
export function registerModelsCommand(program) {
|
|
7
|
-
const models = program
|
|
8
|
-
.command("models", { hidden: true })
|
|
9
|
-
.description("模型选择(Agent 入口)")
|
|
10
|
-
.configureHelp({ showGlobalOptions: true });
|
|
11
|
-
models
|
|
12
|
-
.command("list")
|
|
13
|
-
.description("列出可选图像/视频模型")
|
|
14
|
-
.requiredOption("--type <type>", "image / video")
|
|
15
|
-
.action(withErrorHandler(async (options, command) => {
|
|
16
|
-
const cmd = command;
|
|
17
|
-
const type = parseModelType(options.type);
|
|
18
|
-
const selected = getConfiguredModel(type);
|
|
19
|
-
const payload = {
|
|
20
|
-
type,
|
|
21
|
-
current: {
|
|
22
|
-
mode: selected === "auto" ? "auto" : "manual",
|
|
23
|
-
model: selected === "auto" ? undefined : publicModelByCode(type, selected),
|
|
24
|
-
effective_order: resolveModelOrder(type),
|
|
25
|
-
},
|
|
26
|
-
default_order: getDefaultModelOrder(type),
|
|
27
|
-
models: listModels(type),
|
|
28
|
-
};
|
|
29
|
-
const format = resolveListOutputFormat(cmd);
|
|
30
|
-
if (format === "json") {
|
|
31
|
-
formatOutput(payload, "json");
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
formatOutput(payload.models, format);
|
|
35
|
-
}
|
|
36
|
-
}));
|
|
37
|
-
models
|
|
38
|
-
.command("switch")
|
|
39
|
-
.description("切换默认图像/视频模型")
|
|
40
|
-
.requiredOption("--type <type>", "image / video")
|
|
41
|
-
.option("--model <model>", "模型 code / 名称 / auto")
|
|
42
|
-
.action(withErrorHandler(async (options, command) => {
|
|
43
|
-
const cmd = command;
|
|
44
|
-
const opts = options;
|
|
45
|
-
const type = parseModelType(opts.type);
|
|
46
|
-
const model = typeof opts.model === "string" && opts.model.trim()
|
|
47
|
-
? opts.model.trim()
|
|
48
|
-
: await promptModel(type);
|
|
49
|
-
const selected = setConfiguredModel(type, model);
|
|
50
|
-
const payload = {
|
|
51
|
-
type,
|
|
52
|
-
selected: selected === "auto"
|
|
53
|
-
? { mode: "auto" }
|
|
54
|
-
: { mode: "manual", model: publicModelByCode(type, selected) },
|
|
55
|
-
effective_order: resolveModelOrder(type),
|
|
56
|
-
};
|
|
57
|
-
formatOutput(payload, resolveInvokeOutputFormat(cmd));
|
|
58
|
-
}));
|
|
59
|
-
}
|
|
60
|
-
async function promptModel(type) {
|
|
61
|
-
const current = getConfiguredModel(type);
|
|
62
|
-
const choices = [
|
|
63
|
-
{
|
|
64
|
-
name: current === "auto" ? "auto 当前" : "auto",
|
|
65
|
-
value: "auto",
|
|
66
|
-
description: "使用 Web 默认返回顺序和失败兜底",
|
|
67
|
-
},
|
|
68
|
-
...modelEntriesForType(type).map((model) => ({
|
|
69
|
-
name: current === model.code ? `${model.name} 当前` : model.name,
|
|
70
|
-
value: model.code,
|
|
71
|
-
description: `${model.description} / ${model.code} / 消耗${model.cost_level}`,
|
|
72
|
-
})),
|
|
73
|
-
];
|
|
74
|
-
return Prompt.select({
|
|
75
|
-
message: `选择默认${type === "image" ? "图像" : "视频"}模型`,
|
|
76
|
-
choices,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
export declare function registerToolsCommand(program: Command): void;
|
|
3
|
-
export declare function runToolCall(toolName: string, input: string | undefined, opts: Record<string, unknown>, cmd: Command): Promise<void>;
|
|
4
|
-
export declare function mergeToolCallOptions(base: Record<string, unknown>, opts: Record<string, unknown>): Record<string, unknown>;
|