gaoding-cli 1.0.0-alpha.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/CHANGELOG.md +88 -0
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/SECURITY.md +34 -0
- package/dist/bin/gd-cli.d.ts +2 -0
- package/dist/bin/gd-cli.js +10 -0
- package/dist/src/api/app-runner.d.ts +33 -0
- package/dist/src/api/app-runner.js +1177 -0
- package/dist/src/api/dam-client.d.ts +111 -0
- package/dist/src/api/dam-client.js +897 -0
- package/dist/src/api/direct-auth.d.ts +3 -0
- package/dist/src/api/direct-auth.js +11 -0
- package/dist/src/api/direct-client.d.ts +27 -0
- package/dist/src/api/direct-client.js +151 -0
- package/dist/src/api/direct-tools.d.ts +43 -0
- package/dist/src/api/direct-tools.js +1155 -0
- package/dist/src/api/hub-client.d.ts +20 -0
- package/dist/src/api/hub-client.js +99 -0
- package/dist/src/api/sso-client.d.ts +60 -0
- package/dist/src/api/sso-client.js +140 -0
- package/dist/src/api/task-poller.d.ts +38 -0
- package/dist/src/api/task-poller.js +72 -0
- package/dist/src/api/tool-invoker.d.ts +12 -0
- package/dist/src/api/tool-invoker.js +11 -0
- package/dist/src/api/usage-client.d.ts +39 -0
- package/dist/src/api/usage-client.js +179 -0
- package/dist/src/auth/credential-store-v2.d.ts +12 -0
- package/dist/src/auth/credential-store-v2.js +59 -0
- package/dist/src/commands/auth.d.ts +2 -0
- package/dist/src/commands/auth.js +191 -0
- package/dist/src/commands/dam.d.ts +2 -0
- package/dist/src/commands/dam.js +293 -0
- package/dist/src/commands/models.d.ts +2 -0
- package/dist/src/commands/models.js +78 -0
- package/dist/src/commands/org.d.ts +2 -0
- package/dist/src/commands/org.js +137 -0
- package/dist/src/commands/skills.d.ts +2 -0
- package/dist/src/commands/skills.js +213 -0
- package/dist/src/commands/tools.d.ts +4 -0
- package/dist/src/commands/tools.js +383 -0
- package/dist/src/commands/update.d.ts +2 -0
- package/dist/src/commands/update.js +167 -0
- package/dist/src/commands/usage.d.ts +7 -0
- package/dist/src/commands/usage.js +43 -0
- package/dist/src/commands/workflows.d.ts +3 -0
- package/dist/src/commands/workflows.js +398 -0
- package/dist/src/core/auth/auth-provider.d.ts +8 -0
- package/dist/src/core/auth/auth-provider.js +12 -0
- package/dist/src/core/auth/device-oauth-provider.d.ts +12 -0
- package/dist/src/core/auth/device-oauth-provider.js +124 -0
- package/dist/src/core/auth/org-manager.d.ts +26 -0
- package/dist/src/core/auth/org-manager.js +224 -0
- package/dist/src/core/auth/signature.d.ts +19 -0
- package/dist/src/core/auth/signature.js +33 -0
- package/dist/src/core/auth/types.d.ts +52 -0
- package/dist/src/core/auth/types.js +3 -0
- package/dist/src/core/output/cli-error.d.ts +5 -0
- package/dist/src/core/output/cli-error.js +8 -0
- package/dist/src/core/output/detector.d.ts +5 -0
- package/dist/src/core/output/detector.js +14 -0
- package/dist/src/core/output/engine.d.ts +32 -0
- package/dist/src/core/output/engine.js +77 -0
- package/dist/src/core/output/envelope.d.ts +40 -0
- package/dist/src/core/output/envelope.js +119 -0
- package/dist/src/core/output/index.d.ts +4 -0
- package/dist/src/core/output/index.js +4 -0
- package/dist/src/core/output/live-display.d.ts +15 -0
- package/dist/src/core/output/live-display.js +111 -0
- package/dist/src/core/output/result-card.d.ts +18 -0
- package/dist/src/core/output/result-card.js +39 -0
- package/dist/src/core/prompt/index.d.ts +31 -0
- package/dist/src/core/prompt/index.js +36 -0
- package/dist/src/io.d.ts +14 -0
- package/dist/src/io.js +31 -0
- package/dist/src/middleware/auth.d.ts +3 -0
- package/dist/src/middleware/auth.js +74 -0
- package/dist/src/middleware/error-handler.d.ts +3 -0
- package/dist/src/middleware/error-handler.js +431 -0
- package/dist/src/middleware/interactive-params.d.ts +14 -0
- package/dist/src/middleware/interactive-params.js +53 -0
- package/dist/src/middleware/output.d.ts +14 -0
- package/dist/src/middleware/output.js +546 -0
- package/dist/src/models/model-catalog.d.ts +26 -0
- package/dist/src/models/model-catalog.js +216 -0
- package/dist/src/program.d.ts +2 -0
- package/dist/src/program.js +152 -0
- package/dist/src/registry/agent-contracts.d.ts +43 -0
- package/dist/src/registry/agent-contracts.js +483 -0
- package/dist/src/registry/app-loader.d.ts +2 -0
- package/dist/src/registry/app-loader.js +70 -0
- package/dist/src/registry/direct-registry.d.ts +11 -0
- package/dist/src/registry/direct-registry.js +234 -0
- package/dist/src/registry/registry-cache.d.ts +10 -0
- package/dist/src/registry/registry-cache.js +52 -0
- package/dist/src/registry/registry-client.d.ts +28 -0
- package/dist/src/registry/registry-client.js +50 -0
- package/dist/src/registry/types.d.ts +69 -0
- package/dist/src/registry/types.js +1 -0
- package/dist/src/tty/auth-presenter.d.ts +3 -0
- package/dist/src/tty/auth-presenter.js +21 -0
- package/dist/src/update/install-source.d.ts +19 -0
- package/dist/src/update/install-source.js +139 -0
- package/dist/src/update/notifier.d.ts +2 -0
- package/dist/src/update/notifier.js +59 -0
- package/dist/src/update/update-checker.d.ts +22 -0
- package/dist/src/update/update-checker.js +110 -0
- package/dist/src/update/version.d.ts +9 -0
- package/dist/src/update/version.js +52 -0
- package/dist/src/utils/agent-skill-installer.d.ts +57 -0
- package/dist/src/utils/agent-skill-installer.js +389 -0
- package/dist/src/utils/capability-metadata.d.ts +18 -0
- package/dist/src/utils/capability-metadata.js +88 -0
- package/dist/src/utils/capability-presenter.d.ts +4 -0
- package/dist/src/utils/capability-presenter.js +190 -0
- package/dist/src/utils/config.d.ts +16 -0
- package/dist/src/utils/config.js +54 -0
- package/dist/src/utils/credential-permissions.d.ts +2 -0
- package/dist/src/utils/credential-permissions.js +22 -0
- package/dist/src/utils/ecommerce-input-guidance.d.ts +15 -0
- package/dist/src/utils/ecommerce-input-guidance.js +85 -0
- package/dist/src/utils/endpoints.d.ts +52 -0
- package/dist/src/utils/endpoints.js +258 -0
- package/dist/src/utils/enrich-upload-params.d.ts +6 -0
- package/dist/src/utils/enrich-upload-params.js +11 -0
- package/dist/src/utils/entitlement.d.ts +17 -0
- package/dist/src/utils/entitlement.js +146 -0
- package/dist/src/utils/gd-home.d.ts +7 -0
- package/dist/src/utils/gd-home.js +26 -0
- package/dist/src/utils/help-verify.d.ts +9 -0
- package/dist/src/utils/help-verify.js +41 -0
- package/dist/src/utils/input-json.d.ts +3 -0
- package/dist/src/utils/input-json.js +61 -0
- package/dist/src/utils/list-output-format.d.ts +10 -0
- package/dist/src/utils/list-output-format.js +34 -0
- package/dist/src/utils/logger.d.ts +6 -0
- package/dist/src/utils/logger.js +19 -0
- package/dist/src/utils/matting-compose.d.ts +10 -0
- package/dist/src/utils/matting-compose.js +45 -0
- package/dist/src/utils/open-browser.d.ts +1 -0
- package/dist/src/utils/open-browser.js +4 -0
- package/dist/src/utils/output-path.d.ts +5 -0
- package/dist/src/utils/output-path.js +70 -0
- package/dist/src/utils/redact.d.ts +3 -0
- package/dist/src/utils/redact.js +96 -0
- package/dist/src/utils/reference-image.d.ts +8 -0
- package/dist/src/utils/reference-image.js +43 -0
- package/dist/src/utils/resolve-app-local-images.d.ts +8 -0
- package/dist/src/utils/resolve-app-local-images.js +84 -0
- package/dist/src/utils/sensitive-path.d.ts +6 -0
- package/dist/src/utils/sensitive-path.js +69 -0
- package/dist/src/utils/settings-store.d.ts +42 -0
- package/dist/src/utils/settings-store.js +50 -0
- package/dist/src/utils/sleep.d.ts +1 -0
- package/dist/src/utils/sleep.js +3 -0
- package/dist/src/utils/spinner.d.ts +2 -0
- package/dist/src/utils/spinner.js +4 -0
- package/dist/src/utils/static-help.d.ts +2 -0
- package/dist/src/utils/static-help.js +3 -0
- package/dist/src/utils/tool-display.d.ts +10 -0
- package/dist/src/utils/tool-display.js +55 -0
- package/dist/src/utils/transient-network-error.d.ts +4 -0
- package/dist/src/utils/transient-network-error.js +40 -0
- package/dist/src/utils/url-safety.d.ts +6 -0
- package/dist/src/utils/url-safety.js +67 -0
- package/dist/src/utils/write-app-deliverables.d.ts +18 -0
- package/dist/src/utils/write-app-deliverables.js +386 -0
- package/package.json +91 -0
- package/skills/gd-cli/SKILL.md +57 -0
- package/skills/gd-cli/references/auth.md +31 -0
- package/skills/gd-cli/references/deliverables.md +22 -0
- package/skills/gd-cli/references/entitlement.md +21 -0
- package/skills/gd-cli/references/errors.md +19 -0
- package/skills/gd-cli/references/org.md +18 -0
- package/skills/gd-cli/references/sop.md +25 -0
- package/skills/gd-cli/references/tools.md +29 -0
- package/skills/gd-cli/references/update.md +16 -0
- package/skills/gd-cli/references/workflows.md +22 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { readSettings, writeSettings } from "../utils/settings-store.js";
|
|
2
|
+
const IMAGE_MODELS = [
|
|
3
|
+
{
|
|
4
|
+
type: "image",
|
|
5
|
+
name: "智能图像",
|
|
6
|
+
code: "general",
|
|
7
|
+
description: "高画质|40+风格",
|
|
8
|
+
cost_level: "低",
|
|
9
|
+
aliases: ["smart", "general-image"],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: "image",
|
|
13
|
+
name: "万相 2.7",
|
|
14
|
+
code: "Wan27-image",
|
|
15
|
+
description: "印刷级文字渲染",
|
|
16
|
+
cost_level: "低",
|
|
17
|
+
aliases: ["wan-image", "text-render"],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "image",
|
|
21
|
+
name: "灵动图像 2.0",
|
|
22
|
+
code: "vivi-image-2-0",
|
|
23
|
+
description: "极致可控的编辑模型丨高质量",
|
|
24
|
+
cost_level: "低",
|
|
25
|
+
aliases: ["vivi", "edit", "gpt-edit"],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: "image",
|
|
29
|
+
name: "全能图像 2.0 Flash",
|
|
30
|
+
code: "omni-image-2-0-flash",
|
|
31
|
+
description: "超强长文本理解",
|
|
32
|
+
cost_level: "低",
|
|
33
|
+
aliases: ["fast", "omni-flash"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "image",
|
|
37
|
+
name: "全能图像 2.0",
|
|
38
|
+
code: "omni-image-2-0",
|
|
39
|
+
description: "多角色细节控制",
|
|
40
|
+
cost_level: "低",
|
|
41
|
+
aliases: ["omni", "nano2"],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "image",
|
|
45
|
+
name: "Seedream 5.0 Lite",
|
|
46
|
+
code: "Seedream-5-0-lite",
|
|
47
|
+
description: "即梦5.0 lite",
|
|
48
|
+
cost_level: "低",
|
|
49
|
+
aliases: ["seedream", "seedream-lite"],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: "image",
|
|
53
|
+
name: "千问 Image 2.0 Pro",
|
|
54
|
+
code: "Qwen-image-2-0-Pro",
|
|
55
|
+
description: "图文/图表/PPT直出",
|
|
56
|
+
cost_level: "低",
|
|
57
|
+
aliases: ["qwen-pro", "doc-chart"],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "image",
|
|
61
|
+
name: "千问 Image 2.0",
|
|
62
|
+
code: "Qwen-image-2-0",
|
|
63
|
+
description: "超长文本渲染",
|
|
64
|
+
cost_level: "低",
|
|
65
|
+
aliases: ["qwen"],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
const VIDEO_MODELS = [
|
|
69
|
+
{
|
|
70
|
+
type: "video",
|
|
71
|
+
name: "Seedance 2.0 Fast",
|
|
72
|
+
code: "OmniVideo-2-0-Fast",
|
|
73
|
+
description: "极速全能模型丨支持真人人脸",
|
|
74
|
+
cost_level: "高",
|
|
75
|
+
aliases: ["seedance-fast", "seedance"],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "video",
|
|
79
|
+
name: "万相 2.7",
|
|
80
|
+
code: "Wan27",
|
|
81
|
+
description: "阿里全能模型丨超强控制能力",
|
|
82
|
+
cost_level: "中",
|
|
83
|
+
aliases: ["wan-video", "wan27"],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: "video",
|
|
87
|
+
name: "万相 2.6",
|
|
88
|
+
code: "Wan26",
|
|
89
|
+
description: "多角色互动丨连贯的叙事视频",
|
|
90
|
+
cost_level: "低",
|
|
91
|
+
aliases: ["wan26"],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: "video",
|
|
95
|
+
name: "Happy horse 1.0",
|
|
96
|
+
code: "happy-horse-10",
|
|
97
|
+
description: "主体动作控制流畅丨极速模型",
|
|
98
|
+
cost_level: "高",
|
|
99
|
+
aliases: ["happy-horse", "happy"],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "video",
|
|
103
|
+
name: "可灵 3.0",
|
|
104
|
+
code: "Kling30",
|
|
105
|
+
description: "智能分镜视频丨转场流畅",
|
|
106
|
+
cost_level: "中",
|
|
107
|
+
aliases: ["kling", "kling30"],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: "video",
|
|
111
|
+
name: "可灵 O3",
|
|
112
|
+
code: "KlingO3",
|
|
113
|
+
description: "更强的主体/场景一致性控制",
|
|
114
|
+
cost_level: "低",
|
|
115
|
+
aliases: ["kling-o3"],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: "video",
|
|
119
|
+
name: "Vidu Q3",
|
|
120
|
+
code: "ViduQ3",
|
|
121
|
+
description: "专业动画制作丨画风控制稳定",
|
|
122
|
+
cost_level: "高",
|
|
123
|
+
aliases: ["vidu"],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: "video",
|
|
127
|
+
name: "Vidu Q3 Turbo",
|
|
128
|
+
code: "ViduQ3Turbo",
|
|
129
|
+
description: "专业动画制作丨极速模型",
|
|
130
|
+
cost_level: "中",
|
|
131
|
+
aliases: ["vidu-turbo"],
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
export function parseModelType(value) {
|
|
135
|
+
const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
136
|
+
if (normalized === "image" || normalized === "video")
|
|
137
|
+
return normalized;
|
|
138
|
+
throw new Error("请传 --type image 或 --type video");
|
|
139
|
+
}
|
|
140
|
+
export function listModels(type) {
|
|
141
|
+
return entriesForType(type).map(toPublicModelEntry);
|
|
142
|
+
}
|
|
143
|
+
export function modelEntriesForType(type) {
|
|
144
|
+
return [...entriesForType(type)];
|
|
145
|
+
}
|
|
146
|
+
export function getDefaultModelOrder(type) {
|
|
147
|
+
return modelEntriesForType(type).map((model) => model.code);
|
|
148
|
+
}
|
|
149
|
+
export function getConfiguredModel(type) {
|
|
150
|
+
const configured = readSettings().models?.[type];
|
|
151
|
+
return configured && configured.trim() ? configured : "auto";
|
|
152
|
+
}
|
|
153
|
+
export function setConfiguredModel(type, model) {
|
|
154
|
+
const normalized = normalizeConfiguredModel(type, model);
|
|
155
|
+
const settings = readSettings();
|
|
156
|
+
writeSettings({
|
|
157
|
+
...settings,
|
|
158
|
+
models: {
|
|
159
|
+
...(settings.models ?? {}),
|
|
160
|
+
[type]: normalized,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
return normalized;
|
|
164
|
+
}
|
|
165
|
+
export function resolveModelOrder(type, explicitModel) {
|
|
166
|
+
const explicit = normalizeOptionalModelValue(explicitModel);
|
|
167
|
+
const selected = explicit ?? getConfiguredModel(type);
|
|
168
|
+
if (!selected || selected === "auto")
|
|
169
|
+
return getDefaultModelOrder(type);
|
|
170
|
+
const entry = resolveModelEntry(type, selected);
|
|
171
|
+
return uniqueStrings([entry.code, ...getDefaultModelOrder(type)]);
|
|
172
|
+
}
|
|
173
|
+
export function resolveModelEntry(type, value) {
|
|
174
|
+
const normalized = normalizeModelLookup(value);
|
|
175
|
+
const entry = entriesForType(type).find((item) => {
|
|
176
|
+
const aliases = item.aliases ?? [];
|
|
177
|
+
return [item.code, item.name, ...aliases].some((candidate) => normalizeModelLookup(candidate) === normalized);
|
|
178
|
+
});
|
|
179
|
+
if (!entry) {
|
|
180
|
+
throw new Error(`未找到${type === "image" ? "图像" : "视频"}模型: ${value}。请检查模型 code / 名称,或使用 auto 由平台返回顺序执行。`);
|
|
181
|
+
}
|
|
182
|
+
return entry;
|
|
183
|
+
}
|
|
184
|
+
export function publicModelByCode(type, code) {
|
|
185
|
+
const entry = entriesForType(type).find((item) => item.code === code);
|
|
186
|
+
return entry ? toPublicModelEntry(entry) : undefined;
|
|
187
|
+
}
|
|
188
|
+
export function toPublicModelEntry(entry) {
|
|
189
|
+
return {
|
|
190
|
+
name: entry.name,
|
|
191
|
+
code: entry.code,
|
|
192
|
+
description: entry.description,
|
|
193
|
+
cost_level: entry.cost_level,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function normalizeConfiguredModel(type, value) {
|
|
197
|
+
const normalized = normalizeOptionalModelValue(value);
|
|
198
|
+
if (!normalized || normalized === "auto")
|
|
199
|
+
return "auto";
|
|
200
|
+
return resolveModelEntry(type, normalized).code;
|
|
201
|
+
}
|
|
202
|
+
function normalizeOptionalModelValue(value) {
|
|
203
|
+
if (typeof value !== "string")
|
|
204
|
+
return undefined;
|
|
205
|
+
const trimmed = value.trim();
|
|
206
|
+
return trimmed ? trimmed : undefined;
|
|
207
|
+
}
|
|
208
|
+
function entriesForType(type) {
|
|
209
|
+
return type === "image" ? IMAGE_MODELS : VIDEO_MODELS;
|
|
210
|
+
}
|
|
211
|
+
function normalizeModelLookup(value) {
|
|
212
|
+
return value.trim().toLowerCase().replace(/\s+/g, "");
|
|
213
|
+
}
|
|
214
|
+
function uniqueStrings(values) {
|
|
215
|
+
return [...new Set(values.filter(Boolean))];
|
|
216
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Command, Option } from "commander";
|
|
2
|
+
import { CLI_VERSION } from "./utils/config.js";
|
|
3
|
+
import { registerAuthCommand } from "./commands/auth.js";
|
|
4
|
+
import { registerOrgCommand } from "./commands/org.js";
|
|
5
|
+
import { registerWorkflowsCommand } from "./commands/workflows.js";
|
|
6
|
+
import { registerToolsCommand } from "./commands/tools.js";
|
|
7
|
+
import { registerDamCommand } from "./commands/dam.js";
|
|
8
|
+
import { registerModelsCommand } from "./commands/models.js";
|
|
9
|
+
import { registerUpdateCommand } from "./commands/update.js";
|
|
10
|
+
import { registerSkillsCommand } from "./commands/skills.js";
|
|
11
|
+
import { registerUsageCommand } from "./commands/usage.js";
|
|
12
|
+
import { maybeNotifyUpdate } from "./update/notifier.js";
|
|
13
|
+
import { formatOutput } from "./middleware/output.js";
|
|
14
|
+
import { buildManifest, buildTopExamples, rowsForManifest, } from "./registry/agent-contracts.js";
|
|
15
|
+
import { resolveListOutputFormat } from "./utils/list-output-format.js";
|
|
16
|
+
import { setStaticHelp } from "./utils/static-help.js";
|
|
17
|
+
export async function createProgram() {
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program
|
|
20
|
+
.name("gd-cli")
|
|
21
|
+
.usage("<command> [options]")
|
|
22
|
+
.description("GD CLI — 让稿定成为 Agent 的创意生产引擎")
|
|
23
|
+
.version(CLI_VERSION)
|
|
24
|
+
.addOption(new Option("-f, --format <format>", "输出格式: human / table / json / text").choices(["json", "human", "table", "text"]))
|
|
25
|
+
.addOption(new Option("--json", "等同于 --format json,推荐 Agent 和脚本使用"))
|
|
26
|
+
.addOption(new Option("--no-input", "禁止交互,适合 CI / Agent"))
|
|
27
|
+
.addOption(new Option("--yes", "跳过确认"))
|
|
28
|
+
.addOption(new Option("--verbose", "输出详细日志").hideHelp().default(false));
|
|
29
|
+
setStaticHelp(program, TOP_LEVEL_HELP);
|
|
30
|
+
program
|
|
31
|
+
.command("manifest")
|
|
32
|
+
.description("输出 Agent 可解析的 gd-cli 能力清单")
|
|
33
|
+
.action((_opts, command) => {
|
|
34
|
+
const manifest = buildManifest("all");
|
|
35
|
+
const format = resolveListOutputFormat(command);
|
|
36
|
+
formatOutput(format === "json" ? manifest : rowsForManifest(manifest), format);
|
|
37
|
+
});
|
|
38
|
+
program
|
|
39
|
+
.command("examples")
|
|
40
|
+
.description("查看常用场景示例")
|
|
41
|
+
.action((_opts, command) => {
|
|
42
|
+
const examples = buildTopExamples();
|
|
43
|
+
const format = resolveExplicitExamplesFormat(command);
|
|
44
|
+
if (format === "json") {
|
|
45
|
+
formatOutput(examples, "json");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
printExamples(examples);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const agent = program
|
|
52
|
+
.command("agent", { hidden: true })
|
|
53
|
+
.description("Agent 调用 gd-cli 的机器可读入口说明")
|
|
54
|
+
.action(() => {
|
|
55
|
+
console.log(AGENT_HELP.trim());
|
|
56
|
+
});
|
|
57
|
+
agent.addHelpText("afterAll", `\n${AGENT_HELP}`);
|
|
58
|
+
registerAuthCommand(program);
|
|
59
|
+
registerOrgCommand(program);
|
|
60
|
+
registerWorkflowsCommand(program);
|
|
61
|
+
registerToolsCommand(program);
|
|
62
|
+
registerSkillsCommand(program);
|
|
63
|
+
registerModelsCommand(program);
|
|
64
|
+
registerDamCommand(program);
|
|
65
|
+
registerUpdateCommand(program);
|
|
66
|
+
registerUsageCommand(program);
|
|
67
|
+
program.hook("postAction", async (_thisCommand, actionCommand) => {
|
|
68
|
+
await maybeNotifyUpdate(actionCommand);
|
|
69
|
+
});
|
|
70
|
+
return program;
|
|
71
|
+
}
|
|
72
|
+
const TOP_LEVEL_HELP = `
|
|
73
|
+
Usage: gd-cli <command> [options]
|
|
74
|
+
|
|
75
|
+
GD CLI — 让稿定成为 Agent 的创意生产引擎
|
|
76
|
+
|
|
77
|
+
核心命令:
|
|
78
|
+
auth 登录、退出、查看登录状态
|
|
79
|
+
org 查看和切换当前组织
|
|
80
|
+
workflows 运行完整创意场景任务,例如商品上新、批量海报、内容矩阵
|
|
81
|
+
tools 调用单项 AI 创意能力,例如生图、抠图、高清化、标题生成
|
|
82
|
+
skills 安装和管理 gd-cli Agent Skill
|
|
83
|
+
dam 素材管理,上传、查询、删除素材
|
|
84
|
+
update 检查并升级 gd-cli
|
|
85
|
+
|
|
86
|
+
常用流程:
|
|
87
|
+
gd-cli auth login 登录稿定账号
|
|
88
|
+
gd-cli org list 查看可用组织
|
|
89
|
+
gd-cli org switch 切换当前组织
|
|
90
|
+
gd-cli workflows ls 查看完整创意场景
|
|
91
|
+
gd-cli tools ls 查看单项 AI 创意能力
|
|
92
|
+
gd-cli dam upload ./image.png 上传素材到 DAM
|
|
93
|
+
|
|
94
|
+
常用选项:
|
|
95
|
+
-V, --version output the version number
|
|
96
|
+
-f, --format <format> 输出格式: human / table / json / text
|
|
97
|
+
--json 等同于 --format json,推荐 Agent 和脚本使用
|
|
98
|
+
--no-input 禁止交互,适合 CI / Agent
|
|
99
|
+
--yes 跳过确认
|
|
100
|
+
-h, --help display help for command
|
|
101
|
+
|
|
102
|
+
更多:
|
|
103
|
+
gd-cli examples 查看常用场景示例
|
|
104
|
+
gd-cli manifest 可解析的能力清单
|
|
105
|
+
`;
|
|
106
|
+
const AGENT_HELP = `
|
|
107
|
+
Agent 推荐入口:
|
|
108
|
+
gd-cli manifest --format json 读取完整能力清单
|
|
109
|
+
gd-cli workflows manifest --format json 读取 Workflows 清单
|
|
110
|
+
gd-cli tools manifest --format json 读取 Tools 清单
|
|
111
|
+
gd-cli workflows schema <workflow-id> --format json 查看 Workflow 输入/输出结构
|
|
112
|
+
gd-cli tools schema <tool-id> --format json 查看 Tool 输入/输出结构
|
|
113
|
+
|
|
114
|
+
调用规则:
|
|
115
|
+
1. 优先用 --format json 或 --json。
|
|
116
|
+
2. 复杂输入用 --input <json-file> 或 stdin: cat input.json | gd-cli tools call <tool-id> - --json。
|
|
117
|
+
3. 完整业务场景优先选 workflows;单项能力选 tools;素材复用选 dam。
|
|
118
|
+
4. Agent 不切换模型、环境或组织;这些由 CLI 配置和用户显式命令管理。
|
|
119
|
+
`;
|
|
120
|
+
function resolveExplicitExamplesFormat(command) {
|
|
121
|
+
const root = command.parent;
|
|
122
|
+
const opts = (root?.opts() ?? {});
|
|
123
|
+
if (opts.json)
|
|
124
|
+
return "json";
|
|
125
|
+
const source = root?.getOptionValueSource("format");
|
|
126
|
+
return source && source !== "default" && source !== "implied"
|
|
127
|
+
? opts.format ?? "human"
|
|
128
|
+
: "human";
|
|
129
|
+
}
|
|
130
|
+
function printExamples(payload) {
|
|
131
|
+
const examples = Array.isArray(payload.examples) ? payload.examples : [];
|
|
132
|
+
console.log("常用场景示例\n");
|
|
133
|
+
examples.forEach((item, index) => {
|
|
134
|
+
const record = item;
|
|
135
|
+
console.log(`${index + 1}. ${String(record.title ?? "")}`);
|
|
136
|
+
const description = record.description;
|
|
137
|
+
if (typeof description === "string" && description.trim()) {
|
|
138
|
+
console.log(` ${description.trim()}`);
|
|
139
|
+
}
|
|
140
|
+
console.log("");
|
|
141
|
+
console.log(` ${String(record.command ?? "")}`);
|
|
142
|
+
const input = record.input_json;
|
|
143
|
+
if (input && typeof input === "object" && Object.keys(input).length > 0) {
|
|
144
|
+
console.log("");
|
|
145
|
+
console.log(" input_json:");
|
|
146
|
+
for (const [key, value] of Object.entries(input)) {
|
|
147
|
+
console.log(` ${key}: ${String(value)}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
console.log("");
|
|
151
|
+
});
|
|
152
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { OutputSpec, ParamSpec } from "./types.js";
|
|
2
|
+
import { type CapabilityPolicy, type CapabilitySource, type CapabilityStatus } from "../utils/capability-metadata.js";
|
|
3
|
+
type CapabilityKind = "workflow" | "tool";
|
|
4
|
+
type ManifestScope = "all" | "workflows" | "tools";
|
|
5
|
+
export interface JsonSchemaObject {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: Record<string, Record<string, unknown>>;
|
|
8
|
+
required: string[];
|
|
9
|
+
additionalProperties?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface CapabilityManifestCommand {
|
|
12
|
+
id: string;
|
|
13
|
+
type: CapabilityKind | "dam" | "org";
|
|
14
|
+
category: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
canonical_command: string;
|
|
18
|
+
input_schema_command?: string;
|
|
19
|
+
examples_command?: string;
|
|
20
|
+
output: "json";
|
|
21
|
+
safe_for_agent: boolean;
|
|
22
|
+
source: CapabilitySource;
|
|
23
|
+
status: CapabilityStatus;
|
|
24
|
+
policy: CapabilityPolicy;
|
|
25
|
+
dependency_tools?: string[];
|
|
26
|
+
affected_workflows?: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface CapabilityManifest {
|
|
29
|
+
name: "gd-cli";
|
|
30
|
+
version: string;
|
|
31
|
+
description: string;
|
|
32
|
+
commands: CapabilityManifestCommand[];
|
|
33
|
+
}
|
|
34
|
+
export declare function buildInputJsonSchema(params: ParamSpec[], extraProperties?: Record<string, Record<string, unknown>>): JsonSchemaObject;
|
|
35
|
+
export declare function buildOutputJsonSchema(output: OutputSpec): JsonSchemaObject;
|
|
36
|
+
export declare function buildToolSchema(toolId: string): Record<string, unknown>;
|
|
37
|
+
export declare function buildWorkflowSchema(appId: string): Record<string, unknown>;
|
|
38
|
+
export declare function buildToolExamples(toolId: string): Record<string, unknown>;
|
|
39
|
+
export declare function buildWorkflowExamples(appId: string): Record<string, unknown>;
|
|
40
|
+
export declare function buildManifest(scope?: ManifestScope): CapabilityManifest;
|
|
41
|
+
export declare function rowsForManifest(manifest: CapabilityManifest): Record<string, string>[];
|
|
42
|
+
export declare function buildTopExamples(): Record<string, unknown>;
|
|
43
|
+
export {};
|