## Path Changes - audit.log: memory/audit.log → log/audit.log - projects.json: memory/projects.json → projects/projects.json - prompts: roles/<project>/<role>.md → projects/prompts/<project>/<role>.md ## Files Updated - lib/audit.ts - new audit log path - lib/projects.ts - new projects.json path - lib/dispatch.ts - new prompt instructions path - lib/tools/project-register.ts - prompt scaffolding path - lib/setup/workspace.ts - workspace scaffolding paths - lib/context-guard.ts - projects.json path - lib/tools/setup.ts - tool description - lib/templates.ts - AGENTS.md template path references ## Documentation Updated - README.md - docs/ARCHITECTURE.md - docs/ONBOARDING.md - docs/QA_WORKFLOW.md - docs/ROADMAP.md - docs/TESTING.md Addresses issue #121
30 lines
895 B
TypeScript
30 lines
895 B
TypeScript
/**
|
|
* Append-only NDJSON audit logging.
|
|
* Every tool call automatically logs — no manual action needed from agents.
|
|
*/
|
|
import { appendFile, mkdir } from "node:fs/promises";
|
|
import { join, dirname } from "node:path";
|
|
|
|
export async function log(
|
|
workspaceDir: string,
|
|
event: string,
|
|
data: Record<string, unknown>,
|
|
): Promise<void> {
|
|
const filePath = join(workspaceDir, "log", "audit.log");
|
|
const entry = JSON.stringify({
|
|
ts: new Date().toISOString(),
|
|
event,
|
|
...data,
|
|
});
|
|
try {
|
|
await appendFile(filePath, entry + "\n");
|
|
} catch (err: unknown) {
|
|
// If directory doesn't exist, create it and retry
|
|
if ((err as NodeJS.ErrnoException).code === "ENOENT") {
|
|
await mkdir(dirname(filePath), { recursive: true });
|
|
await appendFile(filePath, entry + "\n");
|
|
}
|
|
// Audit logging should never break the tool — silently ignore other errors
|
|
}
|
|
}
|