Communitygithub.com

xyz-rainbow/xyz-windows-notify

🦄 通用 AI 代理技能,用於在 Windows 10 和 11 上觸發原生通知,包含智能圖示解析、即時百分比進度與聲音提示。

xyz-windows-notify 是什麼?

此技能賦予任何 AI 代理(如 Antigravity、Claude、GPT、Cursor、Trae、Pi、Grok 等)在 Windows 10 與 11 上發送原生 Toast 通知的能力,透過 PowerShell 的 BurntToast 模組實現。它支援自訂品牌圖示、百分比里程碑與聲音提醒。技能內建智慧圖示解析機制,會依序嘗試使用明確參數、技能內建圖示(如 unicorn.jpg)、舊版相容圖示、使用者自訂目錄中的圖示,最後優雅地降級為無圖示通知。此外,AI 代理可根據任務情境(如資料庫、部署、錯誤)主動建議或生成相符的自訂圖示(256x256 或 512x512 的 PNG/JPG),並將其儲存於指定目錄,以提升通知的互動體驗。

相容平台✓Claude Code~Codex CLI✓Cursor✓Antigravity✓Gemini CLI
npx skills add xyz-rainbow/xyz-windows-notify

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

XYZ Windows Notify — 通用 AI 代理技能

此技能讓任何 AI 代理(Antigravity、Claude、GPT、Cursor、Trae、Pi、Grok 等)能夠觸發原生的 Windows Toast 通知(相容於 Windows 10 與 Windows 11),使用 PowerShell 的 BurntToast 模組,並支援自訂品牌標示、百分比里程碑與動態圖示管理。


🚀 透過 Skills CLI 安裝

npx skills add xyz-rainbow/xyz-windows-notify

🦄 內建資產與智慧圖示解析

此技能在其 assets/icons/ 目錄中內建了預設品牌圖示(assets/icons/unicorn.jpg 和 assets/icons/icon.jpg)。

發送通知時,請遵循以下智慧解析層級:

  1. 明確參數:透過 -AppLogo "path/to/custom_icon.png" 提供的路徑。
  2. 技能內建圖示:技能目錄內的本地路徑(例如 <skill_dir>/assets/icons/unicorn.jpg)。
  3. 舊版內建圖示:<skill_dir>/assets/unicorn.jpg(為了向下相容)。
  4. 使用者自訂圖示目錄:環境中的使用者路徑(例如 $env:USERPROFILE\Pictures\Icons\custom.png,若存在)。
  5. 優雅降級:若無圖片檔案存在,則不帶 -AppLogo 發送原生的 Windows 通知。

🤖 AI 代理自訂圖示與生成指南

使用此技能的 AI 代理應主動管理視覺回饋:

1. 情境相關的圖示選擇

  • 一般/預設:使用 assets/icons/unicorn.jpg 或 assets/icons/icon.jpg。
  • 資料庫/備份:若存在專用圖示(例如 assets/icons/backup.png 或 assets/icons/database.png),則優先使用。
  • 部署/伺服器:使用火箭/伺服器圖示。
  • 錯誤/重大警報:使用警告/盾牌圖示。

2. 建議與生成新圖示

  • 儲存圖示的位置:將新圖示儲存在 assets/icons/<name>.png(技能或儲存庫資料夾內),或使用者的圖示目錄($env:USERPROFILE\Pictures\Icons\)。
  • 圖示規範:
    • 格式:PNG 或 JPG(正方形 1:1 長寬比)。
    • 建議尺寸:256x256 或 512x512 像素。
    • 透明或純色乾淨背景。
  • 主動式 AI 協定:
    • 當開始一個新的循環工作流程時(例如新的遊戲伺服器監控、影片渲染管線或資料同步),請檢查 assets/icons/ 中是否存在相符的圖示。
    • 如果沒有主題相符的圖示,可建議:

      「我注意到我們還沒有針對 [任務名稱] 的特定 Toast 圖示。您是否希望我生成一個自訂的 256x256 圖示,並將其儲存到 assets/icons/[名稱].png?」

    • 在使用者批准後,使用圖像生成工具(例如 generate_image)或取得合適的資產。

💻 PowerShell 整合方式

Import-Module BurntToast

# 解析預設/內建圖示(含向下相容)
$CandidateIcons = @(
    "$PSScriptRoot\assets\icons\unicorn.jpg",
    "$PSScriptRoot\assets\unicorn.jpg",
    "$env:USERPROFILE\Pictures\Icons\custom.png"
)

$AppLogo = $CandidateIcons | Where-Object { Test-Path $_ } | Select-Object -First 1

# 發送通知並附帶降級方案
if ($AppLogo) {
    New-BurntToastNotification `
        -Text "🦄 任務里程碑:50%", "已處理 1,024 MB / 2,048 MB" `
        -AppLogo $AppLogo `
        -Sound 'Default'
} else {
    New-BurntToastNotification `
        -Text "📊 任務里程碑:50%", "已處理 1,024 MB / 2,048 MB" `
        -Sound 'Default'
}

🐍 Python 整合模式

import subprocess
import os

def send_toast(title: str, message: str, icon_path: str = None):
    # 候選圖示路徑(含向下相容)
    base_dir = os.path.dirname(__file__)
    user_icon = os.path.expanduser("~/Pictures/Icons/custom.png")
    
    candidates = [
        icon_path,
        os.path.join(base_dir, "assets", "icons", "unicorn.jpg"),
        os.path.join(base_dir, "assets", "unicorn.jpg"),
        user_icon
    ]

    selected_icon = next((c for c in candidates if c and os.path.exists(c)), None)

    if selected_icon:
        ps_cmd = f"Import-Module BurntToast; New-BurntToastNotification -Text '{title}', '{message}' -AppLogo '{selected_icon}' -Sound 'Default'"
    else:
        ps_cmd = f"Import-Module BurntToast; New-BurntToastNotification -Text '{title}', '{message}' -Sound 'Default'"

    subprocess.run(["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", ps_cmd], capture_output=True)

# 生命週期中的使用範例
send_toast("🚀 任務已啟動", "正在掃描工作區檔案並計算校驗和...")
send_toast("📊 進度:50%", "已處理 1,024 MB / 2,048 MB")
send_toast("✅ 任務完成(100%)", "已成功處理 2,100 個檔案!")

🌐 多代理全域設定

若要讓此技能在機器上的所有代理中都可使用,請確保將此資料夾符號連結或複製到:

  • Antigravity / Gemini:~/.gemini/config/skills/windows-notify/
  • Claude Desktop / Code:~/.claude/skills/windows-notify/
  • Cursor / Trae / 全域代理:~/.agents/skills/windows-notify/

相關技能