Files
aetheel-2/src/markdown-config-loader.ts

49 lines
1.5 KiB
TypeScript

import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
export interface MarkdownConfigs {
/** CLAUDE.md — persona: identity, soul, user context, tools (all in one) */
persona: string | null;
/** agents.md — operating rules, cron jobs, hooks (parsed by gateway) */
agents: string | null;
/** memory.md — long-term memory (agent-writable) */
memory: string | null;
}
export class MarkdownConfigLoader {
async loadAll(configDir: string): Promise<MarkdownConfigs> {
const configs: MarkdownConfigs = {
persona: null,
agents: null,
memory: null,
};
// CLAUDE.md — main persona file
configs.persona = await this.loadFile(configDir, "CLAUDE.md");
if (!configs.persona) {
console.warn("Warning: CLAUDE.md not found in " + configDir);
}
// agents.md — parsed by gateway for cron/hooks, also included in prompt
configs.agents = await this.loadFile(configDir, "agents.md");
// memory.md — agent-writable long-term memory
configs.memory = await this.loadFile(configDir, "memory.md");
if (!configs.memory) {
const defaultContent = "# Memory\n";
await writeFile(join(configDir, "memory.md"), defaultContent, "utf-8");
configs.memory = defaultContent;
}
return configs;
}
async loadFile(configDir: string, filename: string): Promise<string | null> {
try {
return await readFile(join(configDir, filename), "utf-8");
} catch {
return null;
}
}
}