feat: fetch X native articles directly from API#5
Merged
Conversation
…earch Add `article` to tweet.fields in API requests so the X API v2 returns inline article content (title, plain_text, code blocks) directly. When a tweet contains a native X Article, the full article content is now extracted from the API response — no Grok web_search roundtrip needed. This eliminates the 25s+ timeout that always failed for x.com/i/article/* URLs. Changes: - api.ts: add TweetArticle type, article field to Tweet, update FIELDS - article.ts: add inlineArticle return path in fetchTweetForArticle, add reconstructArticleContent helper, export isXArticleUrl and buildArticleFallbackFromTweet - mcp_dispatcher.ts: handle tweet URLs and inline articles in xint_article - xint.ts: handle inlineArticle in cmdArticle - article.test.ts: add tests for reconstructArticleContent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
articletotweet.fieldsin X API v2 requests so inline article content (title, plain_text, code blocks) is returned directlyx.com/i/article/*), the full article is extracted from the API response — no Grokweb_searchroundtrip neededChanges
lib/api.tsTweetArticletype,articlefield toTweet, addarticletoFIELDSlib/article.tsinlineArticlereturn path,reconstructArticleContenthelper, exportisXArticleUrlandbuildArticleFallbackFromTweetlib/mcp_dispatcher.tsxint_articleMCP toolxint.tsinlineArticleincmdArticle()lib/article.test.tsreconstructArticleContentTest plan
bun test— all 126 tests pass (7 in article.test.ts including 2 new)bun run xint.ts article https://x.com/elvissun/status/2025920521871716562returns full 3,800+ word article instantly