notify

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Notify

通知

Send a Discord embed via
./scripts/notify.py send
. Never curl. Never hand-build JSON.
通过
./scripts/notify.py send
发送Discord嵌入消息。请勿使用curl,请勿手动构建JSON。

Flags

参数

Skill flags map to CLI flags on
send
:
FlagCLI flagEffect
--task
--task
Task notification. Requires
--link
.
--link <url>
--link
URL in embed. Required with
--task
.
--webhook <path>
--webhook-file
URL file. Default:
<anchor>/webhook.url
.
--color <int|hex>
--color
Embed color. Default
5814783
.
--field "N|V"
--field
Repeatable. Max 10.
--content <text>
--content
Message above embed.
--dry-run
--dry-run
Print payload. No POST.
Positional arg
--description
Embed body if not passed as flag.
--title
and
--description
are always required on the CLI.
Skill参数对应
send
命令的CLI参数:
参数CLI参数作用
--task
--task
任务通知。需搭配
--link
使用。
--link <url>
--link
嵌入消息中的URL。与
--task
搭配时为必填项。
--webhook <path>
--webhook-file
URL文件。默认值:
<anchor>/webhook.url
--color <int|hex>
--color
嵌入消息颜色。默认值为
5814783
--field "N|V"
--field
可重复使用。最多10次。
--content <text>
--content
嵌入消息上方的文本内容。
--dry-run
--dry-run
打印请求负载,不执行POST请求。
位置参数
--description
若未通过参数传入,则作为嵌入消息主体内容。
--title
--description
在CLI中始终为必填项。

Anchor

锚点目录

Directory holding this
SKILL.md
. Script:
<anchor>/scripts/notify.py
.
存放此
SKILL.md
的目录。脚本路径:
<anchor>/scripts/notify.py

Step 1: Classify branch

步骤1:分支分类

  • Task work (implement, fix, review, PR, ticket, CI): use
    --task
    +
    --link
    .
  • Generic ping: omit
    --task
    .
    --link
    optional.
  • 任务类工作(开发、修复、评审、PR、工单、CI):使用
    --task
    +
    --link
  • 通用提醒:省略
    --task
    --link
    为可选。

Step 2: Compose embed

步骤2:编写嵌入消息

  • --title
    : short label ("Task complete", "Input needed").
  • --description
    : positional arg or one-line session summary.
  • --link
    : real URL when
    --task
    . GitHub PR/commit, Linear issue, CI run, repo tree link.
  • --field
    : only when it adds signal (branch, ticket, status).
Done when title + description set and
--task
has
--link
.
  • --title
    :简短标签(例如“任务完成”、“需要输入”)。
  • --description
    :位置参数或单行会话摘要。
  • --link
    :使用
    --task
    时需填写真实URL,例如GitHub PR/提交记录、Linear工单、CI运行记录、仓库目录链接。
  • --field
    :仅在能提供有效信息时使用(例如分支、工单、状态)。
当标题和描述已设置,且
--task
搭配了
--link
时,此步骤完成。

Step 3: Ensure webhook config

步骤3:确保Webhook配置

Skip this step when using
--dry-run
.
  1. Resolve path:
    --webhook <path>
    or
    <anchor>/webhook.url
    .
  2. Read the file if it exists. If missing or whitespace-only, ask the user for the Discord webhook URL. Do not run
    send
    yet. Wait for their reply.
  3. On reply: write the URL as a single line to the resolved path. Create parent dirs if needed. URL must start with
    https://discord.com/api/webhooks/
    . If invalid, ask again with the prefix requirement.
  4. Step done when the file contains a valid webhook URL prefix.
First-time setup help: Discord channel → Integrations → Webhooks → New Webhook → copy URL. See
./REFERENCE.md
.
使用
--dry-run
时可跳过此步骤。
  1. 解析路径:使用
    --webhook <path>
    或默认的
    <anchor>/webhook.url
  2. 若文件存在则读取内容。若文件缺失或仅含空白字符,询问用户获取Discord webhook URL。此时不要运行
    send
    命令,等待用户回复。
  3. 收到回复后:将URL作为单行写入解析后的路径。若需要则创建父目录。URL必须以
    https://discord.com/api/webhooks/
    开头。若URL无效,再次询问并提示前缀要求。
  4. 当文件中包含符合要求的有效webhook URL前缀时,此步骤完成。
首次设置指引:Discord频道 → 集成 → Webhooks → 新建Webhook → 复制URL。详见
./REFERENCE.md

Step 4: Run CLI

步骤4:运行CLI命令

bash
python3 <anchor>/scripts/notify.py send --title "..." --description "..." [flags]
Use
--dry-run
when payload unclear. Read
send --help
for Examples.
bash
python3 <anchor>/scripts/notify.py send --title "..." --description "..." [flags]
当负载内容不明确时使用
--dry-run
。查看
send --help
获取示例。

Step 5: Check exit code

步骤5:检查退出码

0 only means sent (or dry-run ok). On 2/3: stderr verbatim to user. Stop. No silent retry.
On exit 1 after Step 3: URL in file failed validation at POST time. Ask user for a fresh webhook URL, rewrite the file, rerun
send
once.
退出码为0仅表示消息已发送(或dry-run执行正常)。若退出码为2/3:将标准错误信息原封不动告知用户,停止操作,不进行静默重试。
若步骤3完成后退出码为1:文件中的URL在POST请求时验证失败。询问用户获取新的webhook URL,重写文件,重新运行一次
send
命令。

Step 6: Report

步骤6:结果反馈

Parse stdout
status:
,
title:
,
link:
. Never echo webhook URL.
解析标准输出中的
status:
title:
link:
字段。切勿回显webhook URL。

Constraints

约束条件

  • Always embeds. Script enforces.
  • Never commit
    webhook.url
    .
  • On exit 3, follow troubleshooting in
    ./REFERENCE.md
    .
  • 始终使用嵌入消息,脚本会强制执行此要求。
  • 切勿提交
    webhook.url
    文件。
  • 若退出码为3,请按照
    ./REFERENCE.md
    中的故障排查步骤操作。