From c3e66d1a3bb9d671ebf1dab990128f2662a678d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 23:02:29 -0400 Subject: [PATCH] fix(task-quality-gates): add zh keywords and word-boundary capabilities trim --- src/main/task-quality-gates.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/task-quality-gates.ts b/src/main/task-quality-gates.ts index 046bed7b..3d98c0d0 100644 --- a/src/main/task-quality-gates.ts +++ b/src/main/task-quality-gates.ts @@ -45,6 +45,17 @@ export const ACCEPTANCE_CRITERIA_KEYWORDS: readonly string[] = [ "deliverable:", "expected outcome", "exit criteria", + // Chinese equivalents so zh-locale task descriptions are not rejected + // for lacking English keywords. + "验收标准", + "完成标准", + "成功标准", + "交付物", + "交付要求", + "完成条件", + "预期结果", + "需求:", + "要求:", ]; @@ -149,10 +160,23 @@ export function checkCapabilityMatch( // Agent has capabilities but no overlap — warn return { matched: false, - warning: `Agent "${agent.name}" may lack skills for this task. Their capabilities (${agent.capabilities.slice(0, 80)}...) have no overlap with the task description. Consider reassigning.`, + warning: `Agent "${agent.name}" may lack skills for this task. Their capabilities (${truncateAtWordBoundary(agent.capabilities, 80)}...) have no overlap with the task description. Consider reassigning.`, }; } +/** Truncate `text` at or before `maxLength`, preferring the last whitespace + * boundary so the warning does not cut mid-word. Falls back to hard slice + * when a single token exceeds `maxLength`. */ +function truncateAtWordBoundary(text: string, maxLength: number): string { + if (text.length <= maxLength) return text; + const slice = text.slice(0, maxLength); + const lastSpace = slice.search(/\s\S*$/); + if (lastSpace > maxLength * 0.5) { + return slice.slice(0, lastSpace); + } + return slice; +} + export const REVIEW_TIMEOUT_MS = 30 * 60 * 1000; // 30 minutes (D-08)