feat(paths): add agenthub path helpers

This commit is contained in:
chahinebrini 2026-06-24 23:30:15 +02:00
parent 2b5696de82
commit b3dea07352
2 changed files with 44 additions and 0 deletions

27
src/core/paths.ts Normal file
View File

@ -0,0 +1,27 @@
import { join } from 'path';
export type EntityType = 'tasks' | 'handoffs' | 'decisions' | 'memory' | 'status';
export function getAgentHubDir(cwd: string = process.cwd()): string {
return join(cwd, '.agenthub');
}
export function getEntityDir(cwd: string, type: EntityType): string {
return join(getAgentHubDir(cwd), type);
}
export function getCounterPath(cwd: string): string {
return join(getAgentHubDir(cwd), '.counter.json');
}
export function getConfigPath(cwd: string): string {
return join(getAgentHubDir(cwd), 'agenthub.config.json');
}
export function getIndexPath(cwd: string): string {
return join(getAgentHubDir(cwd), '.index.sqlite');
}
export function getStatusPath(cwd: string): string {
return join(getEntityDir(cwd, 'status'), 'latest.md');
}

17
tests/paths.test.ts Normal file
View File

@ -0,0 +1,17 @@
import { describe, it, expect } from 'vitest';
import { tmpdir } from 'os';
import { join } from 'path';
import { getAgentHubDir, getEntityDir, getCounterPath, getConfigPath, getIndexPath } from '../src/core/paths.js';
describe('paths', () => {
const cwd = tmpdir();
it('returns .agenthub directory relative to cwd', () => {
expect(getAgentHubDir(cwd)).toBe(join(cwd, '.agenthub'));
});
it('returns entity directories', () => {
expect(getEntityDir(cwd, 'tasks')).toBe(join(cwd, '.agenthub', 'tasks'));
expect(getEntityDir(cwd, 'memory')).toBe(join(cwd, '.agenthub', 'memory'));
});
});