mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-12 15:42:20 +02:00
feat: hook eval-store sync, use shared utils, add 30 lib tests
- eval-store.ts: import shared getGitInfo/getVersion, add pushEvalRun() hook in finalize() (non-blocking, non-fatal) - session-runner.ts: import shared atomicWriteSync/sanitizeForFilename - eval-store.test.ts: fix pre-existing bug in double-finalize test (was counting _partial file) - 30 new tests for lib/util, lib/sync-config, lib/sync Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+11
-17
@@ -12,6 +12,7 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { spawnSync } from 'child_process';
|
||||
import { getGitInfo as getGitInfoShared, getVersion as getVersionShared } from '../../lib/util';
|
||||
|
||||
const SCHEMA_VERSION = 1;
|
||||
const DEFAULT_EVAL_DIR = path.join(os.homedir(), '.gstack-dev', 'evals');
|
||||
@@ -345,26 +346,11 @@ export function formatComparison(c: ComparisonResult): string {
|
||||
// --- EvalCollector ---
|
||||
|
||||
function getGitInfo(): { branch: string; sha: string } {
|
||||
try {
|
||||
const branch = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { stdio: 'pipe', timeout: 5000 });
|
||||
const sha = spawnSync('git', ['rev-parse', '--short', 'HEAD'], { stdio: 'pipe', timeout: 5000 });
|
||||
return {
|
||||
branch: branch.stdout?.toString().trim() || 'unknown',
|
||||
sha: sha.stdout?.toString().trim() || 'unknown',
|
||||
};
|
||||
} catch {
|
||||
return { branch: 'unknown', sha: 'unknown' };
|
||||
}
|
||||
return getGitInfoShared();
|
||||
}
|
||||
|
||||
function getVersion(): string {
|
||||
try {
|
||||
const pkgPath = path.resolve(__dirname, '..', '..', 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
||||
return pkg.version || 'unknown';
|
||||
} catch {
|
||||
return 'unknown';
|
||||
}
|
||||
return getVersionShared();
|
||||
}
|
||||
|
||||
export class EvalCollector {
|
||||
@@ -469,6 +455,14 @@ export class EvalCollector {
|
||||
process.stderr.write(`\nCompare error: ${err.message}\n`);
|
||||
}
|
||||
|
||||
// Team sync: push eval result (non-fatal, non-blocking)
|
||||
try {
|
||||
const { pushEvalRun } = await import('../../lib/sync');
|
||||
pushEvalRun(result as unknown as Record<string, unknown>).then(ok => {
|
||||
if (ok) process.stderr.write('Synced eval to team store ✓\n');
|
||||
}).catch(() => { /* queued for retry */ });
|
||||
} catch { /* sync module not available — skip */ }
|
||||
|
||||
return filepath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user