470 lines
11 KiB
Markdown
470 lines
11 KiB
Markdown
|
|
# X平台智能命令行工具
|
|||
|
|
|
|||
|
|
`CLI` `Rust` `X/Twitter` `AI分析` `搜索监控`
|
|||
|
|
|
|||
|
|
<!-- markdownlint-disable MD041 -->
|
|||
|
|
<p align="center">
|
|||
|
|
<strong>xint-rs</strong> — X 智能命令行工具
|
|||
|
|
</p>
|
|||
|
|
|
|||
|
|
<p align="center">
|
|||
|
|
<strong>单一二进制文件,零运行时依赖。</strong> 2.5MB,启动时间不到 5ms。
|
|||
|
|
</p>
|
|||
|
|
|
|||
|
|
<p align="center">
|
|||
|
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
|||
|
|
<a href="https://www.rust-lang.org"><img src="https://img.shields.io/badge/Built_with-Rust-dea584.svg" alt="Rust"></a>
|
|||
|
|
<a href="https://github.com/0xNyk/xint-rs/releases"><img src="https://img.shields.io/github/v/release/0xNyk/xint-rs?display_name=tag" alt="Release"></a>
|
|||
|
|
<a href="https://github.com/0xNyk/xint-rs/stargazers"><img src="https://img.shields.io/github/stars/0xNyk/xint-rs" alt="Stars"></a>
|
|||
|
|
</p>
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
> **像专业人士一样搜索 X。** 全文搜索、实时监控、粉丝追踪、AI 分析——全部在命令行完成。用 Rust 构建,追求极速。
|
|||
|
|
|
|||
|
|
## 为什么选择 Rust?
|
|||
|
|
|
|||
|
|
| | TypeScript | Rust |
|
|||
|
|
|---|---|---|
|
|||
|
|
| **启动时间** | ~50ms | <5ms |
|
|||
|
|
| **二进制大小** | ~60MB | 2.5MB |
|
|||
|
|
| **内存占用** | ~40MB | ~5MB |
|
|||
|
|
| **部署方式** | Clone + Bun | 复制单个文件 |
|
|||
|
|
|
|||
|
|
## 安装
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
curl -fsSL https://raw.githubusercontent.com/0xNyk/xint-rs/main/install.sh | bash
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
指定版本安装(可选):
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
XINT_RS_INSTALL_VERSION=<版本标签> \
|
|||
|
|
curl -fsSL https://raw.githubusercontent.com/0xNyk/xint-rs/main/install.sh | bash
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Homebrew(Apple Silicon 轻量预构建二进制):
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
brew tap 0xNyk/xint
|
|||
|
|
brew install xint
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
或安装显式 Rust 配方:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
brew install xint-rs
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
或从源码构建:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
git clone https://github.com/0xNyk/xint-rs.git
|
|||
|
|
cd xint-rs
|
|||
|
|
cargo build --release
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
> **要求:** [X API 访问权限](https://developer.x.com)(预付费额度)
|
|||
|
|
|
|||
|
|
## 快速参考
|
|||
|
|
|
|||
|
|
| 任务 | 命令 |
|
|||
|
|
|------|---------|
|
|||
|
|
| 搜索 | `xint search "AI agents"` |
|
|||
|
|
| 监控 | `xint watch "solana" -i 5m` |
|
|||
|
|
| 流式 | `xint stream` |
|
|||
|
|
| 用户主页 | `xint profile @elonmusk` |
|
|||
|
|
| 推文线程 | `xint thread 123456789` |
|
|||
|
|
| 粉丝变化 | `xint diff @username` |
|
|||
|
|
| 书签 | `xint bookmarks` |
|
|||
|
|
| 列表 | `xint lists` |
|
|||
|
|
| 黑名单 | `xint blocks` |
|
|||
|
|
| 静音 | `xint mutes` |
|
|||
|
|
| 关注 | `xint follow @username` |
|
|||
|
|
| 媒体 | `xint media <tweet_id>` |
|
|||
|
|
| 趋势 | `xint trends` |
|
|||
|
|
| AI 分析 | `xint analyze "best?"` |
|
|||
|
|
| 报告 | `xint report "crypto"` |
|
|||
|
|
| 转发列表 | `xint reposts <tweet_id>` |
|
|||
|
|
| 用户搜索 | `xint users "AI researcher"` |
|
|||
|
|
| 文章 | `xint article <url> --ai "summarize"` |
|
|||
|
|
| 功能清单 | `xint capabilities --json` |
|
|||
|
|
| TUI 界面 | `xint tui` |
|
|||
|
|
|
|||
|
|
### 缩写命令
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint s "query" # 搜索
|
|||
|
|
xint w "query" # 监控
|
|||
|
|
xint p @user # 用户主页
|
|||
|
|
xint tr # 趋势
|
|||
|
|
xint bm # 书签
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### TUI 自定义
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 内置主题:classic | neon | minimal | ocean | amber
|
|||
|
|
XINT_TUI_THEME=ocean xint tui
|
|||
|
|
|
|||
|
|
# 禁用动画标题行
|
|||
|
|
XINT_TUI_HERO=0 xint tui
|
|||
|
|
|
|||
|
|
# 禁用菜单行图标
|
|||
|
|
XINT_TUI_ICONS=0 xint tui
|
|||
|
|
|
|||
|
|
# 使用自定义主题 token 文件
|
|||
|
|
XINT_TUI_THEME_FILE=./tui-theme.tokens.example.json xint tui
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 配置
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cp .env.example .env
|
|||
|
|
# 添加 X_BEARER_TOKEN=your_token
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 可选:xAI
|
|||
|
|
|
|||
|
|
用于 `analyze`、`report --sentiment`、`article --ai`:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
XAI_API_KEY=your_xai_key
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 可选:OAuth
|
|||
|
|
|
|||
|
|
用于书签、点赞、关注、列表、黑名单/静音、粉丝追踪:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
X_CLIENT_ID=your_client_id
|
|||
|
|
xint auth setup
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 部署模式
|
|||
|
|
|
|||
|
|
### 自托管(OSS 默认模式)
|
|||
|
|
|
|||
|
|
- 将此二进制文件运行于本地环境。
|
|||
|
|
- 除非配置了云端环境变量,否则 Package API 功能保持本地运行。
|
|||
|
|
- 最适合开发和私有运营工作流。
|
|||
|
|
|
|||
|
|
### 托管云控制面板(`xint-cloud`)
|
|||
|
|
|
|||
|
|
- 将 Package API 功能指向托管控制面板:
|
|||
|
|
- `XINT_PACKAGE_API_BASE_URL=http://localhost:8787/v1`(或你的部署 URL)
|
|||
|
|
- `XINT_PACKAGE_API_KEY=<workspace_api_key>`
|
|||
|
|
- `XINT_WORKSPACE_ID=<workspace_id>`
|
|||
|
|
- 可选:配额/计划错误时的计费升级 URL:
|
|||
|
|
- `XINT_BILLING_UPGRADE_URL=https://your-app/pricing`
|
|||
|
|
|
|||
|
|
注意:
|
|||
|
|
- 若未设置 `XINT_PACKAGE_API_BASE_URL`,Package API MCP 工具将返回配置错误。
|
|||
|
|
- 请保持 `xint-cloud` 私有;`xint` 和 `xint-rs` 保持公开的 OSS 客户端。
|
|||
|
|
|
|||
|
|
## Agent 原生能力清单
|
|||
|
|
|
|||
|
|
`xint-rs` 内置机器可读的清单,用于 agent 白名单和运行时工具选择:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 格式化 JSON
|
|||
|
|
xint capabilities
|
|||
|
|
|
|||
|
|
# 紧凑 JSON(机器可读)
|
|||
|
|
xint capabilities --compact
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 搜索
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 快速查看
|
|||
|
|
xint search "AI agents" --quick
|
|||
|
|
|
|||
|
|
# 高互动内容
|
|||
|
|
xint search "react 19" --since 1h --sort likes --min-likes 50
|
|||
|
|
|
|||
|
|
# 全量归档
|
|||
|
|
xint search "bitcoin ETF" --full --pages 3
|
|||
|
|
|
|||
|
|
# 带情感分析
|
|||
|
|
xint search "solana" --sentiment
|
|||
|
|
|
|||
|
|
# 导出
|
|||
|
|
xint search "startups" --csv > data.csv
|
|||
|
|
xint search "AI" --jsonl | jq '.text'
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 参数说明
|
|||
|
|
|
|||
|
|
| 参数 | 说明 |
|
|||
|
|
|------|-------------|
|
|||
|
|
| `--sort` | `likes` · `impressions` · `retweets` · `recent` |
|
|||
|
|
| `--since` | `1h` · `3h` · `12h` · `1d` · `7d` |
|
|||
|
|
| `--full` | 搜索完整归档(追溯至 2006 年) |
|
|||
|
|
| `--sentiment` | 对每条推文进行 AI 情感分析 |
|
|||
|
|
| `--quick` | 带缓存的快速模式 |
|
|||
|
|
|
|||
|
|
## 监控
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint watch "solana" -i 5m
|
|||
|
|
xint watch "@user" -i 1m
|
|||
|
|
xint watch "news" -i 30s --webhook https://example.com/webhook
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Webhook 安全说明:
|
|||
|
|
- 远程 Webhook 必须使用 `https://`
|
|||
|
|
- 仅本地/回环目标接受 `http://`
|
|||
|
|
- 可选主机白名单:`XINT_WEBHOOK_ALLOWED_HOSTS=hooks.example.com,*.internal.example`
|
|||
|
|
|
|||
|
|
按 `Ctrl+C` 显示本次会话统计。
|
|||
|
|
|
|||
|
|
## 流式接收(官方过滤流)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 查看当前流规则
|
|||
|
|
xint stream-rules
|
|||
|
|
|
|||
|
|
# 添加过滤流规则
|
|||
|
|
xint stream-rules add "from:elonmusk -is:retweet" --tag elon
|
|||
|
|
|
|||
|
|
# 连接到流
|
|||
|
|
xint stream
|
|||
|
|
|
|||
|
|
# JSONL 输出,接收 25 个事件后停止
|
|||
|
|
xint stream --jsonl --max-events 25
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 粉丝追踪
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint diff @user # 首次运行:创建快照
|
|||
|
|
xint diff @user # 再次运行:查看变化
|
|||
|
|
xint diff @user --following
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
需要 OAuth 授权。
|
|||
|
|
|
|||
|
|
## 列表(需 OAuth)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint lists
|
|||
|
|
xint lists create "AI Researchers" --description "高质量账号" --private
|
|||
|
|
xint lists members add <list_id> @username
|
|||
|
|
xint lists members remove <list_id> @username
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 黑名单与静音(需 OAuth)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint blocks
|
|||
|
|
xint blocks add @username
|
|||
|
|
xint blocks remove @username
|
|||
|
|
|
|||
|
|
xint mutes
|
|||
|
|
xint mutes add @username
|
|||
|
|
xint mutes remove @username
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 关注操作(需 OAuth)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint follow @username
|
|||
|
|
xint unfollow @username
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 媒体下载
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 通过推文 ID 下载媒体
|
|||
|
|
xint media 1900100012345678901
|
|||
|
|
|
|||
|
|
# 通过推文 URL 下载媒体
|
|||
|
|
xint media https://x.com/user/status/1900100012345678901
|
|||
|
|
|
|||
|
|
# 自定义输出目录 + JSON 摘要
|
|||
|
|
xint media 1900100012345678901 --dir ./downloads --json
|
|||
|
|
|
|||
|
|
# 仅下载第一个视频/GIF
|
|||
|
|
xint media 1900100012345678901 --video-only --max-items 1
|
|||
|
|
|
|||
|
|
# 仅下载图片
|
|||
|
|
xint media 1900100012345678901 --photos-only
|
|||
|
|
|
|||
|
|
# 自定义文件名模板
|
|||
|
|
xint media 1900100012345678901 --name-template "{username}-{created_at}-{index}"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 转发列表
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 查看谁转发了某条推文
|
|||
|
|
xint reposts <tweet_id>
|
|||
|
|
xint reposts <tweet_id> --limit 50 --json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 用户搜索
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 按关键词查找用户
|
|||
|
|
xint users "AI researcher"
|
|||
|
|
xint users "solana dev" --limit 10 --json
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 报告与分析
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint report "AI agents" --save
|
|||
|
|
xint analyze "加密货币有什么趋势?"
|
|||
|
|
xint article "https://..." --ai "总结"
|
|||
|
|
|
|||
|
|
# 从 X 推文中自动提取链接文章
|
|||
|
|
xint article "https://x.com/user/status/123" --ai "总结"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
默认分析模型现为 `grok-4-1-fast`。
|
|||
|
|
|
|||
|
|
## xAI 功能
|
|||
|
|
|
|||
|
|
### X 搜索(无需 X API)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint x-search --queries-file queries.json --out-md report.md
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### 集合(知识库)
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint collections list
|
|||
|
|
xint collections upload --path file.md
|
|||
|
|
xint collections search --query "主题"
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## AI Agent 技能
|
|||
|
|
|
|||
|
|
专为 Claude Code、OpenClaw 及其他 Agent 设计:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 将二进制文件 + SKILL.md 放入 agent 技能目录
|
|||
|
|
xint search "topic" --quick --json
|
|||
|
|
xint analyze --pipe "总结"
|
|||
|
|
xint report "topic" --save
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### MCP 服务器
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint mcp
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 费用
|
|||
|
|
|
|||
|
|
| 操作 | 费用 |
|
|||
|
|
|-----------|------|
|
|||
|
|
| 读取推文 | $0.005/条 |
|
|||
|
|
| 全量归档 | $0.01/条 |
|
|||
|
|
| 写操作 | $0.01/次 |
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
xint costs # 今日费用
|
|||
|
|
xint costs week # 近 7 天
|
|||
|
|
xint costs budget 2 # 设置每日 $2 限额
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 环境变量
|
|||
|
|
|
|||
|
|
| 变量 | 是否必填 | 说明 |
|
|||
|
|
|----------|----------|-------------|
|
|||
|
|
| `X_BEARER_TOKEN` | 是 | X API v2 Bearer Token |
|
|||
|
|
| `XAI_API_KEY` | 否 | xAI(用于分析/报告) |
|
|||
|
|
| `XINT_ARTICLE_TIMEOUT_SEC` | 否 | 文章抓取超时秒数(默认 30,范围 5-120) |
|
|||
|
|
| `X_CLIENT_ID` | 否 | OAuth(用于写操作) |
|
|||
|
|
|
|||
|
|
## 项目结构
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
xint-rs/
|
|||
|
|
├── src/
|
|||
|
|
│ ├── main.rs # 入口
|
|||
|
|
│ ├── cli.rs # 命令定义
|
|||
|
|
│ ├── client.rs # HTTP + 速率限制
|
|||
|
|
│ ├── api/ # X、xAI 封装
|
|||
|
|
│ └── commands/ # 20+ 命令实现
|
|||
|
|
├── data/ # 缓存、导出、快照
|
|||
|
|
└── SKILL.md # Agent 使用说明
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 构建
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
cargo build --release
|
|||
|
|
# 输出:target/release/xint(2.5MB)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 发布自动化
|
|||
|
|
|
|||
|
|
`xint-rs` 将发布工作委托给 `xint` 中的标准脚本。
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
# 在 xint-rs/ 目录下运行
|
|||
|
|
./scripts/release.sh --dry-run --allow-dirty
|
|||
|
|
# 所有参数均转发给标准 xint 脚本:
|
|||
|
|
./scripts/release.sh 2026.2.18.4
|
|||
|
|
./scripts/release.sh 2026.2.18.4 --no-clawdhub
|
|||
|
|
./scripts/release.sh 2026.2.18.4 --skillsh
|
|||
|
|
./scripts/release.sh 2026.2.18.4 --no-auto-notes
|
|||
|
|
./scripts/release.sh 2026.2.18.4 --report-dir /tmp/xint-release-reports
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
如果 `xint` 未作为同级目录检出,请设置:
|
|||
|
|
|
|||
|
|
```bash
|
|||
|
|
XINT_RELEASE_SCRIPT=/absolute/path/to/xint/scripts/release.sh
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
发布说明行为由标准脚本控制:
|
|||
|
|
|
|||
|
|
- 默认:GitHub 自动生成说明(`--generate-notes`)
|
|||
|
|
- 手动覆盖:设置 `CHANGELOG_ADDED`、`CHANGELOG_CHANGED`、`CHANGELOG_FIXED` 和/或 `CHANGELOG_SECURITY`
|
|||
|
|
- 默认:安装了 `clawdhub` CLI 时发布到 ClawdHub(用 `--no-clawdhub` 禁用)
|
|||
|
|
- 可选:使用 `--skillsh`(或 `--ai-skill` 同时发布两处)发布到 skills.sh
|
|||
|
|
- 发布报告:默认保存于 `reports/releases/<version>.md`(用 `--no-report` 禁用)
|
|||
|
|
- 报告默认作为附件上传到 GitHub Release(用 `--no-report-asset` 禁用)
|
|||
|
|
- 报告默认嵌入 GitHub Release 正文(用 `--no-report-body` 禁用)
|
|||
|
|
|
|||
|
|
## 安全
|
|||
|
|
|
|||
|
|
- Token 从环境变量读取,永不硬编码
|
|||
|
|
- OAuth Token:权限设为 `chmod 600`
|
|||
|
|
- 无遥测,无回传
|
|||
|
|
|
|||
|
|
详见 [SECURITY.md](docs/security.md)。
|
|||
|
|
|
|||
|
|
## 贡献
|
|||
|
|
|
|||
|
|
欢迎贡献代码。请先阅读[贡献指南](CONTRIBUTING.md)。
|
|||
|
|
|
|||
|
|
## ❤️ 支持项目
|
|||
|
|
|
|||
|
|
如果你觉得这个项目有用,欢迎支持我的开源工作。
|
|||
|
|
|
|||
|
|
[](https://buymeacoffee.com/nyk_builderz)
|
|||
|
|
|
|||
|
|
**Solana 捐赠地址**
|
|||
|
|
|
|||
|
|
`BYLu8XD8hGDUtdRBWpGWu5HKoiPrWqCxYFSh4oxXuvPg`
|
|||
|
|
|
|||
|
|
## 许可证
|
|||
|
|
|
|||
|
|
[](https://creativecommons.org/publicdomain/zero/1.0/)
|
|||
|
|
|
|||
|
|
在法律允许的范围内,作者已放弃本作品的所有版权及相关权利。
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
<p align="center">
|
|||
|
|
<a href="https://star-history.com/#0xNyk/xint-rs&Date">
|
|||
|
|
<img src="https://api.star-history.com/svg?repos=0xNyk/xint-rs&type=Date" alt="Star History" width="400">
|
|||
|
|
</a>
|
|||
|
|
</p>
|