I Taught a Sloth to Write Its Own Chores (Then Put It in a Cage)
说明与用途
Sloth 是一个本地工具,使用 LLM 生成脚本,将 Downloads 文件夹中的文件按类型或内容排序,显示预览计划并支持撤销。
问题
Managing a cluttered Downloads folder with many unrelated files is tedious and error‑prone.
结果
Sloth automated sorting of a cluttered Downloads folder using a local LLM, sandboxed script execution, and offline file reading, achieving a clean folder structure with undo capability.
工作流
- 1. Run
python sloth.py "sort everything in Downloads by file type" - 2. A local Ollama model generates a short Python script using helper functions.
- 3. The script runs in a RestrictedPython cage and records intended actions without touching the disk.
- 4. Sloth displays a preview table of planned moves.
- 5. Press
yto apply the plan or any other key to cancel. - 6. Each applied run is added to an undo stack;
python sloth.py --undorestores the original state.
证据
Sloth is a single Python file that does file chores from one sentence.
The model's script never touches the disk. It can only call a few helpers (sloth.ls, sloth.move, sloth.match, sloth.read) that record what it wants to do.
Every applied run goes on an undo stack. --undo reverses it.
Everything runs locally through Ollama. No cloud, no API key, no per-run cost.
The cage is guardrails, not a fortress: RestrictedPython, a home-folder lock, blocked file-writing methods, and the fact that the script only plans.
- 记录日期: 2026-10-25T16:26:15.338Z