opencode-zombie-monitor 1.0.0
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/LICENSE +21 -0
- package/README.md +153 -0
- package/assets/russia-heart.png +0 -0
- package/assets/russia-heart.webp +0 -0
- package/download-emoji.mjs +115 -0
- package/index.mjs +153 -0
- package/package.json +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matroskin86
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# 🧟 OpenCode Zombie Monitor
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Matroskin86/opencode-zombie-monitor/blob/main/LICENSE)
|
|
4
|
+
[]()
|
|
5
|
+
[]()
|
|
6
|
+
|
|
7
|
+
> *"The only good zombie is a dead zombie"* 💀
|
|
8
|
+
|
|
9
|
+
Automatically hunts down and eliminates orphaned OpenCode processes that lurk in your system, devouring precious RAM.
|
|
10
|
+
|
|
11
|
+
## 😱 The Horror Story
|
|
12
|
+
|
|
13
|
+
You're coding happily with OpenCode. You close a terminal tab. Life goes on...
|
|
14
|
+
|
|
15
|
+
**BUT WAIT!** The process didn't die. It's still there. Lurking. Consuming ~100MB of your RAM. And every time you close a tab without pressing `q`... another zombie rises.
|
|
16
|
+
|
|
17
|
+
Before you know it:
|
|
18
|
+
```
|
|
19
|
+
$ ps aux | grep opencode
|
|
20
|
+
opencode ?? 100MB
|
|
21
|
+
opencode ?? 100MB
|
|
22
|
+
opencode ?? 100MB
|
|
23
|
+
opencode ?? 100MB
|
|
24
|
+
... 💀 YOUR RAM IS GONE 💀
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 🔫 The Solution
|
|
28
|
+
|
|
29
|
+
This plugin is your zombie apocalypse survival kit:
|
|
30
|
+
|
|
31
|
+
- 🔍 **Detects** zombie processes (no TTY = undead)
|
|
32
|
+
- 🧟 **Kills** them on sight (every message you send)
|
|
33
|
+
- 📢 **Reports** the kills (without wasting LLM tokens)
|
|
34
|
+
- 🧹 **Keeps** your system clean automatically
|
|
35
|
+
|
|
36
|
+
## 📦 Installation
|
|
37
|
+
|
|
38
|
+
Add to your `opencode.json`:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"plugin": ["github:Matroskin86/opencode-zombie-monitor"]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Restart OpenCode. The hunt begins. 🎯
|
|
47
|
+
|
|
48
|
+
## 🎮 Usage
|
|
49
|
+
|
|
50
|
+
### Automatic Mode (default)
|
|
51
|
+
|
|
52
|
+
Just chat normally. The plugin silently patrols your system and eliminates zombies on every message.
|
|
53
|
+
|
|
54
|
+
When zombies are neutralized, you'll see:
|
|
55
|
+
```
|
|
56
|
+
🧟 Killed 3 zombie opencode processes | Freed ~300MB RAM
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Manual Mode
|
|
60
|
+
|
|
61
|
+
Want to check the situation yourself?
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
/zombies
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Response when all clear:
|
|
68
|
+
```
|
|
69
|
+
✅ 2 processes, no zombies
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Response when trouble brewing:
|
|
73
|
+
```
|
|
74
|
+
🧟 5 zombies of 7 processes | ~500MB RAM | Fix: oc-kill-zombies
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## ⚙️ Configuration
|
|
78
|
+
|
|
79
|
+
Edit `index.mjs` to adjust aggression level:
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
// RAMBO MODE: Kill on sight (default)
|
|
83
|
+
const AUTO_KILL_THRESHOLD = 1
|
|
84
|
+
|
|
85
|
+
// PATIENT MODE: Wait until horde forms
|
|
86
|
+
const AUTO_KILL_THRESHOLD = 5
|
|
87
|
+
|
|
88
|
+
// PACIFIST MODE: Only notify, never kill
|
|
89
|
+
const AUTO_KILL_THRESHOLD = 999
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 🖥️ Supported Platforms
|
|
93
|
+
|
|
94
|
+
| Platform | Status | TTY Pattern |
|
|
95
|
+
|----------|--------|-------------|
|
|
96
|
+
| macOS | ✅ Ready to hunt | `??` |
|
|
97
|
+
| Linux | ✅ Ready to hunt | `?` |
|
|
98
|
+
| Windows | ❌ Zombies win | N/A |
|
|
99
|
+
|
|
100
|
+
## 🌍 Language Support
|
|
101
|
+
|
|
102
|
+
Auto-detects your language. Because zombies are international.
|
|
103
|
+
|
|
104
|
+
| Language | Detection | Example |
|
|
105
|
+
|----------|-----------|---------|
|
|
106
|
+
| 🇬🇧 English | default | "Killed 3 zombie processes" |
|
|
107
|
+
| 🇷🇺 Russian | `LANG=ru*` | "Убито 3 зомби-процессов" |
|
|
108
|
+
| 🇨🇳 Chinese | `LANG=zh*` | "已击杀 3 个僵尸进程" |
|
|
109
|
+
|
|
110
|
+
## 🔬 How It Works
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
┌─────────────────────────────────────────┐
|
|
114
|
+
│ You send a message │
|
|
115
|
+
└─────────────────┬───────────────────────┘
|
|
116
|
+
▼
|
|
117
|
+
┌─────────────────────────────────────────┐
|
|
118
|
+
│ Plugin runs: ps aux | grep opencode │
|
|
119
|
+
└─────────────────┬───────────────────────┘
|
|
120
|
+
▼
|
|
121
|
+
┌─────────────────────────────────────────┐
|
|
122
|
+
│ Filter: TTY == "??" (no terminal) │
|
|
123
|
+
│ These are the zombies 🧟 │
|
|
124
|
+
└─────────────────┬───────────────────────┘
|
|
125
|
+
▼
|
|
126
|
+
┌─────────────────────────────────────────┐
|
|
127
|
+
│ Execute: kill -9 <zombie_pids> │
|
|
128
|
+
│ Headshot! 💥 │
|
|
129
|
+
└─────────────────┬───────────────────────┘
|
|
130
|
+
▼
|
|
131
|
+
┌─────────────────────────────────────────┐
|
|
132
|
+
│ Notify via "ignored" message │
|
|
133
|
+
│ (Free! No LLM tokens used) │
|
|
134
|
+
└─────────────────────────────────────────┘
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## 🤝 Contributing
|
|
138
|
+
|
|
139
|
+
Found a bug? Zombies escaped? Open an issue!
|
|
140
|
+
|
|
141
|
+
Want to add Windows support? PRs welcome! (Good luck with that 😅)
|
|
142
|
+
|
|
143
|
+
## 📜 License
|
|
144
|
+
|
|
145
|
+
MIT — Use it, fork it, kill zombies with it.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
<p align="center">
|
|
150
|
+
<i>Made with 🧠 (before zombies ate it)</i>
|
|
151
|
+
<br><br>
|
|
152
|
+
<b>From Russia with <img src="./assets/russia-heart.png" width="20" height="20" alt="love"></b>
|
|
153
|
+
</p>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Скрипт для скачивания Telegram custom emoji
|
|
3
|
+
*
|
|
4
|
+
* 1. Отправь эмодзи боту @your_bot
|
|
5
|
+
* 2. Запусти: node download-emoji.mjs
|
|
6
|
+
* 3. Эмодзи сохранится в ./assets/emoji.webp
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import https from 'https'
|
|
10
|
+
import fs from 'fs'
|
|
11
|
+
import path from 'path'
|
|
12
|
+
|
|
13
|
+
const BOT_TOKEN = '8061734285:AAHeLB0YHXomdjPPyTg18GM0_RrdvTbp4aA'
|
|
14
|
+
const API_URL = `https://api.telegram.org/bot${BOT_TOKEN}`
|
|
15
|
+
|
|
16
|
+
async function fetchJson(url) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
https.get(url, (res) => {
|
|
19
|
+
let data = ''
|
|
20
|
+
res.on('data', chunk => data += chunk)
|
|
21
|
+
res.on('end', () => resolve(JSON.parse(data)))
|
|
22
|
+
}).on('error', reject)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function downloadFile(filePath, destPath) {
|
|
27
|
+
const fileUrl = `https://api.telegram.org/file/bot${BOT_TOKEN}/${filePath}`
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const file = fs.createWriteStream(destPath)
|
|
30
|
+
https.get(fileUrl, (res) => {
|
|
31
|
+
res.pipe(file)
|
|
32
|
+
file.on('finish', () => {
|
|
33
|
+
file.close()
|
|
34
|
+
resolve(destPath)
|
|
35
|
+
})
|
|
36
|
+
}).on('error', reject)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
console.log('🔍 Получаю последние сообщения...')
|
|
42
|
+
|
|
43
|
+
// Получить updates
|
|
44
|
+
const updates = await fetchJson(`${API_URL}/getUpdates?limit=10`)
|
|
45
|
+
|
|
46
|
+
if (!updates.ok || !updates.result.length) {
|
|
47
|
+
console.log('❌ Нет сообщений. Отправь эмодзи боту и попробуй снова.')
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Найти сообщение с custom emoji
|
|
52
|
+
let customEmojiId = null
|
|
53
|
+
let messageText = null
|
|
54
|
+
|
|
55
|
+
for (const update of updates.result.reverse()) {
|
|
56
|
+
const msg = update.message
|
|
57
|
+
if (msg?.entities) {
|
|
58
|
+
for (const entity of msg.entities) {
|
|
59
|
+
if (entity.type === 'custom_emoji') {
|
|
60
|
+
customEmojiId = entity.custom_emoji_id
|
|
61
|
+
messageText = msg.text
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (customEmojiId) break
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!customEmojiId) {
|
|
70
|
+
console.log('❌ Custom emoji не найден. Отправь эмодзи из платного/премиум пака.')
|
|
71
|
+
console.log('📋 Последние сообщения:', updates.result.map(u => u.message?.text).filter(Boolean))
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log(`✅ Найден emoji: "${messageText}" (ID: ${customEmojiId})`)
|
|
76
|
+
|
|
77
|
+
// Получить стикер по emoji ID
|
|
78
|
+
console.log('📥 Получаю файл стикера...')
|
|
79
|
+
const stickers = await fetchJson(`${API_URL}/getCustomEmojiStickers?custom_emoji_ids=["${customEmojiId}"]`)
|
|
80
|
+
|
|
81
|
+
if (!stickers.ok || !stickers.result.length) {
|
|
82
|
+
console.log('❌ Не удалось получить стикер:', stickers)
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const sticker = stickers.result[0]
|
|
87
|
+
console.log(`📦 Стикер: ${sticker.file_id}`)
|
|
88
|
+
|
|
89
|
+
// Получить путь к файлу
|
|
90
|
+
const fileInfo = await fetchJson(`${API_URL}/getFile?file_id=${sticker.file_id}`)
|
|
91
|
+
|
|
92
|
+
if (!fileInfo.ok) {
|
|
93
|
+
console.log('❌ Не удалось получить файл:', fileInfo)
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Создать папку assets
|
|
98
|
+
const assetsDir = './assets'
|
|
99
|
+
if (!fs.existsSync(assetsDir)) {
|
|
100
|
+
fs.mkdirSync(assetsDir)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Скачать файл
|
|
104
|
+
const ext = path.extname(fileInfo.result.file_path) || '.webp'
|
|
105
|
+
const destPath = `${assetsDir}/emoji${ext}`
|
|
106
|
+
|
|
107
|
+
console.log(`💾 Скачиваю в ${destPath}...`)
|
|
108
|
+
await downloadFile(fileInfo.result.file_path, destPath)
|
|
109
|
+
|
|
110
|
+
console.log(`✅ Готово! Файл сохранён: ${destPath}`)
|
|
111
|
+
console.log(`\n📝 Для README используй:`)
|
|
112
|
+
console.log(`<img src="${destPath}" width="20" height="20">`)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
main().catch(console.error)
|
package/index.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Zombie Monitor Plugin
|
|
3
|
+
* Auto-detects and kills orphaned opencode processes
|
|
4
|
+
* Supports: macOS and Linux
|
|
5
|
+
*/
|
|
6
|
+
import { exec } from "child_process"
|
|
7
|
+
import { promisify } from "util"
|
|
8
|
+
import { platform } from "os"
|
|
9
|
+
|
|
10
|
+
const execAsync = promisify(exec)
|
|
11
|
+
const isMac = platform() === "darwin"
|
|
12
|
+
|
|
13
|
+
// Detect system language
|
|
14
|
+
const lang = (process.env.LANG || process.env.LC_ALL || "").toLowerCase()
|
|
15
|
+
const getLang = () => {
|
|
16
|
+
if (lang.startsWith("ru")) return "ru"
|
|
17
|
+
if (lang.startsWith("zh")) return "zh"
|
|
18
|
+
return "en"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Localized messages
|
|
22
|
+
const i18n = {
|
|
23
|
+
en: {
|
|
24
|
+
killed: (n) => `🧟 Killed ${n} zombie opencode process${n > 1 ? "es" : ""} | Freed ~${n * 100}MB RAM`,
|
|
25
|
+
found: (n) => `🧟 ${n} zombie opencode process${n > 1 ? "es" : ""} | ~${n * 100}MB RAM | Fix: oc-kill-zombies`,
|
|
26
|
+
status: (zombies, total) => zombies > 0
|
|
27
|
+
? `🧟 ${zombies} zombie${zombies > 1 ? "s" : ""} of ${total} process${total > 1 ? "es" : ""} | ~${zombies * 100}MB RAM | Fix: oc-kill-zombies`
|
|
28
|
+
: `✅ ${total} process${total > 1 ? "es" : ""}, no zombies`,
|
|
29
|
+
commandDesc: "Check zombie opencode processes"
|
|
30
|
+
},
|
|
31
|
+
ru: {
|
|
32
|
+
killed: (n) => `🧟 Убито ${n} зомби-процессов opencode | Освобождено ~${n * 100}MB RAM`,
|
|
33
|
+
found: (n) => `🧟 ${n} зомби-процессов opencode | ~${n * 100}MB RAM | Fix: oc-kill-zombies`,
|
|
34
|
+
status: (zombies, total) => zombies > 0
|
|
35
|
+
? `🧟 ${zombies} зомби из ${total} процессов | ~${zombies * 100}MB RAM | Fix: oc-kill-zombies`
|
|
36
|
+
: `✅ ${total} процессов, зомби нет`,
|
|
37
|
+
commandDesc: "Проверить зомби-процессы opencode"
|
|
38
|
+
},
|
|
39
|
+
zh: {
|
|
40
|
+
killed: (n) => `🧟 已击杀 ${n} 个僵尸 opencode 进程 | 释放 ~${n * 100}MB 内存`,
|
|
41
|
+
found: (n) => `🧟 发现 ${n} 个僵尸 opencode 进程 | ~${n * 100}MB 内存 | 修复: oc-kill-zombies`,
|
|
42
|
+
status: (zombies, total) => zombies > 0
|
|
43
|
+
? `🧟 ${total} 个进程中有 ${zombies} 个僵尸 | ~${zombies * 100}MB 内存 | 修复: oc-kill-zombies`
|
|
44
|
+
: `✅ ${total} 个进程,没有僵尸`,
|
|
45
|
+
commandDesc: "检查僵尸 opencode 进程"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const t = i18n[getLang()]
|
|
50
|
+
|
|
51
|
+
// Count only processes WITHOUT terminal (real zombies)
|
|
52
|
+
const getZombieCount = async () => {
|
|
53
|
+
try {
|
|
54
|
+
// macOS: TTY = "??" | Linux: TTY = "?"
|
|
55
|
+
const ttyPattern = isMac ? '??' : '?'
|
|
56
|
+
const { stdout } = await execAsync(`ps aux | grep "[o]pencode" | grep -v "opencode/" | awk '$7 == "${ttyPattern}" {count++} END {print count+0}'`)
|
|
57
|
+
return parseInt(stdout.trim()) || 0
|
|
58
|
+
} catch {
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Count all opencode processes
|
|
64
|
+
const getTotalCount = async () => {
|
|
65
|
+
try {
|
|
66
|
+
const { stdout } = await execAsync('ps aux | grep "[o]pencode" | grep -v "opencode/" | wc -l')
|
|
67
|
+
return parseInt(stdout.trim()) || 0
|
|
68
|
+
} catch {
|
|
69
|
+
return 0
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Kill zombie processes (without terminal)
|
|
74
|
+
const killZombies = async () => {
|
|
75
|
+
try {
|
|
76
|
+
const ttyPattern = isMac ? '??' : '?'
|
|
77
|
+
await execAsync(`ps aux | grep "[o]pencode" | grep -v "opencode/" | awk '$7 == "${ttyPattern}" {print $2}' | xargs kill -9 2>/dev/null`)
|
|
78
|
+
return true
|
|
79
|
+
} catch {
|
|
80
|
+
return false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Auto-kill threshold (1 = kill immediately)
|
|
85
|
+
const AUTO_KILL_THRESHOLD = 1
|
|
86
|
+
|
|
87
|
+
const sendNotification = async (client, sessionId, text) => {
|
|
88
|
+
await client.session.prompt({
|
|
89
|
+
path: { id: sessionId },
|
|
90
|
+
body: {
|
|
91
|
+
noReply: true,
|
|
92
|
+
parts: [{ type: "text", text, ignored: true }]
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const getSessionIdFromMessages = (messages) => {
|
|
98
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
99
|
+
if (messages[i]?.info?.role === "user" && messages[i]?.info?.sessionID) {
|
|
100
|
+
return messages[i].info.sessionID
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const ZombieMonitor = async ({ client }) => {
|
|
107
|
+
let lastNotifiedCount = 0
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
config: async (opencodeConfig) => {
|
|
111
|
+
opencodeConfig.command = opencodeConfig.command || {}
|
|
112
|
+
opencodeConfig.command["zombies"] = {
|
|
113
|
+
template: "",
|
|
114
|
+
description: t.commandDesc
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
"experimental.chat.messages.transform": async (input, output) => {
|
|
119
|
+
const sessionId = getSessionIdFromMessages(output.messages)
|
|
120
|
+
if (!sessionId) return
|
|
121
|
+
|
|
122
|
+
const zombies = await getZombieCount()
|
|
123
|
+
|
|
124
|
+
// Auto-kill if zombies >= threshold
|
|
125
|
+
if (zombies >= AUTO_KILL_THRESHOLD) {
|
|
126
|
+
await killZombies()
|
|
127
|
+
try {
|
|
128
|
+
await sendNotification(client, sessionId, t.killed(zombies))
|
|
129
|
+
} catch (e) {}
|
|
130
|
+
lastNotifiedCount = 0
|
|
131
|
+
}
|
|
132
|
+
// Notify if zombies appeared (but below threshold)
|
|
133
|
+
else if (zombies > 0 && zombies > lastNotifiedCount) {
|
|
134
|
+
lastNotifiedCount = zombies
|
|
135
|
+
try {
|
|
136
|
+
await sendNotification(client, sessionId, t.found(zombies))
|
|
137
|
+
} catch (e) {}
|
|
138
|
+
} else if (zombies === 0) {
|
|
139
|
+
lastNotifiedCount = 0
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
"command.execute.before": async (input) => {
|
|
144
|
+
if (input.command !== "zombies") return
|
|
145
|
+
|
|
146
|
+
const zombies = await getZombieCount()
|
|
147
|
+
const total = await getTotalCount()
|
|
148
|
+
|
|
149
|
+
await sendNotification(client, input.sessionID, t.status(zombies, total))
|
|
150
|
+
throw new Error("__ZOMBIES_HANDLED__")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-zombie-monitor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Auto-kill zombie opencode processes. Supports macOS and Linux with auto language detection (EN/RU).",
|
|
5
|
+
"main": "index.mjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": ["opencode", "plugin", "zombie", "process", "monitor", "cleanup"],
|
|
8
|
+
"author": "jenshen86",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/jenshen86/opencode-zombie-monitor"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@opencode-ai/plugin": ">=1.0.0"
|
|
16
|
+
}
|
|
17
|
+
}
|