From b3dea07352cb01abb034a9c806536410d8f8a0f7 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Wed, 24 Jun 2026 23:30:15 +0200 Subject: [PATCH] feat(paths): add agenthub path helpers --- src/core/paths.ts | 27 +++++++++++++++++++++++++++ tests/paths.test.ts | 17 +++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/core/paths.ts create mode 100644 tests/paths.test.ts diff --git a/src/core/paths.ts b/src/core/paths.ts new file mode 100644 index 0000000..c437ea4 --- /dev/null +++ b/src/core/paths.ts @@ -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'); +} diff --git a/tests/paths.test.ts b/tests/paths.test.ts new file mode 100644 index 0000000..d720312 --- /dev/null +++ b/tests/paths.test.ts @@ -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')); + }); +});