afk-code 0.1.0 → 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,133 +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
- # Clone the repo
16
- git clone https://github.com/clharman/afk-code.git
17
- cd afk-code
18
-
19
- # Install dependencies
20
- bun install
21
-
22
- # Link the CLI globally (optional)
23
- bun link
24
- ```
25
-
26
- Requires [Bun](https://bun.sh) runtime.
27
-
28
- ## Slack Setup
29
-
30
- ### 1. Create a Slack App
31
-
32
- Go to [api.slack.com/apps](https://api.slack.com/apps) and click **Create New App** → **From manifest**.
33
-
34
- Paste the contents of `slack-manifest.json` from this repo, then click **Create**.
8
+ # 1. Create a Slack app at https://api.slack.com/apps
9
+ # Click "Create New App" → "From manifest" → paste slack-manifest.json
35
10
 
36
- ### 2. Install to Workspace
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
37
15
 
38
- Click **Install to Workspace** and authorize the app.
16
+ # 3. Configure and run
17
+ npx afk-code slack setup # Enter your credentials
18
+ npx afk-code slack # Start the bot
39
19
 
40
- ### 3. Get Your Credentials
41
-
42
- - **Bot Token**: OAuth & Permissions → Bot User OAuth Token (`xoxb-...`)
43
- - **App Token**: Basic Information → App-Level Tokens → Generate Token with `connections:write` scope (`xapp-...`)
44
- - **Signing Secret**: Basic Information → Signing Secret
45
- - **Your User ID**: In Slack, click your profile → three dots → Copy member ID
46
-
47
- ### 4. Configure AFK Code
48
-
49
- ```bash
50
- afk-code slack setup
20
+ # 4. In another terminal, start a monitored Claude session
21
+ npx afk-code run -- claude
51
22
  ```
52
23
 
53
- 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.
54
25
 
55
- ### 5. Run
26
+ ## Quick Start (Discord)
56
27
 
57
28
  ```bash
58
- # Terminal 1: Start the Slack bot
59
- afk-code slack
60
-
61
- # Terminal 2: Start a Claude Code session
62
- afk-code run -- claude
63
- ```
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
64
35
 
65
- A new thread will appear in your Slack channel for each session.
36
+ # 2. Get your User ID (enable Developer Mode, right-click your name Copy User ID)
66
37
 
67
- ## Discord Setup
38
+ # 3. Configure and run
39
+ npx afk-code discord setup # Enter your credentials
40
+ npx afk-code discord # Start the bot
68
41
 
69
- ### 1. Create a Discord Application
70
-
71
- Go to [discord.com/developers/applications](https://discord.com/developers/applications) and click **New Application**.
72
-
73
- ### 2. Create a Bot
74
-
75
- - Go to **Bot** in the sidebar
76
- - Click **Reset Token** and copy it
77
- - 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
+ ```
78
45
 
79
- ### 3. Invite the Bot
46
+ ## Commands
80
47
 
81
- - Go to **OAuth2** → **URL Generator**
82
- - Select scopes: `bot`
83
- - Select permissions: `Send Messages`, `Manage Channels`, `Read Message History`
84
- - 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
+ ```
85
56
 
86
- ### 4. Get Your User ID
57
+ ### Slack Slash Commands
87
58
 
88
- 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
89
64
 
90
- ### 5. Configure AFK Code
65
+ ## Installation Options
91
66
 
92
67
  ```bash
93
- afk-code discord setup
94
- ```
95
-
96
- Enter your bot token and user ID. Config is saved to `~/.afk-code/discord.env`.
68
+ # Global install
69
+ npm install -g afk-code
97
70
 
98
- ### 6. Run
99
-
100
- ```bash
101
- # Terminal 1: Start the Discord bot
102
- afk-code discord
71
+ # Or use npx (no install)
72
+ npx afk-code <command>
103
73
 
104
- # Terminal 2: Start a Claude Code session
105
- 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
106
79
  ```
107
80
 
108
- An "AFK Code Sessions" category will be created with a channel for each session.
81
+ Requires Node.js 18+.
109
82
 
110
- ## Commands
83
+ ## How It Works
111
84
 
112
- ```
113
- afk-code run -- <command> Start a monitored session (e.g., afk-code run -- claude)
114
- afk-code slack Run the Slack bot
115
- afk-code slack setup Configure Slack credentials
116
- afk-code discord Run the Discord bot
117
- afk-code discord setup Configure Discord credentials
118
- afk-code help Show help
119
- ```
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
120
89
 
121
- ## How It Works
90
+ ## Limitations
122
91
 
123
- 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
124
94
 
125
- 1. Spawns the command in a PTY (pseudo-terminal)
126
- 2. Connects to the running Slack/Discord bot via Unix socket
127
- 3. Watches the Claude Code JSONL file for new messages
128
- 4. Relays messages bidirectionally between terminal and chat
95
+ ## Disclaimer
129
96
 
130
- 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.
131
98
 
132
99
  ## License
133
100