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 直接看到结构化数据,不再依赖脚本拼接的中文自然语言
This commit is contained in:
2026-06-02 10:32:27 +08:00
parent fac2016b7e
commit 81c736f873
5 changed files with 111 additions and 253 deletions
@@ -1,27 +1,26 @@
#!/bin/bash
# 列出定时任务(从 PostgreSQL
set -e
# 列出定时任务 → JSON 输出
DB_URL="${DATABASE_URL}"
if [ -z "$DB_URL" ]; then
echo "数据库未配置(DATABASE_URL"
exit 0
fi
[ -z "$DB_URL" ] && echo '{"tasks":[],"error":"数据库未配置"}' && exit 0
# 使用 psql 查询
psql "$DB_URL" -t -A -F '|' -c "
SELECT name, description, enabled, next_run_at, interval_seconds
FROM scheduled_tasks
ORDER BY name
" 2>/dev/null | while IFS='|' read -r name desc enabled next_run interval; do
if [ -n "$name" ]; then
echo "- $name${desc:+ ($desc)}"
echo " 启用: $enabled | 间隔: ${interval}s | 下次: ${next_run:-}"
fi
done
# 检查是否有任何任务
COUNT=$(psql "$DB_URL" -t -A -c "SELECT count(*) FROM scheduled_tasks" 2>/dev/null || echo "0")
if [ "$COUNT" = "0" ] || [ -z "$COUNT" ]; then
echo "暂无定时任务"
fi
SELECT jsonb_build_object(
'name', name,
'description', description,
'enabled', enabled,
'command', command,
'interval_seconds', interval_seconds,
'next_run_at', next_run_at
)
FROM scheduled_tasks ORDER BY name
" 2>/dev/null | python3 -c "
import sys, json
tasks = []
for line in sys.stdin:
line = line.strip()
if line:
try: tasks.append(json.loads(line))
except: pass
print(json.dumps({'tasks': tasks}, ensure_ascii=False))
"
[ -z "$(psql "$DB_URL" -t -A -c "SELECT count(*) FROM scheduled_tasks" 2>/dev/null)" ] && echo '{"tasks":[]}'