cord-bot 1.0.2 → 1.0.5
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/.github/workflows/publish.yml +32 -0
- package/README.md +59 -58
- package/bin/cord.ts +469 -17
- package/package.json +6 -1
- package/skills/cord/HTTP-API.md +273 -0
- package/skills/cord/SKILL.md +304 -0
- package/src/api.ts +339 -0
- package/src/bot.ts +46 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: oven-sh/setup-bun@v2
|
|
17
|
+
with:
|
|
18
|
+
bun-version: latest
|
|
19
|
+
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: bun install
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '22'
|
|
26
|
+
registry-url: 'https://registry.npmjs.org'
|
|
27
|
+
|
|
28
|
+
- name: Update npm for OIDC support
|
|
29
|
+
run: npm install -g npm@latest
|
|
30
|
+
|
|
31
|
+
- name: Publish to npm with provenance
|
|
32
|
+
run: npm publish --provenance --access public
|
package/README.md
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
# Cord
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A Discord bot that connects to Claude Code CLI, plus a Claude Code skill that lets your assistant control the bot.
|
|
4
4
|
|
|
5
5
|
> **cord** /kôrd/ — a connection between two things.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
1. Creates a thread for the conversation
|
|
9
|
-
2. Queues the message for Claude processing
|
|
10
|
-
3. Posts Claude's response back to the thread
|
|
11
|
-
4. Remembers context for follow-up messages
|
|
7
|
+
[](https://www.npmjs.com/package/cord-bot)
|
|
12
8
|
|
|
13
|
-
##
|
|
9
|
+
## What You Get
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
**Discord Bot** — @mention the bot in Discord, it spawns Claude Code to respond. Conversations happen in threads with full context preserved across messages.
|
|
12
|
+
|
|
13
|
+
**Claude Code Skill** — Teaches your assistant to use the bot to send messages, embeds, files, and interactive buttons. Installed automatically during setup. No MCP server needed.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Create a new Cord project
|
|
19
|
+
bunx create-cord my-bot
|
|
20
|
+
cd my-bot
|
|
21
|
+
|
|
22
|
+
# Start Redis (if not already running)
|
|
23
|
+
redis-server &
|
|
24
|
+
|
|
25
|
+
# Start Cord
|
|
26
|
+
cord start
|
|
18
27
|
```
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
<details>
|
|
30
|
+
<summary>Alternative: Clone from GitHub</summary>
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/alexknowshtml/cord.git my-bot
|
|
34
|
+
cd my-bot
|
|
35
|
+
bun install
|
|
36
|
+
cord setup
|
|
37
|
+
cord start
|
|
38
|
+
```
|
|
39
|
+
</details>
|
|
25
40
|
|
|
26
41
|
## Prerequisites
|
|
27
42
|
|
|
@@ -45,23 +60,19 @@ Discord Bot → BullMQ Queue → Claude Spawner
|
|
|
45
60
|
|
|
46
61
|
**Note:** This runs 100% locally. The bot connects *outbound* to Discord's gateway - no need to expose ports or use ngrok.
|
|
47
62
|
|
|
48
|
-
##
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
# Install dependencies
|
|
52
|
-
bun install
|
|
53
|
-
|
|
54
|
-
# Set environment variables
|
|
55
|
-
export DISCORD_BOT_TOKEN="your-bot-token"
|
|
56
|
-
|
|
57
|
-
# Start Redis (if not already running)
|
|
58
|
-
redis-server &
|
|
63
|
+
## Architecture
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
```
|
|
66
|
+
Discord Bot → BullMQ Queue → Claude Spawner
|
|
67
|
+
(Node.js) (Redis) (Bun)
|
|
63
68
|
```
|
|
64
69
|
|
|
70
|
+
- **Bot** (`src/bot.ts`): Catches @mentions, creates threads, sends to queue
|
|
71
|
+
- **Queue** (`src/queue.ts`): BullMQ job queue for reliable processing
|
|
72
|
+
- **Worker** (`src/worker.ts`): Pulls jobs, spawns Claude, posts responses
|
|
73
|
+
- **Spawner** (`src/spawner.ts`): The Claude CLI integration (the core)
|
|
74
|
+
- **DB** (`src/db.ts`): SQLite for thread→session mapping
|
|
75
|
+
|
|
65
76
|
## Environment Variables
|
|
66
77
|
|
|
67
78
|
| Variable | Required | Default | Description |
|
|
@@ -72,41 +83,31 @@ bun run src/worker.ts
|
|
|
72
83
|
| `CLAUDE_WORKING_DIR` | No | `cwd` | Working directory for Claude |
|
|
73
84
|
| `DB_PATH` | No | `./data/threads.db` | SQLite database path |
|
|
74
85
|
|
|
75
|
-
##
|
|
76
|
-
|
|
77
|
-
### New Mentions
|
|
86
|
+
## CLI Commands
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
2. Bot creates a thread from the message
|
|
81
|
-
3. Bot generates a UUID session ID
|
|
82
|
-
4. Bot stores thread_id → session_id in SQLite
|
|
83
|
-
5. Bot queues a job with the prompt and session ID
|
|
84
|
-
6. Worker picks up the job
|
|
85
|
-
7. Worker spawns Claude with `--session-id UUID`
|
|
86
|
-
8. Worker posts Claude's response to the thread
|
|
88
|
+
Once running, Cord provides CLI commands for interacting with Discord:
|
|
87
89
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
```bash
|
|
91
|
+
cord send <channel> "message" # Send a message
|
|
92
|
+
cord embed <channel> "text" --title "T" # Send formatted embed
|
|
93
|
+
cord file <channel> ./report.md # Send file attachment
|
|
94
|
+
cord buttons <channel> "Pick:" --button label="Yes" id="yes" style="success"
|
|
95
|
+
cord typing <channel> # Show typing indicator
|
|
96
|
+
cord edit <channel> <msgId> "new text" # Edit message
|
|
97
|
+
cord delete <channel> <msgId> # Delete message
|
|
98
|
+
cord reply <channel> <msgId> "reply" # Reply to message
|
|
99
|
+
cord react <channel> <msgId> "emoji" # Add reaction
|
|
100
|
+
cord thread <channel> <msgId> "name" # Create thread
|
|
101
|
+
cord rename <threadId> "new name" # Rename thread
|
|
102
|
+
```
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
See [skills/cord/SKILL.md](./skills/cord/SKILL.md) for full CLI documentation.
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
// For new sessions:
|
|
102
|
-
claude --print --session-id UUID -p "prompt"
|
|
106
|
+
## HTTP API
|
|
103
107
|
|
|
104
|
-
|
|
105
|
-
claude --print --resume UUID -p "prompt"
|
|
108
|
+
Cord also exposes an HTTP API on port 2643 for external scripts and webhooks.
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
claude --append-system-prompt "Current time: ..."
|
|
109
|
-
```
|
|
110
|
+
See [skills/cord/HTTP-API.md](./skills/cord/HTTP-API.md) for API documentation.
|
|
110
111
|
|
|
111
112
|
## License
|
|
112
113
|
|