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

Function run_repl

mini_claude_code/main.py:394–515  ·  view source on GitHub ↗

源码: main.rs:935-973

(
    model: str,
    permission_mode: PermissionMode,
    api_client,
    registry: Optional[ToolRegistry] = None,
    storage_dir: Optional[Path] = None,
)

Source from the content-addressed store, hash-verified

392# ============================================================
393
394def run_repl(
395 model: str,
396 permission_mode: PermissionMode,
397 api_client,
398 registry: Optional[ToolRegistry] = None,
399 storage_dir: Optional[Path] = None,
400) -> None:
401 """源码: main.rs:935-973"""
402 cwd = Path.cwd()
403
404 # 构建各组件
405 if registry is None:
406 registry = build_default_registry()
407 system_prompt = build_system_prompt(cwd)
408 session_id = uuid.uuid4().hex[:12]
409 session = Session()
410
411 # 存储
412 store_dir = storage_dir or Path.home() / ".mini-claude-code" / "sessions"
413 store = SessionStore(store_dir)
414
415 # Hook
416 try:
417 config = ConfigLoader.default_for(cwd).load()
418 hook_runner = HookRunner(
419 pre_tool_use=config.hooks_pre(),
420 post_tool_use=config.hooks_post(),
421 )
422 except Exception:
423 hook_runner = HookRunner()
424
425 # 组装 runtime — 唯一的组装点
426 runtime = build_runtime(
427 session=session,
428 api_client=api_client,
429 registry=registry,
430 permission_mode=permission_mode,
431 system_prompt=system_prompt,
432 hook_runner=hook_runner,
433 )
434
435 prompter = CliPermissionPrompter()
436
437 # 打印 banner — main.rs:942
438 print(startup_banner(model, permission_mode, cwd, session_id))
439
440 # REPL 循环 — main.rs:944-970
441 last_uuid: Optional[str] = None
442
443 while True:
444 try:
445 user_input = input("\033[1m> \033[0m")
446 except KeyboardInterrupt:
447 # Ctrl+C: 取消当前输入,不退出 — main.rs:964
448 print()
449 continue
450 except EOFError:
451 # Ctrl+D: 退出 — main.rs:965-968

Callers 1

mainFunction · 0.70

Calls 15

save_messageMethod · 0.95
SessionClass · 0.90
SessionStoreClass · 0.90
HookRunnerClass · 0.90
compact_sessionFunction · 0.90
CompactionConfigClass · 0.90
build_default_registryFunction · 0.85
startup_bannerFunction · 0.85
parse_slash_commandFunction · 0.85
render_helpFunction · 0.85
format_statusFunction · 0.85
hooks_preMethod · 0.80

Tested by

no test coverage detected