@geoly-ai/social-hub-cli 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geoly-ai/social-hub-cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "social-hub CLI for Social Ops Hub",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 1,
3
3
  "package": "social-ops-hub",
4
- "cliVersion": "0.0.4",
4
+ "cliVersion": "0.0.6",
5
5
  "repository": "social-ops-hub",
6
6
  "publish": {
7
7
  "registry": "https://skill.sh",
@@ -4,22 +4,27 @@ description: >-
4
4
  Social Hub 社交账号:social-hub accounts list/get/create/update/delete、brand-bindings、status-snapshots。
5
5
  用户要查 Reddit 账号、改 handle、绑品牌、看账号状态快照、同步飞书账号字段时用本 skill。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-accounts
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已通过 `social-hub auth login` 授权,并已 `social-hub context use <team-id>`。
14
+ > 命令使用 `-t <team-id>`(来自 `social-hub context current`);不要用环境变量传 API key。
15
+
12
16
  ```bash
13
- social-hub accounts list -t "$T" -n 50
14
- social-hub accounts get -t "$T" --id "<uuid>"
15
- social-hub accounts update -t "$T" --id "<uuid>" -j '{"workflowStage":"active",...}'
16
- social-hub accounts delete -t "$T" --id "<uuid>" # 危险:需确认
17
+ social-hub accounts list -t <team-id> -n 50
18
+ social-hub accounts get -t <team-id> --account <uuid>
19
+ social-hub accounts create -t <team-id> -j '{"platform":"reddit","handle":"u/example",...}'
20
+ social-hub accounts update -t <team-id> --account <uuid> -j '{"workflowStage":"active",...}'
21
+ social-hub accounts delete -t <team-id> --account <uuid> # 危险:需确认用户意图
17
22
 
18
- social-hub accounts brand-bindings list -t "$T" --account "<uuid>"
19
- social-hub accounts brand-bindings add -t "$T" --account "<uuid>" -j '{"brandId":"..."}'
20
- social-hub accounts brand-bindings remove -t "$T" --account "<uuid>" --brand "<brandId>"
23
+ social-hub accounts brand-bindings list -t <team-id> --account <uuid>
24
+ social-hub accounts brand-bindings add -t <team-id> --account <uuid> -j '{"brandId":"..."}'
25
+ social-hub accounts brand-bindings remove -t <team-id> --account <uuid> --brand <brandId>
21
26
 
22
- social-hub accounts status-snapshots list -t "$T" --account "<uuid>"
27
+ social-hub accounts status-snapshots list -t <team-id> --account <uuid>
23
28
  ```
24
29
 
25
30
  OpenClaw 执行前优先 `social-hub context account`(见 `social-hub-openclaw-context`),不要只读本地 `account-profiles/*.md`。
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  name: social-hub-admin
3
3
  description: >-
4
- Social Hub 管理面:settings、invites、members、api-keys、agent-teams、users。
5
- 用户要改系统设置、发团队邀请、列成员、轮换 API Key 时用本 skill;高风险写操作需 --apply。
4
+ Social Hub 管理面:settings、invites、members、agent-teams、users。
5
+ 用户要改系统设置、发团队邀请、列成员、管理团队结构时用本 skill;高风险写操作需 --apply。
6
+ API Key 的创建/轮换属于管理员资源管理,不是 CLI 日常登录方式(见 social-hub-shared)。
6
7
  metadata:
7
- cliVersion: ">=0.0.1"
8
+ cliVersion: ">=0.0.6"
8
9
  ---
9
10
 
10
11
  # social-hub-admin
11
12
 
13
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
14
+ > 确认已 `auth login` 且 role 满足操作要求(多数管理命令需 admin 或 manager)。
15
+
12
16
  ## Settings(admin)
13
17
 
14
18
  ```bash
@@ -21,10 +25,10 @@ social-hub settings set <key> --value "..." --apply
21
25
  ## Invites
22
26
 
23
27
  ```bash
24
- social-hub invites list -t "$T"
25
- social-hub invites create -t "$T" --email user@example.com --role manager --dry-run
26
- social-hub invites create -t "$T" --email user@example.com --role manager --apply
27
- social-hub invites revoke -t "$T" --id "<inviteId>" --apply
28
+ social-hub invites list -t <team-id>
29
+ social-hub invites create -t <team-id> --email user@example.com --role manager --dry-run
30
+ social-hub invites create -t <team-id> --email user@example.com --role manager --apply
31
+ social-hub invites revoke -t <team-id> --id <inviteId> --apply
28
32
  ```
29
33
 
30
34
  ## Members
@@ -33,4 +37,7 @@ social-hub invites revoke -t "$T" --id "<inviteId>" --apply
33
37
  social-hub members list
34
38
  ```
35
39
 
36
- API Keys、users、agent-teams 等见 `social-hub-cli` 管理章节。
40
+ ## 团队 / 用户 / API Key(管理员)
41
+
42
+ - **团队与用户**:`agent-teams`、`users` 命令见 `social-hub-cli` 管理章节。
43
+ - **API Key**(`social-hub api-keys *`):仅用于集成/服务端密钥管理;**Agent 日常操作仍用 Device Code**,不要把新建 API Key 当作 CLI 登录步骤。
@@ -4,22 +4,31 @@ description: >-
4
4
  发布日历与调度任务:social-hub calendar list、jobs list/create/batch/retry/cancel。
5
5
  用户要排期、查 scheduled job、重试失败任务、取消任务时用本 skill;Agent 执行态回填优先 ops-runtime。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-calendar-jobs
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login 并选定 team(`context use`)。下文 `-t <team-id>` 来自 `context current`。
14
+
12
15
  ```bash
13
- social-hub calendar list -t "$T"
14
- social-hub jobs list -t "$T" --status scheduled
15
- social-hub jobs create -t "$T" -j '{"socialAccountId":"...","subreddit":"...","runAt":"..."}'
16
- social-hub jobs retry -t "$T" --job "<id>"
17
- social-hub jobs cancel -t "$T" --job "<id>"
16
+ social-hub calendar list -t <team-id>
17
+ social-hub calendar list-full -t <team-id> --account <accountId> --status scheduled
18
+ social-hub calendar patch -t <team-id> -e <entryId> --body '{"status":"succeeded","permalink":"..."}'
19
+
20
+ social-hub jobs list -t <team-id> --status scheduled
21
+ social-hub jobs list-full -t <team-id> --account <accountId>
22
+ social-hub jobs create -t <team-id> -j '{"socialAccountId":"...","action":"engage","subreddit":"...","runAt":"..."}'
23
+ social-hub jobs retry -t <team-id> -i <jobId>
24
+ social-hub jobs cancel -t <team-id> -i <jobId>
18
25
  ```
19
26
 
20
- 遗留:`jobs agent-status` 仍可更新状态,但 OpenClaw 推荐:
27
+ OpenClaw / Agent 运行时优先:
21
28
 
22
29
  ```bash
23
- social-hub ops claim-next -t "$T" --agent "<agentId>"
24
- social-hub ops complete|fail|skip ...
30
+ social-hub ops claim-next -t <team-id> --agent <agentId>
31
+ social-hub ops heartbeat|complete|fail|skip ...
25
32
  ```
33
+
34
+ 见 `social-hub-ops-runtime`。遗留 `jobs agent-status` 仅在未接 ops 链路时使用。
@@ -1,363 +1,235 @@
1
1
  ---
2
2
  name: social-hub-cli
3
3
  description: >-
4
- Social Ops Hub 命令行 social-hub:账号、事件、日历、调度任务、Reddit 帖、报告、API Key、OpenClaw 回填等。
4
+ Social Ops Hub 命令行 social-hub:账号、事件、日历、调度任务、Reddit 帖、报告、OpenClaw 回填等。
5
5
  只要用户提到 social-hub、Social Ops Hub、Hub 写数据、查账号、发帖计划、permalink 回填、openclaw、
6
- 调度任务、团队 API Key、互动事件,或要在 Hub 里查/改运营数据,就应使用本 skill(即使用户没说 CLI)。
7
- 先读本 skill 做路由,再打开对应领域 skill(ops-runtime、openclaw-context 等)。
6
+ 调度任务、互动事件,或要在 Hub 里查/改运营数据,就应使用本 skill(即使用户没说 CLI)。
7
+ 先读本 skill 做路由;执行任何命令前必须先读 social-hub-shared 完成 auth login 与 context
8
8
  metadata:
9
- cliVersion: ">=0.0.4"
10
- homepage: https://github.com/your-org/social-ops-hub/tree/main/skills
9
+ cliVersion: ">=0.0.6"
10
+ homepage: https://github.com/geoly-ai/geoly-reddit/tree/main/social-ops-hub/skills
11
11
  ---
12
12
 
13
13
  # Social Hub CLI
14
14
 
15
- `social-hub` 封装 Social Ops Hub REST API,供人工与 Agent 使用。配套领域 skill 与本目录同级(`skills/social-hub-*`)。
15
+ `social-hub` 封装 Social Ops Hub REST API,供人工与 Agent 使用。
16
16
 
17
- ## 安装 Skill
17
+ > **前置条件:** 执行 Hub 命令前 MUST 先读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
18
+ > 完成 `social-hub auth login`(Device Code)并 `social-hub context use <team-id>`。
19
+ > 日常**不要**使用 `SOCIAL_HUB_API_KEY` / `SOCIAL_HUB_API_URL` 环境变量。
18
20
 
19
- - **推荐(CLI)**:`social-hub skills tui` 或 `social-hub skills install --agent cursor --global --yes`
21
+ ## 快速开始(生产)
22
+
23
+ ```bash
24
+ social-hub auth login --api-url https://reddit.eclick-geo.com/api
25
+ social-hub auth whoami
26
+ social-hub context use <team-uuid>
27
+ social-hub doctor
28
+ social-hub health
29
+ ```
30
+
31
+ 生产 API 基址:**`https://reddit.eclick-geo.com/api`**。下文示例中 `<team-id>` 指当前 context 的 team UUID。
32
+
33
+ ## 安装 CLI 与 Skill
34
+
35
+ ```bash
36
+ npm install -g @geoly-ai/social-hub-cli@latest
37
+ social-hub version
38
+ ```
39
+
40
+ 安装 Agent Skills:
41
+
42
+ - **推荐**:`social-hub skills tui` 或 `social-hub skills install --agent cursor --global --yes`
20
43
  - **免全局安装**:`npx @geoly-ai/social-hub-cli skills bootstrap`
21
44
  - **GitHub 最新**:`social-hub skills install --source github --repo geoly-ai/geoly-reddit --yes`
22
- - **更新已装 skill**:`social-hub skills update --all --yes`(可加 `--source github`)
23
- - **检查状态**:`social-hub skills doctor`
24
- - **同仓开发**:`pnpm skills:install`(或 `pnpm --filter @geoly-ai/social-hub-cli run build` 后使用内置 bundle)
25
- - **skill.sh / 公开市场**:从 [skill.sh](https://skill.sh) 导入本仓库 `skills/` 子目录(见 `skills/README.md`)
45
+ - **更新**:`social-hub skills update --all --yes`
46
+ - **检查**:`social-hub skills doctor`
47
+ - **同仓开发**:`pnpm skills:install`(目标目录可用 `SKILLS_INSTALL_DIR=~/.cursor/skills`)
26
48
 
27
- ## 领域 Skill 路由(先读子 skill)
49
+ ## 领域 Skill 路由
28
50
 
29
51
  | 场景 | Skill |
30
52
  |------|--------|
31
- | 配置 / doctor / auth | `social-hub-shared` |
53
+ | 鉴权 / config / doctor / context | **`social-hub-shared`**(必读) |
32
54
  | OpenClaw 领任务 / 回填 | `social-hub-ops-runtime` |
33
55
  | 账号/任务上下文(DB) | `social-hub-openclaw-context` |
34
56
  | 账号 CRUD | `social-hub-accounts` |
35
57
  | Reddit 帖 | `social-hub-posts` |
36
58
  | 日历 / jobs | `social-hub-calendar-jobs` |
37
59
  | 发布闭环 | `social-hub-publishing` |
38
- | settings / invites | `social-hub-admin` |
60
+ | settings / invites / 成员 | `social-hub-admin` |
39
61
  | 情报 | `social-hub-intelligence` |
40
62
  | 导入导出 replay | `social-hub-migration` |
41
63
 
42
- `social-hub` Social Ops Hub 的命令行工具,封装了全部 REST API
64
+ 命中上表场景时,打开对应领域 skill,**不要**只在总览里硬写命令而跳过子 skill
43
65
 
44
- ## 配置(环境变量)
66
+ ## 同仓开发 Build
45
67
 
46
- 使用前需设置以下环境变量:
68
+ 在 **social-ops-hub monorepo** 内改 CLI/SDK 后:
47
69
 
48
70
  ```bash
49
- export SOCIAL_HUB_API_URL="http://localhost:3000" # Hub API 地址,默认 localhost:3000
50
- export SOCIAL_HUB_API_KEY="soh_..." # API Key(除 health 外均必需)
51
- export SOCIAL_HUB_TEAM_ID="<uuid>" # 当前操作的 Team UUID(命令中用 $SOCIAL_HUB_TEAM_ID)
52
- ```
53
-
54
- `health` 命令不需要 API Key。其他所有命令必须设置 `SOCIAL_HUB_API_KEY`。
55
-
56
- ## 前置步骤:Build
57
-
58
- 在 **本 monorepo 根目录** 首次使用或更新代码后,需先 build:
59
-
60
- ```bash
61
- cd "$(git rev-parse --show-toplevel)"
62
71
  pnpm --filter @geoly-ai/social-hub-sdk run build
63
72
  pnpm --filter @geoly-ai/social-hub-cli run build
64
73
  ```
65
74
 
66
- ---
67
-
68
- ## 初始化工作流(新环境冷启动)
75
+ ## 本地 API 冷启动(仅开发)
69
76
 
70
- ### 步骤 0:部署前置
77
+ 部署/seed 细节见仓库文档;CLI 侧只需改 API 地址并重新 login:
71
78
 
72
79
  ```bash
73
- # 1. 复制并填写环境变量
74
- cp .env.example .env
75
- # 至少填写:DATABASE_URL、REDIS_URL、API_KEY_PEPPER、JWT_SECRET
76
-
77
- # 2. 执行数据库迁移
80
+ cp .env.example .env # 填写 DATABASE_URL、REDIS_URL 等
78
81
  pnpm run db:migrate
79
-
80
- # 3. 初始化最小管理员种子(自动创建 moss team + admin 用户 + seed-cli API Key)
81
82
  SOCIAL_OPS_SEED_MODE=minimal-admin pnpm run db:seed
82
- # 控制台输出:
83
- # admin@local.test / password123
84
- # SOCIAL_HUB_TEAM_ID=<uuid>
85
- # SOCIAL_HUB_API_KEY=soh_...
86
-
87
- # 4. 导出环境变量(或写入 .env)
88
- export SOCIAL_HUB_API_URL="http://localhost:3000"
89
- export SOCIAL_HUB_API_KEY="soh_..." # 从上面控制台复制
90
- export SOCIAL_HUB_TEAM_ID="<moss-team-uuid>" # 从上面控制台复制
91
-
92
- # 5. 验证 Hub 是否正常
83
+ pnpm dev
84
+ social-hub auth login --api-url http://localhost:3000
85
+ social-hub context use <seed 输出的 team uuid>
93
86
  social-hub health
94
87
  ```
95
88
 
96
- ### 步骤 1:创建新团队(若需要独立 team)
97
-
98
- ```bash
99
- # 使用 admin API Key 创建新团队
100
- NEW_TEAM=$(social-hub agent-teams create --slug javis --name "Javis Agent Team" | jq -r '.id')
101
- export T=$NEW_TEAM
102
-
103
- # 创建运营用户(密码直接设置,不需要 set-password 额外操作)
104
- social-hub users create -t $T -j '{"email":"ops@javis.local","password":"Ops2026!","name":"Javis Ops","role":"manager"}'
89
+ 创建新 team、用户等业务初始化:在 **已 auth login 且 role 足够** 的前提下执行下方「团队与用户管理」命令;**不要**再 export API Key。
105
90
 
106
- # 为新团队创建 API Key(Web 登录后进入 API Keys 页面,或用 admin key)
107
- social-hub api-keys create -t $T -j '{"name":"javis-ops","role":"manager"}'
108
- # → 记录返回的 rawKey,后续操作换用该 Key
109
-
110
- export SOCIAL_HUB_TEAM_ID=$T
111
- export SOCIAL_HUB_API_KEY="soh_..." # 上面新建的 Key
112
-
113
- # 确认团队列表
114
- social-hub agent-teams list
115
- ```
116
-
117
- ### 步骤 2:创建业务数据(Brand → Campaign → Account → Plan)
91
+ ### 业务数据初始化示例
118
92
 
119
93
  ```bash
120
- T=$SOCIAL_HUB_TEAM_ID
121
-
122
- # 创建品牌
123
- BRAND_ID=$(social-hub brands create -t $T -j '{"name":"My Brand","slug":"my-brand"}' | jq -r '.id')
124
-
125
- # 创建 Campaign
126
- CAMP_ID=$(social-hub campaigns create -t $T -j \
127
- "{\"brandId\":\"$BRAND_ID\",\"name\":\"2026 Q3 Launch\"}" | jq -r '.id')
128
-
129
- # 添加 Reddit 账号
130
- ACCOUNT_ID=$(social-hub accounts create -t $T -j \
131
- "{\"platform\":\"reddit\",\"handle\":\"u/my_ops_account\",\"credentialsRef\":\"vault:javis/main\"}" | jq -r '.id')
132
-
133
- # 创建内容草稿
134
- DRAFT_ID=$(social-hub drafts create -t $T -j \
135
- "{\"campaignId\":\"$CAMP_ID\",\"title\":\"Launch Post\",\"body\":\"...\"}" | jq -r '.id')
136
-
137
- # 创建发布计划(自动生成 scheduled_jobs)
138
- social-hub plans create -t $T -j "{
139
- \"campaignId\": \"$CAMP_ID\",
140
- \"name\": \"Q3 Week 1\",
141
- \"entries\": [{
142
- \"socialAccountId\": \"$ACCOUNT_ID\",
143
- \"subreddit\": \"LocalLLaMA\",
144
- \"plannedAt\": \"2026-07-01T09:00:00Z\",
145
- \"contentDraftId\": \"$DRAFT_ID\"
146
- }]
147
- }"
148
-
149
- # 验证:查看日历和任务
150
- social-hub calendar list -t $T --status scheduled
151
- social-hub jobs list -t $T --status scheduled
94
+ # 创建品牌 → campaign → 账号 → 计划(<team-id> 来自 context current)
95
+ BRAND_ID=$(social-hub brands create -t <team-id> -j '{"name":"My Brand","slug":"my-brand"}' | jq -r '.id')
96
+ CAMP_ID=$(social-hub campaigns create -t <team-id> -j "{\"brandId\":\"$BRAND_ID\",\"name\":\"2026 Q3 Launch\"}" | jq -r '.id')
97
+ ACCOUNT_ID=$(social-hub accounts create -t <team-id> -j '{"platform":"reddit","handle":"u/my_ops_account","credentialsRef":"vault:javis/main"}' | jq -r '.id')
98
+ DRAFT_ID=$(social-hub drafts create -t <team-id> -j "{\"campaignId\":\"$CAMP_ID\",\"title\":\"Launch Post\",\"body\":\"...\"}" | jq -r '.id')
99
+ social-hub plans create -t <team-id> -j "{\"campaignId\":\"$CAMP_ID\",\"name\":\"Q3 Week 1\",\"entries\":[{\"socialAccountId\":\"$ACCOUNT_ID\",\"subreddit\":\"LocalLLaMA\",\"plannedAt\":\"2026-07-01T09:00:00Z\",\"contentDraftId\":\"$DRAFT_ID\"}]}"
100
+ social-hub calendar list -t <team-id> --status scheduled
101
+ social-hub jobs list -t <team-id> --status scheduled
152
102
  ```
153
103
 
154
104
  ---
155
105
 
156
106
  ## 命令速查表
157
107
 
108
+ 以下 `-t <team-id>` 可换为 `social-hub context current` 中的 `currentTeamId`。
109
+
158
110
  ### health & dashboard
159
111
 
160
112
  ```bash
161
113
  social-hub health
162
- social-hub dashboard summary -t $T
163
- social-hub dashboard summary -t $T # 支持 campaignId 过滤(通过 API 传参)
114
+ social-hub dashboard summary -t <team-id>
164
115
  ```
165
116
 
166
117
  ### 互动事件
167
118
 
168
119
  ```bash
169
- social-hub events append -t $T --type comment --payload '{"permalink":"https://..."}'
170
- social-hub events list -t $T -n 20 # 简单列表
171
- social-hub events list-full -t $T --account <uuid> # 按账号过滤
172
- social-hub events list-full -t $T --type comment --result succeeded --from 2026-05-01T00:00:00Z
173
- social-hub events export-csv -t $T > events.csv
174
- social-hub events export-csv -t $T --account <uuid> --from 2026-05-01T00:00:00Z > filtered.csv
120
+ social-hub events append -t <team-id> --type comment --payload '{"permalink":"https://..."}'
121
+ social-hub events list -t <team-id> -n 20
122
+ social-hub events list-full -t <team-id> --account <uuid>
123
+ social-hub events export-csv -t <team-id> > events.csv
175
124
  ```
176
125
 
177
126
  ### 发布日历
178
127
 
179
128
  ```bash
180
- social-hub calendar list -t $T --status scheduled
181
- social-hub calendar list-full -t $T --account <accountId> --status scheduled
182
- social-hub calendar patch -t $T -e <entryId> --body '{"status":"succeeded","permalink":"https://..."}'
129
+ social-hub calendar list -t <team-id> --status scheduled
130
+ social-hub calendar list-full -t <team-id> --account <accountId> --status scheduled
131
+ social-hub calendar patch -t <team-id> -e <entryId> --body '{"status":"succeeded","permalink":"https://..."}'
183
132
  ```
184
133
 
185
134
  ### 调度任务
186
135
 
187
136
  ```bash
188
- social-hub jobs list -t $T --status scheduled
189
- social-hub jobs list-full -t $T --account <accountId>
190
- social-hub jobs create -t $T -j '{"socialAccountId":"<uuid>","action":"engage","subreddit":"LocalLLaMA","runAt":"2026-05-07T09:00:00Z"}'
191
- social-hub jobs agent-status -t $T -i <jobId> -j '{"status":"succeeded"}'
192
- social-hub jobs agent-status -t $T -i <jobId> -j '{"status":"failed","lastError":"timeout"}'
193
- social-hub jobs retry -t $T -i <jobId>
194
- social-hub jobs cancel -t $T -i <jobId>
195
- ```
196
-
197
- ### 发布计划
198
-
199
- ```bash
200
- social-hub plans list -t $T
201
- social-hub plans list -t $T --campaign <campaignId>
202
- social-hub plans create -t $T -j '{"campaignId":"<uuid>","name":"Q3 Week1","entries":[{"socialAccountId":"<uuid>","subreddit":"LocalLLaMA","plannedAt":"2026-07-01T09:00:00Z"}]}'
203
- social-hub plans cancel -t $T --plan <planId>
137
+ social-hub jobs list -t <team-id> --status scheduled
138
+ social-hub jobs create -t <team-id> -j '{"socialAccountId":"<uuid>","action":"engage","subreddit":"LocalLLaMA","runAt":"2026-05-07T09:00:00Z"}'
139
+ social-hub jobs retry -t <team-id> -i <jobId>
140
+ social-hub jobs cancel -t <team-id> -i <jobId>
204
141
  ```
205
142
 
206
- ### 内容草稿
207
-
208
- ```bash
209
- social-hub drafts list -t $T -n 20
210
- social-hub drafts create -t $T -j '{"campaignId":"<uuid>","title":"Test Post","body":"Content..."}'
211
- social-hub drafts get -t $T --draft <uuid>
212
- social-hub drafts update -t $T --draft <uuid> -j '{"status":"approved"}'
213
- social-hub drafts delete -t $T --draft <uuid>
214
- ```
215
-
216
- ### 报告库
217
-
218
- ```bash
219
- social-hub reports list -t $T -n 20
220
- social-hub reports create -t $T -j '{"reportType":"campaign-digest","title":"5月报告","source":"manual","contentMarkdown":"# 报告..."}'
221
- social-hub reports ingest -t $T -j '{"reportType":"reddit-post-snapshot","source":"path/to/file.md"}'
222
- ```
143
+ OpenClaw 执行态优先 `social-hub ops *`(见 `social-hub-ops-runtime`);`jobs agent-status` 为遗留路径。
223
144
 
224
- ### 账号管理
145
+ ### 发布计划 / 草稿 / 报告
225
146
 
226
147
  ```bash
227
- social-hub accounts list -t $T
228
- social-hub accounts list -t $T --status active
229
- social-hub accounts get -t $T --account <uuid>
230
- social-hub accounts create -t $T -j '{"platform":"reddit","handle":"u_example","externalId":"..."}'
231
- social-hub compliance risk-get -t $T -a <accountId>
232
- social-hub compliance risk-put -t $T -a <accountId> -j '{"riskLevel":"medium","notes":"..."}'
148
+ social-hub plans list -t <team-id>
149
+ social-hub plans create -t <team-id> -j '{"campaignId":"<uuid>","name":"Q3 Week1","entries":[...]}'
150
+ social-hub drafts list -t <team-id> -n 20
151
+ social-hub reports list -t <team-id> -n 20
233
152
  ```
234
153
 
235
- ### 品牌与 Campaign
154
+ ### 账号 / 品牌 / Campaign
236
155
 
237
156
  ```bash
238
- social-hub brands list -t $T
239
- social-hub brands create -t $T -j '{"name":"My Brand","slug":"my-brand"}'
240
- social-hub brands update -t $T --brand <brandId> -j '{"name":"New Name"}'
241
- social-hub campaigns list -t $T --brand <brandId>
242
- social-hub campaigns get -t $T --campaign <uuid>
243
- social-hub campaigns create -t $T -j '{"brandId":"<uuid>","name":"2026 Q2"}'
244
- social-hub campaigns update -t $T --campaign <uuid> -j '{"name":"2026 Q3"}'
157
+ social-hub accounts list -t <team-id> --status active
158
+ social-hub accounts get -t <team-id> --account <uuid>
159
+ social-hub brands list -t <team-id>
160
+ social-hub campaigns list -t <team-id> --brand <brandId>
245
161
  ```
246
162
 
247
163
  ### 板块情报
248
164
 
249
165
  ```bash
250
- social-hub intelligence hot-posts -t $T --subreddit LocalLLaMA
251
- social-hub intelligence hot-posts -t $T --sort score -n 50
252
- social-hub intelligence dispatch -t $T -j '{"hotPostId":"<uuid>","socialAccountId":"<uuid>","action":"engage"}'
253
- social-hub intelligence kol-intents -t $T -n 20
254
- social-hub intelligence watchlists-list -t $T
166
+ social-hub intelligence hot-posts -t <team-id> --subreddit LocalLLaMA --sort score -n 50
167
+ social-hub intelligence dispatch -t <team-id> -j '{"hotPostId":"<uuid>","socialAccountId":"<uuid>","action":"engage"}'
168
+ social-hub intelligence watchlists-list -t <team-id>
255
169
  ```
256
170
 
257
171
  ### 团队与用户管理
258
172
 
259
173
  ```bash
260
174
  social-hub agent-teams list
261
- social-hub agent-teams create --slug moss --name "Moss Agent Team" # admin only
262
- social-hub agent-teams add-member -t $T --user <userId> --role manager # admin only
263
- social-hub users list -t $T
264
- social-hub users create -t $T -j '{"email":"agent@example.com","password":"xxx","role":"manager"}'
175
+ social-hub agent-teams create --slug javis --name "Javis Agent Team" # admin only
176
+ social-hub users list -t <team-id>
177
+ social-hub users create -t <team-id> -j '{"email":"ops@example.com","password":"...","role":"manager"}'
265
178
  ```
266
179
 
267
180
  ### 通知渠道
268
181
 
269
182
  ```bash
270
- social-hub notification-channels list -t $T
271
- social-hub notification-channels create -t $T -j '{"provider":"feishu","externalId":"https://open.feishu.cn/open-apis/bot/v2/hook/..."}'
272
- social-hub notification-channels test -t $T --channel <uuid>
273
- social-hub notification-channels delete -t $T --channel <uuid>
183
+ social-hub notification-channels list -t <team-id>
184
+ social-hub notification-channels create -t <team-id> -j '{"provider":"feishu","externalId":"https://..."}'
274
185
  ```
275
186
 
276
- ### API Key 管理
187
+ ### API Key 管理(管理员资源,非 CLI 登录方式)
277
188
 
278
189
  ```bash
279
- social-hub api-keys list -t $T
280
- social-hub api-keys create -t $T -j '{"name":"agent-key","role":"manager"}'
281
- social-hub api-keys rotate -t $T --key <uuid>
282
- social-hub api-keys delete -t $T --key <uuid>
190
+ social-hub api-keys list -t <team-id>
191
+ social-hub api-keys create -t <team-id> -j '{"name":"integration","role":"manager"}'
283
192
  ```
284
193
 
285
194
  ---
286
195
 
287
196
  ## 典型工作流
288
197
 
289
- ### 工作流 1:Agent 执行完成后回填 Hub
198
+ ### Agent 执行完成后回填
290
199
 
291
- ```bash
292
- T=$SOCIAL_HUB_TEAM_ID
293
- ENTRY_ID="<calendarEntryId>"
294
- PERMALINK="https://www.reddit.com/r/LocalLLaMA/comments/xxx/yyy/"
295
-
296
- # 1. 更新日历条目状态为 succeeded
297
- social-hub calendar patch -t $T -e $ENTRY_ID \
298
- --body "{\"status\":\"succeeded\",\"permalink\":\"$PERMALINK\"}"
200
+ 优先 `social-hub ops complete --permalink ...`(见 `social-hub-ops-runtime`)。手动 patch 示例:
299
201
 
300
- # 2. 写入互动事件
301
- social-hub events append -t $T \
302
- --type "post.published" \
303
- --payload "{\"permalink\":\"$PERMALINK\",\"calendarEntryId\":\"$ENTRY_ID\"}"
304
-
305
- # 3. 查看该账号近期事件(验证写入)
306
- social-hub events list-full -t $T --account $ACCOUNT_ID -n 10
202
+ ```bash
203
+ social-hub calendar patch -t <team-id> -e <entryId> \
204
+ --body '{"status":"succeeded","permalink":"https://www.reddit.com/r/.../..."}'
205
+ social-hub events append -t <team-id> --type post.published \
206
+ --payload '{"permalink":"...","calendarEntryId":"<entryId>"}'
307
207
  ```
308
208
 
309
- ### 工作流 2:查看账号运营数据
209
+ ### 查看账号运营数据
310
210
 
311
211
  ```bash
312
- T=$SOCIAL_HUB_TEAM_ID
313
- ACCOUNT_ID="<socialAccountId>"
314
-
315
- # 账号详情
316
- social-hub accounts get -t $T --account $ACCOUNT_ID
317
-
318
- # 近期事件
319
- social-hub events list-full -t $T --account $ACCOUNT_ID -n 20
320
-
321
- # 近期调度任务
322
- social-hub jobs list-full -t $T --account $ACCOUNT_ID --status scheduled
323
-
324
- # 关联发布日历
325
- social-hub calendar list-full -t $T --account $ACCOUNT_ID --status scheduled
326
-
327
- # 风险档案
328
- social-hub compliance risk-get -t $T -a $ACCOUNT_ID
212
+ social-hub accounts get -t <team-id> --account <accountId>
213
+ social-hub events list-full -t <team-id> --account <accountId> -n 20
214
+ social-hub jobs list-full -t <team-id> --account <accountId> --status scheduled
215
+ social-hub compliance risk-get -t <team-id> -a <accountId>
329
216
  ```
330
217
 
331
- ### 工作流 3:情报热帖派发任务
218
+ ### 情报热帖派发
332
219
 
333
220
  ```bash
334
- T=$SOCIAL_HUB_TEAM_ID
335
-
336
- # 1. 查看热帖
337
- social-hub intelligence hot-posts -t $T --sort score -n 10
338
-
339
- # 2. 查看可用账号
340
- social-hub accounts list -t $T --status active
341
-
342
- # 3. 派发互动任务
343
- social-hub intelligence dispatch -t $T -j '{
344
- "hotPostId": "<hotPostId>",
345
- "socialAccountId": "<accountId>",
346
- "action": "engage",
347
- "runAt": "2026-05-07T09:00:00Z"
348
- }'
349
-
350
- # 4. 确认任务已创建
351
- social-hub jobs list -t $T --status scheduled -n 5
221
+ social-hub intelligence hot-posts -t <team-id> --sort score -n 10
222
+ social-hub accounts list -t <team-id> --status active
223
+ social-hub intelligence dispatch -t <team-id> -j '{"hotPostId":"...","socialAccountId":"...","action":"engage","runAt":"..."}'
224
+ social-hub jobs list -t <team-id> --status scheduled -n 5
352
225
  ```
353
226
 
354
227
  ---
355
228
 
356
229
  ## 注意事项
357
230
 
358
- - 所有命令输出均为 **JSON**,可管道传给 `jq` 处理:`social-hub accounts list -t $T | jq '.items[].handle'`
359
- - `DELETE` 端点(drafts delete、plans cancel、notification-channels delete)返回空响应(204),成功时打印 `OK`
360
- - `events export-csv` 和 `intelligence hot-posts-export` 输出 CSV 到 stdout,可直接重定向:`> output.csv`
361
- - 团队管理操作(`agent-teams create/update/add-member`)需要 **admin** 角色的 API Key
362
- - SessionCookie)认证不在 CLI 支持范围内,始终使用 API Key
363
-
231
+ - 命令输出多为 **JSON**,可管道 `jq`。
232
+ - `DELETE` / cancel 成功时可能返回 204,CLI 打印 `OK`。
233
+ - `events export-csv`、`intelligence hot-posts-export` 输出 CSV 到 stdout
234
+ - 团队管理(`agent-teams create` 等)需要 **admin** role CLI token。
235
+ - CLI 凭证来自 **Device Code**(`auth login`),不是 Web Session Cookie,也不是日常手动创建的 API Key
@@ -3,20 +3,20 @@
3
3
  "evals": [
4
4
  {
5
5
  "id": 0,
6
- "prompt": "我刚在本地部署好了 Social Ops Hub,openclaw-template 也初始化完了。我需要在 Hub 里注册一个新团队叫 javisslug 也是 javis,然后给这个团队添加一个管理员用户,email ops@javis.local,密码是 Javis2026!。完成后确认一下团队列表里有了这个团队。",
7
- "expected_output": "使用 social-hub-cli skill,依次执行:social-hub agent-teams create、social-hub users create -t <newTeamId>、social-hub agent-teams list,输出各步骤的命令和 JSON 结果",
6
+ "prompt": "我要连生产 Social Ops Hub(https://reddit.eclick-geo.com/api),用 social-hub 登录并确认当前身份和 team,然后在 Hub 里注册一个新团队 javisslug 也是 javis),给这个团队添加管理员用户 ops@javis.local,密码 Javis2026!,最后确认团队列表里有 javis。不要用 SOCIAL_HUB_API_KEY 环境变量。",
7
+ "expected_output": "先读 social-hub-shared:auth login --api-url 生产地址、auth whoami、context use;再读 social-hub-cli/admin:agent-teams create、users createagent-teams list;全程 Device Code 凭证,不 export API key",
8
8
  "assertions": []
9
9
  },
10
10
  {
11
11
  "id": 1,
12
- "prompt": "我的 Reddit 账号 u/example_user(id abc123-...-uuid)刚刚在 r/LocalLLaMA 发了一个帖子,permalink 是 https://www.reddit.com/r/LocalLLaMA/comments/abc123/test_post/。对应的发布日历条目 id 是 def456-...-uuid。帮我把这个结果写进 Social Ops Hub:把日历条目标记为 succeeded,写入 permalink,同时记录一条 post.published 事件。最后查一下这个账号最近的互动事件确认写入成功。",
13
- "expected_output": "执行 calendar patch(succeeded + permalink)、events append(post.published)、events list-full --account,输出每步的命令和结果",
12
+ "prompt": "Reddit 账号 u/example_user 刚在 r/LocalLLaMA 发帖,permalink 是 https://www.reddit.com/r/LocalLLaMA/comments/abc123/test_post/,日历条目 def456-uuid。我已在生产 Hub auth login 并 context use 了 team。帮我把日历标 succeeded、写 post.published 事件,并查该账号最近事件。优先 ops complete,若需手动则 calendar patch + events append。",
13
+ "expected_output": "确认已 auth/context;执行 ops complete 或 calendar patch + events append + events list-full;不要求设置 SOCIAL_HUB_API_KEY",
14
14
  "assertions": []
15
15
  },
16
16
  {
17
17
  "id": 2,
18
- "prompt": "帮我查一下 Social Ops Hub 里板块情报里 r/Entrepreneur 最近按分数排名的前 5 条热帖,然后选第一条,派发一个 engage 互动任务给账号 ghi789-...-uuid,运行时间设为明天上午 9 点(2026-05-07T01:00:00Z UTC)。任务派发完后确认一下调度任务列表里有这条新任务。",
19
- "expected_output": "执行 intelligence hot-posts --subreddit Entrepreneur --sort score -n 5、intelligence dispatch(带 hotPostId/socialAccountId/action/runAt)、jobs list 确认,输出各步命令和结果",
18
+ "prompt": "查生产 Hub r/Entrepreneur score 5 热帖,给账号 ghi789-uuid 派发 engage 任务,runAt 2026-05-07T01:00:00Z,并确认 jobs 列表有新任务。我已 social-hub auth login 到 reddit.eclick-geo.com。",
19
+ "expected_output": "路由 social-hub-intelligencehot-posts、dispatch;social-hub-calendar-jobs:jobs list;使用 -t team-id 来自 context,不用 localhost API key env",
20
20
  "assertions": []
21
21
  }
22
22
  ]
@@ -4,22 +4,27 @@ description: >-
4
4
  板块情报:watchlists、hot posts、KOL intents、industry-pools、dispatch 等 social-hub intelligence 子命令。
5
5
  用户要盯 subreddit、拉热帖、行业池、情报派发时用本 skill。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-intelligence
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login 并 `context use <team-id>`。
14
+
12
15
  ```bash
13
- social-hub intelligence industry-pools-list -t "$T"
14
- social-hub intelligence watchlists-list -t "$T"
15
- social-hub intelligence hot-posts -t "$T" --subreddit technology
16
- social-hub intelligence dispatch -t "$T" -j '{ ... }' # 写操作注意 --apply
16
+ social-hub intelligence industry-pools-list -t <team-id>
17
+ social-hub intelligence watchlists-list -t <team-id>
18
+ social-hub intelligence hot-posts -t <team-id> --subreddit technology --sort score -n 50
19
+ social-hub intelligence kol-intents -t <team-id> -n 20
20
+ social-hub intelligence dispatch -t <team-id> -j '{ ... }' # 写操作:确认 payload 与 --apply(若命令支持)
17
21
  ```
18
22
 
19
- 账号可发帖板块优先用:
23
+ 账号可发帖板块优先用 Hub DB 查询,不要猜 subreddit:
20
24
 
21
25
  ```bash
22
- social-hub query account-pools -t "$T" --account <ref>
26
+ social-hub query account-pools -t <team-id> --account <ref>
27
+ social-hub query subreddit-candidates -t <team-id> --account <ref> --action publish_post
23
28
  ```
24
29
 
25
30
  WebSocket `runs/ws` 为 watch 能力,不适合普通 CLI 批处理。
@@ -4,23 +4,26 @@ description: >-
4
4
  Hub 数据批量:export events-jsonl、export agent-context、runbook replay、openclaw-ingest。
5
5
  用户要导出 JSONL、回放事件、迁移/对账时用本 skill;不包含工作区 shared 目录批量 sync(需人工决策)。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-migration
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login;导出/回放目标 team 用 `-t <team-id>`。
14
+
12
15
  ## 导出
13
16
 
14
17
  ```bash
15
- social-hub export events-jsonl -t "$T" -o events.jsonl -n 500
16
- social-hub export agent-context -t "$T" --account "<uuid>" -o ctx.json
18
+ social-hub export events-jsonl -t <team-id> -o events.jsonl -n 500
19
+ social-hub export agent-context -t <team-id> --account <uuid> -o ctx.json
17
20
  ```
18
21
 
19
22
  ## Runbook 回放
20
23
 
21
24
  ```bash
22
- social-hub runbook replay -t "$T" -f events.jsonl --dry-run
23
- social-hub runbook replay -t "$T" -f events.jsonl # 实际 append events
25
+ social-hub runbook replay -t <team-id> -f events.jsonl --dry-run
26
+ social-hub runbook replay -t <team-id> -f events.jsonl # 实际 append events
24
27
  ```
25
28
 
26
29
  JSONL 每行:`{"type":"comment","payload":{...}}`
@@ -5,15 +5,18 @@ description: >-
5
5
  export agent-context。用户问账号能发哪些版、任务上下文、板块池、guardrails、数据是否过期时,
6
6
  必须用 Hub DB 聚合接口,不要解析 Javis/Moss/Panda 工作区里的 shared/*.md。
7
7
  metadata:
8
- cliVersion: ">=0.0.1"
8
+ cliVersion: ">=0.0.6"
9
9
  ---
10
10
 
11
11
  # social-hub-openclaw-context
12
12
 
13
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
14
+ > 确认已 auth login。所有 `-t <team-id>` 与授权 team 一致。
15
+
13
16
  ## 账号上下文
14
17
 
15
18
  ```bash
16
- social-hub context account -t "$T" --account A1 \
19
+ social-hub context account -t <team-id> --account A1 \
17
20
  --expand pools,jobs,persona,risk,env,guardrails
18
21
  ```
19
22
 
@@ -22,24 +25,24 @@ social-hub context account -t "$T" --account A1 \
22
25
  ## 任务上下文
23
26
 
24
27
  ```bash
25
- social-hub context job -t "$T" --job "<scheduledJobId>"
28
+ social-hub context job -t <team-id> --job <scheduledJobId>
26
29
  ```
27
30
 
28
31
  ## 板块与候选
29
32
 
30
33
  ```bash
31
- social-hub query account-pools -t "$T" --account A1 --limit 50
32
- social-hub query subreddit-candidates -t "$T" --account A1 --action publish_post
34
+ social-hub query account-pools -t <team-id> --account A1 --limit 50
35
+ social-hub query subreddit-candidates -t <team-id> --account A1 --action publish_post
33
36
  ```
34
37
 
35
- ## 导出(给人看或离线审计)
38
+ ## 导出(审计 / 离线查看)
36
39
 
37
40
  ```bash
38
- social-hub export agent-context -t "$T" --account "<uuid>" -o /tmp/ctx.json
41
+ social-hub export agent-context -t <team-id> --account <uuid> -o /tmp/ctx.json
39
42
  ```
40
43
 
41
44
  ## freshness
42
45
 
43
- 响应中的 `freshness.needsRefresh === true` 时,应先刷新账号指标或情报,再执行发帖/评论。
46
+ 响应中 `freshness.needsRefresh === true` 时,应先刷新账号指标或情报,再执行发帖/评论。
44
47
 
45
48
  执行任务前配合 `social-hub-ops-runtime`;执行后 `ops complete` 回填 permalink。
@@ -4,31 +4,33 @@ description: >-
4
4
  OpenClaw / Agent 任务运行时:social-hub ops claim-next、claim、heartbeat、complete、fail、skip。
5
5
  用户要领任务、续租、心跳、回填 permalink、任务失败/跳过、避免改本地 Markdown 状态时必须用本 skill。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-ops-runtime
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login 并 `context use <team-id>`。不要用环境变量传 team 或 API key。
14
+
12
15
  Hub DB 是执行状态的真源;不要用 `shared/reddit-account-status.md` 等文件记录任务结果。
13
16
 
14
17
  ## 推荐流程
15
18
 
16
19
  ```bash
17
- export T="$SOCIAL_HUB_TEAM_ID"
18
- export AGENT="javis" # 或 moss / 你的 agentId
20
+ AGENT="javis" # 或 moss / 你的 agentId
19
21
 
20
- social-hub ops claim-next -t "$T" --agent "$AGENT"
21
- social-hub context job -t "$T" --job "<jobId>"
22
- social-hub ops heartbeat -t "$T" --job "<jobId>" --agent "$AGENT"
22
+ social-hub ops claim-next -t <team-id> --agent "$AGENT"
23
+ social-hub context job -t <team-id> --job <jobId>
24
+ social-hub ops heartbeat -t <team-id> --job <jobId> --agent "$AGENT"
23
25
  # 执行 Reddit / 浏览器操作,并写 interaction events(见 social-hub-cli events)
24
- social-hub ops complete -t "$T" --job "<jobId>" --agent "$AGENT" --permalink "https://reddit.com/..."
26
+ social-hub ops complete -t <team-id> --job <jobId> --agent "$AGENT" --permalink "https://reddit.com/..."
25
27
  ```
26
28
 
27
29
  失败或跳过:
28
30
 
29
31
  ```bash
30
- social-hub ops fail -t "$T" --job "<jobId>" --agent "$AGENT" --reason rule_blocked --message "..."
31
- social-hub ops skip -t "$T" --job "<jobId>" --agent "$AGENT" --reason manual_intervention_required
32
+ social-hub ops fail -t <team-id> --job <jobId> --agent "$AGENT" --reason rule_blocked --message "..."
33
+ social-hub ops skip -t <team-id> --job <jobId> --agent "$AGENT" --reason manual_intervention_required
32
34
  ```
33
35
 
34
36
  ## `--reason` 枚举(仅允许下列值)
@@ -4,17 +4,20 @@ description: >-
4
4
  Reddit 帖快照与数据:social-hub reddit list/stats/refresh/refresh-all/import-feishu 等。
5
5
  用户要查帖表现、刷新 score、导入飞书表、permalink 对应快照时用本 skill(命令组名为 reddit)。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-posts
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login 并选定 team。
14
+
12
15
  ```bash
13
- social-hub reddit list -t "$T" -n 20
14
- social-hub reddit stats -t "$T" --campaign "<uuid>"
15
- social-hub reddit refresh-status -t "$T" --id "<snapshotId>"
16
- social-hub reddit refresh-all -t "$T"
17
- social-hub reddit import-feishu -t "$T" -j '{ ... }'
16
+ social-hub reddit list -t <team-id> -n 20
17
+ social-hub reddit stats -t <team-id> --campaign <uuid>
18
+ social-hub reddit refresh-status -t <team-id> --id <snapshotId>
19
+ social-hub reddit refresh-all -t <team-id>
20
+ social-hub reddit import-feishu -t <team-id> -j '{ ... }'
18
21
  ```
19
22
 
20
- 发帖成功后应通过 `social-hub ops complete --permalink ...` 写回任务链路(见 `social-hub-publishing`)。
23
+ 发帖成功后应通过 `social-hub ops complete --permalink ...` 写回任务链路(见 `social-hub-publishing` / `social-hub-ops-runtime`)。
@@ -4,11 +4,14 @@ description: >-
4
4
  内容发布闭环:campaign → plan → draft → calendar → scheduled_job → events → reddit snapshot → report。
5
5
  用户要从草稿到排期、执行任务、permalink 回填、避免 job 成功但 calendar 未更新时用本 skill。
6
6
  metadata:
7
- cliVersion: ">=0.0.1"
7
+ cliVersion: ">=0.0.6"
8
8
  ---
9
9
 
10
10
  # social-hub-publishing
11
11
 
12
+ > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
+ > 确认已 auth login 并 `context use <team-id>`。
14
+
12
15
  ## 事实源
13
16
 
14
17
  - **计划**:`calendar_entries`
@@ -28,4 +31,4 @@ campaign → publishing_plan → content_draft → calendar_entry → scheduled_
28
31
  2. `social-hub ops claim-next` → 执行 → `social-hub ops complete --permalink <url>`
29
32
  3. `complete` 原子更新 job + calendar(+ 可选 snapshot id)
30
33
 
31
- 失败时 `ops fail` / `ops skip`,并写标准 `reason` 枚举。
34
+ 失败时 `ops fail` / `ops skip`,并使用标准 `reason` 枚举(见 `social-hub-ops-runtime`)。
@@ -1,41 +1,143 @@
1
1
  ---
2
2
  name: social-hub-shared
3
3
  description: >-
4
- social-hub 基础能力:config init/show、auth login、doctor、version、permissions、context list/use/current
5
- 在跑任何 Hub 写操作前应先 doctor 或 auth;配置报错、连不上 API、team 不对、权限不足时优先用本 skill。
4
+ social-hub 共享基础:config、auth login(Device Code)、context use/current、doctor、
5
+ permissions、权限排障与安全规则。用户首次配置、登录授权、连不上 API、team 不对、
6
+ 权限不足、或任何 Hub CLI 写操作前必须先读本 skill。Agent 日常凭证只用 auth login,
7
+ 不要用 SOCIAL_HUB_API_KEY 环境变量。
6
8
  metadata:
7
- cliVersion: ">=0.0.1"
9
+ cliVersion: ">=0.0.6"
8
10
  ---
9
11
 
10
12
  # social-hub-shared
11
13
 
12
- ## 环境变量
14
+ skill 是 Social Hub CLI 的**唯一详细鉴权与配置文档**。领域 skill(accounts、ops-runtime 等)开头会要求先读本文件;不要在各领域 skill 里重复展开鉴权流程。
13
15
 
14
- ```bash
15
- export SOCIAL_HUB_API_URL="http://localhost:3000"
16
- export SOCIAL_HUB_API_KEY="soh_..."
17
- export SOCIAL_HUB_TEAM_ID="<team-uuid>" # 或用 context use 持久化
18
- ```
16
+ ## 凭证与配置真源
17
+
18
+ | 项 | 推荐来源 | 说明 |
19
+ |---|---|---|
20
+ | API 地址 | `~/.config/social-hub/config.json` → `apiUrl` | 生产默认 `https://reddit.eclick-geo.com/api` |
21
+ | 凭证 | 同上 → `authToken`(Device Code 登录后写入) | CLI 内部以 Bearer 发送;**不要用环境变量传 key** |
22
+ | 默认 team | `context.json` 的 `currentTeamId` 或 config 的 `teamId` | 用 `social-hub context use` 持久化 |
19
23
 
20
- ## 常用命令
24
+ 配置文件路径:`~/.config/social-hub/config.json`(权限 `600`)。
25
+
26
+ ## 快速开始(生产)
21
27
 
22
28
  ```bash
23
- social-hub config init --api-url http://localhost:3000 --team $T
24
- social-hub auth login --api-key "$SOCIAL_HUB_API_KEY"
29
+ # 1. 浏览器 Device Code 授权(推荐,唯一日常路径)
30
+ social-hub auth login --api-url https://reddit.eclick-geo.com/api
31
+
32
+ # 2. 确认身份与 team
25
33
  social-hub auth whoami
34
+ social-hub context list
35
+
36
+ # 3. 选定当前操作的 team(只需做一次,或切换 team 时再做)
37
+ social-hub context use <team-uuid>
38
+
39
+ # 4. 健康与鉴权自检
26
40
  social-hub doctor
27
- social-hub version --json
28
- social-hub context use "$T"
41
+ social-hub health
42
+ ```
43
+
44
+ `health` 不需要登录;其他写读 Hub 数据的命令需要先完成 `auth login`。
45
+
46
+ ## 认证
47
+
48
+ ### 推荐:Device Code(`auth login`)
49
+
50
+ Agent 帮用户授权时,执行 `social-hub auth login` 并在终端输出 verification URL / user code,引导用户在浏览器完成审批:
51
+
52
+ ```bash
53
+ social-hub auth login --api-url https://reddit.eclick-geo.com/api
54
+ # 可选:登录时指定默认 team
55
+ social-hub auth login --api-url https://reddit.eclick-geo.com/api --team <team-uuid>
56
+ # 可选:CLI token 时长(需 Web 审批账号有相应权限)
57
+ social-hub auth login --duration short # 默认
58
+ social-hub auth login --duration long
59
+ ```
60
+
61
+ 成功后凭证写入 `config.json` 的 `authToken`,无需再 export 任何变量。
62
+
63
+ ### 查看 / 退出
64
+
65
+ ```bash
66
+ social-hub auth whoami # 同 auth status;含 role、teamId、visibleTeamIds
67
+ social-hub auth status
68
+ social-hub auth explain # 当前 role 可用命令
69
+ social-hub auth logout
70
+ social-hub auth logout --revoke # 同时撤销服务端 CLI token
71
+ ```
72
+
73
+ ### Team 上下文
74
+
75
+ 多数命令需要 `-t <team-uuid>`。先持久化当前 team,示例里可直接引用:
76
+
77
+ ```bash
78
+ social-hub context use <team-uuid> [--label "moss"]
29
79
  social-hub context current
30
- social-hub permissions matrix
31
- social-hub auth explain
80
+ social-hub context list # 含 authTeamId、visibleTeamIds
81
+ ```
82
+
83
+ ### 配置命令
84
+
85
+ ```bash
86
+ social-hub config show
87
+ social-hub config init --api-url https://reddit.eclick-geo.com/api [--team <uuid>]
88
+ social-hub config set apiUrl https://reddit.eclick-geo.com/api
89
+ social-hub config set teamId <team-uuid>
90
+ ```
91
+
92
+ ## 本地开发(仅调试 API 时用)
93
+
94
+ 本地 monorepo 跑 API 时,API 地址改为 `http://localhost:3000`:
95
+
96
+ ```bash
97
+ pnpm dev # 在 social-ops-hub 根目录
98
+ social-hub auth login --api-url http://localhost:3000
32
99
  ```
33
100
 
34
- ## 排障顺序
101
+ 本地 seed(`pnpm run db:seed:minimal-admin`)会打印 admin 账号;**仍应通过 Web 登录 + Device Code 授权 CLI**,不要把 seed 输出的 key 写进 skill 示例或环境变量。
102
+
103
+ ## Legacy:静态 API Key(管理员资源,非 Agent 日常凭证)
104
+
105
+ CLI 仍兼容 `social-hub auth login --api-key sk_live_…` 与 `SOCIAL_HUB_API_KEY` 环境变量,但**仅用于**:
106
+
107
+ - 服务端自动化 / CI(若团队明确允许)
108
+ - 管理员在 Hub Web 创建、轮换的 **API Key 资源**(`social-hub api-keys *`)
109
+
110
+ **Agent 与人工日常操作一律用 Device Code,不要**:
111
+
112
+ - `export SOCIAL_HUB_API_KEY=...`
113
+ - 在 skill 示例里把 API Key 当默认登录方式
114
+ - 把「创建 api-key」和「CLI 登录」混为一谈
115
+
116
+ ## 权限不足处理
117
+
118
+ 1. `social-hub doctor` — API 可达性、`/health/live`、auth context
119
+ 2. `social-hub auth whoami` — 确认 `role` 与 `teamId`
120
+ 3. `social-hub context current` — 确认 `-t` 与授权 team 一致
121
+ 4. `social-hub auth explain` — 当前 role 是否允许该命令
122
+ 5. 403 / permission denied — 换有权限的 Web 账号重新 `auth login`,或请 admin 调整成员角色
123
+
124
+ admin 专属操作(如 `agent-teams create`)需要 **admin** role 的 CLI token,不是「随便创建一个 API Key」就能替代。
125
+
126
+ ## 安全规则
127
+
128
+ - **禁止**在对话或日志中输出完整 token / API Key(`config show` 已脱敏)。
129
+ - **写入 / 删除**前确认用户意图;admin skill 中高风险操作用 `--dry-run` / `--apply`。
130
+ - **不要**用 `SOCIAL_HUB_CONFIG_DIR` 绕开标准配置路径,除非用户明确要求隔离环境。
131
+ - Session Cookie 认证不在 CLI 支持范围内;CLI 使用 Bearer token(Device Code 或 legacy API Key)。
132
+
133
+ ## 排障顺序(简表)
35
134
 
36
- 1. `social-hub health`(无需 Key)
37
- 2. `social-hub doctor`(含 `/health/live` 与 auth context)
38
- 3. 确认 `SOCIAL_HUB_TEAM_ID` API Key 绑定 team 一致
39
- 4. `social-hub auth explain` 查看当前角色允许的命令
135
+ | 现象 | 检查 |
136
+ |------|------|
137
+ | Not logged in | `social-hub auth login` |
138
+ | API unreachable | `config show` 的 apiUrl;生产应为 `https://reddit.eclick-geo.com/api` |
139
+ | Missing team id | `context use <uuid>` 或命令加 `-t` |
140
+ | team 不一致 warning | `auth whoami` 的 teamId vs `context current` |
141
+ | 401 / auth failed | 重新 `auth login`;过期则 `auth logout` 后重登 |
40
142
 
41
- 更完整命令表见同包的 `social-hub-cli` skill。
143
+ 更完整命令速查见同包 `social-hub-cli` skill。