Files
xiaoli-cli/xiaoli/__main__.py
T
Xiaoli Dev fe93d7340f feat: 重写 TUI - 暗色主题 + 现代布局
- 全新 xiaoli/tui.py: 独立 TUI 模块
- 暗色主题 (#0a0e14 背景)
- 侧栏: 引擎列表 + 工具列表
- 聊天区: Markdown 渲染 + 语法高亮
- 快捷键: Ctrl+L 清屏, Ctrl+N 新对话, F1 侧栏
- 状态栏: 实时状态显示
- 命令: /help, /model, /clear, /cli
- 降级: Textual 不可用时自动切 CLI

本次更新由 mimo 自动化执行,与开发者无关。
2026-04-25 11:23:02 +08:00

95 lines
9.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""入口点 - python -m xiaoli"""
import sys
import os
import argparse
import time
from colorama import init
# 确保项目根目录在 sys.path 中
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def main():
parser = argparse.ArgumentParser(description="小狸 Pro-CLI - 智能编程助手")
parser.add_argument('--cli', action='store_true', help='使用传统 CLI 模式(默认 TUI)')
parser.add_argument('--engine', type=str, help='指定 AI 引擎')
parser.add_argument('--version', action='store_true', help='显示版本')
args = parser.parse_args()
init(autoreset=True)
if args.version:
from xiaoli import __version__
print(f"小狸 Pro-CLI v{__version__}")
return
# 启动动画
_show_art()
# 检查 Textual 可用性
if not args.cli:
try:
from xiaoli.tui import TEXTUAL_AVAILABLE
if not TEXTUAL_AVAILABLE:
raise ImportError
except ImportError:
print("⚠️ Textual 未安装,自动切换到命令行模式")
print(" 安装 TUI: pip install textual rich")
args.cli = True
from xiaoli.app import App
app = App()
if args.engine:
app._switch_model(args.engine)
if args.cli:
app.run()
else:
app._run_tui()
def _show_art():
"""启动艺术字"""
art = [
"█████████████████████████████████████████████████████████████████████████████████████████████████████",
"██████████ ▒████████████████████████████████████████████████████",
"██████████ ░██████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████",
"██████████ ▓█████████████████████████████████████████████████████████",
"██████████ ▒███████████████████████████████████████████████████████████",
"██████████ █████████████████████████████████████████████████████████████",
"██████████ ███████████████████████████████████████████████████████████████",
"██████████ ▓███████████████████████████████████████████████████████████████",
"██████████ ░████████████████████████████████████████████████████████████████",
"██████████ ██████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████",
"██████████ ▓████████████████████████████████████████████████████████████████████",
"██████████ ░██████████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████████",
"██████████ ██████████████████████████████████████████████████████████████████████████",
"██████████ ░██████████████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████████████",
"██████████ ▓██████████████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████████████",
"██████████ ████████████████████████████████████████████████████████████████████████████",
"███████████ ████████████████████████████████████████████████████████████████████████████",
"█████████████▓ ████████████████████████████████████████████████████████████████████████████",
"█████████████████ ▓██████████████████████████████████████████████████████████████████████████",
"███████████████████▒ ████████████████████████████████████████████████████████████████████████████",
"█████████████████████████████████████████████████████████████████████████████████████████████████████",
"█████████████████████████████████████████████████████████████████████████████████████████████████████",
]
for line in art:
try:
print(line, flush=True)
except UnicodeEncodeError:
pass
time.sleep(0.03)
if __name__ == "__main__":
main()