twitter-cli 0.8.2__tar.gz → 0.8.4__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 (48) hide show
  1. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/.github/ISSUE_TEMPLATE/bug_report.yml +1 -1
  2. twitter_cli-0.8.4/AGENTS.md +70 -0
  3. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/PKG-INFO +42 -26
  4. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/README.md +41 -25
  5. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/SKILL.md +1 -0
  6. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/pyproject.toml +1 -1
  7. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/fixtures/home_timeline.json +7 -0
  8. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_auth.py +2 -2
  9. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_cli.py +22 -32
  10. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_parser_fixtures.py +3 -0
  11. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/auth.py +39 -17
  12. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/cli.py +12 -153
  13. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/constants.py +0 -2
  14. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/formatter.py +1 -1
  15. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/parser.py +4 -1
  16. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/uv.lock +1 -1
  17. twitter_cli-0.8.2/.github/workflows/publish-clawhub.yml +0 -127
  18. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  19. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/.github/workflows/ci.yml +0 -0
  20. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/.github/workflows/publish.yml +0 -0
  21. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/.gitignore +0 -0
  22. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/LICENSE +0 -0
  23. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/SCHEMA.md +0 -0
  24. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/config.yaml +0 -0
  25. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/conftest.py +0 -0
  26. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/fixtures/followers_page.json +0 -0
  27. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/fixtures/list_timeline.json +0 -0
  28. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/fixtures/search_timeline.json +0 -0
  29. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/fixtures/tweet_detail.json +0 -0
  30. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_client.py +0 -0
  31. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_config.py +0 -0
  32. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_config_normalization.py +0 -0
  33. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_filter.py +0 -0
  34. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_search.py +0 -0
  35. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_serialization.py +0 -0
  36. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/tests/test_smoke.py +0 -0
  37. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/__init__.py +0 -0
  38. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/cache.py +0 -0
  39. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/client.py +0 -0
  40. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/config.py +0 -0
  41. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/exceptions.py +0 -0
  42. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/filter.py +0 -0
  43. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/graphql.py +0 -0
  44. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/models.py +0 -0
  45. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/output.py +0 -0
  46. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/search.py +0 -0
  47. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/serialization.py +0 -0
  48. {twitter_cli-0.8.2 → twitter_cli-0.8.4}/twitter_cli/timeutil.py +0 -0
@@ -70,7 +70,7 @@ body:
70
70
  id: diagnostics
71
71
  attributes:
72
72
  label: Diagnostics
73
- description: "Paste the output of `twitter doctor` here. This helps us diagnose cookie and auth issues quickly."
73
+ description: "Paste the output of `twitter -v <command>` here. This helps us diagnose cookie and auth issues quickly."
74
74
  render: text
75
75
  - type: textarea
76
76
  id: logs
@@ -0,0 +1,70 @@
1
+ # AGENTS.md — Agent Developer Guide for twitter-cli
2
+
3
+ This file provides context for AI agents working in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ - **Project**: twitter-cli — A CLI for Twitter/X (read timelines, bookmarks, search, post, reply, etc.)
8
+ - **Language**: Python 3.10+
9
+ - **Package Manager**: uv (recommended) / pip
10
+ - **Repository**: https://github.com/jackwener/twitter-cli
11
+
12
+ ## Build, Lint, and Test Commands
13
+
14
+ ```bash
15
+ # Install all dependencies (including dev)
16
+ uv sync --extra dev
17
+
18
+ # Run ruff linter
19
+ uv run ruff check .
20
+
21
+ # Run mypy type checker
22
+ uv run mypy twitter_cli
23
+
24
+ # Run all tests (excludes smoke tests by default)
25
+ uv run pytest -q
26
+
27
+ # Run a single test
28
+ uv run pytest tests/test_cli.py::test_feed_command -v
29
+
30
+ # Run tests matching pattern
31
+ uv run pytest -k "test_parse" -v
32
+ ```
33
+
34
+ ## Code Style
35
+
36
+ - **Line length**: 100 characters
37
+ - **Python version**: 3.10+
38
+ - Use `from __future__ import annotations` at top of all .py files
39
+ - **Functions/variables**: `snake_case`, **Classes**: `PascalCase`, **Constants**: `UPPER_SNAKE_CASE`
40
+ - Private functions: prefix with `_`
41
+ - Use `@dataclass` for data models (in `models.py`)
42
+ - Use Click framework for CLI commands
43
+ - Custom exceptions in `exceptions.py`, base: `TwitterError(RuntimeError)`
44
+
45
+ ## Project Structure
46
+
47
+ ```
48
+ twitter_cli/
49
+ ├── cli.py # Click CLI entry point
50
+ ├── client.py # Twitter API client (HTTP)
51
+ ├── auth.py # Cookie extraction & auth
52
+ ├── graphql.py # GraphQL query IDs
53
+ ├── parser.py # Tweet/User parsing
54
+ ├── models.py # Dataclass models
55
+ ├── formatter.py # Rich table formatting
56
+ ├── serialization.py # YAML/JSON output
57
+ ├── output.py # Structured output helpers
58
+ ├── config.py # Config loading
59
+ ├── filter.py # Tweet ranking/scoring
60
+ ├── constants.py # Constants
61
+ ├── exceptions.py # Custom exceptions
62
+ ├── cache.py # Tweet caching
63
+ ├── search.py # Search utilities
64
+ └── timeutil.py # Time utilities
65
+ ```
66
+
67
+ ## CI
68
+
69
+ - GitHub Actions: Python 3.10, 3.11, 3.12
70
+ - CI validates: ruff check + mypy + pytest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: twitter-cli
3
- Version: 0.8.2
3
+ Version: 0.8.4
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
@@ -214,6 +214,12 @@ Browser extraction is recommended — it forwards ALL Twitter cookies (not just
214
214
  TWITTER_CHROME_PROFILE="Profile 2" twitter feed
215
215
  ```
216
216
 
217
+ **Browser priority:** If you have multiple browsers, set `TWITTER_BROWSER` to try a specific browser first:
218
+
219
+ ```bash
220
+ TWITTER_BROWSER=chrome twitter feed # Supported: arc, chrome, edge, firefox, brave
221
+ ```
222
+
217
223
  After loading cookies, the CLI performs lightweight verification. Commands that require account access fail fast on clear auth errors (`401/403`).
218
224
 
219
225
  ### Proxy Support
@@ -324,7 +330,7 @@ Mode behavior:
324
330
  - `Invalid tweet JSON file`
325
331
  - Regenerate input using `twitter feed --json > tweets.json`.
326
332
 
327
- **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.
333
+
328
334
 
329
335
  Structured error codes commonly include `not_authenticated`, `not_found`, `invalid_input`, `rate_limited`, and `api_error`.
330
336
 
@@ -365,27 +371,28 @@ twitter_cli/
365
371
 
366
372
  twitter-cli ships with a [`SKILL.md`](./SKILL.md) so AI agents can execute common X/Twitter workflows.
367
373
 
368
- #### Claude Code / Antigravity
374
+ #### [Skills CLI](https://github.com/vercel-labs/skills) (Recommended)
369
375
 
370
376
  ```bash
371
- # Clone into your project's skills directory
372
- mkdir -p .agents/skills
373
- git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
374
-
375
- # Or copy SKILL.md only
376
- curl -o .agents/skills/twitter-cli/SKILL.md \
377
- https://raw.githubusercontent.com/jackwener/twitter-cli/main/SKILL.md
377
+ npx skills add jackwener/twitter-cli
378
378
  ```
379
379
 
380
- #### OpenClaw / ClawHub
380
+ | Flag | Description |
381
+ | --- | --- |
382
+ | `-g` | Install globally (user-level, shared across projects) |
383
+ | `-a claude-code` | Target a specific agent |
384
+ | `-y` | Non-interactive mode |
381
385
 
382
- Install from ClawHub:
386
+ #### Manual Install
383
387
 
384
388
  ```bash
385
- clawhub install twitter-cli
389
+ mkdir -p .agents/skills
390
+ git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
386
391
  ```
387
392
 
388
- After installation, OpenClaw can call `twitter-cli` commands directly.
393
+ #### ~~OpenClaw / ClawHub~~ (Deprecated)
394
+
395
+ > ⚠️ ClawHub install method is deprecated and no longer supported. Use [Skills CLI](#skills-cli-recommended) or Manual Install above.
389
396
 
390
397
  ## 中文
391
398
 
@@ -522,6 +529,12 @@ twitter follow elonmusk --json
522
529
  TWITTER_CHROME_PROFILE="Profile 2" twitter feed
523
530
  ```
524
531
 
532
+ **浏览器优先级**:如果有多个浏览器,可通过 `TWITTER_BROWSER` 指定优先尝试的浏览器:
533
+
534
+ ```bash
535
+ TWITTER_BROWSER=chrome twitter feed # 支持: arc, chrome, edge, firefox, brave
536
+ ```
537
+
525
538
  ### 代理支持
526
539
 
527
540
  设置 `TWITTER_PROXY` 环境变量即可:
@@ -572,7 +585,7 @@ score = likes_w * likes
572
585
  - 或在弹出 Keychain 授权时点击 **"始终允许"**。
573
586
  - 报错 `Twitter API error 404`:通常是 queryId 轮换,重试即可。
574
587
 
575
- **诊断命令**:运行 `twitter doctor` 可输出完整诊断报告(版本、OS、浏览器检测、Keychain 状态、cookie 提取结果),方便提交 bug report。
588
+
576
589
 
577
590
  - 结构化错误码通常会区分 `not_authenticated`、`not_found`、`invalid_input`、`rate_limited`、`api_error`。
578
591
 
@@ -596,26 +609,29 @@ score = likes_w * likes
596
609
 
597
610
  twitter-cli 提供了 [`SKILL.md`](./SKILL.md),可让 AI Agent 更稳定地调用本工具。
598
611
 
599
- #### Claude Code / Antigravity
612
+ #### [Skills CLI](https://github.com/vercel-labs/skills)(推荐)
600
613
 
601
614
  ```bash
602
- # 克隆到项目 skills 目录
603
- mkdir -p .agents/skills
604
- git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
605
-
606
- # 或仅下载 SKILL.md
607
- curl -o .agents/skills/twitter-cli/SKILL.md \
608
- https://raw.githubusercontent.com/jackwener/twitter-cli/main/SKILL.md
615
+ npx skills add jackwener/twitter-cli
609
616
  ```
610
617
 
611
- #### OpenClaw / ClawHub
618
+ | 参数 | 说明 |
619
+ | --- | --- |
620
+ | `-g` | 全局安装(用户级别,跨项目共享) |
621
+ | `-a claude-code` | 指定目标 Agent |
622
+ | `-y` | 非交互模式 |
612
623
 
613
- 通过 ClawHub 安装:
624
+ #### 手动安装
614
625
 
615
626
  ```bash
616
- clawhub install twitter-cli
627
+ mkdir -p .agents/skills
628
+ git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
617
629
  ```
618
630
 
631
+ #### ~~OpenClaw / ClawHub~~(已过时)
632
+
633
+ > ⚠️ ClawHub 安装方式已过时,不再支持。请使用上方的 Skills CLI 或手动安装。
634
+
619
635
  ### 更多工具
620
636
 
621
637
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili 视频、用户、搜索与动态 CLI
@@ -182,6 +182,12 @@ Browser extraction is recommended — it forwards ALL Twitter cookies (not just
182
182
  TWITTER_CHROME_PROFILE="Profile 2" twitter feed
183
183
  ```
184
184
 
185
+ **Browser priority:** If you have multiple browsers, set `TWITTER_BROWSER` to try a specific browser first:
186
+
187
+ ```bash
188
+ TWITTER_BROWSER=chrome twitter feed # Supported: arc, chrome, edge, firefox, brave
189
+ ```
190
+
185
191
  After loading cookies, the CLI performs lightweight verification. Commands that require account access fail fast on clear auth errors (`401/403`).
186
192
 
187
193
  ### Proxy Support
@@ -292,7 +298,7 @@ Mode behavior:
292
298
  - `Invalid tweet JSON file`
293
299
  - Regenerate input using `twitter feed --json > tweets.json`.
294
300
 
295
- **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.
301
+
296
302
 
297
303
  Structured error codes commonly include `not_authenticated`, `not_found`, `invalid_input`, `rate_limited`, and `api_error`.
298
304
 
@@ -333,27 +339,28 @@ twitter_cli/
333
339
 
334
340
  twitter-cli ships with a [`SKILL.md`](./SKILL.md) so AI agents can execute common X/Twitter workflows.
335
341
 
336
- #### Claude Code / Antigravity
342
+ #### [Skills CLI](https://github.com/vercel-labs/skills) (Recommended)
337
343
 
338
344
  ```bash
339
- # Clone into your project's skills directory
340
- mkdir -p .agents/skills
341
- git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
342
-
343
- # Or copy SKILL.md only
344
- curl -o .agents/skills/twitter-cli/SKILL.md \
345
- https://raw.githubusercontent.com/jackwener/twitter-cli/main/SKILL.md
345
+ npx skills add jackwener/twitter-cli
346
346
  ```
347
347
 
348
- #### OpenClaw / ClawHub
348
+ | Flag | Description |
349
+ | --- | --- |
350
+ | `-g` | Install globally (user-level, shared across projects) |
351
+ | `-a claude-code` | Target a specific agent |
352
+ | `-y` | Non-interactive mode |
349
353
 
350
- Install from ClawHub:
354
+ #### Manual Install
351
355
 
352
356
  ```bash
353
- clawhub install twitter-cli
357
+ mkdir -p .agents/skills
358
+ git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
354
359
  ```
355
360
 
356
- After installation, OpenClaw can call `twitter-cli` commands directly.
361
+ #### ~~OpenClaw / ClawHub~~ (Deprecated)
362
+
363
+ > ⚠️ ClawHub install method is deprecated and no longer supported. Use [Skills CLI](#skills-cli-recommended) or Manual Install above.
357
364
 
358
365
  ## 中文
359
366
 
@@ -490,6 +497,12 @@ twitter follow elonmusk --json
490
497
  TWITTER_CHROME_PROFILE="Profile 2" twitter feed
491
498
  ```
492
499
 
500
+ **浏览器优先级**:如果有多个浏览器,可通过 `TWITTER_BROWSER` 指定优先尝试的浏览器:
501
+
502
+ ```bash
503
+ TWITTER_BROWSER=chrome twitter feed # 支持: arc, chrome, edge, firefox, brave
504
+ ```
505
+
493
506
  ### 代理支持
494
507
 
495
508
  设置 `TWITTER_PROXY` 环境变量即可:
@@ -540,7 +553,7 @@ score = likes_w * likes
540
553
  - 或在弹出 Keychain 授权时点击 **"始终允许"**。
541
554
  - 报错 `Twitter API error 404`:通常是 queryId 轮换,重试即可。
542
555
 
543
- **诊断命令**:运行 `twitter doctor` 可输出完整诊断报告(版本、OS、浏览器检测、Keychain 状态、cookie 提取结果),方便提交 bug report。
556
+
544
557
 
545
558
  - 结构化错误码通常会区分 `not_authenticated`、`not_found`、`invalid_input`、`rate_limited`、`api_error`。
546
559
 
@@ -564,26 +577,29 @@ score = likes_w * likes
564
577
 
565
578
  twitter-cli 提供了 [`SKILL.md`](./SKILL.md),可让 AI Agent 更稳定地调用本工具。
566
579
 
567
- #### Claude Code / Antigravity
580
+ #### [Skills CLI](https://github.com/vercel-labs/skills)(推荐)
568
581
 
569
582
  ```bash
570
- # 克隆到项目 skills 目录
571
- mkdir -p .agents/skills
572
- git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
573
-
574
- # 或仅下载 SKILL.md
575
- curl -o .agents/skills/twitter-cli/SKILL.md \
576
- https://raw.githubusercontent.com/jackwener/twitter-cli/main/SKILL.md
583
+ npx skills add jackwener/twitter-cli
577
584
  ```
578
585
 
579
- #### OpenClaw / ClawHub
586
+ | 参数 | 说明 |
587
+ | --- | --- |
588
+ | `-g` | 全局安装(用户级别,跨项目共享) |
589
+ | `-a claude-code` | 指定目标 Agent |
590
+ | `-y` | 非交互模式 |
580
591
 
581
- 通过 ClawHub 安装:
592
+ #### 手动安装
582
593
 
583
594
  ```bash
584
- clawhub install twitter-cli
595
+ mkdir -p .agents/skills
596
+ git clone git@github.com:jackwener/twitter-cli.git .agents/skills/twitter-cli
585
597
  ```
586
598
 
599
+ #### ~~OpenClaw / ClawHub~~(已过时)
600
+
601
+ > ⚠️ ClawHub 安装方式已过时,不再支持。请使用上方的 Skills CLI 或手动安装。
602
+
587
603
  ### 更多工具
588
604
 
589
605
  - [bilibili-cli](https://github.com/jackwener/bilibili-cli) — Bilibili 视频、用户、搜索与动态 CLI
@@ -49,6 +49,7 @@ If `AUTH_NEEDED`, proceed to guide the user:
49
49
 
50
50
  Ensure user is logged into x.com in one of: Arc, Chrome, Edge, Firefox, Brave. twitter-cli auto-extracts cookies.
51
51
  All Chrome profiles are scanned automatically. To specify a profile: `TWITTER_CHROME_PROFILE="Profile 2" twitter feed`.
52
+ To prioritize a specific browser: `TWITTER_BROWSER=chrome twitter feed` (supported: arc, chrome, edge, firefox, brave).
52
53
 
53
54
  ```bash
54
55
  twitter whoami
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "twitter-cli"
7
- version = "0.8.2"
7
+ version = "0.8.4"
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"
@@ -61,6 +61,13 @@
61
61
  ]
62
62
  }
63
63
  },
64
+ "note_tweet": {
65
+ "note_tweet_results": {
66
+ "result": {
67
+ "text": "Hello\nworld\n\nThis is the full text of a long tweet that goes beyond the 280 character limit and contains additional content that would be hidden behind Show More in the Twitter UI."
68
+ }
69
+ }
70
+ },
64
71
  "views": {
65
72
  "count": "1234"
66
73
  }
@@ -135,7 +135,7 @@ def test_extract_via_subprocess_script_includes_arc(monkeypatch) -> None:
135
135
  cookies, diagnostics = auth._extract_via_subprocess()
136
136
 
137
137
  assert cookies is None
138
- assert '("arc", browser_cookie3.arc)' in seen["script"]
138
+ assert '"arc": browser_cookie3.arc' in seen["script"]
139
139
 
140
140
 
141
141
  def test_extract_via_subprocess_retries_uv_when_current_env_has_no_output(monkeypatch) -> None:
@@ -373,7 +373,7 @@ def test_get_cookies_includes_keychain_hint_in_error(monkeypatch) -> None:
373
373
 
374
374
  msg = str(exc_info.value)
375
375
  assert "security unlock-keychain" in msg
376
- assert "twitter doctor" in msg
376
+ assert "twitter -v" in msg
377
377
 
378
378
 
379
379
  def test_extract_in_process_returns_diagnostics_on_failure(monkeypatch) -> None:
@@ -19,22 +19,12 @@ def test_cli_user_command_works_with_client_factory(monkeypatch) -> None:
19
19
  def fetch_user(self, screen_name: str) -> UserProfile:
20
20
  return UserProfile(id="1", name="Alice", screen_name=screen_name)
21
21
 
22
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
22
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
23
23
  runner = CliRunner()
24
24
  result = runner.invoke(cli, ["user", "alice"])
25
25
  assert result.exit_code == 0
26
26
 
27
27
 
28
- def test_get_client_for_output_does_not_swallow_real_type_error(monkeypatch) -> None:
29
- def _broken_get_client(config=None, quiet=False):
30
- raise TypeError("real bug")
31
-
32
- monkeypatch.setattr("twitter_cli.cli._get_client", _broken_get_client)
33
-
34
- with pytest.raises(TypeError, match="real bug"):
35
- from twitter_cli.cli import _get_client_for_output
36
-
37
- _get_client_for_output({})
38
28
 
39
29
 
40
30
  def test_cli_feed_json_input_path(tmp_path, tweet_factory) -> None:
@@ -102,7 +92,7 @@ def test_print_tweet_table_full_text_shows_untruncated_text(tweet_factory) -> No
102
92
  def test_cli_commands_wrap_client_creation_errors(monkeypatch, args) -> None:
103
93
  monkeypatch.setattr(
104
94
  "twitter_cli.cli._get_client",
105
- lambda config=None: (_ for _ in ()).throw(RuntimeError("boom")),
95
+ lambda config=None, quiet=False: (_ for _ in ()).throw(RuntimeError("boom")),
106
96
  )
107
97
  runner = CliRunner()
108
98
 
@@ -117,7 +107,7 @@ def test_cli_user_error_yaml(monkeypatch) -> None:
117
107
  monkeypatch.setenv("OUTPUT", "auto")
118
108
  monkeypatch.setattr(
119
109
  "twitter_cli.cli._get_client",
120
- lambda config=None: (_ for _ in ()).throw(RuntimeError("User not found")),
110
+ lambda config=None, quiet=False: (_ for _ in ()).throw(RuntimeError("User not found")),
121
111
  )
122
112
  runner = CliRunner()
123
113
 
@@ -136,7 +126,7 @@ def test_cli_tweet_accepts_shared_url_with_query(monkeypatch) -> None:
136
126
  assert max_count == 50
137
127
  return []
138
128
 
139
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
129
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
140
130
  monkeypatch.setattr(
141
131
  "twitter_cli.cli.load_config",
142
132
  lambda: {"fetch": {"count": 50}, "filter": {}, "rateLimit": {}},
@@ -162,7 +152,7 @@ def test_cli_article_accepts_article_url_and_json(monkeypatch) -> None:
162
152
  article_text="Hello\n\n## Section",
163
153
  )
164
154
 
165
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
155
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
166
156
  monkeypatch.setattr(
167
157
  "twitter_cli.cli.load_config",
168
158
  lambda: {"fetch": {"count": 50}, "filter": {}, "rateLimit": {}},
@@ -195,7 +185,7 @@ def test_cli_article_markdown_output_and_save(monkeypatch, tmp_path) -> None:
195
185
  assert tweet_id == "12345"
196
186
  return article
197
187
 
198
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
188
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
199
189
  monkeypatch.setattr("twitter_cli.cli.load_config", lambda: {})
200
190
  output_path = tmp_path / "article.md"
201
191
  runner = CliRunner()
@@ -227,7 +217,7 @@ def test_cli_article_markdown_overrides_auto_structured_output(monkeypatch) -> N
227
217
  return article
228
218
 
229
219
  monkeypatch.setenv("OUTPUT", "auto")
230
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
220
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
231
221
  monkeypatch.setattr("twitter_cli.cli.load_config", lambda: {})
232
222
  runner = CliRunner()
233
223
 
@@ -254,7 +244,7 @@ def test_cli_bookmark_alias_works(monkeypatch) -> None:
254
244
  calls.append(tweet_id)
255
245
  return True
256
246
 
257
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
247
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
258
248
  runner = CliRunner()
259
249
 
260
250
  result = runner.invoke(cli, ["bookmark", "123"])
@@ -270,7 +260,7 @@ def test_cli_whoami_command(monkeypatch) -> None:
270
260
  def fetch_me(self) -> UserProfile:
271
261
  return UserProfile(id="42", name="Test User", screen_name="testuser")
272
262
 
273
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
263
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
274
264
  runner = CliRunner()
275
265
 
276
266
  result = runner.invoke(cli, ["whoami"])
@@ -289,7 +279,7 @@ def test_cli_whoami_auto_yaml(monkeypatch) -> None:
289
279
  return UserProfile(id="42", name="Test User", screen_name="testuser")
290
280
 
291
281
  monkeypatch.setenv("OUTPUT", "auto")
292
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
282
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
293
283
  runner = CliRunner()
294
284
 
295
285
  result = runner.invoke(cli, ["whoami"])
@@ -307,7 +297,7 @@ def test_cli_status_auto_yaml(monkeypatch) -> None:
307
297
  return UserProfile(id="42", name="Test User", screen_name="testuser")
308
298
 
309
299
  monkeypatch.setenv("OUTPUT", "auto")
310
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
300
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
311
301
  runner = CliRunner()
312
302
 
313
303
  result = runner.invoke(cli, ["status"])
@@ -328,7 +318,7 @@ def test_cli_reply_command(monkeypatch) -> None:
328
318
  calls.append({"text": text, "reply_to_id": reply_to_id})
329
319
  return "999"
330
320
 
331
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
321
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
332
322
  runner = CliRunner()
333
323
 
334
324
  result = runner.invoke(cli, ["reply", "12345", "Nice tweet!"])
@@ -345,7 +335,7 @@ def test_cli_quote_command(monkeypatch) -> None:
345
335
  calls.append({"tweet_id": tweet_id, "text": text})
346
336
  return "888"
347
337
 
348
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
338
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
349
339
  runner = CliRunner()
350
340
 
351
341
  result = runner.invoke(cli, ["quote", "12345", "Interesting!"])
@@ -361,7 +351,7 @@ def test_cli_post_json_output(monkeypatch) -> None:
361
351
  assert reply_to_id is None
362
352
  return "999"
363
353
 
364
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
354
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
365
355
  runner = CliRunner()
366
356
 
367
357
  result = runner.invoke(cli, ["post", "hello", "--json"])
@@ -378,7 +368,7 @@ def test_cli_like_yaml_output(monkeypatch) -> None:
378
368
  assert tweet_id == "123"
379
369
  return True
380
370
 
381
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
371
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
382
372
  runner = CliRunner()
383
373
 
384
374
  result = runner.invoke(cli, ["like", "123", "--yaml"])
@@ -399,7 +389,7 @@ def test_cli_follow_json_output(monkeypatch) -> None:
399
389
  assert user_id == "42"
400
390
  return True
401
391
 
402
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
392
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
403
393
  runner = CliRunner()
404
394
 
405
395
  result = runner.invoke(cli, ["follow", "alice", "--json"])
@@ -421,7 +411,7 @@ def test_cli_follow_command(monkeypatch) -> None:
421
411
  actions.append(("follow", user_id))
422
412
  return True
423
413
 
424
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
414
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
425
415
  runner = CliRunner()
426
416
 
427
417
  result = runner.invoke(cli, ["follow", "alice"])
@@ -440,7 +430,7 @@ def test_cli_unfollow_command(monkeypatch) -> None:
440
430
  actions.append(("unfollow", user_id))
441
431
  return True
442
432
 
443
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
433
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
444
434
  runner = CliRunner()
445
435
 
446
436
  result = runner.invoke(cli, ["unfollow", "alice"])
@@ -457,7 +447,7 @@ def test_cli_search_advanced_options(monkeypatch) -> None:
457
447
  captured["product"] = product
458
448
  return []
459
449
 
460
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
450
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
461
451
  monkeypatch.setattr(
462
452
  "twitter_cli.cli.load_config",
463
453
  lambda: {"fetch": {"count": 50}, "filter": {}, "rateLimit": {}},
@@ -492,7 +482,7 @@ def test_cli_search_operators_only_no_query(monkeypatch) -> None:
492
482
  captured["query"] = query
493
483
  return []
494
484
 
495
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: FakeClient())
485
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: FakeClient())
496
486
  monkeypatch.setattr(
497
487
  "twitter_cli.cli.load_config",
498
488
  lambda: {"fetch": {"count": 50}, "filter": {}, "rateLimit": {}},
@@ -513,7 +503,7 @@ def test_cli_search_empty_query_no_options() -> None:
513
503
 
514
504
 
515
505
  def test_cli_search_invalid_date_rejected(monkeypatch) -> None:
516
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: None)
506
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: None)
517
507
  runner = CliRunner()
518
508
 
519
509
  result = runner.invoke(cli, ["search", "python", "--since", "not-a-date"])
@@ -522,7 +512,7 @@ def test_cli_search_invalid_date_rejected(monkeypatch) -> None:
522
512
 
523
513
 
524
514
  def test_cli_search_rejects_reversed_date_range(monkeypatch) -> None:
525
- monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None: None)
515
+ monkeypatch.setattr("twitter_cli.cli._get_client", lambda config=None, quiet=False: None)
526
516
  runner = CliRunner()
527
517
 
528
518
  result = runner.invoke(cli, ["search", "python", "--since", "2026-03-02", "--until", "2026-03-01"])
@@ -26,6 +26,9 @@ def test_parse_home_timeline_fixture(fixture_loader) -> None:
26
26
  assert [tweet.id for tweet in tweets] == ["1", "20"]
27
27
  assert cursor == "cursor-bottom-1"
28
28
  assert tweets[0].media[0].type == "photo"
29
+ # note_tweet full text should be preferred over legacy.full_text for long tweets
30
+ assert "Show More" in tweets[0].text
31
+ assert tweets[0].text.startswith("Hello\nworld\n")
29
32
  assert tweets[0].urls == ["https://example.com/post"]
30
33
  assert tweets[1].is_retweet is True
31
34
  assert tweets[1].retweeted_by == "bob"
@@ -193,6 +193,20 @@ _CHROMIUM_BASE_DIRS: Dict[str, str] = {
193
193
  "brave": os.path.join("BraveSoftware", "Brave-Browser"),
194
194
  }
195
195
 
196
+ # Default browser order for cookie extraction
197
+ _DEFAULT_BROWSER_ORDER = ["arc", "chrome", "edge", "firefox", "brave"]
198
+
199
+
200
+ def _get_browser_order() -> List[str]:
201
+ """Return browser extraction order, respecting TWITTER_BROWSER env var."""
202
+ env = os.environ.get("TWITTER_BROWSER", "").strip().lower()
203
+ if not env:
204
+ return _DEFAULT_BROWSER_ORDER
205
+ if env not in {"arc", "chrome", "edge", "firefox", "brave"}:
206
+ logger.warning("TWITTER_BROWSER='%s' is invalid, using default order", env)
207
+ return _DEFAULT_BROWSER_ORDER
208
+ return [env] + [b for b in _DEFAULT_BROWSER_ORDER if b != env]
209
+
196
210
 
197
211
  def _iter_chrome_cookie_files(browser_name: str) -> List[str]:
198
212
  """Return cookie file paths for all Chrome profiles.
@@ -262,17 +276,18 @@ def _extract_in_process() -> Tuple[Optional[Dict[str, str]], List[str]]:
262
276
  logger.debug("browser_cookie3 not installed, skipping in-process extraction")
263
277
  return None, ["browser-cookie3 not installed"]
264
278
 
265
- browsers = [
266
- ("arc", browser_cookie3.arc),
267
- ("chrome", browser_cookie3.chrome),
268
- ("edge", browser_cookie3.edge),
269
- ("firefox", browser_cookie3.firefox),
270
- ("brave", browser_cookie3.brave),
271
- ]
279
+ browser_fns = {
280
+ "arc": browser_cookie3.arc,
281
+ "chrome": browser_cookie3.chrome,
282
+ "edge": browser_cookie3.edge,
283
+ "firefox": browser_cookie3.firefox,
284
+ "brave": browser_cookie3.brave,
285
+ }
272
286
  attempts: List[str] = []
273
287
  diagnostics: List[str] = []
274
288
 
275
- for name, fn in browsers:
289
+ for name in _get_browser_order():
290
+ fn = browser_fns[name]
276
291
  if name in _CHROMIUM_BASE_DIRS:
277
292
  # Chromium-based: iterate all profiles
278
293
  cookie_files = _iter_chrome_cookie_files(name)
@@ -398,16 +413,23 @@ def extract_from_jar(jar, name, profile=""):
398
413
  return result
399
414
  return None
400
415
 
401
- browsers = [
402
- ("arc", browser_cookie3.arc),
403
- ("chrome", browser_cookie3.chrome),
404
- ("edge", browser_cookie3.edge),
405
- ("firefox", browser_cookie3.firefox),
406
- ("brave", browser_cookie3.brave),
407
- ]
416
+ DEFAULT_ORDER = ["arc", "chrome", "edge", "firefox", "brave"]
417
+ env_browser = os.environ.get("TWITTER_BROWSER", "").strip().lower()
418
+ if env_browser in {"arc", "chrome", "edge", "firefox", "brave"}:
419
+ browser_order = [env_browser] + [b for b in DEFAULT_ORDER if b != env_browser]
420
+ else:
421
+ browser_order = DEFAULT_ORDER
422
+ browser_fns = {
423
+ "arc": browser_cookie3.arc,
424
+ "chrome": browser_cookie3.chrome,
425
+ "edge": browser_cookie3.edge,
426
+ "firefox": browser_cookie3.firefox,
427
+ "brave": browser_cookie3.brave,
428
+ }
408
429
  attempts = []
409
430
 
410
- for name, fn in browsers:
431
+ for name in browser_order:
432
+ fn = browser_fns[name]
411
433
  if name in CHROMIUM_BASE_DIRS:
412
434
  cookie_files = iter_cookie_files(name)
413
435
  if not cookie_files:
@@ -584,7 +606,7 @@ def get_cookies() -> Dict[str, str]:
584
606
  lines.append("Option 1: Set TWITTER_AUTH_TOKEN and TWITTER_CT0 environment variables")
585
607
  lines.append("Option 2: Make sure you are logged into x.com in your browser (Arc/Chrome/Edge/Firefox/Brave)")
586
608
  lines.append("")
587
- lines.append("Run 'twitter doctor' for full diagnostics.")
609
+ lines.append("Run 'twitter -v <command>' for debug diagnostics.")
588
610
  raise RuntimeError("\n".join(lines))
589
611
 
590
612
  # Verify only for explicit auth failures; transient endpoint issues are tolerated.
@@ -31,9 +31,7 @@ Write commands:
31
31
  from __future__ import annotations
32
32
 
33
33
  import logging
34
- import os
35
34
  import re
36
- import inspect
37
35
  import sys
38
36
  import time
39
37
  import urllib.parse
@@ -154,17 +152,7 @@ def _get_client(config=None, quiet=False):
154
152
  )
155
153
 
156
154
 
157
- def _get_client_for_output(config=None, quiet=False):
158
- # type: (Optional[Dict[str, Any]], bool) -> TwitterClient
159
- """Call _get_client while staying compatible with monkeypatched legacy signatures."""
160
- try:
161
- signature = inspect.signature(_get_client)
162
- except (TypeError, ValueError):
163
- signature = None
164
155
 
165
- if signature and "quiet" in signature.parameters:
166
- return _get_client(config, quiet=quiet)
167
- return _get_client(config)
168
156
 
169
157
 
170
158
  def _exit_with_error(exc):
@@ -418,7 +406,7 @@ def feed(ctx, feed_type, max_count, as_json, as_yaml, input_file, output_file, d
418
406
  console.print(" Loaded %d tweets" % len(tweets))
419
407
  else:
420
408
  fetch_count = _resolve_configured_count(config, max_count)
421
- client = _get_client_for_output(config, quiet=not rich_output)
409
+ client = _get_client(config, quiet=not rich_output)
422
410
  label = "following feed" if feed_type == "following" else "home timeline"
423
411
  if rich_output:
424
412
  console.print("📡 Fetching %s (%d tweets)...\n" % (label, fetch_count))
@@ -508,7 +496,7 @@ def user(screen_name, as_json, as_yaml):
508
496
  config = load_config()
509
497
  try:
510
498
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml)
511
- client = _get_client_for_output(config, quiet=not rich_output)
499
+ client = _get_client(config, quiet=not rich_output)
512
500
  if rich_output:
513
501
  console.print("👤 Fetching user @%s..." % screen_name)
514
502
  profile = client.fetch_user(screen_name)
@@ -535,7 +523,7 @@ def user_posts(ctx, screen_name, max_count, as_json, as_yaml, output_file, full_
535
523
  config = load_config()
536
524
  def _run():
537
525
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=compact)
538
- client = _get_client_for_output(config, quiet=not rich_output)
526
+ client = _get_client(config, quiet=not rich_output)
539
527
  if rich_output:
540
528
  console.print("👤 Fetching @%s's profile..." % screen_name)
541
529
  profile = client.fetch_user(screen_name)
@@ -620,7 +608,7 @@ def search(ctx, query, product, from_user, to_user, lang, since, until, has, exc
620
608
  config = load_config()
621
609
  def _run():
622
610
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=compact)
623
- client = _get_client_for_output(config, quiet=not rich_output)
611
+ client = _get_client(config, quiet=not rich_output)
624
612
  _fetch_and_display(
625
613
  lambda count: client.fetch_search(composed_query, count, product),
626
614
  "'%s' (%s)" % (composed_query, product), "🔍", max_count, as_json, as_yaml, output_file, do_filter, config,
@@ -649,7 +637,7 @@ def likes(ctx, screen_name, max_count, as_json, as_yaml, output_file, do_filter,
649
637
  config = load_config()
650
638
  def _run():
651
639
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=compact)
652
- client = _get_client_for_output(config, quiet=not rich_output)
640
+ client = _get_client(config, quiet=not rich_output)
653
641
  if rich_output:
654
642
  console.print("👤 Fetching @%s's profile..." % screen_name)
655
643
  profile = client.fetch_user(screen_name)
@@ -695,7 +683,7 @@ def tweet(ctx, tweet_id, max_count, full_text, as_json, as_yaml):
695
683
  config = load_config()
696
684
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=compact)
697
685
  try:
698
- client = _get_client_for_output(config, quiet=not rich_output)
686
+ client = _get_client(config, quiet=not rich_output)
699
687
  if rich_output:
700
688
  console.print("🐦 Fetching tweet %s...\n" % tweet_id)
701
689
  start = time.time()
@@ -759,7 +747,7 @@ def show(ctx, index, max_count, full_text, output_file, as_json, as_yaml):
759
747
  config = load_config()
760
748
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=compact)
761
749
  try:
762
- client = _get_client_for_output(config, quiet=not rich_output)
750
+ client = _get_client(config, quiet=not rich_output)
763
751
  if rich_output:
764
752
  console.print("🐦 Fetching tweet #%d (id: %s)...\n" % (index, tweet_id))
765
753
  start = time.time()
@@ -797,7 +785,7 @@ def article(ctx, tweet_id, as_json, as_yaml, as_markdown, output_file):
797
785
  config = load_config()
798
786
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml, compact=False) and not as_markdown
799
787
  try:
800
- client = _get_client_for_output(config, quiet=not rich_output)
788
+ client = _get_client(config, quiet=not rich_output)
801
789
  if rich_output:
802
790
  console.print("📰 Fetching article %s...\n" % tweet_id)
803
791
  start = time.time()
@@ -857,7 +845,7 @@ def followers(screen_name, max_count, as_json, as_yaml):
857
845
  config = load_config()
858
846
  try:
859
847
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml)
860
- client = _get_client_for_output(config, quiet=not rich_output)
848
+ client = _get_client(config, quiet=not rich_output)
861
849
  if rich_output:
862
850
  console.print("👤 Fetching @%s's profile..." % screen_name)
863
851
  profile = client.fetch_user(screen_name)
@@ -890,7 +878,7 @@ def following(screen_name, max_count, as_json, as_yaml):
890
878
  config = load_config()
891
879
  try:
892
880
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml)
893
- client = _get_client_for_output(config, quiet=not rich_output)
881
+ client = _get_client(config, quiet=not rich_output)
894
882
  if rich_output:
895
883
  console.print("👤 Fetching @%s's profile..." % screen_name)
896
884
  profile = client.fetch_user(screen_name)
@@ -1063,7 +1051,7 @@ def status(as_json, as_yaml):
1063
1051
  config = load_config()
1064
1052
  try:
1065
1053
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml)
1066
- client = _get_client_for_output(config, quiet=not rich_output)
1054
+ client = _get_client(config, quiet=not rich_output)
1067
1055
  profile = client.fetch_me()
1068
1056
  except RuntimeError as exc:
1069
1057
  payload = error_payload("not_authenticated", str(exc))
@@ -1088,7 +1076,7 @@ def whoami(as_json, as_yaml):
1088
1076
  config = load_config()
1089
1077
  try:
1090
1078
  rich_output = use_rich_output(as_json=as_json, as_yaml=as_yaml)
1091
- client = _get_client_for_output(config, quiet=not rich_output)
1079
+ client = _get_client(config, quiet=not rich_output)
1092
1080
  if rich_output:
1093
1081
  console.print("👤 Fetching current user...")
1094
1082
  profile = client.fetch_me()
@@ -1230,135 +1218,6 @@ def unbookmark(tweet_id, as_json, as_yaml):
1230
1218
  _write_action("🔖", "Removing bookmark", "unbookmark_tweet", tweet_id, as_json=as_json, as_yaml=as_yaml)
1231
1219
 
1232
1220
 
1233
- @cli.command(name="doctor")
1234
- @structured_output_options
1235
- def doctor(as_json, as_yaml):
1236
- # type: (bool, bool) -> None
1237
- """Run diagnostics for cookie extraction and authentication.
1238
-
1239
- Useful for troubleshooting auth issues and for pasting into bug reports.
1240
- """
1241
- import platform
1242
-
1243
- from .auth import (
1244
- _diagnose_keychain_issues,
1245
- _extract_in_process,
1246
- _extract_via_subprocess,
1247
- load_from_env,
1248
- verify_cookies,
1249
- )
1250
-
1251
- info: Dict[str, Any] = {}
1252
- mode = _structured_mode(as_json=as_json, as_yaml=as_yaml)
1253
-
1254
- # -- System info --
1255
- info["version"] = __version__
1256
- info["python"] = sys.version.split()[0]
1257
- info["platform"] = platform.platform()
1258
- info["os"] = sys.platform
1259
-
1260
- # -- Environment --
1261
- is_ssh = bool(
1262
- os.environ.get("SSH_CLIENT")
1263
- or os.environ.get("SSH_TTY")
1264
- or os.environ.get("SSH_CONNECTION")
1265
- )
1266
- info["ssh_session"] = is_ssh
1267
- info["env_auth_token_set"] = bool(os.environ.get("TWITTER_AUTH_TOKEN"))
1268
- info["env_ct0_set"] = bool(os.environ.get("TWITTER_CT0"))
1269
- info["chrome_profile_override"] = os.environ.get("TWITTER_CHROME_PROFILE", "")
1270
-
1271
- # -- Cookie extraction --
1272
- env_cookies = load_from_env()
1273
- info["env_cookies"] = "found" if env_cookies else "not set"
1274
-
1275
- # In-process extraction
1276
- in_proc_cookies, in_proc_diag = _extract_in_process()
1277
- info["in_process"] = {
1278
- "status": "ok" if in_proc_cookies else "failed",
1279
- "diagnostics": in_proc_diag,
1280
- }
1281
-
1282
- # Subprocess extraction
1283
- sub_cookies, sub_diag = _extract_via_subprocess()
1284
- info["subprocess"] = {
1285
- "status": "ok" if sub_cookies else "failed",
1286
- "diagnostics": sub_diag,
1287
- }
1288
-
1289
- # Combined diagnostics
1290
- all_diag = in_proc_diag + sub_diag
1291
- cookies = in_proc_cookies or sub_cookies or env_cookies
1292
-
1293
- # Keychain hint
1294
- hint = _diagnose_keychain_issues(all_diag)
1295
- if hint:
1296
- info["keychain_hint"] = hint
1297
-
1298
- # Verification
1299
- if cookies:
1300
- try:
1301
- result = verify_cookies(
1302
- cookies["auth_token"],
1303
- cookies["ct0"],
1304
- cookies.get("cookie_string"),
1305
- )
1306
- info["verification"] = "ok"
1307
- info["screen_name"] = result.get("screen_name", "")
1308
- except RuntimeError as exc:
1309
- info["verification"] = "failed: %s" % exc
1310
- else:
1311
- info["verification"] = "skipped (no cookies)"
1312
-
1313
- # -- Output --
1314
- if _emit_mode_payload(info, mode):
1315
- return
1316
-
1317
- console.print("\n🩺 [bold]twitter-cli doctor[/bold]\n")
1318
- console.print(" Version: %s" % info["version"])
1319
- console.print(" Python: %s" % info["python"])
1320
- console.print(" Platform: %s" % info["platform"])
1321
- console.print(" SSH session: %s" % ("yes ⚠️" if is_ssh else "no"))
1322
- console.print()
1323
-
1324
- console.print("[bold]Environment:[/bold]")
1325
- console.print(" TWITTER_AUTH_TOKEN: %s" % ("set ✅" if info["env_auth_token_set"] else "not set"))
1326
- console.print(" TWITTER_CT0: %s" % ("set ✅" if info["env_ct0_set"] else "not set"))
1327
- if info["chrome_profile_override"]:
1328
- console.print(" TWITTER_CHROME_PROFILE: %s" % info["chrome_profile_override"])
1329
- console.print()
1330
-
1331
- console.print("[bold]Cookie Extraction:[/bold]")
1332
- in_status = info["in_process"]["status"]
1333
- console.print(
1334
- " In-process: %s" % ("[green]ok ✅[/green]" if in_status == "ok" else "[red]failed ❌[/red]")
1335
- )
1336
- for d in info["in_process"]["diagnostics"]:
1337
- console.print(" [dim]• %s[/dim]" % d)
1338
-
1339
- sub_status = info["subprocess"]["status"]
1340
- console.print(
1341
- " Subprocess: %s" % ("[green]ok ✅[/green]" if sub_status == "ok" else "[red]failed ❌[/red]")
1342
- )
1343
- for d in info["subprocess"]["diagnostics"]:
1344
- console.print(" [dim]• %s[/dim]" % d)
1345
- console.print()
1346
-
1347
- if hint:
1348
- console.print("[yellow]💡 Hint:[/yellow]")
1349
- for line in hint.splitlines():
1350
- console.print(" [yellow]%s[/yellow]" % line)
1351
- console.print()
1352
-
1353
- v = info["verification"]
1354
- if v == "ok":
1355
- screen = info.get("screen_name", "")
1356
- console.print("[green]✅ Authentication: OK[/green]%s" % (" (@%s)" % screen if screen else ""))
1357
- elif v.startswith("failed"):
1358
- console.print("[red]❌ Authentication: %s[/red]" % v)
1359
- else:
1360
- console.print("[yellow]⚠️ Authentication: %s[/yellow]" % v)
1361
- console.print()
1362
1221
 
1363
1222
 
1364
1223
  if __name__ == "__main__":
@@ -76,8 +76,6 @@ def get_accept_language():
76
76
  # type: () -> str
77
77
  tag = _get_locale_tag()
78
78
  language = tag.split("-", 1)[0] or "en"
79
- if tag == language:
80
- return "%s,%s;q=0.9,en;q=0.8" % (tag, language)
81
79
  return "%s,%s;q=0.9,en;q=0.8" % (tag, language)
82
80
 
83
81
 
@@ -128,7 +128,7 @@ def print_tweet_detail(tweet: Tweet, console: Optional[Console] = None) -> None:
128
128
  qt = tweet.quoted_tweet
129
129
  body_parts.append("")
130
130
  body_parts.append("┌── Quoted @%s ──" % qt.author.screen_name)
131
- body_parts.append(qt.text[:200])
131
+ body_parts.append(qt.text)
132
132
 
133
133
  body_parts.append("")
134
134
  body_parts.append(
@@ -246,9 +246,12 @@ def parse_tweet_result(result, depth=0):
246
246
  if is_retweet:
247
247
  retweeted_by = user_core.get("screen_name") or user_legacy.get("screen_name", "unknown")
248
248
 
249
+ # Prefer note_tweet full text for long tweets ("Show More")
250
+ note_text = _deep_get(actual_data, "note_tweet", "note_tweet_results", "result", "text")
251
+
249
252
  return Tweet(
250
253
  id=actual_data.get("rest_id", ""),
251
- text=actual_legacy.get("full_text", ""),
254
+ text=note_text or actual_legacy.get("full_text", ""),
252
255
  author=author,
253
256
  metrics=Metrics(
254
257
  likes=_parse_int(actual_legacy.get("favorite_count"), 0),
@@ -609,7 +609,7 @@ wheels = [
609
609
 
610
610
  [[package]]
611
611
  name = "twitter-cli"
612
- version = "0.8.2"
612
+ version = "0.8.4"
613
613
  source = { editable = "." }
614
614
  dependencies = [
615
615
  { name = "beautifulsoup4" },
@@ -1,127 +0,0 @@
1
- name: Publish to ClawHub
2
-
3
- on:
4
- push:
5
- tags:
6
- - "v*"
7
- workflow_dispatch:
8
-
9
- jobs:
10
- publish:
11
- runs-on: ubuntu-latest
12
- permissions:
13
- contents: read
14
- env:
15
- CLAWHUB_SLUG: twitter-cli
16
- CLAWHUB_NAME: twitter-cli
17
-
18
- steps:
19
- - uses: actions/checkout@v4
20
-
21
- - uses: actions/setup-node@v4
22
- with:
23
- node-version: "20"
24
-
25
- - name: Install ClawHub CLI
26
- run: npm install -g clawhub@0.7.0
27
-
28
- - name: Publish to ClawHub
29
- env:
30
- CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }}
31
- run: |
32
- if [ -z "${CLAWHUB_TOKEN:-}" ]; then
33
- echo "Missing required secret: CLAWHUB_TOKEN"
34
- exit 1
35
- fi
36
-
37
- if [ "${GITHUB_REF_TYPE:-}" = "tag" ] && [ -n "${GITHUB_REF_NAME:-}" ]; then
38
- VERSION="${GITHUB_REF_NAME#v}"
39
- else
40
- VERSION="$(sed -n 's/^version = \"\([^\"]*\)\"/\1/p' pyproject.toml | head -n 1)"
41
- fi
42
- if [ -z "${VERSION:-}" ]; then
43
- echo "Unable to resolve version"
44
- exit 1
45
- fi
46
- echo "Publishing ${CLAWHUB_SLUG}@${VERSION}"
47
-
48
- if clawhub --no-input inspect "${CLAWHUB_SLUG}" --version "${VERSION}" >/dev/null 2>&1; then
49
- echo "Version ${VERSION} already exists on ClawHub, skipping publish."
50
- exit 0
51
- fi
52
-
53
- clawhub --no-input login --token "${CLAWHUB_TOKEN}" --no-browser
54
- export VERSION
55
-
56
- # Workaround: clawhub@0.7.0 publish doesn't send acceptLicenseTerms,
57
- # which the server now requires. Use a Node.js script to publish with
58
- # the corrected payload.
59
- # Note: NODE_TLS_REJECT_UNAUTHORIZED=0 is needed because api.clawhub.io
60
- # has an expired SSL certificate. Remove once ClawHub renews their cert.
61
- NODE_TLS_REJECT_UNAUTHORIZED=0 node - <<'PUBLISH_SCRIPT'
62
- const { resolve } = require("path");
63
- const { readFileSync, statSync, readdirSync } = require("fs");
64
- const folder = resolve(".");
65
- const slug = process.env.CLAWHUB_SLUG;
66
- const version = process.env.VERSION;
67
-
68
- // Collect text files (same logic as clawhub CLI)
69
- function walk(dir, base = "") {
70
- let files = [];
71
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
72
- const rel = base ? base + "/" + entry.name : entry.name;
73
- if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
74
- if (entry.isDirectory()) { files.push(...walk(dir + "/" + entry.name, rel)); }
75
- else { files.push({ rel, abs: dir + "/" + entry.name }); }
76
- }
77
- return files;
78
- }
79
- const files = walk(folder).filter(f => {
80
- const ext = f.rel.split(".").pop().toLowerCase();
81
- return ["md","txt","py","toml","yml","yaml","json","cfg","ini","sh","bat"].includes(ext);
82
- });
83
-
84
- const payload = JSON.stringify({
85
- slug,
86
- displayName: slug,
87
- version,
88
- changelog: "Release " + version,
89
- tags: ["latest"],
90
- acceptLicenseTerms: true,
91
- });
92
-
93
- const form = new FormData();
94
- form.set("payload", payload);
95
- for (const file of files) {
96
- const bytes = readFileSync(file.abs);
97
- const blob = new Blob([bytes], { type: "text/plain" });
98
- form.append("files", blob, file.rel);
99
- }
100
-
101
- // Read registry and token from clawhub config
102
- const os = require("os");
103
- const configPath = resolve(os.homedir(), ".config", "clawhub", "config.json");
104
- let token = "";
105
- try {
106
- const cfg = JSON.parse(readFileSync(configPath, "utf8"));
107
- token = cfg.token || "";
108
- } catch {}
109
- if (!token) { console.error("No token found"); process.exit(1); }
110
-
111
- const registry = "https://clawhub.ai";
112
- fetch(registry + "/api/v1/skills", {
113
- method: "POST",
114
- headers: { Authorization: "Bearer " + token },
115
- body: form,
116
- }).then(async (r) => {
117
- const text = await r.text();
118
- if (!r.ok) {
119
- console.error("Publish failed:", r.status, text);
120
- process.exit(1);
121
- }
122
- console.log("✔ Published", slug + "@" + version);
123
- }).catch((e) => {
124
- console.error(e);
125
- process.exit(1);
126
- });
127
- PUBLISH_SCRIPT
File without changes
File without changes
File without changes
File without changes