Files
ai-shell/ai_shell/modern_commands.toml
zackeryyy wang afbbb1fbb0 refactor: 重构现代化命令管理为基于配置文件的安全方案
🎯 解决问题:
- 避免推荐用户系统中不存在的工具
- 防止因缺失工具导致的命令执行失败
- 提供更安全、更灵活的现代化命令管理

🔧 主要改进:
- 新增 ai_shell/modern_commands.toml 配置文件
- 智能检测系统中已安装的现代化工具
- 只推荐实际可用的工具,安全回退到原始命令
- 完整的工具描述、分类和安装提示

📦 配置文件特性:
- 28 个命令映射配置
- 20 个工具描述说明
- 8 个工具分类组织
- 6 个详细安装提示

🛠️ 新增管理工具:
- scripts/manage_modern_commands.py 配置管理脚本
- 支持验证、列表、安装建议等功能
- 完整的配置状态检查和报告

🔍 用户体验优化:
- ai --config 显示详细的工具状态
- 区分已启用、保持原样、未安装的工具
- 提供具体的安装命令和说明
- 支持环境变量和配置文件自定义

🛡️ 安全保障:
- 绝不推荐不存在的工具
- 优雅降级到原始命令
- 保持完全向后兼容性

📋 技术实现:
- 添加 tomli 依赖支持 TOML 解析
- 重构配置加载逻辑
- 智能工具检测和状态管理
- 完善的错误处理和回退机制
2025-07-12 22:44:31 +08:00

99 lines
3.7 KiB
TOML
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.

# AI Shell 现代化命令替代配置文件
# 只有在系统中实际安装了对应工具时,才会启用替代
[commands]
# 文件操作
ls = "eza" # 现代化的 ls支持图标和颜色
cat = "bat" # 带语法高亮的 cat
find = "fd" # 更快更友好的 find
tree = "tree" # 保持原样(已经很现代)
# 文本处理
grep = "rg" # ripgrep - 更快的文本搜索
sed = "sd" # 更简单的 sed 替代
awk = "choose" # 人性化的 awk 替代
cut = "choose" # cut 的替代
diff = "delta" # 带语法高亮的 diff
less = "bat" # 用 bat 进行分页显示
more = "bat" # 用 bat 进行分页显示
# 系统监控
ps = "procs" # 现代化的进程查看器
top = "htop" # 交互式进程监控
du = "ncdu" # 交互式磁盘使用分析
df = "duf" # 更好的磁盘空间显示
# 网络工具
ping = "gping" # 带图形的 ping
curl = "httpie" # 更友好的 HTTP 客户端
wget = "aria2c" # 多连接下载器
# 编辑器
vim = "nvim" # 现代化的 vim
nano = "micro" # 现代化的 nano 替代
# 导航和文件管理
cd = "zoxide" # 智能目录跳转(需要初始化)
rm = "trash" # 安全删除(移到回收站)
# 压缩工具
tar = "ouch" # 通用压缩工具
zip = "ouch" # 通用压缩工具
unzip = "ouch" # 通用压缩工具
# 开发工具
npm = "pnpm" # 更快的 npm 替代
yarn = "pnpm" # 更快的 yarn 替代
scp = "rsync" # 更高效的文件传输
# 保持原样的命令(不需要替代)
# git = "git"
# docker = "docker"
# python = "python"
# node = "node"
# ssh = "ssh"
# rsync = "rsync"
[descriptions]
# 工具描述,用于生成更好的 AI 提示
eza = "现代化的 ls 替代,支持图标、颜色和更好的格式化"
bat = "带语法高亮和行号的 cat 替代"
fd = "更快、更用户友好的 find 替代"
rg = "极快的文本搜索工具,比 grep 更快"
sd = "更简单直观的 sed 替代"
choose = "人性化的字段选择工具,可替代 awk 和 cut"
delta = "带语法高亮的 git diff 查看器"
procs = "现代化的进程查看器,比 ps 更直观"
htop = "交互式的系统监控工具"
ncdu = "交互式的磁盘使用分析工具"
duf = "更美观的磁盘空间显示工具"
gping = "带图形显示的 ping 工具"
httpie = "更友好的 HTTP 客户端"
aria2c = "支持多连接的下载工具"
nvim = "现代化的 vim 编辑器"
micro = "现代化的终端文本编辑器"
zoxide = "智能的目录跳转工具"
trash = "安全的文件删除工具(移到回收站)"
ouch = "通用的压缩/解压工具"
pnpm = "更快、更高效的 Node.js 包管理器"
[categories]
# 工具分类,用于更好的组织和显示
file_operations = ["ls", "cat", "find", "tree", "rm"]
text_processing = ["grep", "sed", "awk", "cut", "diff", "less", "more"]
system_monitoring = ["ps", "top", "du", "df"]
network_tools = ["ping", "curl", "wget"]
editors = ["vim", "nano"]
navigation = ["cd"]
compression = ["tar", "zip", "unzip"]
development = ["npm", "yarn", "scp"]
[installation_hints]
# 安装提示,当工具不存在时可以提供安装建议
eza = "brew install eza # macOS\nsudo apt install eza # Ubuntu\ncargo install eza # Rust"
bat = "brew install bat # macOS\nsudo apt install bat # Ubuntu\ncargo install bat # Rust"
fd = "brew install fd # macOS\nsudo apt install fd-find # Ubuntu\ncargo install fd-find # Rust"
rg = "brew install ripgrep # macOS\nsudo apt install ripgrep # Ubuntu\ncargo install ripgrep # Rust"
ncdu = "brew install ncdu # macOS\nsudo apt install ncdu # Ubuntu"
htop = "brew install htop # macOS\nsudo apt install htop # Ubuntu"