From 49cf5202cb7456928d8fedeeccfbef81b0e2a034 Mon Sep 17 00:00:00 2001 From: mzkarami Date: Thu, 23 Jul 2026 03:50:49 +0200 Subject: [PATCH] fix(extract): recognize reference wikilinks (#2071) --- src/core/link-extraction.ts | 4 ++-- test/link-extraction.test.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts index 6ff2f6822..8aa203480 100644 --- a/src/core/link-extraction.ts +++ b/src/core/link-extraction.ts @@ -79,11 +79,11 @@ export type LinkResolutionType = 'qualified' | 'unqualified'; /** * Directory prefix whitelist. These are the top-level slug dirs the extractor * recognizes as entity references. Upstream canonical + our extensions: - * - Gbrain canonical: people, companies, meetings, concepts, deal, civic, project, source, media, yc, projects + * - Gbrain canonical: people, companies, meetings, concepts, deal, civic, project, source, media, yc, projects, reference * - Our domain extensions: tech, finance, personal, openclaw (domain-organized wikis) * - Our entity prefix: entities (we kept some legacy entities/projects/ pages) */ -const DIR_PATTERN = '(?:people|companies|meetings|concepts|deal|civic|project|projects|source|media|yc|tech|finance|personal|openclaw|entities)'; +const DIR_PATTERN = '(?:people|companies|meetings|concepts|deal|civic|project|projects|source|media|yc|tech|finance|personal|openclaw|entities|reference)'; /** * Match `[Name](path)` markdown links pointing to entity directories. diff --git a/test/link-extraction.test.ts b/test/link-extraction.test.ts index 9a2bc4f7d..64e1db2f9 100644 --- a/test/link-extraction.test.ts +++ b/test/link-extraction.test.ts @@ -140,6 +140,17 @@ describe('extractEntityRefs', () => { expect(wikiRefs[0].needsResolution).toBe(true); }); + test('recognizes reference-page wikilinks as concrete targets', () => { + const refs = extractEntityRefs('See [[reference/mcminnville-market-data]] for source context.'); + expect(refs.length).toBe(1); + expect(refs[0]).toMatchObject({ + name: 'reference/mcminnville-market-data', + slug: 'reference/mcminnville-market-data', + dir: 'reference', + }); + expect(refs[0].needsResolution).toBeUndefined(); + }); + test('skips qualified-syntax tokens (those belong to 2a)', () => { // [[wiki:topics/ai]] looks like 2a's qualified shape — even though // it wouldn't satisfy DIR_PATTERN, 2c must not claim it either