${esc(c.title)}
${esc(c.summary)}
#!/usr/bin/env node import { promises as fs } from 'node:fs' import path from 'node:path' const ROOT = process.env.MNEMAZINE_ROOT || path.resolve(process.cwd()) const VAULT = process.env.MNEMAZINE_VAULT || path.join(ROOT, 'vault') const REPORTS = process.env.MNEMAZINE_REPORTS || path.join(ROOT, 'reports') const STATE = process.env.MNEMAZINE_STATE || path.join(ROOT, '.mnemazine/state') async function walk(dir) { const out = [] for (const item of await fs.readdir(dir, { withFileTypes: true }).catch(() => [])) { const p = path.join(dir, item.name) if (item.isDirectory()) out.push(...await walk(p)) else if (item.isFile() && p.endsWith('.md')) out.push(p) } return out } function esc(s) { return String(s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])) } function titleOf(text, file) { return text.match(/^#\s+(.+)$/m)?.[1]?.trim() || path.basename(file, '.md') } function summaryOf(text) { const block = text.match(/## (?:What This Is|Что это|Суть)\s+([\s\S]*?)(\n## |$)/i)?.[1] || text return block.replace(/[#*_`>-]/g, '').replace(/\s+/g, ' ').trim().slice(0, 520) } await fs.mkdir(REPORTS, { recursive: true }) await fs.mkdir(STATE, { recursive: true }) const files = await walk(VAULT) const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000 const cards = [] for (const file of files) { const stat = await fs.stat(file) if (stat.mtimeMs < weekAgo) continue const text = await fs.readFile(file, 'utf8') cards.push({ file: path.relative(VAULT, file), title: titleOf(text, file), summary: summaryOf(text) }) } const html = `
Сводка знаний за последние 7 дней: что появилось, что стоит взять в работу, что можно забыть.
${esc(c.summary)}
Положите материалы в inbox и запустите Mnemazine.