@geoly-ai/social-hub-cli 0.0.12 → 0.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/admin-index-gates.test.d.ts +2 -0
  3. package/dist/admin-index-gates.test.d.ts.map +1 -0
  4. package/dist/admin-index-gates.test.js +33 -0
  5. package/dist/admin-index-gates.test.js.map +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +810 -63
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.test.js +87 -5
  10. package/dist/index.test.js.map +1 -1
  11. package/dist/permission-runner.d.ts +11 -0
  12. package/dist/permission-runner.d.ts.map +1 -0
  13. package/dist/permission-runner.js +30 -0
  14. package/dist/permission-runner.js.map +1 -0
  15. package/dist/permission-runner.test.d.ts +2 -0
  16. package/dist/permission-runner.test.d.ts.map +1 -0
  17. package/dist/permission-runner.test.js +69 -0
  18. package/dist/permission-runner.test.js.map +1 -0
  19. package/dist/permissions-gates-admin.d.ts +4 -0
  20. package/dist/permissions-gates-admin.d.ts.map +1 -0
  21. package/dist/permissions-gates-admin.js +80 -0
  22. package/dist/permissions-gates-admin.js.map +1 -0
  23. package/dist/permissions-gates-admin.test.d.ts +2 -0
  24. package/dist/permissions-gates-admin.test.d.ts.map +1 -0
  25. package/dist/permissions-gates-admin.test.js +25 -0
  26. package/dist/permissions-gates-admin.test.js.map +1 -0
  27. package/dist/permissions.d.ts.map +1 -1
  28. package/dist/permissions.js +2 -3
  29. package/dist/permissions.js.map +1 -1
  30. package/dist/register-admin.d.ts.map +1 -1
  31. package/dist/register-admin.js +343 -29
  32. package/dist/register-admin.js.map +1 -1
  33. package/dist/register-extensions.d.ts.map +1 -1
  34. package/dist/register-extensions.js +26 -19
  35. package/dist/register-extensions.js.map +1 -1
  36. package/dist/register-shared.js +1 -1
  37. package/dist/register-shared.js.map +1 -1
  38. package/package.json +2 -2
  39. package/skills/README.md +7 -5
  40. package/skills/manifest.json +17 -7
  41. package/skills/social-hub-accounts/SKILL.md +46 -13
  42. package/skills/social-hub-admin/SKILL.md +76 -10
  43. package/skills/social-hub-calendar-jobs/SKILL.md +26 -10
  44. package/skills/social-hub-cli/SKILL.md +35 -191
  45. package/skills/social-hub-cli/evals/evals.json +4 -4
  46. package/skills/social-hub-events-observability/SKILL.md +50 -0
  47. package/skills/social-hub-graph-compliance/SKILL.md +60 -0
  48. package/skills/social-hub-intelligence/SKILL.md +72 -7
  49. package/skills/social-hub-migration/SKILL.md +18 -5
  50. package/skills/social-hub-openclaw-context/SKILL.md +23 -8
  51. package/skills/social-hub-ops-runtime/SKILL.md +10 -5
  52. package/skills/social-hub-posts/SKILL.md +56 -23
  53. package/skills/social-hub-posts/evals/evals.json +23 -0
  54. package/skills/social-hub-publishing/SKILL.md +75 -11
  55. package/skills/social-hub-shared/SKILL.md +8 -4
@@ -1,61 +1,94 @@
1
1
  ---
2
2
  name: social-hub-posts
3
3
  description: >-
4
- Reddit 帖快照与数据:social-hub reddit list/stats/refresh/refresh-all/create-snapshot/batch-upsert 等。
5
- 用户要查帖表现、刷新 score、写入/更新帖快照、permalink 对应快照时用本 skill(命令组名为 reddit)。
4
+ Reddit 帖快照 CRUD 与批量写入:social-hub reddit list/stats/refresh/refresh-all/
5
+ create-snapshot/update/delete/batch-upsert。用户要查帖表现、刷新 score、写入或更新
6
+ 外部来源帖快照时用本 skill(命令组名为 reddit)。不负责从飞书或其他系统取数。
6
7
  metadata:
7
- cliVersion: ">=0.0.6"
8
+ cliVersion: ">=0.0.12"
8
9
  ---
9
10
 
10
11
  # social-hub-posts
11
12
 
12
13
  > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
- > 确认已 auth login 并选定 team
14
+ > 确认已 `auth login` `context use <team-id>`。
15
+
16
+ ## 职责边界
17
+
18
+ | 做 | 不做 |
19
+ |---|---|
20
+ | Hub 内 Reddit 帖快照的查询、刷新、单条/批量写入 | 从飞书 Base、CSV、工作区 Markdown 读取并映射字段 |
21
+ | 说明 `batch-upsert` 的 JSON item 字段与幂等行为 | team 路由、外部 ETL 脚本、来源系统鉴权 |
22
+ | 删除/刷新前提示风险 | 用 `reddit import-feishu`(已废弃) |
23
+
24
+ 外部数据(飞书、表格、爬虫)应先在你自己的流程里整理成 JSON,再调用本模块命令写入 Hub。
14
25
 
15
26
  ## 查询与刷新
16
27
 
17
28
  ```bash
18
29
  social-hub reddit list -t <team-id> -n 20
19
30
  social-hub reddit stats -t <team-id> --campaign <uuid>
20
- social-hub reddit refresh-status -t <team-id> --id <snapshotId>
31
+ social-hub reddit refresh-status -t <team-id>
32
+ social-hub reddit refresh -t <team-id> --snapshot <snapshotId>
33
+ social-hub reddit refresh-progress -t <team-id> --task <taskId>
21
34
  social-hub reddit refresh-all -t <team-id>
22
35
  ```
23
36
 
24
- ## 写入帖快照(含飞书同步)
25
-
26
- **不要用 `reddit import-feishu`。** 飞书数据在本机用 `lark-cli` 读取,再用 Hub 写入命令同步。
37
+ ## 单条写入与更新
27
38
 
28
39
  ```bash
29
- # 本机读飞书 Base(示例)
30
- lark-cli base +record-list \
31
- --base-token <baseToken> \
32
- --table-id <tableId> \
33
- --view-id <viewId>
34
-
35
- # 单条补录
36
40
  social-hub reddit create-snapshot -t <team-id> -j '{
37
- "permalink": "https://www.reddit.com/r/.../comments/.../",
41
+ "permalink": "https://www.reddit.com/r/example/comments/abc/title/",
38
42
  "subreddit": "example",
43
+ "title": "Post title",
39
44
  "score": 0,
40
45
  "commentsCount": 0,
41
- "source": "feishu"
46
+ "source": "manual"
42
47
  }'
43
48
 
44
- # 批量幂等 upsert(推荐;同一 teamId + permalink 重复执行只更新)
49
+ social-hub reddit update -t <team-id> --snapshot <uuid> -j '{"score":42,"commentsCount":3}'
50
+ social-hub reddit delete -t <team-id> --snapshot <uuid> # 危险:确认用户意图
51
+ ```
52
+
53
+ ## 批量 upsert(外部来源帖快照)
54
+
55
+ ```bash
45
56
  social-hub reddit batch-upsert -t <team-id> -j '{
46
57
  "items": [
47
58
  {
48
- "permalink": "https://www.reddit.com/r/.../comments/.../",
59
+ "permalink": "https://www.reddit.com/r/example/comments/abc/title/",
49
60
  "subreddit": "example",
50
61
  "title": "...",
51
62
  "score": 12,
52
63
  "commentsCount": 3,
53
- "source": "feishu"
64
+ "source": "external",
65
+ "feishuRecordId": "recXXX",
66
+ "baseToken": "optional-base-token",
67
+ "tableId": "optional-table-id",
68
+ "viewCount": 100,
69
+ "brandRaw": "BrandName",
70
+ "rawPayload": { "custom": "fields" }
54
71
  }
55
72
  ]
56
- }'
73
+ }' --dry-run
57
74
  ```
58
75
 
59
- 多品牌/多 team:先 `social-hub agent-teams list` 建立品牌 → teamId 映射,再对每个 team 分别调用 `batch-upsert`(`-t` 为目标 team UUID)。
76
+ ### Item 字段说明
77
+
78
+ - **必填(推荐)**:`subreddit`;有真实 Reddit 链接时带 `permalink`
79
+ - **可选**:`title`、`score`、`commentsCount`、`postedAt`、`source`、`rawPayload`
80
+ - **`feishuRecordId`**:飞书记录 ID。当输入来自飞书时,Hub 优先按 `(teamId, feishuRecordId)` 幂等;同一 permalink 对应不同飞书记录时,后续记录可能获得 `feishu.local` 占位 permalink
81
+ - **无 permalink**:可只带 `feishuRecordId`(及 `baseToken`/`tableId`),Hub 会生成稳定占位 URL
82
+
83
+ ### 幂等与风险
84
+
85
+ - 重复 `batch-upsert` 同一条外部记录应更新而非重复插入(取决于提供的幂等键)
86
+ - `delete` 不可恢复;批量写入前先 `--dry-run` 查看计数
87
+ - 不要用已废弃的 `reddit import-feishu`
88
+
89
+ ## 与发布链路的关系
90
+
91
+ 发帖任务成功后,优先通过 `social-hub ops complete --permalink ...` 回填(见 `social-hub-ops-runtime`)。
92
+ 需要手动补快照时用 `create-snapshot` 或 `batch-upsert`。
60
93
 
61
- 发帖成功后应通过 `social-hub ops complete --permalink ...` 写回任务链路(见 `social-hub-publishing` / `social-hub-ops-runtime`)。
94
+ **维护 CRON / 手动维护**:OpenClaw `reddit-post-reply-maintenance` Step 4.7 profile 扫描后应 `batch-upsert` 更新 `score` / `commentsCount` / `viewCount`(曝光);见 OpenClaw `hub-adapter.md` §5d `references/cron-message-skeleton.md`。
@@ -0,0 +1,23 @@
1
+ {
2
+ "skill_name": "social-hub-posts",
3
+ "evals": [
4
+ {
5
+ "id": 0,
6
+ "prompt": "查 team <team-id> 最近 20 条 Reddit 帖快照,并按 campaign <campaign-id> 看 stats 汇总。我已 auth login。",
7
+ "expected_output": "social-hub reddit list、reddit stats;不路由到飞书同步或 lark-cli",
8
+ "assertions": []
9
+ },
10
+ {
11
+ "id": 1,
12
+ "prompt": "我有一批外部 JSON 帖数据(含 permalink、subreddit、score、feishuRecordId recABC),要批量写入 Hub team <team-id>,先 dry-run 再 apply。",
13
+ "expected_output": "social-hub reddit batch-upsert --dry-run 然后正式 upsert;说明 feishuRecordId 幂等;不展开飞书取数流程",
14
+ "assertions": []
15
+ },
16
+ {
17
+ "id": 2,
18
+ "prompt": "刷新 team <team-id> 全部 Reddit 帖 score,并查看 refresh 任务进度。",
19
+ "expected_output": "social-hub reddit refresh-all、reddit refresh-status 或 refresh-progress",
20
+ "assertions": []
21
+ }
22
+ ]
23
+ }
@@ -1,34 +1,98 @@
1
1
  ---
2
2
  name: social-hub-publishing
3
3
  description: >-
4
- 内容发布闭环:campaign → plan → draft → calendar → scheduled_job → eventsreddit snapshot → report。
5
- 用户要从草稿到排期、执行任务、permalink 回填、避免 job 成功但 calendar 未更新时用本 skill。
4
+ 内容发布闭环:brands、campaigns、plans、drafts、calendar、jobs、eventsreddit snapshot
5
+ reports。用户要从草稿到排期、执行任务、permalink 回填、避免 job 成功但 calendar 未更新时用本 skill。
6
6
  metadata:
7
- cliVersion: ">=0.0.6"
7
+ cliVersion: ">=0.0.12"
8
8
  ---
9
9
 
10
10
  # social-hub-publishing
11
11
 
12
12
  > **前置条件:** 先阅读 [`../social-hub-shared/SKILL.md`](../social-hub-shared/SKILL.md),
13
- > 确认已 auth login 并 `context use <team-id>`。
13
+ > 确认已 `auth login` 并 `context use <team-id>`。
14
14
 
15
15
  ## 事实源
16
16
 
17
17
  - **计划**:`calendar_entries`
18
18
  - **执行**:`scheduled_jobs`
19
- - 本地 Markdown 日历仅作导入/导出视图,不是运行时真源
19
+ - agent 工作区 Markdown 日历仅作导入/导出视图,不是运行时真源
20
20
 
21
21
  ## 链路
22
22
 
23
23
  ```
24
- campaignpublishing_plan → content_draft → calendar_entry → scheduled_job
24
+ brandcampaign → content_draft → publishing_plan → calendar_entry → scheduled_job
25
25
  → interaction_events → reddit_post_snapshot → op_report
26
26
  ```
27
27
 
28
- ## Agent 推荐
28
+ ## 品牌与 Campaign
29
29
 
30
- 1. 创建/查询 draft、plan、calendar、job(见 `social-hub-cli` 对应命令)
31
- 2. `social-hub ops claim-next` → 执行 → `social-hub ops complete --permalink <url>`
32
- 3. `complete` 原子更新 job + calendar(+ 可选 snapshot id)
30
+ ```bash
31
+ social-hub brands list -t <team-id>
32
+ social-hub brands create -t <team-id> -j '{"name":"My Brand","slug":"my-brand"}'
33
+ social-hub brands update -t <team-id> --brand <uuid> -j '{"name":"Updated"}'
33
34
 
34
- 失败时 `ops fail` / `ops skip`,并使用标准 `reason` 枚举(见 `social-hub-ops-runtime`)。
35
+ social-hub campaigns list -t <team-id> [--brand <uuid>]
36
+ social-hub campaigns create -t <team-id> -j '{"brandId":"<uuid>","name":"2026 Launch"}'
37
+ social-hub campaigns get -t <team-id> --campaign <uuid>
38
+ social-hub campaigns update -t <team-id> --campaign <uuid> -j '{"name":"Renamed"}'
39
+
40
+ social-hub campaigns accounts list -t <team-id> --campaign <uuid>
41
+ social-hub campaigns accounts assign -t <team-id> --campaign <uuid> --account <uuid>
42
+ social-hub campaigns accounts remove -t <team-id> --campaign <uuid> --account <uuid>
43
+ ```
44
+
45
+ ## 草稿与计划
46
+
47
+ ```bash
48
+ social-hub drafts list -t <team-id> -n 20
49
+ social-hub drafts create -t <team-id> -j '{"campaignId":"<uuid>","title":"Launch","body":"..."}'
50
+ social-hub drafts get -t <team-id> --draft <uuid>
51
+ social-hub drafts update -t <team-id> --draft <uuid> -j '{"body":"..."}'
52
+ social-hub drafts delete -t <team-id> --draft <uuid>
53
+
54
+ social-hub plans list -t <team-id>
55
+ social-hub plans create -t <team-id> -j '{"campaignId":"<uuid>","name":"Week 1","entries":[...]}'
56
+ social-hub plans cancel -t <team-id> --plan <uuid>
57
+ ```
58
+
59
+ ## 日历与任务
60
+
61
+ 见 `social-hub-calendar-jobs`:
62
+
63
+ ```bash
64
+ social-hub calendar list -t <team-id> --status scheduled
65
+ social-hub jobs list -t <team-id> --status scheduled
66
+ ```
67
+
68
+ ## Agent 执行与回填
69
+
70
+ 优先 ops 链路(见 `social-hub-ops-runtime`):
71
+
72
+ ```bash
73
+ social-hub ops claim-next -t <team-id> --agent <agent-id>
74
+ social-hub ops complete -t <team-id> --job <jobId> --agent <agent-id> --permalink "https://..."
75
+ ```
76
+
77
+ 手动回填(无 ops 时):
78
+
79
+ ```bash
80
+ social-hub calendar patch -t <team-id> -e <entryId> --body '{"status":"succeeded","permalink":"..."}'
81
+ social-hub events append -t <team-id> --type post.published --payload '{"permalink":"..."}'
82
+ ```
83
+
84
+ ## 帖快照与报告
85
+
86
+ ```bash
87
+ social-hub reddit create-snapshot -t <team-id> -j '{ ... }' # 见 social-hub-posts
88
+ social-hub reports list -t <team-id>
89
+ social-hub reports create -t <team-id> -j '{"title":"Weekly","bodyMarkdown":"..."}'
90
+ ```
91
+
92
+ ## 决策:ops complete vs 手动 patch
93
+
94
+ | 场景 | 推荐 |
95
+ |------|------|
96
+ | OpenClaw/Agent 刚执行完 scheduled job | `ops complete` |
97
+ | 无 job、仅补 calendar 状态 | `calendar patch` + `events append` |
98
+ | 外部已发帖、补 Hub 快照 | `reddit create-snapshot` 或 `batch-upsert` |
@@ -6,7 +6,7 @@ description: >-
6
6
  权限不足、或任何 Hub CLI 写操作前必须先读本 skill。Agent 日常凭证只用 auth login,
7
7
  不要用 SOCIAL_HUB_API_KEY 环境变量。
8
8
  metadata:
9
- cliVersion: ">=0.0.6"
9
+ cliVersion: ">=0.0.12"
10
10
  ---
11
11
 
12
12
  # social-hub-shared
@@ -65,7 +65,9 @@ social-hub auth login --duration long
65
65
  ```bash
66
66
  social-hub auth whoami # 同 auth status;含 role、teamId、visibleTeamIds
67
67
  social-hub auth status
68
- social-hub auth explain # 当前 role 可用命令
68
+ social-hub auth explain # 当前 role 可用命令(本地 gate 表)
69
+ social-hub permissions matrix -t <team-id> # 团队权限矩阵(API)
70
+ social-hub permissions explain # CLI 命令与权限映射
69
71
  social-hub auth logout
70
72
  social-hub auth logout --revoke # 同时撤销服务端 CLI token
71
73
  ```
@@ -75,7 +77,7 @@ social-hub auth logout --revoke # 同时撤销服务端 CLI token
75
77
  多数命令需要 `-t <team-uuid>`。先持久化当前 team,示例里可直接引用:
76
78
 
77
79
  ```bash
78
- social-hub context use <team-uuid> [--label "moss"]
80
+ social-hub context use <team-uuid> [--label "prod-team-a"]
79
81
  social-hub context current
80
82
  social-hub context list # 含 authTeamId、visibleTeamIds
81
83
  ```
@@ -118,9 +120,11 @@ CLI 仍兼容 `social-hub auth login --api-key sk_live_…` 与 `SOCIAL_HUB_API_
118
120
  1. `social-hub doctor` — API 可达性、`/health/live`、auth context
119
121
  2. `social-hub auth whoami` — 确认 `role` 与 `teamId`
120
122
  3. `social-hub context current` — 确认 `-t` 与授权 team 一致
121
- 4. `social-hub auth explain` — 当前 role 是否允许该命令
123
+ 4. `social-hub auth explain` — 当前 role 是否允许该命令(基于 CLI 本地 gate 表)
122
124
  5. 403 / permission denied — 换有权限的 Web 账号重新 `auth login`,或请 admin 调整成员角色
123
125
 
126
+ CLI 对部分命令(含 admin 域 settings/invites/members、reddit/accounts 写操作)会**先本地 RBAC 预检**再调 API;`auth explain` 展示的是本地 gate 映射,**后端 `assertRuntimePermission` 仍是最终裁决**。
127
+
124
128
  admin 专属操作(如 `agent-teams create`)需要 **admin** role 的 CLI token,不是「随便创建一个 API Key」就能替代。
125
129
 
126
130
  ## 安全规则