Commit Graph

32 Commits

Author SHA1 Message Date
jackwener
b83abadb73 feat: full cookie forwarding from browser and TWITTER_PROXY support 2026-03-09 19:12:06 +08:00
jackwener
27d73efee5 feat: anti-detection hardening with curl_cffi TLS impersonation and request jitter 2026-03-09 17:11:59 +08:00
jackwener
3e13ed3749 chore: bump version to 0.1.1 2026-03-09 12:28:45 +08:00
jackwener
b2603eb753 feat: update Chrome UA to 133 and add sec-ch-ua/Sec-Fetch headers for anti-detection 2026-03-09 12:04:26 +08:00
jackwener
df9b58ed0a docs: comprehensive SKILL.md rewrite — add install, all commands, patterns, error handling, safety notes 2026-03-09 01:38:51 +08:00
jackwener
0a7b6a6b78 fix: console output to stderr for clean --json output
- Change Console() to Console(stderr=True) so all status/progress
  messages go to stderr, keeping stdout pure JSON when --json is used
- Add missing exception handling in likes command for fetch_user
- Fix SKILL.md: favorite -> favorites (correct command name)
2026-03-08 22:37:00 +08:00
jackwener
2559549a84 refactor: rename CLI commands for consistency
- user-posts → tweets (remove only hyphenated command)
- rt → retweet (more readable)
- unrt → unretweet (more readable)

All commands now use full English words.
2026-03-08 14:05:36 +08:00
jackwener
215337ebec refactor: rename bookmark commands to favorite/unfavorite/favorites
- favorite <id>     → bookmark a tweet (was bookmark-add)
- unfavorite <id>    → remove bookmark (was bookmark-rm)
- favorites          → list all bookmarks (was favorite)

Consistent with like/unlike/likes naming pattern.
2026-03-08 14:00:38 +08:00
jackwener
d2d971c865 refactor: deep review fixes round 3
- client.py:
  - Remove dead _extract_cursor second branch (unreachable code)
  - Cache SSL context as module-level _SSL_CTX (avoid re-reading CA certs)
  - Add 404 stale-fallback retry to _graphql_post (parity with GET)
  - Remove dead core.get('name')/core.get('screen_name') in fetch_user
  - Set Content-Type: application/json only for POST requests
  - Rename _to_int → _parse_int for clarity vs config._as_int
  - Add 'not thread-safe' note on module-level caches

- cli.py:
  - _fetch_and_display now accepts optional config param (fix double load)
  - Refactor user_posts to use _fetch_and_display
  - Pass config to all _fetch_and_display callers

- pyproject.toml:
  - Move xclienttransaction/requests to optional [transaction] deps
  - Add beautifulsoup4 to [transaction] optional deps

- README.md:
  - Add rateLimit config section with comments
  - Add constants.py to project structure tree
2026-03-08 13:58:06 +08:00
jackwener
625181b76c refactor: fix remaining code review issues on kabi-use
- _get_client: remove useless try/except that re-raised same error
- verify_cookies: increase timeout from 3s to 5s
- fetch_user: use _deep_get for URL extraction (consistent with
  _parse_user_result)
- formatter: remove no-op tweets_to_json wrapper and unused import
- _as_int/_as_float: filter.py now imports from config.py (dedup)
- CLI read commands: extract _fetch_and_display() to dedup
  favorite/search/likes/list_timeline
- _write_action: move load_config inside try block
- auth.py: add PEP 8 blank line after logger
2026-03-07 21:49:12 +08:00
jackwener
df39a15d00 refactor: code review fixes
Bug fixes:
- _extract_cursor: only extract Bottom cursors, preventing Top cursor
  from corrupting pagination state
- _api_request: merge _api_get/_api_post into unified method — POST
  now has rate-limit code 88 retry (was missing)
- fetch_user_likes: add override_base_variables=True

Code quality:
- Extract BEARER_TOKEN and USER_AGENT into constants.py (was duped
  in auth.py and client.py)
- Add user_profile_to_dict/users_to_json for proper UserProfile
  serialization (followers/following JSON output was ad-hoc)
- Refactor 6 CLI write commands via _write_action helper
- Extract _extract_media and _extract_author from _parse_tweet_result
- Update CLI module docstring with all 18 commands
2026-03-07 20:30:59 +08:00
jackwener
6c73a9f0b6 fix: add fieldToggles support for TweetDetail
- TweetDetail requires fieldToggles (withArticleRichContentState: true)
  to populate tweet_results in entries — without it, server returns {}
- Add fieldToggles parameter throughout: _build_graphql_url, _graphql_get,
  _fetch_timeline
- Tested: tweet detail, followers, following, like — all working
2026-03-07 20:20:59 +08:00
jackwener
80499384c9 feat: add all remaining read/write endpoints
Read commands:
- twitter tweet <id>: view tweet detail + replies
- twitter list <id>: fetch list timeline
- twitter followers <name>: list user followers
- twitter following <name>: list user following

Write commands:
- twitter post <text>: create tweet (with --reply-to)
- twitter delete <id>: delete tweet
- twitter like/unlike <id>: manage likes
- twitter rt/unrt <id>: manage retweets
- twitter bookmark-add/bookmark-rm <id>: manage bookmarks

Infrastructure:
- _graphql_post + _api_post for write operations
- _fetch_user_list + _parse_user_result for user lists
- _deep_get now supports list index access
- _build_headers supports POST method for transaction ID
2026-03-07 20:07:10 +08:00
jackwener
767a466667 fix: add x-client-transaction-id header for search API
- Root cause: Twitter's SearchTimeline endpoint requires x-client-transaction-id
  header that HomeTimeline/Bookmarks don't enforce
- Integrate XClientTransaction library for header generation
- Add requests + beautifulsoup4 dependencies
- Fix SearchTimeline variables (override base timeline vars)
- Update FEATURES dict and fallback queryIds to match live x.com values
2026-03-07 19:53:55 +08:00
jackwener
b0866ed8d7 feat: add search and likes commands
- Add 'twitter search' command with --type (Top/Latest/Photos/Videos), --max, --json, --filter
- Add 'twitter likes' command to view tweets liked by a user
- Add SearchTimeline and Likes GraphQL operations with fallback queryIds
- Update README with new command examples (EN + CN)
2026-03-07 19:15:37 +08:00
jackwener
55c48b077b feat: add rate limiting, retry with backoff, and max count cap
- Add configurable request delay between paginated API calls (default 1.5s)
- Add retry with exponential backoff on HTTP 429 and Twitter error code 88
- Add hard max count cap (default 200, absolute ceiling 500)
- Add rateLimit config section with requestDelay, maxRetries, retryBaseDelay, maxCount
- Add normalization tests for rateLimit config
2026-03-07 19:02:49 +08:00
jackwener
0f26e20abb Revert npx skills install examples in README 2026-03-06 21:23:32 +08:00
jackwener
7146d60fda Remove preferred wording for npx skills install 2026-03-06 21:22:20 +08:00
jackwener
0df8f3af9b Improve skill metadata and npx skills docs 2026-03-06 21:16:29 +08:00
jackwener
cc65c74a53 ci make ClawHub publish workflow dispatch-safe 2026-03-06 00:08:39 +08:00
jackwener
c7570732c0 ci add auto publish to ClawHub on version tags 2026-03-06 00:06:52 +08:00
jackwener
733ce4d5f9 docs: add xhs-cli and bilibili-cli recommendations to README header 2026-03-05 22:18:27 +08:00
jackwener
81486e31d5 docs: add skill metadata frontmatter for ClawHub publish 2026-03-05 16:54:08 +08:00
jackwener
dc1a76ddbb docs: add AI skill and ClawHub sections with SKILL.md 2026-03-05 16:52:04 +08:00
jackwener
b1a0447523 docs: document scoring formula and filter modes in README 2026-03-05 16:33:58 +08:00
jackwener
05867556a4 docs: upgrade README with bilingual structure, badges, auth and troubleshooting 2026-03-05 16:29:06 +08:00
jackwener
34de425a4c ci: allow ci workflow to be reused by publish workflow 2026-03-05 16:21:47 +08:00
jackwener
1ca62d4635 chore: add pypi publish workflow and uv-first install docs 2026-03-05 16:16:00 +08:00
jackwener
6f322ff2d6 test+ci: add regression tests and GitHub Actions workflow 2026-03-05 16:14:05 +08:00
jackwener
4c08d09304 refactor: harden CLI/client/config and centralize serialization 2026-03-05 16:13:54 +08:00
jackwener
7238b932ab feat: add user commands, auto-detect browser, optimize performance
- Add user/user-posts/followers/following commands
- Add UserProfile model and GraphQL API methods
- Add print_user_profile and print_user_table formatters
- Auto-detect browser for cookies (Chrome → Edge → Firefox → Brave)
- Remove --browser option from all commands
- Remove cookie verification (v1.1 endpoints are gone)
- Use hardcoded fallback query IDs first (skip slow JS bundle scan)
- Update FEATURES from latest twitter-openapi config
- Fix user-posts: add required withVoice variable
- Add tweet URL links in feed output
- Add error handling to all user commands
2026-03-05 00:41:26 +08:00
jackwener
16752c3115 Initial commit: twitter-cli v0.1.0 2026-03-04 17:56:42 +08:00