Files
nieaoandClaude Opus 4.7 f3ea1a3088 fix(understand-knowledge): Windows path + zod schema null compatibility
Four single-line fixes that make `/understand-knowledge` work end-to-end on Windows.

## Root causes

1. Path separator mismatch (3 occurrences in parse-knowledge-base.py)
   - `str(rel.with_suffix(""))` returns backslash-separated stems on Windows
     (e.g. `entities\foo`), while wikilinks always use forward slashes
     (`[[entities/foo]]`).
   - Result: name_map keys and article_ids hold `entities\foo`, while
     `resolve_wikilink()` looks up `entities/foo` -> 100% miss.
   - Tested on Windows 11 + Python 3.14: 151/151 wikilinks unresolved,
     0 edges built from wikilinks.

   Fix: use `rel.with_suffix("").as_posix()` in all three places
   (lines 235, 316, 330 on main).

2. Null vs missing field (1 occurrence)
   - `"category": category or None` writes `null` when category is empty.
   - `KnowledgeMetaSchema.category` in packages/core/src/schema.ts is
     `z.string().optional()`, which accepts `undefined`/missing but
     rejects `null`.
   - Result: every article node fails GraphNodeSchema validation in the
     dashboard (`Invalid input: expected string, received null`),
     all nodes get dropped, dashboard renders empty.

   Fix: omit the field when empty using dict spread.

## After

Tested with a 27-article Karpathy wiki on Windows:
- before: 151 unresolved wikilinks, 0 edges, 0 nodes rendered in dashboard
- after:  0 unresolved, 110 wikilink edges + 23 LLM-implicit edges,
          all 53 nodes (article/topic/entity/claim) render correctly

No behavior change on macOS/Linux: `as_posix()` is a no-op when the OS
already uses `/`, and dict spread produces the same key as the previous
truthy branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:38:13 +08:00
..