barkclaude 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.js +34 -12
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -23,24 +23,46 @@ function getRandomMessage() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function sendToClaude(message) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const text = `🐕 ${message}`;
|
|
27
|
+
|
|
28
|
+
if (process.platform === 'win32') {
|
|
29
|
+
// Put text on clipboard, focus a likely terminal window, paste + Enter.
|
|
30
|
+
// Uses PowerShell -EncodedCommand so we don't have to escape anything.
|
|
31
|
+
const ps = `
|
|
32
|
+
Add-Type -AssemblyName System.Windows.Forms | Out-Null
|
|
33
|
+
[System.Windows.Forms.Clipboard]::SetText([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${Buffer.from(text, 'utf8').toString('base64')}')))
|
|
34
|
+
$wshell = New-Object -ComObject wscript.shell
|
|
35
|
+
$titles = @('Claude Code','Windows Terminal','PowerShell','Command Prompt','cmd','Terminal','WezTerm','Alacritty','Cursor','VSCode','Visual Studio Code')
|
|
36
|
+
$activated = $false
|
|
37
|
+
foreach ($t in $titles) { if ($wshell.AppActivate($t)) { $activated = $true; break } }
|
|
38
|
+
if (-not $activated) { exit 0 }
|
|
39
|
+
Start-Sleep -Milliseconds 200
|
|
40
|
+
[System.Windows.Forms.SendKeys]::SendWait('^v')
|
|
41
|
+
Start-Sleep -Milliseconds 80
|
|
42
|
+
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
|
|
43
|
+
`;
|
|
44
|
+
const encoded = Buffer.from(ps, 'utf16le').toString('base64');
|
|
45
|
+
exec(`powershell -NoProfile -EncodedCommand ${encoded}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
if (process.platform === 'darwin') {
|
|
50
|
+
const escaped = text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
35
51
|
const osa = `
|
|
36
|
-
tell application "
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
tell application "System Events"
|
|
53
|
+
set the clipboard to "${escaped}"
|
|
54
|
+
keystroke "v" using command down
|
|
55
|
+
delay 0.1
|
|
56
|
+
keystroke return
|
|
40
57
|
end tell
|
|
41
58
|
`;
|
|
42
59
|
exec(`osascript -e '${osa}' 2>/dev/null || true`);
|
|
60
|
+
return;
|
|
43
61
|
}
|
|
62
|
+
|
|
63
|
+
// Linux: try xdotool
|
|
64
|
+
const escaped = text.replace(/'/g, `'\\''`);
|
|
65
|
+
exec(`xdotool type --delay 0 -- '${escaped}' && xdotool key Return 2>/dev/null || true`);
|
|
44
66
|
}
|
|
45
67
|
|
|
46
68
|
function createOverlay() {
|