diff --git a/src/commands/extract.ts b/src/commands/extract.ts index 21eeaaef5..44f1a651d 100644 --- a/src/commands/extract.ts +++ b/src/commands/extract.ts @@ -509,8 +509,12 @@ export function extractTimelineFromContent(content: string, slug: string): Extra // DB-level uniqueness cannot collapse. const citationPattern = /\[Source:\s*([^\]]+?),\s*(\d{4}-\d{2}-\d{2})\s*\]/g; const bulletLinePattern = /^-\s+\*\*\d{4}-\d{2}-\d{2}\*\*\s*\|/; + // Lines captured by Format 4 (plain bullet) are skipped for the same + // reason: quality.md mandates a trailing [Source: ...] on those bullets, + // and re-extracting the citation would double-count the event. + const plainBulletLinePattern = /^-\s+\d{4}-\d{2}-\d{2}\s*[—–-]/; for (const line of content.split(/\r?\n/)) { - if (bulletLinePattern.test(line)) continue; + if (bulletLinePattern.test(line) || plainBulletLinePattern.test(line)) continue; const lineMatches = [...line.matchAll(citationPattern)]; if (lineMatches.length === 0) continue; // Strip every citation marker from the line to leave the annotated text. @@ -526,6 +530,19 @@ export function extractTimelineFromContent(content: string, slug: string): Extra } } + // Format 4: Plain bullet — - YYYY-MM-DD — Summary + // This is the format gbrain's own enrich skill writes (no bold, no source + // pipe). Without it, every brain-authored timeline entry is invisible to + // extraction and timeline_coverage stays at 0%. Anchored at line start so a + // date inside a summary/link cannot start a spurious entry; a bold Format-1 + // line (`- **…**`) cannot match here (a `*` follows the bullet, not a + // digit), and the citation loop above skips these lines, so a plain bullet + // carrying its own [Source: ...] files exactly one entry. + const plainBulletPattern = /^-\s+(\d{4}-\d{2}-\d{2})\s*[—–-]\s*(.+)$/gm; + while ((match = plainBulletPattern.exec(content)) !== null) { + entries.push({ slug, date: match[1], source: 'markdown', summary: match[2].trim() }); + } + return entries; } diff --git a/test/extract.test.ts b/test/extract.test.ts index 5764de52b..1b563f791 100644 --- a/test/extract.test.ts +++ b/test/extract.test.ts @@ -185,6 +185,49 @@ describe('extractTimelineFromContent', () => { expect(entries).toHaveLength(1); expect(entries[0].summary).toBe('Landed the enterprise pilot with acme-example.'); }); + + // Format 4: the plain bullet `- YYYY-MM-DD — Summary` that gbrain's own + // enrich skill writes. Before this was supported, every brain-authored + // timeline entry was invisible and timeline_coverage was stuck at 0%. + it('extracts plain bullet format (- YYYY-MM-DD — Summary)', () => { + const content = `## Timeline\n- 2026-06-01 — Catch-up call with alice-example; intros offered.`; + const entries = extractTimelineFromContent(content, 'people/alice-example'); + expect(entries).toHaveLength(1); + expect(entries[0].date).toBe('2026-06-01'); + expect(entries[0].source).toBe('markdown'); + expect(entries[0].summary).toBe('Catch-up call with alice-example; intros offered.'); + }); + + it('files exactly one entry for a plain bullet that carries its own citation', () => { + // quality.md mandates this shape; it must not double-count via the + // citation arm (Format 3) AND the plain-bullet arm (Format 4). + const content = `- 2026-05-31 — Confirmed full name. [Source: User, 2026-05-31]`; + const entries = extractTimelineFromContent(content, 'people/charlie-example'); + expect(entries).toHaveLength(1); + expect(entries[0].date).toBe('2026-05-31'); + expect(entries[0].source).toBe('markdown'); + expect(entries[0].summary).toContain('Confirmed full name.'); + }); + + it('does not double-count bold (Format 1) lines as plain bullets', () => { + const content = `- **2025-03-18** | Meeting — Discussed partnership`; + const entries = extractTimelineFromContent(content, 'test'); + expect(entries).toHaveLength(1); + expect(entries[0].source).toBe('Meeting'); + }); + + it('does not start a spurious entry from a date inside a summary', () => { + const content = `- 2026-06-01 — See [meeting](meetings/2026-06-01).`; + const entries = extractTimelineFromContent(content, 'people/alice-example'); + expect(entries).toHaveLength(1); + expect(entries[0].date).toBe('2026-06-01'); + }); + + it('handles en dash and hyphen separators in plain bullets', () => { + const content = `- 2026-06-01 – First\n- 2026-06-02 - Second`; + const entries = extractTimelineFromContent(content, 'test'); + expect(entries).toHaveLength(2); + }); }); describe('walkMarkdownFiles', () => {