task-trigger

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Task 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

命令

CommandDescription
/task-trigger:add
Register a new task interactively (ALWAYS ask confirmation)
/task-trigger:watch
Start monitoring a file/directory for changes
/task-trigger:list
Show all registered tasks
/task-trigger:watchers
List active file watchers
/task-trigger:remove <id>
Remove a task + clean scheduler
/task-trigger:unwatch <id>
Stop monitoring a file/directory
/task-trigger:logs [id]
View execution history
/task-trigger:run <id>
Execute task immediately
/task-trigger:status
Check scheduler health + time remaining
命令描述
/task-trigger:add
交互式注册新任务(必须先确认)
/task-trigger:watch
开始监控文件/目录的变化
/task-trigger:list
显示所有已注册任务
/task-trigger:watchers
列出活跃的文件监控器
/task-trigger:remove <id>
删除任务并清理调度器配置
/task-trigger:unwatch <id>
停止监控文件/目录
/task-trigger:logs [id]
查看任务执行历史
/task-trigger:run <id>
立即执行任务
/task-trigger:status
检查调度器健康状态和任务剩余执行时间

Available Scripts

可用脚本

This skill includes pre-built scripts for common operations. Use them to ensure consistency and reduce manual bash code:
ScriptPurposeUsage
detect-platform.sh
Detect OS platform
./scripts/detect-platform.sh
→ outputs:
wsl
,
macos
, or
linux
detect-cli.sh
Detect available CLI
./scripts/detect-cli.sh
→ outputs: full path (e.g.
/usr/local/bin/opencode
) or
none
add-to-crontab.sh
Add task to crontab
./scripts/add-to-crontab.sh --task-id <id> --cron <expr> --command <cmd> [--dry-run]
add-to-launchd.sh
Add task to launchd
./scripts/add-to-launchd.sh --task-id <id> --hour <H> --minute <M> --command <cmd> [--dry-run]
detect-watcher.sh
Detect file monitoring tools
./scripts/detect-watcher.sh
→ outputs:
inotifywait
,
fswatch
,
polling
, or
none
start-watcher.sh
Start file/directory watcher
./scripts/start-watcher.sh --task-id <id> --path <path> --events <events> --command <cmd> [--dry-run]
stop-watcher.sh
Stop file watcher
./scripts/stop-watcher.sh <task-id>
list-tasks.py
List registered tasks
./scripts/list-tasks.py
list-watchers.py
List active file watchers
./scripts/list-watchers.py
remove-task.sh
Remove task completely
./scripts/remove-task.sh <task-id>
view-logs.sh
View task logs
./scripts/view-logs.sh [task-id] [--tail] [--lines N]
run-task.sh
Execute task now
./scripts/run-task.sh <task-id>
IMPORTANT:
  • Always use scripts for repetitive operations instead of writing bash code manually.
  • Run
    chmod +x scripts/*.sh
    after first install to ensure all scripts are executable.
该技能包含预构建的脚本用于常见操作。使用这些脚本可确保操作一致性,减少手动编写bash代码的工作量:
脚本用途使用方式
detect-platform.sh
检测操作系统平台
./scripts/detect-platform.sh
→ 输出:
wsl
macos
linux
detect-cli.sh
检测可用的CLI
./scripts/detect-cli.sh
→ 输出:完整路径(例如
/usr/local/bin/opencode
)或
none
add-to-crontab.sh
将任务添加到crontab
./scripts/add-to-crontab.sh --task-id <id> --cron <expr> --command <cmd> [--dry-run]
add-to-launchd.sh
将任务添加到launchd
./scripts/add-to-launchd.sh --task-id <id> --hour <H> --minute <M> --command <cmd> [--dry-run]
detect-watcher.sh
检测文件监控工具
./scripts/detect-watcher.sh
→ 输出:
inotifywait
fswatch
polling
none
start-watcher.sh
启动文件/目录监控器
./scripts/start-watcher.sh --task-id <id> --path <path> --events <events> --command <cmd> [--dry-run]
stop-watcher.sh
停止文件监控器
./scripts/stop-watcher.sh <task-id>
list-tasks.py
列出已注册任务
./scripts/list-tasks.py
list-watchers.py
列出活跃的文件监控器
./scripts/list-watchers.py
remove-task.sh
完全删除任务
./scripts/remove-task.sh <task-id>
view-logs.sh
查看任务日志
./scripts/view-logs.sh [task-id] [--tail] [--lines N]
run-task.sh
立即执行任务
./scripts/run-task.sh <task-id>
重要提示:
  • 对于重复操作,请始终使用脚本而非手动编写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
returns the full path to the CLI binary (e.g.
/usr/local/bin/opencode
or
/Users/you/.local/bin/kiro-cli
). Store this full path in the task JSON — launchd and crontab don't inherit the user's PATH.
bash
CLI_PATH=$(./scripts/detect-cli.sh)
echo "Detected CLI: $CLI_PATH"
detect-cli.sh
会返回CLI二进制文件的完整路径(例如
/usr/local/bin/opencode
/Users/you/.local/bin/kiro-cli
)。请将此完整路径存储在任务JSON中——launchd和crontab不会继承用户的PATH环境变量。
bash
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”

undefined
undefined

3. Platform Detection

3. 平台检测

Use the script instead of manual bash:
bash
undefined
请使用脚本而非手动编写bash代码:
bash
undefined

Instead of writing bash code, use:

不要手动编写bash代码,请使用:

PLATFORM=$(./scripts/detect-platform.sh) echo "Detected platform: $PLATFORM"
undefined
PLATFORM=$(./scripts/detect-platform.sh) echo "检测到的平台:$PLATFORM"
undefined

Task 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:
daily-memory-summary
,
log-analysis-30min
, etc. Rules: lowercase, hyphens, based on description.
创建唯一ID:
daily-memory-summary
log-analysis-30min
等。 规则:小写字母、连字符分隔,基于任务描述命名。

Step 3: Create Task JSON

步骤3:创建任务JSON

Create
$HOME/.task-trigger/tasks.json
(create directory if doesn't exist).
The 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
./scripts/add-to-crontab.sh
--task-id "daily-memory-summary"
--cron "0 9 * * *"
--command "$COMMAND"
--dry-run

If looks good, run without --dry-run

如果预览内容无误,去掉--dry-run参数再执行

undefined
undefined

For 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 watchers
bash
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:
    0 9 * * *
    (every day at 9am)
  • CLI:
    /usr/local/bin/opencode
    (full path)
  • Model:
    deepseek/deepseek-chat
    (or "last used model" if not specified)
  • Logs:
    $HOME/.task-trigger/logs/daily-memory-summary.log
  • Platform: WSL/macOS/Linux
  • Status: Enabled
向用户展示任务摘要:
  • 任务ID:
    daily-memory-summary
  • 调度规则:
    0 9 * * *
    (每天上午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:
log-file-watcher
,
config-monitor
, etc.
创建唯一ID:
log-file-watcher
config-monitor
等。

Step 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 1
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/start-watcher.sh \
  --task-id "log-file-watcher" \
  --path "/var/log/app.log" \
  --events "modify" \
  --command "$COMMAND" \
  --debounce 1

Step 5: Confirm to User

步骤5:向用户确认

Show summary:
  • Task ID:
    log-file-watcher
  • Path:
    /var/log/app.log
  • Events:
    modify
  • Tool:
    inotifywait
    (or detected tool)
  • CLI:
    opencode
    /
    kiro
  • Status: Watching
向用户展示任务摘要:
  • 任务ID:
    log-file-watcher
  • 监控路径:
    /var/log/app.log
  • 监控事件:
    modify
  • 使用工具:
    inotifywait
    (或检测到的其他工具)
  • CLI:
    opencode
    /
    kiro
  • 状态:监控中

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 minutes
Implementation: When creating temporal tasks:
  1. Calculate
    expires_at
    = current_time + duration_minutes
  2. Store both
    duration_minutes
    and
    expires_at
    in task JSON
  3. The
    run-task.sh
    script checks
    expires_at
    before executing — if expired, it disables the task and removes it from the scheduler automatically
  4. /task-trigger:status
    shows time remaining for temporal tasks
用户:“接下来30分钟内每分钟检查一次邮件”
→ cron表达式:`*/1 * * * *`
→ duration_minutes: 30
→ expires_at: 当前时间 + 30分钟
**实现方式:**创建临时任务时:
  1. 计算
    expires_at
    = 当前时间 + duration_minutes
  2. 在任务JSON中同时存储
    duration_minutes
    expires_at
  3. run-task.sh
    脚本在执行前会检查
    expires_at
    ——如果任务已过期,会自动禁用任务并从调度器中移除
  4. /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:
  • {{TIMESTAMP}}
    → current ISO 8601 timestamp
  • {{FILE_PATH}}
    → the watched file path (file watchers only)
  • {{TASK_ID}}
    → the task's ID
  • {{LOG_PATH}}
    → the task's log file 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
.
提示词支持变量替换,用于可复用任务:
  • {{TIMESTAMP}}
    → 当前ISO 8601时间戳
  • {{FILE_PATH}}
    → 被监控的文件路径(仅适用于文件监控任务)
  • {{TASK_ID}}
    → 任务的ID
  • {{LOG_PATH}}
    → 任务的日志文件路径
示例:
"prompt": "分析{{FILE_PATH}}中自{{TIMESTAMP}}以来的错误信息。将结果写入{{LOG_PATH}}"
Agent会在
run-task.sh
执行时自动展开这些变量。

Working Directory

工作目录

Always use
$HOME
(not
~
) in scheduled commands.
在定时任务命令和路径中,请始终使用
$HOME
而非
~

File Watcher Events

文件监控事件

Available events:
create
,
modify
,
delete
,
move
  • Files: Use
    modify
    for content changes
  • Directories: Use
    create
    ,
    delete
    ,
    move
    for structure changes
  • Default:
    modify
    for files,
    create,modify,delete
    for directories
可用事件:
create
modify
delete
move
  • 文件监控:使用
    modify
    监控内容变化
  • 目录监控:使用
    create
    delete
    move
    监控结构变化
  • 默认设置:文件监控默认
    modify
    ,目录监控默认
    create,modify,delete

Task Management

任务管理

Listing Tasks (
/task-trigger:list
)

列出任务(
/task-trigger:list

Use the script instead of manual JSON parsing:
bash
./scripts/list-tasks.py
请使用脚本而非手动解析JSON:
bash
./scripts/list-tasks.py

Listing Watchers (
/task-trigger:watchers
)

列出监控器(
/task-trigger:watchers

List active file watchers:
bash
./scripts/list-watchers.py
列出活跃的文件监控器:
bash
./scripts/list-watchers.py

Removing Tasks (
/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>

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]

Use the script instead of manual log viewing:
bash
undefined
请使用脚本而非手动查看日志:
bash
undefined

List 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
undefined

Running Immediately (
/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

  • 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:
    kiro-cli
    (not
    kiro
    )
  • Headless command:
    kiro-cli chat --no-interactive "message"
  • Trust flag:
    --trust-all-tools
    (required for file writes and tool access)
  • Model flag:
    --model "provider/model"
  • Example:
    kiro-cli chat --no-interactive --trust-all-tools "Check memory" --model "anthropic/claude-sonnet-4"
Important: Always use
--trust-all-tools
with kiro headless commands, otherwise the agent cannot write files or use 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无头模式命令中必须添加
--trust-all-tools
参数,否则Agent无法写入文件或使用工具。

Important Rules

重要规则

ALWAYS:

必须执行:

  1. Ask confirmation before modifying crontab/launchd
  2. Use scripts for detection instead of manual bash code
  3. Parse natural language into cron expressions (agent's strength)
  4. Handle temporal tasks with duration/expiration and auto-cleanup
  5. Create necessary directories (
    $HOME/.task-trigger/
    ,
    logs/
    ,
    launchd/
    ,
    watchers/
    )
  6. Use structured logs with timestamps
  7. Include model flag ONLY if user explicitly mentions model
  8. Use $HOME, not ~ in scheduled commands and paths
  9. Verify CLI commands with
    --help
    when uncertain
  10. Prefer scripts over manual operations for consistency
  11. Detect available watcher tool before starting file monitoring
  12. Set appropriate debounce for file watchers (1-5 seconds)
  13. Store full CLI path in task JSON (from
    detect-cli.sh
    )
  14. Use --trust-all-tools with kiro headless commands
  15. Use --dry-run to preview changes before applying
  16. Ensure scripts are executable (
    chmod +x
    ) before first use
  1. 先确认再操作:在修改crontab/launchd配置前必须先获得用户确认
  2. 使用检测脚本:使用脚本进行平台和CLI检测,而非手动编写bash代码
  3. 自然语言解析:将用户的自然语言请求转换为cron表达式(Agent的核心能力)
  4. 临时任务处理:为临时任务设置时长/过期时间,并自动清理
  5. 创建必要目录:创建
    $HOME/.task-trigger/
    logs/
    launchd/
    watchers/
    等目录
  6. 结构化日志:使用带时间戳的结构化日志
  7. 模型参数添加:仅当用户明确提及模型时才添加模型参数
  8. 使用$HOME:在定时任务命令和路径中使用$HOME而非~
  9. 验证CLI命令:不确定时使用
    --help
    参数验证CLI命令
  10. 优先使用脚本:优先使用脚本而非手动操作以确保一致性
  11. 检测监控工具:启动文件监控前先检测可用的监控工具
  12. 设置防抖时间:为文件监控器设置1-5秒的防抖时间
  13. 存储完整CLI路径:在任务JSON中存储从
    detect-cli.sh
    获取的完整CLI路径
  14. kiro信任参数:在kiro无头模式命令中添加
    --trust-all-tools
    参数
  15. 预览配置:使用
    --dry-run
    参数预览配置后再应用
  16. 脚本可执行权限:首次使用前确保脚本具有可执行权限(
    chmod +x

NEVER:

禁止操作:

  1. Use
    --dangerously-skip-permissions
  2. Perform git operations
  3. Depend on MCP sampling
  4. Modify files without explicit instruction
  5. Assume Windows Task Scheduler
  1. 使用
    --dangerously-skip-permissions
    参数
  2. 执行git操作
  3. 依赖MCP采样
  4. 无明确指令时修改文件
  5. 假设用户使用Windows任务调度器

Troubleshooting

故障排查

Common Issues:

常见问题:

  1. Crontab not available: User may need to install cron service
  2. Launchd permissions: macOS may require full disk access
  3. opencode/kiro not in PATH: Suggest adding to PATH or using full path
  4. $HOME expansion: Some shells may not expand $HOME in crontab
  1. Crontab不可用:用户可能需要安装cron服务
  2. Launchd权限问题:macOS可能需要授予完整磁盘访问权限
  3. opencode/kiro不在PATH中:建议用户将其添加到PATH或使用完整路径
  4. $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
    sudo
    (with warning)
  • 如果平台检测失败,请询问用户
  • 如果未找到CLI,请建议用户安装
  • 如果cron表达式无效,请展示示例
  • 如果写入权限被拒绝,请建议用户使用
    sudo
    (并附带警告)

Examples for Testing

测试示例

Test these cases:
  1. every day at 9am summarize memory
  2. cada hora analiza logs usando deepseek
  3. every minute during the next 30 minutes check emails
  4. cada minuto durante la próxima hora revisa sistema
  5. Monday and Wednesday at 8:30am backup files
  6. watch my log file at /var/log/app.log and alert on errors
  7. monitor the downloads folder for new PDF files
  8. if config.json changes, restart the service
  9. when new files appear in /data/uploads, process them
  10. track 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.
测试以下场景:
  1. every day at 9am summarize memory
  2. cada hora analiza logs usando deepseek
  3. every minute during the next 30 minutes check emails
  4. cada minuto durante la próxima hora revisa sistema
  5. Monday and Wednesday at 8:30am backup files
  6. watch my log file at /var/log/app.log and alert on errors
  7. monitor the downloads folder for new PDF files
  8. if config.json changes, restart the service
  9. when new files appear in /data/uploads, process them
  10. track changes to source code and run tests
请记住:您是实现该技能的Agent,请严格遵循以上说明,解析用户的自然语言请求,检测运行环境,并始终在修改配置前获得用户确认。