保留工作流节点开通测试环境选项

- 增加可选 --is-test 配置并路由到测试 Piper
- 默认仍使用标准 Piper,dry-run 与结果显示所选环境
- 更新命令帮助、Skill 与接口目录
This commit is contained in:
gitea committed 2026-11-05 12:10:00 +08:00
1 parent e562ae9227
commit e58841e164
13 files changed
+56 -13

No files matched your search

+2 -1
View File
@@ -286,6 +286,7 @@ export const COMMAND_METADATA: Record<string, CliCommandMetadata> = {
"--parent=<executionId> 展开循环/分支子节点",
"--logs=<executionId> 查看节点执行日志",
"--dry-run 只预览写操作",
"--is-test 使用测试 Piper 环境",
"--yes/--confirm 确认写操作"
],
"aliases": [
@@ -334,7 +335,7 @@ export const COMMAND_METADATA: Record<string, CliCommandMetadata> = {
"url": "link",
"web": "link"
},
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail json none once publish snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c choose-serialization code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs n name node node-id nodeId nodes output output-file outputFile p page page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId seconds set size sleep-time sleepTime snapshot1 snapshot2 snapshotA snapshotB source start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail is-test json none once publish snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c choose-serialization code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs n name node node-id nodeId nodes output output-file outputFile p page page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId seconds set size sleep-time sleepTime snapshot1 snapshot2 snapshotA snapshotB source start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
},
"bill": {
"summary": "单据检索、表单规格诊断与审批动作",
@@ -12,7 +12,12 @@ test("node grant previews without a gateway call and requires explicit confirmat
expect(JSON.parse(result.stdout).dryRun).toBe(true);
expect(JSON.parse(result.stdout).changes.nodes).toEqual(["code-js2"]);
expect(grant).not.toHaveBeenCalled();
const testPreview = await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code", "--is-test", "--dry-run", "--yes"]), runtime);
expect(JSON.parse(testPreview.stdout).changes.isTest).toBe(true);
expect(grant).not.toHaveBeenCalled();
await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code-js2", "--confirm"]), runtime);
expect(grant).toHaveBeenCalledTimes(1);
await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code", "--is-test", "--yes"]), runtime);
expect(grant).toHaveBeenLastCalledWith(expect.anything(), expect.objectContaining({ nodes: ["code"], isTest: true }));
} finally { grant.mockRestore(); }
});
+7 -3
View File
@@ -1,6 +1,6 @@
import { getWorkflowAvailableNodes, grantWorkflowNodes } from "../../../domains/platform/workflow/services.js";
import { GRAY_NODES_CATALOG, findGrayNode } from "../../../domains/platform/workflow/nodes/gray-nodes-catalog.js";
import { stringOption } from "../../parser.js";
import { booleanOption, stringOption } from "../../parser.js";
import { printJson, printTable, printKeyValue } from "../../printer.js";
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
@@ -134,9 +134,11 @@ export async function handleGrantNodes(
}
requireMutationConfirmation(parsed, runtime, "开通企业工作流灰度节点", "hose-use workflow nodes grant <type...> --yes");
const isTest = booleanOption(parsed.options, ["is-test"]);
if (isDryRun(parsed, runtime)) {
return mutationPreview(parsed, runtime, "开通企业工作流灰度节点", corp.corpId || corp.credentials.corpId || corp.id, {
nodes: targetNodes.map(node => findGrayNode(node)?.type || node.trim()),
isTest,
adminPasswordRequired: Boolean(process.env.HOSE_ADMIN_PASSWORD),
});
}
@@ -146,6 +148,7 @@ export async function handleGrantNodes(
const result = await grantWorkflowNodes(corp, {
nodes: targetNodes,
password,
isTest,
});
if (runtime.jsonMode) {
@@ -156,16 +159,17 @@ export async function handleGrantNodes(
};
}
if (!result.success) {
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "网关拒绝了开通请求"}\n`, exitCode: 1 };
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "Piper 拒绝了开通请求"}\n`, exitCode: 1 };
}
const lines = [
`====== 灰度节点开通结果 [${corp.name}] ======`,
printKeyValue({
"申请开通节点": targetNodes.join(", "),
"Piper 环境": result.isTest ? "测试 Piper" : "标准 Piper",
"新开通成功": result.saved.length ? result.saved.join(", ") : "无 (已处于开通状态)",
"跳过(已开通)": result.skipped.length ? result.skipped.join(", ") : "无",
"网关反馈": result.rawMessage || "处理成功",
"Piper 反馈": result.rawMessage || "处理成功",
}),
"",
"✅ 节点权限已生效!工作流设计器与 hose-use workflow analyze 将立即支持该节点。",
+2 -1
View File
@@ -89,12 +89,13 @@ export async function handleNodeCommand(
"",
"子命令 (企业灰度节点级别):",
" nodes [list] [--all] 列出当前企业已开通的节点字典 (别名: probe, catalog)",
" nodes grant <type...> 为当前企业开通灰度节点",
" nodes grant <type...> [--is-test] 为当前企业开通灰度节点",
"",
"示例:",
" hose-use workflow nodes",
" hose-use workflow nodes --all",
" hose-use workflow nodes grant code-js2",
" hose-use workflow nodes grant code-js2 --is-test",
" hose-use workflow node list 896398895352487950",
].join("\n") + "\n",
exitCode: 1,