@actiondock/builder 2.11.0 → 2.13.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.
@@ -141,6 +141,8 @@ if (argv.includes("-h") || argv.includes("--help") || argv[0] === "help") {
141
141
  console.log(" <cmd> list [--json] List available actions");
142
142
  console.log(" <cmd> describe <id> [--json] Show action details and schemas");
143
143
  console.log(" <cmd> run <id> [--input '<json>'] Execute action with JSON input");
144
+ console.log(" <cmd> run <id> [--stdin-field <field>] [-- <assignments...>]");
145
+ console.log(" Bind raw stdin text to an input field");
144
146
  console.log(" <cmd> config list/get/set/delete Manage package configuration");
145
147
  console.log(" <cmd> state list/get/set/delete Manage shared state store");
146
148
  console.log("\\nGlobal options:");
@@ -54,6 +54,35 @@ Playbook SOPs 为复杂业务任务提供逐步指导规程。详细规程请查
54
54
  ${list}
55
55
  `;
56
56
  }
57
+ /**
58
+ * 渲染「执行 Action」调用指引正文:三处生成器共用同一决策原则,
59
+ * 承载输入模式选择(扁平赋值与 --input-file)与输出模式选择(默认原始输出与按需 --json)。
60
+ */
61
+ function renderInvocationGuidance(describeCmd, runCmd) {
62
+ return `推荐在执行前调用 describe 命令调阅确切参数契约:
63
+
64
+ \`\`\`bash
65
+ # 调阅参数契约与建议赋值样例
66
+ ${describeCmd}
67
+
68
+ # 调用语法格式(其中 ASSIGNMENT 根据 describe 查阅的参数契约提供)
69
+ ${runCmd} -- ASSIGNMENT...
70
+
71
+ # 管道原始文本绑定(FIELD 为 describe 查阅的字符串字段名)
72
+ printf '整段原始文本' | ${runCmd} --stdin-field FIELD
73
+ \`\`\`
74
+
75
+ 输入模式选择(原有三种输入方式严格互斥,仅选其一;\`--stdin-field\` 原始文本绑定可与扁平赋值组合):
76
+
77
+ - 扁平赋值为默认首选:参数项少且结构简单时,直接以 \`-- key="value" count:=10\` 形式内联传递。
78
+ - 文件输入用于复杂参数:当参数含深层嵌套结构、大段文本或内容易被终端引号转义破坏时,将完整 JSON 写入文件并通过 \`--input-file input.json\` 传递。
79
+ - 管道原始文本绑定:当只需向单个字符串字段(如 text、content、csv、diff)传入整段原始文本时,使用 \`--stdin-field <field>\` 绑定 stdin 正文,正文保持原样不解析类型,可与扁平赋值补充其他字段。
80
+
81
+ 输出模式选择(避免浪费上下文 token):
82
+
83
+ - 默认不加 \`--json\`:stdout 直接输出业务返回正文,保留原生格式与真实换行,绝大多数调用直接阅读正文即可推进后续步骤。
84
+ - 仅在需要结构化提取时才追加 \`--json\`:如需按 \`error.code\` 判定自愈策略、以 \`runId\` 关联追踪或程序化消费完整字段时,才使用 JSON 信封输出(格式见下节)。`;
85
+ }
57
86
  /**
58
87
  * 渲染「结构化响应解析」小节:三处生成器共用同一 JSON 信封代码块,
59
88
  * 仅首行名词与 stdout/stderr 描述行随变体分化。
@@ -67,9 +96,9 @@ function renderJsonEnvelopeSection(wording, options) {
67
96
  const descriptionBlock = options?.withDescriptions === false
68
97
  ? ""
69
98
  : `\n\n${stdoutLine}\n- \`stderr\`:执行日志与诊断${stderrTail}信息。`;
70
- return `### 结构化响应解析
99
+ return `### 结构化响应解析(--json 模式)
71
100
 
72
- 所有 Action 执行结果均在 \`stdout\` 输出标准格式的 JSON ${noun}:
101
+ 仅当调用时显式追加 \`--json\` 选项,\`stdout\` 才输出标准 JSON ${noun};默认不加该选项时直接输出业务正文:
73
102
 
74
103
  \`\`\`json
75
104
  // 执行成功响应 (ok 为 true)
@@ -104,7 +133,7 @@ export function renderRuntimeReferenceContent(options) {
104
133
  \`\`\`bash
105
134
  ${options.entryRelPath || "node ./entry.mjs"} list
106
135
  ${options.entryRelPath || "node ./entry.mjs"} describe <action-id>
107
- ${options.entryRelPath || "node ./entry.mjs"} run <action-id> --json --input-file input.json
136
+ ${options.entryRelPath || "node ./entry.mjs"} run <action-id> -- ASSIGNMENT...
108
137
  \`\`\`
109
138
 
110
139
  若宿主环境已全局安装 \`ad\`,亦可将其链接后统一调度。`
@@ -214,21 +243,7 @@ ad describe ${pkgId}/${firstAction}
214
243
 
215
244
  为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID。
216
245
 
217
- 推荐在执行前调用 describe 命令调阅确切参数契约:
218
-
219
- \`\`\`bash
220
- # 调阅参数契约与建议赋值样例
221
- ad describe ${pkgId}/${firstAction}
222
-
223
- # 调用语法格式(其中 ASSIGNMENT 根据 ad describe 查阅的参数契约提供)
224
- ad run ${pkgId}/${firstAction} --json -- ASSIGNMENT...
225
- \`\`\`
226
-
227
- 将参数写入 JSON 文件并通过 --input-file 传递:
228
-
229
- \`\`\`bash
230
- ad run ${pkgId}/${firstAction} --json --input-file input.json
231
- \`\`\`
246
+ ${renderInvocationGuidance(`ad describe ${pkgId}/${firstAction}`, `ad run ${pkgId}/${firstAction}`)}
232
247
 
233
248
  ${renderJsonEnvelopeSection("envelope")}
234
249
  ${playbookSection}
@@ -282,21 +297,7 @@ ${binaryRelPath} describe ${firstAction}
282
297
 
283
298
  ### 执行 Action
284
299
 
285
- 推荐在执行前调用 describe 命令调阅确切参数契约:
286
-
287
- \`\`\`bash
288
- # 调阅参数契约与建议赋值样例
289
- ${binaryRelPath} describe ${firstAction}
290
-
291
- # 调用语法格式(其中 ASSIGNMENT 根据 describe 查阅的参数契约提供)
292
- ${binaryRelPath} run ${firstAction} --json -- ASSIGNMENT...
293
- \`\`\`
294
-
295
- 将参数写入 JSON 文件并通过 --input-file 传递:
296
-
297
- \`\`\`bash
298
- ${binaryRelPath} run ${firstAction} --json --input-file input.json
299
- \`\`\`
300
+ ${renderInvocationGuidance(`${binaryRelPath} describe ${firstAction}`, `${binaryRelPath} run ${firstAction}`)}
300
301
 
301
302
  ${renderJsonEnvelopeSection("result")}
302
303
  ${playbookSection}
@@ -397,21 +398,7 @@ ${playbookEntries.join("\n")}
397
398
  : "";
398
399
  const sInvoke = `## 标准调用命令
399
400
 
400
- 推荐在执行前调用 describe 命令调阅确切参数契约:
401
-
402
- \`\`\`bash
403
- # 调阅参数契约与建议赋值样例
404
- ad describe ${sampleActionId}
405
-
406
- # 调用语法格式(其中 ASSIGNMENT 根据 ad describe 查阅的参数契约提供)
407
- ad run ${sampleActionId} --json -- ASSIGNMENT...
408
- \`\`\`
409
-
410
- 将参数写入 JSON 文件并通过 --input-file 传递:
411
-
412
- \`\`\`bash
413
- ad run ${sampleActionId} --json --input-file input.json
414
- \`\`\`
401
+ ${renderInvocationGuidance(`ad describe ${sampleActionId}`, `ad run ${sampleActionId}`)}
415
402
 
416
403
  ${renderJsonEnvelopeSection("envelope", { withDescriptions: false })}`;
417
404
  const sTroubleshooting = renderTroubleshootingSection(RUNTIME_REFERENCE_REL_PATH);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actiondock/builder",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "ActionDock Build Planner, distribution packaging, and Skill exporter",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -29,8 +29,8 @@
29
29
  "test": "node ../../scripts/run-tests.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@actiondock/core": "^2.11.0",
33
- "@actiondock/sdk": "^2.11.0"
32
+ "@actiondock/core": "^2.13.0",
33
+ "@actiondock/sdk": "^2.13.0"
34
34
  },
35
35
  "keywords": [
36
36
  "actiondock",