Skip to content

Commit b112dbf

Browse files
committed
fix: sanitize concept names before links and index
1 parent b49467d commit b112dbf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

openkb/agent/compiler.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -643,16 +643,18 @@ async def _gen_update(concept: dict) -> tuple[str, str, bool, str]:
643643
continue
644644
name, page_content, is_update, brief = r
645645
_write_concept(wiki_dir, name, page_content, source_file, is_update, brief=brief)
646-
concept_names.append(name)
646+
safe_name = _sanitize_concept_name(name)
647+
concept_names.append(safe_name)
647648
if brief:
648-
concept_briefs_map[name] = brief
649+
concept_briefs_map[safe_name] = brief
649650

650651
# --- Step 3b: Process related items (code only, no LLM) ---
651-
for slug in related_items:
652+
sanitized_related = [_sanitize_concept_name(s) for s in related_items]
653+
for slug in sanitized_related:
652654
_add_related_link(wiki_dir, slug, doc_name, source_file)
653655

654656
# --- Step 3c: Backlink — summary ↔ concepts (code only) ---
655-
all_concept_slugs = concept_names + [s for s in related_items]
657+
all_concept_slugs = concept_names + sanitized_related
656658
if all_concept_slugs:
657659
_backlink_summary(wiki_dir, doc_name, all_concept_slugs)
658660
_backlink_concepts(wiki_dir, doc_name, all_concept_slugs)

0 commit comments

Comments
 (0)