Skip to content

feat(twitter): add --type flag to timeline command#232

Merged
jackwener merged 1 commit intojackwener:mainfrom
Astro-Han:worktree-twitter-timeline-type
Mar 22, 2026
Merged

feat(twitter): add --type flag to timeline command#232
jackwener merged 1 commit intojackwener:mainfrom
Astro-Han:worktree-twitter-timeline-type

Conversation

@Astro-Han
Copy link
Copy Markdown
Contributor

@Astro-Han Astro-Han commented Mar 22, 2026

Summary

Closes #83.

  • Add --type flag to twitter timeline with choices for-you (default, algorithmic) and following (chronological)
  • Both endpoints share the same GraphQL response structure; only the endpoint name, HTTP method, and queryId differ (HomeTimeline GET vs HomeLatestTimeline POST)
  • QueryId is resolved dynamically from fa0311/twitter-openapi with hardcoded fallback, validated against /^[A-Za-z0-9_-]+$/ to prevent injection from untrusted upstream

Usage

opencli twitter timeline                        # default: for-you
opencli twitter timeline --type following        # chronological
opencli twitter timeline --type for-you --limit 10

Test plan

  • opencli twitter timeline still works as before (default for-you)
  • opencli twitter timeline --type following returns chronological timeline
  • opencli twitter timeline --type invalid is rejected by choices validation
  • npm run typecheck passes

@Astro-Han
Copy link
Copy Markdown
Contributor Author

Note: Verified via npm run typecheck (pass) and npx vitest run src/ (301/301 pass). Manual testing of the --type following endpoint requires a logged-in browser session with Twitter cookies, which cannot be automated in CI. The implementation mirrors the existing HomeTimeline pattern with only the GraphQL endpoint name and queryId changed.

Support switching between For You (algorithmic) and Following
(chronological) timelines via `--type for-you|following`.

Both endpoints share the same response structure; only the GraphQL
endpoint name and queryId differ. QueryId is resolved dynamically
from fa0311/twitter-openapi with a hardcoded fallback, and validated
against /^[A-Za-z0-9_-]+$/ to prevent injection from upstream.
@Astro-Han Astro-Han force-pushed the worktree-twitter-timeline-type branch from fba7ad6 to 76b8363 Compare March 22, 2026 04:01
@jackwener jackwener merged commit e98cf75 into jackwener:main Mar 22, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: twitter timeline 支持区分 For You / Following

2 participants