Files
HaBraid/src/vault/log.ts
Contributor 5d5336757d feat: HaBraid v0.1.0 — host-following memory visualization engine for Obsidian
- Hybrid BM25 + HNSW vector search with context enrichment
- Knowledge graph with entities, relations, and community detection
- Host-following LLM route with fallback backends
- 3-tier lint system (static + HNSW dup + contradiction detection)
- Q&A Synthesis (Karpathy LLM Wiki pattern)
- 16 MCP tools for agent-driven workflows
- Incremental wiki generation with checkpointing
- SQLite-backed item store with FTS5 + vector indexes
2026-04-18 15:46:42 +09:00

41 lines
1.3 KiB
TypeScript

import path from "node:path";
import type { SyncLogEntry } from "../types.js";
import { parseFrontmatter, stringifyFrontmatter, writeTextFile } from "../utils.js";
/**
* Appends structured entries to `log.md`.
*
* @param vaultPath Vault root path.
* @param entries Entries to append.
*/
export async function appendSyncLog(vaultPath: string, entries: SyncLogEntry[]): Promise<void> {
try {
const filePath = path.join(vaultPath, "log.md");
const { readFile } = await import("node:fs/promises");
let existing = "";
try {
existing = await readFile(filePath, "utf8");
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
throw error;
}
}
const parsed = existing
? parseFrontmatter(existing)
: {
data: { type: "log" },
content: "# Sync Log\n\n| 시간 | 작업 | 대상 | 결과 |\n|------|------|------|------|\n",
};
const rows = entries.map((entry) => `| ${entry.time} | ${entry.action} | ${entry.target} | ${entry.result} |`);
const body = `${parsed.content.trimEnd()}\n${rows.join("\n")}\n`;
const markdown = stringifyFrontmatter(body, parsed.data as Record<string, unknown>);
await writeTextFile(filePath, markdown);
} catch (error) {
throw error instanceof Error ? error : new Error(String(error));
}
}