feat: 完善工作流工具链与大结果保护
- 工作流节点描述增加服务端托管黑名单,仅代码节点保留自定义 desc - 工作流保存新增 --in-place,并改进版本冲突提示 - platform records 新增 --page 分页,--all 强制走 ndjson 文件流 - platform schema 展示 ownerId/submitterId 等系统字段 - 更新 Agent Skill 的代码节点 agent use 标记规范 - 补充对应测试与文档
This commit is contained in:
1 parent
37643da254
commit
7423e166a1
10 files changed
+123
-20
No files matched your search
@@ -14,7 +14,7 @@ import { createClientsForCorp, createPiperClientForCorp } from "../../helpers.js
|
||||
import { printJson } from "../../printer.js";
|
||||
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
import { PLATFORM_ID_OPTION_KEYS } from "./shared.js";
|
||||
import { PLATFORM_ID_OPTION_KEYS, formatWorkflowVersion } from "./shared.js";
|
||||
|
||||
export async function handlePatch(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
|
||||
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipelineId"]);
|
||||
@@ -78,7 +78,7 @@ export async function handleSave(parsed: CliParsedArgs, runtime: CliRuntime): Pr
|
||||
if (!pipelineId || !file) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: "用法: hose-use workflow save <pipelineId> --file=<workflow.json> [--force-write]\n",
|
||||
stderr: "用法: hose-use workflow save <pipelineId> --file=<workflow.json> [--force-write] [--in-place]\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
@@ -96,6 +96,7 @@ export async function handleSave(parsed: CliParsedArgs, runtime: CliRuntime): Pr
|
||||
}
|
||||
|
||||
const forceWrite = booleanOption(parsed.options, ["force-write", "forceWrite"]);
|
||||
const syncFile = booleanOption(parsed.options, ["in-place", "inPlace"]);
|
||||
requireMutationConfirmation(
|
||||
parsed,
|
||||
runtime,
|
||||
@@ -105,8 +106,10 @@ export async function handleSave(parsed: CliParsedArgs, runtime: CliRuntime): Pr
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "保存工作流草稿到远端", pipelineId, {
|
||||
file,
|
||||
version: parsedWorkflow.version,
|
||||
tasksVersion: parsedWorkflow.tasksVersion,
|
||||
forceWrite,
|
||||
syncFile,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -124,28 +127,48 @@ export async function handleSave(parsed: CliParsedArgs, runtime: CliRuntime): Pr
|
||||
|
||||
if (!forceWrite && hasWorkflowVersionConflict(state, remote)) {
|
||||
throw new Error(
|
||||
`工作流版本已变化,拒绝覆盖:远端 tasksVersion=${remote.tasksVersion}, 文件 tasksVersion=${parsedWorkflow.tasksVersion}。确认来源后使用 --force-write。`
|
||||
`工作流版本已变化,拒绝覆盖:远端 tasksVersion=${remote.tasksVersion}, 文件 tasksVersion=${parsedWorkflow.tasksVersion}。请重新导出最新工作流后再改;后续保存可加 --in-place 自动同步本地文件版本。确认要覆盖时使用 --force-write。`
|
||||
);
|
||||
}
|
||||
|
||||
state = beginWorkflowSave(state);
|
||||
const localWorkflowForSync = state.workflow;
|
||||
try {
|
||||
const payload = state.workflow.inputs?.length
|
||||
? state.workflow
|
||||
: { ...state.workflow, inputs: [{ key: "$platformId", value: platformId }] };
|
||||
const saved = await updateWorkflow(piperClient, payload);
|
||||
state = commitWorkflowSave(state, saved);
|
||||
let fileSynced = false;
|
||||
let fileSyncWarning = "";
|
||||
if (syncFile) {
|
||||
try {
|
||||
const syncedWorkflow = {
|
||||
...localWorkflowForSync,
|
||||
version: saved.version,
|
||||
tasksVersion: saved.tasksVersion,
|
||||
updateTime: saved.updateTime,
|
||||
};
|
||||
writeFileSync(file, `${JSON.stringify(syncedWorkflow, null, 2)}\n`, "utf8");
|
||||
fileSynced = true;
|
||||
} catch (error) {
|
||||
fileSyncWarning = `本地文件同步失败: ${error instanceof Error ? error.message : String(error)}`;
|
||||
}
|
||||
}
|
||||
const result = {
|
||||
success: true,
|
||||
pipelineId,
|
||||
status: state.status,
|
||||
version: saved.version,
|
||||
tasksVersion: saved.tasksVersion,
|
||||
updateTime: saved.updateTime,
|
||||
fileSynced,
|
||||
...(fileSyncWarning ? { fileSyncWarning } : {}),
|
||||
};
|
||||
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
|
||||
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: fileSyncWarning, exitCode: 0 };
|
||||
return {
|
||||
stdout: `✅ 工作流 [${pipelineId}] 草稿保存成功,tasksVersion=${saved.tasksVersion}。\n`,
|
||||
stderr: "",
|
||||
stdout: `✅ 工作流 [${pipelineId}] 草稿保存成功:${formatWorkflowVersion(saved)}。${fileSynced ? "\n📝 已同步更新本地文件。" : ""}${fileSyncWarning ? `\n⚠️ ${fileSyncWarning}` : ""}\n`,
|
||||
stderr: fileSyncWarning,
|
||||
exitCode: 0,
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user