Skip to content

feat: fetch X native articles directly from API#5

Merged
0xNyk merged 2 commits into
mainfrom
feat/x-native-article-fetch
Feb 24, 2026
Merged

feat: fetch X native articles directly from API#5
0xNyk merged 2 commits into
mainfrom
feat/x-native-article-fetch

Conversation

@0xNyk

@0xNyk 0xNyk commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds article to tweet.fields in X API v2 requests so inline article content (title, plain_text, code blocks) is returned directly
  • When a tweet contains a native X Article (x.com/i/article/*), the full article is extracted from the API response — no Grok web_search roundtrip needed
  • Eliminates the 25s+ timeout that always failed for X Article URLs, replacing it with instant extraction from the API response

Changes

File Change
lib/api.ts Add TweetArticle type, article field to Tweet, add article to FIELDS
lib/article.ts Add inlineArticle return path, reconstructArticleContent helper, export isXArticleUrl and buildArticleFallbackFromTweet
lib/mcp_dispatcher.ts Handle tweet URLs and inline articles in xint_article MCP tool
xint.ts Handle inlineArticle in cmdArticle()
lib/article.test.ts Add tests for reconstructArticleContent

Test plan

  • bun test — all 126 tests pass (7 in article.test.ts including 2 new)
  • E2E: bun run xint.ts article https://x.com/elvissun/status/2025920521871716562 returns full 3,800+ word article instantly
  • E2E on jarv: same command returns complete article with code blocks
  • External URL articles still route through Grok fetch path

…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
@0xNyk 0xNyk merged commit 0fb7936 into main Feb 24, 2026
@0xNyk 0xNyk deleted the feat/x-native-article-fetch branch March 16, 2026 10:42
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.

1 participant