gaoding-cli 1.0.0-alpha.7 → 1.0.0-alpha.9

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +47 -60
  3. package/dist/bin/gd-cli.js +2 -2
  4. package/dist/src/api/app-runner.d.ts +1 -4
  5. package/dist/src/api/app-runner.js +11 -44
  6. package/dist/src/api/creative-client.d.ts +34 -0
  7. package/dist/src/api/creative-client.js +184 -0
  8. package/dist/src/api/dam-client.d.ts +0 -7
  9. package/dist/src/api/dam-client.js +0 -17
  10. package/dist/src/api/direct-client.d.ts +9 -2
  11. package/dist/src/api/direct-client.js +45 -18
  12. package/dist/src/api/hub-client.d.ts +11 -8
  13. package/dist/src/api/hub-client.js +17 -18
  14. package/dist/src/api/usage-client.d.ts +4 -4
  15. package/dist/src/api/usage-client.js +9 -49
  16. package/dist/src/auth/credential-store-v2.d.ts +0 -1
  17. package/dist/src/auth/credential-store-v2.js +0 -6
  18. package/dist/src/commands/auth.js +17 -53
  19. package/dist/src/commands/creative.d.ts +8 -0
  20. package/dist/src/commands/creative.js +178 -0
  21. package/dist/src/commands/dam.js +270 -127
  22. package/dist/src/commands/org.js +31 -47
  23. package/dist/src/commands/skills.js +33 -118
  24. package/dist/src/commands/update.js +11 -82
  25. package/dist/src/commands/usage.d.ts +1 -1
  26. package/dist/src/commands/usage.js +10 -21
  27. package/dist/src/commands/workflows.d.ts +1 -1
  28. package/dist/src/commands/workflows.js +299 -197
  29. package/dist/src/core/auth/auth-guard.d.ts +21 -0
  30. package/dist/src/core/auth/auth-guard.js +121 -0
  31. package/dist/src/core/auth/org-manager.d.ts +2 -1
  32. package/dist/src/core/auth/org-manager.js +61 -6
  33. package/dist/src/core/output/envelope.d.ts +1 -0
  34. package/dist/src/core/output/envelope.js +76 -6
  35. package/dist/src/creative/contract.d.ts +1060 -0
  36. package/dist/src/creative/contract.js +722 -0
  37. package/dist/src/creative/media.d.ts +19 -0
  38. package/dist/src/creative/media.js +83 -0
  39. package/dist/src/creative/protocol.d.ts +60 -0
  40. package/dist/src/creative/protocol.js +337 -0
  41. package/dist/src/io.d.ts +0 -2
  42. package/dist/src/io.js +0 -8
  43. package/dist/src/middleware/auth.d.ts +6 -2
  44. package/dist/src/middleware/auth.js +25 -63
  45. package/dist/src/middleware/error-handler.d.ts +8 -0
  46. package/dist/src/middleware/error-handler.js +61 -57
  47. package/dist/src/program.d.ts +1 -0
  48. package/dist/src/program.js +137 -122
  49. package/dist/src/registry/agent-contracts.d.ts +14 -34
  50. package/dist/src/registry/agent-contracts.js +209 -297
  51. package/dist/src/registry/direct-registry.d.ts +0 -5
  52. package/dist/src/registry/direct-registry.js +0 -19
  53. package/dist/src/registry/registry-client.d.ts +0 -21
  54. package/dist/src/registry/registry-client.js +1 -40
  55. package/dist/src/utils/capability-presenter.js +6 -29
  56. package/dist/src/utils/config.d.ts +2 -2
  57. package/dist/src/utils/config.js +1 -1
  58. package/dist/src/utils/help-verify.d.ts +1 -3
  59. package/dist/src/utils/help-verify.js +1 -25
  60. package/dist/src/utils/sensitive-path.js +1 -4
  61. package/package.json +4 -3
  62. package/skills/gd-cli/SKILL.md +13 -12
  63. package/skills/gd-cli/references/auth.md +9 -10
  64. package/skills/gd-cli/references/creative.md +47 -0
  65. package/skills/gd-cli/references/entitlement.md +3 -3
  66. package/skills/gd-cli/references/errors.md +10 -3
  67. package/skills/gd-cli/references/org.md +3 -3
  68. package/skills/gd-cli/references/sop.md +8 -8
  69. package/skills/gd-cli/references/update.md +4 -3
  70. package/skills/gd-cli/references/workflows.md +7 -6
  71. package/dist/src/commands/models.d.ts +0 -2
  72. package/dist/src/commands/models.js +0 -78
  73. package/dist/src/commands/tools.d.ts +0 -4
  74. package/dist/src/commands/tools.js +0 -383
  75. package/dist/src/utils/list-output-format.d.ts +0 -10
  76. package/dist/src/utils/list-output-format.js +0 -34
  77. package/skills/gd-cli/references/tools.md +0 -29
@@ -4,25 +4,4 @@ export declare class RegistryClient {
4
4
  private client;
5
5
  constructor(client: HubClient);
6
6
  fetchRegistry(): Promise<RegistryResponse>;
7
- getDetail(id: string): Promise<import("./types.js").ToolSpec | import("./types.js").AppSpec>;
8
- search(query: string, options?: {
9
- type?: string;
10
- limit?: number;
11
- }): Promise<{
12
- results: ({
13
- id: string;
14
- type: string;
15
- display_name: string;
16
- description: string;
17
- category: "asset" | "text" | "image" | "video" | "agent" | "template" | "infrastructure";
18
- spec: import("./types.js").ToolSpec;
19
- } | {
20
- id: string;
21
- type: string;
22
- display_name: string;
23
- description: string;
24
- category: string;
25
- spec: import("./types.js").AppSpec;
26
- })[];
27
- }>;
28
7
  }
@@ -1,4 +1,4 @@
1
- import { DIRECT_APPS, DIRECT_REGISTRY, PUBLIC_DIRECT_TOOLS, resolveAppSpec, resolveToolSpec, } from "./direct-registry.js";
1
+ import { DIRECT_REGISTRY } from "./direct-registry.js";
2
2
  export class RegistryClient {
3
3
  client;
4
4
  constructor(client) {
@@ -8,43 +8,4 @@ export class RegistryClient {
8
8
  void this.client;
9
9
  return DIRECT_REGISTRY;
10
10
  }
11
- async getDetail(id) {
12
- const tool = resolveToolSpec(id);
13
- if (tool)
14
- return tool;
15
- const app = resolveAppSpec(id);
16
- if (app)
17
- return app;
18
- throw new Error(`未找到能力: ${id}`);
19
- }
20
- async search(query, options) {
21
- const q = query.trim().toLowerCase();
22
- const toolResults = PUBLIC_DIRECT_TOOLS.map((spec) => ({
23
- id: spec.name,
24
- type: "tool",
25
- display_name: spec.display_name,
26
- description: spec.description,
27
- category: spec.category,
28
- spec,
29
- }));
30
- const appResults = DIRECT_APPS.map((spec) => ({
31
- id: spec.id,
32
- type: "app",
33
- display_name: spec.name,
34
- description: spec.description,
35
- category: spec.category,
36
- spec,
37
- }));
38
- const all = [
39
- ...(!options?.type || options.type === "tool" ? toolResults : []),
40
- ...(!options?.type || options.type === "app" ? appResults : []),
41
- ].filter((item) => {
42
- if (!q)
43
- return true;
44
- return (item.id.toLowerCase().includes(q) ||
45
- item.display_name.toLowerCase().includes(q) ||
46
- item.description.toLowerCase().includes(q));
47
- });
48
- return { results: all.slice(0, options?.limit ?? all.length) };
49
- }
50
11
  }
@@ -1,13 +1,11 @@
1
1
  import chalk from "chalk";
2
2
  export function printCapabilitySchema(payload) {
3
3
  const id = stringValue(payload.id);
4
- const type = stringValue(payload.type);
5
- const namespace = namespaceForType(type);
6
4
  const title = stringValue(payload.title) || id;
7
5
  const category = stringValue(payload.category);
8
6
  const description = stringValue(payload.description);
9
7
  console.log(chalk.bold(`${title} (${id})`));
10
- console.log(`类型: ${labelForType(type)}`);
8
+ console.log("类型: Workflow 场景");
11
9
  if (category)
12
10
  console.log(`分类: ${category}`);
13
11
  if (description)
@@ -27,23 +25,18 @@ export function printCapabilitySchema(payload) {
27
25
  const stdin = recordValue(payload.stdin);
28
26
  const stdinCommand = stringValue(stdin?.command);
29
27
  const canonicalCommand = stringValue(payload.canonical_command);
30
- const fallbackCommand = type === "workflow"
31
- ? `gd-cli workflows run ${id} --input input.json --format json`
32
- : `gd-cli ${namespace} call ${id} --input input.json --format json`;
28
+ const fallbackCommand = `gd-cli workflows run ${id} --input input.json --json`;
33
29
  console.log("");
34
30
  console.log(chalk.bold("调用方式:"));
35
31
  console.log(` ${canonicalCommand ?? fallbackCommand}`);
36
32
  if (stdinCommand)
37
33
  console.log(` ${stdinCommand}`);
38
34
  console.log("");
39
- console.log(chalk.bold("Agent:"));
40
- console.log(` gd-cli ${namespace} schema ${id} --format json`);
41
- console.log(` gd-cli ${namespace} examples ${id} --format json`);
35
+ console.log(` 完整 JSON Schema: gd-cli workflows schema ${id} --json`);
36
+ console.log(` 调用示例: gd-cli workflows examples ${id}`);
42
37
  }
43
38
  export function printCapabilityExamples(payload) {
44
39
  const id = stringValue(payload.id);
45
- const type = stringValue(payload.type);
46
- const namespace = namespaceForType(type);
47
40
  const title = stringValue(payload.title) || id;
48
41
  const category = stringValue(payload.category);
49
42
  const description = stringValue(payload.description);
@@ -51,7 +44,7 @@ export function printCapabilityExamples(payload) {
51
44
  ? payload.examples.filter(isRecord)
52
45
  : [];
53
46
  console.log(chalk.bold(`${title} (${id})`));
54
- console.log(`类型: ${labelForType(type)}`);
47
+ console.log("类型: Workflow 场景");
55
48
  if (category)
56
49
  console.log(`分类: ${category}`);
57
50
  if (description)
@@ -74,23 +67,7 @@ export function printCapabilityExamples(payload) {
74
67
  }
75
68
  });
76
69
  console.log("");
77
- console.log(chalk.bold("Agent:"));
78
- console.log(` gd-cli ${namespace} examples ${id} --format json`);
79
- console.log(` gd-cli ${namespace} schema ${id} --format json`);
80
- }
81
- function namespaceForType(type) {
82
- if (type === "workflow")
83
- return "workflows";
84
- if (type === "skill")
85
- return "skills";
86
- return "tools";
87
- }
88
- function labelForType(type) {
89
- if (type === "workflow")
90
- return "Workflow 场景";
91
- if (type === "skill")
92
- return "Skill 说明";
93
- return "Tool 能力";
70
+ console.log(`完整 JSON Schema: gd-cli workflows schema ${id} --json`);
94
71
  }
95
72
  function printSchemaFields(title, schema, kind) {
96
73
  console.log(chalk.bold(`${title}:`));
@@ -5,9 +5,9 @@ export declare const PROD_API_BASE = "https://gdcli.gaoding.com/api";
5
5
  export declare const GDHUB_DIR: string;
6
6
  /** Migrate credentials from the early internal storage directory when present. */
7
7
  export declare function migrateCredentialsIfNeeded(): void;
8
- export declare const CLI_VERSION = "1.0.0-alpha.7";
8
+ export declare const CLI_VERSION = "1.0.0-alpha.9";
9
9
  export declare const CLI_PACKAGE_NAME = "gaoding-cli";
10
- export declare const CLI_USER_AGENT = "gd-cli/1.0.0-alpha.7";
10
+ export declare const CLI_USER_AGENT = "gd-cli/1.0.0-alpha.9";
11
11
  export declare const GDHUB_CLI_CLIENT_ID = "gdhub-cli";
12
12
  export declare const DEFAULT_SCOPE: readonly ["scene-executor", "run:scene-app", "use:tools", "export", "read:public"];
13
13
  export declare const CACHE_TTL_MS: number;
@@ -32,7 +32,7 @@ export function migrateCredentialsIfNeeded() {
32
32
  function readEnv(key, legacyKey) {
33
33
  return process.env[key] ?? process.env[legacyKey];
34
34
  }
35
- export const CLI_VERSION = "1.0.0-alpha.7";
35
+ export const CLI_VERSION = "1.0.0-alpha.9";
36
36
  export const CLI_PACKAGE_NAME = "gaoding-cli";
37
37
  export const CLI_USER_AGENT = `gd-cli/${CLI_VERSION}`;
38
38
  export const GDHUB_CLI_CLIENT_ID = "gdhub-cli";
@@ -1,9 +1,7 @@
1
1
  import type { Command } from "commander";
2
2
  /**
3
- * 在命令 `-h` 底部追加一段「快速验证」单行示例(用于具体 Tool / Workflow 子命令)。
3
+ * 在命令 `-h` 底部追加一段「快速验证」单行示例(用于 Workflow 子命令)。
4
4
  */
5
5
  export declare function appendVerifySnippet(cmd: Command, line: string): void;
6
- /** 按工具 id 附加对应示例;无映射则不加(避免误导) */
7
- export declare function appendToolQuickExample(cmd: Command, toolName: string): void;
8
6
  /** `gd-cli workflows run -h` 专用 */
9
7
  export declare function appendAppRunQuickExample(cmd: Command, _legacyPrefix?: string): void;
@@ -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` 底部追加一段「快速验证」单行示例(用于具体 Tool / Workflow 子命令)。
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;
@@ -29,7 +29,7 @@ const SENSITIVE_FILENAMES = new Set([
29
29
  ]);
30
30
  export function assertSafeUploadPath(file, options = {}) {
31
31
  const absolutePath = path.resolve(process.cwd(), file);
32
- if (allowSensitive(options))
32
+ if (options.allowSensitivePath === true)
33
33
  return absolutePath;
34
34
  const reason = sensitivePathReason(absolutePath);
35
35
  if (reason) {
@@ -64,6 +64,3 @@ export function sensitivePathReason(file) {
64
64
  }
65
65
  return null;
66
66
  }
67
- function allowSensitive(options) {
68
- return options.allowSensitivePath === true || process.env.GD_CLI_ALLOW_SENSITIVE_PATHS === "1";
69
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gaoding-cli",
3
- "version": "1.0.0-alpha.7",
4
- "description": "稿定 GD CLI - Tools / Workflows / DAM 命令行工具",
3
+ "version": "1.0.0-alpha.9",
4
+ "description": "稿定 GD CLI - Creative / Workflows / DAM 命令行工具",
5
5
  "license": "MIT",
6
6
  "author": "Gaoding",
7
7
  "type": "module",
@@ -59,6 +59,7 @@
59
59
  "@types/node": "^22.14.1",
60
60
  "@types/qrcode": "^1.5.6",
61
61
  "@types/uuid": "^10.0.0",
62
+ "ajv": "^8.20.0",
62
63
  "eslint": "^9.24.0",
63
64
  "tsx": "^4.19.4",
64
65
  "typescript": "^5.8.3",
@@ -78,7 +79,7 @@
78
79
  "gd-cli",
79
80
  "cli",
80
81
  "visual-creation",
81
- "ai-tools",
82
+ "creative",
82
83
  "dam"
83
84
  ]
84
85
  }
@@ -7,7 +7,7 @@ description: 当用户需要使用稿定生成图片、视频、电商素材或
7
7
 
8
8
  ## 执行原则
9
9
 
10
- 当用户提出图片、视频、电商物料或 DAM 素材需求时,优先使用本地 `gd-cli` 调用稿定能力。不要因为当前 Agent 的工具列表中没有稿定工具,就改用本地 Canvas、ffmpeg、SVG 或未文档化接口。
10
+ 当用户提出图片、视频、电商物料或 DAM 素材需求时,优先使用本地 `gd-cli`。不要因当前 Agent 的能力列表中没有稿定入口,就改用本地 Canvas、ffmpeg、SVG 或未文档化接口。
11
11
 
12
12
  开始执行前:
13
13
 
@@ -18,31 +18,32 @@ description: 当用户需要使用稿定生成图片、视频、电商素材或
18
18
  - 错误处理和停止规则读 `references/errors.md`。
19
19
  - 图片、视频和交付包处理读 `references/deliverables.md`。
20
20
  - CLI 与 Skill 升级读 `references/update.md`。
21
- - 单点能力读 `references/tools.md`,多步骤场景读 `references/workflows.md`。
21
+ - 统一创作读 `references/creative.md`,多步骤场景读 `references/workflows.md`。
22
22
 
23
- Agent 只根据公开的 `tools`、`workflows` 和 `dam` 命令完成用户需求。普通生成任务中不要切换组织、环境或模型,不要调用内部运行时类、`raw.dify` 或未文档化接口。
23
+ Agent 只根据公开的 `creative`、`workflows` 和 `dam` 命令完成用户需求。普通生成任务中不要切换组织、环境或模型,也不要调用内部运行时类或未文档化接口。
24
24
 
25
25
  ## 能力选择
26
26
 
27
- 先读取能力列表,再按用户意图匹配:
27
+ 先读取 Creative 契约和 Workflow 列表,再按用户意图组织输入:
28
28
 
29
29
  ```bash
30
- gd-cli tools list --format json
31
- gd-cli workflows list --format json
30
+ gd-cli creative schema --json
31
+ gd-cli creative examples
32
+ gd-cli workflows list --json
32
33
  ```
33
34
 
34
35
  | 用户意图 | 命令 |
35
36
  | --- | --- |
36
- | 生图、商品主图、海报、场景图 | `gd-cli tools call image.generate` |
37
- | 抠图、去背景、透明底 | `gd-cli tools call image.cutout` |
38
- | 高清、放大、变清晰 | `gd-cli tools call image.super-res` |
39
- | 文生视频、图生视频、动画短片 | `gd-cli tools call video.generate` |
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` |
43
44
  | Campaign KV、多渠道素材 | `gd-cli workflows run campaign-kv-pack` |
44
45
 
45
- 复杂输入优先通过 `--input <json-file>` 或 stdin 传入。Agent 解析结果时使用 `--format json`,最终回复按 `references/deliverables.md` 展示预览、链接或文件,不要直接转发整段原始 JSON。
46
+ 复杂输入优先通过 `--input <json-file>` 或 stdin 传入。只在该命令支持时传入 `--json`;最终回复按 `references/deliverables.md` 展示预览、链接或文件,不要直接转发整段原始 JSON。
46
47
 
47
48
  ## 参考资料
48
49
 
@@ -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/tools.md`
57
+ - `references/creative.md`
57
58
  - `references/workflows.md`
@@ -5,22 +5,21 @@
5
5
  在 Agent 或非 TTY Shell 中执行:
6
6
 
7
7
  ```bash
8
- gd-cli auth login --no-browser --format json
8
+ gd-cli auth login --no-browser
9
9
  ```
10
10
 
11
- 命令会输出包含以下字段的授权信息:
12
-
13
- - `type=device_authorization`
14
- - `verification_uri_complete`
15
- - `expires_in`
16
- - `interval`
17
-
18
- Agent 必须立即把 `verification_uri_complete` 原样发送给用户,并保持授权进程运行。用户完成授权后,再执行:
11
+ 登录命令只输出面向人的授权信息。Agent 必须从输出中提取授权 URL,原样发送给用户,并保持授权进程运行。用户完成授权后,再执行:
19
12
 
20
13
  ```bash
21
- gd-cli auth status --format json
14
+ gd-cli auth status --json
22
15
  ```
23
16
 
17
+ 状态输出只区分登录凭证与当前组织:
18
+
19
+ - `logged_in=false`:执行 `gd-cli auth login`。
20
+ - `logged_in=true` 且 `organization=null`:凭证仍有效,按 `org.md` 让用户选择当前组织。
21
+ - `organization` 存在时只读取公开的 `id` 和 `name`,不要依赖其他未公开字段。
22
+
24
23
  ## 禁止动作
25
24
 
26
25
  - 不向用户索要 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 --json
9
+ gd-cli creative examples
10
+ ```
11
+
12
+ `creative schema` 是本地静态输出;`creative examples` 输出完整可运行的 shell 命令,两者都不请求生成接口。
13
+
14
+ ## 发起创作
15
+
16
+ 纯文本请求:
17
+
18
+ ```bash
19
+ gd-cli creative run --prompt "为轻量跑鞋写三条简洁的电商标题" --json
20
+ ```
21
+
22
+ 需要媒体、比例、分辨率、时长或连续会话时,把完整 JSON 写入文件或 stdin:
23
+
24
+ ```bash
25
+ gd-cli creative run --input request.json --json
26
+ cat request.json | gd-cli creative run --input - --json
27
+ ```
28
+
29
+ 输入中使用:
30
+
31
+ - `prompt` 描述主体、用途、内容、风格、场景、构图或镜头,以及必须保留和避免的事项。
32
+ - `media[]` 传入本地路径或 HTTP(S) URL,并用 `role` 标明 `reference`、`first_frame` 或 `last_frame`。
33
+ - `parameters` 传入可结构化表达的 `ratio`、`resolution` 和 `duration_seconds`。
34
+ - `conversation_id` 仅在继续已有创作或回答追问时传入;首次请求不传。
35
+ - 回答追问时传入上一次结果中的 `question_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`、`question_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
- 用户询问剩余稿豆、权益余额、还能生成几次或 usage 时,执行:
15
+ 用户询问剩余稿豆、权益余额或还能生成几次时,执行:
16
16
 
17
17
  ```bash
18
- gd-cli usage --format json
18
+ gd-cli org credits --json
19
19
  ```
20
20
 
21
- 只根据 `organization`、`credits.total`、`credits.used`、`credits.wait` 和 `credits.surplus` 回复。若用户要求查看其他组织,先执行 `gd-cli org list --format json`,等待用户明确选择后再切换。
21
+ 只根据 `organization`、`credits.total`、`credits.used`、`credits.wait` 和 `credits.surplus` 回复。若用户要求查看其他组织,先执行 `gd-cli org list --json`,等待用户明确选择后再切换。
@@ -2,15 +2,22 @@
2
2
 
3
3
  ## 停止规则
4
4
 
5
- 1. 命令非零退出时,先解析 stdout 中的 JSON envelope。
5
+ 1. 机器可读调用非零退出时,解析 stdout 中的 JSON envelope。
6
6
  2. 优先读取 `error.code`、`error.message`、`error.hint`、`error.next_steps`、`pricing_url` 和 `retryable`。
7
7
  3. `retryable=false` 或未提供 `retryable` 时,不重复执行同一失败命令。
8
8
  4. 只有 `NETWORK_TRANSIENT` 可以短暂重试一次;第二次失败必须停止。
9
- 5. `TOOL_ROUTE_UNAVAILABLE`、`ENTITLEMENT_INSUFFICIENT`、参数错误、授权错误和组织错误都不能盲目重试。
9
+ 5. 内部路由不可用、权益不足、参数错误、授权错误和组织错误都不能盲目重试。
10
10
 
11
11
  ## 禁止扩展诊断
12
12
 
13
- 除非用户明确要求诊断,否则失败后不要切换组织、模型或环境,不查询 `raw.dify`,也不探测未文档化接口。
13
+ 除非用户明确要求诊断,否则失败后不要切换组织、模型或环境,也不探测未文档化接口。
14
+
15
+ ## 授权与当前组织
16
+
17
+ - `AUTH_MISSING`、`AUTH_EXPIRED`:停止当前操作,按 `auth.md` 让用户登录。
18
+ - `ORG_REQUIRED`:执行 `gd-cli org list --json`,等待用户明确选择后再执行 `org switch`。
19
+ - `ORG_INVALID`:当前组织已被 CLI 清除;重新列出组织并等待用户选择,不自动重放刚才的生成或 DAM 操作。
20
+ - CLI 会在需要时内部维护当前组织访问;不要读取或解释内部刷新时间,也不要要求用户为此反复切换组织。
14
21
 
15
22
  ## 回复结构
16
23
 
@@ -5,14 +5,14 @@
5
5
  Agent 可以读取组织,但不能替用户选择组织:
6
6
 
7
7
  ```bash
8
- gd-cli org list --format json
9
- gd-cli org current --format json
8
+ gd-cli org list --json
9
+ gd-cli org current --json
10
10
  ```
11
11
 
12
12
  只有用户明确选择具体组织后,才执行:
13
13
 
14
14
  ```bash
15
- gd-cli org switch --org <org-id> --format json
15
+ gd-cli org switch --org <org-id>
16
16
  ```
17
17
 
18
18
  如果 `org list` 返回多个组织,向用户列出组织名称、组织 ID 和当前状态,然后等待选择。不要根据名称、权益、历史记录或猜测自动切换。
@@ -3,23 +3,23 @@
3
3
  ## 总规则
4
4
 
5
5
  1. 用户要图片、视频、电商物料或 DAM 素材时,优先使用 `gd-cli`。
6
- 2. 需要解析结果、错误、URL、`task_id` 或 schema 时,使用 `--format json`。
6
+ 2. 仅在目标叶命令支持时使用 `--json` 解析结果、错误、URL、`task_id` 或 Schema;非 TTY 不会自动启用 JSON。
7
7
  3. stdout JSON 用于解析结果,stderr 仅用于进度和排错。
8
- 4. 普通生成任务只使用公开的 `tools`、`workflows` 和 `dam` 命令。
8
+ 4. 普通生成任务只使用公开的 `creative`、`workflows` 和 `dam` 命令。
9
9
  5. 不替用户切换组织、环境或模型;涉及账号、组织、充值或授权时,把选择交给用户。
10
10
 
11
11
  ## 推荐流程
12
12
 
13
- 1. 必要时执行 `gd-cli auth status --format json` 检查授权状态。
14
- 2. 未登录时按 `auth.md` 发起授权,并立即把授权链接交给用户。
15
- 3. 使用 `gd-cli manifest --format json`、`gd-cli tools list --format json` 和 `gd-cli workflows list --format json` 发现能力。
16
- 4. 单项处理选择 Tool,多步骤交付选择 Workflow。
13
+ 1. 必要时执行 `gd-cli auth status --json` 检查授权状态。
14
+ 2. 未登录时按 `auth.md` 执行 `gd-cli auth login --no-browser`,从人类输出提取授权 URL 并原样发送给用户。
15
+ 3. 使用 `gd-cli creative schema --json`、`gd-cli creative examples` 和 `gd-cli workflows list --json` 发现能力。
16
+ 4. 图片、视频和文本创作统一使用 Creative,多步骤交付使用 Workflow。
17
17
  5. 执行命令后等待终态,解析 `status`、`outputs`、`assets`、`task_id` 和交付路径。
18
18
  6. 按 `deliverables.md` 交付预览、链接、本地文件或完整交付包。
19
19
 
20
20
  ## 调用边界
21
21
 
22
22
  - 用户未指定模型时,直接调用目标能力,不主动查询或切换模型。
23
- - 用户未要求诊断时,不探测内部 endpoint、工具路由或组织权限。
23
+ - 用户未要求诊断时,不探测内部 endpoint、能力路由或组织权限。
24
24
  - 一次调用失败后按 `errors.md` 处理,不扩展为无关诊断。
25
- - Workflow 可能连续调用多个 Tool;不要在 Workflow 运行中并行发起重复任务。
25
+ - Workflow 可能连续调用多个内部能力;不要在 Workflow 运行中并行发起重复任务。
@@ -3,14 +3,15 @@
3
3
  ## 检查和升级 CLI
4
4
 
5
5
  ```bash
6
- gd-cli update check --format json
7
6
  gd-cli update
8
7
  ```
9
8
 
10
- CLI 升级完成后,显式刷新已安装的 Agent Skill
9
+ `update` 没有子命令或选项,会检查最新版本并在全局安装场景执行升级。CLI 升级完成后,仅在已安装 canonical Skill 时刷新该 Skill。
10
+
11
+ 也可单独刷新已安装的 Agent Skill:
11
12
 
12
13
  ```bash
13
14
  gd-cli skills update
14
15
  ```
15
16
 
16
- 如果结果中 `restart_required=true`,提示用户重启 Agent 或开启新会话。没有写入变化时,不要求用户重启。
17
+ 只有安装内容确实变化时,才提示用户重启 Agent 或开启新会话。
@@ -1,17 +1,18 @@
1
1
  # GD CLI Workflows
2
2
 
3
- Workflow 编排多个 Tool,适合需要一组完整交付物的业务场景。
3
+ Workflow 编排预定义步骤和内部能力,适合需要一组完整交付物的业务场景。
4
4
 
5
5
  发现和执行:
6
6
 
7
7
  ```bash
8
- gd-cli workflows list --format json
9
- gd-cli workflows info <workflow-id> --format json
10
- gd-cli workflows schema <workflow-id> --format json
11
- gd-cli workflows examples <workflow-id> --format json
12
- gd-cli workflows run <workflow-id> --input brief.json --format json
8
+ gd-cli workflows list --json
9
+ gd-cli workflows schema <workflow-id> --json
10
+ gd-cli workflows examples <workflow-id>
11
+ gd-cli workflows run <workflow-id> --input brief.json --json
13
12
  ```
14
13
 
14
+ `examples` 输出完整可运行命令,不支持 JSON 输出。`list`、`schema` 和 `run` 仅在显式传入 `--json` 时输出机器可读结果。
15
+
15
16
  | Workflow ID | 场景 | 交付内容 |
16
17
  | --- | --- | --- |
17
18
  | `listing-gallery` | Listing、商品图库、上架素材 | 白底主图、卖点图、细节图、场景图和文案 |
@@ -1,2 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerModelsCommand(program: Command): void;
@@ -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>;