Legacy generate_docs — requires CodeWiki LLM configuration.
(arguments: dict[str, Any])
| 450 | |
| 451 | |
| 452 | async def _legacy_generate_docs(arguments: dict[str, Any]) -> list[TextContent]: |
| 453 | """Legacy generate_docs — requires CodeWiki LLM configuration.""" |
| 454 | repo_path = Path(arguments["repo_path"]).expanduser().resolve() |
| 455 | output_dir = Path(arguments.get("output_dir", "docs")).expanduser().resolve() |
| 456 | |
| 457 | if not repo_path.exists(): |
| 458 | return [_text(json.dumps({"error": f"Repository not found: {repo_path}"}))] |
| 459 | |
| 460 | manager = _load_config() |
| 461 | config = manager.get_config() |
| 462 | api_key = manager.get_api_key() |
| 463 | |
| 464 | from codewiki.src.be.backend import is_caw_provider |
| 465 | caw_mode = bool(config) and is_caw_provider(getattr(config, "provider", "")) |
| 466 | if not api_key and not caw_mode: |
| 467 | return [_text(json.dumps({"error": "API key not configured. Run 'codewiki config set --api-key <key>'"}))] |
| 468 | |
| 469 | agent_instructions = {} |
| 470 | if arguments.get("doc_type"): |
| 471 | agent_instructions["doc_type"] = arguments["doc_type"] |
| 472 | if arguments.get("include_patterns"): |
| 473 | agent_instructions["include_patterns"] = [p.strip() for p in arguments["include_patterns"].split(",")] |
| 474 | if arguments.get("exclude_patterns"): |
| 475 | agent_instructions["exclude_patterns"] = [p.strip() for p in arguments["exclude_patterns"].split(",")] |
| 476 | |
| 477 | from codewiki.src.config import Config as BackendConfig, set_cli_context |
| 478 | set_cli_context(True) |
| 479 | |
| 480 | backend_config = BackendConfig.from_cli( |
| 481 | repo_path=str(repo_path), |
| 482 | output_dir=str(output_dir), |
| 483 | llm_base_url=config.base_url, |
| 484 | llm_api_key=api_key, |
| 485 | main_model=config.main_model, |
| 486 | cluster_model=config.cluster_model, |
| 487 | fallback_model=config.fallback_model, |
| 488 | provider=getattr(config, "provider", "openai-compatible"), |
| 489 | aws_region=getattr(config, "aws_region", "us-east-1"), |
| 490 | max_tokens=config.max_tokens, |
| 491 | agent_instructions=agent_instructions or None, |
| 492 | ) |
| 493 | |
| 494 | from codewiki.cli.utils.repo_validator import get_git_commit_hash |
| 495 | from codewiki.src.be.documentation_generator import DocumentationGenerator |
| 496 | doc_gen = DocumentationGenerator(backend_config, commit_id=get_git_commit_hash(repo_path) or None) |
| 497 | await doc_gen.run() |
| 498 | |
| 499 | generated_files = [] |
| 500 | for f in output_dir.iterdir(): |
| 501 | if f.suffix in (".md", ".json", ".html"): |
| 502 | generated_files.append(f.name) |
| 503 | |
| 504 | result = { |
| 505 | "status": "success", |
| 506 | "output_dir": str(output_dir), |
| 507 | "files_generated": sorted(generated_files), |
| 508 | "file_count": len(generated_files), |
| 509 | } |
no test coverage detected