From ed728b2ad9a903c6e4723f8ea94b34ed2e113a15 Mon Sep 17 00:00:00 2001 From: jiayiyan <43424880@qq.com> Date: Mon, 18 May 2026 16:41:37 +0800 Subject: [PATCH] refactor: fix exit-1 comment, remove JSON round-trip, use OfficeMeta cast --- templates/document-editor/src/moderator.ts | 4 ++-- workflows/adapters/differ-adapter.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/document-editor/src/moderator.ts b/templates/document-editor/src/moderator.ts index 9544aa2..11492d2 100644 --- a/templates/document-editor/src/moderator.ts +++ b/templates/document-editor/src/moderator.ts @@ -1,5 +1,5 @@ import { END, type ModeratorCondition, type ModeratorTable, START } from "@uncaged/workflow-runtime"; -import type { DocumentEditorMeta } from "./roles.js"; +import type { DocumentEditorMeta, OfficeMeta } from "./roles.js"; const officeIsEdit: ModeratorCondition = { name: "officeIsEdit", @@ -7,7 +7,7 @@ const officeIsEdit: ModeratorCondition = { check: (ctx) => { const officeStep = ctx.steps.find((s) => s.role === "office"); if (officeStep === undefined) return false; - return (officeStep.meta as { mode: string }).mode === "edit"; + return (officeStep.meta as OfficeMeta).mode === "edit"; }, }; diff --git a/workflows/adapters/differ-adapter.ts b/workflows/adapters/differ-adapter.ts index 497c0ce..6d344ae 100644 --- a/workflows/adapters/differ-adapter.ts +++ b/workflows/adapters/differ-adapter.ts @@ -37,6 +37,7 @@ export function createDifferAdapter( if (!result.ok) { const e = result.error; if (e.kind === "non_zero_exit" && e.exitCode === 1) { + // docx-diff exits 1 when documents have differences — this is a success path } else if (e.kind === "non_zero_exit") { throw new Error(`differ: docx-diff failed (exit ${e.exitCode}): ${e.stderr}`); } else if (e.kind === "timeout") { @@ -52,8 +53,7 @@ export function createDifferAdapter( throw new Error(`differ: report file not found: ${reportPath}`); } - const raw = JSON.stringify({ outputDocx, sourceDocx, diffReport: reportPath }); - const meta = schema.parse(JSON.parse(raw)) as T; + const meta = schema.parse({ outputDocx, sourceDocx, diffReport: reportPath }); return { meta, childThread: null }; }; }