feat(paths): add agenthub path helpers
This commit is contained in:
parent
2b5696de82
commit
b3dea07352
27
src/core/paths.ts
Normal file
27
src/core/paths.ts
Normal 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
17
tests/paths.test.ts
Normal 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'));
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user