Commit 5020ced
committed
feat: v0.3 — refresh against live X, add browser cookie auto-import
Live testing against a real logged-in x.com session (via Chrome MCP)
surfaced four breaking changes vs v0.2 and one major DX gap. All five
fixed in this commit.
## Live API rotation (v0.2 was stale)
Every GraphQL query ID rotated, the response shape moved fields out of
`legacy` into a new `core` block, the timeline path lost its `_v2`
suffix, and the legacy `verify_credentials.json` REST endpoint is now a
404. Refreshed `endpoints.yaml` with the live IDs captured from the
April 2026 web client and made the parsers defensive across both shapes.
endpoints.yaml — query IDs captured from the live web client:
UserByScreenName IGgvgiOx4QZndDHuD3x9TQ (was NimuplG1OB7Fd2btCLdBOw)
UserByRestId VQfQ9wwYdk6j_u2O4vt64Q (was tD8zKvQzwY3kdx5yz6YmOw)
UserTweets x3B_xLqC0yZawOB7WQhaVQ (was QWF3SzpHmykQHsQMixG0cg)
TweetDetail rU08O-YiXdr0IZfE7qaUMg (was U0HTv-bAWTBYylwEMT7x5A)
SearchTimeline pCd62NDD9dlCDgEGgEVHMg (was flaR-PUMshxFWZWPNpq4zA)
Following vWCjN9gcTJiXzzMPR5Oxzw (was 2vUj-_Ek-UmBVDNtd8OnQA)
BlueVerifiedFollowers wlnE16ojgADYiHEqMzR3sw (new: separate op)
+ refreshed features blob with the modern keys
(hidden_profile_subscriptions_enabled, profile_label_improvements_*,
responsive_web_grok_*, premium_content_api_read_enabled, ...)
+ variables: UserByScreenName now wants withGrokTranslatedBio instead
of withSafetyModeUserFields; UserTweets dropped withV2Timeline
api/extract.go — defensive projection helpers
firstString / firstInt / firstBool walk a list of paths and return
the first non-empty match. Used everywhere a field has migrated
between `core/*` and `legacy/*`. splitPath helper for slash-delimited
paths.
api/profile.go — extractProfile now reads
core/screen_name → legacy/screen_name
core/name → legacy/name
core/created_at → legacy/created_at
avatar/image_url → legacy/profile_image_url_https
privacy/protected → legacy/protected
Plus a new GetProfileByID(userId) for the auth liveness check.
api/tweets.go — ParseTweet author projection same defensive shape.
scrapeUserTimeline now tries data.user.result.timeline.timeline
first, falls back to timeline_v2.timeline. Variable maps stripped
of withV2Timeline.
api/relationships.go — ParseUserSummary same defensive shape, avatar
bumped from _normal to _400x400 only when it points at the legacy
URL pattern.
api/auth.go — VerifyCredentials no longer hits the dead
/1.1/account/verify_credentials.json. Parses the user id out of the
`twid` cookie (u%3D<id>), calls UserByRestId, returns the live user
identity. Falls back to a UserByScreenName "twitter" probe when twid
is missing. New parseTwidUserID + normaliseAuthError helpers.
## Browser cookie auto-import (the DX gap)
Until this commit, `x auth import` required a manual paste from
DevTools. This is exactly what Python's `browser_cookie3` and `rookiepy`
solve by reading the browser's cookie SQLite store directly from disk
and decrypting the values with the OS-specific Safe Storage key. Go has
the same primitive — `github.com/browserutils/kooky` — and now x-cli
uses it.
internal/browsercookies/ — wraps kooky in a small typed API:
Load(ctx, browser, domain) → (*Result, error)
FormatCookieHeader(cookies, wanted) → string
Supports chrome | firefox | brave | edge | chromium
cmd/auth.go — three import modes:
x auth import --from-browser chrome # auto-decrypt from disk
x auth import --cookie '...' # one-shot for scripted setups
x auth import # interactive paste (default)
Storage path is unchanged — keychain primary, AES-GCM file fallback,
never plaintext. The new modes are read paths, not write paths.
Per-OS notes (also in skills/x-cli/references/auth.md):
- macOS Chrome: must be CLOSED (cookie file is locked while running).
First run prompts for Keychain access to read the Safe Storage AES
key. macOS Firefox: works while running.
- Linux Chrome: needs libsecret or kwallet running, falls back to a
hardcoded `peanuts` salt on truly headless hosts.
- Windows: DPAPI; works while the browser is running.
## Live regression fixtures
api/testdata/userbyscreenname_jack_2026_04.json
api/testdata/usertweets_jack_2026_04.json
Captured from the real x.com response on 2026-04-13 via Chrome MCP.
Two new tests run the parser against them:
TestExtractProfileLiveJackFixture
TestParseLiveUserTweetsFixture
These catch the next rotation early — if any field migrates again
the test breaks with a precise error pointing at which path is dead.
## Misc
cmd/doctor.go — printf-vet fixes (Warn/Success now use %s for the
egress line so `go vet` on Go 1.24 stays clean).
.github/workflows/ci.yml — Go bumped from 1.23 to 1.24 (kooky's go.mod
requires it).
skills/x-cli/SKILL.md and references/auth.md updated with the new
flags and the modern auth flow. README updated to lead with
--from-browser. docs/comparison-xactions.md — no change needed (the
comparison was about XActions vs x-cli, which still holds).
## Tests
70+ tests, race-clean, api/ 70.9% coverage, internal/store/ 62.8%,
internal/browsercookies/ ~50% (the rest needs real browser cookie
files; FormatCookieHeader and the no-browsers error path are tested).1 parent be2e1c7 commit 5020ced
22 files changed
Lines changed: 1047 additions & 168 deletions
File tree
- .github/workflows
- api
- testdata
- cmd
- internal/browsercookies
- skills/x-cli
- references
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
45 | 65 | | |
46 | 66 | | |
47 | 67 | | |
48 | 68 | | |
49 | 69 | | |
50 | 70 | | |
51 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
52 | 80 | | |
53 | 81 | | |
54 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
70 | 101 | | |
71 | | - | |
| 102 | + | |
| 103 | + | |
72 | 104 | | |
73 | | - | |
74 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
75 | 123 | | |
76 | | - | |
77 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
78 | 129 | | |
| 130 | + | |
| 131 | + | |
79 | 132 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
83 | 139 | | |
84 | | - | |
85 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
86 | 145 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 146 | + | |
91 | 147 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
332 | 335 | | |
333 | | - | |
334 | | - | |
| 336 | + | |
| 337 | + | |
335 | 338 | | |
336 | 339 | | |
337 | | - | |
| 340 | + | |
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
341 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
342 | 347 | | |
343 | 348 | | |
344 | 349 | | |
| |||
350 | 355 | | |
351 | 356 | | |
352 | 357 | | |
| 358 | + | |
| 359 | + | |
353 | 360 | | |
354 | 361 | | |
355 | 362 | | |
356 | 363 | | |
357 | 364 | | |
358 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
359 | 368 | | |
360 | 369 | | |
361 | 370 | | |
362 | 371 | | |
363 | 372 | | |
364 | | - | |
365 | | - | |
366 | | - | |
| 373 | + | |
| 374 | + | |
367 | 375 | | |
368 | | - | |
369 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
370 | 392 | | |
371 | 393 | | |
372 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
170 | 176 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
0 commit comments