UNPKG

@brianlovin/notion-skills

Version:

Sync agent skills from a Notion database to Claude Code, Codex, OpenCode, Cursor, Gemini CLI.

43 lines 1.49 kB
import { existsSync, lstatSync } from "node:fs"; import { readFile } from "node:fs/promises"; import { join } from "node:path"; import { hashLocalSkillDir } from "./skill-files.js"; export async function detectLocalState(manifest, contentRoot) { const drift = new Map(); const missingPageIds = new Set(); for (const [name, entry] of Object.entries(manifest.skills)) { const skillDir = join(contentRoot, name); const file = join(skillDir, "SKILL.md"); if (!existsSync(file)) { // Force a pull so users can recover by `rm`-ing a corrupt or unwanted // local copy. We don't try to diff a file that isn't there. missingPageIds.add(entry.page_id); continue; } if (entry.local_hash === undefined) { // Legacy manifest: no baseline → can't tell if edited. Skip. continue; } let currentHash; try { currentHash = await hashLocalSkillDir(skillDir); } catch { continue; } if (currentHash === entry.local_hash) continue; let mtime; let raw; try { mtime = lstatSync(file).mtime; raw = await readFile(file, "utf8"); } catch { continue; } drift.set(name, { name, pageId: entry.page_id, mtime, mdContent: raw }); } return { drift, missingPageIds }; } //# sourceMappingURL=local-state.js.map