From daa5bf345a802aa5e7b444cec870f5f4ee9e51be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Tue, 31 Mar 2026 16:23:03 +0800 Subject: [PATCH] update schedule skill --- skills/schedule-job/SKILL.md | 141 ++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/skills/schedule-job/SKILL.md b/skills/schedule-job/SKILL.md index 587657a..5f600ba 100644 --- a/skills/schedule-job/SKILL.md +++ b/skills/schedule-job/SKILL.md @@ -1,166 +1,167 @@ --- name: schedule-job -description: 定时任务管理 - 为用户创建、管理和查看定时任务(支持 cron 周期任务和一次性任务) +description: Scheduled Task Management - Create, manage, and view scheduled tasks for users (supports cron recurring tasks and one-time tasks) --- -# Schedule Job - 定时任务管理 +# Schedule Job - Scheduled Task Management -管理用户的定时任务,支持 cron 周期性任务和一次性定时任务。任务到期后系统自动执行 AI 对话。 +Manage scheduled tasks for users, supporting cron recurring tasks and one-time scheduled tasks. The system automatically executes AI conversations when tasks are due. ## Quick Start -用户请求创建定时任务时: -1. 确认任务类型(周期 cron / 一次性 once) -2. 确定时间(cron 表达式或具体时间)和时区 -3. 确定发送给 AI 的消息内容 -4. 调用 schedule_manager.py 创建任务 +When a user requests to create a scheduled task: +1. Confirm the task type (recurring cron / one-time once) +2. Determine the time (cron expression or specific time) and timezone +3. Confirm notification method: Check the currently enabled skills in the context and recommend a suitable notification method to the user (e.g., email, Telegram, etc.) for confirmation. If no notification skills are available, proactively ask the user: "How would you like to be notified when the scheduled task completes?" +4. Compose the message content to send to the AI (refer to Message Writing Guidelines) +5. Call schedule_manager.py to create the task ## Instructions -### 工具路径 +### Tool Path -所有操作通过 shell 命令执行: +All operations are executed via shell commands: ```bash python {skill_dir}/scripts/schedule_manager.py [options] ``` -### 可用命令 +### Available Commands -#### 列出任务 +#### List Tasks ```bash python {skill_dir}/scripts/schedule_manager.py list python {skill_dir}/scripts/schedule_manager.py list --format brief ``` -#### 添加 Cron 周期任务 +#### Add Cron Recurring Task ```bash python {skill_dir}/scripts/schedule_manager.py add \ - --name "任务名称" \ + --name "Task Name" \ --type cron \ --schedule "0 9 * * *" \ --timezone "Asia/Tokyo" \ - --message "请帮我搜索并总结今天的重要科技新闻,用简洁的方式列出 Top 5。完成后,根据当前启用的skill选择合适的通知方式将结果推送给用户。" + --message "Please search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user." ``` -#### 添加一次性任务 +#### Add One-Time Task ```bash python {skill_dir}/scripts/schedule_manager.py add \ - --name "会议提醒" \ + --name "Meeting Reminder" \ --type once \ --scheduled-at "2026-04-01T10:00:00+09:00" \ - --message "用户有一个日程提醒到期了,日程内容是:「10点参加会议」。请根据日程内容组织合适的提醒话术,然后根据当前启用的skill选择合适的通知方式将提醒发送给用户。" + --message "A scheduled reminder for the user has arrived. The schedule content is: 'Meeting at 10:00'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user." ``` -#### 编辑任务 +#### Edit Task ```bash python {skill_dir}/scripts/schedule_manager.py edit \ --schedule "0 10 * * 1-5" \ - --message "新的消息内容" + --message "New message content" ``` -#### 删除任务 +#### Delete Task ```bash python {skill_dir}/scripts/schedule_manager.py delete ``` -#### 暂停/恢复任务 +#### Pause/Resume Task ```bash python {skill_dir}/scripts/schedule_manager.py toggle ``` -#### 查看执行日志 +#### View Execution Logs ```bash python {skill_dir}/scripts/schedule_manager.py logs --limit 10 python {skill_dir}/scripts/schedule_manager.py logs --task-id ``` -### 时区映射 +### Timezone Mapping -根据用户语言自动推荐时区: -- 中文 (zh) → Asia/Shanghai (UTC+8) -- 日语 (ja/jp) → Asia/Tokyo (UTC+9) -- 英语 (en) → UTC +Automatically recommend timezone based on user language: +- Chinese (zh) → Asia/Shanghai (UTC+8) +- Japanese (ja/jp) → Asia/Tokyo (UTC+9) +- English (en) → UTC -### Cron 表达式说明 +### Cron Expression Reference -标准 5 字段格式:`分 时 日 月 星期` +Standard 5-field format: `minute hour day-of-month month day-of-week` -常用示例: -| 表达式 | 含义 | -|--------|------| -| `0 9 * * *` | 每天 9:00 | -| `0 9 * * 1-5` | 周一到周五 9:00 | -| `30 8 * * 1` | 每周一 8:30 | -| `0 */2 * * *` | 每 2 小时 | -| `0 9,18 * * *` | 每天 9:00 和 18:00 | +Common examples: +| Expression | Meaning | +|-----------|---------| +| `0 9 * * *` | Every day at 9:00 | +| `0 9 * * 1-5` | Monday to Friday at 9:00 | +| `30 8 * * 1` | Every Monday at 8:30 | +| `0 */2 * * *` | Every 2 hours | +| `0 9,18 * * *` | Every day at 9:00 and 18:00 | -**注意**: cron 表达式的时间基于 --timezone 指定的时区。 +**Note**: Cron expression times are based on the timezone specified by --timezone. -### 一次性任务时间格式 +### One-Time Task Time Format -支持 ISO 8601 格式(推荐带时区偏移): -- `2026-04-01T10:00:00+09:00` (日本时间) +Supports ISO 8601 format (timezone offset recommended): +- `2026-04-01T10:00:00+09:00` (Japan Time) - `2026-04-01T01:00:00Z` (UTC) -- `2026-04-01T08:00:00+08:00` (中国时间) +- `2026-04-01T08:00:00+08:00` (China Time) -## Message 编写规范 +## Message Writing Guidelines -message 是定时触发后发送给 AI agent 的执行指令。agent 执行时没有对话上下文,因此 message 必须包含: +The message is an execution instruction sent to the AI agent when the scheduled task triggers. The agent has no conversation context at execution time, so the message must include: -1. **任务内容**:具体要做什么 -2. **通知指令**:要求 agent 根据当前启用的 skill 选择合适的通知方式将结果推送给用户 -3. **语言**:message 的语言必须与用户当前对话使用的语言一致(如用户说日语则用日语编写 message) +1. **Task Content**: What specifically needs to be done +2. **Notification Instruction**: Based on the notification method confirmed by the user, explicitly specify the notification channel in the message (e.g., "notify the user via email"). If the user has not specified, write "select an appropriate notification method based on the currently enabled skills to push the results to the user" +3. **Language**: The message language must match the language the user is currently using in the conversation (e.g., if the user speaks Japanese, write the message in Japanese) -### 日程提醒场景(一次性任务) +### Schedule Reminder Scenario (One-Time Task) -❌ 错误写法:`"提醒:你现在有一个会议要参加哦,别忘了!"` +❌ Wrong: `"Reminder: You have a meeting to attend now, don't forget!"` -✅ 正确写法:`"用户有一个日程提醒到期了,日程内容是:「下午3点参加产品评审会议」。请你根据日程内容组织合适的提醒话术,然后根据当前启用的skill选择合适的通知方式将提醒发送给用户。"` +✅ Correct: `"A scheduled reminder for the user has arrived. The schedule content is: 'Product review meeting at 3:00 PM'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user."` -### 定时任务场景(周期任务) +### Recurring Task Scenario (Cron Task) -❌ 错误写法:`"执行:获取最新新闻"` +❌ Wrong: `"Execute: Get latest news"` -✅ 正确写法:`"请帮我搜索并总结今天的重要科技新闻,用简洁的方式列出 Top 5。完成后,根据当前启用的skill选择合适的通知方式将结果推送给用户。"` +✅ Correct: `"Please search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user."` ## Examples -**用户**: "帮我设置一个每天早上9点的新闻总结任务" +**User**: "Set up a daily news summary task at 9 AM" ```bash python {skill_dir}/scripts/schedule_manager.py add \ - --name "每日新闻总结" \ + --name "Daily News Summary" \ --type cron \ --schedule "0 9 * * *" \ --timezone "Asia/Tokyo" \ - --message "请帮我搜索并总结今天的重要科技新闻,用简洁的方式列出 Top 5。完成后,根据当前启用的skill选择合适的通知方式将结果推送给用户。" + --message "Please search and summarize today's important tech news, listing the Top 5 in a concise format. After completion, select an appropriate notification method based on the currently enabled skills to push the results to the user." ``` -**用户**: "提醒我明天下午3点开会" +**User**: "Remind me about the meeting tomorrow at 3 PM" ```bash python {skill_dir}/scripts/schedule_manager.py add \ - --name "开会提醒" \ + --name "Meeting Reminder" \ --type once \ --scheduled-at "2026-03-31T15:00:00+09:00" \ - --message "用户有一个日程提醒到期了,日程内容是:「明天下午3点开会」。请根据日程内容组织合适的提醒话术,然后根据当前启用的skill选择合适的通知方式将提醒发送给用户。" + --message "A scheduled reminder for the user has arrived. The schedule content is: 'Meeting tomorrow at 3:00 PM'. Please compose an appropriate reminder message based on the schedule content, then select an appropriate notification method based on the currently enabled skills to send the reminder to the user." ``` -**用户**: "把每日新闻任务改到早上10点" +**User**: "Change the daily news task to 10 AM" ```bash -# 先查看任务列表获取 task_id +# First check the task list to get the task_id python {skill_dir}/scripts/schedule_manager.py list -# 然后编辑 +# Then edit python {skill_dir}/scripts/schedule_manager.py edit --schedule "0 10 * * *" ``` ## Guidelines -- 创建任务前先用 `list` 确认用户已有的任务,避免创建重复任务 -- 根据用户语言自动设置合适的时区 -- message 内容是发给 AI agent 的完整执行指令,必须包含任务内容和通知指令两部分(参考上方 Message 编写规范) -- 不要在 message 中硬编码具体的通知渠道(如"发邮件"),应使用"根据当前启用的skill选择合适的通知方式"让 agent 自行决定 -- message 的语言必须与用户当前对话使用的语言一致 -- 一次性任务的时间不能是过去的时间 -- 编辑任务时只修改用户要求改的字段,不要改动其他字段 +- Before creating a task, use `list` to check existing tasks and avoid duplicates +- Automatically set the appropriate timezone based on user language +- **Must confirm notification method before creating a task**: Check the currently enabled skills, recommend available notification channels to the user and confirm. If no notification skills are available, proactively ask the user how they would like to receive results +- Message content is a complete execution instruction for the AI agent and must include both task content and notification instructions (refer to the Message Writing Guidelines above) +- The message language must match the language the user is currently using in the conversation +- One-time task times cannot be in the past +- When editing a task, only modify the fields the user requested — do not change other fields