twitter-cli 0.6.3__tar.gz → 0.6.5__tar.gz

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.
Files changed (43) hide show
  1. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.github/ISSUE_TEMPLATE/bug_report.yml +31 -0
  2. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/PKG-INFO +54 -1
  3. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/README.md +53 -0
  4. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/SKILL.md +24 -0
  5. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/pyproject.toml +1 -1
  6. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_auth.py +115 -9
  7. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_cli.py +35 -0
  8. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_client.py +49 -0
  9. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/auth.py +105 -30
  10. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/cli.py +198 -31
  11. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/client.py +22 -6
  12. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/constants.py +21 -2
  13. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/formatter.py +6 -3
  14. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/graphql.py +1 -1
  15. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/uv.lock +1 -1
  16. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  17. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.github/workflows/ci.yml +0 -0
  18. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.github/workflows/publish-clawhub.yml +0 -0
  19. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.github/workflows/publish.yml +0 -0
  20. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/.gitignore +0 -0
  21. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/LICENSE +0 -0
  22. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/SCHEMA.md +0 -0
  23. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/config.yaml +0 -0
  24. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/conftest.py +0 -0
  25. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/fixtures/followers_page.json +0 -0
  26. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/fixtures/home_timeline.json +0 -0
  27. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/fixtures/list_timeline.json +0 -0
  28. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/fixtures/search_timeline.json +0 -0
  29. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/fixtures/tweet_detail.json +0 -0
  30. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_config.py +0 -0
  31. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_config_normalization.py +0 -0
  32. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_filter.py +0 -0
  33. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_parser_fixtures.py +0 -0
  34. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_serialization.py +0 -0
  35. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/tests/test_smoke.py +0 -0
  36. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/__init__.py +0 -0
  37. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/config.py +0 -0
  38. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/exceptions.py +0 -0
  39. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/filter.py +0 -0
  40. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/models.py +0 -0
  41. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/output.py +0 -0
  42. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/parser.py +0 -0
  43. {twitter_cli-0.6.3 → twitter_cli-0.6.5}/twitter_cli/serialization.py +0 -0
@@ -21,6 +21,31 @@ body:
21
21
  - Other
22
22
  validations:
23
23
  required: true
24
+ - type: dropdown
25
+ id: browser
26
+ attributes:
27
+ label: Browser (for cookie extraction)
28
+ options:
29
+ - Arc
30
+ - Chrome
31
+ - Edge
32
+ - Firefox
33
+ - Brave
34
+ - Other / N/A (using env vars)
35
+ validations:
36
+ required: true
37
+ - type: dropdown
38
+ id: access_method
39
+ attributes:
40
+ label: Access Method
41
+ description: How are you accessing the machine where twitter-cli runs?
42
+ options:
43
+ - Local terminal
44
+ - SSH
45
+ - Docker / container
46
+ - Other
47
+ validations:
48
+ required: true
24
49
  - type: textarea
25
50
  id: description
26
51
  attributes:
@@ -41,6 +66,12 @@ body:
41
66
  label: Steps to reproduce
42
67
  description: "Commands or steps to reproduce the issue. Use `twitter -v <command>` for debug output."
43
68
  render: bash
69
+ - type: textarea
70
+ id: diagnostics
71
+ attributes:
72
+ label: Diagnostics
73
+ description: "Paste the output of `twitter doctor` here. This helps us diagnose cookie and auth issues quickly."
74
+ render: text
44
75
  - type: textarea
45
76
  id: logs
46
77
  attributes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twitter-cli
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: A CLI for Twitter/X — feed, bookmarks, and user timeline in terminal
5
5
  Project-URL: Homepage, https://github.com/jackwener/twitter-cli
6
6
  Project-URL: Repository, https://github.com/jackwener/twitter-cli
@@ -58,6 +58,7 @@ A terminal-first CLI for Twitter/X: read timelines, bookmarks, and user profiles
58
58
  - Tweet detail: view a tweet and its replies
59
59
  - List timeline: fetch tweets from a Twitter List
60
60
  - User lookup: fetch user profile, tweets, likes, followers, and following
61
+ - `--full-text`: disable tweet text truncation in rich table output
61
62
  - Structured output: export any data as YAML or JSON for scripting and AI agent integration
62
63
  - Optional scoring filter: rank tweets by engagement weights
63
64
  - Structured output contract: [SCHEMA.md](./SCHEMA.md)
@@ -126,32 +127,39 @@ twitter feed --filter
126
127
  ```bash
127
128
  # Feed
128
129
  twitter feed --max 50
130
+ twitter feed --full-text
129
131
  twitter feed --json > tweets.json
130
132
  twitter feed --input tweets.json
131
133
 
132
134
  # Bookmarks
133
135
  twitter bookmarks
136
+ twitter bookmarks --full-text
134
137
  twitter bookmarks --max 30 --yaml
135
138
 
136
139
  # Search
137
140
  twitter search "Claude Code"
138
141
  twitter search "AI agent" -t Latest --max 50
142
+ twitter search "AI agent" --full-text
139
143
  twitter search "机器学习" --yaml
140
144
  twitter search "topic" -o results.json # Save to file
141
145
  twitter search "trending" --filter # Apply ranking filter
142
146
 
143
147
  # Tweet detail (view tweet + replies)
144
148
  twitter tweet 1234567890
149
+ twitter tweet 1234567890 --full-text
145
150
  twitter tweet https://x.com/user/status/1234567890
146
151
 
147
152
  # List timeline
148
153
  twitter list 1539453138322673664
154
+ twitter list 1539453138322673664 --full-text
149
155
 
150
156
  # User
151
157
  twitter user elonmusk
152
158
  twitter user-posts elonmusk --max 20
159
+ twitter user-posts elonmusk --full-text
153
160
  twitter user-posts elonmusk -o tweets.json
154
161
  twitter likes elonmusk --max 30 # ⚠️ own likes only (private since Jun 2024)
162
+ twitter likes elonmusk --full-text
155
163
  twitter likes elonmusk -o likes.json
156
164
  twitter followers elonmusk --max 50
157
165
  twitter following elonmusk --max 50
@@ -233,6 +241,7 @@ rateLimit:
233
241
  Fetch behavior:
234
242
 
235
243
  - `fetch.count` is the default item count for read commands when `--max` is omitted
244
+ - Rich table output truncates long tweet text by default; use `--full-text` to show full body text in list views
236
245
 
237
246
  Filter behavior:
238
247
 
@@ -263,6 +272,13 @@ Mode behavior:
263
272
  - **Use browser cookie extraction** — provides full cookie fingerprint
264
273
  - **Avoid datacenter IPs** — residential proxies are much safer
265
274
 
275
+ ### Output Modes
276
+
277
+ - Use the default rich table for interactive reading
278
+ - Use `--full-text` when reading long posts in terminal tables
279
+ - Use `--yaml` or `--json` for scripts and agent pipelines
280
+ - Use `-c` / `--compact` when token efficiency matters more than completeness
281
+
266
282
  ### Troubleshooting
267
283
 
268
284
  - `No Twitter cookies found`
@@ -273,6 +289,14 @@ Mode behavior:
273
289
  - `Cookie expired or invalid (HTTP 401/403)`
274
290
  - Re-login to `x.com` and retry.
275
291
 
292
+ - `Unable to get key for cookie decryption` (macOS Keychain)
293
+ - **SSH sessions**: Keychain is locked by default over SSH. Run:
294
+ ```bash
295
+ security unlock-keychain ~/Library/Keychains/login.keychain-db
296
+ ```
297
+ - **Local terminal**: Open **Keychain Access** → search for **"\<Browser\> Safe Storage"** → **Access Control** → add your Terminal app → **Save Changes**.
298
+ - Or click **"Always Allow"** when the Keychain authorization popup appears.
299
+
276
300
  - `Twitter API error 404`
277
301
  - This can happen when upstream GraphQL query IDs rotate.
278
302
  - Retry the command; the client attempts a live queryId fallback.
@@ -280,6 +304,8 @@ Mode behavior:
280
304
  - `Invalid tweet JSON file`
281
305
  - Regenerate input using `twitter feed --json > tweets.json`.
282
306
 
307
+ **Diagnostics command**: Run `twitter doctor` to output a full diagnostic report (version, OS, browser detection, Keychain status, cookie extraction results). Paste this output into bug reports.
308
+
283
309
  Structured error codes commonly include `not_authenticated`, `not_found`, `invalid_input`, `rate_limited`, and `api_error`.
284
310
 
285
311
  ### Development
@@ -352,6 +378,7 @@ After installation, OpenClaw can call `twitter-cli` commands directly.
352
378
  - 推文详情:查看推文及其回复
353
379
  - 列表时间线:获取 Twitter List 的推文
354
380
  - 用户查询:查看用户资料、推文、点赞、粉丝和关注
381
+ - `--full-text`:在 rich table 输出里关闭推文正文截断
355
382
  - 结构化输出:支持 YAML 和 JSON,便于脚本处理和 AI agent 集成
356
383
 
357
384
  > **AI Agent 提示:** 需要结构化输出时优先使用 `--yaml`,除非下游必须是 JSON。stdout 不是 TTY 时默认输出 YAML。用 `--max` 控制返回数量。
@@ -396,27 +423,34 @@ uv tool upgrade twitter-cli
396
423
  twitter feed
397
424
  twitter feed -t following
398
425
  twitter feed --filter
426
+ twitter feed --full-text
399
427
 
400
428
  # 收藏
401
429
  twitter bookmarks
430
+ twitter bookmarks --full-text
402
431
 
403
432
  # 搜索
404
433
  twitter search "Claude Code"
405
434
  twitter search "AI agent" -t Latest --max 50
435
+ twitter search "AI agent" --full-text
406
436
  twitter search "topic" -o results.json # 保存到文件
407
437
  twitter search "trending" --filter # 启用排序筛选
408
438
 
409
439
  # 推文详情
410
440
  twitter tweet 1234567890
441
+ twitter tweet 1234567890 --full-text
411
442
 
412
443
  # 列表时间线
413
444
  twitter list 1539453138322673664
445
+ twitter list 1539453138322673664 --full-text
414
446
 
415
447
  # 用户
416
448
  twitter user elonmusk
417
449
  twitter user-posts elonmusk --max 20
450
+ twitter user-posts elonmusk --full-text
418
451
  twitter user-posts elonmusk -o tweets.json
419
452
  twitter likes elonmusk --max 30 # ⚠️ 仅可查看自己的点赞(2024年6月起平台已私密化)
453
+ twitter likes elonmusk --full-text
420
454
  twitter likes elonmusk -o likes.json
421
455
  twitter followers elonmusk
422
456
  twitter following elonmusk
@@ -467,6 +501,8 @@ export TWITTER_PROXY=socks5://127.0.0.1:1080
467
501
 
468
502
  未传 `--max` 时,所有读取命令默认使用 `config.yaml` 里的 `fetch.count`。
469
503
 
504
+ rich table 输出默认会截断较长正文;如果需要在列表视图中查看完整正文,可加 `--full-text`。
505
+
470
506
  只有在传入 `--filter` 时才会启用筛选评分;默认不筛选。
471
507
 
472
508
  评分公式:
@@ -490,7 +526,17 @@ score = likes_w * likes
490
526
  - 报错 `No Twitter cookies found`:请先登录 `x.com`,并确认浏览器为 Arc/Chrome/Edge/Firefox/Brave 之一,或手动设置环境变量。
491
527
  - 如需查看浏览器提取细节,可加 `-v` 打开诊断日志。
492
528
  - 报错 `Cookie expired or invalid`:Cookie 过期,重新登录后重试。
529
+ - 报错 `Unable to get key for cookie decryption`(macOS Keychain 问题):
530
+ - **SSH 远程登录**:Keychain 默认锁定,需手动解锁:
531
+ ```bash
532
+ security unlock-keychain ~/Library/Keychains/login.keychain-db
533
+ ```
534
+ - **本地终端**:打开 **钥匙串访问** → 搜索 **"\<浏览器\> Safe Storage"** → **访问控制** → 添加你的终端 app → **保存更改**。
535
+ - 或在弹出 Keychain 授权时点击 **"始终允许"**。
493
536
  - 报错 `Twitter API error 404`:通常是 queryId 轮换,重试即可。
537
+
538
+ **诊断命令**:运行 `twitter doctor` 可输出完整诊断报告(版本、OS、浏览器检测、Keychain 状态、cookie 提取结果),方便提交 bug report。
539
+
494
540
  - 结构化错误码通常会区分 `not_authenticated`、`not_found`、`invalid_input`、`rate_limited`、`api_error`。
495
541
 
496
542
  ### 使用建议(防封号)
@@ -502,6 +548,13 @@ score = likes_w * likes
502
548
  - **避免数据中心 IP** — 住宅代理更安全
503
549
  - Cookie 仅在本地使用,不会被本工具上传
504
550
 
551
+ ### 输出模式建议
552
+
553
+ - 默认 rich table 适合终端交互式浏览
554
+ - 需要在表格里看完整正文时,使用 `--full-text`
555
+ - 需要脚本消费时,优先使用 `--yaml` 或 `--json`
556
+ - 需要节省 token 时,使用 `-c` / `--compact`
557
+
505
558
  ### 作为 AI Agent Skill 使用
506
559
 
507
560
  twitter-cli 提供了 [`SKILL.md`](./SKILL.md),可让 AI Agent 更稳定地调用本工具。
@@ -26,6 +26,7 @@ A terminal-first CLI for Twitter/X: read timelines, bookmarks, and user profiles
26
26
  - Tweet detail: view a tweet and its replies
27
27
  - List timeline: fetch tweets from a Twitter List
28
28
  - User lookup: fetch user profile, tweets, likes, followers, and following
29
+ - `--full-text`: disable tweet text truncation in rich table output
29
30
  - Structured output: export any data as YAML or JSON for scripting and AI agent integration
30
31
  - Optional scoring filter: rank tweets by engagement weights
31
32
  - Structured output contract: [SCHEMA.md](./SCHEMA.md)
@@ -94,32 +95,39 @@ twitter feed --filter
94
95
  ```bash
95
96
  # Feed
96
97
  twitter feed --max 50
98
+ twitter feed --full-text
97
99
  twitter feed --json > tweets.json
98
100
  twitter feed --input tweets.json
99
101
 
100
102
  # Bookmarks
101
103
  twitter bookmarks
104
+ twitter bookmarks --full-text
102
105
  twitter bookmarks --max 30 --yaml
103
106
 
104
107
  # Search
105
108
  twitter search "Claude Code"
106
109
  twitter search "AI agent" -t Latest --max 50
110
+ twitter search "AI agent" --full-text
107
111
  twitter search "机器学习" --yaml
108
112
  twitter search "topic" -o results.json # Save to file
109
113
  twitter search "trending" --filter # Apply ranking filter
110
114
 
111
115
  # Tweet detail (view tweet + replies)
112
116
  twitter tweet 1234567890
117
+ twitter tweet 1234567890 --full-text
113
118
  twitter tweet https://x.com/user/status/1234567890
114
119
 
115
120
  # List timeline
116
121
  twitter list 1539453138322673664
122
+ twitter list 1539453138322673664 --full-text
117
123
 
118
124
  # User
119
125
  twitter user elonmusk
120
126
  twitter user-posts elonmusk --max 20
127
+ twitter user-posts elonmusk --full-text
121
128
  twitter user-posts elonmusk -o tweets.json
122
129
  twitter likes elonmusk --max 30 # ⚠️ own likes only (private since Jun 2024)
130
+ twitter likes elonmusk --full-text
123
131
  twitter likes elonmusk -o likes.json
124
132
  twitter followers elonmusk --max 50
125
133
  twitter following elonmusk --max 50
@@ -201,6 +209,7 @@ rateLimit:
201
209
  Fetch behavior:
202
210
 
203
211
  - `fetch.count` is the default item count for read commands when `--max` is omitted
212
+ - Rich table output truncates long tweet text by default; use `--full-text` to show full body text in list views
204
213
 
205
214
  Filter behavior:
206
215
 
@@ -231,6 +240,13 @@ Mode behavior:
231
240
  - **Use browser cookie extraction** — provides full cookie fingerprint
232
241
  - **Avoid datacenter IPs** — residential proxies are much safer
233
242
 
243
+ ### Output Modes
244
+
245
+ - Use the default rich table for interactive reading
246
+ - Use `--full-text` when reading long posts in terminal tables
247
+ - Use `--yaml` or `--json` for scripts and agent pipelines
248
+ - Use `-c` / `--compact` when token efficiency matters more than completeness
249
+
234
250
  ### Troubleshooting
235
251
 
236
252
  - `No Twitter cookies found`
@@ -241,6 +257,14 @@ Mode behavior:
241
257
  - `Cookie expired or invalid (HTTP 401/403)`
242
258
  - Re-login to `x.com` and retry.
243
259
 
260
+ - `Unable to get key for cookie decryption` (macOS Keychain)
261
+ - **SSH sessions**: Keychain is locked by default over SSH. Run:
262
+ ```bash
263
+ security unlock-keychain ~/Library/Keychains/login.keychain-db
264
+ ```
265
+ - **Local terminal**: Open **Keychain Access** → search for **"\<Browser\> Safe Storage"** → **Access Control** → add your Terminal app → **Save Changes**.
266
+ - Or click **"Always Allow"** when the Keychain authorization popup appears.
267
+
244
268
  - `Twitter API error 404`
245
269
  - This can happen when upstream GraphQL query IDs rotate.
246
270
  - Retry the command; the client attempts a live queryId fallback.
@@ -248,6 +272,8 @@ Mode behavior:
248
272
  - `Invalid tweet JSON file`
249
273
  - Regenerate input using `twitter feed --json > tweets.json`.
250
274
 
275
+ **Diagnostics command**: Run `twitter doctor` to output a full diagnostic report (version, OS, browser detection, Keychain status, cookie extraction results). Paste this output into bug reports.
276
+
251
277
  Structured error codes commonly include `not_authenticated`, `not_found`, `invalid_input`, `rate_limited`, and `api_error`.
252
278
 
253
279
  ### Development
@@ -320,6 +346,7 @@ After installation, OpenClaw can call `twitter-cli` commands directly.
320
346
  - 推文详情:查看推文及其回复
321
347
  - 列表时间线:获取 Twitter List 的推文
322
348
  - 用户查询:查看用户资料、推文、点赞、粉丝和关注
349
+ - `--full-text`:在 rich table 输出里关闭推文正文截断
323
350
  - 结构化输出:支持 YAML 和 JSON,便于脚本处理和 AI agent 集成
324
351
 
325
352
  > **AI Agent 提示:** 需要结构化输出时优先使用 `--yaml`,除非下游必须是 JSON。stdout 不是 TTY 时默认输出 YAML。用 `--max` 控制返回数量。
@@ -364,27 +391,34 @@ uv tool upgrade twitter-cli
364
391
  twitter feed
365
392
  twitter feed -t following
366
393
  twitter feed --filter
394
+ twitter feed --full-text
367
395
 
368
396
  # 收藏
369
397
  twitter bookmarks
398
+ twitter bookmarks --full-text
370
399
 
371
400
  # 搜索
372
401
  twitter search "Claude Code"
373
402
  twitter search "AI agent" -t Latest --max 50
403
+ twitter search "AI agent" --full-text
374
404
  twitter search "topic" -o results.json # 保存到文件
375
405
  twitter search "trending" --filter # 启用排序筛选
376
406
 
377
407
  # 推文详情
378
408
  twitter tweet 1234567890
409
+ twitter tweet 1234567890 --full-text
379
410
 
380
411
  # 列表时间线
381
412
  twitter list 1539453138322673664
413
+ twitter list 1539453138322673664 --full-text
382
414
 
383
415
  # 用户
384
416
  twitter user elonmusk
385
417
  twitter user-posts elonmusk --max 20
418
+ twitter user-posts elonmusk --full-text
386
419
  twitter user-posts elonmusk -o tweets.json
387
420
  twitter likes elonmusk --max 30 # ⚠️ 仅可查看自己的点赞(2024年6月起平台已私密化)
421
+ twitter likes elonmusk --full-text
388
422
  twitter likes elonmusk -o likes.json
389
423
  twitter followers elonmusk
390
424
  twitter following elonmusk
@@ -435,6 +469,8 @@ export TWITTER_PROXY=socks5://127.0.0.1:1080
435
469
 
436
470
  未传 `--max` 时,所有读取命令默认使用 `config.yaml` 里的 `fetch.count`。
437
471
 
472
+ rich table 输出默认会截断较长正文;如果需要在列表视图中查看完整正文,可加 `--full-text`。
473
+
438
474
  只有在传入 `--filter` 时才会启用筛选评分;默认不筛选。
439
475
 
440
476
  评分公式:
@@ -458,7 +494,17 @@ score = likes_w * likes
458
494
  - 报错 `No Twitter cookies found`:请先登录 `x.com`,并确认浏览器为 Arc/Chrome/Edge/Firefox/Brave 之一,或手动设置环境变量。
459
495
  - 如需查看浏览器提取细节,可加 `-v` 打开诊断日志。
460
496
  - 报错 `Cookie expired or invalid`:Cookie 过期,重新登录后重试。
497
+ - 报错 `Unable to get key for cookie decryption`(macOS Keychain 问题):
498
+ - **SSH 远程登录**:Keychain 默认锁定,需手动解锁:
499
+ ```bash
500
+ security unlock-keychain ~/Library/Keychains/login.keychain-db
501
+ ```
502
+ - **本地终端**:打开 **钥匙串访问** → 搜索 **"\<浏览器\> Safe Storage"** → **访问控制** → 添加你的终端 app → **保存更改**。
503
+ - 或在弹出 Keychain 授权时点击 **"始终允许"**。
461
504
  - 报错 `Twitter API error 404`:通常是 queryId 轮换,重试即可。
505
+
506
+ **诊断命令**:运行 `twitter doctor` 可输出完整诊断报告(版本、OS、浏览器检测、Keychain 状态、cookie 提取结果),方便提交 bug report。
507
+
462
508
  - 结构化错误码通常会区分 `not_authenticated`、`not_found`、`invalid_input`、`rate_limited`、`api_error`。
463
509
 
464
510
  ### 使用建议(防封号)
@@ -470,6 +516,13 @@ score = likes_w * likes
470
516
  - **避免数据中心 IP** — 住宅代理更安全
471
517
  - Cookie 仅在本地使用,不会被本工具上传
472
518
 
519
+ ### 输出模式建议
520
+
521
+ - 默认 rich table 适合终端交互式浏览
522
+ - 需要在表格里看完整正文时,使用 `--full-text`
523
+ - 需要脚本消费时,优先使用 `--yaml` 或 `--json`
524
+ - 需要节省 token 时,使用 `-c` / `--compact`
525
+
473
526
  ### 作为 AI Agent Skill 使用
474
527
 
475
528
  twitter-cli 提供了 [`SKILL.md`](./SKILL.md),可让 AI Agent 更稳定地调用本工具。
@@ -114,6 +114,19 @@ twitter feed --json | jq '.[0].text'
114
114
  All machine-readable output uses the envelope documented in [SCHEMA.md](./SCHEMA.md).
115
115
  Tweet and user payloads now live under `.data`.
116
116
 
117
+ ### Full text: `--full-text` flag (rich tables only)
118
+
119
+ Use `--full-text` when the user wants complete post bodies in terminal tables.
120
+ It affects rich table list views such as `feed`, `bookmarks`, `search`, `user-posts`, `likes`, `list`, and reply tables in `tweet`.
121
+ It does **not** change `--json`, `--yaml`, or `-c` compact output.
122
+
123
+ ```bash
124
+ twitter feed --full-text
125
+ twitter search "AI agent" --full-text
126
+ twitter user-posts elonmusk --max 20 --full-text
127
+ twitter tweet 1234567890 --full-text
128
+ ```
129
+
117
130
  ### Compact: `-c` flag (minimal tokens for LLM)
118
131
 
119
132
  ```bash
@@ -138,19 +151,26 @@ twitter user elonmusk --json # JSON output
138
151
  twitter feed # Home timeline (For You)
139
152
  twitter feed -t following # Following timeline
140
153
  twitter feed --max 50 # Limit count
154
+ twitter feed --full-text # Show full post body in table
141
155
  twitter feed --filter # Enable ranking filter
142
156
  twitter feed --yaml > tweets.yaml # Export as YAML
143
157
  twitter feed --input tweets.json # Read from local JSON file
144
158
  twitter bookmarks # Bookmarked tweets
159
+ twitter bookmarks --full-text # Full text in bookmarks table
145
160
  twitter bookmarks --max 30 --yaml
146
161
  twitter search "keyword" # Search tweets
147
162
  twitter search "AI agent" -t Latest --max 50
163
+ twitter search "AI agent" --full-text # Full text in search results
148
164
  twitter search "topic" -o results.json # Save to file
149
165
  twitter tweet 1234567890 # Tweet detail + replies
166
+ twitter tweet 1234567890 --full-text # Full text in reply table
150
167
  twitter tweet https://x.com/user/status/12345 # Accepts URL
151
168
  twitter list 1539453138322673664 # List timeline
169
+ twitter list 1539453138322673664 --full-text
152
170
  twitter user-posts elonmusk --max 20 # User's tweets
171
+ twitter user-posts elonmusk --full-text
153
172
  twitter likes elonmusk --max 30 # User's likes (own only, see note)
173
+ twitter likes elonmusk --full-text
154
174
  twitter followers elonmusk --max 50 # Followers
155
175
  twitter following elonmusk --max 50 # Following
156
176
  ```
@@ -241,6 +261,10 @@ twitter followers "$MY_NAME" --max 200 --json | jq -r '.data[].username' | grep
241
261
  twitter -c feed -t following --max 30
242
262
  twitter -c bookmarks --max 20
243
263
 
264
+ # Rich table with complete post bodies
265
+ twitter feed -t following --max 20 --full-text
266
+ twitter search "AI agent" --max 20 --full-text
267
+
244
268
  # Full JSON for analysis
245
269
  twitter feed -t following --max 30 -o following.json
246
270
  twitter bookmarks --max 20 -o bookmarks.json
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "twitter-cli"
7
- version = "0.6.3"
7
+ version = "0.6.5"
8
8
  description = "A CLI for Twitter/X — feed, bookmarks, and user timeline in terminal"
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -30,8 +30,8 @@ def test_get_cookies_reextracts_after_verify_failure(monkeypatch) -> None:
30
30
  monkeypatch.setattr(auth, "load_from_env", lambda: None)
31
31
  extracted = iter(
32
32
  [
33
- {"auth_token": "stale-token", "ct0": "stale-csrf", "cookie_string": "stale=1"},
34
- {"auth_token": "fresh-token", "ct0": "fresh-csrf", "cookie_string": "fresh=1"},
33
+ ({"auth_token": "stale-token", "ct0": "stale-csrf", "cookie_string": "stale=1"}, []),
34
+ ({"auth_token": "fresh-token", "ct0": "fresh-csrf", "cookie_string": "fresh=1"}, []),
35
35
  ]
36
36
  )
37
37
  monkeypatch.setattr(auth, "extract_from_browser", lambda: next(extracted))
@@ -84,11 +84,11 @@ def test_extract_cookies_from_jar_logs_missing_required_cookies(caplog) -> None:
84
84
 
85
85
 
86
86
  def test_extract_from_browser_logs_warning_when_all_methods_fail(monkeypatch, caplog) -> None:
87
- monkeypatch.setattr(auth, "_extract_in_process", lambda: None)
88
- monkeypatch.setattr(auth, "_extract_via_subprocess", lambda: None)
87
+ monkeypatch.setattr(auth, "_extract_in_process", lambda: (None, []))
88
+ monkeypatch.setattr(auth, "_extract_via_subprocess", lambda: (None, []))
89
89
 
90
90
  with caplog.at_level("WARNING"):
91
- cookies = auth.extract_from_browser()
91
+ cookies, diagnostics = auth.extract_from_browser()
92
92
 
93
93
  assert cookies is None
94
94
  assert "Twitter cookie extraction failed in both in-process and subprocess modes" in caplog.text
@@ -110,7 +110,7 @@ def test_extract_in_process_supports_arc(monkeypatch) -> None:
110
110
  )
111
111
  monkeypatch.setitem(sys.modules, "browser_cookie3", fake_module)
112
112
 
113
- cookies = auth._extract_in_process()
113
+ cookies, diagnostics = auth._extract_in_process()
114
114
 
115
115
  assert cookies is not None
116
116
  assert cookies["auth_token"] == "token"
@@ -132,7 +132,7 @@ def test_extract_via_subprocess_script_includes_arc(monkeypatch) -> None:
132
132
 
133
133
  monkeypatch.setattr(auth.subprocess, "run", _run)
134
134
 
135
- cookies = auth._extract_via_subprocess()
135
+ cookies, diagnostics = auth._extract_via_subprocess()
136
136
 
137
137
  assert cookies is None
138
138
  assert '("arc", browser_cookie3.arc)' in seen["script"]
@@ -154,7 +154,7 @@ def test_extract_via_subprocess_retries_uv_when_current_env_has_no_output(monkey
154
154
 
155
155
  monkeypatch.setattr(auth.subprocess, "run", _run)
156
156
 
157
- cookies = auth._extract_via_subprocess()
157
+ cookies, diagnostics = auth._extract_via_subprocess()
158
158
 
159
159
  assert cookies == {"auth_token": "token", "ct0": "csrf"}
160
160
  assert len(calls) == 2
@@ -243,6 +243,36 @@ def test_iter_chrome_cookie_files_env_override(monkeypatch, tmp_path) -> None:
243
243
  assert "Profile 5" in paths[0]
244
244
 
245
245
 
246
+ def test_iter_chrome_cookie_files_edge_linux_uses_microsoft_edge_path(monkeypatch, tmp_path) -> None:
247
+ monkeypatch.setattr(auth.sys, "platform", "linux")
248
+ edge_dir = tmp_path / ".config" / "microsoft-edge"
249
+ (edge_dir / "Default").mkdir(parents=True)
250
+ (edge_dir / "Default" / "Cookies").touch()
251
+
252
+ monkeypatch.setenv("HOME", str(tmp_path))
253
+ monkeypatch.delenv("TWITTER_CHROME_PROFILE", raising=False)
254
+
255
+ paths = auth._iter_chrome_cookie_files("edge")
256
+
257
+ assert len(paths) == 1
258
+ assert paths[0].endswith(".config/microsoft-edge/Default/Cookies")
259
+
260
+
261
+ def test_iter_chrome_cookie_files_edge_windows_uses_user_data(monkeypatch, tmp_path) -> None:
262
+ monkeypatch.setattr(auth.sys, "platform", "win32")
263
+ monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
264
+ monkeypatch.delenv("TWITTER_CHROME_PROFILE", raising=False)
265
+
266
+ edge_dir = tmp_path / "Microsoft" / "Edge" / "User Data" / "Default"
267
+ edge_dir.mkdir(parents=True)
268
+ (edge_dir / "Cookies").touch()
269
+
270
+ paths = auth._iter_chrome_cookie_files("edge")
271
+
272
+ assert len(paths) == 1
273
+ assert "Microsoft/Edge/User Data/Default/Cookies".replace("/", os.sep) in paths[0]
274
+
275
+
246
276
  def test_extract_in_process_tries_multiple_profiles(monkeypatch, tmp_path) -> None:
247
277
  """When Default has no Twitter cookies but Profile 1 does, it should find them."""
248
278
 
@@ -285,8 +315,84 @@ def test_extract_in_process_tries_multiple_profiles(monkeypatch, tmp_path) -> No
285
315
  )
286
316
  monkeypatch.setitem(sys.modules, "browser_cookie3", fake_module)
287
317
 
288
- cookies = auth._extract_in_process()
318
+ cookies, diagnostics = auth._extract_in_process()
289
319
 
290
320
  assert cookies is not None
291
321
  assert cookies["auth_token"] == "tok123"
292
322
  assert cookies["ct0"] == "csrf456"
323
+
324
+
325
+ def test_diagnose_keychain_issues_detects_decryption_error(monkeypatch) -> None:
326
+ """_diagnose_keychain_issues should detect Keychain-related error strings."""
327
+ monkeypatch.setattr("sys.platform", "darwin")
328
+ monkeypatch.delenv("SSH_CLIENT", raising=False)
329
+ monkeypatch.delenv("SSH_TTY", raising=False)
330
+ monkeypatch.delenv("SSH_CONNECTION", raising=False)
331
+
332
+ diagnostics = ["arc[Default]: Unable to get key for cookie decryption"]
333
+ hint = auth._diagnose_keychain_issues(diagnostics)
334
+
335
+ assert hint is not None
336
+ assert "Keychain" in hint
337
+
338
+
339
+ def test_diagnose_keychain_issues_ssh_hint(monkeypatch) -> None:
340
+ """When SSH env vars are set, hint should suggest unlock-keychain."""
341
+ monkeypatch.setattr("sys.platform", "darwin")
342
+ monkeypatch.setenv("SSH_CLIENT", "1.2.3.4 54321 22")
343
+
344
+ diagnostics = ["arc: Unable to get key for cookie decryption"]
345
+ hint = auth._diagnose_keychain_issues(diagnostics)
346
+
347
+ assert hint is not None
348
+ assert "SSH session detected" in hint
349
+ assert "security unlock-keychain" in hint
350
+
351
+
352
+ def test_diagnose_keychain_issues_returns_none_for_unrelated_errors() -> None:
353
+ """Should return None when diagnostics don't mention Keychain."""
354
+ diagnostics = ["chrome[Default]=no-cookies", "firefox: profile not found"]
355
+ hint = auth._diagnose_keychain_issues(diagnostics)
356
+
357
+ assert hint is None
358
+
359
+
360
+ def test_get_cookies_includes_keychain_hint_in_error(monkeypatch) -> None:
361
+ """When extraction fails with Keychain errors, error msg should contain the hint."""
362
+ monkeypatch.setattr("sys.platform", "darwin")
363
+ monkeypatch.setenv("SSH_CLIENT", "1.2.3.4 54321 22")
364
+ monkeypatch.setattr(auth, "load_from_env", lambda: None)
365
+ monkeypatch.setattr(
366
+ auth,
367
+ "extract_from_browser",
368
+ lambda: (None, ["arc: Unable to get key for cookie decryption"]),
369
+ )
370
+
371
+ with pytest.raises(RuntimeError) as exc_info:
372
+ auth.get_cookies()
373
+
374
+ msg = str(exc_info.value)
375
+ assert "security unlock-keychain" in msg
376
+ assert "twitter doctor" in msg
377
+
378
+
379
+ def test_extract_in_process_returns_diagnostics_on_failure(monkeypatch) -> None:
380
+ """_extract_in_process should return diagnostics containing error strings."""
381
+ from types import SimpleNamespace
382
+
383
+ class BrowserError(Exception):
384
+ pass
385
+
386
+ fake_module = SimpleNamespace(
387
+ arc=lambda: (_ for _ in ()).throw(BrowserError("Unable to get key for cookie decryption")),
388
+ chrome=lambda: [],
389
+ edge=lambda: (_ for _ in ()).throw(BrowserError("Edge not found")),
390
+ firefox=lambda: (_ for _ in ()).throw(BrowserError("Firefox not found")),
391
+ brave=lambda: (_ for _ in ()).throw(BrowserError("Brave not found")),
392
+ )
393
+ monkeypatch.setitem(sys.modules, "browser_cookie3", fake_module)
394
+
395
+ cookies, diagnostics = auth._extract_in_process()
396
+
397
+ assert cookies is None
398
+ assert any("cookie decryption" in d for d in diagnostics)