knowledge-catalog icon indicating copy to clipboard operation
knowledge-catalog copied to clipboard

visualize: 0 edges for spec-recommended absolute links and CommonMark link titles

Open famulare opened this issue 5 months ago • 0 comments

The reference visualize tool extracts 0 edges from bundles that use either (a) absolute bundle-relative links — which SPEC.md (Cross-links) recommends — or (b) standard CommonMark link titles. Only relative, untitled links produce edges, so spec-conformant bundles can render as disconnected node clouds.

Repro

A 2-concept bundle where a/a.md links b/b.md, varying only the link form, then python -m enrichment_agent visualize --bundle <dir>:

link in a/a.md edges found
[Bee](../b/b.md) 1
[Bee](../b/b.md "note") 0
[Bee](/b/b.md) 0

Causes — src/enrichment_agent/viewer/generator.py

  • L54 if "://" in target or target.startswith("/"): continue skips /-prefixed targets. But SPEC.md recommends absolute bundle-relative links (begin with /, relative to bundle root), so the recommended form is dropped.
  • L12 _LINK_RE = re.compile(r"\]\(([^)\s]+\.md)(?:#[A-Za-z0-9_\-]*)?\)") doesn't allow a link title, so ](path.md "title") — valid CommonMark, and SPEC.md says links use standard markdown syntax — fails to match.

Suggested fix

Resolve /-prefixed targets against the bundle root rather than skipping them, and widen the regex to allow an optional title, e.g.:

_LINK_RE = re.compile(r'\]\(([^)\s]+\.md)(?:#[A-Za-z0-9_\-]*)?(?:\s+"[^"]*")?\)')

Happy to send a PR if that's useful.

famulare avatar Jun 13 '26 19:06 famulare