diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aea040..cf7bf60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [0.2.2] - 2025-05-21 + +### Added + +- `name` key for `.oikb.yaml` entries — use friendly names to target syncs via CLI (`--name wiki`) or API (`POST /sync/wiki`). + +### Changed + +- Daemon sync endpoint changed from `/sync/{source}` to `/sync/{identifier}` — accepts `name` or `kb-id` (UUIDs). + ## [0.2.1] - 2025-05-20 ### Added diff --git a/pyproject.toml b/pyproject.toml index 345d4f5..2a0b5d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "oikb" -version = "0.2.1" +version = "0.2.2" description = "Sync anything to Open WebUI Knowledge Bases" readme = "README.md" authors = [ diff --git a/src/oikb/cli.py b/src/oikb/cli.py index 1d55610..8a91e7b 100644 --- a/src/oikb/cli.py +++ b/src/oikb/cli.py @@ -333,7 +333,7 @@ def sync( # Filter by --name if specified. if name: - entries = [e for e in entries if e.get("kb-id") == name or e.get("source") == name] + entries = [e for e in entries if e.get("name") == name or e.get("kb-id") == name] if not entries: click.echo(click.style(f"No entry matching '{name}' in .oikb.yaml", fg="red"), err=True) sys.exit(1) diff --git a/src/oikb/daemon.py b/src/oikb/daemon.py index 39b8cc2..28b2e2f 100644 --- a/src/oikb/daemon.py +++ b/src/oikb/daemon.py @@ -38,7 +38,7 @@ async def verify_api_key( app = FastAPI( title="oikb", description="Sync engine for Open WebUI Knowledge Bases. Trigger syncs, check status, and query history.", - version="0.2.1", + version="0.2.2", ) # Runtime state populated by start_daemon(). @@ -103,18 +103,18 @@ async def history_endpoint( @app.post( - "/sync/{source}", + "/sync/{identifier}", operation_id="trigger_sync", - summary="Trigger an immediate sync for a source", + summary="Trigger an immediate sync by alias or KB ID", dependencies=[Depends(verify_api_key)], ) -async def trigger_sync(source: str): - """Triggers an immediate sync for the given source or Knowledge Base ID. The sync runs asynchronously in the background. Use get_sync_status to check progress.""" +async def trigger_sync(identifier: str): + """Triggers an immediate sync matching the given alias or Knowledge Base ID. The sync runs asynchronously in the background. Use get_sync_status to check progress.""" for entry in _entries: - if entry.get("source") == source or entry.get("kb-id") == source: + if entry.get("name") == identifier or entry.get("kb-id") == identifier: asyncio.create_task(_run_entry(entry)) - return {"triggered": True, "source": entry.get("source")} - return {"triggered": False, "error": f"No entry matching '{source}'"} + return {"triggered": True, "name": entry.get("name"), "kb_id": entry.get("kb-id")} + return {"triggered": False, "error": f"No entry matching '{identifier}'"} # ── Scheduler ──────────────────────────────────────────────────── @@ -276,7 +276,7 @@ def start_daemon( click.echo(f" {len(webhook_entries)} webhook-enabled source(s)") click.echo(f" GET http://localhost:{port}/health") click.echo(f" GET http://localhost:{port}/history") - click.echo(f" POST http://localhost:{port}/sync/{{source}}") + click.echo(f" POST http://localhost:{port}/sync/{{kb_id}}") if webhook_entries: click.echo(f" POST http://localhost:{port}/webhooks/github|gitlab|slack|confluence") click.echo(f"\n OpenAPI spec: http://localhost:{port}/openapi.json")