#!/usr/bin/env node /** * Phase 2: run v1.49 agent integration tests for DeepSeek/Kimi reasoning preservation. */ import fs from 'node:fs'; import path from 'node:path'; import { spawnSync } from 'node:child_process'; import { fileURLToPath } from 'node:url'; const memindRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); const v149Root = process.env.GOOSED_V149_ROOT || '/Users/john/Project/tkmind_go-v149'; const THINKING_TESTS = [ 'test_deepseek_thinking_preserved_in_tool_call_message', 'test_kimi_thinking_preserved_in_tool_call_message', 'test_reasoning_preserved_when_combined_with_tool_call', 'test_multi_tool_response_preserves_reasoning_and_message_id_correlation', ]; function runTest(testName) { const result = spawnSync( 'cargo', ['test', '--test', 'agent', testName, '--quiet', '--', '--nocapture'], { cwd: v149Root, encoding: 'utf8', env: process.env, }, ); const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim(); const passed = /test result: ok\. 1 passed/.test(output); return { testName, ok: result.status === 0 && passed, output: output.split('\n').slice(-4).join('\n') }; } function main() { if (!fs.existsSync(v149Root)) { throw new Error(`missing v1.49 worktree: ${v149Root}`); } const results = THINKING_TESTS.map(runTest); const failed = results.filter((item) => !item.ok); if (failed.length) { const detail = failed.map((item) => `${item.testName}:\n${item.output}`).join('\n\n'); throw new Error(`thinking preservation tests failed:\n${detail}`); } const outputDir = path.join(memindRoot, 'docs', 'baselines'); fs.mkdirSync(outputDir, { recursive: true }); const evidencePath = path.join(outputDir, 'goose-v149-thinking-preservation-latest.json'); fs.writeFileSync( evidencePath, `${JSON.stringify({ schemaVersion: 'goose-v149-thinking-preservation-v1', capturedAt: new Date().toISOString(), worktree: v149Root, tests: results.map((item) => item.testName), passed: results.length, }, null, 2)}\n`, 'utf8', ); console.log(`GOOSE_V149_THINKING_PRESERVATION_OK: ${results.length} tests passed`); console.log(` evidence=${evidencePath}`); } try { main(); } catch (error) { console.error(`GOOSE_V149_THINKING_PRESERVATION_FAIL: ${error.message}`); process.exit(1); }