| 1 | #!/usr/bin/env python3
|
| 2 |
|
| 3 | """This is the central entry point to the mini-extra script. Use subcommands
|
| 4 | to invoke other command line utilities like running on benchmarks, editing config,
|
| 5 | inspecting trajectories, etc.
|
| 6 | """
|
| 7 |
|
| 8 | import sys
|
| 9 | from importlib import import_module
|
| 10 |
|
| 11 | from rich.console import Console
|
| 12 |
|
| 13 | subcommands = [
|
| 14 | ("minisweagent.run.utilities.config", ["config"], "Manage the global config file"),
|
| 15 | ("minisweagent.run.utilities.inspector", ["inspect", "i", "inspector"], "Run inspector (browse trajectories)"),
|
| 16 | ("minisweagent.run.benchmarks.swebench", ["swebench"], "Evaluate on SWE-bench (batch mode)"),
|
| 17 | ("minisweagent.run.benchmarks.swebench_single", ["swebench-single"], "Evaluate on SWE-bench (single instance)"),
|
| 18 | ]
|
| 19 |
|
| 20 |
|
| 21 | def get_docstring() -> str:
|
| 22 | lines = [
|
| 23 | "This is the [yellow]central entry point for all extra commands[/yellow] from mini-swe-agent.",
|
| 24 | "",
|
| 25 | "Available sub-commands:",
|
| 26 | "",
|
| 27 | ]
|
| 28 | for _, aliases, description in subcommands:
|
| 29 | alias_text = " or ".join(f"[bold green]{alias}[/bold green]" for alias in aliases)
|
| 30 | lines.append(f" {alias_text}: {description}")
|
| 31 | return "\n".join(lines)
|
| 32 |
|
| 33 |
|
| 34 | def main():
|
| 35 | args = sys.argv[1:]
|
| 36 |
|
| 37 | if len(args) == 0 or len(args) == 1 and args[0] in ["-h", "--help"]:
|
| 38 | return Console().print(get_docstring())
|
| 39 |
|
| 40 | for module_path, aliases, _ in subcommands:
|
| 41 | if args[0] in aliases:
|
| 42 | return import_module(module_path).app(args[1:], prog_name=f"mini-extra {aliases[0]}")
|
| 43 |
|
| 44 | return Console().print(get_docstring())
|
| 45 |
|
| 46 |
|
| 47 | if __name__ == "__main__":
|
| 48 | main()
|
| 49 |
|