From 6865d842af574624b2c4023c4705269cab14d93b Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Fri, 31 Jan 2025 10:23:08 +0200 Subject: [PATCH] fixed step output, fixed analyze plugin to work with reasoning model (#4810) Co-authored-by: DavertMik --- lib/output.js | 2 +- lib/plugin/analyze.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/output.js b/lib/output.js index 919764635..a551174ae 100644 --- a/lib/output.js +++ b/lib/output.js @@ -115,7 +115,7 @@ module.exports = { } } - let stepLine = step.toCliStyled() + let stepLine = step.toCliStyled ? step.toCliStyled() : step.toString() if (step.metaStep && outputLevel >= 1) { // this.stepShift += 2; stepLine = colors.dim(truncate(stepLine, this.spaceShift)) diff --git a/lib/plugin/analyze.js b/lib/plugin/analyze.js index e977d6351..77897bafc 100644 --- a/lib/plugin/analyze.js +++ b/lib/plugin/analyze.js @@ -2,6 +2,7 @@ const debug = require('debug')('codeceptjs:analyze') const { isMainThread } = require('node:worker_threads') const { arrowRight } = require('figures') const container = require('../container') +const store = require('../store') const ai = require('../ai') const colors = require('chalk') const ora = require('ora-classic') @@ -75,6 +76,7 @@ const defaultConfig = { * SUMMARY * CATEGORY + * URL * ERROR , , ... * STEP (use CodeceptJS format I.click(), I.see(), etc; if all failures happend on the same step) * SUITE , (if SUITE is present, and if all tests in the group have the same suite or suites) @@ -86,11 +88,6 @@ const defaultConfig = { x ... `, }, - { - role: 'assistant', - content: `## ' - `, - }, ] return messages }, @@ -137,6 +134,7 @@ const defaultConfig = { * ERROR , , ... * CATEGORY * STEPS + * URL Do not add any other sections or explanations. Only CATEGORY, SUMMARY, STEPS. ${config.vision ? 'Also a screenshot of the page is attached to the prompt.' : ''} @@ -338,12 +336,13 @@ function serializeTest(test) { } function formatResponse(response) { - if (!response.startsWith('##')) response = '## ' + response return response + .replace(/([\s\S]*?)<\/think>/g, store.debugMode ? colors.cyan('$1') : '') .split('\n') .map(line => line.trim()) .filter(line => !/^[A-Z\s]+$/.test(line)) .map(line => markdownToAnsi(line)) .map(line => line.replace(/^x /gm, ` ${colors.red.bold('x')} `)) .join('\n') + .trim() }