Files
xiaoli-cli/xcli_core/__init__.py
T
xiaoli-cli 04e2d26809 refactor: 拆分 ai_cli.py 为模块化 xcli_core 包
将 4130 行的单文件拆分为 13 个职责清晰的模块:
- constants.py: 常量 + 可选依赖导入
- sandbox.py: 安全代码沙箱 (AST检查器 + 子进程隔离)
- config.py: 配置管理 + 日志
- plugin_manager.py: LiuginManager 插件管理器
- cli_base.py: BaseAICLI 基类 (初始化/引擎/插件/命令)
- cli_clawli.py: ClawliMixin 远程模式
- cli_tools.py: ToolMixin 工具调用
- cli_code_exec.py: CodeExecMixin 代码沙箱执行
- cli_display.py: DisplayMixin 显示/输出/图片/帮助
- cli_history.py: HistoryMixin 聊天记录
- cli_core.py: AICLI 主类 + 对话循环 + main()
- tui.py: Textual TUI 界面
- __init__.py: 包导出汇总

ai_cli.py 保留为入口文件 (11行), 根目录整洁。
原逻辑完全不变, 仅做结构拆分。
2026-04-25 22:27:59 +08:00

36 lines
853 B
Python

"""
xcli_core - 小狸 Pro-CLI 核心模块
从 ai_cli.py 拆分优化的模块化架构。
"""
from .constants import *
from .sandbox import *
from .config import *
from .plugin_manager import LiuginManager
from .cli_core import AICLI, main
def ask_user_confirmation(prompt="确认执行?", default=False):
"""请求用户确认(兼容性存根,供插件调用)"""
try:
suffix = " [Y/n] " if default else " [y/N] "
response = input(prompt + suffix).strip().lower()
if not response:
return default
return response in ('y', 'yes', '是', '确认')
except (EOFError, KeyboardInterrupt):
return False
__all__ = [
'AICLI',
'LiuginManager',
'main',
'load_config',
'save_config',
'get_system_config',
'set_system_config',
'ask_user_confirmation',
]