MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / bundle_export

Function bundle_export

src/codegraphcontext/cli/main.py:566–615  ·  view source on GitHub ↗

Export the current graph to a portable .cgc bundle. Creates a pre-indexed graph snapshot that can be distributed and loaded instantly without re-indexing. Perfect for sharing famous repositories. Examples: cgc bundle export numpy.cgc --repo /path/to/numpy c

(
    output: str = typer.Argument(..., help="Output path for the .cgc bundle file"),
    repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Specific repository path to export (default: export all)"),
    no_stats: bool = typer.Option(False, "--no-stats", help="Skip statistics generation"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

564
565@bundle_app.command("export")
566def bundle_export(
567 output: str = typer.Argument(..., help="Output path for the .cgc bundle file"),
568 repo: Optional[str] = typer.Option(None, "--repo", "-r", help="Specific repository path to export (default: export all)"),
569 no_stats: bool = typer.Option(False, "--no-stats", help="Skip statistics generation"),
570 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
571):
572 """
573 Export the current graph to a portable .cgc bundle.
574
575 Creates a pre-indexed graph snapshot that can be distributed and loaded
576 instantly without re-indexing. Perfect for sharing famous repositories.
577
578 Examples:
579 cgc bundle export numpy.cgc --repo /path/to/numpy
580 cgc bundle export my-project.cgc
581 cgc bundle export all-repos.cgc --no-stats
582 """
583 _load_credentials()
584 from codegraphcontext.core.cgc_bundle import CGCBundle
585
586 services = _initialize_services(context)
587 if not all(services[:3]):
588 return
589 db_manager, graph_builder, code_finder = services[:3]
590
591 try:
592 output_path = Path(output)
593 repo_path = Path(repo).resolve() if repo else None
594
595 console.print(f"[cyan]Exporting graph to {output_path}...[/cyan]")
596 if repo_path:
597 console.print(f"[dim]Repository: {repo_path}[/dim]")
598 else:
599 console.print(f"[dim]Exporting all repositories[/dim]")
600
601 bundle = CGCBundle(db_manager)
602 success, message = bundle.export_to_bundle(
603 output_path,
604 repo_path=repo_path,
605 include_stats=not no_stats
606 )
607
608 if success:
609 console.print(f"[bold green]{message}[/bold green]")
610 else:
611 console.print(f"[bold red]Export failed: {message}[/bold red]")
612 raise typer.Exit(code=1)
613
614 finally:
615 db_manager.close_driver()
616
617@bundle_app.command("import")
618def bundle_import(

Callers 1

export_shortcutFunction · 0.85

Calls 6

export_to_bundleMethod · 0.95
CGCBundleClass · 0.90
_load_credentialsFunction · 0.85
_initialize_servicesFunction · 0.85
resolveMethod · 0.80
close_driverMethod · 0.45

Tested by

no test coverage detected