// 辨識「驗證類」指令(測試、型別檢查、build),失敗後轉成功才值得角色反應 const VERIFY: RegExp[] = [ /^(?:bun|npm|pnpm|yarn)\s+(?:run\s+)?(?:test|build|typecheck|lint)\b/, /^(?:bun|npm|pnpm|yarn)\s+test\b/, /^(?:pytest|tsc|vitest|jest|mypy|ruff)\b/, /^cargo\s+(?:test|build|check)\b/, /^go\s+(?:test|build|vet)\b/, ] // 以 && ; | 拆開複合指令,任何一段是驗證指令就算 export function isVerifyCommand(command: string): boolean { return command .split(/&&|\|\||;|\|/) .map(s => s.trim()) .some(s => VERIFY.some(re => re.test(s))) }