@gaoding/cli 2.1.8 → 3.0.0

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 (61) hide show
  1. package/README.md +6 -3
  2. package/contracts/operations/tool.call/canvas-input.schema.json +0 -3
  3. package/contracts/presentations/agent.send.schema.json +303 -0
  4. package/contracts/presentations/model.get.schema.json +246 -0
  5. package/contracts/presentations/model.list.schema.json +144 -0
  6. package/contracts/presentations/task.get.schema.json +146 -0
  7. package/contracts/presentations/tool.call.schema.json +200 -0
  8. package/dist/bin/gd-cli.js +9 -3
  9. package/dist/bin/insmind-cli.js +6 -1
  10. package/dist/src/bootstrap/create-cli.js +7 -4
  11. package/dist/src/bootstrap/create-runtime.js +7 -32
  12. package/dist/src/cli/action-binding.js +2 -2
  13. package/dist/src/cli/agent-commands.js +5 -4
  14. package/dist/src/cli/auth-commands.js +1 -1
  15. package/dist/src/cli/dam-commands.js +18 -10
  16. package/dist/src/cli/errors.js +1 -35
  17. package/dist/src/cli/host-input.js +0 -11
  18. package/dist/src/cli/model-commands.js +6 -5
  19. package/dist/src/cli/skill-output.js +13 -0
  20. package/dist/src/cli/tool-commands.js +9 -5
  21. package/dist/src/features/skill/catalog.js +152 -0
  22. package/dist/src/features/skill/manual.js +71 -0
  23. package/dist/src/features/tool/archived-ocr-result.js +74 -0
  24. package/dist/src/features/tool/canvas-copy.js +2 -3
  25. package/dist/src/features/tool/canvas-models.js +2 -4
  26. package/dist/src/features/tool/canvas-recovery.js +3 -2
  27. package/dist/src/features/tool/canvas-results.js +1 -55
  28. package/dist/src/features/tool/canvas-tool-adapter.js +7 -10
  29. package/dist/src/features/tool/resource-authorizer.js +1 -1
  30. package/dist/src/features/tool/scene-catalog-adapter.js +20 -22
  31. package/dist/src/features/tool/tool-definitions.js +0 -1
  32. package/dist/src/product/config.js +0 -7
  33. package/dist/src/telemetry/command-routes.json +1 -1
  34. package/package.json +4 -4
  35. package/skills/gd-cli/SKILL.md +10 -29
  36. package/contracts/operations/editor.apply/input.schema.json +0 -134
  37. package/contracts/operations/editor.apply/output.schema.json +0 -15
  38. package/contracts/operations/editor.connect/input.schema.json +0 -15
  39. package/contracts/operations/editor.connect/output.schema.json +0 -17
  40. package/contracts/operations/editor.disconnect/input.schema.json +0 -8
  41. package/contracts/operations/editor.disconnect/output.schema.json +0 -14
  42. package/contracts/operations/editor.save/input.schema.json +0 -8
  43. package/contracts/operations/editor.save/output.schema.json +0 -23
  44. package/contracts/operations/editor.screenshot/input.schema.json +0 -8
  45. package/contracts/operations/editor.screenshot/output.schema.json +0 -16
  46. package/contracts/operations/editor.snapshot/input.schema.json +0 -8
  47. package/contracts/operations/editor.snapshot/output.schema.json +0 -113
  48. package/contracts/operations/tool.call/models/image-ocr.schema.json +0 -22
  49. package/contracts/operations/tool.call/ocr-payload.schema.json +0 -65
  50. package/dist/src/cli/editor-commands.js +0 -136
  51. package/skills/gd-cli/references/agent.md +0 -39
  52. package/skills/gd-cli/references/auth-org.md +0 -11
  53. package/skills/gd-cli/references/creation.md +0 -61
  54. package/skills/gd-cli/references/dam.md +0 -53
  55. package/skills/gd-cli/references/editor.md +0 -67
  56. package/skills/gd-cli/references/errors.md +0 -46
  57. package/skills/gd-cli/references/generation-constraints.md +0 -40
  58. package/skills/gd-cli/references/matting.md +0 -27
  59. package/skills/gd-cli/references/media-tools.md +0 -46
  60. package/skills/gd-cli/references/tool.md +0 -24
  61. package/skills/gd-cli/references/update.md +0 -22
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorApplyResult",
4
- "description": "编辑器操作应用结果。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["appliedCount"],
8
- "properties": {
9
- "appliedCount": {
10
- "type": "integer",
11
- "minimum": 0,
12
- "description": "已成功应用的操作数量。"
13
- }
14
- }
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorConnectInput",
4
- "description": "编辑器连接参数。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "properties": {
8
- "target": {
9
- "type": "string",
10
- "minLength": 1,
11
- "pattern": ".*\\S.*",
12
- "description": "作品 ID 或 AI+ Editor URL;省略时创建新作品。"
13
- }
14
- }
15
- }
@@ -1,17 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorConnectResult",
4
- "description": "已连接的编辑器页面。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["target"],
8
- "properties": {
9
- "target": {
10
- "type": "string",
11
- "format": "uri",
12
- "minLength": 1,
13
- "pattern": ".*\\S.*",
14
- "description": "已连接的 AI+ Editor URL。"
15
- }
16
- }
17
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorDisconnectInput",
4
- "description": "断开当前编辑器连接。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "properties": {}
8
- }
@@ -1,14 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorDisconnectResult",
4
- "description": "编辑器断开结果。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["disconnected"],
8
- "properties": {
9
- "disconnected": {
10
- "type": "boolean",
11
- "description": "是否断开了一个当前连接。"
12
- }
13
- }
14
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorSaveInput",
4
- "description": "保存当前编辑器作品。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "properties": {}
8
- }
@@ -1,23 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorSaveResult",
4
- "description": "已保存的编辑器作品。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["workId", "url"],
8
- "properties": {
9
- "workId": {
10
- "type": "string",
11
- "minLength": 1,
12
- "pattern": ".*\\S.*",
13
- "description": "作品 ID。"
14
- },
15
- "url": {
16
- "type": "string",
17
- "format": "uri",
18
- "minLength": 1,
19
- "pattern": ".*\\S.*",
20
- "description": "作品的 AI+ Editor URL。"
21
- }
22
- }
23
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorScreenshotInput",
4
- "description": "导出当前编辑器截图。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "properties": {}
8
- }
@@ -1,16 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorScreenshotResult",
4
- "description": "已导出的编辑器截图。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["path"],
8
- "properties": {
9
- "path": {
10
- "type": "string",
11
- "minLength": 1,
12
- "pattern": ".*\\S.*",
13
- "description": "截图在本机的绝对路径。"
14
- }
15
- }
16
- }
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorSnapshotInput",
4
- "description": "读取当前编辑器快照。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "properties": {}
8
- }
@@ -1,113 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "EditorSnapshotResult",
4
- "description": "当前编辑器中的受支持元素与选区。",
5
- "type": "object",
6
- "additionalProperties": false,
7
- "required": ["elements", "selectedIds"],
8
- "properties": {
9
- "elements": {
10
- "type": "array",
11
- "description": "当前编辑器中的受支持元素。",
12
- "items": {
13
- "oneOf": [
14
- { "$ref": "#/$defs/EditorShape" },
15
- { "$ref": "#/$defs/EditorConnector" }
16
- ]
17
- }
18
- },
19
- "selectedIds": {
20
- "type": "array",
21
- "description": "当前选中元素的 ID。",
22
- "items": {
23
- "type": "string",
24
- "minLength": 1,
25
- "pattern": ".*\\S.*"
26
- }
27
- }
28
- },
29
- "$defs": {
30
- "EditorShape": {
31
- "title": "EditorShape",
32
- "type": "object",
33
- "additionalProperties": false,
34
- "required": ["_type", "id", "shapeType", "x", "y", "w", "h", "fill", "stroke"],
35
- "properties": {
36
- "_type": {
37
- "const": "shape",
38
- "description": "元素类型。"
39
- },
40
- "id": {
41
- "type": "string",
42
- "minLength": 1,
43
- "pattern": ".*\\S.*",
44
- "description": "元素 ID。"
45
- },
46
- "shapeType": {
47
- "type": "string",
48
- "enum": ["rectangle", "rounded-rectangle", "triangle-up", "ellipse", "diamond"],
49
- "description": "图形类型。"
50
- },
51
- "x": { "type": "number", "description": "左上角横坐标。" },
52
- "y": { "type": "number", "description": "左上角纵坐标。" },
53
- "w": { "type": "number", "description": "宽度。" },
54
- "h": { "type": "number", "description": "高度。" },
55
- "text": { "type": "string", "description": "图形中的文本。" },
56
- "fill": {
57
- "type": "string",
58
- "minLength": 1,
59
- "pattern": ".*\\S.*",
60
- "description": "填充颜色。"
61
- },
62
- "stroke": {
63
- "description": "描边颜色;null 表示无描边。",
64
- "anyOf": [
65
- { "type": "string", "minLength": 1, "pattern": ".*\\S.*" },
66
- { "type": "null" }
67
- ]
68
- }
69
- }
70
- },
71
- "EditorConnector": {
72
- "title": "EditorConnector",
73
- "type": "object",
74
- "additionalProperties": false,
75
- "required": ["_type", "id", "fromId", "toId", "lineType", "color"],
76
- "properties": {
77
- "_type": {
78
- "const": "connector",
79
- "description": "元素类型。"
80
- },
81
- "id": {
82
- "type": "string",
83
- "minLength": 1,
84
- "pattern": ".*\\S.*",
85
- "description": "连线 ID。"
86
- },
87
- "fromId": {
88
- "type": "string",
89
- "minLength": 1,
90
- "pattern": ".*\\S.*",
91
- "description": "起点元素 ID。"
92
- },
93
- "toId": {
94
- "type": "string",
95
- "minLength": 1,
96
- "pattern": ".*\\S.*",
97
- "description": "终点元素 ID。"
98
- },
99
- "lineType": {
100
- "type": "string",
101
- "enum": ["straight", "elbowed"],
102
- "description": "连线类型。"
103
- },
104
- "color": {
105
- "type": "string",
106
- "minLength": 1,
107
- "pattern": ".*\\S.*",
108
- "description": "连线颜色。"
109
- }
110
- }
111
- }
112
- }
113
- }
@@ -1,22 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "ImageOcrInput",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "required": [
7
- "model",
8
- "image"
9
- ],
10
- "properties": {
11
- "model": {
12
- "type": "string",
13
- "const": "image-ocr",
14
- "description": "本次调用的模型机器标识;使用当前 model list/get 返回值。"
15
- },
16
- "image": {
17
- "type": "string",
18
- "format": "uri",
19
- "description": "本次要处理的原图 URI;HTTP(S) URL 或标准 file URI。参考图另放 referenceImages(若该模型支持),不与原图互换。"
20
- }
21
- }
22
- }
@@ -1,65 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "OcrPayload",
4
- "type": "object",
5
- "additionalProperties": true,
6
- "required": [
7
- "image",
8
- "blocks"
9
- ],
10
- "properties": {
11
- "image": {
12
- "type": "object",
13
- "additionalProperties": true,
14
- "required": [
15
- "uri",
16
- "width",
17
- "height"
18
- ],
19
- "properties": {
20
- "uri": {
21
- "type": "string",
22
- "format": "uri",
23
- "description": "单个 HTTP(S) 或 CLI file:// 素材 URI。"
24
- },
25
- "width": {
26
- "type": "integer",
27
- "minimum": 1
28
- },
29
- "height": {
30
- "type": "integer",
31
- "minimum": 1
32
- }
33
- }
34
- },
35
- "blocks": {
36
- "type": "array",
37
- "items": {
38
- "type": "object",
39
- "additionalProperties": true,
40
- "required": [
41
- "bbox",
42
- "category"
43
- ],
44
- "properties": {
45
- "bbox": {
46
- "type": "array",
47
- "minItems": 4,
48
- "maxItems": 4,
49
- "items": {
50
- "type": "number"
51
- }
52
- },
53
- "category": {
54
- "type": "string",
55
- "minLength": 1,
56
- "pattern": ".*\\S.*"
57
- },
58
- "text": {
59
- "type": "string"
60
- }
61
- }
62
- }
63
- }
64
- }
65
- }
@@ -1,136 +0,0 @@
1
- import { hostSchema, readHostInput, editorActions } from "./host-input.js";
2
- import { jsonOutput, bindAction, bindPreparedAction } from "./action-binding.js";
3
- import { contractSchema } from "../contracts/schema.js";
4
- import { CliUsageError } from "./errors.js";
5
- import { productText as text } from "../product/text.js";
6
- function editorApplyInputSchema() {
7
- const { $defs, ...actionArray } = contractSchema("editor.apply", "input");
8
- return {
9
- type: "object", additionalProperties: false, required: ["actions"], properties: { actions: actionArray },
10
- $defs: Object.fromEntries(Object.entries($defs)
11
- .map(([name, definition]) => [name, { ...definition, additionalProperties: true }]))
12
- };
13
- }
14
- export function registerEditorCommands(program, runtime) {
15
- const editor = program.command("editor")
16
- .description(text(runtime.product, "连接并操作 AI+ Editor", "Connect to and operate insMind Editor"))
17
- .helpCommand(false);
18
- editor.addHelpText("after", [
19
- "",
20
- text(runtime.product, "对象是已连接作品中的元素。用户提供附件图片/媒体链接并要求改字、分层、矢量化或其他图片处理时,先从 tool list 发现能力;无需为了这些操作新建 Board。", "This group operates elements in a connected work. For attached images or media links needing text replacement, decomposition, vectorization or other processing, discover tool list first; these operations do not require a new Board."),
21
- text(runtime.product, "操作一个当前 Session、当前 Page 的直属 Shape 和绑定 Connector;单操作者串行执行。", "Operate one current Session and its Page's direct Shapes and bound Connectors, serially with one operator."),
22
- text(runtime.product, "元素类型与字段以 editor apply --schema 为准;Schema 查询无需登录或连接 Editor。", "Discover element types and fields with editor apply --schema; no login or Editor connection is required."),
23
- text(runtime.product, "当前不支持嵌套元素、自由/半绑定 Connector、页面或选择修改;UNSUPPORTED_PAGE_CONTENT 时保留原作品并换用空白或专用 Page。", "Nested elements, free/half-bound Connectors, page and selection changes are unsupported. On UNSUPPORTED_PAGE_CONTENT, preserve the work and use a blank or dedicated Page."),
24
- text(runtime.product, "流程:connect → snapshot → apply → snapshot/screenshot 复查 → 按用户授权 save → disconnect。apply 不代替 save。只预览/暂不保存时停在预览;用户要求断开就执行 disconnect,断开不隐含保存。", "Workflow: connect → snapshot → apply → review snapshot/screenshot → save as authorized → disconnect. Apply does not replace Save. For preview-only requests stop at preview; on a request to disconnect, execute disconnect without implicitly saving."),
25
- text(runtime.product, "EDITOR_BUSY 时等待原命令结束;写入超时、取消或断连时,先重新连接同一作品并检查真实状态,不直接重试写入。", "On EDITOR_BUSY, wait for the original command. After a write times out, is cancelled or disconnects, reconnect to the same work and inspect its state before deciding what to do."),
26
- ""
27
- ].join("\n"));
28
- const connect = leaf(editor.command("connect"))
29
- .description(text(runtime.product, "打开并连接一个 AI+ Editor 作品", "Open and connect to an Editor work"))
30
- .argument("[target]", text(runtime.product, "已有作品的 ID 或完整 URL;留空会新建线上 Board", "existing work ID or full URL; omitting it creates a new production Board"));
31
- connect.addHelpText("after", [
32
- "",
33
- text(runtime.product, "继续已有作品时,传数字作品 ID 或完整 HTTP(S) URL。还没有目标就先向用户索取作品链接或 ID。用户要求新建时才省略 target。", "To continue an existing work, pass its numeric ID or supported insMind production Editor URL. If the target is missing, ask the user for the link or ID. Omit target only when the user requests a new Board."),
34
- text(runtime.product, "会打开浏览器并替换旧 Session;浏览器登录、加载、Board 类型、编辑/保存权限与页面内容检查通过后才成功。CLI 登录不能替代浏览器登录。", "Opens the browser and replaces the old Session. Browser login, loading, Board type, edit/save permission and page-content checks must pass. CLI credentials do not replace browser login."),
35
- text(runtime.product, "输出 JSON {target},不含连接凭证。连接失败时停止写入,让用户在页面处理登录或权限,再重新连接。", "Returns JSON {target} without connection credentials. On failure, stop writing and let the user resolve browser login or permissions before reconnecting."),
36
- text(runtime.product, "页面切换作品会断开 Session;EDITOR_NOT_READY、EDITOR_SESSION_NOT_FOUND 或 EDITOR_NOT_CONNECTED 时确认目标后重连,不轮询旧 Session。", "Switching works disconnects the Session. On EDITOR_NOT_READY, EDITOR_SESSION_NOT_FOUND or EDITOR_NOT_CONNECTED, verify the target and reconnect instead of polling the old Session."),
37
- ""
38
- ].join("\n"));
39
- jsonOutput(connect);
40
- bindPreparedAction(connect, "none", async (signal) => {
41
- signal.throwIfAborted();
42
- const target = connect.processedArgs[0];
43
- const input = typeof target === "string" ? { target } : {};
44
- runtime.validators.editorConnectInput(input);
45
- return { handled: false, input };
46
- }, async (_context, input, signal) => {
47
- const result = await runtime.telemetry.stage("editor.connect", () => runtime.editor.connect({ input, signal }));
48
- writeJson(runtime, result);
49
- });
50
- const disconnect = leaf(editor.command("disconnect"))
51
- .description(text(runtime.product, "断开当前 Editor 连接", "Disconnect the current Editor"));
52
- disconnect.addHelpText("after", `\n${text(runtime.product, "输出 JSON {disconnected},解除当前 CLI 会话连接,不保存作品、不关闭浏览器页面。需要保留修改且已获保存授权时先 save;用户只要求断开或明确不保存时直接断开,并说明未保存状态。", "Returns JSON {disconnected}, ending the CLI session without saving the work or closing its browser page. Save first only when persistence is intended and authorized; if the user requests only disconnection or no save, disconnect and state what remains unsaved.")}\n`);
53
- jsonOutput(disconnect);
54
- bindAction(disconnect, "none", async (_context, signal) => {
55
- writeJson(runtime, await runtime.telemetry.stage("editor.disconnect", () => runtime.editor.disconnect({ signal })));
56
- });
57
- const snapshot = leaf(editor.command("snapshot"))
58
- .description(text(runtime.product, "读取当前作品快照", "Read the current work snapshot"));
59
- snapshot.addHelpText("after", [
60
- "",
61
- text(runtime.product, "输出 JSON {elements, selectedIds};selectedIds 只读。元素字段和类型见 editor apply --schema。", "Returns JSON {elements, selectedIds}; selectedIds is read-only. Discover element fields and types with editor apply --schema."),
62
- text(runtime.product, "修改时以最新 Snapshot 中的完整元素为基础;每次 apply 后重新读取。UNSUPPORTED_PAGE_CONTENT 时停止并保留原作品。", "Base changes on complete elements from the latest Snapshot and read again after every Apply. On UNSUPPORTED_PAGE_CONTENT, stop and preserve the work."),
63
- ""
64
- ].join("\n"));
65
- jsonOutput(snapshot);
66
- bindAction(snapshot, "none", async (_context, signal) => {
67
- writeJson(runtime, await runtime.telemetry.stage("editor.snapshot", () => runtime.editor.snapshot({ signal })));
68
- });
69
- const apply = leaf(editor.command("apply"))
70
- .description(text(runtime.product, "按顺序应用元素操作", "Apply element operations in order"))
71
- .option("--schema", text(runtime.product, "输出输入 Schema,不执行操作", "output the input Schema without executing an operation"))
72
- .option("--input <file|->", text(runtime.product, "从文件或标准输入读取 JSON", "read JSON from a file or stdin"));
73
- apply.addHelpText("after", [
74
- "",
75
- text(runtime.product, "--schema 与 --input 必须且只能选择一个。Schema 为本地契约,不连接 Editor;执行成功输出 JSON {appliedCount}。", "Choose exactly one of --schema and --input. Schema reads the local contract without connecting to Editor; successful execution returns JSON {appliedCount}."),
76
- text(runtime.product, "先保存完整 JSON,再用 --input request.json 执行;--input - 必须在同一条 shell 命令中经管道或重定向提供完整 JSON,不交互填参。", "Save complete JSON before using --input request.json. With --input -, pipe or redirect complete JSON in the same shell command; input is not an interactive form."),
77
- text(runtime.product, "输入对象包含 host_application 和按序执行的 actions 数组;类型、必填字段与可选值见 --schema。使用简短语义 ID;create ID 必须唯一,Connector 可引用本批次更早创建的 Shape。", "Input is an object with host_application and an ordered actions array; discover types, required fields and choices with --schema. Use short semantic IDs. Create IDs must be unique; a Connector may reference a Shape created earlier in the batch."),
78
- text(runtime.product, "update 提交完整元素而非 patch,不改变 id 或 _type。delete 要求 ID 存在;删除 Shape 同时删除绑定的 Connector。", "Update requires the full element, not a patch, without changing id or _type. Delete requires an existing ID; deleting a Shape also deletes its bound Connectors."),
79
- text(runtime.product, "Shape 的 x/y 为 Page 左上角坐标,w/h 大于 0;数值必须有限。颜色用 #RRGGBB 或 #RRGGBBAA,仅 stroke 可为 null。Connector 用 fromId/toId 表达有方向的 Shape 关系。", "Shape x/y locate its top-left corner in Page coordinates; w/h must exceed zero and numbers must be finite. Colors use #RRGGBB or #RRGGBBAA; only stroke accepts null. Connector fromId/toId express a directed Shape relationship."),
80
- text(runtime.product, "整批先预检,再在可回滚事务中应用;INVALID_ACTIONS 时修正输入,APPLY_FAILED 时读 Snapshot 确认回滚。EDITOR_ROLLBACK_FAILED 时停止 apply/save,只读检查并报告。", "The batch is checked before one rollback-capable transaction. Correct INVALID_ACTIONS; on APPLY_FAILED read a Snapshot to confirm rollback. On EDITOR_ROLLBACK_FAILED, stop apply/save, inspect read-only and report."),
81
- text(runtime.product, "成功不表示已保存或视觉正确;读取新 Snapshot,涉及布局/文字/连线时查看截图。只预览时交付截图且不 save;需要持久化并已获授权时再显式 save。超时、取消或断连后先检查真实状态,不重复提交。", "Success proves neither persistence nor correct rendering. Read a new Snapshot and view a screenshot for layout/text/connectors. Deliver preview-only requests without save; explicitly save when persistence is intended and authorized. Inspect real state after timeout, cancellation or disconnection instead of resubmitting."),
82
- ""
83
- ].join("\n"));
84
- jsonOutput(apply);
85
- bindPreparedAction(apply, "none", async (signal) => {
86
- signal.throwIfAborted();
87
- const options = apply.opts();
88
- if (Number(options.schema === true) + Number(options.input !== undefined) !== 1)
89
- throw new CliUsageError();
90
- if (options.schema === true) {
91
- await runtime.telemetry.stage("output", () => { writeJson(runtime, hostSchema(runtime, editorApplyInputSchema())); });
92
- return { handled: true };
93
- }
94
- const input = editorActions(readHostInput(runtime, await runtime.jsonInput.read(options.input, signal)));
95
- return { handled: false, input };
96
- }, async (_context, input, signal) => {
97
- writeJson(runtime, await runtime.telemetry.stage("editor.apply", () => runtime.editor.apply({ input, signal })));
98
- }, {
99
- operation: "editor.apply",
100
- mode: () => apply.opts().schema === true ? "schema" : "execute"
101
- });
102
- const screenshot = leaf(editor.command("screenshot"))
103
- .description(text(runtime.product, "导出当前作品 PNG 截图", "Export a PNG screenshot of the current work"))
104
- .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
105
- screenshot.addHelpText("after", `\n${text(runtime.product, "将当前作品截图写入本机 PNG;--json 输出 {path},path 为绝对路径。打开实际图片检查文字、布局与连线,不以文件存在代替视觉验收。", "Writes a PNG screenshot locally; --json returns {path} with an absolute path. View the actual image to check text, layout and connectors; file existence is not visual verification.")}\n`);
106
- bindAction(screenshot, "none", async (_context, signal) => {
107
- const result = await runtime.telemetry.stage("editor.screenshot", () => runtime.editor.screenshot({ signal }));
108
- runtime.presenter.result(result, {
109
- json: screenshot.opts().json === true,
110
- view: value => text(runtime.product, `截图已保存至 ${value.path}`, `Screenshot saved to ${value.path}`)
111
- });
112
- });
113
- const save = leaf(editor.command("save"))
114
- .description(text(runtime.product, "保存当前 AI+ Editor 作品", "Save the current Editor work"))
115
- .option("--json", text(runtime.product, "输出 JSON", "output JSON"));
116
- save.addHelpText("after", [
117
- "",
118
- text(runtime.product, "等待真实持久化完成;--json 输出 {workId, url}。新 Board 首次保存创建作品 ID;原样交付公开 url,保留环境参数。", "Waits for real persistence; --json returns {workId, url}. A new Board gets its work ID on first save. Deliver the public url unchanged, retaining environment parameters."),
119
- text(runtime.product, "Save 最长等待 5 分 30 秒,其他 Editor RPC 默认 1 分钟;继续等待原命令,保持串行。成功前不得报告已保存。", "Save waits up to 5 minutes 30 seconds; other Editor RPCs default to one minute. Keep waiting on the original command and run serially. Do not report persistence before success."),
120
- text(runtime.product, "SAVE_FAILED 时保留 Session 并处理明确原因;超时、取消或断连不表示未保存,先重连同一作品检查真实状态。EDITOR_ROLLBACK_FAILED 时不得继续保存。", "On SAVE_FAILED retain the Session and resolve the stated cause. Timeout, cancellation or disconnection does not prove failure to save; reconnect to the same work and inspect first. Do not save after EDITOR_ROLLBACK_FAILED."),
121
- ""
122
- ].join("\n"));
123
- bindAction(save, "none", async (_context, signal) => {
124
- const result = await runtime.telemetry.stage("editor.save", () => runtime.editor.save({ signal }));
125
- runtime.presenter.result(result, {
126
- json: save.opts().json === true,
127
- view: value => text(runtime.product, `作品已保存:${value.url}`, `Work saved: ${value.url}`)
128
- });
129
- });
130
- }
131
- function leaf(command) {
132
- return command.allowExcessArguments(false);
133
- }
134
- function writeJson(runtime, value) {
135
- runtime.io.writeOut(`${JSON.stringify(value)}\n`);
136
- }
@@ -1,39 +0,0 @@
1
- # Agent 创作
2
-
3
- 现在要结果时默认同步,保留并等待宿主返回的原进程句柄。用户明确稍后取回时用 `--async`,受理后当轮交接原 taskId 和状态。回来取件或同步输出丢失时,按[状态处理](errors.md)查原任务。
4
-
5
- 先读取输入规范。需要指定 Model 时,也先读取实时 Model detail:
6
-
7
- ```bash
8
- gd-cli agent send --schema
9
- gd-cli model list --tool <tool>
10
- gd-cli model get <model>
11
- gd-cli agent send --input request.json
12
- ```
13
-
14
- 继续已有创作时,从上一条结果读取 `message.contextId`,原样填入下一次请求;同一创作的后续规划、生成和修改沿用该 Context。首次创作省略此字段。续聊示例:
15
-
16
- ```json
17
- {
18
- "message": {
19
- "contextId": "<上一条结果的 message.contextId>",
20
- "parts": [{ "text": "<用户的后续要求>" }]
21
- }
22
- }
23
- ```
24
-
25
- completed 表示本轮回复完整,先读 `result.message.parts` 再决定下一步:资源按实际内容交付;策划或普通确认文本如实转述,需要用户决定时询问;结构化 `data.questions` 则把问题交给用户。它们都不能被概括为“没有提交”,也不都表示图片/视频已生成。
26
-
27
- 交付本轮回复或资源时,一并报告 `usage.cost.amount` 的实际稿豆消耗。同步从原输出读,异步从 completed 任务的 `result` 读。返回 0 就报 0,缺失则说未取得。汇总只加不同 taskId 已取得的费用,同一任务重复取回只计一次。
28
-
29
- 收到结构化问题的用户回答后,沿用该结果的 `message.contextId`,把 `message.messageId` 放入 `data.questionMessageId`,`answers` 保留 question 原文并填写用户 values。这个 data Part 是本轮 parts 唯一一项,具体结构见 `agent send --schema`。普通文本补充或确认使用 text Part。每轮回复先判断是否需要用户信息,再继续;不替用户编造确认。
30
-
31
- 将用户要求和已确认信息放在 Text Part,区分图片可见特征与材质、功能等推断。未核实信息标为待确认,必要时向用户澄清;上一轮模型描述按其事实来源判断,不自动视为用户确认。交付文案保持相同的事实边界,风格、客群和场景设想作为建议表达。
32
-
33
- 需要指定 Model、生成参数或首尾帧时,在组装请求前读取 [生成约束与媒体角色](generation-constraints.md)。
34
-
35
- 本地素材按 Skill 根页构造标准 URI。也可用 `--input -` 从 stdin 传完整 JSON。
36
-
37
- 交付多个资源时,将每个 URL Part 的 `url`、`filename`、本地保存路径和展示名称作为一条记录一起处理;下载、重命名或调整顺序时保持对应,不按请求中的顺序重新配对。交付前核对每个最终链接的文件内容与名称一致;名称不足以辨认时查看资源内容。
38
-
39
- 每轮后续创作都会生成新的 taskId;续聊沿用 result.message.contextId。Agent 异步由本机临时后台进程继续执行,完成后退出;请在同一台机器查询。后台终止或电脑关机可能导致 unknown,按已有结果和快照说明情况,不自动重新生成。
@@ -1,11 +0,0 @@
1
- # 登录与组织
2
-
3
- 1. 用 `gd-cli auth status` 检查登录状态;需要机器读取时使用 `--json`。
4
- 2. 千问办公桌面入口使用 `gd-cli auth init` 自动打开浏览器;打开失败按错误说明处理,不使用手动链接模式。普通 CLI 未登录时执行 `gd-cli auth login`,按终端提示在浏览器完成授权;无法自动打开浏览器时使用 `--no-browser`。
5
- 3. 用 `gd-cli org list` 查看当前账号可用的组织,用 `gd-cli org current` 查看当前选择。
6
- 4. 让用户从真实列表中选择,再执行 `gd-cli org switch --org <org-id>`;不要猜组织 ID。
7
- 5. 用户要求退出或登录状态失效时执行 `gd-cli auth logout`;状态失效后重新登录。
8
-
9
- 在千问办公桌面连接器中,使用平台入口 `gd-cli auth show --status` 检查 `status`;`unauthorized` 时执行 `gd-cli auth init`,请用户在自动打开的浏览器中完成授权,等待命令结束并检查为 `authorized` 后执行业务。账号展示用 `gd-cli identity whoami`。连接器沿用 CLI 的共享本地身份,凭证到期重新登录;显式 logout 会影响同一系统用户的其他入口,禁用或卸载套件不会自动退出。
10
-
11
- 不要向用户索要或回显 Bearer Token、Cookie、AK、SK 或签名,也不要读取本地凭证文件。组织不可用时先切换组织;仍无法恢复时退出后重新登录。
@@ -1,61 +0,0 @@
1
- # 创作
2
-
3
- ## 需求与素材
4
-
5
- 忠实传递用户需求、已提供素材和明确约束。缺少完成任务所必需的信息或素材时,由宿主向用户澄清,或将原始需求交给业务 Agent 判断并追问;不要擅自添加生成替代素材、忽略约束或改变任务目标的指令。用户明确允许自由创作、使用示意素材或自行补全的,按其授权执行。
6
-
7
- 以缺失内容是否影响任务成立、对象一致性或明确要求的满足为判断依据;可选的风格偏好不必一律追问。
8
-
9
- 例如,用户说“为这件商品制作宣传图”却没有提供可识别该商品的素材:
10
-
11
- - 正例:请求补充商品图;或将这句原始需求交给业务 Agent,由其判断需要哪些素材并追问。
12
- - 反例:自行加上“没有原图,先生成一个示意商品”。即使标注“概念展示”,也改变了用户指定的对象;应先取得用户选择。
13
- - 自由创作的区别:“设计一件虚构商品并制作宣传图”已允许创造对象,可以直接创作;仅未指定配色或版式时,可自行设计这些风格细节。
14
-
15
- 成品交付后用户要求修改,把本轮指定成品作为新任务的输入;先交付已有结果,后续创作以用户要求为准。持续策划或多轮创作对话使用 Agent。
16
-
17
- ## Creation Route
18
-
19
- 先判断 Creation Route,再选择或校验 Model。Model 和参数不决定 Agent 或 Tool 路由;两条路由都支持指定 Model 及其参数,`model list` 和 `model get` 是共享的实时发现能力。
20
-
21
- - Agent:用户要的是业务交付物,或过程需要澄清、规划、多步骤、多产物或继续已有创作。下列十类业务意图通常优先走 Agent;它们只帮助选择 Creation Route,具体 Business Skill 由服务端 Agent 选择。
22
- - Tool:任务是一个无需业务编排的原子单次调用,具体能力由 `tool list` 发现;或用户明确要求直接调用可用 Tool。
23
-
24
- 选择 Tool 后,新图/新视频创作、依参考素材整体重创分别以 `image.generate` / `video.generate` 为发现方向;现有媒体的具体处理按 [图片与视频工具选择](media-tools.md) 判断。参考图本身不决定使用 `image.edit`,工具内部有多个处理阶段也不等于用户需要业务 Agent 编排。
25
-
26
- 业务意图参考(语义匹配,不是只能逐字命中):
27
-
28
- | 业务意图 | 常见说法 | 素材与边界 |
29
- | --- | --- | --- |
30
- | 电商主图套图 | 主图、主图套图、一套主图、主图设计、商品图 | 通常带商品图;区分场景图、海报、详情页、改图、包装设计和多角度图 |
31
- | 电商详情页 | 详情页、电商详情、宝贝详情、产品详情、长图、卖点页、参数页、功能介绍、对比说明、购买理由 | 通常带商品图;出现“详情”类词时优先按电商详情页判断,不按主图套图处理 |
32
- | 商品精修 | 精修、修一下、翻新、白底图、纯白背景、修复使用痕迹 | 必须提供商品实物图;加文字、去水印、抠图、局部编辑、海报、套版和仿图不按商品精修判断 |
33
- | 电商模特 | 模特、试穿、上身、穿戴、佩戴、换模特、换姿势、换背景 | 商品图可选;没有商品图时可以生成纯模特 |
34
- | 商品场景图 | 生成场景、换场景、换个背景、整合到一张图+背景 | 必须提供商品实物图;人像、风景和设计稿不算商品图,带卖点文字的主图不按商品场景图判断 |
35
- | 主题照 | 主题照、写真、风格人像 | 人像图可选 |
36
- | 形象照 | 形象照、职业照 | 人像图可选 |
37
- | 证件照 | 证件照、报名照、头像照,包括换底色和改尺寸 | 人像图可选 |
38
- | 电商图片提示词 | 写电商图片提示词、产品主图提示词 | 服务端按当前组织的 Business Skill 可用性处理 |
39
- | 电商视频提示词 | 电商视频提示词、带货视频、产品宣传视频 | 服务端按当前组织的 Business Skill 可用性处理 |
40
-
41
- 这些参考不在 CLI 选择具体 Business Skill,也不代替服务端实时可用性。业务意图成立但缺少必需素材时,仍使用 Agent 并请用户提供素材;不要因此降级为 Tool。指定 Model、分辨率、比例、时长等参数也不改变路由。
42
-
43
- 典型判断:
44
-
45
- - “指定 Model 的电商主图套图”仍使用 Agent,因为目标是业务交付物且可能需要多产物编排。
46
- - “规划三种风格,再分别生成图片”使用 Agent,因为它包含规划和多步骤。
47
- - “指定 Model 生成一只猫”使用 Tool,因为它只是原子单次调用,而不是因为指定了 Model。
48
- - 用户明确要求直接调用某个 Tool 时,使用 Tool。
49
-
50
- 不猜 Tool 名、Model 名或参数;以当前命令输出为准。用户询问推荐 Model、Model 能力、参数或稿豆价格时,先用 `model list` 筛选,再用 `model get` 核对实时详情。
51
-
52
- ## 读取所选路由
53
-
54
- - 选择 Agent:发送请求前读取 [Agent 创作](agent.md),其中包含新建、续聊、等待和交付步骤。
55
- - 选择 Tool:调用前读取 [Tool 创作](tool.md),按所选 Model detail 组织参数。
56
-
57
- ## 本地媒体
58
-
59
- 用户本轮明确附图、点名文件或指定已有结果时,将该资源作为此次编辑目标;未指定时再从当前创作的最近相关结果选择。组装或复用请求 JSON 时,核对并更新全部资源字段中的 URL/本地路径、名称与角色,使其和本轮目标对应,不只替换文字。Agent 继续同一创作时,保留对应的 `message.contextId`。
60
-
61
- Agent 将本地媒体写成独立 URL Part;Tool 按所选 Model detail 写入对应媒体参数。按 Skill 根页从真实路径生成标准 file URI,保持原图/参考/首尾帧角色、顺序及重复引用。CLI 会在内部通过 DAM 完成临时上传并把公网 URL 传给创作服务;不要自行伪造 URL,也不要读取用户未明确授权的路径。