galaxy-opc-plugin 0.1.0

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 (46) hide show
  1. package/README.md +166 -0
  2. package/index.ts +145 -0
  3. package/openclaw.plugin.json +17 -0
  4. package/package.json +47 -0
  5. package/skills/basic-crm/SKILL.md +81 -0
  6. package/skills/basic-finance/SKILL.md +100 -0
  7. package/skills/business-monitoring/SKILL.md +120 -0
  8. package/skills/company-lifecycle/SKILL.md +99 -0
  9. package/skills/company-registration/SKILL.md +80 -0
  10. package/skills/finance-tax/SKILL.md +150 -0
  11. package/skills/hr-assistant/SKILL.md +127 -0
  12. package/skills/investment-management/SKILL.md +101 -0
  13. package/skills/legal-assistant/SKILL.md +113 -0
  14. package/skills/media-ops/SKILL.md +101 -0
  15. package/skills/procurement-management/SKILL.md +91 -0
  16. package/skills/project-management/SKILL.md +125 -0
  17. package/src/api/companies.ts +193 -0
  18. package/src/api/dashboard.ts +25 -0
  19. package/src/api/routes.ts +14 -0
  20. package/src/db/index.ts +63 -0
  21. package/src/db/migrations.ts +67 -0
  22. package/src/db/schema.ts +518 -0
  23. package/src/db/sqlite-adapter.ts +366 -0
  24. package/src/opc/company-manager.ts +82 -0
  25. package/src/opc/context-injector.ts +186 -0
  26. package/src/opc/reminder-service.ts +289 -0
  27. package/src/opc/types.ts +330 -0
  28. package/src/opc/workspace-factory.ts +189 -0
  29. package/src/tools/acquisition-tool.ts +150 -0
  30. package/src/tools/asset-package-tool.ts +283 -0
  31. package/src/tools/finance-tool.ts +244 -0
  32. package/src/tools/hr-tool.ts +211 -0
  33. package/src/tools/investment-tool.ts +201 -0
  34. package/src/tools/legal-tool.ts +191 -0
  35. package/src/tools/lifecycle-tool.ts +251 -0
  36. package/src/tools/media-tool.ts +174 -0
  37. package/src/tools/monitoring-tool.ts +207 -0
  38. package/src/tools/opb-tool.ts +193 -0
  39. package/src/tools/opc-tool.ts +206 -0
  40. package/src/tools/procurement-tool.ts +191 -0
  41. package/src/tools/project-tool.ts +203 -0
  42. package/src/tools/schemas.ts +163 -0
  43. package/src/tools/staff-tool.ts +211 -0
  44. package/src/utils/tool-helper.ts +16 -0
  45. package/src/web/config-ui.ts +3501 -0
  46. package/src/web/landing-page.ts +269 -0
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # 星环OPC中心 — OpenClaw 插件
2
+
3
+ > 一人公司(OPC)孵化与赋能平台,基于 [OpenClaw](https://github.com/openclaw/openclaw) 构建的 AI 员工全套解决方案。
4
+
5
+ ![版本](https://img.shields.io/badge/version-0.1.0-blue)
6
+ ![License](https://img.shields.io/badge/license-MIT-green)
7
+ ![OpenClaw](https://img.shields.io/badge/OpenClaw-2026.x-orange)
8
+
9
+ ---
10
+
11
+ ## ✨ 功能概览
12
+
13
+ | 模块 | 工具名 | 功能 |
14
+ |------|--------|------|
15
+ | 核心管理 | `opc_core` | 公司注册、客户管理、收支记录 |
16
+ | AI 员工 | `opc_staff` | 行政/财务/HR/法务/市场/运营岗位配置 |
17
+ | 财税管理 | `opc_finance` | 发票、增值税、所得税、纳税申报 |
18
+ | 法务合同 | `opc_legal` | 合同管理、风险评估、到期提醒 |
19
+ | 人力资源 | `opc_hr` | 员工档案、薪资、社保、公积金 |
20
+ | 新媒体运营 | `opc_media` | 内容创建、发布排期、数据分析 |
21
+ | 项目管理 | `opc_project` | 项目、任务、进度、预算跟踪 |
22
+ | 投融资 | `opc_investment` | 融资轮次、投资人、股权结构 |
23
+ | 服务采购 | `opc_procurement` | 服务项目、采购订单、费用统计 |
24
+ | 生命周期 | `opc_lifecycle` | 里程碑、大事记、时间线报告 |
25
+ | 运营监控 | `opc_monitoring` | 指标记录、告警管理、KPI 看板 |
26
+
27
+ **自动提醒服务**(后台每小时扫描):
28
+ - 税务申报到期提醒(7天内)
29
+ - 合同到期提醒(30天内)
30
+ - 现金流预警(净流出超 5000 元)
31
+ - 融资轮次截止跟进
32
+
33
+ **管理后台** `http://localhost:18789/opc/admin`:
34
+ - 公司仪表盘、财务总览、监控中心
35
+ - 一键进入公司 AI 助手对话
36
+ - SOP 使用指南
37
+
38
+ ---
39
+
40
+ ## 📦 安装
41
+
42
+ ### 前提条件
43
+
44
+ - 已安装并运行 [OpenClaw](https://github.com/openclaw/openclaw) Gateway
45
+ - Node.js 20+
46
+
47
+ ### 方式一:直接克隆到插件目录(推荐)
48
+
49
+ ```bash
50
+ # 进入你的 OpenClaw 插件目录
51
+ cd <your-openclaw-dir>/extensions
52
+
53
+ # 克隆插件
54
+ git clone https://github.com/P3ngSaM/opc.git opc-platform
55
+
56
+ # 安装依赖
57
+ cd opc-platform
58
+ npm install
59
+ ```
60
+
61
+ ### 方式二:手动下载
62
+
63
+ 下载 Release 压缩包,解压到 `<openclaw>/extensions/opc-platform/`,然后 `npm install`。
64
+
65
+ ---
66
+
67
+ ## ⚙️ 配置
68
+
69
+ 在 OpenClaw 配置文件 `~/.openclaw/openclaw.json` 中启用插件:
70
+
71
+ ```json
72
+ {
73
+ "plugins": {
74
+ "entries": {
75
+ "opc-platform": {
76
+ "enabled": true,
77
+ "config": {
78
+ "dbPath": "~/.openclaw/opc-platform/opc.db"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ `dbPath` 可选,默认为 `~/.openclaw/opc-platform/opc.db`,支持 `~/` 路径前缀。
87
+
88
+ ---
89
+
90
+ ## 🚀 快速开始
91
+
92
+ 重启 OpenClaw Gateway 后,对 AI 说:
93
+
94
+ ```
95
+ 注册一家公司,名称"极光科技有限公司",行业"软件开发",注册资金50万
96
+ ```
97
+
98
+ 然后访问管理后台:`http://localhost:18789/opc/admin`
99
+
100
+ ### 典型 SOP 流程
101
+
102
+ ```
103
+ 1. 注册公司 → opc_core: register_company
104
+ 2. 激活公司 → opc_core: activate_company
105
+ 3. 配置 AI 员工 → opc_staff: init_default_staff
106
+ 4. 日常运营 → 告诉 AI 助手记录收支、合同、员工等
107
+ 5. 融资管理 → opc_investment: create_round
108
+ 6. 生命周期报告 → opc_lifecycle: generate_report
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 📁 项目结构
114
+
115
+ ```
116
+ opc-platform/
117
+ ├── index.ts # 插件入口
118
+ ├── openclaw.plugin.json # 插件元数据
119
+ ├── package.json
120
+ ├── src/
121
+ │ ├── api/ # HTTP API 路由
122
+ │ ├── db/ # SQLite 数据库适配器 & Schema
123
+ │ ├── opc/ # 上下文注入、提醒服务、工作区工厂
124
+ │ ├── tools/ # 11 个 AI 工具模块
125
+ │ └── web/ # 管理后台 UI (config-ui) & Landing Page
126
+ └── skills/ # OpenClaw Skills 配置
127
+ ├── basic-crm/
128
+ ├── basic-finance/
129
+ ├── company-registration/
130
+ └── ...(共 11 个技能包)
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 🗄️ 数据库
136
+
137
+ 使用 SQLite(WAL 模式),自动迁移,无需手动建表。主要数据表:
138
+
139
+ - `opc_companies` — 公司档案
140
+ - `opc_transactions` — 收支流水
141
+ - `opc_contracts` — 合同管理
142
+ - `opc_tax_filings` — 税务申报
143
+ - `opc_employees` / `opc_hr_records` — HR 档案
144
+ - `opc_investment_rounds` — 融资轮次
145
+ - `opc_alerts` — 告警记录
146
+ - `opc_staff_config` — AI 员工角色配置
147
+ - ...共 19 张表
148
+
149
+ ---
150
+
151
+ ## 🛠️ 开发
152
+
153
+ ```bash
154
+ # 类型检查
155
+ npx tsc -p tsconfig.json --noEmit
156
+
157
+ # 构建管理后台 UI(如修改了 UI)
158
+ # 在 openclaw 根目录执行:
159
+ node scripts/ui.js build
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 📄 License
165
+
166
+ MIT © 2026 星河数科 (StarRiver Digital Technology)
package/index.ts ADDED
@@ -0,0 +1,145 @@
1
+ /**
2
+ * 星环OPC中心 — OpenClaw 插件入口
3
+ *
4
+ * 一人公司(OPC)孵化与赋能平台。
5
+ * 零核心代码修改,全部通过 Plugin API 扩展。
6
+ */
7
+
8
+ import fs from "node:fs";
9
+ import os from "node:os";
10
+ import path from "node:path";
11
+ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
12
+ import { Type } from "@sinclair/typebox";
13
+ import { registerHttpRoutes } from "./src/api/routes.js";
14
+ import type { OpcDatabase } from "./src/db/index.js";
15
+ import { SqliteAdapter } from "./src/db/sqlite-adapter.js";
16
+ import { registerContextInjector } from "./src/opc/context-injector.js";
17
+ import { startReminderService } from "./src/opc/reminder-service.js";
18
+ import { registerAcquisitionTool } from "./src/tools/acquisition-tool.js";
19
+ import { registerAssetPackageTool } from "./src/tools/asset-package-tool.js";
20
+ import { registerFinanceTool } from "./src/tools/finance-tool.js";
21
+ import { registerHrTool } from "./src/tools/hr-tool.js";
22
+ import { registerInvestmentTool } from "./src/tools/investment-tool.js";
23
+ import { registerLegalTool } from "./src/tools/legal-tool.js";
24
+ import { registerLifecycleTool } from "./src/tools/lifecycle-tool.js";
25
+ import { registerMediaTool } from "./src/tools/media-tool.js";
26
+ import { registerMonitoringTool } from "./src/tools/monitoring-tool.js";
27
+ import { registerOpcTool } from "./src/tools/opc-tool.js";
28
+ import { registerOpbTool } from "./src/tools/opb-tool.js";
29
+ import { registerProcurementTool } from "./src/tools/procurement-tool.js";
30
+ import { registerProjectTool } from "./src/tools/project-tool.js";
31
+ import { registerStaffTool } from "./src/tools/staff-tool.js";
32
+ import { registerConfigUi } from "./src/web/config-ui.js";
33
+ import { registerLandingPage } from "./src/web/landing-page.js";
34
+
35
+ /** 解析数据库路径,支持 ~ 前缀 */
36
+ function resolveDbPath(configured?: string): string {
37
+ const defaultPath = path.join(os.homedir(), ".openclaw", "opc-platform", "opc.db");
38
+ const dbPath = configured ?? defaultPath;
39
+ if (dbPath.startsWith("~/")) {
40
+ return path.join(os.homedir(), dbPath.slice(2));
41
+ }
42
+ return dbPath;
43
+ }
44
+
45
+ let db: OpcDatabase | null = null;
46
+
47
+ const plugin = {
48
+ id: "opc-platform",
49
+ name: "OPC Platform",
50
+ description: "星环OPC中心 — 一人公司孵化与赋能平台",
51
+ configSchema: Type.Object({
52
+ dbPath: Type.Optional(Type.String({ description: "SQLite 数据库文件路径,默认 ~/.openclaw/opc-platform/opc.db" })),
53
+ }, { additionalProperties: false }),
54
+
55
+ register(api: OpenClawPluginApi) {
56
+ // 解析数据库路径
57
+ const dbPath = resolveDbPath(
58
+ (api.pluginConfig as Record<string, unknown> | undefined)?.dbPath as string | undefined,
59
+ );
60
+
61
+ // 确保目录存在
62
+ const dbDir = path.dirname(dbPath);
63
+ fs.mkdirSync(dbDir, { recursive: true });
64
+
65
+ // 初始化数据库
66
+ db = new SqliteAdapter(dbPath);
67
+ api.logger.info(`opc: 数据库已初始化 (${dbPath})`);
68
+
69
+ // 读取工具启用配置(启动时一次性读取,修改后需重启生效)
70
+ const isEnabled = (key: string): boolean => {
71
+ const row = db!.queryOne(
72
+ "SELECT value FROM opc_tool_config WHERE key = ?", key,
73
+ ) as { value: string } | null;
74
+ return row?.value !== "disabled";
75
+ };
76
+
77
+ // 注册核心工具(始终启用)
78
+ registerOpcTool(api, db);
79
+ registerStaffTool(api, db);
80
+ registerOpbTool(api, db);
81
+
82
+ // 注册 Phase 2 专业工具(可通过管理后台禁用)
83
+ if (isEnabled("opc_finance")) registerFinanceTool(api, db);
84
+ if (isEnabled("opc_legal")) registerLegalTool(api, db);
85
+ if (isEnabled("opc_hr")) registerHrTool(api, db);
86
+ if (isEnabled("opc_media")) registerMediaTool(api, db);
87
+ if (isEnabled("opc_project")) registerProjectTool(api, db);
88
+
89
+ // 注册 Phase 3 业务闭环工具(可通过管理后台禁用)
90
+ if (isEnabled("opc_investment")) registerInvestmentTool(api, db);
91
+ if (isEnabled("opc_procurement")) registerProcurementTool(api, db);
92
+ if (isEnabled("opc_lifecycle")) registerLifecycleTool(api, db);
93
+ if (isEnabled("opc_monitoring")) registerMonitoringTool(api, db);
94
+
95
+ // 资金闭环工具(始终启用,核心商业模式)
96
+ registerAcquisitionTool(api, db);
97
+ registerAssetPackageTool(api, db);
98
+
99
+ api.logger.info("opc: 工具已按配置注册完毕(重启后生效)");
100
+
101
+ // 注册上下文注入钩子
102
+ registerContextInjector(api, db);
103
+
104
+ // 注册 HTTP API
105
+ registerHttpRoutes(api, db);
106
+
107
+ // 注册 Web UI
108
+ registerConfigUi(api, db);
109
+ registerLandingPage(api);
110
+
111
+ // 注册后台服务(数据库生命周期 + 自动提醒)
112
+ let stopReminder: (() => void) | null = null;
113
+ api.registerService({
114
+ id: "opc-db-lifecycle",
115
+ start() {
116
+ api.logger.info("opc: OPC 平台服务已启动");
117
+ // 读取 Webhook 配置
118
+ const webhookRow = db!.queryOne(
119
+ "SELECT value FROM opc_tool_config WHERE key = ?", "webhook_url",
120
+ ) as { value: string } | null;
121
+ const webhookUrl = webhookRow?.value?.trim() || undefined;
122
+ // 启动自动提醒服务(每小时扫描一次)
123
+ stopReminder = startReminderService(
124
+ db!,
125
+ (msg) => api.logger.info(msg),
126
+ webhookUrl,
127
+ );
128
+ api.logger.info(`opc: 自动提醒服务已启动(每小时扫描${webhookUrl ? ",Webhook 已配置" : ""})`);
129
+ },
130
+ stop() {
131
+ stopReminder?.();
132
+ stopReminder = null;
133
+ if (db) {
134
+ db.close();
135
+ db = null;
136
+ api.logger.info("opc: 数据库连接已关闭");
137
+ }
138
+ },
139
+ });
140
+
141
+ api.logger.info("opc: 星环OPC中心插件注册完毕");
142
+ },
143
+ };
144
+
145
+ export default plugin;
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "opc-platform",
3
+ "name": "OPC Platform",
4
+ "description": "星环OPC中心 — 一人公司孵化与赋能平台",
5
+ "version": "0.1.0",
6
+ "skills": ["./skills"],
7
+ "configSchema": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "dbPath": {
12
+ "type": "string",
13
+ "description": "SQLite 数据库文件路径,默认 ~/.openclaw/opc-platform/opc.db"
14
+ }
15
+ }
16
+ }
17
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "galaxy-opc-plugin",
3
+ "version": "0.1.0",
4
+ "description": "星环 Galaxy OPC — 一人公司孵化与赋能平台 OpenClaw 插件",
5
+ "keywords": [
6
+ "openclaw",
7
+ "openclaw-plugin",
8
+ "opc",
9
+ "one-person-company",
10
+ "ai",
11
+ "business",
12
+ "startup"
13
+ ],
14
+ "homepage": "https://github.com/P3ngSaM/galaxy-opc",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/P3ngSaM/galaxy-opc.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/P3ngSaM/galaxy-opc/issues"
21
+ },
22
+ "license": "MIT",
23
+ "author": "p3ngsam",
24
+ "type": "module",
25
+ "files": [
26
+ "index.ts",
27
+ "src/",
28
+ "skills/",
29
+ "openclaw.plugin.json"
30
+ ],
31
+ "dependencies": {
32
+ "@sinclair/typebox": "0.34.48",
33
+ "better-sqlite3": "^11.8.1"
34
+ },
35
+ "devDependencies": {
36
+ "@types/better-sqlite3": "^7.6.12"
37
+ },
38
+ "openclaw": {
39
+ "extensions": [
40
+ "./index.ts"
41
+ ],
42
+ "install": {
43
+ "npmSpec": "galaxy-opc-plugin",
44
+ "defaultChoice": "npm"
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: basic-crm
3
+ description: |
4
+ 基础客户管理技能。当用户提到客户、联系人、CRM、客户管理、跟进时激活。
5
+ ---
6
+
7
+ # 基础客户管理技能
8
+
9
+ 使用 `opc_manage` 工具管理客户/联系人信息。
10
+
11
+ ## 添加客户
12
+
13
+ ```json
14
+ {
15
+ "action": "add_contact",
16
+ "company_id": "公司ID",
17
+ "name": "李四",
18
+ "phone": "13900139000",
19
+ "email": "lisi@example.com",
20
+ "company_name": "客户公司名称",
21
+ "tags": "[\"VIP\", \"技术合作\"]",
22
+ "notes": "通过行业峰会认识,对AI产品感兴趣"
23
+ }
24
+ ```
25
+
26
+ ## 查看客户列表
27
+
28
+ 全部客户:
29
+ ```json
30
+ {
31
+ "action": "list_contacts",
32
+ "company_id": "公司ID"
33
+ }
34
+ ```
35
+
36
+ 按标签筛选:
37
+ ```json
38
+ {
39
+ "action": "list_contacts",
40
+ "company_id": "公司ID",
41
+ "tag": "VIP"
42
+ }
43
+ ```
44
+
45
+ ## 更新客户信息
46
+
47
+ ```json
48
+ {
49
+ "action": "update_contact",
50
+ "contact_id": "联系人ID",
51
+ "notes": "已发送产品方案,等待回复",
52
+ "last_contact_date": "2025-01-20"
53
+ }
54
+ ```
55
+
56
+ ## 删除客户
57
+
58
+ ```json
59
+ {
60
+ "action": "delete_contact",
61
+ "contact_id": "联系人ID"
62
+ }
63
+ ```
64
+
65
+ ## 标签体系
66
+
67
+ 建议使用以下标签分类客户:
68
+ - **客户类型**: `潜在客户`, `正式客户`, `VIP`, `合作伙伴`, `供应商`
69
+ - **行业**: `科技`, `金融`, `教育`, `制造`, `服务`
70
+ - **状态**: `跟进中`, `已成交`, `已流失`
71
+ - **来源**: `转介绍`, `线上获客`, `行业活动`
72
+
73
+ tags 字段使用 JSON 数组格式,例如: `["VIP", "科技", "跟进中"]`
74
+
75
+ ## 客户跟进建议
76
+
77
+ 在对话中帮助创业者:
78
+ 1. 添加客户时,主动询问标签和备注
79
+ 2. 更新跟进记录时,同步更新 `last_contact_date`
80
+ 3. 如果用户提到与某客户的互动,提醒记录
81
+ 4. 建议对长时间未联系的客户进行跟进
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: basic-finance
3
+ description: |
4
+ 基础财务记账技能。当用户提到记账、收入、支出、报表、财务、收支、流水时激活。
5
+ ---
6
+
7
+ # 基础财务技能
8
+
9
+ 使用 `opc_manage` 工具进行收支记录和财务统计。
10
+
11
+ ## 记账
12
+
13
+ ### 记录收入
14
+
15
+ ```json
16
+ {
17
+ "action": "add_transaction",
18
+ "company_id": "公司ID",
19
+ "type": "income",
20
+ "category": "service_income",
21
+ "amount": 50000,
22
+ "description": "XX项目开发尾款",
23
+ "counterparty": "客户公司名",
24
+ "transaction_date": "2025-01-15"
25
+ }
26
+ ```
27
+
28
+ ### 记录支出
29
+
30
+ ```json
31
+ {
32
+ "action": "add_transaction",
33
+ "company_id": "公司ID",
34
+ "type": "expense",
35
+ "category": "rent",
36
+ "amount": 3000,
37
+ "description": "1月办公室租金",
38
+ "counterparty": "房东姓名",
39
+ "transaction_date": "2025-01-01"
40
+ }
41
+ ```
42
+
43
+ ## 交易分类
44
+
45
+ | 分类 | 类型 | 说明 |
46
+ |---|---|---|
47
+ | `service_income` | 收入 | 服务/咨询收入 |
48
+ | `product_income` | 收入 | 产品销售收入 |
49
+ | `investment_income` | 收入 | 投资收益 |
50
+ | `salary` | 支出 | 工资/人力成本 |
51
+ | `rent` | 支出 | 房租/场地费用 |
52
+ | `utilities` | 支出 | 水电网等公用事业 |
53
+ | `marketing` | 支出 | 营销/推广费用 |
54
+ | `tax` | 支出 | 税费 |
55
+ | `supplies` | 支出 | 办公用品/耗材 |
56
+ | `other` | 通用 | 其他 |
57
+
58
+ ## 查询交易
59
+
60
+ ### 交易列表
61
+
62
+ ```json
63
+ {
64
+ "action": "list_transactions",
65
+ "company_id": "公司ID",
66
+ "type": "income",
67
+ "start_date": "2025-01-01",
68
+ "end_date": "2025-01-31",
69
+ "limit": 20
70
+ }
71
+ ```
72
+
73
+ ### 财务摘要
74
+
75
+ ```json
76
+ {
77
+ "action": "finance_summary",
78
+ "company_id": "公司ID",
79
+ "start_date": "2025-01-01",
80
+ "end_date": "2025-03-31"
81
+ }
82
+ ```
83
+
84
+ 返回: 总收入、总支出、净利润、交易笔数。
85
+
86
+ ## 记账建议
87
+
88
+ 对话中,帮助创业者:
89
+ 1. 收到收入/支出信息时,自动选择合适的分类
90
+ 2. 如果用户说"上个月",计算出具体日期范围
91
+ 3. 定期提醒查看财务摘要
92
+ 4. 如果净利润为负,温和地提出关注
93
+ 5. 金额使用人民币(元),无需用户每次声明货币
94
+
95
+ ## 平台看板
96
+
97
+ 查看整体统计:
98
+ ```json
99
+ { "action": "dashboard" }
100
+ ```
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: business-monitoring
3
+ description: |
4
+ 运营监控技能。当用户提到指标、KPI、告警、监控、运营看板、数据统计、业务指标时激活。
5
+ ---
6
+
7
+ # 运营监控技能
8
+
9
+ 使用 `opc_monitoring` 工具记录运营指标、管理告警和查看 KPI 汇总。
10
+
11
+ ## 指标记录
12
+
13
+ ### 记录运营指标
14
+
15
+ ```json
16
+ {
17
+ "action": "record_metric",
18
+ "company_id": "公司ID",
19
+ "name": "月收入",
20
+ "value": 50000,
21
+ "unit": "元",
22
+ "category": "revenue",
23
+ "recorded_at": "2025-03-31",
24
+ "notes": "3月份总收入"
25
+ }
26
+ ```
27
+
28
+ 常用指标分类: revenue(收入), user(用户), conversion(转化), cost(成本), other
29
+
30
+ ### 查询指标数据
31
+
32
+ ```json
33
+ {
34
+ "action": "get_metrics",
35
+ "company_id": "公司ID",
36
+ "name": "月收入",
37
+ "category": "revenue",
38
+ "start_date": "2025-01-01",
39
+ "end_date": "2025-12-31"
40
+ }
41
+ ```
42
+
43
+ ## 告警管理
44
+
45
+ ### 创建告警
46
+
47
+ ```json
48
+ {
49
+ "action": "create_alert",
50
+ "company_id": "公司ID",
51
+ "title": "现金流预警",
52
+ "severity": "warning",
53
+ "category": "finance",
54
+ "message": "账户余额低于安全线,建议尽快回款"
55
+ }
56
+ ```
57
+
58
+ 告警严重度: info(提示), warning(警告), critical(严重)
59
+
60
+ ### 查看告警列表
61
+
62
+ ```json
63
+ {
64
+ "action": "list_alerts",
65
+ "company_id": "公司ID",
66
+ "severity": "critical",
67
+ "status": "active"
68
+ }
69
+ ```
70
+
71
+ ### 消除告警
72
+
73
+ ```json
74
+ {
75
+ "action": "dismiss_alert",
76
+ "alert_id": "告警ID"
77
+ }
78
+ ```
79
+
80
+ 告警状态: `active` → `acknowledged` → `resolved`
81
+
82
+ ## KPI 汇总
83
+
84
+ ### 查看 KPI 看板
85
+
86
+ ```json
87
+ {
88
+ "action": "kpi_summary",
89
+ "company_id": "公司ID"
90
+ }
91
+ ```
92
+
93
+ 返回跨表聚合数据:
94
+ - **财务**: 总收入/总支出/净利润
95
+ - **团队**: 活跃员工数
96
+ - **项目**: 总数/进行中/已完成
97
+ - **合同**: 总数/活跃数/活跃合同价值
98
+ - **客户**: 联系人总数
99
+ - **告警**: 活跃告警(按严重度分组)
100
+ - **最新指标**: 最近20条指标记录
101
+
102
+ ## 常用指标参考
103
+
104
+ | 指标 | 单位 | 类别 | 建议记录频率 |
105
+ |------|------|------|-------------|
106
+ | 月收入 | 元 | revenue | 每月 |
107
+ | 月支出 | 元 | cost | 每月 |
108
+ | 注册用户数 | 人 | user | 每月 |
109
+ | 活跃用户数 | 人 | user | 每月 |
110
+ | 转化率 | % | conversion | 每月 |
111
+ | 客单价 | 元 | revenue | 每月 |
112
+ | 客户留存率 | % | user | 每月 |
113
+
114
+ ## 使用建议
115
+
116
+ 1. 每月固定日期 `record_metric` 记录核心指标
117
+ 2. 发现异常数据时主动 `create_alert` 提醒用户
118
+ 3. 每周查看 `kpi_summary` 了解公司整体状况
119
+ 4. 对 critical 级别告警立即处理,warning 级别限期处理
120
+ 5. 利用 `get_metrics` 对比历史数据,分析趋势