Commit Graph

43 Commits

Author SHA1 Message Date
jackwener
0b91e66998 fix(windows): add ensure_utf8_streams() for Windows GBK encoding + ConPTY docs
- Add ensure_utf8_streams() in output.py: reconfigures stdout/stderr to UTF-8
  on Windows at CLI startup, fixing emoji UnicodeEncodeError on GBK locales
- Call ensure_utf8_streams() in cli() entry point — one-line fix for all
  output paths (click.echo, rich Console, print)
- Add Windows ConPTY troubleshooting to README (English + Chinese):
  document Git Bash workaround, ConPTY pipe capture issue, and encoding notes

Ref: #29 (issuecomment-4065690862)
2026-03-16 17:59:33 +08:00
jackwener
07e7f83e6f chore: code review cleanup + bump v0.8.4
- Remove _get_client_for_output() compat shim (replaced by direct _get_client calls)
- Remove unused inspect import
- Fix redundant branch in constants.get_accept_language()
- Add TWITTER_BROWSER docs to README (en + zh)
- Update all test monkeypatch signatures
- Bump version to 0.8.4
2026-03-15 19:29:34 +08:00
jackwener
18721e7967 docs: deprecate ClawHub install method, recommend Skills CLI instead 2026-03-14 20:05:26 +08:00
jackwener
4b94b769ba docs: add npx skills install method for AI agent skill setup 2026-03-14 20:01:41 +08:00
jackwener
7de8ad0fbd refactor: remove doctor command 2026-03-14 13:41:59 +08:00
Pleasurecruise
5335516d57 feat: add show command with short-index cache
Persist last displayed tweet lists and allow opening a tweet by index.

- Add twitter_cli/cache.py: stores a short-index cache (~/.twitter-cli/last_results.json) with a 1h TTL and helpers to resolve index->tweet-id and cache size.
- Update twitter_cli/cli.py: save list results to cache, display a hint, and add `twitter show <N>` command which fetches a tweet by cached index and prints detail/replies (supports --full-text, --json, structured output, and max replies).
- Update README.md and SKILL.md to document the new `show` usage.
- Add .idea/ to .gitignore and bump package version in uv.lock to 0.8.0.

This change makes it easy to open items from the last feed/search without copying IDs.
2026-03-12 22:12:27 +00:00
jackwener
41d8ad676e docs: update README and SKILL.md with image upload support
- Add image upload to Features lists (EN + CN)
- Add --image/-i usage examples to Usage sections
- Add 'Post with images' agent workflow in SKILL.md
- Update Limitations: 'text only' → 'images only (no video yet)'
2026-03-13 02:03:03 +08:00
jackwener
7d1b519c85 fix: harden search validation and release v0.7.1 2026-03-13 01:04:29 +08:00
jakevin
79eadd2579 feat: add twitter article markdown command (#16) 2026-03-12 14:47:49 +08:00
jackwener
1313eb0be1 feat: add full-text option for tweet tables 2026-03-11 20:58:12 +08:00
jackwener
60e1e7c580 feat: improve cookie extraction diagnostics and add doctor command
- Add _diagnose_keychain_issues() for macOS Keychain/SSH detection
- Extraction functions now return (cookies, diagnostics) tuples
- Error messages include actionable Keychain hints (e.g. unlock-keychain)
- Add 'twitter doctor' diagnostic command for troubleshooting
- Enhance bug_report.yml with browser/access method/diagnostics fields
- Expand README troubleshooting (EN+CN) with Keychain/SSH solutions
- Add 5 new tests for Keychain diagnostics

Closes #11
2026-03-11 16:53:06 +08:00
jackwener
53a700ec60 feat: support Chrome multi-profile cookie extraction
Auto-iterates all Chrome/Arc/Edge/Brave profiles (Default, Profile 1,
Profile 2, ...) to find Twitter cookies. Falls back to the default
browser_cookie3 behavior when no profile dirs are found.

Set TWITTER_CHROME_PROFILE env var to specify a profile explicitly:
  TWITTER_CHROME_PROFILE='Profile 2' twitter feed

Closes #6
2026-03-11 12:53:25 +08:00
jackwener
84504b1477 docs: add upgrade instructions to README and SKILL.md 2026-03-11 12:43:51 +08:00
jackwener
e9efa11fa5 fix: warn when querying other users' likes (private since Jun 2024)
Twitter/X made all likes private since June 2024. The likes command now:
- Detects if the target user differs from the authenticated user
- Shows a clear warning that only your own likes are visible
- Updated SKILL.md and README.md with likes privacy limitation

Closes #8
2026-03-11 12:34:17 +08:00
jackwener
8505428264 docs: update cross-references (xhs-cli → xiaohongshu-cli) 2026-03-11 00:33:14 +08:00
jackwener
21b4c28d63 docs: update project structure in README (add graphql.py, parser.py, exceptions.py, output.py) 2026-03-10 23:45:14 +08:00
jackwener
9cf74abd56 feat: add integration smoke tests
CLI-level smoke tests using --yaml output against real Twitter API.
Default skipped via @pytest.mark.smoke marker + pyproject.toml addopts.
Run locally with: uv run pytest -m smoke -v
2026-03-10 22:26:46 +08:00
jackwener
fa6255f2ee docs: document structured output schema 2026-03-10 21:22:35 +08:00
jackwener
32d074dc9f feat: anti-detection hardening, transaction cache, article parsing, structured write output
Anti-detection:
- Add 6 sec-ch-ua-* Client Hints headers (arch, bitness, full-version, etc.)
- POST requests now send Referer: x.com/compose/post + Priority: u=1, i
- follow/unfollow REST adds include_profile_interstitial_type param

Performance:
- Transaction ID cache with 1h TTL (~/.twitter-cli/transaction_cache.json)
- resolve_user_id: auto-detect screen_name vs numeric user_id

Features:
- Twitter Article parsing: extract long-form content as Markdown
- Write operations emit structured JSON/YAML when piped or OUTPUT env set
  ActionResult: {success, action, id, url, ...}

84 tests passing
2026-03-10 20:48:42 +08:00
jackwener
250fca46f0 docs: add structured output guidance for AI agents 2026-03-10 15:47:06 +08:00
jackwener
d22a729fb9 docs: add related CLI project links 2026-03-10 14:15:35 +08:00
jackwener
d71ad45a0a fix: harden pagination auth and runtime headers 2026-03-10 12:33:04 +08:00
jackwener
19ab11d6a4 fix: harden auth flow and sync browser support docs 2026-03-10 11:02:34 +08:00
jackwener
bbe0bc8de3 docs: rename rt/unrt → retweet/unretweet, update SKILL.md + README.md
- Rename rt/unrt commands to retweet/unretweet for clarity
- SKILL.md: fix Python version, add --output/--filter examples, safety notes
- README.md: dynamic Chrome fingerprint, write delays, --output examples
- Sync Chinese section with English changes
2026-03-09 21:20:05 +08:00
jackwener
12f425abea feat: write operation delays, dynamic FEATURES update, 30+ client.py tests, fix README proxy wording 2026-03-09 20:45:51 +08:00
jackwener
94e21fba9a fix: remove unused requests import (CI lint), fix README wording, drop requests dep 2026-03-09 20:25:24 +08:00
jackwener
27b02578c8 docs: update README with anti-detection features, proxy support, and ban prevention tips 2026-03-09 19:17:01 +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
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
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
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
733ce4d5f9 docs: add xhs-cli and bilibili-cli recommendations to README header 2026-03-05 22:18:27 +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
1ca62d4635 chore: add pypi publish workflow and uv-first install docs 2026-03-05 16:16:00 +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