import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { mkdtempSync, rmSync, existsSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { generateStatus } from '../src/core/status.js'; import { writeEntity } from '../src/core/files.js'; import { getEntityDir } from '../src/core/paths.js'; import { init } from '../src/cli/commands/init.js'; import { createAsk } from '../src/core/services/askService.js'; describe('status', () => { let cwd: string; beforeEach(() => { cwd = mkdtempSync(join(tmpdir(), 'agenthub-')); }); afterEach(() => { rmSync(cwd, { recursive: true, force: true }); }); it('generates a status file', () => { init(cwd, { projectName: 'status-test', yes: true }); const taskDir = getEntityDir(cwd, 'tasks'); writeEntity(join(taskDir, 'TSK-0001.md'), { id: 'TSK-0001', title: 'Open task', status: 'open', createdAt: '2026-06-24T10:00:00Z', updatedAt: '2026-06-24T10:00:00Z' }, 'desc'); const status = generateStatus(cwd); expect(status.activeTasks).toContain('TSK-0001'); expect(existsSync(join(cwd, '.agenthub', 'status', 'latest.md'))).toBe(true); }); it('surfaces pending Ask ids, count and oldest age as an urgent summary', () => { init(cwd, { projectName: 'status-test', yes: true }); createAsk(cwd, { from: 'codex', to: 'claude', question: 'Need a decision' }); const status = generateStatus(cwd); expect(status.pendingAsks).toEqual(['ASK-0001']); expect(status.oldestAskAgeSec).toBeTypeOf('number'); expect(status.summary).toContain('Pending asks: 1 (ASK-0001)'); expect(status.summary).toContain('architect action required'); }); });