task-trigger
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTask Trigger Skill
任务触发技能
This skill enables you to register, manage, and execute scheduled tasks using the OS native scheduler. You'll convert natural language into cron expressions, create task definitions, integrate with crontab (Linux/WSL) or launchd (macOS), and handle logs.
该技能支持您使用操作系统原生调度器来注册、管理和执行定时任务。您可以将自然语言转换为cron表达式,创建任务定义,与crontab(Linux/WSL)或launchd(macOS)集成,并处理日志。
Core Concept
核心概念
user: "every day at 9am summarize my memory MCP entries"
└→ You execute: /task-trigger:add
└→ You write crontab entry (Linux) or .plist (macOS)
└→ At scheduled time: CLI runs headless (opencode run or kiro chat)
└→ Output goes to log file
└→ User reads log when ready用户:“每天上午9点总结我的MCP记忆条目”
└→ 您执行:/task-trigger:add
└→ 您写入crontab条目(Linux)或.plist文件(macOS)
└→ 到预定时间:CLI以无头模式运行(opencode run或kiro chat)
└→ 输出内容写入日志文件
└→ 用户在需要时查看日志Commands
命令
| Command | Description |
|---|---|
| Register a new task interactively (ALWAYS ask confirmation) |
| Start monitoring a file/directory for changes |
| Show all registered tasks |
| List active file watchers |
| Remove a task + clean scheduler |
| Stop monitoring a file/directory |
| View execution history |
| Execute task immediately |
| Check scheduler health + time remaining |
| 命令 | 描述 |
|---|---|
| 交互式注册新任务(必须先确认) |
| 开始监控文件/目录的变化 |
| 显示所有已注册任务 |
| 列出活跃的文件监控器 |
| 删除任务并清理调度器配置 |
| 停止监控文件/目录 |
| 查看任务执行历史 |
| 立即执行任务 |
| 检查调度器健康状态和任务剩余执行时间 |
Available Scripts
可用脚本
This skill includes pre-built scripts for common operations. Use them to ensure consistency and reduce manual bash code:
| Script | Purpose | Usage |
|---|---|---|
| Detect OS platform | |
| Detect available CLI | |
| Add task to crontab | |
| Add task to launchd | |
| Detect file monitoring tools | |
| Start file/directory watcher | |
| Stop file watcher | |
| List registered tasks | |
| List active file watchers | |
| Remove task completely | |
| View task logs | |
| Execute task now | |
IMPORTANT:
- Always use scripts for repetitive operations instead of writing bash code manually.
- Run after first install to ensure all scripts are executable.
chmod +x scripts/*.sh
该技能包含预构建的脚本用于常见操作。使用这些脚本可确保操作一致性,减少手动编写bash代码的工作量:
| 脚本 | 用途 | 使用方式 |
|---|---|---|
| 检测操作系统平台 | |
| 检测可用的CLI | |
| 将任务添加到crontab | |
| 将任务添加到launchd | |
| 检测文件监控工具 | |
| 启动文件/目录监控器 | |
| 停止文件监控器 | |
| 列出已注册任务 | |
| 列出活跃的文件监控器 | |
| 完全删除任务 | |
| 查看任务日志 | |
| 立即执行任务 | |
重要提示:
- 对于重复操作,请始终使用脚本而非手动编写bash代码。
- 首次安装后,请运行确保所有脚本可执行。
chmod +x scripts/*.sh
How to Use This Skill
如何使用该技能
1. Natural Language Parsing
1. 自然语言解析
You MUST parse natural language into cron expressions. This is best done by you (the agent) because you understand context and nuances.
Examples:
- "every day at 9am" →
0 9 * * * - "every hour" →
0 * * * * - "every minute during the next 30 minutes" → +
*/1 * * * *duration_minutes: 30 - "every Monday at 8:30am" →
30 8 * * 1 - "cada día a las 10am" →
0 10 * * * - "cada minuto durante la próxima hora" → +
*/1 * * * *duration_minutes: 60
Duration handling: When user says "durante la próxima X", calculate expiration time.
您必须将自然语言解析为cron表达式。这是您(Agent)的优势,因为您能理解上下文和细微差别。
示例:
- "every day at 9am" →
0 9 * * * - "every hour" →
0 * * * * - "every minute during the next 30 minutes" → +
*/1 * * * *duration_minutes: 30 - "every Monday at 8:30am" →
30 8 * * 1 - "cada día a las 10am" →
0 10 * * * - "cada minuto durante la próxima hora" → +
*/1 * * * *duration_minutes: 60
**时长处理:**当用户提及“durante la próxima X”时,请计算任务的过期时间。
2. CLI Detection
2. CLI检测
detect-cli.sh/usr/local/bin/opencode/Users/you/.local/bin/kiro-clibash
CLI_PATH=$(./scripts/detect-cli.sh)
echo "Detected CLI: $CLI_PATH"detect-cli.sh/usr/local/bin/opencode/Users/you/.local/bin/kiro-clibash
CLI_PATH=$(./scripts/detect-cli.sh)
echo "检测到的CLI:$CLI_PATH"Use $CLI_PATH in commands, not just "opencode" or "kiro-cli"
在命令中使用$CLI_PATH,而非仅使用“opencode”或“kiro-cli”
undefinedundefined3. Platform Detection
3. 平台检测
Use the script instead of manual bash:
bash
undefined请使用脚本而非手动编写bash代码:
bash
undefinedInstead of writing bash code, use:
不要手动编写bash代码,请使用:
PLATFORM=$(./scripts/detect-platform.sh)
echo "Detected platform: $PLATFORM"
undefinedPLATFORM=$(./scripts/detect-platform.sh)
echo "检测到的平台:$PLATFORM"
undefinedTask Creation Workflow
任务创建流程
Step 1: Parse User Request
步骤1:解析用户请求
User: "every day at 9am summarize my memory MCP entries using deepseek"
→ You extract:
- Trigger: "every day at 9am" → cron: `0 9 * * *`
- Prompt: "summarize my memory MCP entries"
- Model: "deepseek" (if mentioned, else null)
- CLI: detect with full path用户:“每天上午9点用deepseek总结我的MCP记忆条目”
→ 您提取以下信息:
- 触发条件:“every day at 9am” → cron表达式:`0 9 * * *`
- 提示词:“summarize my memory MCP entries”
- 模型:“deepseek”(如果用户提及,否则为null)
- CLI:通过脚本检测完整路径Step 2: Generate Task ID
步骤2:生成任务ID
Create unique ID: , , etc.
Rules: lowercase, hyphens, based on description.
daily-memory-summarylog-analysis-30min创建唯一ID:、等。
规则:小写字母、连字符分隔,基于任务描述命名。
daily-memory-summarylog-analysis-30minStep 3: Create Task JSON
步骤3:创建任务JSON
Create (create directory if doesn't exist).
$HOME/.task-trigger/tasks.jsonThe file is a plain JSON array:
[{task1}, {task2}, ...]创建(如果目录不存在则先创建)。
$HOME/.task-trigger/tasks.json该文件为纯JSON数组:
[{task1}, {task2}, ...]For cron-based tasks:
基于cron的任务:
json
{
"id": "daily-memory-summary",
"name": "Daily Memory Summary",
"enabled": true,
"trigger": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "local",
"duration_minutes": null,
"expires_at": null
},
"execution": {
"cli_path": "/usr/local/bin/opencode",
"agent": "opencode",
"model": "deepseek/deepseek-chat",
"prompt": "Check MCP memory for new entries since yesterday and summarize them. Write output to $HOME/.task-trigger/logs/daily-memory-summary.log",
"workingDirectory": "$HOME",
"timeout": 300
},
"created_at": "2026-03-18T10:00:00Z",
"log_path": "$HOME/.task-trigger/logs/daily-memory-summary.log"
}json
{
"id": "daily-memory-summary",
"name": "每日记忆总结",
"enabled": true,
"trigger": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "local",
"duration_minutes": null,
"expires_at": null
},
"execution": {
"cli_path": "/usr/local/bin/opencode",
"agent": "opencode",
"model": "deepseek/deepseek-chat",
"prompt": "检查MCP记忆中自昨天以来的新条目并进行总结。将输出写入$HOME/.task-trigger/logs/daily-memory-summary.log",
"workingDirectory": "$HOME",
"timeout": 300
},
"created_at": "2026-03-18T10:00:00Z",
"log_path": "$HOME/.task-trigger/logs/daily-memory-summary.log"
}For file watcher tasks:
文件监控任务:
json
{
"id": "log-file-watcher",
"name": "Log File Watcher",
"enabled": true,
"trigger": {
"type": "file",
"path": "/var/log/myapp.log",
"watch_events": ["create", "modify"],
"recursive": false,
"poll_interval": 5,
"debounce": 1
},
"execution": {
"agent": "opencode",
"model": "deepseek/deepseek-chat",
"prompt": "New log entry detected. Analyze the latest lines and notify if errors found. Write output to $HOME/.task-trigger/logs/log-analyzer.log",
"workingDirectory": "$HOME",
"timeout": 60
},
"created_at": "2026-03-18T10:00:00Z",
"log_path": "$HOME/.task-trigger/logs/log-analyzer.log"
}json
{
"id": "log-file-watcher",
"name": "日志文件监控器",
"enabled": true,
"trigger": {
"type": "file",
"path": "/var/log/myapp.log",
"watch_events": ["create", "modify"],
"recursive": false,
"poll_interval": 5,
"debounce": 1
},
"execution": {
"agent": "opencode",
"model": "deepseek/deepseek-chat",
"prompt": "检测到新的日志条目。分析最新的日志行,若发现错误则发出通知。将结果写入$HOME/.task-trigger/logs/log-analyzer.log",
"workingDirectory": "$HOME",
"timeout": 60
},
"created_at": "2026-03-18T10:00:00Z",
"log_path": "$HOME/.task-trigger/logs/log-analyzer.log"
}Step 4: Platform-Specific Integration
步骤4:平台特定集成
For WSL/Linux (crontab):
适用于WSL/Linux(crontab):
bash
CLI_PATH=$(./scripts/detect-cli.sh)bash
CLI_PATH=$(./scripts/detect-cli.sh)Build command using full path
使用完整路径构建命令
if [[ "$CLI_PATH" == opencode ]]; then
COMMAND="$CLI_PATH run --prompt 'your prompt here'"
else
kiro needs --trust-all-tools for file writes
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools 'your prompt here'"
fi
if [[ "$CLI_PATH" == opencode ]]; then
COMMAND="$CLI_PATH run --prompt '你的提示词内容'"
else
kiro需要--trust-all-tools权限才能写入文件
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools '你的提示词内容'"
fi
Preview first, then apply
先预览配置,再应用
./scripts/add-to-crontab.sh
--task-id "daily-memory-summary"
--cron "0 9 * * *"
--command "$COMMAND"
--dry-run
--task-id "daily-memory-summary"
--cron "0 9 * * *"
--command "$COMMAND"
--dry-run
./scripts/add-to-crontab.sh
--task-id "daily-memory-summary"
--cron "0 9 * * *"
--command "$COMMAND"
--dry-run
--task-id "daily-memory-summary"
--cron "0 9 * * *"
--command "$COMMAND"
--dry-run
If looks good, run without --dry-run
如果预览内容无误,去掉--dry-run参数再执行
undefinedundefinedFor macOS (launchd):
适用于macOS(launchd):
bash
CLI_PATH=$(./scripts/detect-cli.sh)
if [[ "$CLI_PATH" == *opencode* ]]; then
COMMAND="$CLI_PATH run --prompt 'your prompt here'"
else
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools 'your prompt here'"
fi
./scripts/add-to-launchd.sh \
--task-id "daily-memory-summary" \
--hour 9 \
--minute 0 \
--command "$COMMAND"bash
CLI_PATH=$(./scripts/detect-cli.sh)
if [[ "$CLI_PATH" == *opencode* ]]; then
COMMAND="$CLI_PATH run --prompt '你的提示词内容'"
else
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools '你的提示词内容'"
fi
./scripts/add-to-launchd.sh \
--task-id "daily-memory-summary" \
--hour 9 \
--minute 0 \
--command "$COMMAND"Step 5: Create Log Directory
步骤5:创建日志目录
bash
mkdir -p $HOME/.task-trigger/logs
mkdir -p $HOME/.task-trigger/launchd # macOS only
mkdir -p $HOME/.task-trigger/watchers # For file watchersbash
mkdir -p $HOME/.task-trigger/logs
mkdir -p $HOME/.task-trigger/launchd # 仅适用于macOS
mkdir -p $HOME/.task-trigger/watchers # 用于文件监控任务Step 6: Confirm to User
步骤6:向用户确认
Show summary:
- Task ID:
daily-memory-summary - Schedule: (every day at 9am)
0 9 * * * - CLI: (full path)
/usr/local/bin/opencode - Model: (or "last used model" if not specified)
deepseek/deepseek-chat - Logs:
$HOME/.task-trigger/logs/daily-memory-summary.log - Platform: WSL/macOS/Linux
- Status: Enabled
向用户展示任务摘要:
- 任务ID:
daily-memory-summary - 调度规则:(每天上午9点)
0 9 * * * - CLI:(完整路径)
/usr/local/bin/opencode - 模型:(如果用户未指定则显示“上次使用的模型”)
deepseek/deepseek-chat - 日志路径:
$HOME/.task-trigger/logs/daily-memory-summary.log - 平台:WSL/macOS/Linux
- 状态:已启用
File Watcher Workflow
文件监控任务流程
Step 1: Parse User Request
步骤1:解析用户请求
User: "watch my log file at /var/log/app.log and analyze new entries"
→ You extract:
- Path: "/var/log/app.log"
- Events: ["modify"] (default for files)
- Prompt: "analyze new log entries"
- CLI: detect opencode/kiro用户:“监控我的日志文件/var/log/app.log并分析新条目”
→ 您提取以下信息:
- 路径:"/var/log/app.log"
- 事件:["modify"](文件监控的默认事件)
- 提示词:“analyze new log entries”
- CLI:检测opencode/kiro的完整路径Step 2: Generate Task ID
步骤2:生成任务ID
Create unique ID: , , etc.
log-file-watcherconfig-monitor创建唯一ID:、等。
log-file-watcherconfig-monitorStep 3: Create Task JSON (File Trigger)
步骤3:创建任务JSON(文件触发类型)
Use the file trigger format shown in Step 3.
使用步骤3中展示的文件触发任务格式。
Step 4: Start Watcher
步骤4:启动监控器
bash
CLI_PATH=$(./scripts/detect-cli.sh)
if [[ "$CLI_PATH" == *opencode* ]]; then
COMMAND="$CLI_PATH run --prompt 'New log entry detected. Analyze the latest lines and notify if errors found.'"
else
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools 'New log entry detected. Analyze the latest lines and notify if errors found.'"
fi
./scripts/start-watcher.sh \
--task-id "log-file-watcher" \
--path "/var/log/app.log" \
--events "modify" \
--command "$COMMAND" \
--debounce 1bash
CLI_PATH=$(./scripts/detect-cli.sh)
if [[ "$CLI_PATH" == *opencode* ]]; then
COMMAND="$CLI_PATH run --prompt '检测到新的日志条目。分析最新的日志行,若发现错误则发出通知。'"
else
COMMAND="$CLI_PATH chat --no-interactive --trust-all-tools '检测到新的日志条目。分析最新的日志行,若发现错误则发出通知。'"
fi
./scripts/start-watcher.sh \
--task-id "log-file-watcher" \
--path "/var/log/app.log" \
--events "modify" \
--command "$COMMAND" \
--debounce 1Step 5: Confirm to User
步骤5:向用户确认
Show summary:
- Task ID:
log-file-watcher - Path:
/var/log/app.log - Events:
modify - Tool: (or detected tool)
inotifywait - CLI: /
opencodekiro - Status: Watching
向用户展示任务摘要:
- 任务ID:
log-file-watcher - 监控路径:
/var/log/app.log - 监控事件:
modify - 使用工具:(或检测到的其他工具)
inotifywait - CLI:/
opencodekiro - 状态:监控中
Special Cases
特殊场景
Temporal Tasks ("during next X")
临时任务(“during next X”)
User: "check logs every minute during the next 30 minutes"
→ cron: `*/1 * * * *`
→ duration_minutes: 30
→ expires_at: current_time + 30 minutesImplementation: When creating temporal tasks:
- Calculate = current_time + duration_minutes
expires_at - Store both and
duration_minutesin task JSONexpires_at - The script checks
run-task.shbefore executing — if expired, it disables the task and removes it from the scheduler automaticallyexpires_at - shows time remaining for temporal tasks
/task-trigger:status
用户:“接下来30分钟内每分钟检查一次邮件”
→ cron表达式:`*/1 * * * *`
→ duration_minutes: 30
→ expires_at: 当前时间 + 30分钟**实现方式:**创建临时任务时:
- 计算= 当前时间 + duration_minutes
expires_at - 在任务JSON中同时存储和
duration_minutesexpires_at - 脚本在执行前会检查
run-task.sh——如果任务已过期,会自动禁用任务并从调度器中移除expires_at - 会显示临时任务的剩余执行时间
/task-trigger:status
Model Specification
模型指定
User: "using opencode/zen" or "con claude-3.5-sonnet"
→ Add to command: --model "opencode/zen"
→ If not specified: omit --model flag (uses last model)用户:“使用opencode/zen”或“con claude-3.5-sonnet”
→ 在命令中添加:--model "opencode/zen"
→ 如果用户未指定:省略--model参数(使用上次使用的模型)Prompt Templates
提示词模板
Prompts support variable substitution for reusable tasks:
- → current ISO 8601 timestamp
{{TIMESTAMP}} - → the watched file path (file watchers only)
{{FILE_PATH}} - → the task's ID
{{TASK_ID}} - → the task's log file path
{{LOG_PATH}}
Example:
"prompt": "Analyze {{FILE_PATH}} for errors since {{TIMESTAMP}}. Write results to {{LOG_PATH}}"The agent expands these variables at execution time in .
run-task.sh提示词支持变量替换,用于可复用任务:
- → 当前ISO 8601时间戳
{{TIMESTAMP}} - → 被监控的文件路径(仅适用于文件监控任务)
{{FILE_PATH}} - → 任务的ID
{{TASK_ID}} - → 任务的日志文件路径
{{LOG_PATH}}
示例:
"prompt": "分析{{FILE_PATH}}中自{{TIMESTAMP}}以来的错误信息。将结果写入{{LOG_PATH}}"Agent会在执行时自动展开这些变量。
run-task.shWorking Directory
工作目录
Always use (not ) in scheduled commands.
$HOME~在定时任务命令和路径中,请始终使用而非。
$HOME~File Watcher Events
文件监控事件
Available events: , , ,
createmodifydeletemove- Files: Use for content changes
modify - Directories: Use ,
create,deletefor structure changesmove - Default: for files,
modifyfor directoriescreate,modify,delete
可用事件:、、、
createmodifydeletemove- 文件监控:使用监控内容变化
modify - 目录监控:使用、
create、delete监控结构变化move - 默认设置:文件监控默认,目录监控默认
modifycreate,modify,delete
Task Management
任务管理
Listing Tasks (/task-trigger:list
)
/task-trigger:list列出任务(/task-trigger:list
)
/task-trigger:listUse the script instead of manual JSON parsing:
bash
./scripts/list-tasks.py请使用脚本而非手动解析JSON:
bash
./scripts/list-tasks.pyListing Watchers (/task-trigger:watchers
)
/task-trigger:watchers列出监控器(/task-trigger:watchers
)
/task-trigger:watchersList active file watchers:
bash
./scripts/list-watchers.py列出活跃的文件监控器:
bash
./scripts/list-watchers.pyRemoving Tasks (/task-trigger:remove <id>
)
/task-trigger:remove <id>删除任务(/task-trigger:remove <id>
)
/task-trigger:remove <id>Use the script instead of manual removal:
bash
./scripts/remove-task.sh <task-id>请使用脚本而非手动删除:
bash
./scripts/remove-task.sh <task-id>Stopping Watchers (/task-trigger:unwatch <id>
)
/task-trigger:unwatch <id>停止监控(/task-trigger:unwatch <id>
)
/task-trigger:unwatch <id>Stop a file watcher:
bash
./scripts/stop-watcher.sh <task-id>停止文件监控器:
bash
./scripts/stop-watcher.sh <task-id>Viewing Logs (/task-trigger:logs [id]
)
/task-trigger:logs [id]查看日志(/task-trigger:logs [id]
)
/task-trigger:logs [id]Use the script instead of manual log viewing:
bash
undefined请使用脚本而非手动查看日志:
bash
undefinedList all available logs
列出所有可用日志
./scripts/view-logs.sh
./scripts/view-logs.sh
View specific log (last 50 lines)
查看指定任务的日志(最后50行)
./scripts/view-logs.sh <task-id>
./scripts/view-logs.sh <task-id>
Tail log in real-time
实时查看日志更新
./scripts/view-logs.sh <task-id> --tail
./scripts/view-logs.sh <task-id> --tail
View more lines
查看更多行数
./scripts/view-logs.sh <task-id> --lines 100
undefined./scripts/view-logs.sh <task-id> --lines 100
undefinedRunning Immediately (/task-trigger:run <id>
)
/task-trigger:run <id>立即执行任务(/task-trigger:run <id>
)
/task-trigger:run <id>Use the script instead of manual execution:
bash
./scripts/run-task.sh <task-id>请使用脚本而非手动执行:
bash
./scripts/run-task.sh <task-id>Checking Status (/task-trigger:status
)
/task-trigger:status检查状态(/task-trigger:status
)
/task-trigger:status- Verify scheduler is running (crontab entries / launchctl list)
- Show temporal tasks with time remaining until
expires_at - Show last execution timestamp and result from log
- Show next scheduled execution time
- Check log directory health
- 验证调度器是否运行(检查crontab条目/launchctl列表)
- 显示临时任务的剩余执行时间(距离的时长)
expires_at - 从日志中显示上次执行的时间戳和结果
- 显示下一次预定执行时间
- 检查日志目录的健康状态
CLI Commands Reference
CLI命令参考
opencode
opencode
- Headless command:
opencode run --prompt "message" - Model flag:
-m "provider/model" - Example:
opencode run --prompt "Check memory" -m "deepseek/deepseek-chat"
- 无头模式命令:
opencode run --prompt "消息内容" - 模型参数:
-m "provider/model" - 示例:
opencode run --prompt "检查记忆内容" -m "deepseek/deepseek-chat"
kiro
kiro
- Binary name: (not
kiro-cli)kiro - Headless command:
kiro-cli chat --no-interactive "message" - Trust flag: (required for file writes and tool access)
--trust-all-tools - Model flag:
--model "provider/model" - Example:
kiro-cli chat --no-interactive --trust-all-tools "Check memory" --model "anthropic/claude-sonnet-4"
Important: Always use with kiro headless commands, otherwise the agent cannot write files or use tools.
--trust-all-tools- 二进制文件名:(而非
kiro-cli)kiro - 无头模式命令:
kiro-cli chat --no-interactive "消息内容" - 信任参数:(写入文件和使用工具时必须添加)
--trust-all-tools - 模型参数:
--model "provider/model" - 示例:
kiro-cli chat --no-interactive --trust-all-tools "检查记忆内容" --model "anthropic/claude-sonnet-4"
重要提示:在kiro无头模式命令中必须添加参数,否则Agent无法写入文件或使用工具。
--trust-all-toolsImportant Rules
重要规则
ALWAYS:
必须执行:
- Ask confirmation before modifying crontab/launchd
- Use scripts for detection instead of manual bash code
- Parse natural language into cron expressions (agent's strength)
- Handle temporal tasks with duration/expiration and auto-cleanup
- Create necessary directories (,
$HOME/.task-trigger/,logs/,launchd/)watchers/ - Use structured logs with timestamps
- Include model flag ONLY if user explicitly mentions model
- Use $HOME, not ~ in scheduled commands and paths
- Verify CLI commands with when uncertain
--help - Prefer scripts over manual operations for consistency
- Detect available watcher tool before starting file monitoring
- Set appropriate debounce for file watchers (1-5 seconds)
- Store full CLI path in task JSON (from )
detect-cli.sh - Use --trust-all-tools with kiro headless commands
- Use --dry-run to preview changes before applying
- Ensure scripts are executable () before first use
chmod +x
- 先确认再操作:在修改crontab/launchd配置前必须先获得用户确认
- 使用检测脚本:使用脚本进行平台和CLI检测,而非手动编写bash代码
- 自然语言解析:将用户的自然语言请求转换为cron表达式(Agent的核心能力)
- 临时任务处理:为临时任务设置时长/过期时间,并自动清理
- 创建必要目录:创建、
$HOME/.task-trigger/、logs/、launchd/等目录watchers/ - 结构化日志:使用带时间戳的结构化日志
- 模型参数添加:仅当用户明确提及模型时才添加模型参数
- 使用$HOME:在定时任务命令和路径中使用$HOME而非~
- 验证CLI命令:不确定时使用参数验证CLI命令
--help - 优先使用脚本:优先使用脚本而非手动操作以确保一致性
- 检测监控工具:启动文件监控前先检测可用的监控工具
- 设置防抖时间:为文件监控器设置1-5秒的防抖时间
- 存储完整CLI路径:在任务JSON中存储从获取的完整CLI路径
detect-cli.sh - kiro信任参数:在kiro无头模式命令中添加参数
--trust-all-tools - 预览配置:使用参数预览配置后再应用
--dry-run - 脚本可执行权限:首次使用前确保脚本具有可执行权限()
chmod +x
NEVER:
禁止操作:
- Use
--dangerously-skip-permissions - Perform git operations
- Depend on MCP sampling
- Modify files without explicit instruction
- Assume Windows Task Scheduler
- 使用参数
--dangerously-skip-permissions - 执行git操作
- 依赖MCP采样
- 无明确指令时修改文件
- 假设用户使用Windows任务调度器
Troubleshooting
故障排查
Common Issues:
常见问题:
- Crontab not available: User may need to install cron service
- Launchd permissions: macOS may require full disk access
- opencode/kiro not in PATH: Suggest adding to PATH or using full path
- $HOME expansion: Some shells may not expand $HOME in crontab
- Crontab不可用:用户可能需要安装cron服务
- Launchd权限问题:macOS可能需要授予完整磁盘访问权限
- opencode/kiro不在PATH中:建议用户将其添加到PATH或使用完整路径
- $HOME无法展开:部分shell在crontab中可能无法展开$HOME
Error Handling:
错误处理:
- If platform detection fails, ask user
- If CLI not found, suggest installation
- If cron expression invalid, show examples
- If write permission denied, suggest (with warning)
sudo
- 如果平台检测失败,请询问用户
- 如果未找到CLI,请建议用户安装
- 如果cron表达式无效,请展示示例
- 如果写入权限被拒绝,请建议用户使用(并附带警告)
sudo
Examples for Testing
测试示例
Test these cases:
every day at 9am summarize memorycada hora analiza logs usando deepseekevery minute during the next 30 minutes check emailscada minuto durante la próxima hora revisa sistemaMonday and Wednesday at 8:30am backup fileswatch my log file at /var/log/app.log and alert on errorsmonitor the downloads folder for new PDF filesif config.json changes, restart the servicewhen new files appear in /data/uploads, process themtrack changes to source code and run tests
Remember: You are the agent implementing this. Follow these instructions precisely, parse natural language, detect environment, and always confirm before making changes.
测试以下场景:
every day at 9am summarize memorycada hora analiza logs usando deepseekevery minute during the next 30 minutes check emailscada minuto durante la próxima hora revisa sistemaMonday and Wednesday at 8:30am backup fileswatch my log file at /var/log/app.log and alert on errorsmonitor the downloads folder for new PDF filesif config.json changes, restart the servicewhen new files appear in /data/uploads, process themtrack changes to source code and run tests
请记住:您是实现该技能的Agent,请严格遵循以上说明,解析用户的自然语言请求,检测运行环境,并始终在修改配置前获得用户确认。