knowledge-catalog
knowledge-catalog copied to clipboard
visualize: 0 edges for spec-recommended absolute links and CommonMark link titles
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("/"): continueskips/-prefixed targets. ButSPEC.mdrecommends 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, andSPEC.mdsays 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.