Skip to content

ZJU-REAL/Easel / skills/builtin/skill-xhs-analyzer

redbook

Flagged

小红书内容分析:搜索笔记、拉取互动数据、分析爆款规律、创作者画像、限流检测,支持 CLI 自动化操作。 当用户说"小红书数据分析""小红书爆款分析""笔记数据""小红书限流检测""小红书创作者画像""分析小红书账号"时使用。 发布与日常互动运营请用 skill-xhs-publisher。

FileKindSize
.github/workflows/npm-publish.ymlconfig3.8 KB
EASEL-META.mdmarkdown2.1 KB
SKILL.mdskill md5.2 KB
package-lock.jsonmanifest36.6 KB
package.jsonmanifest1.6 KB
references/commands.mdmarkdown4.4 KB
references/modules.mdmarkdown6.2 KB
references/platform-signals.mdmarkdown1.7 KB
references/research-loop.mdmarkdown8.2 KB
references/technical-reference.mdmarkdown3.8 KB
scripts/postinstall.jsscript4.5 KB
scripts/preuninstall.jsscript1.4 KB
social-preview.htmlother5.1 KB
social-preview.pngbinary261.4 KB
src/cli.tsscript76.8 KB
src/lib/analyze.tsscript20.0 KB
src/lib/cdp-cookies.tsscript13.1 KB
src/lib/client.tsscript22.2 KB
src/lib/cookies.tsscript13.3 KB
src/lib/creator-signing.tsscript1.8 KB
src/lib/detect.tsscript6.6 KB
src/lib/fingerprint-data.tsscript2.3 KB
src/lib/health.tsscript5.5 KB
src/lib/platform.tsscript2.7 KB
src/lib/render.tsscript19.5 KB
src/lib/reply-strategy.tsscript6.0 KB
src/lib/signing.tsscript21.1 KB
src/lib/template.tsscript8.0 KB
src/lib/url.tsscript1.8 KB
tsconfig.jsonconfig458 B

src/lib/health.ts

View on GitHub
/**
 * Note Health Check — detect hidden rate-limiting (限流) via creator API level field
 *
 * XHS assigns a hidden `level` to each note in the creator backend API response.
 * This level controls recommendation distribution but is never shown in the UI.
 *
 * Discovery credit: @xxx111god (Jason Zuo)
 * Reference: https://github.com/jzOcb/xhs-note-health-checker
 */

// ─── Level Definitions ──────────────────────────────────────────────────────

export interface LevelMeta {
  label: string;
  color: "green" | "lightGreen" | "yellow" | "red" | "darkRed" | "severe" | "gray";
  emoji: string;
  description: string;
}

const LEVEL_META: Record<string, LevelMeta> = {
  normal: { label: "L4 正常", color: "green", emoji: "🟢", description: "Normal distribution" },
  baseline: { label: "L2 基本", color: "lightGreen", emoji: "🟡", description: "Basically normal" },
  newPost: { label: "L1 新帖", color: "yellow", emoji: "⚪", description: "New post, under review" },
  softLimit: { label: "L-1 限流", color: "red", emoji: "🔴", description: "Mild throttling" },
  moderate: { label: "中度限流", color: "darkRed", emoji: "🔴", description: "Moderate throttling" },
  severe: { label: "L-102 严重", color: "severe", emoji: "⛔", description: "Severe (irreversible)" },
  unknown: { label: "未知", color: "gray", emoji: "❓", description: "Unknown level" },
};

export function getLevelMeta(level: number): LevelMeta & { level: number } {
  let meta: LevelMeta;
  if (level === -102) meta = LEVEL_META.severe;
  else if (level <= -5) meta = { ...LEVEL_META.moderate, label: `L${level} 中度` };
  else if (level === -1) meta = LEVEL_META.softLimit;
  else if (level === 1) meta = LEVEL_META.newPost;
  else if (level >= 4) meta = LEVEL_META.normal;
  else if (level >= 2) meta = { ...LEVEL_META.baseline, label: `L${level} 基本` };
  else meta = { ...LEVEL_META.unknown, label: `L${level}` };
  return { ...meta, level };
}

// ─── Sensitive Word Detection ───────────────────────────────────────────────

const SENSITIVE_WORDS = [
  "自动化",
  "自动发布",
  "AI生成",
  "内容工厂",
  "批量",
  "全自动",
  "自动工作流",
  "AI自动",
];

export function detectSensitiveWords(title: string): string[] {
  return SENSITIVE_WORDS.filter((word) => title.includes(word));
}

// ─── Tag Count Check ────────────────────────────────────────────────────────

const MAX_RECOMMENDED_TAGS = 5;

export function checkTagCount(note: Record<string, unknown>): { count: number; warning: boolean } {
  const arrayCandidates = [
    note.tag_list, note.tags, note.topic_list,
    note.topics, note.hash_tag_list, note.hashtag_list, note.hash_tag,
  ];
  for (const candidate of arrayCandidates) {
    if (Array.isArray(candidate)) return { count: candidate.length, warning: candidate.length > MAX_RECOMMENDED_TAGS };
  }
  const numericCandidates = [note.tag_count, note.topic_count, note.hashtag_count];
  for (const candidate of numericCandidates) {
    if (typeof candidate === "number") return { count: candidate, warning: candidate > MAX_RECOMMENDED_TAGS };
  }
  return { count: 0, warning: false };
}

// ─── Note Diagnostics ───────────────────────────────────────────────────────

export interface NoteDiagnostics {
  noteId: string;
  title: string;
  level: number;
  levelMeta: LevelMeta;
  sensitiveHits: string[];
  tagCount: number;
  tagWarning: boolean;
}

export function diagnoseNote(note: Record<string, unknown>): NoteDiagnostics {
  const noteId = String(note.note_id ?? note.noteId ?? note.id ?? note.item_id ?? note.display_id ?? "");
  const title = String(note.display_title ?? note.title ?? note.note_title ?? note.name ?? "");

  // Level extraction with fallback cascade (matches Chrome extension logic)
  const levelValue = Number(
    note.level_ ?? note.level ?? note.distribution_level ?? note.status_level ?? NaN
  );
  const level = Number.isFinite(levelValue) ? levelValue : 1;

  const levelMeta = getLevelMeta(level);
  const sensitiveHits = detectSensitiveWords(title);
  const { count: tagCount, warning: tagWarning } = checkTagCount(note);

  return { noteId, title, level, levelMeta, sensitiveHits, tagCount, tagWarning };
}

// ─── Health Report ──────────────────────────────────────────────────────────

export interface HealthReport {
  totalNotes: number;
  notes: NoteDiagnostics[];
  distribution: Record<string, number>;
  limitedNotes: NoteDiagnostics[];
  sensitiveNotes: NoteDiagnostics[];
}

export function buildHealthReport(rawNotes: Record<string, unknown>[]): HealthReport {
  const notes = rawNotes.map(diagnoseNote);
  const distribution: Record<string, number> = {};

  for (const n of notes) {
    const key = n.levelMeta.emoji + " " + n.levelMeta.label;
    distribution[key] = (distribution[key] ?? 0) + 1;
  }

  const limitedNotes = notes.filter((n) => n.level < 1);
  const sensitiveNotes = notes.filter((n) => n.sensitiveHits.length > 0 || n.tagWarning);

  return { totalNotes: notes.length, notes, distribution, limitedNotes, sensitiveNotes };
}
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated 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: 322kUpdated Claude CodeCodexVerifiedInstall