07490c4d38d562c412fa6070d9e8de01adbf0d24
此前只有手动的 /chat save|list|open,关终端就丢上下文。现升级为
opencode 式体验:每轮对话自动落盘、启动提示历史会话、/resume 一键恢复。
- 新增 xcli_core/session.py:Session 数据类(id/title/created_at/updated_at/
engine/model/messages)+ SessionManager(new/save/list/load/resolve,存
chat_history/<id>.json)。向后兼容旧 /chat 格式(无 id、用 conversation 键,
读取时回退用文件名作 id)。标题自动取首条 user 消息前若干字。
- HistoryMixin 升级(cli_history.py):新增 init_session_manager /
_autosave_session / handle_resume_command。自动保存首轮惰性建会话、
更新标题与 updated_at;/resume 列出(序号|ID)或按序号|ID|前缀恢复,
恢复时把 messages 载入 shared_conversation_history 并同步引擎。
- 集成:cli_base.__init__ 在 chat_history_dir 就绪后 init_session_manager;
cli_core 主循环 1395 行 process_conversation 后调用 _autosave_session;
新增 /resume|/sessions 路由(/sessions 等同 /resume)。
- 体验:启动时若有历史会话提示 /resume(含最近会话标题);run() 紧凑提示
与 /help 速查表均补 /resume(列出/恢复/开新会话)。
- 修复 cli_history.py 一处历史 typo:{Style.RESET型} -> {Style.RESET_ALL}
(旧 load_chat_history 在含消息时会抛 AttributeError)。
- 测试:新增 tests/test_session.py(12 项,覆盖兼容/新建/落盘/排序/解析/
自动保存/恢复/列表/未知token,全程临时目录不污染真实 config/chat_history)。
全量 242 passed(原 230)。
真实 CLI 冒烟:启动提示识别到历史会话、/resume 正确列出(含标题/时间/引擎/
条数)、/resume <id> 正确恢复并回显;已清理测试种入文件,chat_history 复原为空。
XiaoLi Pro-CLI
AI Programming Assistant — Code Editing · Git · Browser Automation · Multi-Agent
Features
- Dual AI Engines — Ollama local + OpenAI compatible (DeepSeek, Grok, SiliconFlow, etc.)
- Code Editing & Search — Precise replace, batch edit, symbol extraction, regex search
- Git Integration — Full Git operations + workflow automation
- Browser Automation — Playwright-driven, navigate/interact/screenshot/JS execution
- Sub-Agent System — Multi-agent parallel collaboration with task delegation
- Unified Safety — AI risk analysis + 3-mode switching (Normal/Manual/Unrestricted)
- 15 Plugins, 141 Operations — Code, Git, browser, engineering, file management, etc.
- 113 Automated Tests — pytest coverage for all plugins and core modules
Quick Start
git clone https://gitee.com/shuiyu1123/xiaoli-cli.git
cd xiaoli-cli
pip install -r requirements.txt
python ai_cli.py
AI Engines
| Engine | Type | Description |
|---|---|---|
ollama |
Local | Ollama local models, no API key needed |
openai |
Cloud/Local | OpenAI compatible: DeepSeek, Grok, SiliconFlow, local vLLM |
Plugins (15)
Core Productivity
| Plugin | Ops | Description |
|---|---|---|
code_editor |
23 | Code editing + search. replace/batch/find/regex/symbols/imports/callers/todo |
git_tools |
20 | Git. status/diff/log/commit/branch + smart-commit/changelog/contributors |
cmd_executor |
1 | Shell commands. Cross-platform, timeout, danger blocking |
file_manager |
11 | File system. list/read/write/copy/move/delete/search/info/mkdir |
auto_engineer |
16 | Engineering. lint/format/test/build/deps + complexity/security/metrics |
task_manager |
7 | Task tracking. add/list/complete/delete/clear with JSON persistence |
Advanced
| Plugin | Ops | Description |
|---|---|---|
sub_agent |
8 | Sub-Agent system. spawn/list/status/result/send/kill, parallel collaboration |
browser_auto |
31 | Browser automation. navigate/click/fill/screenshot/JS/PDF/cookies |
tool_search |
— | Tool discovery. Search available plugins by keyword |
Utilities
| Plugin | Description |
|---|---|
network_tools |
ping/get/status/headers/ip |
ai_search |
AI search via jina.ai + web content extraction |
frontend_tester |
HTML/CSS/JS syntax check, responsive validation |
speech_recognition |
Voice recording + speech-to-text |
audio_player |
Audio playback |
send_image |
Send images to phone (Clawli mode) |
Safety
Three modes (/safe to switch):
| Mode | Icon | Behavior |
|---|---|---|
| Normal (default) | AI analyzes risk, confirms only when risk detected | |
| Manual | All commands require user confirmation | |
| Unrestricted | Execute directly, no checking |
Testing
python -m pytest tests/ -v # 113 tests
License
Releases
3