claude-notification-plugin 1.0.80 → 1.0.88
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/.claude-plugin/plugin.json +13 -14
- package/README.md +276 -283
- package/bin/install.js +262 -16
- package/bin/uninstall.js +3 -2
- package/listener/LISTENER-DETAILED.md +3 -3
- package/listener/listener.js +39 -16
- package/listener/telegram-poller.js +27 -1
- package/package.json +60 -60
- package/bin/register-cli.js +0 -142
- package/commands/listener.md +0 -100
- package/commands/setup.md +0 -54
package/bin/register-cli.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const PLUGIN_ROOT = path.resolve(__dirname, '..');
|
|
12
|
-
|
|
13
|
-
const BINS = {
|
|
14
|
-
'claude-notify-listener': 'bin/listener-cli.js',
|
|
15
|
-
'claude-notify-install': 'bin/install.js',
|
|
16
|
-
'claude-notify-uninstall': 'bin/uninstall.js',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function findClaudeDir () {
|
|
20
|
-
try {
|
|
21
|
-
const cmd = process.platform === 'win32' ? 'where claude' : 'which claude';
|
|
22
|
-
const result = execSync(cmd, { encoding: 'utf-8', windowsHide: true }).trim();
|
|
23
|
-
// 'where' on Windows may return multiple lines
|
|
24
|
-
const first = result.split('\n')[0].trim();
|
|
25
|
-
return path.dirname(first);
|
|
26
|
-
} catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function register () {
|
|
32
|
-
const claudeDir = findClaudeDir();
|
|
33
|
-
if (!claudeDir) {
|
|
34
|
-
console.error('Could not find "claude" in PATH.');
|
|
35
|
-
console.error('Make sure Claude Code CLI is installed and available.');
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const isWindows = process.platform === 'win32';
|
|
40
|
-
const created = [];
|
|
41
|
-
|
|
42
|
-
for (const [name, relPath] of Object.entries(BINS)) {
|
|
43
|
-
const scriptPath = path.join(PLUGIN_ROOT, relPath);
|
|
44
|
-
|
|
45
|
-
if (!fs.existsSync(scriptPath)) {
|
|
46
|
-
console.warn(` Skip ${name}: ${scriptPath} not found`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (isWindows) {
|
|
51
|
-
const cmdFile = path.join(claudeDir, `${name}.cmd`);
|
|
52
|
-
const content = `@echo off\r\nnode "${scriptPath}" %*\r\n`;
|
|
53
|
-
fs.writeFileSync(cmdFile, content);
|
|
54
|
-
created.push(cmdFile);
|
|
55
|
-
} else {
|
|
56
|
-
const shFile = path.join(claudeDir, name);
|
|
57
|
-
const content = `#!/bin/sh\nexec node "${scriptPath}" "$@"\n`;
|
|
58
|
-
fs.writeFileSync(shFile, content, { mode: 0o755 });
|
|
59
|
-
created.push(shFile);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (created.length > 0) {
|
|
64
|
-
console.log('Registered CLI commands:');
|
|
65
|
-
for (const f of created) {
|
|
66
|
-
console.log(` ${f}`);
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
console.log('No commands were registered.');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function list () {
|
|
74
|
-
const claudeDir = findClaudeDir();
|
|
75
|
-
if (!claudeDir) {
|
|
76
|
-
console.log('Claude CLI not found in PATH.');
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const isWindows = process.platform === 'win32';
|
|
81
|
-
const ext = isWindows ? '.cmd' : '';
|
|
82
|
-
let found = 0;
|
|
83
|
-
|
|
84
|
-
for (const name of Object.keys(BINS)) {
|
|
85
|
-
const filePath = path.join(claudeDir, `${name}${ext}`);
|
|
86
|
-
const exists = fs.existsSync(filePath);
|
|
87
|
-
console.log(` ${exists ? '+' : '-'} ${name}${exists ? ` (${filePath})` : ''}`);
|
|
88
|
-
if (exists) {
|
|
89
|
-
found++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
console.log('');
|
|
94
|
-
console.log(`${found}/${Object.keys(BINS).length} commands registered in ${claudeDir}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function unregister () {
|
|
98
|
-
const claudeDir = findClaudeDir();
|
|
99
|
-
if (!claudeDir) {
|
|
100
|
-
console.log('Claude CLI not found in PATH — nothing to unregister.');
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const isWindows = process.platform === 'win32';
|
|
105
|
-
const removed = [];
|
|
106
|
-
|
|
107
|
-
for (const name of Object.keys(BINS)) {
|
|
108
|
-
const ext = isWindows ? '.cmd' : '';
|
|
109
|
-
const filePath = path.join(claudeDir, `${name}${ext}`);
|
|
110
|
-
if (fs.existsSync(filePath)) {
|
|
111
|
-
fs.unlinkSync(filePath);
|
|
112
|
-
removed.push(filePath);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (removed.length > 0) {
|
|
117
|
-
console.log('Removed CLI commands:');
|
|
118
|
-
for (const f of removed) {
|
|
119
|
-
console.log(` ${f}`);
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
console.log('No CLI commands found to remove.');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const action = process.argv[2];
|
|
127
|
-
|
|
128
|
-
if (action === 'unregister' || action === 'remove') {
|
|
129
|
-
unregister();
|
|
130
|
-
} else if (action === 'list' || action === 'status') {
|
|
131
|
-
list();
|
|
132
|
-
} else if (action === 'register' || !action) {
|
|
133
|
-
register();
|
|
134
|
-
} else {
|
|
135
|
-
console.log('Usage: claude-notify-register <register|unregister|list>');
|
|
136
|
-
console.log('');
|
|
137
|
-
console.log('Commands:');
|
|
138
|
-
console.log(' register Register CLI commands next to claude binary (default)');
|
|
139
|
-
console.log(' unregister Remove registered CLI commands');
|
|
140
|
-
console.log(' list Show registration status of CLI commands');
|
|
141
|
-
process.exit(1);
|
|
142
|
-
}
|
package/commands/listener.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Manage the Telegram Listener daemon (start, stop, status, logs, restart)
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Listener Management
|
|
6
|
-
|
|
7
|
-
Manage the Telegram Listener daemon that receives tasks from Telegram and executes them via `claude -p`.
|
|
8
|
-
|
|
9
|
-
The user invokes this command as `/claude-notification-plugin:listener <action>`.
|
|
10
|
-
|
|
11
|
-
## Actions
|
|
12
|
-
|
|
13
|
-
Determine the action from the user's input. If no action is provided, show the help text below and ask which action they want.
|
|
14
|
-
|
|
15
|
-
### start
|
|
16
|
-
|
|
17
|
-
Start the listener daemon.
|
|
18
|
-
|
|
19
|
-
1. Determine the plugin root path — use the directory where this command file lives: `${CLAUDE_PLUGIN_ROOT}`. The listener CLI script is at `${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js`.
|
|
20
|
-
2. Run in a shell:
|
|
21
|
-
```bash
|
|
22
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js" start
|
|
23
|
-
```
|
|
24
|
-
3. Show the output to the user. If it says "Listener started", confirm success. If there is an error (missing config, missing projects, already running), explain what to do.
|
|
25
|
-
|
|
26
|
-
### stop
|
|
27
|
-
|
|
28
|
-
Stop the listener daemon.
|
|
29
|
-
|
|
30
|
-
1. Run:
|
|
31
|
-
```bash
|
|
32
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js" stop
|
|
33
|
-
```
|
|
34
|
-
2. Show the output.
|
|
35
|
-
|
|
36
|
-
### status
|
|
37
|
-
|
|
38
|
-
Show the listener status.
|
|
39
|
-
|
|
40
|
-
1. Run:
|
|
41
|
-
```bash
|
|
42
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js" status
|
|
43
|
-
```
|
|
44
|
-
2. Show the output.
|
|
45
|
-
|
|
46
|
-
### logs
|
|
47
|
-
|
|
48
|
-
Show recent log entries.
|
|
49
|
-
|
|
50
|
-
1. Run:
|
|
51
|
-
```bash
|
|
52
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js" logs
|
|
53
|
-
```
|
|
54
|
-
2. Show the output.
|
|
55
|
-
|
|
56
|
-
### restart
|
|
57
|
-
|
|
58
|
-
Restart the listener daemon.
|
|
59
|
-
|
|
60
|
-
1. Run:
|
|
61
|
-
```bash
|
|
62
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/listener-cli.js" restart
|
|
63
|
-
```
|
|
64
|
-
2. Show the output.
|
|
65
|
-
|
|
66
|
-
## Help text
|
|
67
|
-
|
|
68
|
-
If the user doesn't specify an action, show:
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
Telegram Listener — receives tasks from Telegram and executes via claude -p.
|
|
72
|
-
|
|
73
|
-
Usage:
|
|
74
|
-
/claude-notification-plugin:listener start — Start the daemon
|
|
75
|
-
/claude-notification-plugin:listener stop — Stop the daemon
|
|
76
|
-
/claude-notification-plugin:listener status — Show status
|
|
77
|
-
/claude-notification-plugin:listener logs — Show recent logs
|
|
78
|
-
/claude-notification-plugin:listener restart — Restart the daemon
|
|
79
|
-
|
|
80
|
-
Prerequisites:
|
|
81
|
-
1. Telegram bot configured (token + chatId in ~/.claude/notifier.config.json)
|
|
82
|
-
2. "listener.projects" section in config with at least one project
|
|
83
|
-
|
|
84
|
-
See LISTENER.md for detailed documentation.
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Important
|
|
88
|
-
|
|
89
|
-
- The `${CLAUDE_PLUGIN_ROOT}` variable resolves to the plugin installation directory. Always use it to build the path to `bin/listener-cli.js`.
|
|
90
|
-
- If the config doesn't have a `listener.projects` section, tell the user to add one and show a minimal example:
|
|
91
|
-
```json
|
|
92
|
-
{
|
|
93
|
-
"listener": {
|
|
94
|
-
"projects": {
|
|
95
|
-
"default": { "path": "/path/to/your/project" }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
- If Telegram credentials are missing, suggest running `/claude-notification-plugin:setup` first.
|
package/commands/setup.md
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Configure Telegram credentials and notification settings
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Setup claude-notification-plugin
|
|
6
|
-
|
|
7
|
-
Help the user configure the notification plugin. The config file is `~/.claude/notifier.config.json`.
|
|
8
|
-
|
|
9
|
-
## Steps
|
|
10
|
-
|
|
11
|
-
1. **Read existing config** (if it exists) from `~/.claude/notifier.config.json` to preserve current settings.
|
|
12
|
-
|
|
13
|
-
2. **Ask for Telegram bot token**. If a token already exists in the config, show a masked version (first 6 and last 4 characters) and ask if the user wants to keep it. If they want a new one, ask them to provide it.
|
|
14
|
-
|
|
15
|
-
3. **Get the Chat ID**. If the token is available and Chat ID is missing:
|
|
16
|
-
- Ask the user to send any message to their bot in Telegram.
|
|
17
|
-
- Fetch `https://api.telegram.org/bot<TOKEN>/getUpdates` to auto-detect the Chat ID.
|
|
18
|
-
- If auto-detection fails, ask the user to enter the Chat ID manually.
|
|
19
|
-
- If Chat ID already exists, show it and ask if the user wants to keep it.
|
|
20
|
-
|
|
21
|
-
4. **Write the config** to `~/.claude/notifier.config.json`. Merge with existing config — do NOT overwrite settings that already exist (`notifyAfterSeconds`, `notifyOnWaiting`, `debug`, channel `enabled` flags, etc.). Only update `telegram.token` and `telegram.chatId` with the values from this session.
|
|
22
|
-
|
|
23
|
-
Default config structure (for new installs):
|
|
24
|
-
```json
|
|
25
|
-
{
|
|
26
|
-
"telegram": {
|
|
27
|
-
"enabled": true,
|
|
28
|
-
"token": "<TOKEN>",
|
|
29
|
-
"chatId": "<CHAT_ID>",
|
|
30
|
-
"deleteAfterHours": 24
|
|
31
|
-
},
|
|
32
|
-
"windowsNotification": { "enabled": true },
|
|
33
|
-
"sound": { "enabled": true, "file": "C:/Windows/Media/notify.wav" },
|
|
34
|
-
"voice": { "enabled": true },
|
|
35
|
-
"notifyAfterSeconds": 15,
|
|
36
|
-
"notifyOnWaiting": false,
|
|
37
|
-
"debug": false
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
5. **Register CLI commands** — so that `claude-notify-listener`, `claude-notify-install`, and `claude-notify-uninstall` are available from the terminal (not just inside Claude).
|
|
42
|
-
|
|
43
|
-
Run in a shell:
|
|
44
|
-
```bash
|
|
45
|
-
node "${CLAUDE_PLUGIN_ROOT}/bin/register-cli.js"
|
|
46
|
-
```
|
|
47
|
-
This finds the directory where `claude` is installed and creates wrapper scripts there. Show the output to the user. If registration fails (e.g. `claude` not in PATH), inform the user but do NOT treat it as a fatal error — the rest of setup is still valid.
|
|
48
|
-
|
|
49
|
-
6. **Confirm** — show the user a summary of what was saved.
|
|
50
|
-
|
|
51
|
-
## Important
|
|
52
|
-
|
|
53
|
-
- NEVER log or display the full token. Always mask it.
|
|
54
|
-
- Preserve all existing config values when writing — only update token and chatId.
|