Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(extract): recognize reference wikilinks (#2071)

mzkarami49cf5202cb74
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts
index 6ff2f6822b..8aa2034803 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 9a2bc4f7d0..64e1db2f9e 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