@gaoding/cli 3.0.1 → 3.0.3

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 (54) hide show
  1. package/README.md +7 -3
  2. package/contracts/operations/agent.send/input.schema.json +1 -1
  3. package/contracts/operations/credits.get/output.schema.json +3 -3
  4. package/contracts/operations/dam.copy/input.schema.json +3 -3
  5. package/contracts/operations/dam.copy/output.schema.json +1 -1
  6. package/contracts/operations/dam.list/output.schema.json +2 -2
  7. package/contracts/operations/dam.move/input.schema.json +3 -3
  8. package/contracts/operations/dam.search/output.schema.json +2 -2
  9. package/contracts/operations/feedback.submit/input.schema.json +231 -0
  10. package/contracts/operations/feedback.submit/output.schema.json +29 -0
  11. package/contracts/operations/task.get/output.schema.json +2 -2
  12. package/contracts/presentations/task.get.schema.json +2 -2
  13. package/dist/bin/gd-cli.js +1 -6
  14. package/dist/bin/insmind-cli.js +1 -6
  15. package/dist/src/bootstrap/create-cli.js +34 -19
  16. package/dist/src/bootstrap/create-runtime.js +13 -2
  17. package/dist/src/bootstrap/run-task-worker.js +6 -2
  18. package/dist/src/bootstrap/validators.js +1 -8
  19. package/dist/src/cli/agent-commands.js +7 -6
  20. package/dist/src/cli/dam-commands.js +14 -6
  21. package/dist/src/cli/errors.js +23 -6
  22. package/dist/src/cli/feedback-command.js +31 -0
  23. package/dist/src/cli/model-commands.js +4 -4
  24. package/dist/src/cli/skill-output.js +13 -4
  25. package/dist/src/cli/task-commands.js +3 -2
  26. package/dist/src/cli/tool-commands.js +12 -5
  27. package/dist/src/cli/update-command.js +3 -3
  28. package/dist/src/contracts/creation-input.js +0 -3
  29. package/dist/src/features/dam/file-downloader.js +19 -9
  30. package/dist/src/features/dam/operation-executor.js +2 -0
  31. package/dist/src/features/dam/use-cases.js +53 -29
  32. package/dist/src/features/feedback/submit.js +86 -0
  33. package/dist/src/features/skill/catalog.js +17 -1
  34. package/dist/src/features/skill/manual.js +37 -31
  35. package/dist/src/features/task/store.js +7 -0
  36. package/dist/src/features/task/use-cases.js +66 -10
  37. package/dist/src/features/update/check-schema.js +22 -16
  38. package/dist/src/features/update/update-notification.js +8 -4
  39. package/dist/src/features/update/update-service.js +37 -16
  40. package/dist/src/telemetry/command-routes.json +1 -1
  41. package/dist/src/telemetry/invocation.js +8 -4
  42. package/dist/src/telemetry/process-errors.js +7 -2
  43. package/dist/src/telemetry/sanitize.js +18 -7
  44. package/dist/src/telemetry/sls-sink.js +38 -15
  45. package/package.json +7 -7
  46. package/skills/gd-cli/SKILL.md +2 -2
  47. package/dist/src/features/editor/bridge-client.js +0 -107
  48. package/dist/src/features/editor/bridge-process.js +0 -237
  49. package/dist/src/features/editor/bridge-server.js +0 -339
  50. package/dist/src/features/editor/protocol.js +0 -1
  51. package/dist/src/features/editor/public-url.js +0 -1
  52. package/dist/src/features/editor/session-state.js +0 -81
  53. package/dist/src/features/editor/session.js +0 -232
  54. package/dist/src/features/editor/use-cases.js +0 -118
package/README.md CHANGED
@@ -6,7 +6,9 @@
6
6
 
7
7
  ## 安装
8
8
 
9
- 需要 Node.js 20 或更高版本。使用 npm 或 pnpm 全局安装:
9
+ 需要 Node.js 20.10.0 或更高版本。使用 npm 或 pnpm 全局安装:
10
+
11
+ 旧版千问办公 CLI 连接器使用宿主管理的 Node。若其版本低于 20.10.0,请切换到千问办公远程 MCP 连接器 2.x,或请宿主升级其 Node 到 20.10.0 或更高版本后重新安装 CLI。
10
12
 
11
13
  ```bash
12
14
  npm install --global --allow-scripts=@gaoding/cli @gaoding/cli
@@ -52,7 +54,9 @@ node (Join-Path (Split-Path $target) "sync-skill.js")
52
54
 
53
55
  ## 开始使用
54
56
 
55
- 运行 `gd-cli --skill` 查看基础用法和远程目录,`gd-cli --skill --help` 只列目录。用 `gd-cli --skill <章节>` 读取选中的一篇。目录和已读正文分别缓存一小时,过期时按 ETag 刷新,断网时可使用已有副本。按工具查模型、查模型详情或提交创作时,结果 JSON 默认用 `relatedSkills` 列出匹配的指引和读取命令。脚本若按原业务 Schema 校验,显式传 `--json`。同时传 `--json --with-skills` 会包含匹配的推荐。默认结果和原业务结果的 Schema 分别随包放在 `contracts/presentations/` 和 `contracts/operations/`。模型参数和价格从实时模型目录查询。
57
+ 用 `gd-cli --skill` 查看远程目录。按工具查模型或查模型详情时,结果中的 `relatedSkills` 给出匹配章节。工具列表也在对应条目中给出用法入口。需要用法时,运行 `gd-cli --skill <章节>`。已受理的任务按原任务号查询,拿到作品就交付。若明确需要完整结果附上指引,可以加 `--with-skills`。用 `--json` 取得原业务 JSON。模型参数和价格以实时目录为准。
58
+
59
+ 用户要报问题或提需求时,运行 `gd-cli feedback --schema` 查看问题和需求示例,再用 `gd-cli feedback --input report.json` 提交。写入成功后把反馈编号交给用户。
56
60
 
57
61
  ```bash
58
62
  gd-cli auth login
@@ -68,7 +72,7 @@ gd-cli credits usage list --help
68
72
  gd-cli credits usage get --schema
69
73
  ```
70
74
 
71
- 选定 Model 后,以 `model get` 返回的 `parameters` 与 `usageDescription` 构造实际输入;其中 `cost` 是当前上架 SKU 的稿豆价格区间,不表示某次调用的实际扣费。`tool call <tool> --schema` 只给出整个 Tool 的参数并集。运行 `gd-cli --help` 查看当前命令;运行任一命令的 `--help` 查看参数。
75
+ 选定 Model 后,以 `model get` 返回的 `parameters` 与 `usageDescription` 构造实际输入;其中 `cost` 是当前上架 SKU 的稿豆价格区间,不表示某次调用的实际扣费。`tool call <tool> --schema` 给出整个 Tool 的参数索引,并在 `allOf` 中按所选模型列出必填项和取值约束;结合 `model get <model> --tool <tool>` 查看当前模型的说明和完整输入 Schema。运行 `gd-cli --help` 查看当前命令;运行任一命令的 `--help` 查看参数。
72
76
 
73
77
  CLI 最多每小时检查一次 npm `latest`,发现新版本后每天最多在 stderr 提醒一次;检查失败不影响原命令,`CI=true` 时跳过。普通启动不会检查或修复 Agent Skill。`gd-cli update` 始终实时检查 `latest`,支持更新 npm、pnpm 全局安装并同步 Agent Skill。
74
78
 
@@ -204,7 +204,7 @@
204
204
  "type": "string",
205
205
  "minLength": 1,
206
206
  "pattern": ".*\\S.*",
207
- "description": "可选创作模型机器标识;指定时由 CLI 根据实时 Model Catalog 校验。"
207
+ "description": "可选创作模型标识;已知编辑模型别名会映射到服务端 code,其余标识原样发送,由执行服务判断能否使用。"
208
208
  },
209
209
  "arguments": {
210
210
  "type": "object",
@@ -32,19 +32,19 @@
32
32
  "type": "number",
33
33
  "minimum": 0,
34
34
  "maximum": 9007199254740991,
35
- "description": "该权益行的 total;不等同于终身累计充值。"
35
+ "description": "本次查询返回的各条权益的 total 之和;不等同于终身累计充值。"
36
36
  },
37
37
  "used": {
38
38
  "type": "number",
39
39
  "minimum": 0,
40
40
  "maximum": 9007199254740991,
41
- "description": "与该权益行总量配对的已用量;不等同于所选日期消费合计。"
41
+ "description": "本次查询返回的各条权益的 used 之和;不等同于所选日期消费合计。"
42
42
  },
43
43
  "pending": {
44
44
  "type": "number",
45
45
  "minimum": 0,
46
46
  "maximum": 9007199254740991,
47
- "description": "服务端 wait 的数值;含义由服务端定义,不承诺待生效或冻结。"
47
+ "description": "本次查询返回的各条权益的服务端 wait 之和;含义由服务端定义,不承诺待生效或冻结。"
48
48
  },
49
49
  "available": {
50
50
  "type": "number",
@@ -8,9 +8,9 @@
8
8
  "properties": {
9
9
  "entry_id": { "$ref": "#/$defs/nonblank" },
10
10
  "kind": { "$ref": "#/$defs/kind" },
11
- "repositoryId": { "$ref": "#/$defs/nonblank" },
12
- "targetRepositoryId": { "$ref": "#/$defs/nonblank" },
13
- "targetFolderId": { "$ref": "#/$defs/nonblank" }
11
+ "repositoryId": { "$ref": "#/$defs/nonblank", "description": "源资源库 ID;省略时使用当前默认资源库。" },
12
+ "targetRepositoryId": { "$ref": "#/$defs/nonblank", "description": "目标资源库 ID;省略时使用源资源库。" },
13
+ "targetFolderId": { "$ref": "#/$defs/nonblank", "description": "目标文件夹 ID;目标资源库根目录传字符串 \"0\"。" }
14
14
  },
15
15
  "$defs": {
16
16
  "nonblank": { "type": "string", "minLength": 1, "pattern": ".*\\S.*" },
@@ -10,7 +10,7 @@
10
10
  "kind": { "$ref": "#/$defs/kind" },
11
11
  "repository_id": { "$ref": "#/$defs/nonblank" },
12
12
  "folder_id": { "$ref": "#/$defs/nonblank" },
13
- "copied_entry_id": { "$ref": "#/$defs/nonblank" }
13
+ "copied_entry_id": { "$ref": "#/$defs/nonblank", "description": "服务返回的副本 ID;成功但未返回时,到目标文件夹查找,不要重复提交复制。" }
14
14
  },
15
15
  "$defs": {
16
16
  "nonblank": { "type": "string", "minLength": 1, "pattern": ".*\\S.*" },
@@ -13,8 +13,8 @@
13
13
  "description": "本次查询的资源库 ID。"
14
14
  },
15
15
  "page_size": { "type": "integer", "minimum": 1, "description": "本次 DAM 请求的分页大小;实际 assets 数量可能大于该值。" },
16
- "total": { "type": "integer", "minimum": 0, "description": "匹配素材总数。" },
17
- "finish": { "type": "boolean", "description": "是否已到最后一页。" },
16
+ "total": { "type": "integer", "minimum": 0, "description": "服务返回总数时为匹配素材总数;未返回时为本页条数。结合 finish、next_cursor 和分页信息不完整的警告判断是否还有下一页;缺少分页事实时不能确认结束。" },
17
+ "finish": { "type": "boolean", "description": "结束标记;服务未提供时按已有总数或游标推导,缺少分页事实时不能确认结束。" },
18
18
  "next_cursor": { "$ref": "#/$defs/nonblank", "description": "下一页游标。" },
19
19
  "assets": {
20
20
  "type": "array",
@@ -8,9 +8,9 @@
8
8
  "properties": {
9
9
  "entry_id": { "$ref": "#/$defs/nonblank" },
10
10
  "kind": { "$ref": "#/$defs/kind" },
11
- "repositoryId": { "$ref": "#/$defs/nonblank" },
12
- "targetRepositoryId": { "$ref": "#/$defs/nonblank" },
13
- "targetFolderId": { "$ref": "#/$defs/nonblank" }
11
+ "repositoryId": { "$ref": "#/$defs/nonblank", "description": "源资源库 ID;省略时使用当前默认资源库。" },
12
+ "targetRepositoryId": { "$ref": "#/$defs/nonblank", "description": "目标资源库 ID;省略时使用源资源库。" },
13
+ "targetFolderId": { "$ref": "#/$defs/nonblank", "description": "目标文件夹 ID;目标资源库根目录传字符串 \"0\"。" }
14
14
  },
15
15
  "$defs": {
16
16
  "nonblank": { "type": "string", "minLength": 1, "pattern": ".*\\S.*" },
@@ -13,8 +13,8 @@
13
13
  "description": "本次查询的资源库 ID。"
14
14
  },
15
15
  "page_size": { "type": "integer", "minimum": 1, "description": "本次 DAM 请求的分页大小;实际 assets 数量可能大于该值。" },
16
- "total": { "type": "integer", "minimum": 0, "description": "匹配素材总数。" },
17
- "finish": { "type": "boolean", "description": "是否已到最后一页。" },
16
+ "total": { "type": "integer", "minimum": 0, "description": "服务返回总数时为匹配素材总数;未返回时为本页条数。结合 finish、next_cursor 和分页信息不完整的警告判断是否还有下一页;缺少分页事实时不能确认结束。" },
17
+ "finish": { "type": "boolean", "description": "结束标记;服务未提供时按已有总数或游标推导,缺少分页事实时不能确认结束。" },
18
18
  "next_cursor": { "$ref": "#/$defs/nonblank", "description": "下一页游标。" },
19
19
  "assets": {
20
20
  "type": "array",
@@ -0,0 +1,231 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://gdcli.gaoding.com/contracts/operations/feedback.submit/input.schema.json",
4
+ "title": "FeedbackSubmitInput",
5
+ "description": "用户要向产品团队反馈时,宿主根据用户描述、已发生的操作和可见的错误整理一份反馈。填写能确认的事实,保留有用的错误码和关联号。提交前移除令牌、带签名的链接和无关个人信息。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "type": {
10
+ "type": "string",
11
+ "enum": [
12
+ "bug",
13
+ "feature"
14
+ ],
15
+ "description": "操作出错或结果不符合预期时选 bug。希望增加或改进能力时选 feature。"
16
+ },
17
+ "host_application": {
18
+ "type": "string",
19
+ "minLength": 1,
20
+ "pattern": "\\S",
21
+ "description": "发起本次反馈的宿主应用。例如 workbuddy、codex。用户直接在终端操作时填 terminal。确实无法识别时填 unknown。",
22
+ "examples": [
23
+ "workbuddy",
24
+ "codex",
25
+ "terminal",
26
+ "unknown"
27
+ ],
28
+ "maxLength": 160
29
+ },
30
+ "host_application_version": {
31
+ "type": [
32
+ "string",
33
+ "null"
34
+ ],
35
+ "minLength": 1,
36
+ "pattern": "\\S",
37
+ "description": "宿主应用自身的版本。先查看宿主提供的版本信息,确实不可见时填 null。CLI、MCP 和连接器各有自己的版本。",
38
+ "maxLength": 160
39
+ },
40
+ "user_os": {
41
+ "type": "object",
42
+ "additionalProperties": false,
43
+ "description": "用户设备的操作系统。宿主根据已知的客户端环境填写。仅能看到云端、容器或远程 shell 时,将用户设备系统记为未知。",
44
+ "properties": {
45
+ "name": {
46
+ "type": "string",
47
+ "minLength": 1,
48
+ "pattern": "\\S",
49
+ "description": "操作系统名称,例如 Windows、macOS 或 Linux。宿主和用户都未提供时填 unknown。",
50
+ "maxLength": 128
51
+ },
52
+ "version": {
53
+ "type": [
54
+ "string",
55
+ "null"
56
+ ],
57
+ "minLength": 1,
58
+ "pattern": "\\S",
59
+ "description": "用户设备的系统版本。无法确认时填 null。",
60
+ "maxLength": 128
61
+ },
62
+ "arch": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "pattern": "\\S",
66
+ "description": "可确认时填写用户设备的架构,例如 arm64 或 x64。",
67
+ "maxLength": 128
68
+ }
69
+ },
70
+ "required": [
71
+ "name",
72
+ "version"
73
+ ]
74
+ },
75
+ "connector_version": {
76
+ "type": "string",
77
+ "minLength": 1,
78
+ "pattern": "\\S",
79
+ "description": "能确定这次使用的连接器安装包版本时填写。",
80
+ "maxLength": 160
81
+ },
82
+ "actual": {
83
+ "type": "string",
84
+ "minLength": 1,
85
+ "pattern": "\\S",
86
+ "description": "问题反馈必填。说明做了什么、在哪一步看到了什么现象。错误提示保留与排查有关的文字。",
87
+ "maxLength": 3000
88
+ },
89
+ "expected": {
90
+ "type": "string",
91
+ "minLength": 1,
92
+ "pattern": "\\S",
93
+ "description": "问题反馈写用户原本期望的结果。需求反馈写希望产品能做什么,以及做到什么程度。",
94
+ "maxLength": 3000
95
+ },
96
+ "scenario": {
97
+ "type": "string",
98
+ "minLength": 1,
99
+ "pattern": "\\S",
100
+ "description": "需求反馈必填。说明用户在什么场景下需要这项能力。",
101
+ "maxLength": 3000
102
+ },
103
+ "steps": {
104
+ "type": "array",
105
+ "minItems": 1,
106
+ "items": {
107
+ "type": "string",
108
+ "minLength": 1,
109
+ "pattern": "\\S",
110
+ "description": "一次已经发生的操作。",
111
+ "maxLength": 512
112
+ },
113
+ "description": "能还原过程时按顺序列出已经做过的操作。无需为填写此字段再次生成作品或触发写入。",
114
+ "maxItems": 24
115
+ },
116
+ "operation": {
117
+ "type": "string",
118
+ "minLength": 1,
119
+ "pattern": "\\S",
120
+ "description": "与反馈有关的原命令或工具名,例如 task.get。命令只写命令名,参数里的用户内容可省略。",
121
+ "maxLength": 160
122
+ },
123
+ "failedStep": {
124
+ "type": "string",
125
+ "minLength": 1,
126
+ "pattern": "\\S",
127
+ "description": "原错误能定位到具体环节时填写,例如上传素材或交付结果。",
128
+ "maxLength": 160
129
+ },
130
+ "errorCode": {
131
+ "type": "string",
132
+ "minLength": 1,
133
+ "pattern": "\\S",
134
+ "description": "原始错误里实际出现的错误码。",
135
+ "maxLength": 160
136
+ },
137
+ "taskId": {
138
+ "type": "string",
139
+ "minLength": 1,
140
+ "pattern": "\\S",
141
+ "description": "原任务号,取自原回执。尚未受理或没有任务号时省略。",
142
+ "maxLength": 160
143
+ },
144
+ "traceId": {
145
+ "type": "string",
146
+ "minLength": 1,
147
+ "pattern": "\\S",
148
+ "description": "原调用的诊断编号,取自原错误或回执。没有时省略。",
149
+ "maxLength": 160
150
+ },
151
+ "occurredAt": {
152
+ "type": "string",
153
+ "format": "date-time",
154
+ "description": "已知问题发生时间时填写,带时区。系统会另记收到反馈的时间。"
155
+ }
156
+ },
157
+ "required": [
158
+ "type",
159
+ "host_application",
160
+ "host_application_version",
161
+ "user_os",
162
+ "expected"
163
+ ],
164
+ "allOf": [
165
+ {
166
+ "if": {
167
+ "properties": {
168
+ "type": {
169
+ "const": "bug"
170
+ }
171
+ }
172
+ },
173
+ "then": {
174
+ "properties": {
175
+ "actual": {}
176
+ },
177
+ "required": [
178
+ "actual"
179
+ ]
180
+ }
181
+ },
182
+ {
183
+ "if": {
184
+ "properties": {
185
+ "type": {
186
+ "const": "feature"
187
+ }
188
+ }
189
+ },
190
+ "then": {
191
+ "properties": {
192
+ "scenario": {}
193
+ },
194
+ "required": [
195
+ "scenario"
196
+ ]
197
+ }
198
+ }
199
+ ],
200
+ "examples": [
201
+ {
202
+ "type": "bug",
203
+ "host_application": "workbuddy",
204
+ "host_application_version": null,
205
+ "user_os": {
206
+ "name": "Windows",
207
+ "version": "11",
208
+ "arch": "x64"
209
+ },
210
+ "actual": "查询原任务可以取到视频,但打开返回的视频链接时提示 403。",
211
+ "expected": "点击成品链接后可以播放视频。",
212
+ "steps": [
213
+ "用原任务号取回生成的视频。",
214
+ "在浏览器打开成品链接。"
215
+ ],
216
+ "operation": "task.get",
217
+ "taskId": "49de8098-7935-4e9e-9ad1-6fa2fa39b000"
218
+ },
219
+ {
220
+ "type": "feature",
221
+ "host_application": "codex",
222
+ "host_application_version": null,
223
+ "user_os": {
224
+ "name": "unknown",
225
+ "version": null
226
+ },
227
+ "scenario": "给同一款商品生成六张主图后,需要把全部原图交给运营。",
228
+ "expected": "一次下载全部原图,并保留生成顺序。"
229
+ }
230
+ ]
231
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://gdcli.gaoding.com/contracts/operations/feedback.submit/output.schema.json",
4
+ "title": "FeedbackSubmitOutput",
5
+ "description": "SLS 确认接收反馈后返回。宿主可以把反馈编号交给用户,供后续排查时引用。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "feedbackId": {
10
+ "type": "string",
11
+ "format": "uuid",
12
+ "description": "接收调用的 CLI 或 MCP 服务在发送反馈前生成的 UUID。宿主将回执中的编号交给用户,支持人员可凭它在 SLS 查找反馈。"
13
+ },
14
+ "status": {
15
+ "const": "received",
16
+ "description": "SLS 已确认接收。"
17
+ }
18
+ },
19
+ "required": [
20
+ "feedbackId",
21
+ "status"
22
+ ],
23
+ "examples": [
24
+ {
25
+ "feedbackId": "7607e64d-8c72-4b40-8e80-46f45451c223",
26
+ "status": "received"
27
+ }
28
+ ]
29
+ }
@@ -52,7 +52,7 @@
52
52
  "agent.send",
53
53
  "tool.call"
54
54
  ],
55
- "description": "决定 result 的结构及费用含义:agent.send 为本轮回复和实扣,tool.call 为工具产物和估价。"
55
+ "description": "决定 result 的结构及费用含义:agent.send 为本轮回复和已知扣费合计,记录不完整时总额待核对;tool.call 为工具产物和目录或按输入估价。"
56
56
  },
57
57
  "label": {
58
58
  "type": "string",
@@ -96,7 +96,7 @@
96
96
  "$ref": "../tool.call/output.schema.json"
97
97
  }
98
98
  ],
99
- "description": "仅 completed 时提供原调用完整结果;同一 taskId 重读不累计 usage。Tool cost.minimum/maximum 是估价,Agent cost.amount 是本轮实扣。交付本次返回的完整链接;再次查询可更新稿定结构化资源的授权,第三方签名和正文保持原样。"
99
+ "description": "仅 completed 时提供原调用完整结果;同一 taskId 重读不累计 usage。Tool cost.minimum/maximum 是目录或按输入估价;Agent cost.amount 是已确认金额之和,记录不完整时总额待核对。交付本次返回的完整链接;再次查询可更新稿定结构化资源的授权,第三方签名和正文保持原样。"
100
100
  },
101
101
  "partialResult": {
102
102
  "oneOf": [
@@ -52,7 +52,7 @@
52
52
  "agent.send",
53
53
  "tool.call"
54
54
  ],
55
- "description": "决定 result 的结构及费用含义:agent.send 为本轮回复和实扣,tool.call 为工具产物和估价。"
55
+ "description": "决定 result 的结构及费用含义:agent.send 为本轮回复和已知扣费合计,记录不完整时总额待核对;tool.call 为工具产物和目录或按输入估价。"
56
56
  },
57
57
  "label": {
58
58
  "type": "string",
@@ -96,7 +96,7 @@
96
96
  "$ref": "../operations/tool.call/output.schema.json"
97
97
  }
98
98
  ],
99
- "description": "仅 completed 时提供原调用完整结果;同一 taskId 重读不累计 usage。Tool cost.minimum/maximum 是估价,Agent cost.amount 是本轮实扣。交付本次返回的完整链接;再次查询可更新稿定结构化资源的授权,第三方签名和正文保持原样。"
99
+ "description": "仅 completed 时提供原调用完整结果;同一 taskId 重读不累计 usage。Tool cost.minimum/maximum 是目录或按输入估价;Agent cost.amount 是已确认金额之和,记录不完整时总额待核对。交付本次返回的完整链接;再次查询可更新稿定结构化资源的授权,第三方签名和正文保持原样。"
100
100
  },
101
101
  "partialResult": {
102
102
  "oneOf": [
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { randomBytes } from "node:crypto";
3
- import { runSkillManual } from "../src/features/skill/manual.js";
4
3
  import { jsonErrorsRequested } from "../src/platform/error-output-mode.js";
5
4
  import { isInterruption } from "../src/platform/interruption.js";
6
5
  const argv = process.argv.slice(2);
@@ -15,11 +14,7 @@ let runtime;
15
14
  let mapCliError;
16
15
  let redact;
17
16
  try {
18
- const manualExitCode = await runSkillManual(argv, "gd-cli", jsonErrors);
19
- if (manualExitCode !== undefined) {
20
- process.exitCode = manualExitCode;
21
- }
22
- else if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
17
+ if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
23
18
  await Promise.all([import("../src/telemetry/host-diagnostics.js"), import("../src/product/config.js")])
24
19
  .then(([{ runHostDiagnosticReporter }, { gaodingProduct }]) => runHostDiagnosticReporter({ product: gaodingProduct }))
25
20
  .catch(() => undefined);
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { randomBytes } from "node:crypto";
3
- import { runSkillManual } from "../src/features/skill/manual.js";
4
3
  import { jsonErrorsRequested } from "../src/platform/error-output-mode.js";
5
4
  import { isInterruption } from "../src/platform/interruption.js";
6
5
  import { insmindProduct } from "../src/product/config.js";
@@ -16,11 +15,7 @@ let runtime;
16
15
  let mapCliError;
17
16
  let redact;
18
17
  try {
19
- const manualExitCode = await runSkillManual(process.argv.slice(2), "insmind-cli", jsonErrors);
20
- if (manualExitCode !== undefined) {
21
- process.exitCode = manualExitCode;
22
- }
23
- else if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
18
+ if (process.env.CLI_INTERNAL_HOST_DIAGNOSTIC === "1" && process.argv.length === 3 && process.argv[2] === "--version") {
24
19
  await import("../src/telemetry/host-diagnostics.js")
25
20
  .then(({ runHostDiagnosticReporter }) => runHostDiagnosticReporter({ product: insmindProduct }))
26
21
  .catch(() => undefined);
@@ -1,4 +1,6 @@
1
+ import { writeSkillManual, skillManualArguments } from "../features/skill/manual.js";
1
2
  import { isInterruption } from "../platform/interruption.js";
3
+ import { registerFeedbackCommand } from "../cli/feedback-command.js";
2
4
  import { registerTaskCommands } from "../cli/task-commands.js";
3
5
  import { Command, CommanderError } from "commander";
4
6
  import { assertAllLeafCommandsBound, errorUsesJson, invocationDefinition, configureActionEnvironment } from "../cli/action-binding.js";
@@ -59,6 +61,7 @@ export function createCli(runtime, options) {
59
61
  registerUpdateCommand(program, runtime);
60
62
  registerTaskCommands(program, runtime);
61
63
  registerCreditsCommand(program, runtime);
64
+ registerFeedbackCommand(program, runtime);
62
65
  assertAllLeafCommandsBound(program);
63
66
  outputs.set(program, runtime);
64
67
  if (runtime.analytics)
@@ -66,14 +69,27 @@ export function createCli(runtime, options) {
66
69
  return program;
67
70
  }
68
71
  export async function executeCli(options) {
69
- const definition = invocationDefinition(options.program, options.argv);
72
+ const name = options.product?.commandName ?? "gd-cli";
73
+ const manual = skillManualArguments(options.argv, name);
74
+ const definition = manual ? { operation: "skill", mode: () => "help" } : invocationDefinition(options.program, options.argv);
70
75
  await options.telemetry.issue(definition);
71
- const automaticNotice = definition.operation !== "update" && !definition.operation.startsWith("update.");
76
+ const automaticNotice = !manual && definition.operation !== "update" && !definition.operation.startsWith("update.");
72
77
  let informational = false;
73
78
  let help = false;
74
79
  try {
75
80
  try {
76
- await options.program.parseAsync(options.argv, { from: "user" });
81
+ if (manual) {
82
+ const runtime = outputs.get(options.program);
83
+ const catalog = runtime.skillCatalog;
84
+ await writeSkillManual(manual, name, content => options.telemetry.stage("output", () => {
85
+ options.signal.throwIfAborted();
86
+ runtime.io.writeOut(content);
87
+ }), catalog?.list && catalog.read ? { list: catalog.list, read: catalog.read } : undefined);
88
+ informational = true;
89
+ }
90
+ else {
91
+ await options.program.parseAsync(options.argv, { from: "user" });
92
+ }
77
93
  }
78
94
  catch (error) {
79
95
  if (!isHelpOutcome(error))
@@ -115,14 +131,16 @@ export async function executeCli(options) {
115
131
  const refused = ["TOOL_TASK_FAILED", "INSUFFICIENT_CREDITS"].includes(outcome.failure.code)
116
132
  || ["audit_rejected", "input_audit_rejected", "output_audit_rejected"].includes(details?.reason ?? "");
117
133
  const recovery = { ...details, cli_task_id: taskId };
118
- if (outcome.exitCode !== 2 && !refused && details?.phase !== "input_upload_before_dispatch") {
119
- recovery.next_steps = [
120
- ...(details?.next_steps ?? []),
121
- `${options.product?.commandName ?? "gd-cli"} task get ${taskId}`,
122
- options.product?.id === "insmind"
123
- ? "If the outcome is still unknown, tell the user and keep this ID for recovery. Do not start another creation."
124
- : "原任务结果仍未知时,向用户说明并保留此 ID 供取回。不要另发创作。"
125
- ];
134
+ const unsent = details?.phase === "input_upload_before_dispatch" ||
135
+ (details?.phase === "before_dispatch" && details.request_sent === false && details.accepted === false);
136
+ if (outcome.exitCode !== 2 && !refused && !unsent) {
137
+ recovery.next_steps = [...new Set([
138
+ ...(details?.next_steps ?? []),
139
+ `${options.product?.commandName ?? "gd-cli"} task get ${taskId}`,
140
+ options.product?.id === "insmind"
141
+ ? "If the outcome is still unknown, tell the user and keep this ID for recovery. Do not start another creation."
142
+ : "原任务结果仍未知时,向用户说明并保留此 ID 供取回。不要另发创作。"
143
+ ])];
126
144
  }
127
145
  outcome.failure.details = recovery;
128
146
  }
@@ -131,18 +149,15 @@ export async function executeCli(options) {
131
149
  const traceId = options.telemetry.selected
132
150
  ? options.telemetry.traceId
133
151
  : undefined;
134
- let errorDelivered = false;
135
- try {
152
+ const errorDelivered = await options.telemetry.stage("output", async () => {
136
153
  options.presenter.error(outcome, {
137
154
  json: errorUsesJson(options.program, options.argv),
138
155
  ...(traceId ? { traceId } : {})
139
156
  });
140
- await outputs.get(options.program)?.io.flush?.();
141
- errorDelivered = true;
142
- }
143
- catch (presenterError) {
144
- await options.telemetry.stage("output", () => { throw presenterError; }).catch(() => undefined);
145
- }
157
+ const io = outputs.get(options.program)?.io;
158
+ await (io?.flushError ?? io?.flush)?.();
159
+ return true;
160
+ }).catch(() => false);
146
161
  if (errorDelivered)
147
162
  await outputs.get(options.program)?.tasks.outputCompleted(error);
148
163
  if (errorDelivered && automaticNotice && outcome.exitCode === 1 && definition.operation !== "unknown") {
@@ -1,3 +1,4 @@
1
+ import { sendFeedback } from "../features/feedback/submit.js";
1
2
  import { createSkillCatalog } from "../features/skill/catalog.js";
2
3
  import { httpUserAgent } from "../platform/http-user-agent.js";
3
4
  import { canvasModelBindings } from "../features/tool/canvas-models.js";
@@ -53,7 +54,7 @@ import { createOrganizationPrompt } from "../cli/prompt.js";
53
54
  import { createPresenter } from "../cli/presenter.js";
54
55
  import { createContractValidators } from "./validators.js";
55
56
  import { loadBundledSkills } from "../features/skill/bundled-skills.js";
56
- import { createUpdateService } from "../features/update/update-service.js";
57
+ import { createUpdateService, detectInstallSource, legacyQwenBridge } from "../features/update/update-service.js";
57
58
  import { createUpdateNotificationService } from "../features/update/update-notification.js";
58
59
  import { classifyTelemetryError, mapCliError } from "../cli/errors.js";
59
60
  import { createTelemetryInvocation, hostTelemetryContext } from "../telemetry/invocation.js";
@@ -138,6 +139,7 @@ export function createProductionRuntime(options = {}) {
138
139
  const io = {
139
140
  writeOut: stdout.write,
140
141
  writeError: stderr.write,
142
+ flushError: stderr.flush,
141
143
  flush: async () => { await Promise.all([stdout.flush(), stderr.flush()]); },
142
144
  inputTerminal: rawIo.inputTerminal ?? hasTerminal(rawIo.input),
143
145
  stderrTerminal: rawIo.stderrTerminal ?? hasTerminal(rawIo.stderr)
@@ -547,6 +549,7 @@ export function createProductionRuntime(options = {}) {
547
549
  currentVersion: primarySkill.version,
548
550
  packageRoot,
549
551
  bundledSkills,
552
+ env,
550
553
  fetch,
551
554
  telemetry,
552
555
  ...(product.id === "insmind" ? {
@@ -566,6 +569,8 @@ export function createProductionRuntime(options = {}) {
566
569
  fetch,
567
570
  now,
568
571
  installationOwner,
572
+ installSource: () => detectInstallSource({ binaryPath: process.argv[1] ?? "", packageRoot, cwd: process.cwd(), env,
573
+ packageName: product.npmPackage, binaryName: product.commandName }),
569
574
  ...(options.homeDirectory ? { homeDirectory: options.homeDirectory } : {}),
570
575
  ...(options.env ? { env: options.env } : {}),
571
576
  diagnosticOnly: !io.stderrTerminal && env.CLI_UPDATE_NOTICE_FORMAT !== "offer",
@@ -577,7 +582,7 @@ export function createProductionRuntime(options = {}) {
577
582
  } : {})
578
583
  });
579
584
  // The retired Qwen CLI bridge validates the original closed JSON schemas.
580
- const legacyQwen = env.CLI_HOST_APPLICATION === "qwenwork" && env.CLI_INVOCATION_PURPOSE !== undefined;
585
+ const legacyQwen = legacyQwenBridge(env);
581
586
  return {
582
587
  ...(legacyQwen ? {} : {
583
588
  skillCatalog: createSkillCatalog(product.commandName, { home: options.homeDirectory,
@@ -585,6 +590,12 @@ export function createProductionRuntime(options = {}) {
585
590
  }),
586
591
  product,
587
592
  version: primarySkill.version,
593
+ submitFeedback: (input, signal) => sendFeedback(input, {
594
+ entry_point: "cli", cli_name: product.commandName, cli_version: primarySkill.version, environment: telemetryEnvironment,
595
+ trace_id: telemetry.traceId, host_application: host.host_application ?? "unknown",
596
+ host_application_source: host.host_application_source ?? "unknown",
597
+ ...(host.host_connector_version && { host_connector_version: host.host_connector_version }),
598
+ }, { url: options.telemetryTrackingUrl ?? product.telemetryUrl, fetch, signal }),
588
599
  telemetry,
589
600
  telemetrySink,
590
601
  ...(analytics ? { analytics } : {}),
@@ -8,8 +8,12 @@ export async function runTaskWorker(options) {
8
8
  const { job, signal, send } = options;
9
9
  runtime.telemetry.useSignal(signal);
10
10
  runtime.telemetry.select({ operation: job.operation, mode: () => "execute" });
11
- runtime.telemetry.annotate({ ...(job.origin ? { host_application: job.origin.host_application ?? "unknown" } : {}),
12
- ...(job.origin ? { creation_trace_id: job.origin.trace_id } : {}),
11
+ runtime.telemetry.annotate({ ...(job.origin ? {
12
+ host_application: job.origin.host_application ?? "unknown",
13
+ host_application_source: job.origin.host_application_source ?? "unknown",
14
+ ...(job.origin.host_connector_version ? { host_connector_version: job.origin.host_connector_version } : {}),
15
+ creation_trace_id: job.origin.trace_id
16
+ } : {}),
13
17
  account_id: job.state.account?.id, organization_id: job.state.organization.id,
14
18
  parameters: { ...job.input }, execution_mode: "async" });
15
19
  let completion = { outcome: "success" };