Parse command line arguments Returns: Parsed arguments
()
| 283 | |
| 284 | |
| 285 | def parse_args() -> argparse.Namespace: |
| 286 | """Parse command line arguments |
| 287 | |
| 288 | Returns: |
| 289 | Parsed arguments |
| 290 | """ |
| 291 | parser = argparse.ArgumentParser( |
| 292 | description="Mini Agent - AI assistant with file tools and MCP support", |
| 293 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 294 | epilog=""" |
| 295 | Examples: |
| 296 | mini-agent # Use current directory as workspace |
| 297 | mini-agent --workspace /path/to/dir # Use specific workspace directory |
| 298 | mini-agent log # Show log directory and recent files |
| 299 | mini-agent log agent_run_xxx.log # Read a specific log file |
| 300 | """, |
| 301 | ) |
| 302 | parser.add_argument( |
| 303 | "--workspace", |
| 304 | "-w", |
| 305 | type=str, |
| 306 | default=None, |
| 307 | help="Workspace directory (default: current directory)", |
| 308 | ) |
| 309 | parser.add_argument( |
| 310 | "--task", |
| 311 | "-t", |
| 312 | type=str, |
| 313 | default=None, |
| 314 | help="Execute a task non-interactively and exit", |
| 315 | ) |
| 316 | parser.add_argument( |
| 317 | "--version", |
| 318 | "-v", |
| 319 | action="version", |
| 320 | version="mini-agent 0.1.0", |
| 321 | ) |
| 322 | |
| 323 | # Subcommands |
| 324 | subparsers = parser.add_subparsers(dest="command", help="Available commands") |
| 325 | |
| 326 | # log subcommand |
| 327 | log_parser = subparsers.add_parser("log", help="Show log directory or read log files") |
| 328 | log_parser.add_argument( |
| 329 | "filename", |
| 330 | nargs="?", |
| 331 | default=None, |
| 332 | help="Log filename to read (optional, shows directory if omitted)", |
| 333 | ) |
| 334 | |
| 335 | return parser.parse_args() |
| 336 | |
| 337 | |
| 338 | async def initialize_base_tools(config: Config): |