hdcommunity-mng-toolkit
v0.8.0
Published
Agent toolkit for Huawei Cloud Community management/operator consoles — MCP tools + Skills for blog review/online/top/stats, the growth-center management console (money-config change-request approval), and growth business-side points/coupon issue and exch
Maintainers
Readme
HDCommunity MNG Toolkit
华为云社区 · 管理面/运营面 Agent 工具包(MCP 工具 + Skill)。让 AI 编码助手(opencode / codex / 码道 等)以自然语言完成社区与成长中心管理台的运营操作,以及成长中心业务侧的查积分/发积分/发券/兑换。
- 本包为**端侧(工具包)**实现,结构/安装方式与用户面工具包
hdcommunity-toolkit一致。 - 只含管理面/运营面能力;看/写/发博客等用户面在
hdcommunity-toolkit。
分支与环境默认口径(强制)
| 分支 | 默认环境 | HDCOMMUNITY_BASE | HDGROW_BASE |
|---|---|---|---|
| main | 现网 | https://open-dataset.huaweicloud.com/api/v1/blogservice | https://grow-dataset.developer.huaweicloud.com/api/v1/hdgrowservice |
| develop | 测试 | 由 develop 分支的 src/config.mjs 提供默认值 | 由 develop 分支的 src/config.mjs 提供默认值 |
- 不要把测试配置带进
main;环境可用同名环境变量显式覆盖。 - 不确定当前指向哪套环境时,先调
hdgrow_admin_env(返回test / prod / mixed / custom与两个 base);所有写操作预览里也会带env。
安装
要求:Node.js ≥ 22。
支持的 Agent(10 个)
安装器支持以下 10 个 agent target(以 src/setup-cli.mjs 的 TARGETS 为单一真源,install --target all 与 status 均覆盖):
| target | Agent | Skills 落盘路径 | MCP 配置 |
|---|---|---|---|
| opencode | OpenCode | ~/.config/opencode/skills | 自动写入 opencode.json |
| codex | Codex CLI | ~/.codex/skills | 手动(见 Other Agents) |
| codex-desktop | Codex 桌面版 | ~/.codex/skills | 手动(见 Other Agents) |
| codearts | CodeArts Agent(码道) | ~/.codeartsdoer/skills | 手动(见 Other Agents) |
| codearts-work | CodeArts Work | ~/.codeartswork/skills | 手动(见 Other Agents) |
| workbuddy | WorkBuddy | ~/.workbuddy/skills | 手动(见 Other Agents) |
| dsh | DeepSeek Harness (DSH) | ~/.dsh/skills(DSH_HOME 可覆盖) | 自动写入 profiles/<profile>/cordis.patch.yml |
| hermes | Hermes | ~/.hermes/skills | 手动(见 Other Agents) |
| openclaw | OpenClaw | ~/.openclaw/skills | 手动(见 Other Agents) |
| atomcode | AtomCode | ~/.atomcode/skills | 手动(见 Other Agents) |
codex与codex-desktop共用~/.codex/skills(install --target all只拷贝一次)。
Quick Start
npx --yes hdcommunity-mng-toolkit install # 省略 --target = 默认 opencode
npx --yes hdcommunity-mng-toolkit doctor # 只读体检:Node / Skills / MCP 配置
npx --yes hdcommunity-mng-toolkit status # 查看 10 个 target 的安装状态
npx --yes hdcommunity-mng-toolkit update # 检查版本并给出升级指引
npx --yes hdcommunity-mng-toolkit uninstall --target opencode- 省略
--target的行为:install/uninstall都以opencode为目标(不是自动检测已装 agent),命令会打印默认提示。 - 未知 target:命令报错、列出全部合法值(10 个 +
all)、退出码 1,且不会创建任何目录。 - 安装完成后重启会话,新 Skills 与 MCP 工具才会被加载。
- MCP 自动注册覆盖
opencode与dsh;其余 target 安装后按 Other Agents 的片段手动注册。
让 Agent 帮你装:
请运行 npx --yes hdcommunity-mng-toolkit install --target <你的 agent>,再用 status 确认,并提醒我重启会话。
OpenCode
npx --yes hdcommunity-mng-toolkit install --target opencode- Skills 落盘:
~/.config/opencode/skills/ - MCP:自动合并到
~/.config/opencode/opencode.json的mcp.hdcommunity-mng-toolkit(local stdio,npx -y -p hdcommunity-mng-toolkit hdcommunity-mng-toolkit-mcp);已有配置无法解析时回退为打印片段。 uninstall --target opencode在移除 skills 的同时删除该 MCP 条目,保留其它 MCP 条目与配置字段;未安装时卸载为无害操作。- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target opencodeCodex
npx --yes hdcommunity-mng-toolkit install --target codex- Skills 落盘:
~/.codex/skills/ - MCP:不自动写入,安装后按 Other Agents 的片段加入 Codex 的
mcpServers。 - 重启 Codex 会话(重开 CLI)后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target codexCodex Desktop
npx --yes hdcommunity-mng-toolkit install --target codex-desktop- Skills 落盘:
~/.codex/skills/(与codex共用同一目录) - MCP:不自动写入,按 Other Agents 的片段手动注册。
- 重启 Codex 桌面应用后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target codex-desktopCodeArts Agent(码道)
npx --yes hdcommunity-mng-toolkit install --target codearts- Skills 落盘:
~/.codeartsdoer/skills/ - MCP:不自动写入,按 Other Agents 的片段注册到 CodeArts 的 MCP 设置。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target codeartsCodeArts Work
npx --yes hdcommunity-mng-toolkit install --target codearts-work- Skills 落盘:
~/.codeartswork/skills/ - MCP:不自动写入,按 Other Agents 的片段注册。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target codearts-workWorkBuddy
npx --yes hdcommunity-mng-toolkit install --target workbuddy- Skills 落盘:
~/.workbuddy/skills/ - MCP:不自动写入,按 Other Agents 的片段注册。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target workbuddyDeepSeek Harness (DSH)
npx --yes hdcommunity-mng-toolkit install --target dsh- Skills 落盘:
$DSH_HOME/skills(未设置DSH_HOME时为~/.dsh/skills) - MCP:自动写入
$DSH_HOME/profiles/<profile>/cordis.patch.yml(profile 默认web,可用DSH_PROFILE覆盖),使用insert:键语法注册id: mcp-hdcommunity;env透传HDCOMMUNITY_BASE/HDGROW_BASE(未设置时用当前分支默认地址)。- 按 id 幂等:重复 install 不会产生重复条目;若你已手写同 id 条目,install 不会重复写入,uninstall 也不会删除它。
uninstall --target dsh仅移除本工具写入的受管条目,保留其它用户内容。- 若
DSH_HOME不是可写目录,或已有cordis.patch.yml不是 YAML 序列(如 mapping),install 会 fail-fast(非 0 退出)并给出修复指引,当次不写入 skills 或 MCP 条目。
- 重启 DSH 会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target dshHermes
npx --yes hdcommunity-mng-toolkit install --target hermes- Skills 落盘:
~/.hermes/skills/ - MCP:不自动写入,按 Other Agents 的片段注册。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target hermesOpenClaw
npx --yes hdcommunity-mng-toolkit install --target openclaw- Skills 落盘:
~/.openclaw/skills/ - MCP:不自动写入,按 Other Agents 的片段注册。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target openclawAtomCode
npx --yes hdcommunity-mng-toolkit install --target atomcode- Skills 落盘:
~/.atomcode/skills/ - MCP:不自动写入,按 Other Agents 的片段注册。
- 重启会话后生效。
npx --yes hdcommunity-mng-toolkit doctor
npx --yes hdcommunity-mng-toolkit status
npx --yes hdcommunity-mng-toolkit uninstall --target atomcodeOther Agents
未内置 target 的 agent,只要支持 MCP,就手动注册本包的 MCP server(local stdio):
{
"mcpServers": {
"hdcommunity-mng-toolkit": {
"command": "npx",
"args": ["-y", "-p", "hdcommunity-mng-toolkit", "hdcommunity-mng-toolkit-mcp"],
"env": {
"HDGROW_BASE": "<你的 HDGROW_BASE>",
"HDCOMMUNITY_BASE": "<你的 HDCOMMUNITY_BASE>"
}
}
}
}- OpenCode 使用
mcp.<name>结构(type: local+command数组),由install --target opencode自动写入。 - Skills 仍需落盘,装到对应 agent 的 skills 目录:
npx --yes hdcommunity-mng-toolkit install --target <agent>;未内置的 agent 可用npx --yes hdcommunity-mng-toolkit install --target all后手工复制skills/。 - remote HTTP(Streamable HTTP)传输尚未实现:
--transport remote目前会回退 stdio,请使用上面的 stdio 片段。 - 认证类环境变量(
HDCOMMUNITY_ADMIN_USER、HW_ACCESS_KEY等)同样通过这些env传入,见配置。
认证
| 面 | 工具前缀 | 鉴权 |
|---|---|---|
| 博客管理台 | hdcommunity_admin_* | 内部账号登录 → Bearer(/manage/auth/login) |
| 成长中心管理台 | hdgrow_admin_* | 同上(登录 /manage/auth/*,接口 /agent/admin/grow/** 与 /manage/**;任务分类走只读 /agent/show/grow/task/categories) |
| 成长中心业务侧 | hdgrow_*(points/task/prize/发券) | 华为云 AK/SK(HW_ACCESS_KEY/HW_SECRET_KEY),与管理员登录无关 |
| 内容风控 | hdcommunity_admin_blog_risk_check | 无(本地词库) |
统一登录:hdcommunity_admin_login 与 hdgrow_admin_login 会用同一账号同时登录两个管理台;*_logout 同时登出。
管理台 401 自动重登(可选):设 HDCOMMUNITY_ADMIN_USER / HDCOMMUNITY_ADMIN_PASS(或 credentials.json 的 admin_user/admin_pass)。
工具清单(博客管理台 + 成长管理台)
博客管理台 hdcommunity_admin_*
登录/注销、blog_page/blog_detail/blog_review/blog_review_batch、blog_online/blog_top/blog_records、comment_page/comment_review/comment_review_batch/comment_online、stats。
成长中心管理台 hdgrow_admin_*(36)
登录/注销;环境自检 env;变更单 change_create|commit|approve|apply|revert|cancel|archive|get|page;task_page|_get、task_update、task_categories、prize_page|_get、whitelist_page;记录审计 record_points|_exchange|_issue|_job、user_page、user_block/user_unblock;积分补发 reissue_create|_page|_get|_approve|_issue;首个自然人 natural_person_page|_get|_approve|_reject;stats。
成长中心业务侧 hdgrow_*(6,AK/SK)
查询:points_query(查积分)、server_tasks(带个人完成状态)、server_prizes;
写入:points_add(发积分)、prize_exchange(兑换)、issue_coupon(发券)。
涉钱写操作默认 dry_run 预演 + 一次性 confirm_token + 高风险阈值 + 强制 biz_id。
内容风控
hdcommunity_admin_blog_risk_check(本地词库;审核时自动附带,标记风险不阻断)。
写操作两步确认(强制)
所有新建/修改/删除工具默认 dry_run=true:只返回 preview + env + 一次性 preview_confirm_token,不写任何数据。
流程:调用(默认预览)→ 把 preview(含 env)展示给用户并等回复[确认] → 用相同参数 + dry_run:false + preview_confirm_token 再调用一次才执行。
令牌 5 分钟有效、一次性、绑定参数;change_create 的预览走后端 POST /manage/change-request/preview(不产生草案);批量审核执行时按预览冻结的目标 id 处理。
配置(环境变量)
| 变量 | 默认 | 说明 |
|---|---|---|
| HDCOMMUNITY_BASE | main=现网 open-dataset;develop=测试(见 develop 分支 config) | 博客服务地址(用户面+管理面合并单服务) |
| HDGROW_BASE | main=现网 grow-dataset;develop=测试(见 develop 分支 config) | 成长服务地址,形如 https://<网关>/api/v1/hdgrowservice |
| HDCOMMUNITY_ADMIN_USER / HDCOMMUNITY_ADMIN_PASS | 空 | 管理台账号(401 自动重登用) |
| HW_ACCESS_KEY / HW_SECRET_KEY | 空 | 成长业务侧 AK/SK(发积分/发券/兑换) |
| HDGROW_RISK_FACE_AMOUNT_MAX / HDGROW_RISK_QUANTITY_MAX | 100 / 10 | 涉钱高风险阈值(业务侧写入) |
| HDCOMMUNITY_CONFIRM_TTL_MS | 300000(5 分钟) | 写操作预览令牌 preview_confirm_token 的有效期 |
在 Agent 的 MCP 配置里通过
env传入;默认值随分支变化,显式设置优先。
内置 Skill
| Skill | 用途 |
|---|---|
| hd-blog-operator | 博客运营:待审清理 / 内容巡检 |
| hd-grow-admin | 成长中心管理台:变更单分级审批、任务/权益/白名单、记录审计、统计、积分补发、首个自然人、用户拉黑 |
| hd-grow-operator | 成长中心业务侧:查积分/任务/权益、发积分、发券、兑换(涉钱强制预演) |
开发
npm install
npm run smoke # 协议层冒烟(无需网络)
node --test # 单元测试
npm start # 启动 MCP server(stdio)许可
Apache-2.0
