refactor: rename .oikb.yaml top-level key from sync: to sources:

Backward compatible — both sync: and sources: are accepted,
sources: takes precedence.
This commit is contained in:
Timothy Jaeryang Baek 2026-05-20 22:58:14 +04:00
parent f3ca110358
commit af83f4b4c8
2 changed files with 8 additions and 6 deletions

View file

@ -52,7 +52,7 @@ Features:
```yaml
# .oikb.yaml
sync:
sources:
- source: github:owner/repo
kb-id: team-wiki
interval: 1h
@ -119,7 +119,7 @@ Some connectors need an optional extra: `pip install oikb[gdrive]`, `pip install
Route files from a single source to different Knowledge Bases by glob pattern:
```yaml
sync:
sources:
- source: github:owner/repo
routes:
"docs/**/*.md": docs-kb
@ -131,7 +131,7 @@ sync:
Narrow what gets synced with include/exclude globs:
```yaml
sync:
sources:
- source: github:owner/repo
kb-id: docs-only
filter:

View file

@ -282,10 +282,12 @@ def _load_oikb_yaml() -> list[dict] | None:
with open(yaml_path) as f:
data = yaml.safe_load(f)
if not data or "sync" not in data:
if not data:
return None
return data["sync"]
# Prefer sources: (new), fall back to sync: (legacy).
entries = data.get("sources") or data.get("sync")
return entries or None
# ── sync ────────────────────────────────────────────────────────
@ -747,7 +749,7 @@ def daemon(port: int, no_server: bool, config_file: str | None):
import yaml
with open(config_file) as f:
data = yaml.safe_load(f)
entries = data.get("sync", []) if data else []
entries = (data.get("sources") or data.get("sync", [])) if data else []
else:
entries = _load_oikb_yaml()