@gaoding/cli 1.4.0 → 1.5.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.
@@ -1,3 +1,4 @@
1
+ import { remoteErrorEvidence } from "../../platform/remote-error-evidence.js";
1
2
  import { classifyBindOutcome, SsoRequestError } from "../auth/sso-service.js";
2
3
  import { RemoteRequestError } from "../../platform/signed-http-transport.js";
3
4
  import { OrganizationResponseError } from "./org-service.js";
@@ -14,9 +15,13 @@ export class OrganizationInvalidError extends Error {
14
15
  }
15
16
  }
16
17
  export class OrganizationBindFailedError extends Error {
17
- constructor() {
18
+ remoteCode;
19
+ remoteBody;
20
+ constructor(evidence = {}) {
18
21
  super("选择组织失败,请稍后重试。");
19
22
  this.name = "OrganizationBindFailedError";
23
+ this.remoteCode = evidence.remoteCode;
24
+ this.remoteBody = evidence.remoteBody;
20
25
  }
21
26
  }
22
27
  export function createOrgUseCases(dependencies) {
@@ -29,7 +34,7 @@ export function createOrgUseCases(dependencies) {
29
34
  if (outcome.status === "invalid")
30
35
  throw new OrganizationInvalidError();
31
36
  if (outcome.status === "failed")
32
- throw new OrganizationBindFailedError();
37
+ throw new OrganizationBindFailedError(remoteErrorEvidence(response));
33
38
  return {
34
39
  id: record.id,
35
40
  name: record.publicName,
@@ -134,7 +139,7 @@ export function createOrgUseCases(dependencies) {
134
139
  if (outcome.status === "invalid")
135
140
  throw new OrganizationInvalidError();
136
141
  if (outcome.status === "failed")
137
- throw new OrganizationBindFailedError();
142
+ throw new OrganizationBindFailedError(remoteErrorEvidence(response));
138
143
  return {
139
144
  id: input.state.organization.id,
140
145
  name: input.state.organization.name,
@@ -8,11 +8,6 @@ export const defaultToolDefinitions = [
8
8
  name: "video.generate",
9
9
  title: "视频生成",
10
10
  description: "使用已发布的视频模型,根据文本及可选图片、视频或音频生成视频。"
11
- },
12
- {
13
- name: "text.generate",
14
- title: "文本生成",
15
- description: "使用已发布的文本模型,根据文本和可选图片生成文本。"
16
11
  }
17
12
  ];
18
13
  export class ToolInputError extends Error {
@@ -1,7 +1,7 @@
1
1
  import { Ajv2020 } from "ajv/dist/2020.js";
2
2
  import addFormatsImport, {} from "ajv-formats";
3
3
  import { ToolInputError } from "./catalog.js";
4
- function parameterSchema(parameter) {
4
+ function parameterSchema(parameter, includeBounds = false) {
5
5
  const common = {
6
6
  ...(parameter.description === undefined ? {} : { description: parameter.description }),
7
7
  ...(parameter.default === undefined ? {} : { default: parameter.default })
@@ -11,8 +11,18 @@ function parameterSchema(parameter) {
11
11
  if (parameter.type === "uri[]") {
12
12
  return { type: "array", items: { type: "string", format: "uri" }, ...common };
13
13
  }
14
- if (parameter.type === "number")
15
- return { type: "number", ...common };
14
+ if (parameter.type === "number") {
15
+ return {
16
+ type: "number",
17
+ ...(includeBounds && parameter.minimum !== undefined
18
+ ? { minimum: parameter.minimum }
19
+ : {}),
20
+ ...(includeBounds && parameter.maximum !== undefined
21
+ ? { maximum: parameter.maximum }
22
+ : {}),
23
+ ...common
24
+ };
25
+ }
16
26
  return {
17
27
  type: "string",
18
28
  ...(parameter.options === undefined
@@ -78,7 +88,7 @@ export function buildModelArgumentsSchema(model) {
78
88
  }
79
89
  };
80
90
  for (const parameter of model.parameters) {
81
- properties[parameter.name] = parameterSchema(parameter);
91
+ properties[parameter.name] = parameterSchema(parameter, true);
82
92
  }
83
93
  return {
84
94
  type: "object",
@@ -105,7 +115,7 @@ function controlArgumentsValidator(model) {
105
115
  || parameter.type === "uri"
106
116
  || parameter.type === "uri[]")
107
117
  continue;
108
- properties[parameter.name] = parameterSchema(parameter);
118
+ properties[parameter.name] = parameterSchema(parameter, true);
109
119
  }
110
120
  return ajv.compile({
111
121
  type: "object",
@@ -116,13 +126,31 @@ function controlArgumentsValidator(model) {
116
126
  }
117
127
  export function assertModelArguments(model, value) {
118
128
  if (typeof value !== "object" || value === null
119
- || !validator(model)(value)) {
129
+ || !validator(model)(value)
130
+ || !sliderStepsAreValid(model, value)) {
120
131
  throw new ToolInputError();
121
132
  }
122
133
  }
134
+ function sliderStepsAreValid(model, value) {
135
+ return model.parameters.every((parameter) => {
136
+ if (parameter.step === undefined || !Object.hasOwn(value, parameter.name))
137
+ return true;
138
+ const candidate = value[parameter.name];
139
+ const minimum = parameter.minimum;
140
+ if (typeof candidate !== "number" || minimum === undefined || parameter.step <= 0) {
141
+ return false;
142
+ }
143
+ const steps = (candidate - minimum) / parameter.step;
144
+ const nearestStep = Math.round(steps);
145
+ const expected = minimum + nearestStep * parameter.step;
146
+ const tolerance = Number.EPSILON * Math.max(1, Math.abs(candidate), Math.abs(expected), Math.abs(minimum), Math.abs(nearestStep * parameter.step)) * 2;
147
+ return Math.abs(candidate - expected) <= tolerance;
148
+ });
149
+ }
123
150
  export function modelControlArgumentsAreValid(model, value) {
124
151
  return typeof value === "object"
125
152
  && value !== null
126
153
  && !Array.isArray(value)
127
- && controlArgumentsValidator(model)(value);
154
+ && controlArgumentsValidator(model)(value)
155
+ && sliderStepsAreValid(model, value);
128
156
  }
@@ -2,19 +2,16 @@ import { RemoteRequestError } from "../../platform/signed-http-transport.js";
2
2
  export const ROOT_SCENE_CODES = [
3
3
  "image-model-art",
4
4
  "AI-image-generation-art",
5
- "AI-video-generation",
6
- "AI-text-generation"
5
+ "AI-video-generation"
7
6
  ];
8
7
  const rootTools = {
9
8
  "image-model-art": "image.generate",
10
9
  "AI-image-generation-art": "image.generate",
11
- "AI-video-generation": "video.generate",
12
- "AI-text-generation": "text.generate"
10
+ "AI-video-generation": "video.generate"
13
11
  };
14
12
  const toolOrder = {
15
13
  "image.generate": 0,
16
- "video.generate": 1,
17
- "text.generate": 2
14
+ "video.generate": 1
18
15
  };
19
16
  const multiUriKeys = new Set([
20
17
  "image_urls",
@@ -95,17 +92,33 @@ function parameter(value) {
95
92
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name))
96
93
  return undefined;
97
94
  const sourceType = requiredText(field.type);
98
- const type = multiUriKeys.has(name)
99
- ? "uri[]"
100
- : name === "start_frame" || name === "end_frame" || sourceType === "IMAGE"
101
- ? "uri"
102
- : sourceType === "NUMBER"
103
- ? "number"
104
- : sourceType === "TEXT" || sourceType === "INPUT" || sourceType === "SELECT"
105
- ? "string"
106
- : undefined;
95
+ const type = sourceType === "SLIDER"
96
+ ? "number"
97
+ : multiUriKeys.has(name)
98
+ ? "uri[]"
99
+ : name === "start_frame" || name === "end_frame" || sourceType === "IMAGE"
100
+ ? "uri"
101
+ : sourceType === "NUMBER"
102
+ ? "number"
103
+ : sourceType === "TEXT" || sourceType === "INPUT" || sourceType === "SELECT"
104
+ ? "string"
105
+ : undefined;
107
106
  if (type === undefined)
108
107
  throw new Error("unsupported parameter");
108
+ let minimum;
109
+ let maximum;
110
+ let step;
111
+ if (sourceType === "SLIDER") {
112
+ if (typeof field.min !== "number" || !Number.isFinite(field.min)
113
+ || typeof field.max !== "number" || !Number.isFinite(field.max)
114
+ || typeof field.step !== "number" || !Number.isFinite(field.step)
115
+ || field.min > field.max || field.step <= 0) {
116
+ throw new Error("invalid slider constraints");
117
+ }
118
+ minimum = field.min;
119
+ maximum = field.max;
120
+ step = field.step;
121
+ }
109
122
  let options;
110
123
  if (sourceType === "SELECT") {
111
124
  if (!Array.isArray(field.options))
@@ -132,6 +145,9 @@ function parameter(value) {
132
145
  name,
133
146
  type,
134
147
  required: field.required === true,
148
+ ...(minimum === undefined ? {} : { minimum }),
149
+ ...(maximum === undefined ? {} : { maximum }),
150
+ ...(step === undefined ? {} : { step }),
135
151
  ...(description === undefined ? {} : { description }),
136
152
  ...(hasDefault
137
153
  ? { default: defaultValue }
@@ -251,7 +267,8 @@ export function createMnsCatalogAdapter(dependencies) {
251
267
  models,
252
268
  warnings: invalidCount === 0
253
269
  ? []
254
- : [`已忽略 ${invalidCount} 个无效模型配置。`]
270
+ : [dependencies.invalidModelWarning?.(invalidCount)
271
+ ?? `已忽略 ${invalidCount} 个无效模型配置。`]
255
272
  };
256
273
  }
257
274
  catch (error) {
@@ -75,11 +75,6 @@ export const insmindProduct = freezeProduct({
75
75
  name: "video.generate",
76
76
  title: "Video generation",
77
77
  description: "Generate videos with published video models using text and optional images, video, or audio."
78
- },
79
- {
80
- name: "text.generate",
81
- title: "Text generation",
82
- description: "Generate text with published text models using text and optional images."
83
78
  }
84
79
  ]
85
80
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaoding/cli",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Gaoding command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -55,8 +55,8 @@
55
55
  "vitest": "4.1.10"
56
56
  },
57
57
  "gaodingRelease": {
58
- "sourceCommit": "c8b6775824e2c5d4a08be92d3d4f0bc07c5dad61",
59
- "pipelineId": "183000",
60
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/183000"
58
+ "sourceCommit": "20512692303b4ceff9b97871902c5ba126bdb894",
59
+ "pipelineId": "188672",
60
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/188672"
61
61
  }
62
62
  }
@@ -5,11 +5,20 @@ description: Use when creating images, videos or text with GD CLI, operating the
5
5
 
6
6
  # GD CLI
7
7
 
8
+ ## 按需发现当前能力
9
+
10
+ - 首次使用时确认 `gd-cli --version`;不确定入口时读 `gd-cli --help`,沿相关命令组选择命令,执行前读其 `--help`。本 Skill 的示例不代表完整能力清单。
11
+ - 结构化输入先读取命令公开支持的 `--schema`;模型、参数选项、价格与资源 ID 由对应目录或详情查询取得,不从旧示例猜值。发现不支持或查询失败时说明缺口,不静默替换用户明确约束。
12
+ - 同一会话可复用同一路径/版本的 help 和静态 Schema;CLI 变化后重查。动态信息在本次任务选能力或报价时查询,身份/组织变化或明确不匹配时刷新相关结果,不全量扫描无关目录。
13
+ - 发现只说明当前实装 CLI 的能力,不等于升级,也不授予生成、写入或安装权限;未知结果的恢复按错误处理指引执行。
14
+
15
+ ## 读取任务指引
16
+
8
17
  按用户目标只读取对应参考:
9
18
 
10
19
  - 按业务意图选择 Agent / Tool 创作路由、发现 Model 并生成图片、视频或文本:[创作](references/creation.md)
11
20
  - 操作当前 AI+ Editor 作品:[编辑器](references/editor.md)
12
- - 发现资源库、文件夹与标签,查询、上传、下载或单条目管理 DAM 资源:[素材管理](references/dam.md)
21
+ - 发现资源库、文件夹与标签,查询、上传、下载或管理 DAM 资源:[素材管理](references/dam.md)
13
22
  - 登录或选择组织:[登录与组织](references/auth-org.md)
14
23
  - 处理输出、警告、失败、中断或找回丢失结果:[错误处理](references/errors.md)
15
24
  - 更新 CLI 与随包 Agent Skill:[更新](references/update.md)
@@ -1,11 +1,23 @@
1
1
  # 创作
2
2
 
3
+ ## 需求与素材
4
+
5
+ 忠实传递用户需求、已提供素材和明确约束。缺少完成任务所必需的信息或素材时,由宿主向用户澄清,或将原始需求交给业务 Agent 判断并追问;不要擅自添加生成替代素材、忽略约束或改变任务目标的指令。用户明确允许自由创作、使用示意素材或自行补全的,按其授权执行。
6
+
7
+ 以缺失内容是否影响任务成立、对象一致性或明确要求的满足为判断依据;可选的风格偏好不必一律追问。
8
+
9
+ 例如,用户说“为这件商品制作宣传图”却没有提供可识别该商品的素材:
10
+
11
+ - 正例:请求补充商品图;或将这句原始需求交给业务 Agent,由其判断需要哪些素材并追问。
12
+ - 反例:自行加上“没有原图,先生成一个示意商品”。即使标注“概念展示”,也改变了用户指定的对象;应先取得用户选择。
13
+ - 自由创作的区别:“设计一件虚构商品并制作宣传图”已允许创造对象,可以直接创作;仅未指定配色或版式时,可自行设计这些风格细节。
14
+
3
15
  ## Creation Route
4
16
 
5
17
  先判断 Creation Route,再选择或校验 Model。Model 和参数不决定 Agent 或 Tool 路由;两条路由都支持指定 Model 及其参数,`model list` 和 `model get` 是共享的实时发现能力。
6
18
 
7
19
  - Agent:用户要的是业务交付物,或过程需要澄清、规划、多步骤、多产物或继续已有创作。下列十类业务意图通常优先走 Agent;它们只帮助选择 Creation Route,具体 Business Skill 由服务端 Agent 选择。
8
- - Tool:任务是一个无需业务编排的原子单次图片、视频或文本调用,或用户明确要求直接调用 Tool。
20
+ - Tool:任务是一个无需业务编排的原子单次调用,具体能力由 `tool list` 发现;或用户明确要求直接调用可用 Tool。
9
21
 
10
22
  业务意图参考(语义匹配,不是只能逐字命中):
11
23
 
@@ -24,8 +36,6 @@
24
36
 
25
37
  这些参考不在 CLI 选择具体 Business Skill,也不代替服务端实时可用性。业务意图成立但缺少必需素材时,仍使用 Agent 并请用户提供素材;不要因此降级为 Tool。指定 Model、分辨率、比例、时长等参数也不改变路由。
26
38
 
27
- 状态映射:原“商品白底图”Business Skill 已下线,白底图或纯白背景需求按商品精修意图走 Agent;原“小红书人像封面”Business Skill 已下线,相关种草人像封面需求走 Agent 兜底。状态只解释路由,不表示 CLI 指定了服务端 Skill。
28
-
29
39
  典型判断:
30
40
 
31
41
  - “指定 Model 的电商主图套图”仍使用 Agent,因为目标是业务交付物且可能需要多产物编排。
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## 先发现,再操作
4
4
 
5
+ 先读 `gd-cli dam --help` 选择当前支持的操作,使用前读对应子命令的 `--help`;以下是常见路径,不是完整命令或参数清单。
6
+
5
7
  任何资源库范围内的查询或写入都先运行:
6
8
 
7
9
  ```bash
@@ -18,7 +20,7 @@ gd-cli dam folder list --repository-id <id> --json
18
20
  gd-cli dam tag list --repository-id <id> --json
19
21
  ```
20
22
 
21
- 文件夹可用 `--parent-id`、`--query`、`--page` 和 `--page-size`;标签可用 `--query`。根文件夹 ID 为 `0`,涉及目标位置时必须显式传 `--target-folder-id 0`,不要把缺省值理解为根目录。
23
+ 文件夹、标签的筛选和分页参数从对应 `--help` 获取。根文件夹 ID 为 `0`,涉及目标位置时必须显式传 `--target-folder-id 0`,不要把缺省值理解为根目录。
22
24
 
23
25
  ## 查询与下载
24
26
 
@@ -29,9 +31,9 @@ gd-cli dam get <asset-id> --json
29
31
  gd-cli dam download <asset-id> --repository-id <id> --output-dir ./downloads --json
30
32
  ```
31
33
 
32
- 跨资源库查询只在用户明确要求时使用 `--all-repositories`。列表或搜索按需增加文件夹、类型、格式、标签、数量和游标筛选。下载只支持一个素材,不支持文件夹下载,也不会覆盖已存在的同名文件。
34
+ 跨资源库查询只在用户明确要求时使用 `--all-repositories`。筛选、下载范围和本地文件处理规则从所选命令的 `--help` 获取,不擅自扩大用户指定的资源范围。
33
35
 
34
- ## 单条目写入
36
+ ## 写入与授权
35
37
 
36
38
  ```bash
37
39
  gd-cli dam upload ./asset.png --repository-id <id> --folder-id <folder-id> --tag-ids <tag-id> --json
@@ -41,12 +43,11 @@ gd-cli dam move <entry-id> --kind asset --repository-id <source-id> --target-rep
41
43
  gd-cli dam delete <asset-id> --repository-id <id>
42
44
  ```
43
45
 
44
- - `rename`、`move`、`copy` 的 `--kind` 只能是 `asset` 或 `folder`。
45
- - 一次只处理一个素材或文件夹;不拆分或模拟批量操作。
46
+ - 条目类型和单次操作范围以命令 `--help` 为准,不把示例当作完整能力清单,也不擅自扩大写入范围。
46
47
  - 上传受保护路径时,只有用户明确允许才加 `--allow-sensitive-path`;需要等待分析完成时加 `--wait-analysis`。
47
48
  - 复制结果可能没有 `copied_entry_id`,这不表示失败;查询目标文件夹或目标资源库发现新副本,不要猜测新 ID,也不要再次提交 copy。
48
49
  - 移动、复制或重命名若返回“已提交但未确认”,先查询目标位置并报告诊断 ID,不要立即重复提交。
49
50
  - 删除默认移入回收站;只有用户明确要求永久删除时才加 `--permanent`。
50
- - 回收站列表和恢复暂不可用,不要尝试不存在的 `dam recycle` 命令。
51
+ - 回收站等未在示例中展示的操作先查 `gd-cli dam --help`;未发现所需能力时说明限制,不猜测命令。
51
52
 
52
53
  写操作前确认资源库、条目 ID、类型和目标位置。优先从本轮 JSON 输出取得 ID,不从本地登录状态或旧输出替用户猜测。
@@ -1,86 +1,33 @@
1
1
  # AI+ Editor
2
2
 
3
- ## 使用边界
3
+ ## 发现能力与使用边界
4
4
 
5
- 使用 `gd-cli editor` 读取和操作浏览器中当前一个 AI+ Editor 作品。当前版本只支持一个 Editor Session、当前 Page 的直属 Shape 和 Connector,以及单操作者串行操作。
5
+ 首次进入此任务分支,读取当前安装版本的帮助;构造 Action 前查询输入 Schema:
6
6
 
7
- 支持的 Shape:
8
-
9
- - `rectangle`
10
- - `rounded-rectangle`
11
- - `triangle-up`
12
- - `ellipse`
13
- - `diamond`
7
+ ```bash
8
+ gd-cli editor --help
9
+ gd-cli editor apply --help
10
+ gd-cli editor apply --schema
11
+ ```
14
12
 
15
- Connector 必须从一个 Shape 绑定到另一个 Shape,`lineType` 只支持 `straight` 和 `elbowed`。当前不支持 Group、图片、视频、独立文本、嵌套元素、自由 Connector、半绑定 Connector、Connector label、端点坐标、选择修改或页面管理。
13
+ 支持的元素、Action、字段和可选值以当前 Schema 为准;操作范围、坐标/颜色语义、等待与错误处理以对应子命令 help 为准。Schema 查询无需登录或连接 Editor。不从旧示例推断能力,也不猜测不存在的字段或命令。
16
14
 
17
- 当前 Page 只要包含不支持的直属元素,`snapshot`、`apply` 和 `screenshot` 都会返回 `UNSUPPORTED_PAGE_CONTENT`。此时停止操作,让用户换用空白或专用 Page;保留原作品内容。
15
+ 保持单操作者串行操作。页面包含不支持的内容时停止,让用户换用空白或专用 Page;保留原作品内容。
18
16
 
19
17
  ## 标准流程
20
18
 
21
- 按以下闭环执行,完成标准是保存后得到 `workId` 和公开作品 URL:
22
-
23
- 1. 建立 Session。target 省略时在线上新建 Board;纯数字按线上作品 ID 打开;完整 HTTP/HTTPS URL 按该 URL 的环境打开:
24
-
25
- ```bash
26
- gd-cli editor connect
27
- gd-cli editor connect 37428738696269847
28
- gd-cli editor connect "http://my.gaoding.art:3000/?mode=create&type=board"
29
- ```
30
-
31
- 三种形式只选与目标匹配的一种。`connect` 只有在页面已连接,且浏览器 AI+ 登录、作品加载、Board 类型、编辑/保存权限和内容检查全部通过后才成功。连接失败时停止作图。
32
-
33
- 2. 读取当前 Page:
34
-
35
- ```bash
36
- gd-cli editor snapshot
37
- ```
38
-
39
- 3. 根据 Snapshot 生成完整、有序的 Action JSON 数组,通过文件或 stdin 应用:
40
-
41
- ```bash
42
- gd-cli editor apply --input actions.json
43
- # 或
44
- gd-cli editor apply --input -
45
- ```
46
-
47
- 4. 每次 Apply 后都重新读取结构。只要涉及布局、文字或 Connector,再获取截图并打开实际 PNG 复查:
48
-
49
- ```bash
50
- gd-cli editor snapshot
51
- gd-cli editor screenshot --json
52
- ```
53
-
54
- `screenshot --json` 返回 `{ "path": "<绝对 PNG 路径>" }`。使用本地图片查看能力检查图片;文件存在或 Action 已提交都不代表渲染正确。
55
-
56
- 5. 结构和视觉复查均通过后显式保存:
57
-
58
- ```bash
59
- gd-cli editor save --json
60
- ```
61
-
62
- 成功 stdout 形如:
19
+ 完成标准是结构与视觉复查通过,且显式保存成功并得到公开作品 URL:
63
20
 
64
- ```json
65
- {
66
- "workId": "37428738696269847",
67
- "url": "https://www.gaoding.art/editor/canvas?mode=user&type=board&id=37428738696269847"
68
- }
69
- ```
70
-
71
- 只有该命令成功才可以声明作品已保存。新 Board 在第一次显式保存时创建作品 ID;把返回的公开 `url` 交给用户,并保留其中的环境参数。
72
-
73
- 保存会等待 AI+ Editor 的真实持久化完成,可能明显慢于其他 Editor 命令;Bridge 为 Save 保留最长 5 分 30 秒。保持命令运行直到返回,不因短暂无输出而中断或并发发起其他 Editor 命令。
74
-
75
- 6. 保存成功后断开 Session:
76
-
77
- ```bash
78
- gd-cli editor disconnect
79
- ```
21
+ 1. 查询 `gd-cli editor connect --help`,按用户目标选择 `gd-cli editor connect [target]`。不为恢复已有作品而省略目标新建 Board。只有浏览器登录、加载、编辑/保存权限和内容检查通过后才成功;连接失败时停止作图。
22
+ 2. 读取 `gd-cli editor snapshot`。以最新 Snapshot 中的完整元素为基础,只改变目标字段;Update 提交完整元素,不能提交 patch。
23
+ 3. 根据 Schema 和 Snapshot 构造完整、有序的 Action JSON 数组,执行 `gd-cli editor apply --input actions.json`,或用 `--input -` 从 stdin 读取。使用简短语义 ID;Connector 的方向和目标必须符合业务关系。
24
+ 4. 每次 Apply 后重新读取 Snapshot。涉及布局、文字或 Connector 时,执行 `gd-cli editor screenshot --json` 并打开返回的绝对 `path` 对应的实际 PNG。文件存在或 Action 已提交都不代表渲染正确。
25
+ 5. 结构和视觉复查均通过后,执行 `gd-cli editor save --json`,继续等待原命令完成,不因短暂无输出而中断或并发操作。只有保存成功才可声明作品已保存;把返回的 `workId` 和公开 `url` 交给用户,并保留 URL 中的环境参数。等待时限查 `editor save --help`。
26
+ 6. 保存成功后执行 `gd-cli editor disconnect`;断开连接不代替保存。
80
27
 
81
28
  `connect` 会替换旧 Session 并打开作品页面。连接前置检查失败会清理本次 Session,但保留浏览器页面;用户在页面中完成登录或处理访问权限后,再重新执行 `connect`。GD CLI 的 AK/SK 登录不能替代浏览器 AI+ 登录,账号密码应由用户在浏览器登录界面输入。
82
29
 
83
- 如果 AI+ 在同一个 SPA 页面再次加载或切换作品,当前 Session 会主动断开以避免误写;此时重新执行 `gd-cli editor connect [target]`。
30
+ 页面重新加载或切换作品导致 Session 断开时,重新连接预期作品并读取最新 Snapshot 后再操作。
84
31
 
85
32
  ## 复查作品
86
33
 
@@ -100,155 +47,19 @@ Connector 必须从一个 Shape 绑定到另一个 Shape,`lineType` 只支持
100
47
 
101
48
  修正后再次执行 `snapshot`;涉及视觉变化时再次执行 `screenshot --json` 并打开图片。存在问题就继续修正;没有可执行问题时结束复查并保存。
102
49
 
103
- ## Snapshot 契约
104
-
105
- ```ts
106
- type FocusedPageSnapshot = {
107
- elements: Array<FocusedShape | FocusedConnector>;
108
- selectedIds: string[];
109
- };
110
-
111
- type FocusedShape = {
112
- _type: "shape";
113
- id: string;
114
- shapeType:
115
- | "rectangle"
116
- | "rounded-rectangle"
117
- | "triangle-up"
118
- | "ellipse"
119
- | "diamond";
120
- x: number;
121
- y: number;
122
- w: number;
123
- h: number;
124
- text?: string;
125
- fill: string;
126
- stroke: string | null;
127
- };
128
-
129
- type FocusedConnector = {
130
- _type: "connector";
131
- id: string;
132
- fromId: string;
133
- toId: string;
134
- lineType: "straight" | "elbowed";
135
- color: string;
136
- };
137
- ```
138
-
139
- `x`、`y` 是 Shape 左上角的 Page 坐标,`w`、`h` 是尺寸。`selectedIds` 只读。
140
-
141
- 只使用简短、有语义的 `id`,例如 `start`、`review`、`start-to-review`。Bridge 会把这些 ID 映射到 Editor 内部标识。Connector 用 `fromId`、`toId` 表达有方向的 Shape 关系。
142
-
143
- ## Action 契约
144
-
145
- ```ts
146
- type FocusedEditorAction =
147
- | { _type: "create"; element: FocusedShape | FocusedConnector }
148
- | { _type: "update"; element: FocusedShape | FocusedConnector }
149
- | { _type: "delete"; id: string };
150
- ```
151
-
152
- - 输入必须是 JSON 数组,Action 按数组顺序执行。
153
- - Create 的 `id` 必须唯一;Connector 可以引用本数组中更早创建的 Shape。
154
- - Update 必须提交完整元素,不能提交 patch,也不能改变 `id` 或 `_type`。
155
- - Delete 的 `id` 必须存在;删除 Shape 会同时删除绑定到它的 Connector。
156
- - 对象不接受额外字段。所有数值必须有限,`w`、`h` 必须大于 0。
157
- - `fill`、`stroke` 和 `color` 使用 `#RRGGBB` 或 `#RRGGBBAA`;只有 Shape 的 `stroke` 可以为 `null`。
158
- - 整批 Action 会先预检,再在一个可回滚事务中应用。任何一项无效时整批不写入;修正输入后再提交。
159
-
160
- ## 完整示例
161
-
162
- 以下数组创建从左到右的 `Start -> Review? -> Done` 流程图:
163
-
164
- ```json
165
- [
166
- {
167
- "_type": "create",
168
- "element": {
169
- "_type": "shape",
170
- "id": "start",
171
- "shapeType": "rounded-rectangle",
172
- "x": 80,
173
- "y": 160,
174
- "w": 180,
175
- "h": 80,
176
- "text": "Start",
177
- "fill": "#ffffff",
178
- "stroke": "#222222"
179
- }
180
- },
181
- {
182
- "_type": "create",
183
- "element": {
184
- "_type": "shape",
185
- "id": "review",
186
- "shapeType": "diamond",
187
- "x": 360,
188
- "y": 140,
189
- "w": 140,
190
- "h": 120,
191
- "text": "Review?",
192
- "fill": "#f2f6ff",
193
- "stroke": "#222222"
194
- }
195
- },
196
- {
197
- "_type": "create",
198
- "element": {
199
- "_type": "shape",
200
- "id": "done",
201
- "shapeType": "rounded-rectangle",
202
- "x": 600,
203
- "y": 160,
204
- "w": 180,
205
- "h": 80,
206
- "text": "Done",
207
- "fill": "#e8f7ed",
208
- "stroke": "#222222"
209
- }
210
- },
211
- {
212
- "_type": "create",
213
- "element": {
214
- "_type": "connector",
215
- "id": "start-to-review",
216
- "fromId": "start",
217
- "toId": "review",
218
- "lineType": "straight",
219
- "color": "#222222"
220
- }
221
- },
222
- {
223
- "_type": "create",
224
- "element": {
225
- "_type": "connector",
226
- "id": "review-to-done",
227
- "fromId": "review",
228
- "toId": "done",
229
- "lineType": "straight",
230
- "color": "#222222"
231
- }
232
- }
233
- ]
234
- ```
235
-
236
- 修改现有元素时,以最新 Snapshot 中的完整对象为基础,只改变目标字段后提交完整 Update。
237
-
238
50
  ## 失败处理
239
51
 
240
52
  - `LOGIN_REQUIRED`:停止作图,让用户在已打开的 AI+ 页面登录,然后重新执行 `connect`;浏览器登录不能用 `gd-cli auth` 代替。
241
53
  - `EDITOR_NOT_READY`:停止并检查页面是否完成加载;重新执行 `connect`,成功前不调用写操作。
242
54
  - `WORK_NOT_EDITABLE`:停止;当前用户没有该作品的编辑或保存能力。
243
- - `EDITOR_SESSION_NOT_FOUND`:重新执行 `gd-cli editor connect [target]`,然后读取 Snapshot。
244
- - `EDITOR_NOT_CONNECTED`:页面连接已丢失;重新连接目标作品,不轮询旧 Session。
55
+ - `EDITOR_SESSION_NOT_FOUND` 或 `EDITOR_NOT_CONNECTED`:重新连接目标作品并读取 Snapshot,不轮询旧 Session。
245
56
  - `UNSUPPORTED_PAGE_CONTENT`:停止,让用户改用空白或专用 Page。
246
- - `INVALID_ACTIONS`:根据本契约和最新 Snapshot 修正 Action,不原样重试。
57
+ - `INVALID_ACTIONS`:根据当前 Schema、help 和最新 Snapshot 修正 Action,不原样重试。
247
58
  - `APPLY_FAILED`:运行时异常已触发批次回滚;重新读取 Snapshot,确认作品处于 Apply 前状态后再决定下一步。
248
59
  - `EDITOR_ROLLBACK_FAILED`:无法确认恢复到 Apply 前状态。停止所有 `apply` 和 `save`,只读取 Snapshot 或截图并报告。
249
60
  - `SAVE_FAILED`:保留当前 Session,处理明确失败原因后可再次执行 `save --json`;成功前不报告已保存。
250
61
  - `EDITOR_BUSY`:等待当前命令结束后再发下一条,保持串行。
251
- - `EDITOR_RPC_TIMEOUT`:页面是否执行完成未知,Bridge 会关闭。普通 Editor RPC 默认等待 1 分钟,Save 最长等待 5 分 30 秒。读取类操作可重新连接同一作品后重试;`apply` 或 `save` 属于不确定写入,先重新连接同一作品并检查真实状态,再决定后续动作。无法检查原作品时停止并报告,不自动重试该写入。
252
- - `PROTOCOL_VERSION_MISMATCH`:停止并升级 GD CLI,或使用协议匹配的 AI+ Editor。
62
+ - `EDITOR_RPC_TIMEOUT`:页面是否执行完成未知,Bridge 会关闭。读取类操作可重新连接同一作品后重试;`apply` 或 `save` 属于不确定写入,先重新连接同一作品并检查真实状态,再决定后续动作。无法检查原作品时停止并报告,不自动重试该写入。
63
+ - `PROTOCOL_VERSION_MISMATCH`:停止,按[更新指引](update.md)处理安装渠道,或使用协议匹配的 AI+ Editor;不绕过宿主管理。
253
64
 
254
65
  任何写操作在超时、取消或连接中断后都可能已经提交。恢复时先观察真实状态,避免重复创建、重复 Apply 或重复 Save。
@@ -11,7 +11,7 @@
11
11
  "data": {
12
12
  "model": "<model>",
13
13
  "arguments": {
14
- "resolution": "2K"
14
+ "<parameter>": "<value from model detail and user request>"
15
15
  }
16
16
  }
17
17
  }
@@ -1,15 +1,16 @@
1
1
  # 更新
2
2
 
3
- 执行:
3
+ 用户要求升级或同意处理兼容性问题时,先查询当前安装渠道的更新语义,再执行更新:
4
4
 
5
5
  ```bash
6
+ gd-cli update --help
6
7
  gd-cli update
7
8
  ```
8
9
 
9
- 该命令检查 `@gaoding/cli` 的 npm `latest`,更新受支持的 npm 或 pnpm 全局安装,并确保随包 `gd-cli` Agent Skill 已同步;CLI 已是最新版本时仍会同步 Agent Skill。npm 更新只通过 `--allow-scripts=@gaoding/cli` 为本包启用安装脚本,pnpm 更新只通过 `--allow-build=@gaoding/cli` 为本包启用 build lifecycle。
10
+ 参数、安装来源、lifecycle 开关和 Skill 同步行为以 `update --help` 及命令返回为准;不要复制旧版本的安装命令。
10
11
 
11
- 正常使用 CLI 时,版本可用性最多每小时检查一次;存在新版本时,同一本地自然日最多在 stderr 提醒一次。看到提示后执行 `gd-cli update`。自动检查不会更新 CLI,也不会检查或修复 Agent Skill;`CI=true` 时跳过。
12
+ 普通版本提示不等于已经升级,也不表示 Skill 已同步;能力发现基于本机实装版本,不为查询能力自行升级。
12
13
 
13
- 如果 `gd-cli update` 提示当前安装由 WorkBuddy 连接器管理,请在 WorkBuddy 中更新「稿定」连接器。不要尝试绕过该安装渠道单独升级 CLI 或同步 Agent Skill;连接器会一起管理并验收匹配版本的 CLI 与 Skill。
14
+ 安装由 WorkBuddy 等宿主管理时,按命令返回的渠道指引处理。不要绕过托管升级、覆盖宿主 Skill 或借其他宿主的全局安装修复;CLI 与 Skill 不必具有相同版本号,兼容性由该渠道的最低版本和验收保证。
14
15
 
15
- 命令不接收参数或 `--json`。不支持自动更新的安装来源会给出明确的 npm、pnpm 全局安装命令。若 CLI 已更新但 Agent Skill 验收失败,保留已更新版本,按 stderr 的下一步修复后重新执行 `gd-cli update`。
16
+ 若 CLI 已更新但 Agent Skill 验收失败,保留已更新版本,按 stderr 的下一步修复后重新执行更新;不要把失败报告成完整成功。