afk-code 0.1.1 → 0.1.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Colin Harman
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 CHANGED
@@ -1,129 +1,100 @@
1
1
  # AFK Code
2
2
 
3
- Monitor your Claude Code sessions from Slack or Discord. Get notified when Claude needs input, and respond without leaving your chat app.
3
+ Monitor and interact with Claude Code sessions from Slack or Discord. Respond from your phone while AFK.
4
4
 
5
- ## How it works
6
-
7
- 1. Run `afk-code slack` or `afk-code discord` to start the bot
8
- 2. Run `afk-code run -- claude` to start a monitored Claude Code session
9
- 3. A new thread (Slack) or channel (Discord) is created for the session
10
- 4. All messages are relayed bidirectionally - respond from your phone while AFK
11
-
12
- ## Installation
5
+ ## Quick Start (Slack)
13
6
 
14
7
  ```bash
15
- # Install globally via npm
16
- npm install -g afk-code
17
-
18
- # Or run directly with npx
19
- npx afk-code help
20
- ```
21
-
22
- Requires Node.js 18+.
23
-
24
- ## Slack Setup
25
-
26
- ### 1. Create a Slack App
27
-
28
- Go to [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App** → **From manifest**.
29
-
30
- Paste the contents of `slack-manifest.json` from this repo, then click **Create**.
31
-
32
- ### 2. Install to Workspace
8
+ # 1. Create a Slack app at https://api.slack.com/apps
9
+ # Click "Create New App" → "From manifest" → paste slack-manifest.json
33
10
 
34
- Click **Install to Workspace** and authorize the app.
11
+ # 2. Install to your workspace and get credentials:
12
+ # - Bot Token (xoxb-...) from OAuth & Permissions
13
+ # - App Token (xapp-...) from Basic Information → App-Level Tokens (needs connections:write)
14
+ # - Your User ID from your Slack profile → "..." → Copy member ID
35
15
 
36
- ### 3. Get Your Credentials
16
+ # 3. Configure and run
17
+ npx afk-code slack setup # Enter your credentials
18
+ npx afk-code slack # Start the bot
37
19
 
38
- - **Bot Token**: OAuth & Permissions Bot User OAuth Token (`xoxb-...`)
39
- - **App Token**: Basic Information → App-Level Tokens Generate Token with `connections:write` scope (`xapp-...`)
40
- - **Signing Secret**: Basic Information → Signing Secret
41
- - **Your User ID**: In Slack, click your profile → three dots → Copy member ID
42
-
43
- ### 4. Configure AFK Code
44
-
45
- ```bash
46
- afk-code slack setup
20
+ # 4. In another terminal, start a monitored Claude session
21
+ npx afk-code run -- claude
47
22
  ```
48
23
 
49
- Follow the prompts to enter your credentials. Config is saved to `~/.afk-code/slack.env`.
24
+ A new channel is created for each session. Messages relay bidirectionally.
50
25
 
51
- ### 5. Run
26
+ ## Quick Start (Discord)
52
27
 
53
28
  ```bash
54
- # Terminal 1: Start the Slack bot
55
- afk-code slack
56
-
57
- # Terminal 2: Start a Claude Code session
58
- afk-code run -- claude
59
- ```
60
-
61
- A new thread will appear in your Slack channel for each session.
29
+ # 1. Create a Discord app at https://discord.com/developers/applications
30
+ # - Go to Bot → Reset Token → copy it
31
+ # - Enable "Message Content Intent"
32
+ # - Go to OAuth2 URL Generator → select "bot" scope
33
+ # - Select permissions: Send Messages, Manage Channels, Read Message History
34
+ # - Open the generated URL to invite the bot
62
35
 
63
- ## Discord Setup
36
+ # 2. Get your User ID (enable Developer Mode, right-click your name → Copy User ID)
64
37
 
65
- ### 1. Create a Discord Application
38
+ # 3. Configure and run
39
+ npx afk-code discord setup # Enter your credentials
40
+ npx afk-code discord # Start the bot
66
41
 
67
- Go to [discord.com/developers/applications](https://discord.com/developers/applications) and click **New Application**.
68
-
69
- ### 2. Create a Bot
70
-
71
- - Go to **Bot** in the sidebar
72
- - Click **Reset Token** and copy it
73
- - Enable **Message Content Intent** under Privileged Gateway Intents
42
+ # 4. In another terminal, start a monitored Claude session
43
+ npx afk-code run -- claude
44
+ ```
74
45
 
75
- ### 3. Invite the Bot
46
+ ## Commands
76
47
 
77
- - Go to **OAuth2** → **URL Generator**
78
- - Select scopes: `bot`
79
- - Select permissions: `Send Messages`, `Manage Channels`, `Read Message History`
80
- - Open the generated URL to invite the bot to your server
48
+ ```
49
+ afk-code slack setup Configure Slack credentials
50
+ afk-code slack Run the Slack bot
51
+ afk-code discord setup Configure Discord credentials
52
+ afk-code discord Run the Discord bot
53
+ afk-code run -- <command> Start a monitored session
54
+ afk-code help Show help
55
+ ```
81
56
 
82
- ### 4. Get Your User ID
57
+ ### Slack Slash Commands
83
58
 
84
- Enable Developer Mode in Discord settings, then right-click your name → **Copy User ID**.
59
+ - `/afk` - List active sessions
60
+ - `/background` - Send Ctrl+B (background signal)
61
+ - `/interrupt` - Send Escape (interrupt signal)
62
+ - `/mode` - Send Shift+Tab (toggle mode)
63
+ - Not recommended since you don't get feedback on what mode you're in
85
64
 
86
- ### 5. Configure AFK Code
65
+ ## Installation Options
87
66
 
88
67
  ```bash
89
- afk-code discord setup
90
- ```
91
-
92
- Enter your bot token and user ID. Config is saved to `~/.afk-code/discord.env`.
93
-
94
- ### 6. Run
68
+ # Global install
69
+ npm install -g afk-code
95
70
 
96
- ```bash
97
- # Terminal 1: Start the Discord bot
98
- afk-code discord
71
+ # Or use npx (no install)
72
+ npx afk-code <command>
99
73
 
100
- # Terminal 2: Start a Claude Code session
101
- afk-code run -- claude
74
+ # Or run from source
75
+ git clone https://github.com/clharman/afk-code.git
76
+ cd afk-code && npm install
77
+ npm run dev -- slack
78
+ npm run dev -- run -- claude
102
79
  ```
103
80
 
104
- An "AFK Code Sessions" category will be created with a channel for each session.
81
+ Requires Node.js 18+.
105
82
 
106
- ## Commands
83
+ ## How It Works
107
84
 
108
- ```
109
- afk-code run -- <command> Start a monitored session (e.g., afk-code run -- claude)
110
- afk-code slack Run the Slack bot
111
- afk-code slack setup Configure Slack credentials
112
- afk-code discord Run the Discord bot
113
- afk-code discord setup Configure Discord credentials
114
- afk-code help Show help
115
- ```
85
+ 1. `afk-code slack` or `afk-code discord` starts a bot that listens for sessions
86
+ 2. `afk-code run -- claude` spawns Claude in a PTY and connects to the bot via Unix socket
87
+ 3. The bot watches Claude's JSONL files for messages and relays them to chat
88
+ 4. Messages you send in chat are forwarded to the terminal
116
89
 
117
- ## How It Works
90
+ ## Limitations
118
91
 
119
- AFK Code watches Claude Code's JSONL output files to capture messages in real-time. When you start a session with `afk-code run`, it:
92
+ - Does not support plan mode or responding to Claude Code's form-based questions (AskUserQuestion)
93
+ - Does not send tool calls or results
120
94
 
121
- 1. Spawns the command in a PTY (pseudo-terminal)
122
- 2. Connects to the running Slack/Discord bot via Unix socket
123
- 3. Watches the Claude Code JSONL file for new messages
124
- 4. Relays messages bidirectionally between terminal and chat
95
+ ## Disclaimer
125
96
 
126
- Messages you send in Slack/Discord threads are forwarded to the terminal as if you typed them.
97
+ This project is not affiliated with Anthropic. Use at your own risk.
127
98
 
128
99
  ## License
129
100
 
package/dist/cli/index.js CHANGED
@@ -1573,7 +1573,9 @@ async function run(command2) {
1573
1573
  if (process.stdin.isTTY) {
1574
1574
  process.stdin.setRawMode(false);
1575
1575
  }
1576
- process.stdin.unref();
1576
+ if (typeof process.stdin.unref === "function") {
1577
+ process.stdin.unref();
1578
+ }
1577
1579
  daemon?.close();
1578
1580
  resolve2();
1579
1581
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "afk-code",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Monitor and interact with Claude Code sessions from Slack/Discord",
5
5
  "author": "Colin Harman",
6
6
  "repository": {
@@ -14,7 +14,8 @@
14
14
  "scripts": {
15
15
  "build": "tsup",
16
16
  "dev": "tsx src/cli/index.ts",
17
- "prepublishOnly": "npm run build"
17
+ "prepublishOnly": "npm run build",
18
+ "postinstall": "node -e \"const fs = require('fs'); const path = require('path'); const dir = path.dirname(path.dirname(require.resolve('node-pty'))); const prebuilds = path.join(dir, 'prebuilds'); if (fs.existsSync(prebuilds)) { fs.readdirSync(prebuilds).forEach(p => { const helper = path.join(prebuilds, p, 'spawn-helper'); if (fs.existsSync(helper)) fs.chmodSync(helper, 0o755); }); }\""
18
19
  },
19
20
  "files": [
20
21
  "dist",