Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89e9fd2083 | ||
|
|
da63b09064 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "oh-my-opencode",
|
"name": "oh-my-opencode",
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
|
"description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@ -48,20 +48,35 @@ async function sendNotification(
|
|||||||
title: string,
|
title: string,
|
||||||
message: string
|
message: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const escapedTitle = title.replace(/"/g, '\\"').replace(/'/g, "\\'")
|
|
||||||
const escapedMessage = message.replace(/"/g, '\\"').replace(/'/g, "\\'")
|
|
||||||
|
|
||||||
switch (p) {
|
switch (p) {
|
||||||
case "darwin":
|
case "darwin": {
|
||||||
await ctx.$`osascript -e ${"display notification \"" + escapedMessage + "\" with title \"" + escapedTitle + "\""}`
|
const esTitle = title.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
|
||||||
|
const esMessage = message.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
|
||||||
|
await ctx.$`osascript -e ${"display notification \"" + esMessage + "\" with title \"" + esTitle + "\""}`
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case "linux":
|
case "linux":
|
||||||
await ctx.$`notify-send ${escapedTitle} ${escapedMessage} 2>/dev/null`.catch(() => {})
|
await ctx.$`notify-send ${title} ${message} 2>/dev/null`.catch(() => {})
|
||||||
break
|
break
|
||||||
case "win32":
|
case "win32": {
|
||||||
await ctx.$`powershell -Command ${"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('" + escapedMessage + "', '" + escapedTitle + "')"}`
|
const psTitle = title.replace(/'/g, "''")
|
||||||
|
const psMessage = message.replace(/'/g, "''")
|
||||||
|
const toastScript = `
|
||||||
|
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
|
||||||
|
$Template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
|
||||||
|
$RawXml = [xml] $Template.GetXml()
|
||||||
|
($RawXml.toast.visual.binding.text | Where-Object {$_.id -eq '1'}).AppendChild($RawXml.CreateTextNode('${psTitle}')) | Out-Null
|
||||||
|
($RawXml.toast.visual.binding.text | Where-Object {$_.id -eq '2'}).AppendChild($RawXml.CreateTextNode('${psMessage}')) | Out-Null
|
||||||
|
$SerializedXml = New-Object Windows.Data.Xml.Dom.XmlDocument
|
||||||
|
$SerializedXml.LoadXml($RawXml.OuterXml)
|
||||||
|
$Toast = [Windows.UI.Notifications.ToastNotification]::new($SerializedXml)
|
||||||
|
$Notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('OpenCode')
|
||||||
|
$Notifier.Show($Toast)
|
||||||
|
`.trim().replace(/\n/g, "; ")
|
||||||
|
await ctx.$`powershell -Command ${toastScript}`.catch(() => {})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function playSound(ctx: PluginInput, p: Platform, soundPath: string): Promise<void> {
|
async function playSound(ctx: PluginInput, p: Platform, soundPath: string): Promise<void> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user