GoogleCloudPlatform / GoogleCloudPlatform/knowledge-catalog
visualize: 0 edges for spec-recommended absolute links and CommonMark link titles
- Dominant language
- TypeScript
- Stars
- 9.2k
- Forks
- 782
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 85
Description
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 `:
| 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.:
```python
_LINK_RE = re.compile(r'\]\(([^)\s]+\.md)(?:#[A-Za-z0-9_\-]*)?(?:\s+"[^"]*")?\)')
```
Happy to send a PR if that's useful.
Contributor guide
Assessment
This issue has not been assessed yet.