social-agent-cli 4.5.0 → 5.0.1

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
@@ -1,225 +1,94 @@
1
1
  # social-agent-cli
2
2
 
3
- AI-powered social media automation tool with self-healing browser automation. Teach it any action on any platform it learns, adapts, and recovers from errors automatically.
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
- The setup wizard asks your name, social handles, API tokens, and configures everything — Chrome profile selection, git hooks, shell aliases.
40
-
41
- ## Quick Start
13
+ ## Post
42
14
 
43
15
  ```bash
44
- # 1. First-time setup
45
- social-agent setup
16
+ # Text post
17
+ social-agent run x --content "Hello world"
18
+ social-agent run linkedin --content "Hello world"
46
19
 
47
- # 2. Login to browser platforms (one-time)
48
- social-agent login x
49
- social-agent login linkedin
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
- # 3. Teach actions
52
- social-agent learn x # learn to post (default)
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
- ## Commands
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
- Step 6: Click "Post" button ✗
98
- [heal] AI analyzing screen (effort: low)...
99
- "Post button is inside a scrollable container, need to scroll first"
100
- New plan: scroll down + click with updated selector
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
- Effort escalates on repeated failures: `low medium medium`
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
- ## Chrome Integration
40
+ ## Claude Code Integration
128
41
 
129
- - **CDP (Chrome DevTools Protocol)** connection
130
- - Chrome open connects to existing instance, opens new tab
131
- - Chrome closed launches with your selected profile
132
- - Only closes the tab, **never kills Chrome**
133
- - `navigator.webdriver = false` to avoid detection
134
- - `--enable-automation` flag removed
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
- ## Claude Code Integration
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
- ### `claude-social` mode
139
- Run Claude with social media awareness. It suggests posts at milestones:
51
+ ## Setup
140
52
 
141
53
  ```bash
142
- claude-social
143
-
144
- # While working...
145
- # AI: "This feature is worth sharing. Type /social to create a post."
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
- ### `/social` slash command
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 and settings
164
- ├── social-mode-prompt.md # AI assistant personality (editable)
165
- ├── profile-map.json # Platform → Chrome profile mapping
166
- ├── history.json # Action log
167
- ├── knowledge/ # Platform knowledge files
168
- │ ├── x.md # X/Twitter: selectors, URLs, limits
169
- ├── linkedin.md # LinkedIn: aria-labels, anti-bot
170
- ├── instagram.md # Instagram: aggressive anti-bot docs
171
- ├── facebook.md # Facebook: checkpoint system
172
- │ ├── mastodon.md # Mastodon: full API reference
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
- ## Adding New Platforms
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
- social-agent/
194
- ├── bin/social-agent.js # Global CLI entry point
195
- ├── cli.ts # Command router
196
- ├── install.ts # Setup wizard
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 — Linux/Windows support planned)
222
- - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) (`npm install -g @anthropic-ai/claude-code`)
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
 
@@ -73,6 +73,51 @@ switch (command) {
73
73
  break;
74
74
  }
75
75
 
76
+ case "reset": {
77
+ console.log("\n Sıfırlama başlatılıyor...\n");
78
+ const { execSync: ex, spawnSync: sp } = await import("node:child_process");
79
+ const { rmSync: rm } = await import("node:fs");
80
+
81
+ // 1. Eski data sil
82
+ try { rm(DATA_DIR, { recursive: true, force: true }); console.log(" ✓ ~/.social-agent/ silindi"); } catch {}
83
+
84
+ // 2. Eski commands sil
85
+ const cmdsDir = join(homedir(), ".claude", "commands");
86
+ for (const f of ["social.md", "social-suggest.md", "social-suggest-level.md"]) {
87
+ try { rm(join(cmdsDir, f), { force: true }); } catch {}
88
+ }
89
+ console.log(" ✓ Eski /social komutları silindi");
90
+
91
+ // 3. zshrc/bashrc'den claude-social alias sil
92
+ const shell = process.env.SHELL?.includes("zsh") ? ".zshrc" : ".bashrc";
93
+ const rcPath = join(homedir(), shell);
94
+ try {
95
+ const rc = readFileSync(rcPath, "utf-8");
96
+ const cleaned = rc.split("\n").filter(l => !l.includes("claude-social") && !l.includes("# Social Agent")).join("\n");
97
+ const { writeFileSync: wf } = await import("node:fs");
98
+ wf(rcPath, cleaned);
99
+ console.log(` ✓ ${shell}'den claude-social kaldırıldı`);
100
+ } catch {}
101
+
102
+ // 4. CLAUDE.md'lerden social block sil
103
+ try {
104
+ const { readdirSync: rd } = await import("node:fs");
105
+ // Mevcut dizindeki CLAUDE.md
106
+ try {
107
+ const cmd = readFileSync("CLAUDE.md", "utf-8");
108
+ if (cmd.includes("SOCIAL-AGENT-START")) {
109
+ const cleaned = cmd.replace(/<!-- SOCIAL-AGENT-START -->[\s\S]*?<!-- SOCIAL-AGENT-END -->/g, "").trim();
110
+ const { writeFileSync: wf } = await import("node:fs");
111
+ if (cleaned) wf("CLAUDE.md", cleaned + "\n"); else rm("CLAUDE.md", { force: true });
112
+ console.log(" ✓ CLAUDE.md temizlendi");
113
+ }
114
+ } catch {}
115
+ } catch {}
116
+
117
+ console.log("\n ✓ Sıfırlama tamamlandı. Şimdi: social-agent setup\n");
118
+ break;
119
+ }
120
+
76
121
  case "screenshot": {
77
122
  // social-agent screenshot /tmp/input.html /tmp/output.jpeg 1200 675
78
123
  run("core/screenshot.ts", args);
@@ -105,25 +150,22 @@ switch (command) {
105
150
 
106
151
  Setup:
107
152
  social-agent setup First-time setup
153
+ social-agent reset Remove all data and start fresh
108
154
  social-agent login <platform> Chrome profile select (x, linkedin)
109
- social-agent config Show config file paths
155
+ social-agent config Show config paths
110
156
 
111
157
  Post:
112
- social-agent run x "post this: Hello world"
113
- social-agent run x "post with image: msg, image: /path/to/img.jpg"
114
- social-agent run linkedin "share this post: Hello"
115
- social-agent post "text" --platforms mastodon
116
-
117
- Actions:
118
- social-agent run x "like this: https://x.com/..."
119
- social-agent run x "like and retweet: https://x.com/..."
158
+ social-agent run x --content "Hello world"
159
+ social-agent run x --content "Hello" --image /path/to/img.jpg
160
+ social-agent run linkedin --content "Hello"
161
+ social-agent run linkedin --content "Hello" --image /path/to/img.jpg
162
+ social-agent post "text" --platforms mastodon --image /path/to/img.jpg
120
163
 
121
164
  Info:
122
165
  social-agent status Connected platforms
123
166
  social-agent history Action log
124
167
 
125
168
  Claude Code:
126
- claude-social Social-aware mode
127
169
  /social Create post from work context
128
170
  /social-suggest on|off Toggle suggestions
129
171
  /social-suggest-level 0-5 Sensitivity (0=off, 3=balanced)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "social-agent-cli",
3
- "version": "4.5.0",
3
+ "version": "5.0.1",
4
4
  "description": "AI-powered social media agent - free APIs + browser automation with self-healing selectors",
5
5
  "type": "module",
6
6
  "bin": {