Write ``metadata.json`` to the session's output directory. Merges the current git commit and timestamp into any existing metadata so that stats from other workflows (e.g. CLI ``generate_docs``) are preserved.
(session: SessionState)
| 554 | use_gitignore=arguments.get("use_gitignore", True), |
| 555 | layout=docs_layout(str(output_dir)), |
| 556 | ) |
| 557 | |
| 558 | from codewiki.cli.utils.repo_validator import get_git_commit_hash |
| 559 | from codewiki.src.be.documentation_generator import DocumentationGenerator |
| 560 | |
| 561 | doc_gen = DocumentationGenerator( |
| 562 | backend_config, commit_id=get_git_commit_hash(repo_path) or None |
| 563 | ) |
| 564 | await doc_gen.run() |
| 565 | |
| 566 | generated_files = sorted(list_doc_files(str(output_dir)).values()) |
| 567 | for f in output_dir.iterdir(): |
| 568 | if f.suffix in (".json", ".html"): |
| 569 | generated_files.append(f.name) |
| 570 | |
| 571 | result = { |
| 572 | "status": "success", |
| 573 | "output_dir": str(output_dir), |
| 574 | "files_generated": sorted(generated_files), |
| 575 | "file_count": len(generated_files), |
| 576 | } |
| 577 | return [_text(json.dumps(result, indent=2))] |
| 578 | |
| 579 | |
| 580 | async def _legacy_get_module_tree(arguments: dict[str, Any]) -> list[TextContent]: |
| 581 | """Legacy get_module_tree.""" |
| 582 | repo_path = Path(arguments["repo_path"]).expanduser().resolve() |
| 583 | output_dir_arg = arguments.get("output_dir") |
| 584 | if output_dir_arg: |
| 585 | output_dir = Path(output_dir_arg).expanduser().resolve() |
| 586 | else: |
| 587 | # Default docs live next to the repo, not relative to the MCP process cwd. |
| 588 | output_dir = (repo_path / "docs").resolve() |
| 589 | |
| 590 | module_tree_path = output_dir / "module_tree.json" |
| 591 | if not module_tree_path.exists(): |
| 592 | return [ |
| 593 | _text( |
| 594 | json.dumps( |
| 595 | { |
| 596 | "error": f"Module tree not found at {module_tree_path}. Run 'codewiki generate' first." |
| 597 | } |
| 598 | ) |
| 599 | ) |
no test coverage detected