Skip to content

chang-zy/xiaohongshu-skill

xiaohongshu-skills

Verified

小红书(RedNote / Xiaohongshu / XHS / RED / Little Red Book)浏览器自动化技能集合。 支持认证登录、内容发布、搜索发现、账号与评论分析、社交互动和复合运营。 当用户提到小红书、红书、RedNote、Xiaohongshu、XHS、RED、Little Red Book, 或要求发笔记、搜笔记、分析博主、评论、登录、点赞、收藏时触发。

scripts/xhs/local_discovery.py

View on GitHub
"""基于小红书当前浏览器会话的本地内容发现。"""

from __future__ import annotations

from .cdp import Page
from .search import search_feeds
from .types import Feed, FilterOption

_ALLOWED_SCOPES = {"同城", "附近"}


def _account_from_feed(feed: Feed) -> dict | None:
    """将一条公开笔记压缩为账号及其首条样本笔记。"""
    item = feed.to_dict()
    user = item.get("user") or {}
    user_id = str(user.get("userId") or "").strip()
    nickname = str(user.get("nickname") or "").strip()
    # 热搜推荐等非笔记卡片没有稳定账号,不应混进账号发现结果。
    if not user_id or not nickname:
        return None

    sample = {
        "feedId": item["id"],
        "xsecToken": item["xsecToken"],
        "title": item.get("displayTitle", ""),
        "type": item.get("type", ""),
        "interactInfo": item.get("interactInfo", {}),
    }
    if item.get("cover"):
        sample["cover"] = item["cover"]
    if item.get("video"):
        sample["video"] = item["video"]
    return {"userId": user_id, "nickname": nickname, "sampleNote": sample}


def unique_accounts_from_feeds(feeds: list[Feed], limit: int) -> list[dict]:
    """按账号去重,保留其在当前结果中的首条样本笔记。"""
    accounts: list[dict] = []
    seen_user_ids: set[str] = set()
    for feed in feeds:
        account = _account_from_feed(feed)
        if not account or account["userId"] in seen_user_ids:
            continue
        seen_user_ids.add(account["userId"])
        accounts.append(account)
        if len(accounts) >= limit:
            break
    return accounts


def browse_local_accounts(
    page: Page,
    keyword: str,
    *,
    scope: str = "同城",
    limit: int = 30,
    sort_by: str = "综合",
) -> dict:
    """以小红书当前会话的本地筛选浏览并返回去重的公开账号。"""
    if scope not in _ALLOWED_SCOPES:
        choices = "、".join(sorted(_ALLOWED_SCOPES))
        raise ValueError(f"本地范围必须是 {choices},实际为: {scope}")
    if not 1 <= limit <= 100:
        raise ValueError("--limit 必须在 1 到 100 之间")

    feeds = search_feeds(page, keyword, FilterOption(sort_by=sort_by, location=scope))
    accounts = unique_accounts_from_feeds(feeds, limit)
    return {
        "keyword": keyword,
        "localContext": {
            "mode": scope,
            "source": "小红书当前浏览器会话自动定位",
            "city": None,
            "cityStatus": "已应用本地筛选;页面未暴露可可靠读取的城市名称。",
        },
        "accounts": accounts,
        "count": len(accounts),
        "requestedLimit": limit,
        "warning": (
            "结果仅为关键词命中的公开账号,未验证账号主体的身份、年龄、性别或外貌;"
            "本地范围由小红书当前会话决定,不能视为精确位置。"
        ),
    }
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall