技能精益版
- 作者仓库星标 435
- 作者仓库 nvim
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @benbrastmckie · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
第 1 步:解析参数
提取模式和标志:第一个非标志参数:模式(`check`,`upgrade`,`rollback`) - 默认:`check``--dry-run`:预览模式`--version VERSION`:升级的目标版本
步骤 3:按模式路由
检查 -> 显示当前版本状态升级 -> 通过备份回滚执行交互式升级 -> 从以前的备份恢复
# Lean Version Management Skill (Direct Execution)
Direct execution skill for managing Lean toolchain and Mathlib versions. Provides check, upgrade, rollback, and dry-run modes. Creates backups before upgrades and supports interactive user confirmation.
This skill executes inline without spawning a subagent.
## Execution
### Step 1: Parse Arguments
Extract mode and flags:
- First non-flag argument: Mode (`check`, `upgrade`, `rollback`) - default: `check`
- `--dry-run`: Preview mode
- `--version VERSION`: Target version for upgrade
```bash
mode="check"
dry_run=false
target_version=""
for arg in "$@"; do
case "$arg" in
check|upgrade|rollback) mode="$arg" ;;
--dry-run) dry_run=true ;;
--version=*) target_version="${arg#*=}" ;;
esac
done
```
---
### Step 2: Read Current State
```bash
# Read current toolchain
if [ -f "lean-toolchain" ]; then
current_toolchain=$(cat lean-toolchain | tr -d '\n')
else
current_toolchain="not found"
fi
# Read current Mathlib version from lakefile.lean
if [ -f "lakefile.lean" ]; then
current_mathlib=$(grep -oP 'mathlib.*@\s*"\K[^"]+' lakefile.lean 2>/dev/null || echo "not found")
else
current_mathlib="not found"
fi
```
---
### Step 3: Route by Mode
- **check** -> Display current version status
- **upgrade** -> Perform interactive upgrade with backup
- **rollback** -> Restore from a previous backup
---
## Check Mode
Display current version status:
```
Lean Version Status
===================
Current Configuration:
- Toolchain: {current_toolchain}
- Mathlib: {current_mathlib}
Installed Toolchains:
{elan_status}
Backups Available:
{backup_list}
```
---
## Upgrade Mode
### Create Backup
```bash
mkdir -p .lean-version-backup
timestamp=$(date +%Y%m%d_%H%M%S)
cp lean-toolchain ".lean-version-backup/lean-toolchain.$timestamp"
cp lakefile.lean ".lean-version-backup/lakefile.lean.$timestamp"
```
### Apply Changes
```bash
echo "$new_toolchain" > lean-toolchain
sed -i "s|@ \"v[0-9.]*\(-rc[0-9]*\)\?\"|@ \"$new_mathlib\"|g" lakefile.lean
```
### Post-Upgrade
```bash
lake update
lake exe cache get
```
---
## Rollback Mode
### List Backups
```bash
timestamps=$(ls .lean-version-backup/lean-toolchain.* 2>/dev/null | \
sed 's|.*/lean-toolchain\.||' | sort -r | head -5)
```
### Restore
```bash
cp ".lean-version-backup/lean-toolchain.$selected_timestamp" lean-toolchain
cp ".lean-version-backup/lakefile.lean.$selected_timestamp" lakefile.lean
lake update
lake exe cache get
```
---
## Safety Measures
### Backup Before Changes
- Always create timestamped backup before upgrade
- Backup includes: `lean-toolchain`, `lakefile.lean`, `lake-manifest.json`
- Location: `.lean-version-backup/`
- Retention: Keep 3 most recent
### Dry-Run Support
- `--dry-run` previews all changes without applying
### User Confirmation
- Upgrade mode requires explicit confirmation via AskUserQuestion
章节与文件索引
按说明文件中的顺序排列。
第 1 步:解析参数
步骤 3:按模式路由
检查模式
更改前备份
试运行支持
文件/命令 -> check · upgrade · rollback · --dry-run · --version VERSION · lean-toolchain · lakefile.lean · lake-manifest.json
内容校验值 -> 52d4af513449
当前原文的自动摘译,尚未人工审校。
检查模式
显示当前版本状态:
更改前备份
升级前始终创建带时间戳的备份 备份包括:
lean-toolchain、lakefile.lean、lake-manifest.json位置:.lean-version-backup/保留:保留 3 个最新的试运行支持
--dry-run预览所有更改而不应用