MCPcopy
hub / github.com/zgsm-ai/costrict / copyConversationHistory

Function copyConversationHistory

packages/evals/src/cli/utils.ts:144–189  ·  view source on GitHub ↗
({
	rooTaskId,
	logDir,
	language,
	exercise,
	iteration,
	logger,
}: {
	rooTaskId: string
	logDir: string
	language: string
	exercise: string
	iteration: number
	logger: Logger
})

Source from the content-addressed store, hash-verified

142 * files for post-mortem analysis alongside the log files.
143 */
144export async function copyConversationHistory({
145 rooTaskId,
146 logDir,
147 language,
148 exercise,
149 iteration,
150 logger,
151}: {
152 rooTaskId: string
153 logDir: string
154 language: string
155 exercise: string
156 iteration: number
157 logger: Logger
158}): Promise<void> {
159 // VS Code extension global storage path within the container
160 const extensionStoragePath = "/roo/.vscode/User/globalStorage/zgsm-ai.zgsm"
161 const taskStoragePath = path.join(extensionStoragePath, "tasks", rooTaskId)
162
163 const filesToCopy = ["api_conversation_history.json", "ui_messages.json"]
164
165 for (const filename of filesToCopy) {
166 const sourcePath = path.join(taskStoragePath, filename)
167 // Use sanitized exercise name (replace slashes with dashes) for the destination filename
168 // Include iteration number to handle multiple attempts at the same exercise
169 const sanitizedExercise = exercise.replace(/\//g, "-")
170 const destFilename = `${language}-${sanitizedExercise}.${iteration}_${filename}`
171 const destPath = path.join(logDir, destFilename)
172
173 try {
174 // Check if source file exists
175 await fsp.access(sourcePath)
176
177 // Copy the file
178 await fsp.copyFile(sourcePath, destPath)
179 logger.info(`copied ${filename} to ${destPath}`)
180 } catch (error) {
181 // File may not exist if task didn't complete properly - this is not fatal
182 if ((error as NodeJS.ErrnoException).code === "ENOENT") {
183 logger.info(`${filename} not found at ${sourcePath} - skipping`)
184 } else {
185 logger.error(`failed to copy ${filename}:`, error)
186 }
187 }
188 }
189}
190
191/**
192 * Merge incoming tool usage with accumulated data using MAX strategy.

Callers 1

runTaskInVscodeFunction · 0.90

Calls 3

replaceMethod · 0.65
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected