// Small helpers shared by the lab tests. import { mkdtemp, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import path from 'node:path'; import { after } from 'node:test'; import type { ToolContext } from '../../src/tools/tool.ts'; /** A temp folder that is deleted when the test file finishes. */ export async function tempDir(prefix = 'steward-test-'): Promise { const dir = await mkdtemp(path.join(tmpdir(), prefix)); after(() => rm(dir, { recursive: true, force: true })); return dir; } /** A clock that returns the same instant every time, and can be moved. */ export function fixedClock(iso: string): { now: () => Date; set: (iso: string) => void } { let current = new Date(iso); return { now: () => new Date(current), set: (next) => (current = new Date(next)) }; } export function toolContext(iso = '2026-11-22T15:00:00Z', timezone = 'UTC'): ToolContext { return { timezone, now: () => new Date(iso) }; }