mcpField
O
ops-comms

ops-comms

github.com/davepoon生产力3.7k72 次安装今天更新
代码仓库

关于 ops-comms

ops-comms 是用于处理多渠道通信的 Claude 技能,涵盖 WhatsApp、邮件、Slack、Telegram、Discord 和 Notion。它按渠道路由请求,并要求发送前预览消息。

主要功能

  1. 01按渠道路由消息
  2. 02读取近期聊天和邮件线程
  3. 03搜索联系人与对话
  4. 04发送前预览并确认

适用场景

  1. 01查看各消息渠道的近期动态
  2. 02起草并发送联系人消息
  3. 03搜索 Notion 页面和评论

MCP 相关

通过已配置的 MCP 工具处理 Slack、Gmail、Telegram 和 Notion 操作;WhatsApp 与 Discord 工作流则使用命令行工具。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davepoon/buildwithclaude --skill ops-comms

安装后在 Claude Code 中输入/ops-comms确认已加载。

详细介绍

OPS ► COMMS

运行时上下文

执行前,加载可用上下文:

  1. 守护进程健康状态:读取 ${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/daemon-health.json

    • 执行任何 WhatsApp 操作前,检查 wacli-sync 状态
    • 还要检查 ~/.wacli/.health — 如果不是 status=connected,则在继续前指出身份验证问题
  2. Ops 记忆:起草任何消息前,检查 ${CLAUDE_PLUGIN_DATA_DIR}/memories/:

    • contact_*.md — 加载收件人资料
    • preferences.md — 匹配用户的沟通风格、语言和语气
    • donts.md — 任何草稿中都不得出现的限制内容
  3. 偏好设置:读取 ${CLAUDE_PLUGIN_DATA_DIR}/preferences.json 中的 default_channels,以确定当某个联系人有多个可用渠道时应优先使用哪个渠道。

CLI/API 参考

wacli(WhatsApp)

健康状态文件 — 执行任何 wacli 命令前,检查 ~/.wacli/.health:

  • status=connected → 继续
  • status=needs_auth 或 status=needs_reauth → 提示用户扫描 QR 码,不要运行 wacli 命令
命令用法输出
wacli doctor --json检查身份验证/连接/锁/FTS{data: {authenticated, connected, lock_held, fts_enabled}}
wacli chats list --json所有聊天{data: [{JID, Name, Kind, LastMessageTS}]}
wacli messages list --chat "<JID>" --limit N --json聊天消息{data: {messages: [{FromMe, Text, Timestamp, SenderName, ChatName}]}}
wacli messages search --query "<text>" --jsonFTS 搜索同上
wacli contacts --search "<name>" --json查找联系人联系人对象
wacli send --to "<JID>" --message "<msg>"发送文本成功/错误
gog CLI(Gmail/Calendar)
命令用法输出
gog gmail search "in:inbox" --max 50 -j --results-only --no-input搜索收件箱JSON 线程数组
gog gmail thread get <threadId> -j获取包含所有消息的完整线程完整消息 JSON
gog gmail send --to "[email protected]" --subject "subj" --body "text"发送新邮件发送结果
gog gmail send --reply-to-message-id <msgId> --reply-all --body "text"回复所有人发送结果
gog gmail send --to "[email protected]" --subject "subj" --body "text" --attach /path/file添加附件发送结果
gog gmail archive <messageId> ... --no-input --force归档消息归档结果

解析 $ARGUMENTS 并立即路由:

路由表

模式操作
whatsapp显示最近的 WhatsApp 聊天 — 提供读取或发送选项
email通过 Gmail MCP 显示最近的邮件线程
slack显示最近的 Slack 活动
telegram显示最近的 Telegram 聊天
discord显示最近的 Discord 频道活动(通过 bin/ops-discord)
notion搜索 Notion 工作区 — 页面、评论、任务
send * to *解析消息和联系人,确定最佳渠道并发送
read *读取指定频道或联系人的消息
(空)显示频道选择菜单

自然语言解析:像 send "deploy done" to #general on discord 或 to #ops-alerts on Discord 这样的短语应路由到下方的 discord 分支。提取频道标记(# 后的词,不区分大小写),并将其作为第一个参数传给 bin/ops-discord send。


发送流程:send [message] to [contact]

  1. 从 $ARGUMENTS 中解析联系人姓名和消息。
  2. 通过查找联系人确定渠道:
    • 检查 WhatsApp:wacli contacts --search "[contact]" --json 2>/dev/null
    • 检查 Slack:使用 mcp__claude_ai_Slack__slack_search_users,参数为 query: "[contact]"
    • 检查电子邮件:根据已知上下文确定,或询问用户
  3. 如果找到多个渠道,使用 AskUserQuestion:[WhatsApp] / [Slack] / [Email]
  4. 发送前务必预览。 使用 AskUserQuestion 确认:
Ready to send via [channel]:
  To: [contact name] ([identifier])
  Message: "[full message text]"

  [Send now]  [Edit message]  [Cancel]

如果用户选择“编辑消息”,使用 AskUserQuestion 通过自由文本获取修改后的消息,然后重新预览。

  1. 通过所选渠道发送。确认消息:Sent to [contact] via [channel] ✓
WhatsApp 发送

**重要 — 发送前请阅读:**起草任何 WhatsApp 回复前,必须:

  1. 阅读完整对话:wacli messages list --chat "<JID>" --limit 20 --json
  2. 确认哪些消息来自用户(FromMe: true),哪些来自联系人
  3. 总结对话内容以及联系人提出的问题
  4. 只有完成以上步骤后,才能起草回复,回应联系人实际说的内容

**切勿仅根据单条消息发送回复。**像“你能从 Klaviyo 把它调出来吗?”这样的消息,如果不知道前文中“它”指的是什么,就毫无意义。

**发送前检查:**运行任何 wacli 命令前,检查 ~/.wacli/.health。如果 status=needs_auth 或 status=needs_reauth,提示用户:“WhatsApp 需要重新验证身份。请在单独的终端中运行 wacli auth 并扫描二维码,然后输入‘done’。”使用 AskUserQuestion:[Done — re-paired]、[Skip WhatsApp]。用户选择 Done 后,重启守护进程:launchctl kickstart -k gui/$(id -u)/com.claude-ops.wacli-keepalive,等待 5 秒。

wacli send --to "[contact]" --message "[message]"
Slack 发送

使用 mcp__claude_ai_Slack__slack_send_message,并提供已解析的频道或用户 ID。

电子邮件发送(草稿)

使用 mcp__claude_ai_Gmail__create_draft——始终先创建草稿。然后使用 AskUserQuestion:

Draft created for [recipient]:
  Subject: [subject]
  Body: [preview]

  [Send now]  [Keep as draft]  [Edit]

阅读流程:read [channel]

WhatsApp:

wacli chats --limit 10 --json 2>/dev/null

显示最近 10 个聊天,包含发送者、预览和时间戳。

电子邮件: 使用 mcp__claude_ai_Gmail__search_threads,参数为 query: "in:inbox"(不要使用 is:unread——扫描整个收件箱,包括已读消息),并显示邮件会话列表。

Slack: 使用 mcp__claude_ai_Slack__slack_search_public_and_private,参数为 query: "in:channel"(不要使用 is:unread——扫描近期的全部活动)。

Telegram: 使用 mcp__claude_ops_telegram__get_updates(limit: 20)和 mcp__claude_ops_telegram__list_chats。 回退方案:telegram-cli --exec "dialog_list" 2>/dev/null || echo "Telegram MCP not configured"

Discord: ${CLAUDE_PLUGIN_ROOT}/bin/ops-discord read "<CHANNEL_ID>" --limit 20 --json——需要 DISCORD_BOT_TOKEN(或凭据存储中的 discord/bot-token)。如果用户不知道频道 ID 且已设置 DISCORD_GUILD_ID,则回退到 bin/ops-discord channels --json。

Notion: 使用 mcp__claude_ai_Notion__notion-search 和用户的查询(或使用 query: "",按 last_edited_time 排序以便浏览)。对于每个结果:

  • 使用搜索结果中的页面 URL/ID,通过 mcp__claude_ai_Notion__notion-fetch 获取完整页面内容
  • 使用 mcp__claude_ai_Notion__notion-get-comments 获取评论
  • 显示页面标题、数据库名称、最后编辑者和近期评论

**Notion API 回退方案:**如果 MCP 工具失败且已设置 NOTION_API_KEY,使用 curl -s -H "Authorization: Bearer $NOTION_API_KEY" -H "Notion-Version: 2022-06-28" -X POST https://api.notion.com/v1/search -d '{"query":"<QUERY>","page_size":10}'

Notion 评论/回复

使用 mcp__claude_ai_Notion__notion-create-comment 和页面 ID 回复评论串。要在数据库中创建新页面,请使用 mcp__claude_ai_Notion__notion-create-pages。

发表评论前务必预览:

Ready to comment on Notion page:
  Page: [page title]
  Comment: "[comment text]"

  [Post comment]  [Edit]  [Cancel]
Telegram 发送

使用 mcp__claude_ops_telegram__send_message,并提供 chat_id(来自 list_chats)和 text。

Discord 发送

通过 Shell 调用 bin/ops-discord send。三种调用形式:

# By channel alias (resolves DISCORD_WEBHOOK_<UPPER> or DISCORD_WEBHOOK_URL)
${CLAUDE_PLUGIN_ROOT}/bin/ops-discord send "<channel-alias>" "<message>" --json

# By channel snowflake (17-20 digit ID, routed through bot token)
${CLAUDE_PLUGIN_ROOT}/bin/ops-discord send "<CHANNEL_ID>" "<message>" --json

# By full webhook URL (useful when the URL is stored per-project)
${CLAUDE_PLUGIN_ROOT}/bin/ops-discord send "https://discord.com/api/webhooks/<ID>/<TOKEN>" "<message>" --json

如果脚本以状态码 1 退出,并返回 {"error":"no discord credential configured — run /ops:setup discord"},请通过 AskUserQuestion 询问用户(每条规则 1 最多提供 4 个选项):[运行 /ops:setup discord] / [现在粘贴 webhook URL] / [跳过]。不要默默跳过——这违反规则 3。

注意:DISCORD_WEBHOOK_URL 与 ops-fires 通知接收器(scripts/ops-notify.sh)共用。如果它已预先配置,执行 /ops:comms discord send 时,应优先将其用作默认值,而不是询问用户设置单独的值。


参数为空 — 频道选择器

显示标题,然后使用分批的 AskUserQuestion 调用(每次最多 4 个选项):

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 OPS ► COMMS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

显示选项前,读取 ${CLAUDE_PLUGIN_DATA_DIR}/preferences.json 并检查已配置的频道。只显示已配置的频道。如果选项总数不超过 4 个(已配置频道 +“发送消息”),则在一次调用中提供。如果超过 4 个,则分批提供:

AskUserQuestion 调用 1 — 读取频道:

  [Read WhatsApp]
  [Read Email]
  [Read Slack]
  [More...]

AskUserQuestion 调用 2(仅当选择“更多...”时):

  [Read Telegram]
  [Send a message]

如果所有频道都已配置,共有 5 个选项——始终分批。如果仅配置了 3 个频道,“读取 X” + “读取 Y” + “读取 Z” + “发送消息”共 4 个选项,可在一次调用中提供。

执行所选操作。

评论

支持 Markdown