Install
openclaw skills install laosi-quick-todo待办清单 - 最轻的任务管理,语音添加、划掉完成、进度统计、优先级排序,本地JSON存储
openclaw skills install laosi-quick-todo激活词: 待办 / 任务 / todo / 加一个任务
import os, json
from datetime import datetime
TASKS_FILE = os.path.join(os.path.dirname(__file__), "quick_tasks.json")
class QuickTodo:
def __init__(self):
os.makedirs(os.path.dirname(TASKS_FILE), exist_ok=True)
self.tasks = self._load()
def _load(self):
if os.path.exists(TASKS_FILE):
with open(TASKS_FILE, encoding="utf-8") as f:
return json.load(f)
return []
def _save(self):
with open(TASKS_FILE, "w", encoding="utf-8") as f:
json.dump(self.tasks, f, ensure_ascii=False, indent=2)
def add(self, task: str, priority: str = "medium", due: str = None) -> dict:
"""添加新任务"""
item = {
"id": len(self.tasks) + 1,
"task": task,
"priority": priority,
"done": False,
"created": datetime.now().isoformat(),
"due": due,
"completed_at": None
}
self.tasks.append(item)
self._save()
return item
def done(self, task_id: int) -> bool:
"""标记完成"""
for t in self.tasks:
if t["id"] == task_id:
t["done"] = True
t["completed_at"] = datetime.now().isoformat()
self._save()
return True
return False
def delete(self, task_id: int) -> bool:
"""删除任务"""
before = len(self.tasks)
self.tasks = [t for t in self.tasks if t["id"] != task_id]
if len(self.tasks) < before:
self._save()
return True
return False
def list(self, filter_done: bool = None, priority: str = None) -> list:
"""查看任务,支持筛选"""
results = self.tasks
if filter_done is not None:
results = [t for t in results if t["done"] == filter_done]
if priority:
results = [t for t in results if t["priority"] == priority]
# 排序:待办优先、高优先级优先
results.sort(key=lambda t: (
t["done"],
{"high": 0, "medium": 1, "low": 2}.get(t["priority"], 3),
t["created"]
))
return results
def stats(self) -> dict:
"""进度统计"""
total = len(self.tasks)
done_count = sum(1 for t in self.tasks if t["done"])
pending = total - done_count
return {
"total": total,
"done": done_count,
"pending": pending,
"progress": f"{done_count}/{total}",
"pct": round(done_count / total * 100, 1) if total > 0 else 0
}
# 使用示例
todo = QuickTodo()
todo.add("学习Transformer架构", priority="high")
todo.add("写周报", priority="medium", due="2026-05-30")
todo.add("整理书签", priority="low")
# 查看待办
for t in todo.list(filter_done=False):
pri = {"high": "🔴", "medium": "🟡", "low": "⚪"}[t["priority"]]
print(f"[{t['id']}] {pri} {t['task']}")
# 标记完成
todo.done(1)
# 查看统计
s = todo.stats()
print(f"进度: {s['done']}/{s['total']} ({s['pct']}%)")
# 添加一个高优先级任务
python -c "from quick_todo import QuickTodo; QuickTodo().add('读FlashAttention论文', priority='high')"
# 标记完成
python -c "from quick_todo import QuickTodo; QuickTodo().done(1)"
# 查看统计
python -c "from quick_todo import QuickTodo; print(QuickTodo().stats())"
[
{
"id": 1,
"task": "学习Transformer架构",
"priority": "high",
"done": true,
"created": "2026-05-28T10:00:00",
"due": null,
"completed_at": "2026-05-28T11:30:00"
}
]