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
This commit is contained in:
jackwener
2026-03-10 20:48:42 +08:00
parent 97708889c9
commit 32d074dc9f
10 changed files with 533 additions and 145 deletions

View File

@@ -33,7 +33,7 @@ uv tool install twitter-cli
### Step 0: Check if already authenticated
```bash
twitter whoami --json 2>/dev/null && echo "AUTH_OK" || echo "AUTH_NEEDED"
twitter status --yaml >/dev/null && echo "AUTH_OK" || echo "AUTH_NEEDED"
```
If `AUTH_OK`, skip to [Command Reference](#command-reference).
@@ -97,9 +97,12 @@ twitter whoami
twitter feed # Pretty table output
```
### JSON: `--json` flag (agent-readable)
### YAML / JSON: structured output
Non-TTY stdout defaults to YAML automatically. Use `OUTPUT=yaml|json|rich|auto` to override.
```bash
twitter feed --yaml
twitter feed --json | jq '.[0].text'
```
@@ -121,7 +124,10 @@ twitter -c search "AI" --max 20 # ~80% fewer tokens than --json
### Read Operations
```bash
twitter status # Quick auth check
twitter status --yaml # Structured auth status
twitter whoami # Current authenticated user
twitter whoami --yaml # YAML output
twitter whoami --json # JSON output
twitter user elonmusk # User profile
twitter user elonmusk --json # JSON output
@@ -129,10 +135,10 @@ twitter feed # Home timeline (For You)
twitter feed -t following # Following timeline
twitter feed --max 50 # Limit count
twitter feed --filter # Enable ranking filter
twitter feed --json > tweets.json # Export as JSON
twitter feed --yaml > tweets.yaml # Export as YAML
twitter feed --input tweets.json # Read from local JSON file
twitter bookmarks # Bookmarked tweets
twitter bookmarks --max 30 --json
twitter bookmarks --max 30 --yaml
twitter search "keyword" # Search tweets
twitter search "AI agent" -t Latest --max 50
twitter search "topic" -o results.json # Save to file