social-agent-cli 4.4.0 → 5.0.0
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 +53 -184
- package/bin/social-agent.js +6 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,225 +1,94 @@
|
|
|
1
1
|
# social-agent-cli
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## How It Works
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
You: "like this tweet and retweet it: https://x.com/..."
|
|
9
|
-
|
|
10
|
-
1. [Planner] → Parses natural language command
|
|
11
|
-
2. [Knowledge] → Loads platform-specific knowledge (URLs, selectors, limits)
|
|
12
|
-
3. [Map Check] → Checks learned action maps
|
|
13
|
-
4. [Learn] → If missing, opens Chrome, takes screenshot + DOM, AI creates selector map
|
|
14
|
-
5. [Runner] → Executes steps sequentially
|
|
15
|
-
6. [Heal] → On failure: screenshots page, AI re-plans remaining steps (effort escalates)
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Features
|
|
19
|
-
|
|
20
|
-
- **Natural language commands** — `social-agent run x "like and retweet this tweet"`
|
|
21
|
-
- **Self-healing** — When selectors break, AI sees the screen and re-plans from where it left off
|
|
22
|
-
- **Learning** — Teach any action once, reuse forever. Maps are saved as JSON
|
|
23
|
-
- **Combination** — Chains multiple learned actions in a single command
|
|
24
|
-
- **Real Chrome profile** — Uses your actual Chrome profile via CDP. No bot detection
|
|
25
|
-
- **Zero hardcode** — No platform-specific selectors in code. Everything is AI-learned
|
|
26
|
-
- **Free API drivers** — Mastodon, Bluesky, Telegram via direct API (no browser needed)
|
|
27
|
-
- **Browser automation** — X, LinkedIn, Instagram, Facebook via Chrome
|
|
28
|
-
- **Post history** — Logs every action. AI matches your tone in future posts
|
|
29
|
-
- **Git hook** — Notifies you after `git push` to suggest social media posts
|
|
30
|
-
- **Claude Code integration** — `claude-social` mode + `/social` slash command
|
|
3
|
+
Social media automation that works like an API. Post to X and LinkedIn from the terminal or Claude Code.
|
|
31
4
|
|
|
32
5
|
## Install
|
|
33
6
|
|
|
34
7
|
```bash
|
|
35
8
|
npm install -g social-agent-cli
|
|
9
|
+
npm install -g agent-browser && agent-browser install
|
|
36
10
|
social-agent setup
|
|
37
11
|
```
|
|
38
12
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## Quick Start
|
|
13
|
+
## Post
|
|
42
14
|
|
|
43
15
|
```bash
|
|
44
|
-
#
|
|
45
|
-
social-agent
|
|
16
|
+
# Text post
|
|
17
|
+
social-agent run x --content "Hello world"
|
|
18
|
+
social-agent run linkedin --content "Hello world"
|
|
46
19
|
|
|
47
|
-
#
|
|
48
|
-
social-agent
|
|
49
|
-
social-agent
|
|
20
|
+
# With image
|
|
21
|
+
social-agent run x --content "Check this out" --image /path/to/image.jpg
|
|
22
|
+
social-agent run linkedin --content "New project" --image /path/to/image.jpg
|
|
50
23
|
|
|
51
|
-
#
|
|
52
|
-
social-agent
|
|
53
|
-
social-agent learn "learn to like tweets" x # learn liking
|
|
54
|
-
social-agent learn "learn to send connection request" linkedin
|
|
55
|
-
|
|
56
|
-
# 4. Use with natural language
|
|
57
|
-
social-agent run x "like this tweet: https://x.com/user/status/123"
|
|
58
|
-
social-agent run x "like and retweet: https://x.com/user/status/123"
|
|
59
|
-
social-agent run linkedin "send connection requests to 3 people"
|
|
60
|
-
social-agent post "New feature released!" --platforms mastodon,bluesky
|
|
24
|
+
# Mastodon (API)
|
|
25
|
+
social-agent post "Hello" --platforms mastodon --image /path/to/image.jpg
|
|
61
26
|
```
|
|
62
27
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
| Command | Description |
|
|
66
|
-
|---------|-------------|
|
|
67
|
-
| `social-agent setup` | First-time setup wizard |
|
|
68
|
-
| `social-agent login <platform>` | Select Chrome profile and verify login |
|
|
69
|
-
| `social-agent learn "<task>" <platform>` | AI learns a new action from the page |
|
|
70
|
-
| `social-agent run <platform> "<command>"` | Execute with natural language |
|
|
71
|
-
| `social-agent post "<text>" --platforms x,mastodon` | Post to platforms |
|
|
72
|
-
| `social-agent status` | Show connected platforms |
|
|
73
|
-
| `social-agent history` | Show action history |
|
|
74
|
-
|
|
75
|
-
## Supported Platforms
|
|
76
|
-
|
|
77
|
-
### API-based (free, no browser needed)
|
|
78
|
-
| Platform | Auth | Features |
|
|
79
|
-
|----------|------|----------|
|
|
80
|
-
| **Mastodon** | Access token | Post, media upload, like, boost, follow |
|
|
81
|
-
| **Bluesky** | App password | Post, media, like, repost, follow |
|
|
82
|
-
| **Telegram** | Bot token | Send messages, photos, videos to channels |
|
|
83
|
-
|
|
84
|
-
### Browser-based (Chrome automation)
|
|
85
|
-
| Platform | Method | Notes |
|
|
86
|
-
|----------|--------|-------|
|
|
87
|
-
| **X (Twitter)** | CDP + real Chrome | Free tier friendly, no API costs |
|
|
88
|
-
| **LinkedIn** | CDP + real Chrome | Connection requests, posts, reactions |
|
|
89
|
-
| **Instagram** | CDP + real Chrome | Aggressive anti-bot, use with caution |
|
|
90
|
-
| **Facebook** | CDP + real Chrome | Checkpoint system, careful usage |
|
|
91
|
-
|
|
92
|
-
## Self-Healing
|
|
93
|
-
|
|
94
|
-
When a step fails, AI doesn't just retry — it **sees the screen and re-plans**:
|
|
28
|
+
## How It Works
|
|
95
29
|
|
|
96
30
|
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Step 6 (new): Scroll down ✓
|
|
103
|
-
Step 7 (new): Click post button ✓
|
|
31
|
+
1. Cached CSS selector (instant)
|
|
32
|
+
↓ broken?
|
|
33
|
+
2. ARIA snapshot + ref match (ms)
|
|
34
|
+
↓ not found?
|
|
35
|
+
3. Claude AI finds the right element (5-15s)
|
|
104
36
|
```
|
|
105
37
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
## Selector Maps
|
|
109
|
-
|
|
110
|
-
Learned actions are saved as JSON in `~/.social-agent/maps/`:
|
|
111
|
-
|
|
112
|
-
```json
|
|
113
|
-
{
|
|
114
|
-
"platform": "x",
|
|
115
|
-
"action": "like_tweet",
|
|
116
|
-
"parameters": ["{{TWEET_URL}}"],
|
|
117
|
-
"steps": [
|
|
118
|
-
{ "action": "goto", "url": "{{TWEET_URL}}" },
|
|
119
|
-
{ "action": "wait", "waitMs": 2000 },
|
|
120
|
-
{ "action": "click", "selector": "[data-testid='like']",
|
|
121
|
-
"fallbackSelectors": ["[aria-label*='Like']"] },
|
|
122
|
-
{ "action": "wait", "waitMs": 1000 }
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
```
|
|
38
|
+
Uses [agent-browser](https://github.com/vercel-labs/agent-browser) (Rust) for fast browser automation via CDP, connected to your real Chrome profile. No bot detection.
|
|
126
39
|
|
|
127
|
-
##
|
|
40
|
+
## Claude Code Integration
|
|
128
41
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
-
|
|
133
|
-
-
|
|
134
|
-
|
|
42
|
+
```
|
|
43
|
+
/social Create post from current work context
|
|
44
|
+
/social-suggest on Enable post suggestions at milestones
|
|
45
|
+
/social-suggest off Disable suggestions
|
|
46
|
+
/social-suggest-level 3 Set sensitivity (0=off, 5=max)
|
|
47
|
+
```
|
|
135
48
|
|
|
136
|
-
|
|
49
|
+
When suggestions are on, Claude notices milestones in your work and asks: "This is worth sharing. Want to create a post?"
|
|
137
50
|
|
|
138
|
-
|
|
139
|
-
Run Claude with social media awareness. It suggests posts at milestones:
|
|
51
|
+
## Setup
|
|
140
52
|
|
|
141
53
|
```bash
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
#
|
|
145
|
-
|
|
54
|
+
social-agent setup # Name, language, style, platform logins
|
|
55
|
+
social-agent login x # Select Chrome profile for X
|
|
56
|
+
social-agent login linkedin # Select Chrome profile for LinkedIn
|
|
57
|
+
social-agent status # Show connected platforms
|
|
58
|
+
social-agent config # Show config file paths
|
|
59
|
+
social-agent history # Show post history
|
|
146
60
|
```
|
|
147
61
|
|
|
148
|
-
|
|
149
|
-
Creates a post from your current work context:
|
|
150
|
-
1. Analyzes conversation history + git log + project info
|
|
151
|
-
2. Reads post history for tone matching
|
|
152
|
-
3. Asks which platforms
|
|
153
|
-
4. Generates platform-optimized content
|
|
154
|
-
5. Creates image (optional, platform-sized)
|
|
155
|
-
6. Posts in background after approval
|
|
156
|
-
|
|
157
|
-
## Data Directory
|
|
158
|
-
|
|
159
|
-
Everything lives in `~/.social-agent/`:
|
|
62
|
+
## Architecture
|
|
160
63
|
|
|
161
64
|
```
|
|
162
65
|
~/.social-agent/
|
|
163
|
-
├── config.json # API keys
|
|
164
|
-
├── social-mode-prompt.md # AI
|
|
165
|
-
├── profile-map.json # Platform → Chrome profile
|
|
166
|
-
├── history.json #
|
|
167
|
-
├──
|
|
168
|
-
│ ├── x.
|
|
169
|
-
│
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
│ ├── bluesky.md # Bluesky: AT Protocol API
|
|
174
|
-
│ └── telegram.md # Telegram: Bot API
|
|
175
|
-
├── maps/ # Learned action maps (JSON)
|
|
176
|
-
├── profiles/ # Chrome CDP working directory
|
|
177
|
-
└── screenshots/ # AI analysis screenshots
|
|
66
|
+
├── config.json # API keys (Mastodon)
|
|
67
|
+
├── social-mode-prompt.md # AI personality (editable)
|
|
68
|
+
├── profile-map.json # Platform → Chrome profile
|
|
69
|
+
├── history.json # Post log
|
|
70
|
+
├── maps/
|
|
71
|
+
│ ├── x.json # X post steps + cached selectors
|
|
72
|
+
│ └── linkedin.json # LinkedIn post steps + cached selectors
|
|
73
|
+
├── knowledge/ # Platform knowledge (X, LinkedIn, Mastodon)
|
|
74
|
+
├── profiles/chrome-cdp/ # Chrome CDP session data
|
|
75
|
+
└── screenshots/ # Debug screenshots
|
|
178
76
|
```
|
|
179
77
|
|
|
180
|
-
##
|
|
181
|
-
|
|
182
|
-
No code changes needed:
|
|
183
|
-
|
|
184
|
-
1. Add URL to `BROWSER_PLATFORMS` in `cli.ts`
|
|
185
|
-
2. Create `knowledge/platform.md`
|
|
186
|
-
3. `social-agent login platform`
|
|
187
|
-
4. `social-agent learn platform`
|
|
188
|
-
5. `social-agent run platform "do something"`
|
|
189
|
-
|
|
190
|
-
## Architecture
|
|
78
|
+
## Supported Platforms
|
|
191
79
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
├── core/
|
|
198
|
-
│ ├── config.ts # Config & paths (~/.social-agent/)
|
|
199
|
-
│ ├── types.ts # TypeScript interfaces
|
|
200
|
-
│ ├── profiles.ts # Chrome profile discovery & selection
|
|
201
|
-
│ ├── history.ts # Action logging
|
|
202
|
-
│ └── screenshot.ts # HTML → JPEG converter
|
|
203
|
-
├── ai/
|
|
204
|
-
│ ├── mapper.ts # Claude -p: create/heal selector maps
|
|
205
|
-
│ ├── planner.ts # Natural language → execution plan
|
|
206
|
-
│ ├── runner.ts # Execute plan with heal-on-failure
|
|
207
|
-
│ └── knowledge.ts # Platform knowledge reader
|
|
208
|
-
├── platforms/
|
|
209
|
-
│ ├── mastodon.ts # Mastodon API driver
|
|
210
|
-
│ ├── bluesky.ts # Bluesky AT Protocol driver
|
|
211
|
-
│ └── browser/
|
|
212
|
-
│ └── driver.ts # Playwright + Chrome CDP + anti-detection
|
|
213
|
-
├── knowledge/ # Platform knowledge (7 platforms, 7000+ lines)
|
|
214
|
-
└── hooks/
|
|
215
|
-
└── post-push # Git hook for post suggestions
|
|
216
|
-
```
|
|
80
|
+
| Platform | Method | Text | Image |
|
|
81
|
+
|----------|--------|------|-------|
|
|
82
|
+
| X | Browser (CDP) | ✓ | ✓ |
|
|
83
|
+
| LinkedIn | Browser (CDP) | ✓ | ✓ |
|
|
84
|
+
| Mastodon | API | ✓ | ✓ |
|
|
217
85
|
|
|
218
86
|
## Requirements
|
|
219
87
|
|
|
220
88
|
- Node.js 18+
|
|
221
|
-
- Google Chrome (macOS
|
|
222
|
-
- [
|
|
89
|
+
- Google Chrome (macOS)
|
|
90
|
+
- [agent-browser](https://github.com/vercel-labs/agent-browser)
|
|
91
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (for /social commands)
|
|
223
92
|
|
|
224
93
|
## License
|
|
225
94
|
|
package/bin/social-agent.js
CHANGED
|
@@ -106,24 +106,20 @@ switch (command) {
|
|
|
106
106
|
Setup:
|
|
107
107
|
social-agent setup First-time setup
|
|
108
108
|
social-agent login <platform> Chrome profile select (x, linkedin)
|
|
109
|
-
social-agent config Show config
|
|
109
|
+
social-agent config Show config paths
|
|
110
110
|
|
|
111
111
|
Post:
|
|
112
|
-
social-agent run x "
|
|
113
|
-
social-agent run x "
|
|
114
|
-
social-agent run linkedin "
|
|
115
|
-
social-agent
|
|
116
|
-
|
|
117
|
-
Actions:
|
|
118
|
-
social-agent run x "like this: https://x.com/..."
|
|
119
|
-
social-agent run x "like and retweet: https://x.com/..."
|
|
112
|
+
social-agent run x --content "Hello world"
|
|
113
|
+
social-agent run x --content "Hello" --image /path/to/img.jpg
|
|
114
|
+
social-agent run linkedin --content "Hello"
|
|
115
|
+
social-agent run linkedin --content "Hello" --image /path/to/img.jpg
|
|
116
|
+
social-agent post "text" --platforms mastodon --image /path/to/img.jpg
|
|
120
117
|
|
|
121
118
|
Info:
|
|
122
119
|
social-agent status Connected platforms
|
|
123
120
|
social-agent history Action log
|
|
124
121
|
|
|
125
122
|
Claude Code:
|
|
126
|
-
claude-social Social-aware mode
|
|
127
123
|
/social Create post from work context
|
|
128
124
|
/social-suggest on|off Toggle suggestions
|
|
129
125
|
/social-suggest-level 0-5 Sensitivity (0=off, 3=balanced)
|