{"id":49209249,"url":"https://github.com/fancyboi999/goofish-cli","last_synced_at":"2026-04-23T20:30:39.094Z","repository":{"id":353007413,"uuid":"1217098957","full_name":"fancyboi999/goofish-cli","owner":"fancyboi999","description":"闲鱼 CLI · 原生支持 MCP · 为 AI Agent 而生 | Goofish (Xianyu) automation CLI · MCP-ready · Built for AI Agents","archived":false,"fork":false,"pushed_at":"2026-04-22T04:35:06.000Z","size":284,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-22T05:20:13.929Z","etag":null,"topics":["ai-agent","automation","claude","cli","goofish","mcp","mcp-server","python","typer","websocket","xianyu"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fancyboi999.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-21T14:43:07.000Z","updated_at":"2026-04-22T04:35:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fancyboi999/goofish-cli","commit_stats":null,"previous_names":["fancyboi999/goofish-cli"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fancyboi999/goofish-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fancyboi999%2Fgoofish-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fancyboi999%2Fgoofish-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fancyboi999%2Fgoofish-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fancyboi999%2Fgoofish-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fancyboi999","download_url":"https://codeload.github.com/fancyboi999/goofish-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fancyboi999%2Fgoofish-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32198224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T20:19:26.138Z","status":"ssl_error","status_checked_at":"2026-04-23T20:19:23.520Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","automation","claude","cli","goofish","mcp","mcp-server","python","typer","websocket","xianyu"],"created_at":"2026-04-23T20:30:37.166Z","updated_at":"2026-04-23T20:30:39.088Z","avatar_url":"https://github.com/fancyboi999.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# goofish-cli\n\n**闲鱼 CLI · 原生支持 MCP · 为 AI Agent 而生**\n\n*Goofish (Xianyu) automation CLI · MCP-ready · Built for AI Agents*\n\n[![CI](https://github.com/fancyboi999/goofish-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/fancyboi999/goofish-cli/actions/workflows/ci.yml)\n[![PyPI version](https://img.shields.io/pypi/v/goofish-cli.svg)](https://pypi.org/project/goofish-cli/)\n[![Python](https://img.shields.io/pypi/pyversions/goofish-cli.svg)](https://pypi.org/project/goofish-cli/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](./LICENSE)\n[![MCP](https://img.shields.io/badge/MCP-ready-8A2BE2)](https://modelcontextprotocol.io)\n[![GitHub stars](https://img.shields.io/github/stars/fancyboi999/goofish-cli?style=social)](https://github.com/fancyboi999/goofish-cli)\n\n\u003c/div\u003e\n\n`goofish-cli` 把闲鱼（Xianyu/Goofish）的核心运营能力抽成一套结构化命令，\n**同一份定义**同时输出给三种消费者：\n\n- 👨‍💻 **人类**：`goofish item get 12345 --format table`\n- 🤖 **AI Agent（Claude Code / Cursor / Codex）**：`uvx goofish-cli` → 自动注册成 MCP tool\n- 🧩 **Claude Skills**（v0.3）：5 个内置 skill，`goofish skills install` 一行装到 `~/.claude/skills/`\n\n\u003e 架构思想来自 [opencli](https://github.com/jackwener/opencli) 的 single-registry 设计。\n\n---\n\n## ✨ 核心特性\n\n- 🔐 **16 个命令覆盖核心链路**：发布、下架、查询、图片上传、AI 类目识别、默认地址、IM 收发 + 会话列表、skills 安装\n- 📡 **真·实时 IM**：WebSocket 长连 + 自动重连 + **三类事件分类输出**\n  - `event=message`（收到消息）· `event=read`（已读回执）· `event=new_msg`（轻量通知）\n- 🛡 **内置风控护栏**：令牌桶限流（1 写/分钟）+ RGV587 自动熔断\n- 🧠 **AI-first I/O**：`--format json/yaml/table/md/csv`，给 LLM 喂 JSON、给人看表格\n- ⚡ **一次定义，三种入口**：CLI / MCP / Skill 共享同一 registry\n- ✅ **真实端到端验证**：每个命令都跑过真实账号\n\n---\n\n## 🚀 60 秒上手\n\n```bash\n# 1. 安装\npip install goofish-cli    # 或 uv pip install goofish-cli\n\n# 2. 导入 cookie（从浏览器 DevTools → Application → Cookies 导出）\ngoofish auth login ~/Downloads/goofish-cookies.json\n\n# 3. 验证登录态\ngoofish auth status\n# → {\"unb\":\"2214350705775\",\"tracknick\":\"xy575986224572\",\"nick\":\"...\",\"valid\":true}\n\n# 4. 干活\ngoofish item get 1045171414271\ngoofish message watch                               # 实时接收消息\ngoofish message send \u003ccid\u003e \u003ctoid\u003e --text \"在的\"    # 发消息\n```\n\n---\n\n## 🧩 Claude Skills（v0.3 新增）\n\nv0.3 起内置 5 个 Claude Skill，装完之后 Claude Code / Cursor 里的 Agent 在识别到\n闲鱼任务就会自动加载对应 skill 的知识库，**不再靠 zero-shot 试错**。\n\n```bash\n# 装到 ~/.claude/skills/（默认）\ngoofish skills install\n\n# 或者只看有哪些 skill，不拷贝\ngoofish skills install --list\n\n# 或者装到自定义目录 + 覆盖已有的\ngoofish skills install --dest ./skills --force\n```\n\n### 5 个 skill 分工\n\n| Skill | 什么时候激活 | 核心能力 |\n|---|---|---|\n| `goofish-overview` | 用户首次提闲鱼 / 问这工具能干啥 | 总入口，dispatch 到其他 4 个 skill |\n| `goofish-publish-item` | 发商品 / 上架 / 挂闲置 | 类目识别 → 标题 5 段式 → 风控扫描 → 图片检查 → 确认发布 |\n| `goofish-reply-buyer` | 回消息 / 看未读 / 议价 | 拉未读 → 意图 5 分类 → 议价三档（小刀/大刀/屠龙刀）→ 用户确认发送 |\n| `goofish-risk-guard` | 发布前 / 发送前 / 被限流了 | 违禁词表、外联词正则、发布红线、x5sec 恢复指引（被其他 skill 频繁引用） |\n| `goofish-shop-diagnosis` | 店铺没流量 / 曝光掉了 | 买家视角搜索 + 历史对比 → 归因清单 + 修复建议（纯读不写） |\n\nskill 的源文件在仓库的 `skills/` 目录下（每个 skill 一个子目录，含 `SKILL.md`\n+ `references/*.md` 知识库）。也可以走 Claude Code Plugin Marketplace 安装：\n\n```bash\nclaude /plugin marketplace add fancyboi999/goofish-cli\n```\n\n---\n\n## 📟 命令详略与真实输出\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003e\u003ccode\u003egoofish list-commands\u003c/code\u003e\u003c/b\u003e — 注册表全景\u003c/summary\u003e\n\n```bash\n$ goofish list-commands --format table\n```\n\n| 命令 | 说明 | 写操作 |\n|---|---|:-:|\n| `auth login` | 从 JSON 文件或 cookie 字符串导入登录态 | ❌ |\n| `auth status` | 检查登录态是否有效 | ❌ |\n| `auth reset-guard` | 手动解除风控熔断 | ❌ |\n| `item get` | 查询闲鱼商品详情 | ❌ |\n| `item publish` | 发布商品（自动识别类目 + 默认地址） | ✅ |\n| `item delete` | 下架/删除商品 | ✅ |\n| `media upload` | 上传图片到闲鱼 CDN | ✅ |\n| `category recommend` | AI 识别商品类目 | ❌ |\n| `location default` | 获取默认发布地址 | ❌ |\n| `message list-chats` | 拉取会话列表（左栏；`--watch-secs N` 叠加 WS 历史推送补漏） | ❌ |\n| `search items` | 搜索闲鱼商品（浏览器路径 Playwright + 系统 Chrome） | ❌ |\n| `item view` | 浏览器视角看商品详情（字段完整，抗风控；`item get` 的姊妹版） | ❌ |\n| `message history` | 拉取会话历史消息 | ❌ |\n| `message send` | 发送文本/图片 | ✅ |\n| `message watch` | 常驻 IM 长连（JSONL 输出） | ❌ |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e\u003ccode\u003egoofish auth status\u003c/code\u003e\u003c/b\u003e — 登录态健康检查\u003c/summary\u003e\n\n```json\n{\n  \"unb\": \"2214350705775\",\n  \"tracknick\": \"xy575986224572\",\n  \"nick\": \"闲鱼用户昵称\",\n  \"valid\": true,\n  \"h5_token_exp\": \"2026-04-21T20:30:00+08:00\"\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e\u003ccode\u003egoofish message watch\u003c/code\u003e\u003c/b\u003e — 三类事件 JSONL 流\u003c/summary\u003e\n\n```bash\n$ goofish message watch\n```\n\n实时输出（小号给主号发 3 条 + 主号读了所有消息）：\n\n```jsonl\n{\"event\":\"message\",\"cid\":\"60585751957\",\"send_user_id\":\"2215266653893\",\"send_user_name\":\"小号昵称\",\"send_message\":\"测试消息1\"}\n{\"event\":\"message\",\"cid\":\"60585751957\",\"send_user_id\":\"2215266653893\",\"send_user_name\":\"小号昵称\",\"send_message\":\"测试消息2\"}\n{\"event\":\"message\",\"cid\":\"60585751957\",\"send_user_id\":\"2215266653893\",\"send_user_name\":\"小号昵称\",\"send_message\":\"测试消息3\"}\n{\"event\":\"read\",\"cid\":\"60585751957\",\"msg_ids\":[\"4077151826249.PNM\",\"4066820235744.PNM\",\"4066826134477.PNM\"],\"status\":1,\"ts\":\"1776770953455\"}\n```\n\n| 事件 | 字段 |\n|---|---|\n| `message` | cid · send_user_id · send_user_name · send_message · content_type |\n| `read` | cid · msg_ids[] · status · ts |\n| `new_msg` | cid · msg_id · ts（服务端只推指针，需 `message history` 拉正文） |\n\n**自动跳过噪音**：`/s/para`（对方正在输入）、`contentType=8`（会话激活心跳）。\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e\u003ccode\u003egoofish message send\u003c/code\u003e\u003c/b\u003e — 主动发消息\u003c/summary\u003e\n\n```bash\n$ goofish message send 60585751957 2215266653893 \\\n    --text \"在的 claude 测试成功 ✅\" --item-id 1045171414271\n```\n\n```json\n{\"ok\": true, \"mid\": \"1061776769407570\", \"cid\": \"60585751957\"}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e\u003ccode\u003egoofish item publish\u003c/code\u003e\u003c/b\u003e — 发布商品（含风控护栏）\u003c/summary\u003e\n\n```bash\n$ goofish item publish \\\n    --title \"男士毛呢大衣 驼色长款\" \\\n    --desc \"全新未拆封 原价 2999 现 999\" \\\n    --images ./a.png,./b.png \\\n    --price 999\n```\n\n流程：\n1. `media upload` 每张图 → CDN URL + 尺寸\n2. `category recommend` 拿 AI 识别的 catId\n3. `location default` 拿默认地址\n4. `mtop.idle.pc.idleitem.publish` 落库\n\n返回：\n```json\n{\"ok\": true, \"itemId\": \"1046118265141\", \"status\": \"published\"}\n```\n\n**触发令牌桶限流**（1 写/分钟）。高频调用会被本地拒绝，避免被闲鱼风控。\n\u003c/details\u003e\n\n---\n\n## 🔌 接入 Claude Code（MCP）\n\n在 `~/.config/claude-code/config.json`：\n\n```json\n{\n  \"mcpServers\": {\n    \"goofish\": {\n      \"command\": \"uvx\",\n      \"args\": [\"goofish-cli\"]\n    }\n  }\n}\n```\n\nClaude 会自动把全部命令看成 tool：`goofish_item_get` / `goofish_item_publish` / `goofish_message_watch`... 你在对话里直接说\"帮我看下 itemId=xxx 的详情\"，Claude 就会调用。\n\n---\n\n## 🎯 项目亮点\n\n| 能力 | 说明 |\n|---|---|\n| 11 个核心 mtop 接口 | 发布/下架/查询/图片/类目/地址/IM 全覆盖 |\n| CLI + `--format` 多格式输出 | `json` / `yaml` / `table` / `md` / `csv`，人机两用 |\n| MCP Server | `uvx goofish-cli` 一行接入 Claude Code / Cursor |\n| WebSocket 批量 push 全量解码 | 一帧多条消息全部还原，不丢单 |\n| WebSocket 自动重连 | 断线自退避重连，长跑无感知 |\n| 已读回执 / typing / 新消息通知分类 | `/s/sync` 元事件结构化为三类 JSONL |\n| 全局限流 + 风控熔断 | 令牌桶 1 写/分钟 + RGV587 自动熔断 |\n| 单元测试 | 33 个，ruff 零告警 |\n| 包分发 | `pip install goofish-cli` / `uvx goofish-cli` |\n\n---\n\n## 🗺 Roadmap\n\n- [x] v0.1：12 个命令 + MCP + IM 三类事件\n- [x] v0.2：`goofish message list-chats`（会话列表 + sessionType 分类：1 真人 / 3 系统 / 6 互动 / 23 通知；`--watch-secs` 支持合并 WS `ackDiff(pts=0)` 历史推送补齐 h5 接口漏掉的会话）\n- [x] v0.2：浏览器自动化链路（吸纳 [OpenCLI](https://github.com/jackwener/opencli) 精华）—— Playwright + 系统 Chrome 驱动 `goofish search items` / `goofish item view`，抗风控 \u0026 完整字段\n- [x] v0.2.3 / v0.2.4：session 自动续命（passport 快速进入）+ `auth login --qr` 扫码兜底\n- [x] v0.3：Claude Skills 包装（5 个 skill：overview / risk-guard / publish-item / reply-buyer / shop-diagnosis）+ `goofish skills install`\n- [ ] v0.4：`goofish message create-chat`（主动与陌生用户建会话）\n- [ ] v0.4：`goofish order`（订单状态查询 / 发货）\n- [ ] v0.4：历史数据落盘（SQLite / JSONL），给 shop-diagnosis 做时序归因\n- [ ] v0.5：支持发视频消息\n\n---\n\n## 🛠 开发\n\n```bash\ngit clone https://github.com/fancyboi999/goofish-cli\ncd goofish-cli\nuv venv --python 3.11\nuv pip install -e \".[dev]\"\n\nuv run pytest                # 33 测全绿\nuv run ruff check src tests  # 零告警\n```\n\n详细请看 [CONTRIBUTING.md](./CONTRIBUTING.md) 和 [docs/architecture.md](./docs/architecture.md)。\n\n---\n\n## ⚠️ 合规声明\n\n本工具**仅用于用户自有账号**的自动化运营。**严禁**：\n\n- 欺诈 / 刷单 / 虚假交易\n- 针对闲鱼平台的 SaaS 化转售\n- 违反闲鱼、淘宝、阿里巴巴用户协议的行为\n\n工具不提供：绕过滑块验证、批量设备 ID 伪造、自动化规避封号。遇到风控请人工处理（见 [docs/compliance.md](./docs/compliance.md)）。\n\n---\n\n## 📜 License\n\nApache-2.0 © 2026 fancy。详见 [LICENSE](./LICENSE) 和 [NOTICE](./NOTICE)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffancyboi999%2Fgoofish-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffancyboi999%2Fgoofish-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffancyboi999%2Fgoofish-cli/lists"}