Files
iAs/resources/skills/get_current_datetime/scripts/datetime.sh
T
wunianxiao 81c736f873 refactor: skill 脚本输出改为结构化 JSON
- query_weather: {location, now: {temp,text}, forecast: [{date,day,night,tempMin,tempMax}]}
- search_web: {query, answer, results: [{title,url,content}]}
- get_current_datetime: {datetime}
- list_scheduled_tasks: {tasks: [{name,description,enabled,command,...}]}
- manage_scheduled_task: {ok, action, name} / {error}

LLM 直接看到结构化数据,不再依赖脚本拼接的中文自然语言
2026-06-02 10:32:27 +08:00

17 lines
460 B
Bash
Executable File

#!/bin/bash
# 读取 stdin JSON 参数
read -r input
format=$(echo "$input" | python3 -c "
import sys, json
try:
d = json.load(sys.stdin)
print(d.get('format', 'full'))
except: print('full')
" 2>/dev/null || echo "full")
case "$format" in
date) TZ='Asia/Shanghai' date '+{"datetime": "%Y-%m-%d"}' ;;
time) TZ='Asia/Shanghai' date '+{"datetime": "%H:%M:%S"}' ;;
*) TZ='Asia/Shanghai' date '+{"datetime": "%Y-%m-%d %H:%M:%S"}' ;;
esac