# ai-sentiment > Fetch and analyze X/Twitter posts to extract AI keyword trends, sentiment distribution, and executive summary. Use when tracking AI industry discussions, generating sentiment reports, or analyzing AI model/product mentions. Also use when user asks to fetch/crawl/grab latest X content. - Author: littlesheepxy - Repository: Littlesheepxy/intelligence-skills - Version: 20260121150804 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/Littlesheepxy/intelligence-skills - Web: https://mule.run/skillshub/@@Littlesheepxy/intelligence-skills~ai-sentiment:20260121150804 --- --- name: ai-sentiment description: Fetch and analyze X/Twitter posts to extract AI keyword trends, sentiment distribution, and executive summary. Use when tracking AI industry discussions, generating sentiment reports, or analyzing AI model/product mentions. Also use when user asks to fetch/crawl/grab latest X content. --- # AI 舆情与趋势分析 ## 一句话目标 **一句话完成**:抓取 X 推文 → 分析 AI 关键词词频、情绪分布、热度趋势 → 输出结构化报告。 ## 适用场景 ✅ **适用**: - "抓取最近一周的 X 内容并分析 AI 舆情" - "重新抓取 AI 账号的最新推文,然后分析" - "分析 AI 舆情"(自动判断是否需要先抓取) - 追踪 AI 模型/产品/技术的舆情变化 - 生成周报/日报级别的趋势分析 ❌ **不适用**: - YouTube 视频内容分析(用 `investment-insights`) - 单条推文的深度解读 - 非 AI 领域的内容分析 --- ## ⚡ 一句话工作流(推荐) 用户说:**"抓取最近一周的 X 内容并分析 AI 舆情"** Claude 自动执行: ### Step 1: 抓取数据 ```bash cd /Users/littleyang/Desktop/intelligence-skills pnpm fetch:sentiment ``` ### Step 2: 读取数据库 ```bash sqlite3 data/contents.db "SELECT author, text, url, published_at FROM contents WHERE platform='x' AND published_at >= datetime('now', '-7 days') ORDER BY published_at DESC LIMIT 300;" ``` ### Step 3: 分析并输出报告 按照下面的"执行步骤"和"输出格式"分析内容。 --- ## 🔧 手动抓取命令(可选) 如果自动抓取失败,可以手动执行: ```bash # 抓取 AI 舆情账号(张咋啦推荐 + 扩展) pnpm fetch:sentiment pnpm fetch:sentiment:expanded # 指定时间范围 pnpm cli fetch-x --source zhangzhala_recommend --from 2026-01-14 --to 2026-01-21 # 指定账号 pnpm cli fetch-x --accounts sama,karpathy,ylecun --limit 50 # 查看数据库统计 pnpm cli storage-stats ``` --- ## 输入格式 ```typescript interface Input { contents: Array<{ text: string; // 必填:推文正文 url: string; // 必填:原文链接 author: string; // 必填:作者 @handle author_labels: string[];// 必填:身份标签 ["investor", "founder"] published_at: string; // 必填:ISO 8601 日期 }>; date_range: { from: string; // 必填:开始日期 to: string; // 必填:结束日期 }; } ``` **约束**: - `contents` 至少 10 条,建议 50-500 条 - `author_labels` 允许值:`investor`, `founder`, `fund`, `partner`, `researcher`, `operator`, `media`, `kol` --- ## 输出格式 ```typescript interface Output { keywords: Array<{ keyword: string; category: "model" | "product" | "technology" | "company" | "person" | "unknown_new"; count: number; trend: "rising" | "stable" | "declining"; }>; trending: Array<{ keyword: string; category: string; growth_rate: number; // >1 表示上升 trigger_event?: string; // 触发热度的事件 }>; sentiment_distribution: Array<{ keyword: string; positive: number; neutral: number; negative: number; dominant_sentiment: "positive" | "neutral" | "negative"; }>; representative_posts: Array<{ keyword: string; posts: Array<{ text: string; url: string; // 必须有! author: string; author_labels: string[]; sentiment: string; why_representative: string; }>; }>; executive_summary: { key_findings: string[]; // 3-5 条 narrative: string; // 300-500 字 action_suggestions: string[]; }; } ``` --- ## 执行步骤 1. **识别关键词**:扫描所有推文,提取 AI 相关实体 - 模型名(GPT-4, Claude, Gemini, Llama, DeepSeek...) - 产品名(ChatGPT, Copilot, Cursor, Perplexity...) - 技术概念(Agent, RAG, MoE, Reasoning...) - 公司名(OpenAI, Anthropic, Google...) - 人物名(Sam Altman, Demis Hassabis...) 2. **统计词频**:计算每个关键词的出现次数 3. **判断趋势**:根据时间分布判断 rising/stable/declining 4. **情绪分析**:对每条涉及关键词的推文判断情绪 - `positive`:看好、赞扬、期待 - `neutral`:客观陈述、信息分享 - `negative`:质疑、批评、担忧 5. **选取代表性原文**:每个重要关键词选 3-5 条,**必须包含 URL** 6. **生成总结**:3-5 条核心发现 + 300-500 字分析 + 建议 --- ## 示例 ### ✅ 正确示例 **输入**: ```json { "contents": [ { "text": "DeepSeek-V3 is impressive! The open source community is winning.", "url": "https://x.com/karpathy/status/123456", "author": "@karpathy", "author_labels": ["founder", "researcher"], "published_at": "2025-01-18T10:00:00Z" } ], "date_range": { "from": "2025-01-13", "to": "2025-01-20" } } ``` **输出**: ```json { "keywords": [ { "keyword": "DeepSeek-V3", "category": "model", "count": 45, "trend": "rising" } ], "trending": [ { "keyword": "DeepSeek-V3", "category": "model", "growth_rate": 2.3, "trigger_event": "DeepSeek-V3 开源发布" } ], "executive_summary": { "key_findings": ["DeepSeek-V3 发布引发热议,开源社区反响积极"], "narrative": "本周 AI 领域最大热点是 DeepSeek-V3 的发布...", "action_suggestions": ["关注 DeepSeek 后续迭代"] } } ``` ### ❌ 错误示例 **问题**:代表性原文缺少 URL ```json { "posts": [{ "text": "GPT-4 is great!", "author": "@someone" }] } ``` → **修正**:每条 post 必须包含 `url` 字段 --- ## 边界情况 | 情况 | 处理方式 | |------|---------| | 输入为空 | 返回错误 | | 内容少于 10 条 | 返回错误:内容数量不足 | | 无 AI 相关关键词 | 返回空结果 + 说明 | | 推文无 URL | 跳过该推文的代表性选取 | --- ## 如何获取输入数据 本 Skill 需要标准化的 X 推文 JSON 作为输入。你可以: ### 方式 1:使用配套工具(推荐) ```bash # 1. 克隆仓库 git clone https://github.com/your-org/intelligence-skills.git cd intelligence-skills && pnpm install # 2. 配置 API Key echo "TWITTER_API_KEY=your_key" >> .env # 3. 抓取 X 内容 pnpm cli fetch-x --from 2025-01-13 --to 2025-01-20 # 4. 导出数据(用于 Skill 输入) pnpm cli export --from 2025-01-13 --to 2025-01-20 -p x -o data/batch.json # 5. 运行 Skill pnpm cli run-skill -s ai-sentiment -i data/batch.json ``` ### 方式 2:手动准备 JSON 按照输入格式准备 JSON 文件,然后粘贴给 Claude。 ### 方式 3:API 集成 ```typescript import { runAISentimentSkill } from "@repo/intelligence-skills"; const result = await runAISentimentSkill({ batch: yourContentBatch, }); ``` --- ## 依赖与环境 | 依赖 | 用途 | 必需 | |------|------|------| | `ANTHROPIC_API_KEY` | Claude API 调用 | ✅ | | `TWITTER_API_KEY` | X 内容抓取(使用工具时) | 可选 | | 配套工具 `intelligence-skills` | 数据抓取与导出 | 可选 | --- ## 快捷命令 ```bash # 一键运行(抓取 + 分析 + 推送飞书) pnpm cli daily-sentiment --days 7 --push-feishu ```