feat: 新增现代化命令替代功能 v0.2.0
🎯 主要功能: - 智能检测系统中已安装的现代化命令行工具 - 支持 44 种默认命令映射 (ls→eza, cat→bat, find→fd 等) - 灵活的环境变量配置系统 - AI 提示词集成,优先推荐现代化工具 - 完整的配置状态显示 ⚙️ 配置方式: - 环境变量: AI_SHELL_MODERN_COMMANDS="ls:eza,cat:bat" - .env 文件配置支持 - 动态配置检测和合并 🔧 技术实现: - 新增 get_modern_commands() 配置管理 - 新增 get_available_modern_commands() 系统检测 - 新增 generate_modern_commands_prompt() 提示词生成 - 更新 AI agent 系统提示词 - 完善配置显示和测试脚本 📊 支持的现代化工具: 文件操作: eza, bat, fd, tree 文本处理: rg, sd, choose, delta 系统监控: procs, htop, ncdu, duf 网络工具: gping, httpie, aria2c 编辑器: nvim, micro 其他: zoxide, trash, ouch, pnpm
This commit is contained in:
@ -80,7 +80,8 @@ def create_parser() -> argparse.ArgumentParser:
|
||||
|
||||
def show_config() -> None:
|
||||
"""Show current configuration"""
|
||||
from .config import get_api_key, get_base_url, get_model, get_timeout, get_max_retries, validate_config
|
||||
from .config import (get_api_key, get_base_url, get_model, get_timeout,
|
||||
get_max_retries, validate_config, get_available_modern_commands)
|
||||
|
||||
print("AI Shell Configuration:")
|
||||
print(f" Model: {get_model()}")
|
||||
@ -110,6 +111,30 @@ def show_config() -> None:
|
||||
print(" AI_SHELL_MODEL - Model name")
|
||||
print(" AI_SHELL_TIMEOUT - Request timeout (seconds)")
|
||||
print(" AI_SHELL_MAX_RETRIES - Maximum retry attempts")
|
||||
print(" AI_SHELL_MODERN_COMMANDS - Custom modern command alternatives")
|
||||
|
||||
# Show modern commands configuration
|
||||
modern_commands = get_available_modern_commands()
|
||||
if modern_commands:
|
||||
print(f"\n现代化命令替代 ({len(modern_commands)} 个可用):")
|
||||
|
||||
# Group commands for better display
|
||||
active_alternatives = {k: v for k, v in modern_commands.items() if k != v}
|
||||
unchanged_commands = {k: v for k, v in modern_commands.items() if k == v}
|
||||
|
||||
if active_alternatives:
|
||||
print(" 已启用的替代:")
|
||||
for old_cmd, new_cmd in sorted(active_alternatives.items()):
|
||||
print(f" {old_cmd} → {new_cmd}")
|
||||
|
||||
if unchanged_commands:
|
||||
print(f" 保持原样: {', '.join(sorted(unchanged_commands.keys()))}")
|
||||
|
||||
print("\n 自定义配置格式:")
|
||||
print(" export AI_SHELL_MODERN_COMMANDS=\"old1:new1,old2:new2\"")
|
||||
print(" 例如: export AI_SHELL_MODERN_COMMANDS=\"ls:exa,cat:bat,find:fd\"")
|
||||
else:
|
||||
print("\n现代化命令替代: 未检测到可用的现代化工具")
|
||||
|
||||
def main() -> None:
|
||||
"""Main entry point"""
|
||||
|
Reference in New Issue
Block a user