Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(links): a verb followed by a preposition and the next link belongs to that link
garrytand7d0d2f0845f
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.tsindex f834882fdf..b70d9232fe 100644--- a/src/core/link-extraction.ts+++ b/src/core/link-extraction.ts@@ -1277,7 +1277,7 @@ function attachedVerb(context: string, targetSlug?: string, anchor?: number): stconst start = m.index ?? 0; const end = start + m[0].length;if (end <= linkStart && LINK_MARK_RE.test(context.slice(end, linkStart))&& !coordinated(context.slice(end, linkStart))) continue;- if (start >= linkEnd && (LINK_MARK_RE.test(context.slice(linkEnd, start)) || /^\s{0,3}\[/.test(context.slice(end)))) continue;+ if (start >= linkEnd && (LINK_MARK_RE.test(context.slice(linkEnd, start)) || /^\s*(?:(?:with|at|to|for|of|in|on)\s+)?\[/i.test(context.slice(end)))) continue;return verb;}}diff --git a/test/link-type-attachment.test.ts b/test/link-type-attachment.test.tsindex 154b60ccfe..802c3526a4 100644--- a/test/link-type-attachment.test.ts+++ b/test/link-type-attachment.test.ts@@ -51,3 +51,9 @@ test('links joined by "and" share the verb before the first: works at [A] and atexpect(inferLinkType('person', window, undefined, 'companies/widget-co', undefined, window.indexOf('[Widget]'))).toBe('works_at');expect(inferLinkType('person', 'Alice works at [Acme](companies/acme-example) and also advises [Widget](companies/widget-co).', undefined, 'companies/widget-co')).toBe('advises');});++test('a verb right before a preposition and the next link belongs to that link: "Took an advisory role with [X]"', async () => {+ const content = 'Alice works at [Beta](companies/beta-example).\n\n## Timeline\n\n- **2024-03-01** | linkedin — Took an advisory role with [Acme](companies/acme-example)';+ const r = await extractPageLinks('people/alice-example', content, {}, 'person', { resolve: async () => null } as SlugResolver, {});+ expect(r.candidates.map(c => [c.targetSlug, c.linkType])).toEqual([['companies/beta-example', 'works_at'], ['companies/acme-example', 'advises']]);+});