discord-bridge 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -10,7 +10,7 @@ Claude Code と Discord の双方向通信ブリッジ。スマホから Claude
10
10
  - **メッセージ取得** - ユーザーからの指示を取得
11
11
  - **リアルタイム待機** - SSE 接続で次の指示を待機
12
12
  - **離席モード** - ターミナルを離れても Discord 経由で操作
13
- - **Hooks** - 通知・停止イベントを自動で Discord に転送
13
+ - **Claude Code / Codex 対応** - どちらのプラットフォームにもスキルをインストール可能
14
14
 
15
15
  ## インストール
16
16
 
@@ -62,15 +62,36 @@ Claude Code を使うプロジェクトのルートに `.discord-bridge.json`
62
62
 
63
63
  > **Note**: チャンネル ID は秘密情報ではありませんが、プロジェクト固有の設定です。チームで共有する場合はそのままコミットし、個人用の場合は `.gitignore` に追加してください。
64
64
 
65
- ### 5. Claude Code プラグインのインストール
65
+ ### 5. スキルのインストール
66
+
67
+ プラットフォームを指定してインストールします:
66
68
 
67
69
  ```bash
68
- discord-bridge install
70
+ # Claude Code の場合(プロジェクトローカル)
71
+ discord-bridge install claude
72
+
73
+ # Codex の場合(プロジェクトローカル)
74
+ discord-bridge install codex
75
+ ```
76
+
77
+ `--user` を付けるとホームディレクトリにインストールされ、全プロジェクトで利用できます:
78
+
79
+ ```bash
80
+ # Claude Code(ユーザー全体)
81
+ discord-bridge install claude --user
82
+
83
+ # Codex(ユーザー全体)
84
+ discord-bridge install codex --user
69
85
  ```
70
86
 
71
- `~/.claude/plugins/discord-bridge/` にスキル(Discord 通知・質問・待機など)と Hooks(イベント自動転送)が配置されます。
87
+ | コマンド | インストール先 |
88
+ |---|---|
89
+ | `install claude` | `.claude/skills/discord-comm/` |
90
+ | `install claude --user` | `~/.claude/skills/discord-comm/` |
91
+ | `install codex` | `.agents/skills/discord-comm/` |
92
+ | `install codex --user` | `~/.agents/skills/discord-comm/` |
72
93
 
73
- Claude Code を再起動してプラグインを読み込みます。
94
+ インストール後、エージェントを再起動してスキルを読み込みます。
74
95
 
75
96
  ### 6. 動作確認
76
97
 
@@ -96,9 +117,9 @@ discord-bridge status
96
117
  discord-bridge start
97
118
  ```
98
119
 
99
- ### Claude Code での利用
120
+ ### エージェントでの利用
100
121
 
101
- Claude Code で以下のように話しかけてください:
122
+ Claude Code や Codex で以下のように話しかけてください:
102
123
 
103
124
  - 「Discord にテスト通知を送って」 - 通知テスト
104
125
  - 「離席する」 - 離席モード(Discord 経由で操作)
package/bin/cli.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { fileURLToPath } from "url";
4
- import { dirname, join } from "path";
4
+ import { dirname, join, resolve } from "path";
5
5
  import { spawn } from "child_process";
6
- import { cpSync, existsSync, mkdirSync } from "fs";
6
+ import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = dirname(__filename);
@@ -23,24 +23,66 @@ switch (command) {
23
23
  }
24
24
 
25
25
  case "install": {
26
+ const platform = process.argv[3];
27
+ const hasUserFlag = process.argv.includes("--user");
28
+
29
+ if (!platform || !["claude", "codex"].includes(platform)) {
30
+ console.error("Usage: discord-bridge install <claude|codex> [--user]");
31
+ console.error("");
32
+ console.error("Platforms:");
33
+ console.error(" claude Install skill for Claude Code (.claude/skills/)");
34
+ console.error(" codex Install skill for Codex (.agents/skills/)");
35
+ console.error("");
36
+ console.error("Options:");
37
+ console.error(" --user Install to home directory instead of project directory");
38
+ process.exit(1);
39
+ }
40
+
26
41
  const home = process.env.HOME;
27
42
  if (!home) {
28
43
  console.error("HOME environment variable is not set");
29
44
  process.exit(1);
30
45
  }
31
- const target = join(home, ".claude", "plugins", "discord-bridge");
32
- const source = join(packageRoot, "plugin");
46
+
47
+ const skillDirs = {
48
+ claude: ".claude/skills",
49
+ codex: ".agents/skills",
50
+ };
51
+
52
+ const base = hasUserFlag ? home : process.cwd();
53
+ const target = join(base, skillDirs[platform], "discord-comm");
54
+ const source = join(packageRoot, "plugin", "skills", "discord-comm");
33
55
 
34
56
  if (!existsSync(source)) {
35
- console.error("Plugin files not found");
57
+ console.error("Skill files not found");
36
58
  process.exit(1);
37
59
  }
38
60
 
39
61
  mkdirSync(target, { recursive: true });
40
62
  cpSync(source, target, { recursive: true });
41
- console.log(`Plugin installed to ${target}`);
63
+
64
+ // Replace script path placeholders in SKILL.md
65
+ const skillMdPath = join(target, "SKILL.md");
66
+ if (existsSync(skillMdPath)) {
67
+ const absoluteTarget = resolve(target);
68
+ let content = readFileSync(skillMdPath, "utf-8");
69
+ content = content.replaceAll(
70
+ "$CLAUDE_PLUGIN_ROOT/skills/discord-comm",
71
+ absoluteTarget
72
+ );
73
+ writeFileSync(skillMdPath, content);
74
+ }
75
+
76
+ const scope = hasUserFlag ? "user" : "project";
77
+ console.log(`Skill installed to ${target}`);
78
+ console.log(` Platform: ${platform}`);
79
+ console.log(` Scope: ${scope}`);
42
80
  console.log("");
43
- console.log("Restart Claude Code to load the plugin.");
81
+ if (platform === "claude") {
82
+ console.log("Restart Claude Code to load the skill.");
83
+ } else {
84
+ console.log("Restart Codex to load the skill.");
85
+ }
44
86
  break;
45
87
  }
46
88
 
@@ -58,13 +100,13 @@ switch (command) {
58
100
  }
59
101
 
60
102
  default:
61
- console.log("discord-bridge - Claude Code <-> Discord communication bridge");
103
+ console.log("discord-bridge - Claude Code / Codex <-> Discord communication bridge");
62
104
  console.log("");
63
105
  console.log("Usage: discord-bridge <command>");
64
106
  console.log("");
65
107
  console.log("Commands:");
66
- console.log(" start Start the Discord bridge server");
67
- console.log(" install Install Claude Code plugin to ~/.claude/plugins/");
68
- console.log(" status Check server health");
108
+ console.log(" start Start the Discord bridge server");
109
+ console.log(" install <claude|codex> [--user] Install skill for the specified platform");
110
+ console.log(" status Check server health");
69
111
  break;
70
112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-bridge",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Claude Code <-> Discord bidirectional communication bridge",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,8 +0,0 @@
1
- {
2
- "name": "discord-bridge",
3
- "description": "Bidirectional communication bridge between Claude Code and Discord. Send questions, receive instructions, share files, and get progress updates through a dedicated Discord channel.",
4
- "version": "0.1.0",
5
- "author": {
6
- "name": "naichi"
7
- }
8
- }
package/plugin/README.md DELETED
@@ -1,17 +0,0 @@
1
- # Discord Bridge Plugin for Claude Code
2
-
3
- Claude Code と Discord の双方向通信ブリッジ。スマホから Claude Code を操作できます。
4
-
5
- ## セットアップ
6
-
7
- このプラグインは `discord-bridge install` コマンドで自動的にインストールされます。
8
-
9
- 詳しいセットアップ手順はリポジトリの README を参照してください:
10
- https://github.com/naichilab/discord-bridge-server
11
-
12
- ## 使い方
13
-
14
- Claude Code で以下のように話しかけてください:
15
-
16
- - 「Discord にテスト通知を送って」 - 通知テスト
17
- - 「離席する」 - 離席モード(Discord 経由で操作)
@@ -1,27 +0,0 @@
1
- {
2
- "description": "Discord bridge hooks for forwarding notifications and stop events",
3
- "hooks": {
4
- "Notification": [
5
- {
6
- "hooks": [
7
- {
8
- "type": "command",
9
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/notify-discord.sh",
10
- "timeout": 15
11
- }
12
- ]
13
- }
14
- ],
15
- "Stop": [
16
- {
17
- "hooks": [
18
- {
19
- "type": "command",
20
- "command": "bash ${CLAUDE_PLUGIN_ROOT}/hooks/scripts/stop-hook.sh",
21
- "timeout": 10
22
- }
23
- ]
24
- }
25
- ]
26
- }
27
- }
@@ -1,36 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- # Read hook input from stdin
5
- HOOK_INPUT=$(cat)
6
-
7
- DISCORD_TOKEN="${DISCORD_TOKEN:-}"
8
- DISCORD_CHANNEL_ID="${DISCORD_CHANNEL_ID:-}"
9
-
10
- if [[ -z "$DISCORD_TOKEN" ]] || [[ -z "$DISCORD_CHANNEL_ID" ]]; then
11
- exit 0
12
- fi
13
-
14
- # Extract notification message
15
- NOTIFICATION=$(echo "$HOOK_INPUT" | /usr/bin/python3 -c "
16
- import sys, json
17
- try:
18
- data = json.load(sys.stdin)
19
- print(data.get('notification', data.get('message', 'Claude Code notification')))
20
- except:
21
- print('Claude Code notification')
22
- " 2>/dev/null || echo "Claude Code notification")
23
-
24
- # Send via Discord REST API
25
- curl -s -X POST \
26
- "https://discord.com/api/v10/channels/${DISCORD_CHANNEL_ID}/messages" \
27
- -H "Authorization: Bot ${DISCORD_TOKEN}" \
28
- -H "Content-Type: application/json" \
29
- -d "$(/usr/bin/python3 -c "
30
- import json, sys
31
- msg = sys.argv[1]
32
- print(json.dumps({'embeds': [{'title': 'Notification', 'description': msg, 'color': 3447003}]}))
33
- " "$NOTIFICATION")" \
34
- > /dev/null 2>&1
35
-
36
- exit 0
@@ -1,35 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- HOOK_INPUT=$(cat)
5
-
6
- DISCORD_TOKEN="${DISCORD_TOKEN:-}"
7
- DISCORD_CHANNEL_ID="${DISCORD_CHANNEL_ID:-}"
8
-
9
- if [[ -z "$DISCORD_TOKEN" ]] || [[ -z "$DISCORD_CHANNEL_ID" ]]; then
10
- exit 0
11
- fi
12
-
13
- # Extract stop reason
14
- REASON=$(echo "$HOOK_INPUT" | /usr/bin/python3 -c "
15
- import sys, json
16
- try:
17
- data = json.load(sys.stdin)
18
- print(data.get('reason', data.get('stopReason', 'Task completed')))
19
- except:
20
- print('Task completed')
21
- " 2>/dev/null || echo "Task completed")
22
-
23
- # Send stop notification
24
- curl -s -X POST \
25
- "https://discord.com/api/v10/channels/${DISCORD_CHANNEL_ID}/messages" \
26
- -H "Authorization: Bot ${DISCORD_TOKEN}" \
27
- -H "Content-Type: application/json" \
28
- -d "$(/usr/bin/python3 -c "
29
- import json, sys
30
- msg = sys.argv[1]
31
- print(json.dumps({'embeds': [{'title': 'Claude Code Stopped', 'description': msg, 'color': 15158332}]}))
32
- " "$REASON")" \
33
- > /dev/null 2>&1
34
-
35
- exit 0