import { readArtifact } from "./artifacts.ts"; import { updatePhaseArtifact } from "./state.ts"; import type { ActiveRun } from "./types.ts"; export function shouldAutoRecordQuestionAnswer(text: string): boolean { const trimmed = text.trim(); if (!trimmed || trimmed.startsWith("/")) return false; if (trimmed.length > 300) return false; if (/[??]/.test(trimmed)) return false; if (/(并|然后|同时|顺便|接着|继续|实现|修改|修复|写代码|编码|提交|发布|push)/i.test(trimmed)) return false; if (/^(先|暂停|等等|不用|不要|继续|开始|实现|修改|修复|提交|push|发布)\b/i.test(trimmed)) return false; if (/^(先|暂停|等等|不用|不要|继续|开始|实现|修改|修复|提交|发布)/.test(trimmed)) return false; return true; } export function appendQuestionEventToArtifact(cwd: string, run: ActiveRun, lines: string[]): void { const existing = readArtifact(cwd, run, run.phase) ?? ""; const section = ["", "## Harness 问题", "", ...lines, ""].join("\n"); updatePhaseArtifact(cwd, run, run.phase, existing.includes("## Harness 问题") ? `${existing.trimEnd()}\n${lines.join("\n")}\n` : `${existing.trimEnd()}${section}`); }