---
name: chat-schedule
description: Guide the user to create, refine, pause, or stop a reliable sidecar watch or recurring follow-up attached to the current chat (e.g. watching PR review comments, fixing issues, and merging to dev once approved and green). Also supports `/watch` (alias `/schedule`).
metadata:
  i18n:
    en:
      name: "Chat Watch & Follow-up"
      description: "Guide the user from natural language to a reliable sidecar Watcher (probe context, clarify ambiguous/high-risk gates, capture baseline cursor, and propose an editable confirmation card)."
    zh-CN:
      name: "对话外挂监听与定时跟进"
      description: "从自然语言自动探测上下文、澄清高风险条件、固化初始游标并生成外挂监听确认卡片（默认后台只读检查，有变化才派发主对话，不污染上下文）。"
  xopc:
    emoji: "⏱"
    requires_tools:
      - chat_schedule
---

# Chat Sidecar Watch & Scheduled Follow-up

Use this skill when the user wants to continuously watch an ongoing task attached to the **current conversation** (such as PR review comments + auto-fix + conditional merge, CI checks, deployment status, or issue updates), or wants to inspect, pause, resume, or stop the current chat's watch/schedule.

Do **not** use this skill for standalone global Automations that belong in `#/automations` (e.g. daily morning digests or webhook workflows independent of this conversation).

## Default to Sidecar Watch Mode (`mode: "watch"`)

Always default to **`mode: "watch"`** unless the user explicitly asks to send a fixed reminder directly into the chat on every tick regardless of external changes (`mode: "direct"`).

In **watch mode**, an isolated background Watcher periodically inspects data using read-only tools and compares against a persisted JSON cursor (`watcherState`):
- Nothing actionable (`noop`): stays completely silent and never pollutes the main conversation.
- Actionable change or satisfied branch (`dispatch`): sends a focused message into the main chat (skipping automatically if the main chat is busy, without advancing the cursor so nothing is lost).
- Stop condition objectively verified (`stop`): closes itself automatically.

## Reliable 3-Step Workflow: Probe → Clarify → Propose

Follow these three steps whenever the user asks in natural language to watch something (for example: *"帮我盯着看下这个 PR 下是否有新的 comment 需要修复，如果有则修复并 comment push，如果没有问题把 PR 合并到 dev"*):

### Step 1: Silent Read-Only Probe First
Before asking the user anything, quietly inspect the workspace / conversation context with read-only commands so you never ask avoidable questions:
- For PR workflows, run read-only checks such as `gh pr view --json number,url,state,baseRefName,headRefName,headRefOid,reviewDecision,mergeable` and `gh api user --jq .login` (plus existing unresolved comment/thread IDs).
- Capture the factual baseline into a compact JSON string for `initialWatcherState` (for example: `{"target":"PR #418","state":"OPEN","headSha":"abc123","selfLogin":"alice","seenCommentIds":["101","102"],"reviewDecision":"REVIEW_REQUIRED","ciStatus":"PENDING"}`).
- Never perform write actions (commits, pushes, comments, merges) during setup.

### Step 2: One Concise `clarify` Call (Only for Real Ambiguity or High-Risk Gates)
Use the `clarify` tool (`schemaVersion: 2`, 1–3 concise choices) ONLY when:
1. **Target could not be probed** (e.g. no PR found for the current branch and none mentioned in chat).
2. **High-risk conditional write action has a vague gate** — e.g. *"如果没有问题就把 PR 合并到 dev"*:
   - **Never** treat "0 comments" as "no issues / ready to merge" (reviewers may simply not have looked yet!).
   - Clarify the merge gate with clear choices:
     - **至少 1 个 Approve + CI 全绿 + 无未解决评论（推荐）**
     - **仅 CI 全绿且无未解决评论**
     - **满足条件时先发消息提醒我确认，不自动合并**
3. **Cadence is unspecified and non-obvious** (optional quick choice: `每 15 分钟（推荐）` / `每 5 分钟` / `每 30 分钟`).

Keep clarification to **at most one round**. If the user prefers filling details themselves or details remain open, proceed to Step 3 and include `missingDetails` so the proposal card highlights the **Edit / 完善配置** button to open the prefilled form.

### Step 3: Propose a Clean, User-Readable Watch Draft
Call `chat_schedule(action: "propose")` with four engineering guardrails built in.
**Important UI rule**: `watchPrompt`, `prompt`, and `stopCondition` are displayed directly in the user's editable form and confirmation card — write them in **short, natural, scannable prose** matching the user's language, and **never** leak internal protocol terms (`noop`, `dispatch`, `[BRANCH: ...]`, `nextState`, `chat_schedule action=stop`) into those user-facing fields (the runtime injects those rules automatically).

1. **Clear `watchPrompt` (Target + What Counts as Change + Anti-Echo)**:
   - Name the exact target (repo / PR number / file / target branch `dev`).
   - State clearly to ignore self-authored replies and already-resolved items.
   - If there are multiple outcomes, write them in plain bullet-like sentences (e.g. *"检查 PR #418：1）有他人新增未解决评论时通知；2）当获得 Approve、CI 全绿且无未解决评论时通知可合并到 dev。"*). Never trigger merge just because comment count is 0.
2. **Matching `prompt` (Main-Chat Action + Optional Skill)**:
   - Place any `/skill:<name>` reference at the **very beginning** of `prompt` so it expands natively.
   - Keep the action crisp and natural (e.g. *"如有新评论，按评论修复代码、跑测试、push 并回复同事；如已满足合并条件，确认状态无误后将 PR 合并到 dev 并结束监听。"*).
3. **Short, Verifiable `stopCondition`**:
   - Keep it to 1 short sentence (e.g. *"PR #418 已合并或关闭"*).
4. **Baseline Cursor (`initialWatcherState`) & Guardrails**:
   - Pass the compact JSON baseline from Step 1 into `initialWatcherState` so round #1 does not re-trigger on historical items.
   - Keep sensible defaults: `intervalMinutes` (10–15m for PRs, 3–5m for CI), `maxRuns: 50`, `expiresInHours: 24`.

## Always Propose First (Confirmation Card)

- Never activate a schedule silently; always call `chat_schedule(action: "propose")` so the user gets an inline confirmation card to click **开启定时** or **修改配置** (prefilled modal form with model/agent/skill selection).
- Mention that the user can also adjust or inspect check history anytime via `/watch` (alias `/schedule`) or the `[⏱]` clock button.
- If the user asks to tweak the draft in chat, call `chat_schedule(action: "propose")` again to replace the draft.
