Skip to content

feat: absorb community PRs, issue fixes, and x.com resilience updates - #106

Merged
jackwener merged 8 commits into
mainfrom
feat/absorb-community-prs
Nov 28, 2026
Merged

jackwener merged 8 commits into
mainfrom
feat/absorb-community-prs

Conversation

@jackwener

Copy link
Copy Markdown
Owner

Summary

Consolidates and cleanly integrates 30 open community PRs, 21 open issues, and recent x.com resilience practices from quangdang46/twitter_cli (twr) into 7 atomic, reviewed, and fully tested commits — preserving full Co-authored-by: attribution for every original contributor.

Commit Breakdown

  1. fix(deps,security): upgrade curl_cffi & xclienttransaction, owner-only cache, harden CI (a47589f)

  2. fix(graphql,tx): restore ClientTransaction bootstrap, refresh queryIds, fail-closed unsigned POSTs (a50aa90)

  3. feat(auth): support custom Chromium dirs, Vivaldi, Zen, TWITTER_COOKIE_STRING, and better diagnostics (d1125c6)

  4. feat(parser,model): rich tweet/user/media metadata, TweetDetail validation, article rich content, numeric user IDs (ed674be)

  5. feat(cli,config): pagination cap, --time, shell completion, user config, news, and doctor (a9c098f)

  6. feat(write): video upload, Premium long-form CreateNoteTweet, and article-publish (3ddca2d)

  7. feat(api,docs): export Python library API and update README, SKILL.md, SCHEMA.md (2e07af9)

    • Exports public Python library API (TwitterClient, get_cookies, load_config, filter_tweets, models, exceptions, serializers) from twitter_cli with import tests (fixes [feature] Extend your CLI tool as a Python library #9).
    • Updates README.md (English & Chinese), SKILL.md, and SCHEMA.md.

Intentionally Deferred (Follow-up Candidates)

Verification

  • uv run ruff check . — passed
  • uv run mypy twitter_cli — passed (0 issues across 20 source files)
  • TERM=xterm uv run pytest -q — 338 passed, 8 integration tests deselected
  • Live check (2026-11-27): verified curl_cffi 0.17.0 + xclienttransaction 1.0.3 bootstrap against https://x.com/i/jf/ resolves ondemand.s and generates valid x-client-transaction-id.

Contributors (Co-authored-by)

Co-authored-by: axsddlr axsddlr@users.noreply.github.com
Co-authored-by: Canc luca.canc@gmail.com
Co-authored-by: Stoner stoner@StonerdeMacBook-Air.local
Co-authored-by: Lucius chenyh572@gmail.com
Co-authored-by: Jawad Margieh J.margieh@gmail.com
Co-authored-by: Kage oxkage@users.noreply.github.com
Co-authored-by: Ahmed Elshaabany ahmed.elshaabany@gmail.com
Co-authored-by: Perry Huang perry@gnuhpc.org
Co-authored-by: LiuWei liuweixh@gmail.com
Co-authored-by: Abdurrahman Özkan ozkanabdurrahmann@gmail.com
Co-authored-by: Blacksuite larszx@outlook.com
Co-authored-by: GodfreyPrince GodfreyPrince@users.noreply.github.com
Co-authored-by: Mckgare0717 mckinnonrebello@gmail.com
Co-authored-by: RiriAgent ririagent@users.noreply.github.com
Co-authored-by: Aditya Gupta adityagupta2087@gmail.com
Co-authored-by: edwinbernadus bernadus.edwin@gmail.com
Co-authored-by: Li Chenxi me@ayayaya.org
Co-authored-by: kangxl 230263957+zh-xl-kang@users.noreply.github.com
Co-authored-by: Ankit Ranjan arstejas7@gmail.com
Co-authored-by: jollyroger1480 jollyroger1480@users.noreply.github.com
Co-authored-by: rakei076 rakei076@users.noreply.github.com
Co-authored-by: hhh2210 hzy2210@gmail.com
Co-authored-by: Trần Quang Đãng 91641923+quangdang46@users.noreply.github.com

jackwener and others added 8 commits November 27, 2026 18:12
…y cache, harden CI

- Raise curl_cffi floor to >=0.15.0 (resolves GHSA-qw2m-4pqf-rmpp / CVE-2026-33752, closes #100)
- Raise xclienttransaction floor to >=1.0.3 for X's numeric webpack module map
- Enforce owner-only permissions (0600 files / 0700 dir) on tweet and transaction caches
- Make auth path tests portable across POSIX/Windows
- Harden CI workflow (minimal permissions, concurrency, timeouts, ubuntu-24.04, Python 3.13)

Absorbs #102, #103, and dependency updates from #91/#93.

Co-authored-by: axsddlr <axsddlr@users.noreply.github.com>
Co-authored-by: Canc <luca.canc@gmail.com>
Co-authored-by: Stoner <stoner@StonerdeMacBook-Air.local>
…s, fail-closed unsigned POSTs

- Bootstrap ClientTransaction from authenticated https://x.com/home with
  unauthenticated fallback to https://x.com/i/jf/ (handles X's Vite x-web
  migration on anonymous / and /home) and never leak cookies to CDN assets
- Refresh FALLBACK_QUERY_IDS against current twitter-openapi IDs and add
  UserByRestId; support TWITTER_QID_<OP> env overrides and 24h owner-only
  disk cache for live-resolved queryIds
- Scan both responsive-web/client-web and x-web/x-web bundles (following
  ./assets/*.js chunks) via /i/jf/ and /
- Treat GraphQL "Query: Unspecified" / persisted-query-not-found errors as
  stale queryIds and retry once with live lookup on GET and POST (fixes #59)
- Fail closed on unsigned POST requests when x-client-transaction-id is
  unavailable (overrideable with TWITTER_ALLOW_UNSIGNED=1, mitigates #72)
- Prefer chrome136 TLS impersonation target when available in curl_cffi

Absorbs #74, #77, #79, #82, #83, #84, #86, #89, #90, #91, #93, #98, #99,
#101, and query-ID/transaction practices from quangdang46/twitter_cli.
Closes #59, #69, #73, #78, #88.

Co-authored-by: Lucius <chenyh572@gmail.com>
Co-authored-by: Canc <luca.canc@gmail.com>
Co-authored-by: Jawad Margieh <J.margieh@gmail.com>
Co-authored-by: Kage <oxkage@users.noreply.github.com>
Co-authored-by: Ahmed Elshaabany <ahmed.elshaabany@gmail.com>
Co-authored-by: Perry Huang <perry@gnuhpc.org>
Co-authored-by: LiuWei <liuweixh@gmail.com>
Co-authored-by: Abdurrahman Özkan <ozkanabdurrahmann@gmail.com>
Co-authored-by: Blacksuite <larszx@outlook.com>
Co-authored-by: GodfreyPrince <GodfreyPrince@users.noreply.github.com>
Co-authored-by: Mckgare0717 <mckinnonrebello@gmail.com>
Co-authored-by: Stoner <stoner@StonerdeMacBook-Air.local>
Co-authored-by: Trần Quang Đãng <91641923+quangdang46@users.noreply.github.com>
…E_STRING, and better diagnostics

- Support TWITTER_CHROMIUM_USER_DATA_DIR for ungoogled-chromium and custom
  Chromium profiles (discovers both Cookies and Network/Cookies, passes
  matching Local State key file, closes #61)
- Add Vivaldi and Zen browser cookie extraction (in-process + subprocess,
  with profiles.ini priority and Linux Flatpak/XDG discovery for Zen)
- Support TWITTER_COOKIE_STRING env var so headless/SigCLI/Windows users can
  supply a full cookie header without losing write/226 protection (#58)
- Improve Windows Chrome/Edge >=127 App-Bound Encryption diagnostics with
  actionable workarounds (addresses #28, #46, #66)

Absorbs #76, #92, #95, auth diagnostics from #104, and full-cookie env
support inspired by #58 and quangdang46/twitter_cli.

Co-authored-by: Lucius <chenyh572@gmail.com>
Co-authored-by: RiriAgent <ririagent@users.noreply.github.com>
Co-authored-by: Aditya Gupta <adityagupta2087@gmail.com>
Co-authored-by: axsddlr <axsddlr@users.noreply.github.com>
Co-authored-by: Trần Quang Đãng <91641923+quangdang46@users.noreply.github.com>
…ation, article rich content, numeric user IDs

- Add author followers/following counts (#57) and optional viewer follow
  state (viewerFollowing / viewerFollowedBy)
- Expose possiblySensitive and per-media warning labels (adultContent,
  graphicViolence, otherWarning) plus optional posterUrl, altText, and
  durationMs (#87 + quangdang46/twitter_cli)
- Expose thread relationship fields (conversationId, inReplyToStatusId,
  inReplyToUserId, inReplyToScreenName) and --cursor / pagination.nextCursor
  on `twitter tweet` (closes #105)
- Validate TweetDetail responses contain the requested focal tweet and
  order it first, returning structured not_found instead of empty success
  (closes #53)
- Support post-legacy UserByRestId shapes (profile_bio, website,
  relationship_counts, tweet_counts, action_counts) and accept numeric
  user IDs in fetch_user()
- Add Draft.js article rich content parsing (DIVIDER, TWEET, inline
  Bold/Italic/Code/Strikethrough with overlap-safe link rendering) and
  `twitter bookmarks --cursor` pagination

Absorbs #57, #70, #75, #87, and live-payload audit fixes from
quangdang46/twitter_cli. Closes #53, #105.

Co-authored-by: edwinbernadus <bernadus.edwin@gmail.com>
Co-authored-by: Lucius <chenyh572@gmail.com>
Co-authored-by: Li Chenxi <me@ayayaya.org>
Co-authored-by: kangxl <230263957+zh-xl-kang@users.noreply.github.com>
Co-authored-by: Trần Quang Đãng <91641923+quangdang46@users.noreply.github.com>
…ig, news, and doctor

- Raise user-list pagination safety ceiling to 10000 and honour explicit
  --max on followers/following instead of clamping to rateLimit.maxCount
  (closes #50)
- Resolve ~/.twitter-cli/config.yaml between cwd and package defaults
- Add root --time relative|absolute|iso option and display.time config
  (closes #35)
- Add `twitter completion bash|zsh|fish` using Click shell completion
  (closes #36)
- Add `twitter news` command for Explore > News stories (closes #47)
- Add `twitter doctor [--refresh]` diagnostic command (never leaks secrets)
- Normalize tweet URLs consistently across like/retweet/bookmark/delete

Absorbs #63, #104, and config/doctor/normalization practices from
quangdang46/twitter_cli. Closes #35, #36, #47, #50.

Co-authored-by: axsddlr <axsddlr@users.noreply.github.com>
Co-authored-by: Ankit Ranjan <arstejas7@gmail.com>
Co-authored-by: Trần Quang Đãng <91641923+quangdang46@users.noreply.github.com>
…icle-publish

- Support chunked video upload (tweet_video, up to 512 MB, 4 MB APPEND
  chunks, async STATUS polling) and add --video / -V to post, reply, and
  quote (closes #13)
- Add twitter-text v3 weighted character counting and automatic
  CreateNoteTweet routing for posts/quotes exceeding 280 weighted chars
  (closes #54)
- Add `twitter article-publish <file.md> --title ... [--draft]` with
  Markdown-to-Draft.js conversion

Absorbs #60, #62, #64, #65, #96. Closes #13, #54.

Co-authored-by: jollyroger1480 <jollyroger1480@users.noreply.github.com>
Co-authored-by: rakei076 <rakei076@users.noreply.github.com>
Co-authored-by: hhh2210 <hzy2210@gmail.com>
…, SCHEMA.md

- Export clean public Python library API from twitter_cli.__init__ (TwitterClient,
  get_cookies, load_config, filter_tweets, models, exceptions, serializers) and
  add import-surface tests (addresses #9).
- Document updated structured output fields in SCHEMA.md (possiblySensitive, media
  sensitivity/poster/altText/durationMs, author followers/following & viewer follow
  flags, thread metadata, bookmarks/tweet nextCursor, news, doctor, article-publish).
- Update README.md (English & Chinese) and SKILL.md for all newly absorbed features,
  browsers, auth methods, environment variables, and Python 3.10–3.13 CI matrix.

Co-authored-by: axsddlr <axsddlr@users.noreply.github.com>
Co-authored-by: hhh2210 <hzy2210@gmail.com>
Co-authored-by: Lucius <chenyh572@gmail.com>
Co-authored-by: RiriAgent <ririagent@users.noreply.github.com>
Co-authored-by: Aditya Gupta <adityagupta2087@gmail.com>
Co-authored-by: Li Chenxi <me@ayayaya.org>
Co-authored-by: Trần Quang Đãng <91641923+quangdang46@users.noreply.github.com>
…parser/text edge cases, and docs

Addresses findings from full adversarial code review of PR #106:

- Cache security (`cache.py`, `client.py`, `graphql.py`): replace in-place truncating
  writes with atomic `O_CREAT | O_EXCL | O_NOFOLLOW` sibling temp file + `os.replace`,
  create cache dirs with `0o700`, and preserve `created_at` on incremental queryId
  disk merges while replacing cleanly on `refresh_query_ids()`.
- GraphQL & ClientTransaction (`graphql.py`, `client.py`): pass `exclude_ids` on stale
  queryId retries so lagged `twitter-openapi` IDs fall through to live `_scan_bundles`;
  anchor Vite `x-web` asset URLs to `/x-web/x-web/` (fixes `/assets/assets/` 404);
  recognize HTTP 400 stale-query errors; prefer unauthenticated `/i/jf/` first, validate
  `ClientTransaction(...)` inside the candidate loop, and avoid caching authenticated
  `/home` HTML on disk.
- TweetDetail, media upload & deeplinks (`client.py`): return `([], None)` when
  `count <= 0` with `return_cursor=True`; place focal tweet first before slicing to
  `count` so replies with ancestors don't raise false `NotFoundError`; restore
  `tweet_gif` category + `STATUS` polling for GIFs; allowlist mp4/mov/webm video MIME
  types; reject 0-byte uploads; lower video chunk size to 2 MB (under 5 MB base64 cap);
  use `time.monotonic()` and guard `check_after_secs: null` in `STATUS` polling; fix
  `twitter://trending/<id>?...` and `twitter://search?...` deeplink parsing.
- Auth (`auth.py`): sanitize `TWITTER_COOKIE_STRING` (`Cookie:` prefix, CR/LF, quotes)
  and rebuild cookie header when `TWITTER_AUTH_TOKEN`/`TWITTER_CT0` override or
  supplement it; add Flatpak `config/zen` path & normalize Windows Zen paths; check
  profile parent `Local State` first and try Chromium-family keychain loaders on
  non-Windows for `TWITTER_CHROMIUM_USER_DATA_DIR`; detect Windows DPAPI errors.
- Parser, text, article & formatter (`parser.py`, `text.py`, `article.py`, `formatter.py`):
  map Draft.js UTF-16 code unit offsets to Python indices so emoji + links/styles
  round-trip cleanly; guard `null` nested user dicts & strings; restrict bare-URL
  matching to ASCII hostnames with common IANA TLDs (prevents `config.yaml`/`cli.py`
  misrouting to `CreateNoteTweet`); refine `©`/`®`, Geometric Shapes emoji, and
  repeated trailing URL trimming; support `###` headings, balanced-paren link URLs,
  inline-code/image/math preservation, and strict fenced-code opening in `article.py`;
  widen `--time iso` Stats column, render `print_article` time via `_render_time`,
  and reset `set_time_style(None)` to `"relative"`.
- CLI, library API, docs & tests (`cli.py`, `__init__.py`, `SCHEMA.md`, `SKILL.md`,
  `README.md`, `pyproject.toml`, `tests/`): lazy PEP 562 exports in `__init__.py` and
  resilient `.client` import so `doctor` works when deps are missing; guard invalid
  tweet IDs with `InvalidInputError` across write commands; validate `article-publish`
  title/UTF-8/non-empty input, upfront media MIME/count checks, `news --max >= 1`,
  `doctor` error exit code + `query_ids` TTL, and `likes` own numeric ID check; fix
  `SCHEMA.md` `news` fields, `SKILL.md` `jq` queries, `README.md` `display.time`
  default & EN/ZH parity, `public-clis/twitter-cli` URLs; isolate `~/.twitter-cli`
  caches and `TWITTER_*` env vars in `tests/conftest.py` and add 25 regression tests.
@jackwener
jackwener merged commit 9c33a37 into main Nov 28, 2026
8 checks passed
@jackwener
jackwener deleted the feat/absorb-community-prs branch November 28, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment