技能 lean Version
- 作者仓库星标 435
- 作者仓库 nvim
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
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
# 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
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
echo "$new_toolchain" > lean-toolchain
sed -i "s|@ \"v[0-9.]*\(-rc[0-9]*\)\?\"|@ \"$new_mathlib\"|g" lakefile.lean
Post-Upgrade
lake update
lake exe cache get
Rollback Mode
List Backups
timestamps=$(ls .lean-version-backup/lean-toolchain.* 2>/dev/null | \
sed 's|.*/lean-toolchain\.||' | sort -r | head -5)
Restore
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-runpreviews all changes without applying
User Confirmation
- Upgrade mode requires explicit confirmation via AskUserQuestion
- 流狐分类
- 通用
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @benbrastmckie · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Extract mode and flags: First non-flag argument: Mode (check, upgrade, rollback) - default: check --dry-run: Preview mode
Step 2: Read Current State
check -> Display current version status upgrade -> Perform interactive upgrade with backup rollback -> Restore from a previous backup
# 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)
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Execution → Step 1: Parse Arguments → Step 2: Read Current State → Step 3: Route by Mode → Check Mode → Upgrade Mode
要点 -> check · upgrade · rollback · Direct execution skill for managing Lean toolchain and Mathlib versions. · This skill executes inline without spawning a subagent.
文件/命令 -> check · upgrade · rollback · --dry-run · --version VERSION · lean-toolchain · lakefile.lean · lake-manifest.json
内容 SHA-256 -> 52d4af513449
方法与流程
适用与边界
原文中的明确线索
check、upgrade、rollback、--dry-run、--version VERSION、lean-toolchain、lakefile.lean、lake-manifest.json