feat: 支持 OpenClaw skill 格式 (SKILL.md + scripts/)

- scan_skills() 支持两种格式: .yaml 文件 和 目录/SKILL.md
- 解析 SKILL.md 的 YAML frontmatter 提取 name/description
- 自动扫描 scripts/ 子目录的 .py 脚本
- skill_exec 支持 asyncio 子进程执行脚本
- 新增示例 OpenClaw 技能: skills/time-tool/
This commit is contained in:
2026-04-23 23:53:45 +08:00
parent 1c42ba0812
commit 28da16829f
5 changed files with 215 additions and 7 deletions

19
skills/time-tool/SKILL.md Normal file
View File

@@ -0,0 +1,19 @@
---
name: time-tool
description: "时间工具 - 获取当前时间和日期信息"
---
# 时间工具
获取当前时间、日期信息,以及进行简单的日期计算。
## 使用方法
```bash
python3 scripts/time_info.py [时区]
```
## 功能
- 获取当前时间(支持指定时区)
- 获取当前日期和星期
- 输出格式化的时间信息

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""时间信息脚本 - OpenClaw skill 示例"""
import sys
from datetime import datetime
try:
import pytz
HAS_PYTZ = True
except ImportError:
HAS_PYTZ = False
def main():
tz_name = sys.argv[1] if len(sys.argv) > 1 else "Asia/Shanghai"
if HAS_PYTZ:
try:
tz = pytz.timezone(tz_name)
now = datetime.now(tz)
except Exception:
now = datetime.now()
tz_name = "本地时间"
else:
now = datetime.now()
tz_name = "本地时间"
weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
print(f"时区: {tz_name}")
print(f"日期: {now.strftime('%Y年%m月%d')}")
print(f"星期: {weekdays[now.weekday()]}")
print(f"时间: {now.strftime('%H:%M:%S')}")
if __name__ == "__main__":
main()