Legacy generate_docs — requires CodeWiki LLM configuration.
(arguments: dict[str, Any])
| 450 | ) |
| 451 | # Clean up workspace files on disk |
| 452 | if session.workspace is not None: |
| 453 | session.workspace.cleanup() |
| 454 | removed = _store.remove(sid) |
| 455 | return [ |
| 456 | _text( |
| 457 | json.dumps( |
| 458 | { |
| 459 | "status": "closed" if removed else "not_found", |
| 460 | "session_id": sid, |
| 461 | } |
| 462 | ) |
| 463 | ) |
| 464 | ] |
| 465 | |
| 466 | # --- Legacy tools (require CodeWiki LLM config) --- |
| 467 | elif name == "generate_docs": |
| 468 | return await _legacy_generate_docs(arguments) |
| 469 | |
| 470 | elif name == "get_module_tree": |
| 471 | return await _legacy_get_module_tree(arguments) |
| 472 | |
| 473 | else: |
| 474 | return [_text(json.dumps({"error": f"Unknown tool: {name}"}))] |
| 475 | |
| 476 | except Exception as e: |
| 477 | logger.error("Tool %s failed: %s", name, e, exc_info=True) |
| 478 | return [_text(json.dumps({"error": str(e)}))] |
| 479 | |
| 480 | |
| 481 | # =================================================================== |
| 482 | # Legacy tool handlers (require _load_config) |
| 483 | # =================================================================== |
| 484 | |
| 485 | |
| 486 | def _load_config(): |
| 487 | """Load CodeWiki configuration from ~/.codewiki/config.json + keyring.""" |
| 488 | from codewiki.cli.config_manager import ConfigManager |
| 489 | |
| 490 | manager = ConfigManager() |
| 491 | if not manager.load(): |
| 492 | raise RuntimeError("CodeWiki not configured. Run 'codewiki config set' first.") |
| 493 | return manager |
| 494 | |
| 495 | |
| 496 | async def _legacy_generate_docs(arguments: dict[str, Any]) -> list[TextContent]: |
| 497 | """Legacy generate_docs — requires CodeWiki LLM configuration.""" |
| 498 | repo_path = Path(arguments["repo_path"]).expanduser().resolve() |
| 499 | output_dir = Path(arguments.get("output_dir", "docs")).expanduser().resolve() |
| 500 | |
| 501 | if not repo_path.exists(): |
| 502 | return [_text(json.dumps({"error": f"Repository not found: {repo_path}"}))] |
| 503 | |
| 504 | manager = _load_config() |
| 505 | config = manager.get_config() |
| 506 | api_key = manager.get_api_key() |
| 507 | |
| 508 | from codewiki.src.be.backend import needs_api_key |
| 509 |
no test coverage detected