技能 lake 修复
- 作者仓库星标 435
- 作者仓库 nvim
Lake Repair Skill (Direct Execution)
Direct execution skill for automated Lean build repair. Runs lake build, parses errors, and automatically fixes common mechanical errors in an iterative loop.
This skill executes inline without spawning a subagent.
Execution
Step 1: Parse Arguments
Extract flags from command input:
--clean: Runlake cleanbefore building--max-retries N: Maximum fix iterations (default: 3)--dry-run: Preview fixes without applying--module NAME: Build specific module only
clean=false
max_retries=3
dry_run=false
module=""
for arg in "$@"; do
case "$arg" in
--clean) clean=true ;;
--dry-run) dry_run=true ;;
--max-retries=*) max_retries="${arg#*=}" ;;
--module=*) module="${arg#*=}" ;;
esac
done
Step 2: Initial Clean (Optional)
If --clean flag is set:
if [ "$clean" = true ]; then
echo "Running lake clean..."
lake clean
fi
Step 3: Build Loop
Initialize tracking variables:
retry_count=0previous_errors=""(for cycle detection)total_fixes=0
Step 4: Run Build
Attempt to build the project:
if [ -n "$module" ]; then
build_output=$(lake build "$module" 2>&1)
else
build_output=$(lake build 2>&1)
fi
build_exit_code=$?
Step 5: Parse Build Errors
Extract errors and warnings from build output using regex pattern:
Pattern: ^(.+\.lean):(\d+):(\d+): (error|warning): (.+)$
Step 6: Classify Errors
| Error Pattern | Fix Type |
|---|---|
| Missing cases | missing_cases |
| Unused variable | unused_variable |
| Unused import | unused_import |
| All other | UNFIXABLE |
Step 7: Apply Fixes
Missing Cases Fix
Add match cases with sorry placeholders.
Unused Variable Fix
Rename by adding underscore prefix: {name} -> _{name}
Unused Import Fix
Remove the import line (only clean single-import lines).
Step 8: Final Report
After loop exits:
Lake Build Complete
===================
Build succeeded after {retry_count} iterations.
Fixes applied:
- {file}:{line} - {description}
All modules built successfully.
Error Handling
MCP Tool Failure
Fall back to lake build via Bash.
File Read/Write Failure
Skip that particular fix, continue with others.
Parse Failure
Treat as unfixable error.
Safety Measures
Conservative Fixes
- All missing case fixes use
sorryplaceholders - Unused variable fixes only add underscore prefix
- Unused import removal is cautious (single-import lines only)
Cycle Prevention
- Track error signatures between iterations
- Stop if same errors recur
- Hard limit via max_retries (default 3)
- 流狐分类
- 工程开发
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @benbrastmckie · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Extract flags from command input: --clean: Run lake clean before building --max-retries N: Maximum fix iterations (default: 3)
If --clean flag is set:
Initialize tracking variables: retrycount=0 previouserrors="" (for cycle detection)
Attempt to build the project:
Extract errors and warnings from build output using regex pattern:
Error Pattern · Fix Type Missing cases · missingcases Unused variable · unusedvariable
# Lake Repair Skill (Direct Execution)
Direct execution skill for automated Lean build repair. Runs `lake build`, parses errors, and automatically fixes common mechanical errors in an iterative loop.
This skill executes inline without spawning a subagent.
## Execution
### Step 1: Parse Arguments
Extract flags from command input:
- `--clean`: Run `lake clean` before building
- `--max-retries N`: Maximum fix iterations (default: 3)
- `--dry-run`: Preview fixes without applying
- `--module NAME`: Build specific module only
```bash
clean=false
max_retries=3
dry_run=false
module=""
for arg in "$@"; do
case "$arg" in
--clean) clean=true ;;
--dry-run) dry_run=true ;;
--max-retries=*) max_retries="${arg#*=}" ;;
--module=*) module="${arg#*=}" ;;
esac
done
```
---
### Step 2: Initial Clean (Optional)
If `--clean` flag is set:
```bash
if [ "$clean" = true ]; then
echo "Running lake clean..."
lake clean
fi
```
---
### Step 3: Build Loop
Initialize tracking variables:
- `retry_count=0`
- `previous_errors=""` (for cycle detection)
- `total_fixes=0`
---
### Step 4: Run Build
Attempt to build the project:
```bash
if [ -n "$module" ]; then
build_output=$(lake build "$module" 2>&1)
else
build_output=$(lake build 2>&1)
fi
build_exit_code=$?
```
---
### Step 5: Parse Build Errors
Extract errors and warnings from build output using regex pattern:
```
Pattern: ^(.+\.lean):(\d+):(\d+): (error|warning): (.+)$
```
---
### Step 6: Classify Errors
| Error Pattern | Fix Type |
|---------------|----------|
| Missing cases | missing_cases |
| Unused variable | unused_variable |
| Unused import | unused_import |
| All other | UNFIXABLE |
---
### Step 7: Apply Fixes
#### Missing Cases Fix
Add match cases with sorry placeholders.
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Execution → Step 1: Parse Arguments → Step 2: Initial Clean (Optional) → Step 3: Build Loop → Step 4: Run Build → Step 5: Parse Build Errors
要点 -> Direct execution skill for automated Lean build repair. · This skill executes inline without spawning a subagent. · Build succeeded after {retrycount} iterations. · All modules built successfully.
文件/命令 -> lake build · --clean · lake clean · --max-retries N · --dry-run · --module NAME · retrycount=0 · previouserrors=""
内容 SHA-256 -> db8ba0af0a9a
方法与流程
适用与边界
原文中的明确线索
lake build、--clean、lake clean、--max-retries N、--dry-run、--module NAME、retrycount=0、previouserrors=""