Collect marker_hash values from existing intake item frontmatter.
()
| 372 | |
| 373 | /** Collect marker_hash values from existing intake item frontmatter. */ |
| 374 | function readExistingIntakeHashes() { |
| 375 | const hashes = new Set(); |
| 376 | if (!fs.existsSync(INTAKE_DIR)) return hashes; |
| 377 | for (const name of fs.readdirSync(INTAKE_DIR)) { |
| 378 | if (!name.endsWith('.md')) continue; |
| 379 | let content; |
| 380 | try { |
| 381 | content = fs.readFileSync(path.join(INTAKE_DIR, name), 'utf8'); |
| 382 | } catch { |
| 383 | continue; |
| 384 | } |
| 385 | const frontmatter = content.match(/^---\r?\n([\s\S]*?)\r?\n---/); |
| 386 | if (!frontmatter) continue; |
| 387 | const hashLine = frontmatter[1].match(/^marker_hash:\s*"?([0-9a-f]{16})"?\s*$/m); |
| 388 | if (hashLine) hashes.add(hashLine[1]); |
| 389 | } |
| 390 | return hashes; |
| 391 | } |
| 392 | |
| 393 | function generateIntakeItem(marker, hash) { |
| 394 | if (!fs.existsSync(INTAKE_DIR)) { |