MCPcopy Create free account
hub / github.com/Louisym/MiniCC / main

Function main

mini_claude_code/main.py:627–690  ·  view source on GitHub ↗

源码: main.rs:53-93

()

Source from the content-addressed store, hash-verified

625# ============================================================
626
627def main() -> None:
628 """源码: main.rs:53-93"""
629 args = sys.argv[1:]
630 action, params = parse_args(args)
631
632 if action == CliAction.VERSION:
633 print(f"mini-claude-code v{VERSION}")
634 return
635
636 if action == CliAction.HELP:
637 print(
638 f"mini-claude-code v{VERSION}\n"
639 "\n"
640 "Usage:\n"
641 " mini-cc Start interactive REPL\n"
642 " mini-cc \"prompt\" One-shot prompt\n"
643 " mini-cc --model opus \"prompt\" Use specific model\n"
644 "\n"
645 "Options:\n"
646 " --model MODEL Model name or alias (opus/sonnet/haiku)\n"
647 " --permission-mode MODE read-only/workspace-write/danger-full-access\n"
648 " --dangerously-skip-permissions Skip all permission checks\n"
649 " --version, -V Show version\n"
650 " --help, -h Show this help\n"
651 )
652 return
653
654 model = params.get("model", DEFAULT_MODEL)
655 permission_mode = params.get("permission_mode", PermissionMode.WORKSPACE_WRITE)
656
657 # API 客户端: 尝试导入真实客户端,失败则提示
658 api_client = _create_api_client(model)
659 if api_client is None:
660 return
661
662 if action == CliAction.PROMPT:
663 # 单次 prompt — main.rs:81-83
664 prompt = params["prompt"]
665 registry = build_default_registry()
666 system_prompt = build_system_prompt(Path.cwd())
667 runtime = build_runtime(
668 session=Session(),
669 api_client=api_client,
670 registry=registry,
671 permission_mode=permission_mode,
672 system_prompt=system_prompt,
673 )
674 prompter = CliPermissionPrompter()
675
676 try:
677 summary = runtime.run_turn(prompt, prompter=prompter)
678 except RuntimeError as e:
679 print(f"Error: {e}", file=sys.stderr)
680 sys.exit(1)
681
682 # 文本已由 api_client 流式输出
683 return
684

Callers 2

__main__.pyFile · 0.90
main.pyFile · 0.70

Calls 10

SessionClass · 0.90
_create_api_clientFunction · 0.85
build_default_registryFunction · 0.85
parse_argsFunction · 0.70
build_system_promptFunction · 0.70
build_runtimeFunction · 0.70
run_replFunction · 0.70
getMethod · 0.45
run_turnMethod · 0.45

Tested by

no test coverage detected