x-collect-skill 2.0.0 → 2.1.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 CHANGED
@@ -46,6 +46,8 @@ Output: JSONL + Markdown in `./x-collect-data/` with real handles, tweet text, l
46
46
 
47
47
  ### Setup Actionbook Extension
48
48
 
49
+ Follow the official guide: **[Actionbook Installation](https://actionbook.dev/docs/guides/installation)**
50
+
49
51
  ```bash
50
52
  actionbook extension install # install extension files
51
53
  # Then load unpacked extension in Chrome (chrome://extensions)
package/README.zh-CN.md CHANGED
@@ -46,6 +46,8 @@ X/Twitter 话题情报采集工具,Claude Code 专用 Skill。通过 Actionboo
46
46
 
47
47
  ### 安装 Actionbook 扩展
48
48
 
49
+ 请先按照官方指南完成安装:**[Actionbook 安装指南](https://actionbook.dev/docs/guides/installation)**
50
+
49
51
  ```bash
50
52
  actionbook extension install # 安装扩展文件
51
53
  # 然后在 Chrome 中加载未打包扩展 (chrome://extensions)
package/SKILL.md CHANGED
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: x-collect
3
3
  description: |
4
- X/Twitter topic intelligence tool. Uses Actionbook browser automation to search
5
- x.com directly, scraping real tweets, engagement metrics, and KOL accounts.
4
+ X/Twitter topic intelligence tool. Two search modes: Grok (quick AI-powered search)
5
+ and Actionbook DOM scraping (detailed multi-round collection with search operators).
6
6
  Outputs a structured intel report (JSONL + Markdown) with content opportunity analysis.
7
7
  Use when the user wants to research a topic on X/Twitter, find what's performing,
8
8
  or scout trending discussions before creating content.
@@ -19,14 +19,14 @@ allowed-tools:
19
19
 
20
20
  # X Topic Intelligence
21
21
 
22
- Research what's trending and performing on X/Twitter for any topic. Browse x.com directly via Actionbook Extension mode (controlling the user's logged-in Chrome) to find real tweets, engagement data, and KOL accounts.
22
+ Research what's trending and performing on X/Twitter for any topic. Two search backends available pick based on the task complexity.
23
23
 
24
24
  ---
25
25
 
26
26
  ## Usage
27
27
 
28
28
  ```
29
- /x-collect [topic] # direct mode
29
+ /x-collect [topic] # auto-select mode based on topic complexity
30
30
  /x-collect # interactive mode - asks for topic
31
31
  ```
32
32
 
@@ -35,6 +35,36 @@ When no topic is provided, use `AskUserQuestion`:
35
35
 
36
36
  ---
37
37
 
38
+ ## Search Mode Selection
39
+
40
+ | | Grok Mode (quick) | Actionbook Scrape Mode (full) |
41
+ |---|---|---|
42
+ | **Speed** | ~60s single query | ~5-10 min multi-round |
43
+ | **Best for** | Quick overview, trend check, "what's hot" | Systematic collection, precise metrics, dataset building |
44
+ | **Data quality** | AI-summarized, may miss some posts | Raw DOM data, exact engagement numbers, includes views |
45
+ | **Search operators** | No (natural language only) | Yes (`min_faves:`, `filter:blue_verified`, date ranges, etc.) |
46
+ | **Output** | 5-15 posts per query | 10-15 posts per round, 3-5 rounds |
47
+ | **Views count** | Not available | Available |
48
+
49
+ ### Auto-selection rules
50
+
51
+ Use **Grok Mode** when:
52
+ - User asks a simple question ("what's trending about X?", "find popular posts about Y")
53
+ - Quick exploration / first look at a topic
54
+ - Single broad query is sufficient
55
+ - User explicitly says "quick" or "fast"
56
+
57
+ Use **Actionbook Scrape Mode** when:
58
+ - User wants systematic multi-round collection (viral + trending + KOL + hook study)
59
+ - Need precise engagement thresholds (`min_faves:100`, `filter:blue_verified`)
60
+ - Need views count
61
+ - Building a JSONL dataset for later analysis
62
+ - User explicitly says "detailed", "full", or "all rounds"
63
+
64
+ > When unsure, default to **Grok Mode** — it's faster and sufficient for most requests. Escalate to Actionbook Scrape if Grok results are insufficient or user asks for more.
65
+
66
+ ---
67
+
38
68
  ## Prerequisites
39
69
 
40
70
  | Dependency | Purpose | Required |
@@ -43,6 +73,7 @@ When no topic is provided, use `AskUserQuestion`:
43
73
  | Actionbook CLI | Browser automation (`actionbook` command) | Yes |
44
74
  | Actionbook Extension | Chrome extension + bridge for controlling user's browser | Yes |
45
75
  | Logged-in X/Twitter session | User's Chrome must have an active x.com session | Yes |
76
+ | X Premium (for Grok) | Grok search requires Premium subscription | Only for Grok Mode |
46
77
 
47
78
  ### Pre-flight Check
48
79
 
@@ -57,9 +88,99 @@ If not connected, inform the user:
57
88
 
58
89
  ---
59
90
 
60
- ## Browser Automation Flow
91
+ ## Grok Mode (Quick Search)
92
+
93
+ Ask Grok on x.com to search X and return structured results. One query, ~60 seconds.
94
+
95
+ ### Grok Workflow
96
+
97
+ #### 1. Navigate to Grok
98
+
99
+ ```bash
100
+ actionbook --extension browser open "https://x.com/i/grok"
101
+ ```
61
102
 
62
- Use Actionbook Extension mode to control the user's Chrome browser, navigate x.com, perform searches, and extract tweet data.
103
+ Wait 4 seconds for page load, then verify textarea exists:
104
+
105
+ ```bash
106
+ actionbook --extension browser eval "document.querySelector('textarea') ? 'ready' : 'not_ready'"
107
+ ```
108
+
109
+ > Use `browser open` (new tab) instead of `browser goto` to avoid "Cannot access chrome:// URL" errors.
110
+
111
+ #### 2. Input the Question
112
+
113
+ Craft a Grok prompt that returns structured data. Template:
114
+
115
+ ```
116
+ Search X for the most popular posts about [TOPIC] in the past [TIME_RANGE]. Show me the top [N] posts with the most engagement (likes + retweets). For each post, include: the author handle, post text, likes count, retweets count, and the post URL.
117
+ ```
118
+
119
+ Set the value via JS (React state-safe):
120
+
121
+ ```bash
122
+ actionbook --extension browser eval "
123
+ var textarea = document.querySelector('textarea');
124
+ if (textarea) {
125
+ var setter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
126
+ setter.call(textarea, 'YOUR GROK PROMPT HERE');
127
+ textarea.dispatchEvent(new Event('input', { bubbles: true }));
128
+ 'ok'
129
+ } else { 'no_textarea' }
130
+ "
131
+ ```
132
+
133
+ #### 3. Send the Question
134
+
135
+ ```bash
136
+ actionbook --extension browser eval "
137
+ var btns = document.querySelectorAll('button');
138
+ var sent = false;
139
+ for (var i = 0; i < btns.length; i++) {
140
+ var svg = btns[i].querySelector('svg');
141
+ var rect = btns[i].getBoundingClientRect();
142
+ if (svg && rect.width > 20 && rect.width < 60 && rect.height > 20 && rect.height < 60 && rect.x > 600) {
143
+ btns[i].click();
144
+ sent = true;
145
+ break;
146
+ }
147
+ }
148
+ sent ? 'sent' : 'not_found'
149
+ "
150
+ ```
151
+
152
+ If `not_found`, take a screenshot (`actionbook --extension browser screenshot`) and debug visually.
153
+
154
+ #### 4. Wait for Response
155
+
156
+ Grok takes 10-60 seconds (longer when searching X). Poll every 8 seconds:
157
+
158
+ ```bash
159
+ actionbook --extension browser eval "document.querySelector('main') ? document.querySelector('main').innerText.length : 0"
160
+ ```
161
+
162
+ Response is ready when length > 500. Timeout after 90 seconds and extract whatever is available.
163
+
164
+ #### 5. Extract Response
165
+
166
+ ```bash
167
+ actionbook --extension browser eval "document.querySelector('main').innerText"
168
+ ```
169
+
170
+ #### 6. Parse into JSONL Schema
171
+
172
+ Parse Grok's text response and map each post to the standard JSONL schema. For fields Grok doesn't provide:
173
+ - `views`: set to `"0"` (Grok doesn't return views)
174
+ - `replies`: set to `0` if not provided
175
+ - `posted_at`: set to `null` if not provided
176
+ - `angle` and `key_takeaway`: analyze and fill in yourself
177
+ - `format`: infer from text length and content (`thread` if mentions thread/continues, else `single`)
178
+
179
+ ---
180
+
181
+ ## Actionbook Scrape Mode (Full Collection)
182
+
183
+ Use Actionbook Extension mode to control the user's Chrome browser, navigate x.com search, and extract tweet data directly from the DOM.
63
184
 
64
185
  ### General Steps (repeat for each search round)
65
186
 
@@ -177,10 +298,12 @@ Use these operators in the search URL `q=` parameter (URL-encoded). Combine free
177
298
 
178
299
  ---
179
300
 
180
- ## Intelligence Gathering Rounds
301
+ ## Intelligence Gathering Rounds (Actionbook Scrape Mode)
181
302
 
182
303
  Run 3 core rounds + optional bonus rounds. All queries include `-filter:replies -filter:nativeretweets` by default to eliminate noise and surface only original content.
183
304
 
305
+ > **Grok Mode alternative**: If using Grok Mode, skip these rounds entirely. Instead, craft 1-3 targeted Grok prompts covering the same ground (e.g., "top viral posts about [topic]", "trending [topic] posts in last 24h", "which verified accounts are posting about [topic]").
306
+
184
307
  ### Core Rounds
185
308
 
186
309
  #### Round 1: Top / Viral Posts
@@ -343,7 +466,7 @@ Based on the N tweets above:
343
466
  After collection, display:
344
467
 
345
468
  ```
346
- X Intelligence for "[topic]" — [N] tweets collected:
469
+ X Intelligence for "[topic]" — [N] tweets collected (via [Grok / Actionbook Scrape]):
347
470
  Top / viral: X
348
471
  Trending (24h): Y
349
472
  KOL / verified: Z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-collect-skill",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "X/Twitter topic intelligence skill for Claude Code",
5
5
  "keywords": [
6
6
  "claude-code",