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
2026-04-25 11:06:53 +08:00
2026-04-25 13:28:21 +08:00
2026-04-25 13:26:05 +08:00
2026-04-25 11:47:49 +08:00
2026-04-25 13:26:05 +08:00
2026-04-25 13:26:05 +08:00
2026-04-25 13:26:05 +08:00

XiaoLi Pro-CLI

Intelligent Programming Assistant — Precise Code Editing, Code Search, Git Integration, Multi-AI Engine Support

version python license


✨ Features

  • 🤖 Multi AI Engines — Ollama, MiMo, GLM, QwQ, MaaS and more
  • 🔧 Precise Code Editing — Search & replace, batch edits, diff comparison, line-level operations
  • 🔍 Code Search & Understanding — Cross-file search, regex matching, symbol extraction, dependency analysis
  • 🔄 Git Integration — Full Git workflow support
  • 🎨 Dual UI Modes — TUI graphical interface (default) + traditional CLI mode
  • 🧩 Triple Protocol Plugin System — Plugin / Skill / MCP protocols
  • 🌐 WebSocket Remote — Remote connections and QQ bot integration
  • 🛡️ Code Sandbox — Secure code execution environment

📦 Quick Start

Installation

git clone https://gitee.com/shuiyu1123/xiaoli-cli.git
cd xiaoli-cli
pip install -r requirements.txt

Usage

# TUI mode (default, requires textual)
python -m xiaoli

# CLI mode
python -m xiaoli --cli

# Specify engine
python -m xiaoli --engine mimo

# Show version
python -m xiaoli --version

Dependencies

Core:

Package Purpose
colorama Terminal colored output
openai OpenAI compatible API
requests HTTP requests
Pillow Image processing
numpy Numerical computation

Optional:

Package Purpose
textual TUI mode
opencv-python Enhanced image processing
pygame Audio playback
websockets WebSocket remote

🏗️ Architecture

xiaoli-cli/
├── xiaoli/                     # Core package (v3.6+ modular architecture)
│   ├── __main__.py             # Entry point (python -m xiaoli)
│   ├── app.py                  # Main application (orchestration layer)
│   ├── config.py               # Configuration management
│   ├── engines.py              # AI engine management
│   ├── sandbox.py              # Code execution sandbox
│   ├── prompt.py               # System prompts
│   ├── tui.py                  # TUI interface
│   ├── conversation/           # Conversation handling
│   └── display/                # Display output (CLI/TUI dual mode)
│
├── plugins/                    # Plugins (Plugin protocol)
│   ├── code_editor.py          # Precise code editor ⭐
│   ├── code_search.py          # Code search & understanding ⭐
│   ├── git_tools.py            # Git version control ⭐
│   └── ...                     # 20+ plugins
│
├── skills/                     # Skills (Skill protocol)
├── ai_engines/                 # AI engine implementations
├── image_engine/               # Image processing engines
├── tests/                      # Test suite
└── requirements.txt            # Dependencies

🎮 Commands

Command Description
/help Show help
/quit Exit
/about Show version info
/model <engine> Switch AI engine
/engine list List available engines
/chat save <name> Save conversation
/chat list List conversations
/chat open <name> Load conversation
/tui Toggle TUI mode

🔌 Plugin Development

XiaoLi supports three plugin protocols. See Development Documentation for details.

Plugin Protocol

class Plugin:
    def get_tool_info(self):
        return {"name": "my_tool", "description": "...", "keywords": [...]}
    
    def handle(self, args: str) -> str:
        return "result"

Skill Protocol

from skills.base import Skill, SkillResult

class MySkill(Skill):
    name = "my_skill"
    def run(self, **kwargs) -> SkillResult:
        return SkillResult(success=True, message="Done")

MCP Protocol

Supports Anthropic/OpenAI Model Context Protocol for seamless external tool integration.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Create a Pull Request

📄 License

This project is licensed under the MIT License.

S
Description
No description provided
Readme
10 MiB
0 Stars 1 Watchers 0 Forks