@antcoder/birdxtwittercli 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/LICENSE +21 -0
  3. package/README.md +388 -0
  4. package/dist/cli/pagination.d.ts +35 -0
  5. package/dist/cli/pagination.d.ts.map +1 -0
  6. package/dist/cli/pagination.js +43 -0
  7. package/dist/cli/pagination.js.map +1 -0
  8. package/dist/cli/program.d.ts +5 -0
  9. package/dist/cli/program.d.ts.map +1 -0
  10. package/dist/cli/program.js +113 -0
  11. package/dist/cli/program.js.map +1 -0
  12. package/dist/cli/shared.d.ts +77 -0
  13. package/dist/cli/shared.d.ts.map +1 -0
  14. package/dist/cli/shared.js +327 -0
  15. package/dist/cli/shared.js.map +1 -0
  16. package/dist/cli.d.ts +12 -0
  17. package/dist/cli.d.ts.map +1 -0
  18. package/dist/cli.js +29 -0
  19. package/dist/cli.js.map +1 -0
  20. package/dist/commands/bookmarks.d.ts +4 -0
  21. package/dist/commands/bookmarks.d.ts.map +1 -0
  22. package/dist/commands/bookmarks.js +189 -0
  23. package/dist/commands/bookmarks.js.map +1 -0
  24. package/dist/commands/check.d.ts +4 -0
  25. package/dist/commands/check.d.ts.map +1 -0
  26. package/dist/commands/check.js +43 -0
  27. package/dist/commands/check.js.map +1 -0
  28. package/dist/commands/follow.d.ts +4 -0
  29. package/dist/commands/follow.d.ts.map +1 -0
  30. package/dist/commands/follow.js +91 -0
  31. package/dist/commands/follow.js.map +1 -0
  32. package/dist/commands/help.d.ts +4 -0
  33. package/dist/commands/help.d.ts.map +1 -0
  34. package/dist/commands/help.js +19 -0
  35. package/dist/commands/help.js.map +1 -0
  36. package/dist/commands/home.d.ts +4 -0
  37. package/dist/commands/home.d.ts.map +1 -0
  38. package/dist/commands/home.js +43 -0
  39. package/dist/commands/home.js.map +1 -0
  40. package/dist/commands/lists.d.ts +4 -0
  41. package/dist/commands/lists.d.ts.map +1 -0
  42. package/dist/commands/lists.js +213 -0
  43. package/dist/commands/lists.js.map +1 -0
  44. package/dist/commands/news.d.ts +4 -0
  45. package/dist/commands/news.d.ts.map +1 -0
  46. package/dist/commands/news.js +131 -0
  47. package/dist/commands/news.js.map +1 -0
  48. package/dist/commands/post.d.ts +4 -0
  49. package/dist/commands/post.d.ts.map +1 -0
  50. package/dist/commands/post.js +101 -0
  51. package/dist/commands/post.js.map +1 -0
  52. package/dist/commands/query-ids.d.ts +4 -0
  53. package/dist/commands/query-ids.d.ts.map +1 -0
  54. package/dist/commands/query-ids.js +80 -0
  55. package/dist/commands/query-ids.js.map +1 -0
  56. package/dist/commands/read.d.ts +4 -0
  57. package/dist/commands/read.d.ts.map +1 -0
  58. package/dist/commands/read.js +152 -0
  59. package/dist/commands/read.js.map +1 -0
  60. package/dist/commands/search.d.ts +4 -0
  61. package/dist/commands/search.d.ts.map +1 -0
  62. package/dist/commands/search.js +115 -0
  63. package/dist/commands/search.js.map +1 -0
  64. package/dist/commands/unbookmark.d.ts +4 -0
  65. package/dist/commands/unbookmark.d.ts.map +1 -0
  66. package/dist/commands/unbookmark.js +36 -0
  67. package/dist/commands/unbookmark.js.map +1 -0
  68. package/dist/commands/user-tweets.d.ts +4 -0
  69. package/dist/commands/user-tweets.d.ts.map +1 -0
  70. package/dist/commands/user-tweets.js +109 -0
  71. package/dist/commands/user-tweets.js.map +1 -0
  72. package/dist/commands/users.d.ts +4 -0
  73. package/dist/commands/users.d.ts.map +1 -0
  74. package/dist/commands/users.js +295 -0
  75. package/dist/commands/users.js.map +1 -0
  76. package/dist/index.d.ts +2 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +2 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/lib/cli-args.d.ts +7 -0
  81. package/dist/lib/cli-args.d.ts.map +1 -0
  82. package/dist/lib/cli-args.js +25 -0
  83. package/dist/lib/cli-args.js.map +1 -0
  84. package/dist/lib/cookies.d.ts +31 -0
  85. package/dist/lib/cookies.d.ts.map +1 -0
  86. package/dist/lib/cookies.js +173 -0
  87. package/dist/lib/cookies.js.map +1 -0
  88. package/dist/lib/extract-bookmark-folder-id.d.ts +2 -0
  89. package/dist/lib/extract-bookmark-folder-id.d.ts.map +1 -0
  90. package/dist/lib/extract-bookmark-folder-id.js +20 -0
  91. package/dist/lib/extract-bookmark-folder-id.js.map +1 -0
  92. package/dist/lib/extract-list-id.d.ts +2 -0
  93. package/dist/lib/extract-list-id.d.ts.map +1 -0
  94. package/dist/lib/extract-list-id.js +19 -0
  95. package/dist/lib/extract-list-id.js.map +1 -0
  96. package/dist/lib/extract-tweet-id.d.ts +2 -0
  97. package/dist/lib/extract-tweet-id.d.ts.map +1 -0
  98. package/dist/lib/extract-tweet-id.js +14 -0
  99. package/dist/lib/extract-tweet-id.js.map +1 -0
  100. package/dist/lib/features.json +17 -0
  101. package/dist/lib/index.d.ts +10 -0
  102. package/dist/lib/index.d.ts.map +1 -0
  103. package/dist/lib/index.js +4 -0
  104. package/dist/lib/index.js.map +1 -0
  105. package/dist/lib/normalize-handle.d.ts +6 -0
  106. package/dist/lib/normalize-handle.d.ts.map +1 -0
  107. package/dist/lib/normalize-handle.js +31 -0
  108. package/dist/lib/normalize-handle.js.map +1 -0
  109. package/dist/lib/output.d.ts +29 -0
  110. package/dist/lib/output.d.ts.map +1 -0
  111. package/dist/lib/output.js +88 -0
  112. package/dist/lib/output.js.map +1 -0
  113. package/dist/lib/paginate-cursor.d.ts +27 -0
  114. package/dist/lib/paginate-cursor.d.ts.map +1 -0
  115. package/dist/lib/paginate-cursor.js +37 -0
  116. package/dist/lib/paginate-cursor.js.map +1 -0
  117. package/dist/lib/query-ids.json +20 -0
  118. package/dist/lib/runtime-features.d.ts +19 -0
  119. package/dist/lib/runtime-features.d.ts.map +1 -0
  120. package/dist/lib/runtime-features.js +151 -0
  121. package/dist/lib/runtime-features.js.map +1 -0
  122. package/dist/lib/runtime-query-ids.d.ts +33 -0
  123. package/dist/lib/runtime-query-ids.d.ts.map +1 -0
  124. package/dist/lib/runtime-query-ids.js +264 -0
  125. package/dist/lib/runtime-query-ids.js.map +1 -0
  126. package/dist/lib/thread-filters.d.ts +8 -0
  127. package/dist/lib/thread-filters.d.ts.map +1 -0
  128. package/dist/lib/thread-filters.js +124 -0
  129. package/dist/lib/thread-filters.js.map +1 -0
  130. package/dist/lib/twitter-client-base.d.ts +38 -0
  131. package/dist/lib/twitter-client-base.d.ts.map +1 -0
  132. package/dist/lib/twitter-client-base.js +129 -0
  133. package/dist/lib/twitter-client-base.js.map +1 -0
  134. package/dist/lib/twitter-client-bookmarks.d.ts +7 -0
  135. package/dist/lib/twitter-client-bookmarks.d.ts.map +1 -0
  136. package/dist/lib/twitter-client-bookmarks.js +61 -0
  137. package/dist/lib/twitter-client-bookmarks.js.map +1 -0
  138. package/dist/lib/twitter-client-constants.d.ts +44 -0
  139. package/dist/lib/twitter-client-constants.d.ts.map +1 -0
  140. package/dist/lib/twitter-client-constants.js +51 -0
  141. package/dist/lib/twitter-client-constants.js.map +1 -0
  142. package/dist/lib/twitter-client-engagement.d.ts +16 -0
  143. package/dist/lib/twitter-client-engagement.d.ts.map +1 -0
  144. package/dist/lib/twitter-client-engagement.js +81 -0
  145. package/dist/lib/twitter-client-engagement.js.map +1 -0
  146. package/dist/lib/twitter-client-features.d.ts +14 -0
  147. package/dist/lib/twitter-client-features.d.ts.map +1 -0
  148. package/dist/lib/twitter-client-features.js +347 -0
  149. package/dist/lib/twitter-client-features.js.map +1 -0
  150. package/dist/lib/twitter-client-follow.d.ts +8 -0
  151. package/dist/lib/twitter-client-follow.d.ts.map +1 -0
  152. package/dist/lib/twitter-client-follow.js +178 -0
  153. package/dist/lib/twitter-client-follow.js.map +1 -0
  154. package/dist/lib/twitter-client-home.d.ts +13 -0
  155. package/dist/lib/twitter-client-home.d.ts.map +1 -0
  156. package/dist/lib/twitter-client-home.js +138 -0
  157. package/dist/lib/twitter-client-home.js.map +1 -0
  158. package/dist/lib/twitter-client-lists.d.ts +12 -0
  159. package/dist/lib/twitter-client-lists.d.ts.map +1 -0
  160. package/dist/lib/twitter-client-lists.js +390 -0
  161. package/dist/lib/twitter-client-lists.js.map +1 -0
  162. package/dist/lib/twitter-client-media.d.ts +11 -0
  163. package/dist/lib/twitter-client-media.d.ts.map +1 -0
  164. package/dist/lib/twitter-client-media.js +136 -0
  165. package/dist/lib/twitter-client-media.js.map +1 -0
  166. package/dist/lib/twitter-client-news.d.ts +47 -0
  167. package/dist/lib/twitter-client-news.d.ts.map +1 -0
  168. package/dist/lib/twitter-client-news.js +283 -0
  169. package/dist/lib/twitter-client-news.js.map +1 -0
  170. package/dist/lib/twitter-client-posting.d.ts +8 -0
  171. package/dist/lib/twitter-client-posting.d.ts.map +1 -0
  172. package/dist/lib/twitter-client-posting.js +218 -0
  173. package/dist/lib/twitter-client-posting.js.map +1 -0
  174. package/dist/lib/twitter-client-search.d.ts +19 -0
  175. package/dist/lib/twitter-client-search.d.ts.map +1 -0
  176. package/dist/lib/twitter-client-search.js +157 -0
  177. package/dist/lib/twitter-client-search.js.map +1 -0
  178. package/dist/lib/twitter-client-timelines.d.ts +23 -0
  179. package/dist/lib/twitter-client-timelines.d.ts.map +1 -0
  180. package/dist/lib/twitter-client-timelines.js +471 -0
  181. package/dist/lib/twitter-client-timelines.js.map +1 -0
  182. package/dist/lib/twitter-client-tweet-detail.d.ts +25 -0
  183. package/dist/lib/twitter-client-tweet-detail.d.ts.map +1 -0
  184. package/dist/lib/twitter-client-tweet-detail.js +295 -0
  185. package/dist/lib/twitter-client-tweet-detail.js.map +1 -0
  186. package/dist/lib/twitter-client-types.d.ts +407 -0
  187. package/dist/lib/twitter-client-types.d.ts.map +1 -0
  188. package/dist/lib/twitter-client-types.js +2 -0
  189. package/dist/lib/twitter-client-types.js.map +1 -0
  190. package/dist/lib/twitter-client-user-lookup.d.ts +16 -0
  191. package/dist/lib/twitter-client-user-lookup.d.ts.map +1 -0
  192. package/dist/lib/twitter-client-user-lookup.js +224 -0
  193. package/dist/lib/twitter-client-user-lookup.js.map +1 -0
  194. package/dist/lib/twitter-client-user-tweets.d.ts +22 -0
  195. package/dist/lib/twitter-client-user-tweets.d.ts.map +1 -0
  196. package/dist/lib/twitter-client-user-tweets.js +154 -0
  197. package/dist/lib/twitter-client-user-tweets.js.map +1 -0
  198. package/dist/lib/twitter-client-users.d.ts +9 -0
  199. package/dist/lib/twitter-client-users.d.ts.map +1 -0
  200. package/dist/lib/twitter-client-users.js +358 -0
  201. package/dist/lib/twitter-client-users.js.map +1 -0
  202. package/dist/lib/twitter-client-utils.d.ts +173 -0
  203. package/dist/lib/twitter-client-utils.d.ts.map +1 -0
  204. package/dist/lib/twitter-client-utils.js +511 -0
  205. package/dist/lib/twitter-client-utils.js.map +1 -0
  206. package/dist/lib/twitter-client.d.ts +23 -0
  207. package/dist/lib/twitter-client.d.ts.map +1 -0
  208. package/dist/lib/twitter-client.js +21 -0
  209. package/dist/lib/twitter-client.js.map +1 -0
  210. package/dist/lib/version.d.ts +6 -0
  211. package/dist/lib/version.d.ts.map +1 -0
  212. package/dist/lib/version.js +174 -0
  213. package/dist/lib/version.js.map +1 -0
  214. package/package.json +61 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,176 @@
1
+ # Changelog
2
+
3
+ ## 0.8.0 — 2026-01-19
4
+
5
+ ### Added
6
+ - `bookmarks` thread expansion controls (`--expand-root-only`, `--author-chain`, `--author-only`, `--full-chain-only`, `--include-ancestor-branches`, `--include-parent`, `--thread-meta`, `--sort-chronological`) for richer context exports (#55) — thanks @kkretschmer2.
7
+ - `--chrome-profile-dir` to point at Chromium profile directories or cookie DB files (Arc/Brave/etc) for cookie extraction (#16) — thanks @tekumara.
8
+ - `about` command to report account origin/location metadata (#51) — thanks @pjtf93.
9
+ - `follow`/`unfollow` commands to manage follows (#54) — thanks @citizenlee.
10
+ - Twitter client now supports like/unlike/retweet/unretweet/bookmark via the engagement mixin (#53) — thanks @the-vampiire.
11
+
12
+ ### Fixed
13
+ - `bookmarks` expanded JSON now preserves pagination `nextCursor`, and full-chain filtering only includes ancestor branches when requested.
14
+ - Follow/unfollow REST fallback now supports cursor pagination for followers/following (#54).
15
+ - About account live coverage now verifies data extraction paths (#51) — thanks @pjtf93.
16
+
17
+ ### Tests
18
+ - Live tests now exercise engagement mutations (opt-in) (#53) — thanks @the-vampiire.
19
+
20
+ ## 0.7.0 — 2026-01-12
21
+
22
+ ### Added
23
+ - `home` command for the "For You" and "Following" home timelines (#31) — thanks @odysseus0.
24
+ - `news`/`trending` command for Explore tabs with AI-curated headlines (#39) — thanks @aavetis.
25
+ - `user-tweets` command to fetch a user's profile timeline (#34) — thanks @crcatala.
26
+ - `replies` and `thread` now support pagination (`--all`, `--max-pages`, `--cursor`, `--delay`) (#35) — thanks @crcatala.
27
+ - `search` now supports pagination (`--all`, `--max-pages`, `--cursor`) (#42) — thanks @pjtf93.
28
+ - `likes` now supports pagination (`--all`, `--max-pages`, `--cursor`) (#44) — thanks @jsholmes.
29
+ - `list-timeline` now supports pagination (`--all`, `--max-pages`, `--cursor`) (#30) — thanks @zheli.
30
+ - Rich text output now shows article previews, quoted tweets, and media links (#32) — thanks @odysseus0.
31
+ - Long-form article tweets now render rich Draft.js content blocks/entities (#36) — thanks @crcatala.
32
+
33
+ ### Changed
34
+ - Library typing: `SearchResult` is now a discriminated union (so `error` only exists when `success: false`).
35
+
36
+ ### Fixed
37
+ - Lists GraphQL feature flags updated to prevent 400s (#27) — thanks @zheli.
38
+ - Lists feature overrides now scope new GraphQL flags correctly (#50) — thanks @ryanh-ai.
39
+ - Tweet detail parsing now tolerates partial GraphQL errors when usable data exists (#48) — thanks @jsholmes.
40
+ - News output now respects `--tweets-per-item`, keeps unique IDs, and parses non-add entry instructions (#39) — thanks @aavetis.
41
+ - Following/followers pagination now guards repeat cursors and standardizes JSON output (#28) — thanks @malpern.
42
+ - Likes pagination now follows cursors and avoids stalling on duplicate pages (#12) — thanks @titouv.
43
+ - macOS cookie extraction now supports Brave keychain storage (#40) — thanks @gakonst.
44
+ - Terminal hyperlinks now sanitize control characters before emitting OSC 8 sequences (#29) — thanks @mafulafunk.
45
+ - `pnpm run build:dist` now succeeds after tightening JSON/pagination option typing in tweet output commands.
46
+
47
+ ### Tests
48
+ - Following: split following/likes tests + cover cursor handling (#33) — thanks @VACInc.
49
+
50
+ ## 0.6.0 — 2026-01-05
51
+
52
+ ### Added
53
+ - Bookmark exports now support pagination (`--all`, `--max-pages`) with retries (#15) — thanks @Nano1337.
54
+ - `lists` + `list-timeline` commands for Twitter Lists (#21) — thanks @harperreed
55
+ - Tweet JSON output now includes media items (photos, videos, GIFs) (#14) — thanks @Hormold
56
+ - Bookmarks can resume pagination from a cursor (#26) — thanks @leonho
57
+ - `unbookmark` command to remove bookmarked tweets (#22) — thanks @mbelinky.
58
+
59
+ ### Changed
60
+ - Feature flags can be overridden at runtime via `features.json` (refreshable via `query-ids`).
61
+
62
+ ### Fixed
63
+ - GraphQL feature flags now include `post_ctas_fetch_enabled` to avoid 400s (#38) — thanks @philipp-spiess.
64
+
65
+ ## 0.5.1 — 2026-01-01
66
+
67
+ ### Changed
68
+ - `bird --help` now includes explicit “Shortcuts” and “JSON Output” sections (documents `bird <tweet-id-or-url>` shorthand + `--json`).
69
+ - Release docs now include explicit npm publish verification steps.
70
+
71
+ ### Fixed
72
+ - `pnpm bird --help` now works (dev script runs the CLI entrypoint, not the library entrypoint).
73
+ - `following`/`followers` now fall back to internal v1.1 REST endpoints when GraphQL returns `404`.
74
+
75
+ ### Tests
76
+ - Add root help output regression test.
77
+ - Add opt-in live CLI test suite (real GraphQL calls; skipped by default; gated via `BIRD_LIVE=1`).
78
+
79
+ ## 0.5.0 — 2026-01-01
80
+
81
+ ### Added
82
+ - `likes` command to list your liked tweets (thanks @swairshah).
83
+ - Quoted tweet data in JSON output + `--quote-depth` (thanks @alexknowshtml).
84
+ - `following`/`followers` commands to list users (thanks @lockmeister).
85
+
86
+ ### Changed
87
+ - Query ID updater now tracks the Likes GraphQL operation.
88
+ - Query ID updater now tracks Following/Followers GraphQL operations.
89
+ - Query ID updater now tracks BookmarkFolderTimeline and keeps bookmark query IDs seeded.
90
+ - `following`/`followers` JSON user fields are now camelCase (`followersCount`, `followingCount`, `isBlueVerified`, `profileImageUrl`, `createdAt`).
91
+ - Cookie extraction timeout is now configurable (default 30s on macOS) via `--cookie-timeout` / `BIRD_COOKIE_TIMEOUT_MS` (thanks @tylerseymour).
92
+ - Search now paginates beyond 20 results when using `-n` (thanks @ryanh-ai).
93
+ - Library exports are now separated from the CLI entrypoint for easier embedding.
94
+
95
+ ## 0.4.1 — 2025-12-31
96
+
97
+ ### Added
98
+ - `bookmarks` command to list your bookmarked tweets.
99
+ - `bookmarks --folder-id` to fetch bookmark folders (thanks @tylerseymour).
100
+
101
+ ### Changed
102
+ - Cookie extraction now uses `@steipete/sweet-cookie` (drops `sqlite3` CLI + custom browser readers in `bird`).
103
+ - Query ID updater now tracks the Bookmarks GraphQL operation.
104
+ - Lint rules stricter (block statements, no-negation-else, useConst/useTemplate, top-level regex, import extension enforcement).
105
+ - `pnpm lint` now runs both Biome and oxlint (type-aware).
106
+
107
+ ### Tests
108
+ - Coverage thresholds raised to 90% statements/lines/functions (80% branches).
109
+ - Added targeted Twitter client coverage suites.
110
+
111
+ ## 0.4.0 — 2025-12-26
112
+
113
+ ### Added
114
+ - Cookie source selection: `--cookie-source safari|chrome|firefox` (repeatable) + `cookieSource` config (string or array).
115
+
116
+ ### Fixed
117
+ - `tweet`/`reply`: fallback to `statuses/update.json` when GraphQL `CreateTweet` returns error 226 (“automated request”).
118
+
119
+ ### Breaking
120
+ - Remove `allowSafari`/`allowChrome`/`allowFirefox` config toggles in favor of `cookieSource` ordering.
121
+
122
+ ## 0.3.0 — 2025-12-26
123
+
124
+ ### Added
125
+ - Safari cookie extraction (`Cookies.binarycookies`) + `allowSafari` config toggle.
126
+
127
+ ### Changed
128
+ - Removed the Sweetistics engine + fallback. `bird` is GraphQL-only.
129
+ - Browser cookie fallback order: Safari → Chrome → Firefox.
130
+
131
+ ### Tests
132
+ - Enforce coverage thresholds (>= 70% statements/branches/functions/lines) + expand unit coverage for version/output/Twitter client branches.
133
+
134
+ ## 0.2.0 — 2025-12-26
135
+
136
+ ### Added
137
+ - Output controls: `--plain`, `--no-emoji`, `--no-color` (respects `NO_COLOR`).
138
+ - `help` command: `bird help <command>`.
139
+ - Runtime GraphQL query ID refresh: `bird query-ids --fresh` (cached on disk; auto-retry on 404; override cache via `BIRD_QUERY_IDS_CACHE`).
140
+ - GraphQL media uploads via `--media` (up to 4 images/GIFs, or 1 video).
141
+
142
+ ### Fixed
143
+ - CLI `--version`: read version from `package.json`/`VERSION` (no hardcoded string) + append git sha when available.
144
+
145
+ ### Changed
146
+ - `mentions`: no hardcoded user; defaults to authenticated user or accepts `--user @handle`.
147
+ - GraphQL query ID updater: correctly pairs `operationName` ↔ `queryId` (CreateTweet/CreateRetweet/etc).
148
+ - `build:dist`: copies `src/lib/query-ids.json` into `dist/lib/query-ids.json` (keeps `dist/` in sync).
149
+ - `--engine graphql`: strict GraphQL-only (disables Sweetistics fallback).
150
+
151
+ ## 0.1.1 — 2025-12-26
152
+
153
+ ### Changed
154
+ - Engine default now `auto` (GraphQL primary; Sweetistics only on fallback when configured).
155
+
156
+ ### Tests
157
+ - Add engine resolution tests for auto/default behavior.
158
+
159
+ ### Fixed
160
+ - GraphQL read: rotate TweetDetail query IDs with fallback to avoid 404s.
161
+
162
+ ## 0.1.0 — 2025-12-20
163
+
164
+ ### Added
165
+ - CLI commands: `tweet`, `reply`, `read`, `replies`, `thread`, `search`, `mentions`, `whoami`, `check`.
166
+ - URL/ID shorthand for `read`, plus `--json` output where supported.
167
+ - GraphQL engine with cookie auth from Firefox/Chrome/env/flags (macOS browsers).
168
+ - Sweetistics engine (API key) with automatic fallback when configured.
169
+ - Media uploads via Sweetistics with per-item alt text (images or single video).
170
+ - Long-form Notes and Articles extraction for full text output.
171
+ - Thread + reply fetching with full conversation parsing.
172
+ - Search + mentions via GraphQL (latest timeline).
173
+ - JSON5 config files (`~/.config/bird/config.json5`, `./.birdrc.json5`) with engine defaults, profiles, allowChrome/allowFirefox, and timeoutMs.
174
+ - Request timeouts (`--timeout`, `timeoutMs`) for GraphQL and Sweetistics calls.
175
+ - Bun-compiled standalone binary via `pnpm run build`.
176
+ - Query ID refresh helper: `pnpm run graphql:update`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Peter Steinberger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,388 @@
1
+ # bird 🐦 — fast X CLI for tweeting, replying, and reading
2
+
3
+ `bird` is a fast X CLI for tweeting, replying, and reading via X/Twitter GraphQL (cookie auth).
4
+
5
+ ## Disclaimer
6
+
7
+ This project uses X/Twitter’s **undocumented** web GraphQL API (and cookie auth). X can change endpoints, query IDs,
8
+ and anti-bot behavior at any time — **expect this to break without notice**.
9
+
10
+ **Strong recommendation: Do not use bird to tweet. You will hit blocks very quickly. Use it to read tweets.
11
+ Bots are not welcome on X/Twitter. If you absolutely have to, use browser automation instead, or pay for the Twitter API to create tweets.**
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @antcoder/birdxtwittercli
17
+ # or
18
+ pnpm add -g @antcoder/birdxtwittercli
19
+ # or
20
+ bun add -g @antcoder/birdxtwittercli
21
+
22
+ # one-shot (no install)
23
+ bunx @antcoder/birdxtwittercli whoami
24
+ ```
25
+
26
+ Homebrew (macOS, prebuilt Bun binary):
27
+
28
+ ```bash
29
+ # brew install coming soon
30
+ ```
31
+
32
+ ## Quickstart
33
+
34
+ ```bash
35
+ # Show the logged-in account
36
+ bird whoami
37
+
38
+ # Discover command help
39
+ bird help whoami
40
+
41
+ # Read a tweet (URL or ID)
42
+ bird read https://x.com/user/status/1234567890123456789
43
+ bird 1234567890123456789 --json
44
+
45
+ # Thread + replies
46
+ bird thread https://x.com/user/status/1234567890123456789
47
+ bird replies 1234567890123456789
48
+ bird replies 1234567890123456789 --max-pages 3 --json
49
+ bird thread 1234567890123456789 --max-pages 3 --json
50
+
51
+ # Search + mentions
52
+ bird search "from:steipete" -n 5
53
+ bird mentions -n 5
54
+ bird mentions --user @steipete -n 5
55
+
56
+ # User tweets (profile timeline)
57
+ bird user-tweets @steipete -n 20
58
+ bird user-tweets @steipete -n 50 --json
59
+
60
+ # Bookmarks
61
+ bird bookmarks -n 5
62
+ bird bookmarks --folder-id 123456789123456789 -n 5 # https://x.com/i/bookmarks/<folder-id>
63
+ bird bookmarks --all --json
64
+ bird bookmarks --all --max-pages 2 --json
65
+ bird bookmarks --include-parent --json
66
+ bird unbookmark 1234567890123456789
67
+ bird unbookmark https://x.com/user/status/1234567890123456789
68
+
69
+ # Likes
70
+ bird likes -n 5
71
+
72
+ # News and trending topics (AI-curated from Explore tabs)
73
+ bird news --ai-only -n 10
74
+ bird news --sports -n 5
75
+
76
+ # Lists
77
+ bird list-timeline 1234567890 -n 20
78
+ bird list-timeline https://x.com/i/lists/1234567890 --all --json
79
+ bird list-timeline 1234567890 --max-pages 3 --json
80
+
81
+ # Following (who you follow)
82
+ bird following -n 20
83
+ bird following --user 12345678 -n 10 # by user ID
84
+
85
+ # Followers (who follows you)
86
+ bird followers -n 20
87
+ bird followers --user 12345678 -n 10 # by user ID
88
+
89
+ # Refresh GraphQL query IDs cache (no rebuild)
90
+ bird query-ids --fresh
91
+ ```
92
+
93
+ ## News & Trending
94
+
95
+ Fetch AI-curated news and trending topics from X's Explore page tabs:
96
+
97
+ ```bash
98
+ # Fetch 10 news items from all tabs (default: For You, News, Sports, Entertainment)
99
+ bird news -n 10
100
+
101
+ # Fetch only AI-curated news (filters out regular trends)
102
+ bird news --ai-only -n 20
103
+
104
+ # Fetch from specific tabs
105
+ bird news --news-only --ai-only -n 10
106
+ bird news --sports -n 15
107
+ bird news --entertainment --ai-only -n 5
108
+
109
+ # Include related tweets for each news item
110
+ bird news --with-tweets --tweets-per-item 3 -n 10
111
+
112
+ # Combine multiple tab filters
113
+ bird news --sports --entertainment -n 20
114
+
115
+ # JSON output
116
+ bird news --json -n 5
117
+ bird news --json-full --ai-only -n 10 # includes raw API response
118
+ ```
119
+
120
+ Tab options (can be combined):
121
+ - `--for-you` — Fetch from For You tab only
122
+ - `--news-only` — Fetch from News tab only
123
+ - `--sports` — Fetch from Sports tab only
124
+ - `--entertainment` — Fetch from Entertainment tab only
125
+ - `--trending-only` — Fetch from Trending tab only
126
+
127
+ By default, the command fetches from For You, News, Sports, and Entertainment tabs (Trending excluded to reduce noise). Headlines are automatically deduplicated across tabs.
128
+
129
+ ## Library
130
+
131
+ `bird` can be used as a library (same GraphQL client as the CLI):
132
+
133
+ ```ts
134
+ import { TwitterClient, resolveCredentials } from '@antcoder/birdxtwittercli';
135
+
136
+ const { cookies } = await resolveCredentials({ cookieSource: 'safari' });
137
+ const client = new TwitterClient({ cookies });
138
+
139
+ // Search for tweets
140
+ const searchResult = await client.search('from:steipete', 50);
141
+
142
+ // Fetch news and trending topics from all tabs (default: For You, News, Sports, Entertainment)
143
+ const newsResult = await client.getNews(10, { aiOnly: true });
144
+
145
+ // Fetch from specific tabs with related tweets
146
+ const sportsNews = await client.getNews(10, {
147
+ aiOnly: true,
148
+ withTweets: true,
149
+ tabs: ['sports', 'entertainment']
150
+ });
151
+ ```
152
+
153
+ Account details (About profile):
154
+
155
+ ```ts
156
+ const aboutResult = await client.getUserAboutAccount('antcoder');
157
+ if (aboutResult.success && aboutResult.aboutProfile) {
158
+ console.log(aboutResult.aboutProfile.accountBasedIn);
159
+ }
160
+ ```
161
+
162
+ Fields:
163
+ - `accountBasedIn`
164
+ - `source`
165
+ - `createdCountryAccurate`
166
+ - `locationAccurate`
167
+ - `learnMoreUrl`
168
+
169
+ ## Commands
170
+
171
+ - `bird tweet "<text>"` — post a new tweet.
172
+ - `bird reply <tweet-id-or-url> "<text>"` — reply to a tweet using its ID or URL.
173
+ - `bird help [command]` — show help (or help for a subcommand).
174
+ - `bird query-ids [--fresh] [--json]` — inspect or refresh cached GraphQL query IDs.
175
+ - `bird home [-n count] [--following] [--json] [--json-full]` — fetch your home timeline (For You) or Following feed.
176
+ - `bird read <tweet-id-or-url> [--json]` — fetch tweet content as text or JSON.
177
+ - `bird <tweet-id-or-url> [--json]` — shorthand for `read` when only a URL or ID is provided.
178
+ - `bird replies <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json]` — list replies to a tweet.
179
+ - `bird thread <tweet-id-or-url> [--all] [--max-pages n] [--cursor string] [--delay ms] [--json]` — show the full conversation thread.
180
+ - `bird search "<query>" [-n count] [--all] [--max-pages n] [--cursor string] [--json]` — search for tweets matching a query; `--max-pages` requires `--all` or `--cursor`.
181
+ - `bird mentions [-n count] [--user @handle] [--json]` — find tweets mentioning a user (defaults to the authenticated user).
182
+ - `bird user-tweets <@handle> [-n count] [--cursor string] [--max-pages n] [--delay ms] [--json]` — get tweets from a user's profile timeline.
183
+ - `bird bookmarks [-n count] [--folder-id id] [--all] [--max-pages n] [--cursor string] [--expand-root-only] [--author-chain] [--author-only] [--full-chain-only] [--include-ancestor-branches] [--include-parent] [--thread-meta] [--sort-chronological] [--json]` — list your bookmarked tweets (or a specific bookmark folder); expansion flags control thread context; `--max-pages` requires `--all` or `--cursor`.
184
+ - `bird unbookmark <tweet-id-or-url...>` — remove one or more bookmarks by tweet ID or URL.
185
+ - `bird likes [-n count] [--all] [--max-pages n] [--cursor string] [--json] [--json-full]` — list your liked tweets; `--max-pages` requires `--all` or `--cursor`.
186
+ - `bird news [-n count] [--ai-only] [--with-tweets] [--tweets-per-item n] [--for-you] [--news-only] [--sports] [--entertainment] [--trending-only] [--json]` — fetch news and trending topics from X's Explore tabs.
187
+ - `bird trending` — alias for `news` command.
188
+ - `bird lists [--member-of] [-n count] [--json]` — list your lists (owned or memberships).
189
+ - `bird list-timeline <list-id-or-url> [-n count] [--all] [--max-pages n] [--cursor string] [--json]` — get tweets from a list timeline; `--max-pages` implies `--all`.
190
+ - `bird following [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json]` — list users that you (or another user) follow; `--max-pages` requires `--all`.
191
+ - `bird followers [--user <userId>] [-n count] [--cursor string] [--all] [--max-pages n] [--json]` — list users that follow you (or another user); `--max-pages` requires `--all`.
192
+ - `bird about <@handle> [--json]` — get account origin and location information for a user.
193
+ - `bird whoami` — print which Twitter account your cookies belong to.
194
+ - `bird check` — show which credentials are available and where they were sourced from.
195
+
196
+ Bookmarks flags:
197
+ - `--expand-root-only`: expand threads only when the bookmark is a root tweet.
198
+ - `--author-chain`: keep only the bookmarked author's connected self-reply chain.
199
+ - `--author-only`: include all tweets from the bookmarked author within the thread.
200
+ - `--full-chain-only`: keep the entire reply chain connected to the bookmarked tweet (all authors).
201
+ - `--include-ancestor-branches`: include sibling branches for ancestors when using `--full-chain-only`.
202
+ - `--include-parent`: include the direct parent tweet for non-root bookmarks.
203
+ - `--thread-meta`: add thread metadata fields to each tweet.
204
+ - `--sort-chronological`: sort output globally oldest to newest (default preserves bookmark order).
205
+
206
+ Global options:
207
+ - `--auth-token <token>`: set the `auth_token` cookie manually.
208
+ - `--ct0 <token>`: set the `ct0` cookie manually.
209
+ - `--cookie-source <safari|chrome|firefox>`: choose browser cookie source (repeatable; order matters).
210
+ - `--chrome-profile <name>`: Chrome profile name for cookie extraction (e.g., `Default`, `Profile 2`).
211
+ - `--chrome-profile-dir <path>`: Chrome/Chromium profile directory or cookie DB path for cookie extraction.
212
+ - `--firefox-profile <name>`: Firefox profile for cookie extraction.
213
+ - `--cookie-timeout <ms>`: cookie extraction timeout for keychain/OS helpers (milliseconds).
214
+ - `--timeout <ms>`: abort requests after the given timeout (milliseconds).
215
+ - `--quote-depth <n>`: max quoted tweet depth in JSON output (default: 1; 0 disables).
216
+ - `--plain`: stable output (no emoji, no color).
217
+ - `--no-emoji`: disable emoji output.
218
+ - `--no-color`: disable ANSI colors (or set `NO_COLOR=1`).
219
+ - `--media <path>`: attach media file (repeatable, up to 4 images or 1 video).
220
+ - `--alt <text>`: alt text for the corresponding `--media` (repeatable).
221
+
222
+ ## Authentication (GraphQL)
223
+
224
+ GraphQL mode uses your existing X/Twitter web session (no password prompt). It sends requests to internal
225
+ X endpoints and authenticates via cookies (`auth_token`, `ct0`).
226
+
227
+ Write operations:
228
+ - `tweet`/`reply` primarily use GraphQL (`CreateTweet`).
229
+ - If GraphQL returns error `226` (“automated request”), `bird` falls back to the legacy `statuses/update.json` endpoint.
230
+
231
+ `bird` resolves credentials in this order:
232
+
233
+ 1. CLI flags: `--auth-token`, `--ct0`
234
+ 2. Environment variables: `AUTH_TOKEN`, `CT0` (fallback: `TWITTER_AUTH_TOKEN`, `TWITTER_CT0`)
235
+ 3. Browser cookies via `@steipete/sweet-cookie` (override via `--cookie-source` order)
236
+
237
+ Browser cookie sources:
238
+ - Safari: `~/Library/Cookies/Cookies.binarycookies` (fallback: `~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies`)
239
+ - Chrome: `~/Library/Application Support/Google/Chrome/<Profile>/Cookies`
240
+ - Firefox: `~/Library/Application Support/Firefox/Profiles/<profile>/cookies.sqlite`
241
+ - For Chromium variants (Arc/Brave/etc), pass a profile directory or cookie DB via `--chrome-profile-dir`.
242
+
243
+ ## Config (JSON5)
244
+
245
+ Config precedence: CLI flags > env vars > project config > global config.
246
+
247
+ - Global: `~/.config/bird/config.json5`
248
+ - Project: `./.birdrc.json5`
249
+
250
+ Example `~/.config/bird/config.json5`:
251
+
252
+ ```json5
253
+ {
254
+ // Cookie source order for browser extraction (string or array)
255
+ cookieSource: ["firefox", "safari"],
256
+ chromeProfileDir: "/path/to/Chromium/Profile",
257
+ firefoxProfile: "default-release",
258
+ cookieTimeoutMs: 30000,
259
+ timeoutMs: 20000,
260
+ quoteDepth: 1
261
+ }
262
+ ```
263
+
264
+ Environment shortcuts:
265
+ - `BIRD_TIMEOUT_MS`
266
+ - `BIRD_COOKIE_TIMEOUT_MS`
267
+ - `BIRD_QUOTE_DEPTH`
268
+
269
+ ## Output
270
+
271
+ - `--json` prints raw tweet objects for read/replies/thread/search/mentions/user-tweets/bookmarks/likes.
272
+ - When using `--json` with pagination (`--all`, `--cursor`, `--max-pages`, or for `user-tweets` when `-n > 20`), output is `{ tweets, nextCursor }`.
273
+ - `read` returns full text for Notes and Articles when present.
274
+ - Use `--plain` for stable, script-friendly output (no emoji, no color).
275
+
276
+ ### JSON Schema
277
+
278
+ When using `--json`, tweet objects include:
279
+
280
+ | Field | Type | Description |
281
+ |-------|------|-------------|
282
+ | `id` | string | Tweet ID |
283
+ | `text` | string | Full tweet text (includes Note/Article content when present) |
284
+ | `author` | object | `{ username, name }` |
285
+ | `authorId` | string? | Author's user ID |
286
+ | `createdAt` | string | Timestamp |
287
+ | `replyCount` | number | Number of replies |
288
+ | `retweetCount` | number | Number of retweets |
289
+ | `likeCount` | number | Number of likes |
290
+ | `conversationId` | string | Thread conversation ID |
291
+ | `inReplyToStatusId` | string? | Parent tweet ID (present if this is a reply) |
292
+ | `quotedTweet` | object? | Embedded quote tweet (same schema; depth controlled by `--quote-depth`) |
293
+
294
+ When using `--json` with `following`/`followers`, user objects include:
295
+
296
+ | Field | Type | Description |
297
+ |-------|------|-------------|
298
+ | `id` | string | User ID |
299
+ | `username` | string | Username/handle |
300
+ | `name` | string | Display name |
301
+ | `description` | string? | User bio |
302
+ | `followersCount` | number? | Followers count |
303
+ | `followingCount` | number? | Following count |
304
+ | `isBlueVerified` | boolean? | Blue verified flag |
305
+ | `profileImageUrl` | string? | Profile image URL |
306
+ | `createdAt` | string? | Account creation timestamp |
307
+
308
+ When using `--json` with `news`/`trending`, news objects include:
309
+
310
+ | Field | Type | Description |
311
+ |-------|------|-------------|
312
+ | `id` | string | Unique identifier for the news item |
313
+ | `headline` | string | News headline or trend title |
314
+ | `category` | string? | Category (e.g., "AI · Technology", "Trending", "News") |
315
+ | `timeAgo` | string? | Relative time (e.g., "2h ago") |
316
+ | `postCount` | number? | Number of posts |
317
+ | `description` | string? | Item description |
318
+ | `url` | string? | URL to the trend or news article |
319
+ | `tweets` | array? | Related tweets (only when `--with-tweets` is used) |
320
+ | `_raw` | object? | Raw API response (only when `--json-full` is used) |
321
+
322
+
323
+ ## Query IDs (GraphQL)
324
+
325
+ X rotates GraphQL “query IDs” frequently. Each GraphQL operation is addressed as:
326
+
327
+ - `operationName` (e.g. `TweetDetail`, `CreateTweet`)
328
+ - `queryId` (rotating ID baked into X’s web client bundles)
329
+
330
+ `bird` ships with a baseline mapping in `src/lib/query-ids.json` (copied into `dist/` on build). At runtime,
331
+ it can refresh that mapping by scraping X’s public web client bundles and caching the result on disk.
332
+
333
+ Runtime cache:
334
+ - Default path: `~/.config/bird/query-ids-cache.json`
335
+ - Override path: `BIRD_QUERY_IDS_CACHE=/path/to/file.json`
336
+ - TTL: 24h (stale cache is still used, but marked “not fresh”)
337
+
338
+ Auto-recovery:
339
+ - On GraphQL `404` (query ID invalid), `bird` forces a refresh once and retries.
340
+ - For `TweetDetail`/`SearchTimeline`, `bird` also rotates through a small set of known fallback IDs to reduce
341
+ breakage while refreshing.
342
+
343
+ Refresh on demand:
344
+
345
+ ```bash
346
+ bird query-ids --fresh
347
+ ```
348
+
349
+ Exit codes:
350
+ - `0`: success
351
+ - `1`: runtime error (network/auth/etc)
352
+ - `2`: invalid usage/validation (e.g. bad `--user` handle)
353
+
354
+ ## Version
355
+
356
+ `bird --version` prints `package.json` version plus current git sha when available, e.g. `0.3.0 (3df7969b)`.
357
+
358
+ ## Media uploads
359
+
360
+ - Attach media with `--media` (repeatable) and optional `--alt` per item.
361
+ - Up to 4 images/GIFs, or 1 video (no mixing). Supported: jpg, jpeg, png, webp, gif, mp4, mov.
362
+ - Images/GIFs + 1 video supported (uploads via Twitter legacy upload endpoint + cookies; video may take longer to process).
363
+
364
+ Example:
365
+
366
+ ```bash
367
+ bird tweet "hi" --media img.png --alt "desc"
368
+ ```
369
+
370
+ ## Development
371
+
372
+ ```bash
373
+ cd ~/Projects/bird
374
+ pnpm install
375
+ pnpm run build # dist/ + bun binary
376
+ pnpm run build:dist # dist/ only
377
+ pnpm run build:binary
378
+
379
+ pnpm run dev tweet "Test"
380
+ pnpm run dev -- --plain check
381
+ pnpm test
382
+ pnpm run lint
383
+ ```
384
+
385
+ ## Notes
386
+
387
+ - GraphQL uses internal X endpoints and can be rate limited (429).
388
+ - Query IDs rotate; refresh at runtime with `bird query-ids --fresh` (or update the baked baseline via `pnpm run graphql:update`).
@@ -0,0 +1,35 @@
1
+ export type PaginationCmdOpts = {
2
+ all?: boolean;
3
+ maxPages?: string;
4
+ cursor?: string;
5
+ delay?: string;
6
+ };
7
+ export declare function parsePositiveIntFlag(raw: string | undefined, flagName: string): {
8
+ ok: true;
9
+ value: number | undefined;
10
+ } | {
11
+ ok: false;
12
+ error: string;
13
+ };
14
+ export declare function parseNonNegativeIntFlag(raw: string | undefined, flagName: string, defaultValue: number): {
15
+ ok: true;
16
+ value: number;
17
+ } | {
18
+ ok: false;
19
+ error: string;
20
+ };
21
+ export declare function parsePaginationFlags(cmdOpts: PaginationCmdOpts, opts?: {
22
+ maxPagesImpliesPagination?: boolean;
23
+ defaultDelayMs?: number;
24
+ includeDelay?: boolean;
25
+ }): {
26
+ ok: true;
27
+ usePagination: boolean;
28
+ maxPages?: number;
29
+ cursor?: string;
30
+ pageDelayMs?: number;
31
+ } | {
32
+ ok: false;
33
+ error: string;
34
+ };
35
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/cli/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,MAAM,GACf;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CASxE;AAED,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAM5D;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,IAAI,CAAC,EAAE;IACL,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAEC;IACE,EAAE,EAAE,IAAI,CAAC;IACT,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA8B/B"}
@@ -0,0 +1,43 @@
1
+ export function parsePositiveIntFlag(raw, flagName) {
2
+ if (raw === undefined) {
3
+ return { ok: true, value: undefined };
4
+ }
5
+ const value = Number.parseInt(raw, 10);
6
+ if (!Number.isFinite(value) || value <= 0) {
7
+ return { ok: false, error: `Invalid ${flagName}. Expected a positive integer.` };
8
+ }
9
+ return { ok: true, value };
10
+ }
11
+ export function parseNonNegativeIntFlag(raw, flagName, defaultValue) {
12
+ const value = Number.parseInt(raw ?? String(defaultValue), 10);
13
+ if (!Number.isFinite(value) || value < 0) {
14
+ return { ok: false, error: `Invalid ${flagName}. Expected a non-negative integer.` };
15
+ }
16
+ return { ok: true, value };
17
+ }
18
+ export function parsePaginationFlags(cmdOpts, opts) {
19
+ const maxPagesImpliesPagination = opts?.maxPagesImpliesPagination ?? false;
20
+ const includeDelay = opts?.includeDelay ?? false;
21
+ const defaultDelayMs = opts?.defaultDelayMs ?? 1000;
22
+ const maxPages = parsePositiveIntFlag(cmdOpts.maxPages, '--max-pages');
23
+ if (!maxPages.ok) {
24
+ return maxPages;
25
+ }
26
+ const usePagination = Boolean(cmdOpts.all || cmdOpts.cursor || (maxPagesImpliesPagination && maxPages.value !== undefined));
27
+ let pageDelayMs;
28
+ if (includeDelay) {
29
+ const delay = parseNonNegativeIntFlag(cmdOpts.delay, '--delay', defaultDelayMs);
30
+ if (!delay.ok) {
31
+ return delay;
32
+ }
33
+ pageDelayMs = delay.value;
34
+ }
35
+ return {
36
+ ok: true,
37
+ usePagination,
38
+ maxPages: maxPages.value,
39
+ cursor: cmdOpts.cursor,
40
+ pageDelayMs,
41
+ };
42
+ }
43
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/cli/pagination.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,oBAAoB,CAClC,GAAuB,EACvB,QAAgB;IAEhB,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,QAAQ,gCAAgC,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,GAAuB,EACvB,QAAgB,EAChB,YAAoB;IAEpB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,QAAQ,oCAAoC,EAAE,CAAC;IACvF,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,OAA0B,EAC1B,IAIC;IAUD,MAAM,yBAAyB,GAAG,IAAI,EAAE,yBAAyB,IAAI,KAAK,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,KAAK,CAAC;IACjD,MAAM,cAAc,GAAG,IAAI,EAAE,cAAc,IAAI,IAAI,CAAC;IAEpD,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACvE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,aAAa,GAAG,OAAO,CAC3B,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,CAAC,CAC7F,CAAC;IAEF,IAAI,WAA+B,CAAC;IACpC,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,KAAK,GAAG,uBAAuB,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QAChF,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QACD,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,aAAa;QACb,QAAQ,EAAE,QAAQ,CAAC,KAAK;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ import { type CliContext } from './shared.js';
3
+ export declare const KNOWN_COMMANDS: Set<string>;
4
+ export declare function createProgram(ctx: CliContext): Command;
5
+ //# sourceMappingURL=program.d.ts.map