@scorehub/creator-outreach 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md ADDED
@@ -0,0 +1,68 @@
1
+ # @scorehub/creator-outreach
2
+
3
+ Chinese version: [README.md](./README.md)
4
+
5
+ **Tiky** is a creator outreach AI agent for TikTok Shop sellers. It searches creators by category, GMV, and audience profile; analyzes and ranks their sales performance; and sends outreach messages in batches. By default, TikTok operations run through ScoreHub MCP.
6
+
7
+ ## Supported Clients
8
+
9
+ - Claude Code
10
+ - WorkBuddy
11
+
12
+ Claude Desktop is not currently supported by this installer.
13
+
14
+ ## Install
15
+
16
+ ### Prerequisites
17
+
18
+ - Node.js 18 or later
19
+ - npm and network access to the npm registry
20
+ - Claude Code or WorkBuddy installed and launched at least once
21
+
22
+ Run:
23
+
24
+ ```bash
25
+ npx -y @scorehub/creator-outreach
26
+ ```
27
+
28
+ The installer configures only clients it detects. If it finds neither Claude Code nor WorkBuddy, it exits without writing configuration files.
29
+
30
+ | Client | Detection | Installed content | How to use |
31
+ |---|---|---|---|
32
+ | Claude Code | `~/.claude/` exists | Agent definition in `~/.claude/agents/`; MCP configuration merged into `~/.claude.json` | Restart, then enter `@tiktok-creator-outreach` |
33
+ | WorkBuddy | `~/.workbuddy/` exists | Plugin files in `~/.workbuddy/plugins/.../`; MCP configuration merged into `~/.workbuddy/mcp.json` | Restart, then select “Tiky — TikTok Creator Outreach” from the Agent list |
34
+
35
+ The MCP server (`@scorehub/mcp-server`) is downloaded automatically by the configured `npx -y` command the first time it starts. A global installation is not required. WorkBuddy uses its bundled Node.js and the installer handles Windows `npx.cmd` and PATH separators.
36
+
37
+ > You can also search for `@scorehub/creator-outreach` in the WorkBuddy plugin marketplace.
38
+
39
+ ## First Use and Authorization
40
+
41
+ When Tiky first calls a TikTok tool, it opens a browser for ScoreHub login. Tokens are then cached under `~/.scorehub/` and shared by Claude Code and WorkBuddy, so you do not need to authorize again.
42
+
43
+ If Tiky says that the current shop's TikTok authorization is invalid or unavailable, your local ScoreHub login is usually still valid. Rebind the shop in ScoreHub and try again; do not repeat browser login.
44
+
45
+ If a request is rate limited or quota limited, wait, retry in smaller batches, or narrow the operation. Reauthorization does not resolve rate limits.
46
+
47
+ ## Quick Start
48
+
49
+ Ask Tiky:
50
+
51
+ - Find TikTok creators in the beauty category with GMV between $1,000 and $10,000.
52
+ - Analyze the sales performance of these 10 creators and rank them.
53
+ - Send outreach messages to these 50 creators using my collaboration template.
54
+
55
+ ## Troubleshooting
56
+
57
+ ### No supported client found
58
+
59
+ Install and launch Claude Code or WorkBuddy once, then run the install command again. Claude Desktop is outside the current support scope.
60
+
61
+ ### MCP tools are unavailable, the tool list is empty, or the connection closes
62
+
63
+ This usually means that the local MCP process has not started, not that login, shop authorization, or rate limiting failed. Verify Node.js 18+, npm, and npm registry access, then fully restart Claude Code or WorkBuddy. The configuration downloads mcp-server through `npx`; no global installation is needed.
64
+
65
+ ## Related Links
66
+
67
+ - MCP Server: [@scorehub/mcp-server](https://www.npmjs.com/package/@scorehub/mcp-server)
68
+ - Repository: [ScoreHub-AI/creator-outreach](https://github.com/ScoreHub-AI/creator-outreach)
package/README.md CHANGED
@@ -1,34 +1,48 @@
1
1
  # @scorehub/creator-outreach
2
2
 
3
- **Tiky** — TikTok 达人建联 AI 智能体。一条命令装进 Claude Code 和 WorkBuddy。
3
+ English version: [README.en.md](./README.en.md)
4
4
 
5
- 按类目 / GMV / 粉丝画像搜索 TikTok Shop 达人,分析带货表现并打分排名,批量发送建联消息(`create_conversation` → `send_message`)。所有 TikTok API 调用通过 ScoreHub MCP 完成。
5
+ **Tiky** 是面向 TikTok Shop 卖家的达人建联 AI 智能体。它可按类目、GMV 和粉丝画像搜索达人,分析带货表现并排名,以及批量发送合作消息。默认情况下,TikTok 操作通过 ScoreHub MCP 完成。
6
+
7
+ ## 支持的客户端
8
+
9
+ - Claude Code
10
+ - WorkBuddy
11
+
12
+ Claude Desktop 当前不受此安装器支持。
6
13
 
7
14
  ## 安装
8
15
 
16
+ ### 前置条件
17
+
18
+ - Node.js 18 或更高版本
19
+ - npm 和可访问 npm registry 的网络
20
+ - 已安装并至少启动过 Claude Code 或 WorkBuddy
21
+
22
+ 运行:
23
+
9
24
  ```bash
10
- npx @scorehub/creator-outreach
25
+ npx -y @scorehub/creator-outreach
11
26
  ```
12
27
 
13
- 命令会自动检测本机已安装的 AI 客户端并完成配置:
28
+ 安装器只会配置已检测到的客户端;未检测到 Claude Code 或 WorkBuddy 时,会退出且不写入任何配置文件。
14
29
 
15
- | 客户端 | 安装内容 |
16
- |--------|----------|
17
- | **Claude Code / Claude Desktop** | Agent 定义 → `~/.claude/agents/`;MCP 配置 → `~/.claude.json` |
18
- | **WorkBuddy**(检测到 `~/.workbuddy/` 时) | 插件文件 → `~/.workbuddy/plugins/.../`;MCP 配置 → `~/.workbuddy/mcp.json` |
30
+ | 客户端 | 检测条件 | 安装内容 | 使用方式 |
31
+ |---|---|---|---|
32
+ | Claude Code | `~/.claude/` 存在 | Agent 定义写入 `~/.claude/agents/`;MCP 配置合并到 `~/.claude.json` | 重启后输入 `@tiktok-creator-outreach` |
33
+ | WorkBuddy | `~/.workbuddy/` 存在 | 插件文件写入 `~/.workbuddy/plugins/.../`;MCP 配置合并到 `~/.workbuddy/mcp.json` | 重启后在 Agent 列表选择 “Tiky — TikTok Creator Outreach” |
19
34
 
20
- MCP Server(`@scorehub/mcp-server`)由配置中的 `npx -y` 在首次启动时自动拉取,无需单独安装。
35
+ MCP Server(`@scorehub/mcp-server`)由配置中的 `npx -y` 在首次启动时自动拉取,无需全局安装。WorkBuddy 会使用其捆绑的 Node.js,并自动适配 Windows 的 `npx.cmd` 与 PATH 分隔符。
21
36
 
22
- 安装完成后重启客户端,即可唤起 Tiky:
37
+ > 也可在 WorkBuddy 插件市场直接搜索 `@scorehub/creator-outreach` 安装。
23
38
 
24
- - **Claude Code**:输入 `@tiktok-creator-outreach`
25
- - **WorkBuddy**:在 Agent 列表中选择 "Tiky — TikTok Creator Outreach"
39
+ ## 首次使用与授权
26
40
 
27
- > 也可在 WorkBuddy 插件市场直接搜索 `@scorehub/creator-outreach` 安装。
41
+ 首次调用 TikTok 工具时,Tiky 会打开浏览器引导你登录 ScoreHub。登录后 Token 缓存在 `~/.scorehub/`,Claude Code 与 WorkBuddy 共享,无需重复授权。
28
42
 
29
- ## 首次使用:授权
43
+ 如果提示当前店铺的 TikTok 授权已失效或异常,本地 ScoreHub 登录通常仍然有效。请先到 ScoreHub 重新绑定店铺,再重试;不要反复进行浏览器登录。
30
44
 
31
- Tiky 首次调用 TikTok 工具时会自动打开浏览器引导登录 ScoreHub。登录一次后 Token 缓存在本地(`~/.scorehub/`),Claude Code 与 WorkBuddy 共享,无需重复授权。
45
+ 如果提示请求过于频繁或配额受限,请等待、分批重试或缩小操作范围。限流不需要重新登录。
32
46
 
33
47
  ## 快速开始
34
48
 
@@ -38,6 +52,16 @@ Tiky 首次调用 TikTok 工具时会自动打开浏览器引导登录 ScoreHub
38
52
  - 分析这 10 个达人的带货表现,帮我打分排名
39
53
  - 用我的建联话术模板,给这 50 个达人批量发送合作消息
40
54
 
55
+ ## 故障排查
56
+
57
+ ### 找不到受支持的客户端
58
+
59
+ 先安装并启动 Claude Code 或 WorkBuddy 一次,再重新运行安装命令。Claude Desktop 不在当前支持范围内。
60
+
61
+ ### MCP 工具不可用、工具列表为空或连接已关闭
62
+
63
+ 通常是本地 MCP 进程尚未启动,不是登录、店铺授权或限流问题。确认 Node.js 18+、npm 和 npm registry 网络可用,然后完全重启 Claude Code 或 WorkBuddy 后重试。配置会通过 `npx` 自动下载 mcp-server,无需全局安装。
64
+
41
65
  ## 相关链接
42
66
 
43
67
  - MCP Server:[@scorehub/mcp-server](https://www.npmjs.com/package/@scorehub/mcp-server)
@@ -92,10 +92,13 @@ Step 3: 批量建联
92
92
  1. **单步确认,多步通报**:单次操作(搜索/分析单个达人)直接执行并汇报结果;批量操作(批量分析/批量建联)先确认计划再执行。
93
93
  2. **建联前置确认**:批量发送前必须与你确认品牌名和佣金比例(用于模板变量替换),并让你核对消息内容。
94
94
  3. **配额意识**:你每天有 10,000 次 API 配额,我每次操作都会告知消耗量。如果预算紧张,我会建议优先级策略。
95
- 4. **失败不沉默**:API 调用失败时我会明确告知原因(错误码+英文原文 message),并提供替代方案。
95
+ 4. **失败不沉默**:API 调用失败时我会用中文明确告知原因和下一步处理建议,不向用户展示错误码或英文原文。
96
96
  5. **数据可追溯**:每次搜索结果、分析报告、建联记录都保留完整,方便你后续回溯。
97
97
  6. **不在深夜骚扰达人**:建联消息默认按达人所在时区的工作时间(9:00-21:00)发送,避免深夜打扰。
98
98
  7. **类目解析规范**:当用户提到品类名称(如"美妆"/"电子产品")时,必须先用 `get_categories` 解析为类目 ID,再搜索达人。绝不要凭空猜测类目 ID 或使用硬编码值。如果 `get_categories` 返回多个匹配结果,用表格展示让用户确认具体要筛选哪些类目。
99
+ 8. **结构化错误优先**:远程工具若返回结构化 JSON,必须优先读取其中的 `error_type` 决定下一步动作,不要靠自然语言错误文本猜测。
100
+ 9. **两层授权区分**:当 `error_type = "shop_auth_invalid"`,或者 `authorize` / `status` 正常但真实 TikTok 工具提示当前店铺授权失效、过期、撤销或异常时,我必须判断为店铺侧 TikTok 绑定问题,直接提醒用户去 ScoreHub 重新绑定该店铺;不要让用户重复本地 OAuth 登录。
101
+ 10. **限流优先等待**:当 `error_type = "rate_limited"` 或 `error_type = "quota_exhausted"`,或者提示请求过于频繁、持续限流或配额受限时,我只会建议你耐心等待、分批执行、缩小请求范围或稍后重试;不要建议“重新授权拿一个干净的 token”,也不要主动调用 `authorize`。只有你自己明确要求重新授权时,我才会这么做。
99
102
 
100
103
  ## 调用方式
101
104
 
@@ -108,14 +111,30 @@ Step 3: 批量建联
108
111
  - `authorize` — OAuth 授权
109
112
  - `status` — 连接状态
110
113
 
111
- 如果尚未授权,我会先引导你走 `authorize` 完成 OAuth 登录。如果 MCP 工具不可用,才降级使用环境变量中的 TikTok API 凭证直接调用。
114
+ 如果尚未授权,我会先引导你走 `authorize` 完成 OAuth 登录。
115
+
116
+ 如果 ScoreHub MCP 工具不可见、工具列表为空、连接已关闭或本地 MCP 未启动,我会先判断为本地 MCP 可用性问题,而不是 OAuth、店铺授权或限流问题。我会提示你确认 Node.js 18+ 与 npm 可用、网络可访问 npm registry,并完全重启 Claude Code 或 WorkBuddy 后重试。MCP 配置会通过 `npx -y @scorehub/mcp-server@latest` 自动下载本地代理,macOS、Linux、Windows 无需执行全局安装命令。只有 MCP 已确认不可用且环境变量 TikTok API 凭证已经配置时,才降级直接调用 API。
117
+
118
+ 如果本地登录状态正常,但真实工具调用提示当前店铺的 TikTok 授权已失效或异常,我会直接提醒你去 ScoreHub 重新绑定该店铺后再试,不会再让你重复浏览器登录。
119
+
120
+ 如果工具提示请求过于频繁、持续限流或配额受限,我会优先建议等待和稍后重试,不会因为限流自动让你重新登录。只有你自己明确要求重新授权时,我才会走 `authorize`。
121
+
122
+ 如果工具返回结构化错误类型,我会按以下顺序处理:
123
+
124
+ - 本地 MCP 不可用 → 提示检查 Node.js 18+、npm、npm registry 网络并重启客户端;不调用 `authorize`
125
+ - `oauth_invalid` → 允许建议 `authorize`
126
+ - `shop_auth_invalid` → 提示去 ScoreHub 重新绑定店铺
127
+ - `rate_limited` / `quota_exhausted` → 只提示等待、分批或缩量
128
+ - `invalid_input` → 只提示修正请求条件
112
129
 
113
130
  ## 限制与注意事项
114
131
 
115
132
  - **支持市场**:当前仅支持东南亚市场——泰国(TH)、马来西亚(MY)、越南(VN)、菲律宾(PH)、印度尼西亚(ID)、新加坡(SG)。用户明确提到其他市场(如美国、日本、欧洲等)时,主动说明不支持,并建议改选以上 SEA 市场之一
116
133
  - **日配额**:搜索和表现查询共享每日 10,000 次调用限额
134
+ - **限流处理**:如果请求过于频繁或短时间内持续限流,应先等待、分批执行或缩小请求范围;这类问题默认不是授权问题,也不需要为了解除限流去重新授权
117
135
  - **单页限制**:搜索接口每次最多返回 20 条,大批量搜索需要多次翻页
118
136
  - **建联门槛**:店铺 GMV 需达标,且店铺与达人需在同一区域
119
- - **建联字段**:`create_conversation` 必须用 `creator_open_id`(非 `creator_user_id`,否则报 36009004/36009035),该字段仅来自搜索结果
137
+ - **建联字段**:`create_conversation` 必须用 `creator_open_id`(不是 `creator_user_id`),该字段仅来自搜索结果;传错会导致建会话失败
120
138
  - **消息配额**:单店铺对单达人有 IM 消息条数上限
139
+ - **店铺重新绑定**:如果本地登录状态正常,但当前店铺的 TikTok 授权失效、撤销、过期或不匹配,需要先到 ScoreHub 重新绑定该店铺,再继续搜索、分析或建联
121
140
  - **API 版本**:当前基于 202508(搜索/表现/建会话)和 202412(消息)版本,TikTok 可能更新
package/install.js CHANGED
@@ -6,24 +6,8 @@ const os = require('os');
6
6
  const { execSync } = require('child_process');
7
7
 
8
8
  const pkg = require('./package.json');
9
- console.log(`${pkg.name} v${pkg.version}\n`);
9
+ const MIN_NODE_MAJOR = 18;
10
10
 
11
- // === Claude Code 路径 ===
12
- const CLAUDE_DIR = path.join(os.homedir(), '.claude');
13
- const AGENTS_DIR = path.join(CLAUDE_DIR, 'agents');
14
- const CLAUDE_JSON = path.join(os.homedir(), '.claude.json');
15
-
16
- const AGENT_SRC = path.join(__dirname, 'agents', 'tiktok-creator-outreach.md');
17
- const AGENT_DEST = path.join(AGENTS_DIR, 'tiktok-creator-outreach.md');
18
-
19
- // === WorkBuddy 路径 ===
20
- const WORKBUDDY_DIR = path.join(os.homedir(), '.workbuddy');
21
- const WORKBUDDY_PLUGIN_DIR = path.join(
22
- WORKBUDDY_DIR, 'plugins', 'marketplaces', 'my-experts', 'plugins', 'tiktok-creator-outreach',
23
- );
24
- const WORKBUDDY_MCP_JSON = path.join(WORKBUDDY_DIR, 'mcp.json');
25
-
26
- // === 共享 MCP 配置 ===
27
11
  const MCP_CONFIG = {
28
12
  type: 'stdio',
29
13
  command: 'npx',
@@ -33,27 +17,49 @@ const MCP_CONFIG = {
33
17
  },
34
18
  };
35
19
 
36
- // 工具函数:解析 WorkBuddy 捆绑的 node bin 目录
37
- // WorkBuddy spawn 子进程的 PATH 不含 node,npx 及其下载的包依赖 #!/usr/bin/env node,
38
- // 找不到 node 会秒退导致 "Connection closed"。返回 npx 全路径 + bin 目录用于注入 PATH。
39
- function resolveWorkBuddyNode() {
40
- const versionsDir = path.join(WORKBUDDY_DIR, 'binaries', 'node', 'versions');
20
+ function getNodeMajorVersion(nodeVersion = process.versions.node) {
21
+ return Number.parseInt(nodeVersion.split('.')[0], 10);
22
+ }
23
+
24
+ function isSupportedNode(nodeVersion = process.versions.node) {
25
+ return getNodeMajorVersion(nodeVersion) >= MIN_NODE_MAJOR;
26
+ }
27
+
28
+ function getPaths(homeDir) {
29
+ const claudeDir = path.join(homeDir, '.claude');
30
+ const workBuddyDir = path.join(homeDir, '.workbuddy');
31
+
32
+ return {
33
+ claudeDir,
34
+ agentsDir: path.join(claudeDir, 'agents'),
35
+ claudeJson: path.join(homeDir, '.claude.json'),
36
+ workBuddyDir,
37
+ workBuddyPluginDir: path.join(
38
+ workBuddyDir, 'plugins', 'marketplaces', 'my-experts', 'plugins', 'tiktok-creator-outreach',
39
+ ),
40
+ workBuddyMcpJson: path.join(workBuddyDir, 'mcp.json'),
41
+ };
42
+ }
43
+
44
+ function resolveWorkBuddyNode(workBuddyDir) {
45
+ const versionsDir = path.join(workBuddyDir, 'binaries', 'node', 'versions');
46
+ const npxExecutable = process.platform === 'win32' ? 'npx.cmd' : 'npx';
41
47
  try {
42
48
  const versions = fs.readdirSync(versionsDir);
43
49
  if (versions.length > 0) {
44
- const binDir = path.join(versionsDir, versions[0], 'bin');
45
- const npxPath = path.join(binDir, 'npx');
46
- if (fs.existsSync(npxPath)) return { npx: npxPath, binDir };
50
+ const versionDir = path.join(versionsDir, versions[0]);
51
+ const binDirs = [path.join(versionDir, 'bin'), versionDir];
52
+ for (const binDir of binDirs) {
53
+ const npxPath = path.join(binDir, npxExecutable);
54
+ if (fs.existsSync(npxPath)) return { npx: npxPath, binDir };
55
+ }
47
56
  }
48
57
  } catch {
49
- // 目录不存在或无权限
58
+ // WorkBuddy or its bundled Node.js is not available at this path.
50
59
  }
51
60
  return { npx: 'npx', binDir: null };
52
61
  }
53
62
 
54
- // 工具函数:查询 mcp-server 在 npm registry 的当前最新版本
55
- // 注意:这是 install 此刻的最新版;实际 MCP 拉起时由 npx 现场解析 @latest,
56
- // 若之后 registry 更新,运行时版本可能与此不同。失败时静默返回 null(不阻断安装)。
57
63
  function fetchLatestMcpServerVersion() {
58
64
  try {
59
65
  const out = execSync('npm view @scorehub/mcp-server version', {
@@ -67,91 +73,107 @@ function fetchLatestMcpServerVersion() {
67
73
  }
68
74
  }
69
75
 
70
- // 工具函数:合并 MCP Server 配置到 JSON 文件
71
76
  function mergeMcpConfig(configPath, serverName, serverConfig, extraFields) {
72
77
  let config = {};
73
78
  if (fs.existsSync(configPath)) {
74
79
  try {
75
80
  config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
76
81
  } catch {
77
- console.warn(`警告:${configPath} 解析失败,将重新写入`);
82
+ console.warn(`Warning: ${configPath} could not be parsed and will be replaced.`);
78
83
  }
79
84
  }
80
85
 
81
86
  config.mcpServers = config.mcpServers || {};
82
87
  config.mcpServers[serverName] = Object.assign({}, serverConfig, extraFields);
83
-
84
88
  fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
85
89
  }
86
90
 
87
- // ========== Claude Code ==========
88
-
89
- // 1. 复制 Agent 定义文件
90
- fs.mkdirSync(AGENTS_DIR, { recursive: true });
91
- fs.copyFileSync(AGENT_SRC, AGENT_DEST);
92
- console.log(`✓ Claude Code: Agent 已安装 → ${AGENT_DEST}`);
91
+ function install({
92
+ homeDir = os.homedir(),
93
+ nodeVersion = process.versions.node,
94
+ getLatestMcpServerVersion = fetchLatestMcpServerVersion,
95
+ } = {}) {
96
+ console.log(`${pkg.name} v${pkg.version}\n`);
93
97
 
94
- // 2. 合并 MCP Server 配置到 ~/.claude.json
95
- mergeMcpConfig(CLAUDE_JSON, 'scorehub', MCP_CONFIG, {});
96
- console.log(`✓ Claude Code: MCP Server 已配置 → ${CLAUDE_JSON}`);
97
-
98
- // ========== WorkBuddy ==========
99
-
100
- const hasWorkBuddy = fs.existsSync(WORKBUDDY_DIR);
98
+ if (!isSupportedNode(nodeVersion)) {
99
+ console.error(`Node.js ${MIN_NODE_MAJOR}+ is required. Detected ${nodeVersion}. No configuration files were changed.`);
100
+ return 1;
101
+ }
101
102
 
102
- if (hasWorkBuddy) {
103
- // 3. 复制插件文件到 WorkBuddy 插件目录
104
- const pluginDirs = ['.codebuddy-plugin', 'agents', 'skills', 'avatars'];
105
- const pluginFiles = ['package.json', 'README.md'];
103
+ const paths = getPaths(homeDir);
104
+ const hasClaudeCode = fs.existsSync(paths.claudeDir);
105
+ const hasWorkBuddy = fs.existsSync(paths.workBuddyDir);
106
106
 
107
- fs.mkdirSync(WORKBUDDY_PLUGIN_DIR, { recursive: true });
107
+ if (!hasClaudeCode && !hasWorkBuddy) {
108
+ console.error('No supported client was found. Launch Claude Code or WorkBuddy once, then run this command again. No configuration files were changed.');
109
+ return 1;
110
+ }
108
111
 
109
- for (const dir of pluginDirs) {
110
- const src = path.join(__dirname, dir);
111
- const dest = path.join(WORKBUDDY_PLUGIN_DIR, dir);
112
- if (fs.existsSync(src)) {
113
- fs.cpSync(src, dest, { recursive: true });
114
- }
112
+ if (hasClaudeCode) {
113
+ const agentSource = path.join(__dirname, 'agents', 'tiktok-creator-outreach.md');
114
+ const agentDestination = path.join(paths.agentsDir, 'tiktok-creator-outreach.md');
115
+ fs.mkdirSync(paths.agentsDir, { recursive: true });
116
+ fs.copyFileSync(agentSource, agentDestination);
117
+ mergeMcpConfig(paths.claudeJson, 'scorehub', MCP_CONFIG, {});
118
+ console.log(`Claude Code: Agent installed at ${agentDestination}`);
119
+ console.log(`Claude Code: MCP server configured at ${paths.claudeJson}`);
115
120
  }
116
121
 
117
- for (const file of pluginFiles) {
118
- const src = path.join(__dirname, file);
119
- const dest = path.join(WORKBUDDY_PLUGIN_DIR, file);
120
- if (fs.existsSync(src)) {
121
- fs.copyFileSync(src, dest);
122
+ if (hasWorkBuddy) {
123
+ const pluginDirs = ['.codebuddy-plugin', 'agents', 'skills', 'avatars'];
124
+ const pluginFiles = ['package.json', 'README.md', 'README.en.md'];
125
+
126
+ fs.mkdirSync(paths.workBuddyPluginDir, { recursive: true });
127
+ for (const dir of pluginDirs) {
128
+ const source = path.join(__dirname, dir);
129
+ const destination = path.join(paths.workBuddyPluginDir, dir);
130
+ if (fs.existsSync(source)) {
131
+ fs.cpSync(source, destination, { recursive: true });
132
+ }
122
133
  }
123
- }
124
134
 
125
- console.log(`✓ WorkBuddy: 插件文件已安装 → ${WORKBUDDY_PLUGIN_DIR}`);
126
-
127
- // 4. 合并 MCP Server 配置到 ~/.workbuddy/mcp.json
128
- // - 去掉 type 字段(WorkBuddy 不识别)
129
- // - command 用 npx 全路径(WorkBuddy PATH 不含系统 npx)
130
- // - env.PATH 注入 node bin 目录(否则 npx 及其子进程的 shebang 找不到 node,秒退报 Connection closed)
131
- const { npx, binDir } = resolveWorkBuddyNode();
132
- const { type: _, ...baseMCPConfig } = MCP_CONFIG;
133
- const wbEnv = binDir
134
- ? Object.assign({}, MCP_CONFIG.env, { PATH: `${binDir}:/usr/local/bin:/usr/bin:/bin` })
135
- : MCP_CONFIG.env;
136
- const wbMCPConfig = Object.assign({}, baseMCPConfig, { command: npx, env: wbEnv });
137
- mergeMcpConfig(WORKBUDDY_MCP_JSON, 'scorehub', wbMCPConfig, { disabled: false });
138
- console.log(`✓ WorkBuddy: MCP Server 已配置 → ${WORKBUDDY_MCP_JSON}`);
139
- }
135
+ for (const file of pluginFiles) {
136
+ const source = path.join(__dirname, file);
137
+ const destination = path.join(paths.workBuddyPluginDir, file);
138
+ if (fs.existsSync(source)) {
139
+ fs.copyFileSync(source, destination);
140
+ }
141
+ }
140
142
 
141
- // ========== 完成 ==========
143
+ const { npx, binDir } = resolveWorkBuddyNode(paths.workBuddyDir);
144
+ const { type: _, ...baseMcpConfig } = MCP_CONFIG;
145
+ const existingPath = process.env.PATH || process.env.Path || '';
146
+ const env = binDir
147
+ ? Object.assign({}, MCP_CONFIG.env, { PATH: [binDir, existingPath].filter(Boolean).join(path.delimiter) })
148
+ : MCP_CONFIG.env;
149
+ const workBuddyMcpConfig = Object.assign({}, baseMcpConfig, { command: npx, env });
150
+ mergeMcpConfig(paths.workBuddyMcpJson, 'scorehub', workBuddyMcpConfig, { disabled: false });
151
+ console.log(`WorkBuddy: Plugin installed at ${paths.workBuddyPluginDir}`);
152
+ console.log(`WorkBuddy: MCP server configured at ${paths.workBuddyMcpJson}`);
153
+ }
142
154
 
143
- const platforms = ['Claude Code'];
144
- if (hasWorkBuddy) platforms.push('WorkBuddy');
155
+ const mcpServerVersion = getLatestMcpServerVersion();
156
+ if (mcpServerVersion) {
157
+ console.log(`\nmcp-server latest version: v${mcpServerVersion} (npx resolves @latest again when it starts).`);
158
+ } else {
159
+ console.log('\nmcp-server: @latest (the current version could not be queried).');
160
+ }
145
161
 
146
- const mcpServerVersion = fetchLatestMcpServerVersion();
147
- if (mcpServerVersion) {
148
- console.log(`\n→ mcp-server 当前最新版本:v${mcpServerVersion}(运行时由 npx 解析 @latest,届时可能更新)`);
149
- } else {
150
- console.log('\n→ mcp-server:@latest(运行时由 npx 解析,未能查询到具体版本号)');
162
+ const platforms = [];
163
+ if (hasClaudeCode) platforms.push('Claude Code');
164
+ if (hasWorkBuddy) platforms.push('WorkBuddy');
165
+ console.log(`\nInstallation complete. Restart ${platforms.join(' / ')} and use Tiky.`);
166
+ return 0;
151
167
  }
152
168
 
153
- console.log(`\n安装完成!重启 ${platforms.join(' / ')} 后使用 Tiky。`);
154
- if (!hasWorkBuddy) {
155
- console.log('提示:未检测到 WorkBuddy,仅安装了 Claude Code。如需 WorkBuddy 支持请先安装 WorkBuddy 后重新运行本命令。');
169
+ if (require.main === module) {
170
+ process.exitCode = install();
156
171
  }
157
172
 
173
+ module.exports = {
174
+ MIN_NODE_MAJOR,
175
+ getNodeMajorVersion,
176
+ getPaths,
177
+ install,
178
+ isSupportedNode,
179
+ };
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@scorehub/creator-outreach",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "ScoreHub Tiky 智能体 — Agent 定义 + Skills 配置",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
5
8
  "files": [
6
9
  ".codebuddy-plugin",
7
10
  "agents",
8
11
  "skills",
9
12
  "avatars",
10
- "install.js"
13
+ "install.js",
14
+ "README.en.md"
11
15
  ],
16
+ "scripts": {
17
+ "test": "node --test test/install.test.js"
18
+ },
12
19
  "bin": {
13
20
  "creator-outreach": "./install.js"
14
21
  },
@@ -24,6 +24,14 @@
24
24
  1. **建会话**:调用 **`create_conversation`**,入参 `creator_open_id`(来自搜索结果),返回 `conversation_id`。
25
25
  2. **发消息**:调用 **`send_message`**,入参 `conversation_id` + `msg_type: "TEXT"` + `content`(模板填充后的文本)。
26
26
 
27
+ 如果 ScoreHub MCP 工具不可见、工具列表为空、连接已关闭或本地 MCP 未启动,判定为本地 MCP 可用性问题。提示用户确认 Node.js 18+ 与 npm 可用、网络可访问 npm registry,并完全重启 Claude Code 或 WorkBuddy 后重试;配置中的 `npx -y @scorehub/mcp-server@latest` 会自动下载 mcp-server,macOS、Linux、Windows 都不需要全局安装。不要将此类错误当作 OAuth、店铺授权或限流问题,也不要调用 `authorize`。
28
+
29
+ 如果工具返回结构化 JSON,优先按 `error_type` 做分流,不要靠自然语言错误文本猜测。
30
+
31
+ 如果本地登录状态正常,但工具提示当前店铺的 TikTok 授权失效或异常,直接提醒用户去 ScoreHub 重新绑定该店铺后再试;不要展示错误码,也不要要求用户重复执行 `authorize`。
32
+
33
+ 如果工具提示请求过于频繁、持续限流或配额受限,直接提醒用户暂停发送、耐心等待并稍后继续;不要建议“重新授权拿一个干净的 token”,也不要主动走 `authorize`,除非用户自己明确要求重新授权。
34
+
27
35
  ### 速率与话术
28
36
 
29
37
  - 每条发送间隔 **5-8 秒 + 随机抖动**(间隔 <5s 会触发 429)。
@@ -38,7 +46,7 @@
38
46
 
39
47
  ## 关键陷阱
40
48
 
41
- - `create_conversation` 必须用 **`creator_open_id`**(不是 `creator_user_id`,否则报 36009004 / 36009035)。
49
+ - `create_conversation` 必须用 **`creator_open_id`**(不是 `creator_user_id`)。
42
50
  - `creator_open_id` **仅来自搜索接口**,分析接口不返回——务必从搜索结果透传。
43
51
 
44
52
  ## 降级:直接 API
@@ -50,11 +58,13 @@ POST /affiliate_seller/202412/conversations/{id}/messages Body: {"msg_type":"T
50
58
 
51
59
  ## 错误处理
52
60
 
53
- | 错误码 | 含义 | 处理 |
54
- |--------|------|------|
55
- | 36009004 | 必填字段缺失 | 检查字段名为 `creator_open_id` |
56
- | 36009035 | 无效 open_id | 确保来自搜索结果 |
57
- | 16030100 | 消息配额已用完 | 跳过该达人 |
58
- | 16032001 | 区域不匹配 | 跳过该达人 |
59
- | 45101004 | 日配额已用完 | 停止全部 |
60
- | 36009002 | 请求过于频繁 | 指数退避重试 |
61
+ | 问题类型 | 处理 |
62
+ |----------|------|
63
+ | MCP 工具不可见、工具列表为空、连接关闭或本地 MCP 未启动 | 提示确认 Node.js 18+、npm 和 npm registry 网络后完全重启客户端;`npx` 会自动下载 mcp-server,不执行全局安装,不走 `authorize` |
64
+ | `oauth_invalid` | 仅在真正未授权或本地 OAuth 失效时,才允许提示用户调用 `authorize` |
65
+ | 当前店铺的 TikTok 授权失效或异常 | 用中文提醒用户:本地登录状态正常,但当前店铺需要先到 ScoreHub 重新绑定后再试;不要展示错误码,不要要求重复 `authorize` |
66
+ | 建会话入参不对或达人标识无效 | 检查传入的是来自搜索结果的 `creator_open_id` |
67
+ | 消息配额已用完或当前达人不满足发送条件 | 跳过该达人,继续后续名单 |
68
+ | 日配额已用完 | 停止全部 |
69
+ | 请求过于频繁或持续限流 | 先提醒用户暂停发送、耐心等待并稍后继续;必要时有限退避重试。不要建议重新授权;只有用户明确要求时才走 `authorize` |
70
+ | 参数无效 | 提示用户修正名单、消息内容或建联参数,不走授权路径 |
@@ -15,6 +15,14 @@
15
15
  对候选达人**逐个**调用 MCP 工具 **`creator_performance`**(入参 `creator_user_id`),拿到表现数据后应用
16
16
  [评分模型](./references/scoring-model.md) 打分排序。批量分析属多步操作,先与用户确认名单再执行。
17
17
 
18
+ 如果 ScoreHub MCP 工具不可见、工具列表为空、连接已关闭或本地 MCP 未启动,判定为本地 MCP 可用性问题。提示用户确认 Node.js 18+ 与 npm 可用、网络可访问 npm registry,并完全重启 Claude Code 或 WorkBuddy 后重试;配置中的 `npx -y @scorehub/mcp-server@latest` 会自动下载 mcp-server,macOS、Linux、Windows 都不需要全局安装。不要将此类错误当作 OAuth、店铺授权或限流问题,也不要调用 `authorize`。
19
+
20
+ 如果工具返回结构化 JSON,优先按 `error_type` 做分流,不要靠自然语言错误文本猜测。
21
+
22
+ 如果本地登录状态正常,但工具提示当前店铺的 TikTok 授权失效或异常,直接提醒用户去 ScoreHub 重新绑定该店铺后再试;不要展示错误码,也不要要求用户重复执行 `authorize`。
23
+
24
+ 如果工具提示请求过于频繁、持续限流或配额受限,直接提醒用户耐心等待、减少本次分析人数或稍后重试;不要建议“重新授权拿一个干净的 token”,也不要主动走 `authorize`,除非用户自己明确要求重新授权。
25
+
18
26
  ### 输出
19
27
 
20
28
  - 排行榜:排名 / 昵称 / 综合评分 / 各维度分 / 标签。
@@ -46,9 +54,12 @@ GET https://open-api.tiktokglobalshop.com/affiliate_seller/202508/marketplace_cr
46
54
 
47
55
  ## 错误处理
48
56
 
49
- | 错误码 | 含义 | 处理 |
50
- |--------|------|------|
51
- | 16901005 | 达人无电商权限 | 跳过 |
52
- | 16901006 | 区域不匹配 | 跳过 |
53
- | 45101004 | 日配额已用完 | 停止 |
54
- | 36009002 | 请求过于频繁 | 指数退避重试 |
57
+ | 问题类型 | 处理 |
58
+ |----------|------|
59
+ | MCP 工具不可见、工具列表为空、连接关闭或本地 MCP 未启动 | 提示确认 Node.js 18+、npm 和 npm registry 网络后完全重启客户端;`npx` 会自动下载 mcp-server,不执行全局安装,不走 `authorize` |
60
+ | `oauth_invalid` | 仅在真正未授权或本地 OAuth 失效时,才允许提示用户调用 `authorize` |
61
+ | 当前店铺的 TikTok 授权失效或异常 | 用中文提醒用户:本地登录状态正常,但当前店铺需要先到 ScoreHub 重新绑定后再试;不要展示错误码,不要要求重复 `authorize` |
62
+ | 达人当前不可分析(如无电商权限或区域不匹配) | 跳过该达人,并说明当前达人不满足分析条件 |
63
+ | 日配额已用完 | 停止 |
64
+ | 请求过于频繁或持续限流 | 先提醒用户耐心等待,建议减少本次分析人数或稍后重试;必要时有限退避重试。不要建议重新授权;只有用户明确要求时才走 `authorize` |
65
+ | 参数无效 | 提示用户修正待分析名单或输入格式,不走授权路径 |
@@ -33,6 +33,14 @@
33
33
 
34
34
  调用 MCP 工具 **`search_creators`**,不要写脚本。若已授权可直接调用;未授权时先走 `authorize`。
35
35
 
36
+ 如果 ScoreHub MCP 工具不可见、工具列表为空、连接已关闭或本地 MCP 未启动,判定为本地 MCP 可用性问题。提示用户确认 Node.js 18+ 与 npm 可用、网络可访问 npm registry,并完全重启 Claude Code 或 WorkBuddy 后重试;配置中的 `npx -y @scorehub/mcp-server@latest` 会自动下载 mcp-server,macOS、Linux、Windows 都不需要全局安装。不要将此类错误当作 OAuth、店铺授权或限流问题,也不要调用 `authorize`。
37
+
38
+ 如果工具返回结构化 JSON,优先按 `error_type` 做分流,不要靠自然语言错误文本猜测。
39
+
40
+ 如果本地登录状态正常,但工具提示当前店铺的 TikTok 授权失效或异常,直接提醒用户去 ScoreHub 重新绑定该店铺后再试;不要展示错误码,也不要要求用户重复执行 `authorize`。
41
+
42
+ 如果工具提示请求过于频繁、持续限流或配额受限,直接提醒用户耐心等待、缩小搜索范围或稍后重试;不要建议“重新授权拿一个干净的 token”,也不要主动走 `authorize`,除非用户自己明确要求重新授权。
43
+
36
44
  ### 入参
37
45
 
38
46
  | 参数 | 说明 |
@@ -88,7 +96,11 @@ POST https://open-api.tiktokglobalshop.com/affiliate_seller/202508/marketplace_c
88
96
 
89
97
  ## 错误处理
90
98
 
91
- | 错误码 | 含义 | 处理 |
92
- |--------|------|------|
93
- | 45101004 | 日配额已用完 | 明确告知用户,停止 |
94
- | 36009002 | 请求过于频繁 | 指数退避重试 1s/2s/4s/8s/16s |
99
+ | 问题类型 | 处理 |
100
+ |----------|------|
101
+ | MCP 工具不可见、工具列表为空、连接关闭或本地 MCP 未启动 | 提示确认 Node.js 18+、npm 和 npm registry 网络后完全重启客户端;`npx` 会自动下载 mcp-server,不执行全局安装,不走 `authorize` |
102
+ | `oauth_invalid` | 仅在真正未授权或本地 OAuth 失效时,才允许提示用户调用 `authorize` |
103
+ | 当前店铺的 TikTok 授权失效或异常 | 用中文提醒用户:本地登录状态正常,但当前店铺需要先到 ScoreHub 重新绑定后再试;不要展示错误码,不要要求重复 `authorize` |
104
+ | 日配额已用完 | 明确告知用户,停止 |
105
+ | 请求过于频繁或持续限流 | 先提醒用户耐心等待,建议缩小搜索范围、减少翻页或稍后重试;必要时按 1s/2s/4s/8s/16s 有限退避重试。不要建议重新授权;只有用户明确要求时才走 `authorize` |
106
+ | 参数无效 | 提示用户修正搜索条件或 page_size / 类目参数,不走授权路径 |