import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { mkdtempSync, rmSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { getNextId } from '../src/core/counter.js'; describe('counter', () => { let cwd: string; beforeEach(() => { cwd = mkdtempSync(join(tmpdir(), 'agenthub-')); }); afterEach(() => { rmSync(cwd, { recursive: true, force: true }); }); it('generates sequential task ids', () => { expect(getNextId(cwd, 'task')).toBe('TSK-0001'); expect(getNextId(cwd, 'task')).toBe('TSK-0002'); }); it('keeps counters separate by type', () => { expect(getNextId(cwd, 'handoff')).toBe('HOF-0001'); expect(getNextId(cwd, 'task')).toBe('TSK-0001'); expect(getNextId(cwd, 'handoff')).toBe('HOF-0002'); }); });