insightcrm 0.1.7 → 0.1.8
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.md +2 -0
- package/SKILL.md +14 -3
- package/dist/cli.js +146 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@ crm schema --json # 字段契约,含每个字段的填写
|
|
|
11
11
|
echo '{"name":"王小明","company":"ACME"}' | crm add - --json
|
|
12
12
|
crm add --name "王小明" --social channels:@wm email:wm@example.com # 视频号 / 小红书 / 邮箱等社交账号
|
|
13
13
|
crm add --name "王小明" --relationship 学员 社群成员 # 他在你这里是什么身份(可多个)
|
|
14
|
+
crm add --name "王小明" --org "同济大学:在职教师:在职" # 他挂着的单位(可多个,机构名:身份:状态)
|
|
14
15
|
crm list --relationship 甲方 --json # 甲方名单
|
|
16
|
+
crm list --org 同济 --json # 挂在某个机构的客户
|
|
15
17
|
crm list --due-today --json
|
|
16
18
|
crm version # 当前版本 + npm 上有没有新版
|
|
17
19
|
crm skill # 打印给 agent 的使用说明;在 agent 指令里加一句「先运行 crm skill」
|
package/SKILL.md
CHANGED
|
@@ -60,6 +60,14 @@ crm login https://<服务器地址>
|
|
|
60
60
|
- 转化了**追加**新关系,别删旧的——学员变甲方,两个都留着,路径才追得回。
|
|
61
61
|
- 没有依据就留空,不要编。命令行写法:`--relationship 学员 甲方`。
|
|
62
62
|
|
|
63
|
+
**单位 `orgs`**:这个人挂着的**所有**机构——公司、学校、协会、平台、实验室。
|
|
64
|
+
- 元素形如 `{"org":"同济大学建筑与城市规划学院","role":"在职教师","status":"current"}`。`role` 是在这个机构里的身份 / 职位(自由文本);`status` 是受控词表。
|
|
65
|
+
- `status` 写中文就行(`在职`、`已离职`、`在读`、`校友`、`创始人`、`顾问`),会自动归一化;**分不清就填 `unknown`,别猜**。
|
|
66
|
+
- **一个人常常同时有多个单位**:高校教师 + 博士在读 + 平台共建;企业服务平台 + 协会任职 + 园区平台发起人。**都要写,履历和现任都写**,别只留现在的。
|
|
67
|
+
- `company` 只写**主单位**(现在最主要的那一个),完整清单放 `orgs`。两者不冲突:`company` 是给人看的摘要,`orgs` 是可筛选的结构化数据。
|
|
68
|
+
- 机构名**照抄材料里的写法**,不要擅自合并全称和简称(「上海开索人工智能科技有限公司」和「开索 AI」是两个写法,别自己并成一个)。按机构筛选用的是包含匹配,简称也能命中。
|
|
69
|
+
- 材料里没出现就整条省略,**不要编造**。命令行写法:`--org "同济大学:在职教师:在职" "浙江理工大学:博士在读:在读"`(机构名:身份:状态,身份可省略)。
|
|
70
|
+
|
|
63
71
|
**日程 `upcomingEvents`**:`{title, date, type}` 的数组,`date` 是 `YYYY-MM-DD`,`type` 是 `meeting` / `follow_up` / `deadline` / `other`。
|
|
64
72
|
- 今天是几号要自己确认,相对日期(「下周三」)按今天换算成具体日期。
|
|
65
73
|
- **已经过去的日期不要录**。
|
|
@@ -100,14 +108,16 @@ crm login https://<服务器地址>
|
|
|
100
108
|
|
|
101
109
|
| 想做的事 | 用 |
|
|
102
110
|
|---|---|
|
|
103
|
-
| 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` |
|
|
104
|
-
| **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship`,或 JSON 里直接传数组 |
|
|
111
|
+
| 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 / 单位 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` / `--add-org` |
|
|
112
|
+
| **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship` / `--org`,或 JSON 里直接传数组 |
|
|
105
113
|
| 清空日程 | `--clear-events` |
|
|
106
114
|
|
|
107
115
|
`upcomingEvents` 在 JSON 里传了就是**整体替换**。只想加一个日程,用 `--add-event 2026-10-25:deadline:报价截止`,不要把一个事件的数组传上去把旧的冲掉。
|
|
108
116
|
|
|
109
117
|
`socials` 同理:传了就是**整体替换**。只想补一个号,用 `--add-social channels:@san三`。
|
|
110
118
|
|
|
119
|
+
`orgs` 也一样:传了就是**整体替换**。只想补一个单位,用 `--add-org "同济大学:在职教师:在职"`。
|
|
120
|
+
|
|
111
121
|
`summary` 是对这个客户的整体描述。合并新材料时,是在原有摘要上补充,不是整段覆盖掉已有的信息:先 `crm get <id> --json` 读出旧内容再写。
|
|
112
122
|
|
|
113
123
|
## 查询
|
|
@@ -116,9 +126,10 @@ crm login https://<服务器地址>
|
|
|
116
126
|
crm list --potential high --city 北京 --json # 按等级、城市、标签筛选
|
|
117
127
|
crm list --due-today --json # 今天有日程的客户(今天要联系谁)
|
|
118
128
|
crm list --due 2026-10-20 --json
|
|
119
|
-
crm list -q 跨境 --json #
|
|
129
|
+
crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、关系、单位、摘要、备注、标签、目标
|
|
120
130
|
crm list --social-platform xiaohongshu --json # 有小红书账号的客户
|
|
121
131
|
crm list --relationship 甲方 --json # 甲方名单(写 client 一样命中)
|
|
132
|
+
crm list --org 同济 --json # 挂在某个机构的客户(包含匹配,简称也能命中)
|
|
122
133
|
crm get <id> --json
|
|
123
134
|
```
|
|
124
135
|
|
package/dist/cli.js
CHANGED
|
@@ -167,6 +167,22 @@ var RELATIONSHIPS = [
|
|
|
167
167
|
"other"
|
|
168
168
|
// 其他
|
|
169
169
|
];
|
|
170
|
+
var ORG_STATUSES = [
|
|
171
|
+
"current",
|
|
172
|
+
// 在职:现在在这里
|
|
173
|
+
"former",
|
|
174
|
+
// 已离职:曾经在这里
|
|
175
|
+
"student",
|
|
176
|
+
// 在读:学生 / 博士生
|
|
177
|
+
"alumni",
|
|
178
|
+
// 校友:已毕业
|
|
179
|
+
"founder",
|
|
180
|
+
// 创始人 / 合伙人
|
|
181
|
+
"advisor",
|
|
182
|
+
// 顾问 / 兼职
|
|
183
|
+
"unknown"
|
|
184
|
+
// 未明示:只知道有这么个机构,关系待确认
|
|
185
|
+
];
|
|
170
186
|
var EXIT = {
|
|
171
187
|
ok: 0,
|
|
172
188
|
error: 1,
|
|
@@ -535,6 +551,78 @@ function relationshipLabel(relationship, lang = "zh") {
|
|
|
535
551
|
return RELATIONSHIP_LABELS[relationship]?.[lang] ?? relationship;
|
|
536
552
|
}
|
|
537
553
|
|
|
554
|
+
// ../shared/src/org.ts
|
|
555
|
+
var ORG_STATUS_ALIASES = {
|
|
556
|
+
// 在职
|
|
557
|
+
current: "current",
|
|
558
|
+
employee: "current",
|
|
559
|
+
\u5728\u804C: "current",
|
|
560
|
+
\u73B0\u4EFB: "current",
|
|
561
|
+
\u4EFB\u804C: "current",
|
|
562
|
+
// 已离职
|
|
563
|
+
former: "former",
|
|
564
|
+
ex: "former",
|
|
565
|
+
past: "former",
|
|
566
|
+
\u5DF2\u79BB\u804C: "former",
|
|
567
|
+
\u79BB\u804C: "former",
|
|
568
|
+
\u524D: "former",
|
|
569
|
+
\u66FE\u4EFB: "former",
|
|
570
|
+
\u5386\u4EFB: "former",
|
|
571
|
+
// 在读
|
|
572
|
+
student: "student",
|
|
573
|
+
\u5728\u8BFB: "student",
|
|
574
|
+
\u5C31\u8BFB: "student",
|
|
575
|
+
\u535A\u58EB\u751F: "student",
|
|
576
|
+
\u7855\u58EB\u751F: "student",
|
|
577
|
+
// 校友
|
|
578
|
+
alumni: "alumni",
|
|
579
|
+
\u6821\u53CB: "alumni",
|
|
580
|
+
\u6BD5\u4E1A: "alumni",
|
|
581
|
+
// 创始人
|
|
582
|
+
founder: "founder",
|
|
583
|
+
cofounder: "founder",
|
|
584
|
+
\u521B\u59CB\u4EBA: "founder",
|
|
585
|
+
\u8054\u5408\u521B\u59CB\u4EBA: "founder",
|
|
586
|
+
\u5408\u4F19\u4EBA: "founder",
|
|
587
|
+
\u53D1\u8D77\u4EBA: "founder",
|
|
588
|
+
// 顾问
|
|
589
|
+
advisor: "advisor",
|
|
590
|
+
consultant: "advisor",
|
|
591
|
+
\u987E\u95EE: "advisor",
|
|
592
|
+
\u517C\u804C: "advisor",
|
|
593
|
+
\u7279\u8058: "advisor",
|
|
594
|
+
// 未明示
|
|
595
|
+
unknown: "unknown",
|
|
596
|
+
\u672A\u660E\u793A: "unknown",
|
|
597
|
+
\u5F85\u786E\u8BA4: "unknown"
|
|
598
|
+
};
|
|
599
|
+
var LOOKUP4 = /* @__PURE__ */ new Map();
|
|
600
|
+
for (const s of ORG_STATUSES) LOOKUP4.set(s.toLowerCase(), s);
|
|
601
|
+
for (const [alias, canonical] of Object.entries(ORG_STATUS_ALIASES)) LOOKUP4.set(alias.toLowerCase(), canonical);
|
|
602
|
+
function normalizeOrgStatus(input2) {
|
|
603
|
+
if (!input2) return "unknown";
|
|
604
|
+
const cleaned = input2.replace(/[ \s]+/g, " ").trim();
|
|
605
|
+
if (!cleaned) return "unknown";
|
|
606
|
+
return LOOKUP4.get(cleaned.toLowerCase()) ?? cleaned;
|
|
607
|
+
}
|
|
608
|
+
var isKnownOrgStatus = (input2) => ORG_STATUSES.includes(normalizeOrgStatus(input2));
|
|
609
|
+
var ORG_STATUS_LABELS = {
|
|
610
|
+
current: { zh: "\u5728\u804C", en: "Current" },
|
|
611
|
+
former: { zh: "\u5DF2\u79BB\u804C", en: "Former" },
|
|
612
|
+
student: { zh: "\u5728\u8BFB", en: "Student" },
|
|
613
|
+
alumni: { zh: "\u6821\u53CB", en: "Alumni" },
|
|
614
|
+
founder: { zh: "\u521B\u59CB\u4EBA", en: "Founder" },
|
|
615
|
+
advisor: { zh: "\u987E\u95EE", en: "Advisor" },
|
|
616
|
+
unknown: { zh: "\u672A\u660E\u793A", en: "Unknown" }
|
|
617
|
+
};
|
|
618
|
+
function orgStatusLabel(status, lang = "zh") {
|
|
619
|
+
return ORG_STATUS_LABELS[status]?.[lang] ?? status;
|
|
620
|
+
}
|
|
621
|
+
function normalizeOrgName(input2) {
|
|
622
|
+
if (!input2) return "";
|
|
623
|
+
return input2.replace(/[ \s]+/g, " ").trim();
|
|
624
|
+
}
|
|
625
|
+
|
|
538
626
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
539
627
|
var external_exports = {};
|
|
540
628
|
__export(external_exports, {
|
|
@@ -20262,6 +20350,11 @@ var socialLink = external_exports.object({
|
|
|
20262
20350
|
handle: external_exports.string().trim().min(1).max(200),
|
|
20263
20351
|
url: external_exports.string().trim().max(2e3).nullable().optional()
|
|
20264
20352
|
});
|
|
20353
|
+
var orgLink = external_exports.object({
|
|
20354
|
+
org: external_exports.string().trim().min(1).max(200).transform(normalizeOrgName),
|
|
20355
|
+
role: external_exports.string().trim().max(200).nullable().optional(),
|
|
20356
|
+
status: external_exports.string().trim().min(1).max(50).transform(normalizeOrgStatus)
|
|
20357
|
+
});
|
|
20265
20358
|
var eventInput = external_exports.object({
|
|
20266
20359
|
title: short(200).min(1),
|
|
20267
20360
|
date: isoDate,
|
|
@@ -20281,6 +20374,8 @@ var customerShape = {
|
|
|
20281
20374
|
socials: external_exports.array(socialLink).max(50),
|
|
20282
20375
|
/** 关系:这个人是谁。可以多个,按重要性从高到低。整体替换 */
|
|
20283
20376
|
relationships: external_exports.array(external_exports.string().trim().min(1).max(50).transform(normalizeRelationship)).max(20),
|
|
20377
|
+
/** 关联的机构:一个人可以挂多个单位。整体替换 */
|
|
20378
|
+
orgs: external_exports.array(orgLink).max(30),
|
|
20284
20379
|
summary: short(5e3),
|
|
20285
20380
|
painPoints: tags,
|
|
20286
20381
|
goals: tags,
|
|
@@ -20334,13 +20429,24 @@ var socialFields = [
|
|
|
20334
20429
|
{ name: "handle", type: "string", required: true, guide: "\u8D26\u53F7\u540D\u6216\u90AE\u7BB1\u5730\u5740\uFF0C\u5982\u300C@san\u4E09\u300D\u300Czhang@example.com\u300D" },
|
|
20335
20430
|
{ name: "url", type: "string", nullable: true, guide: "\u8D26\u53F7\u4E3B\u9875\u94FE\u63A5\u3002\u6750\u6599\u91CC\u6CA1\u6709\u5C31\u7701\u7565\uFF0C\u4E0D\u8981\u731C" }
|
|
20336
20431
|
];
|
|
20432
|
+
var orgFields = [
|
|
20433
|
+
{ name: "org", type: "string", required: true, guide: "\u673A\u6784\u540D\uFF1A\u516C\u53F8\u3001\u5B66\u6821\u3001\u534F\u4F1A\u3001\u5E73\u53F0\u3001\u5B9E\u9A8C\u5BA4\u7B49\uFF0C\u5982\u300C\u540C\u6D4E\u5927\u5B66\u5EFA\u7B51\u4E0E\u57CE\u5E02\u89C4\u5212\u5B66\u9662\u300D\u300C\u4E0A\u6D77\u5E02\u5408\u540C\u4FE1\u7528\u4FC3\u8FDB\u4F1A\u300D" },
|
|
20434
|
+
{ name: "role", type: "string", nullable: true, guide: "\u5728\u8FD9\u4E2A\u673A\u6784\u91CC\u7684\u8EAB\u4EFD\u6216\u804C\u4F4D\uFF0C\u5982\u300C\u5728\u804C\u6559\u5E08\u300D\u300C\u79D8\u4E66\u957F\u300D\u300C\u8054\u5408\u521B\u59CB\u4EBA\u300D\u3002\u6750\u6599\u91CC\u6CA1\u5199\u5C31\u7701\u7565\uFF0C\u4E0D\u8981\u7F16\u9020" },
|
|
20435
|
+
{
|
|
20436
|
+
name: "status",
|
|
20437
|
+
type: "enum",
|
|
20438
|
+
required: true,
|
|
20439
|
+
values: ORG_STATUSES,
|
|
20440
|
+
guide: "\u8DDF\u8FD9\u4E2A\u673A\u6784\u7684\u5173\u7CFB\u72B6\u6001\u3002\u5199\u300C\u5728\u804C\u300D\u300C\u73B0\u4EFB\u300D\u300C\u5DF2\u79BB\u804C\u300D\u300C\u5728\u8BFB\u300D\u300C\u6821\u53CB\u300D\u7B49\u4E2D\u6587\u4F1A\u81EA\u52A8\u5F52\u4E00\u5316\uFF1B\u6E05\u5355\u5916\u7684\u5199\u6CD5\u4E0D\u62A5\u9519\uFF0C\u539F\u6837\u4FDD\u7559\u3002\u5206\u4E0D\u6E05\u5C31\u586B unknown\u3002"
|
|
20441
|
+
}
|
|
20442
|
+
];
|
|
20337
20443
|
var SCHEMA = {
|
|
20338
20444
|
customer: {
|
|
20339
20445
|
description: "\u5BA2\u6237\u6863\u6848\u3002\u521B\u5EFA\u53EA\u9700\u8981 name\uFF0C\u5176\u4F59\u5B57\u6BB5\u80FD\u4ECE\u5BF9\u8BDD\u91CC\u786E\u5B9A\u7684\u90FD\u5E94\u586B\u5199\uFF0C\u6CA1\u6709\u4F9D\u636E\u7684\u4E0D\u8981\u7F16\u9020\u3002",
|
|
20340
20446
|
fields: [
|
|
20341
20447
|
{ name: "name", type: "string", required: true, guide: "\u5BA2\u6237\u59D3\u540D\u3002\u5BF9\u8BDD\u91CC\u51FA\u73B0\u7684\u79F0\u547C\u3001\u6635\u79F0\u82E5\u65E0\u6CD5\u786E\u5B9A\u771F\u540D\uFF0C\u5199\u5BF9\u65B9\u4F7F\u7528\u7684\u540D\u5B57" },
|
|
20342
|
-
{ name: "company", type: "string", guide: "\
|
|
20343
|
-
{ name: "title", type: "string", guide: "\u804C\u4F4D\u6216\u8EAB\u4EFD" },
|
|
20448
|
+
{ name: "company", type: "string", guide: "\u4E3B\u5355\u4F4D\uFF1A\u4ED6\u73B0\u5728\u6700\u4E3B\u8981\u7684\u90A3\u4E2A\u673A\u6784\u7B80\u79F0\uFF0C\u5982\u300C\u5F00\u7D22 AI\u300D\u300C\u4E0A\u6D77\u7D22\u95FC\u79D1\u6280\u300D\u3002\u5B8C\u6574\u7684\u673A\u6784\u6E05\u5355\u5199\u8FDB orgs" },
|
|
20449
|
+
{ name: "title", type: "string", guide: "\u804C\u4F4D\u6216\u8EAB\u4EFD\u3002\u4E3B\u5355\u4F4D\u91CC\u7684\u804C\u4F4D\uFF0C\u5982\u300C\u521B\u59CB\u4EBA\u517C CEO\u300D\u3002\u591A\u4E2A\u8EAB\u4EFD\u5199\u8FDB orgs \u7684 role" },
|
|
20344
20450
|
{ name: "city", type: "enum", values: CITIES, guide: "\u6240\u5728\u57CE\u5E02\u3002\u4F18\u5148\u53D6\u4E0B\u9762\u6E05\u5355\u91CC\u7684\u503C\uFF1B\u5199\u300C\u4E0A\u6D77\u5E02\u300D\u300CShanghai\u300D\u300C\u81FA\u5317\u300D\u4F1A\u81EA\u52A8\u5F52\u4E00\u5316\u6210\u300C\u4E0A\u6D77\u300D\u300C\u4E0A\u6D77\u300D\u300C\u53F0\u5317\u300D\u3002\u6E05\u5355\u5916\u7684\u5199\u6CD5\u4E0D\u4F1A\u62A5\u9519\uFF0C\u539F\u6837\u4FDD\u7559\uFF0C\u4E8B\u540E\u53EF\u5F52\u7C7B\u3002" },
|
|
20345
20451
|
{ name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199" },
|
|
20346
20452
|
{
|
|
@@ -20355,6 +20461,12 @@ var SCHEMA = {
|
|
|
20355
20461
|
values: RELATIONSHIPS,
|
|
20356
20462
|
guide: "\u8FD9\u4E2A\u4EBA\u5728\u6211\u8FD9\u91CC\u662F\u4EC0\u4E48\u8EAB\u4EFD\uFF1A\u7532\u65B9 / \u6E20\u9053\u65B9 / \u5B66\u5458 / \u793E\u7FA4\u6210\u5458\u2026\u53EF\u4EE5\u540C\u65F6\u591A\u4E2A\uFF0C\u6309\u91CD\u8981\u6027\u4ECE\u9AD8\u5230\u4F4E\uFF08\u7B2C\u4E00\u4E2A\u662F\u5F53\u524D\u6700\u4E3B\u8981\u7684\u5173\u7CFB\uFF09\u3002\u5199\u4E2D\u6587\u4F1A\u81EA\u52A8\u5F52\u4E00\u5316\uFF08\u300C\u7532\u65B9\u300D\u300C\u5BA2\u6237\u65B9\u300D\u300C\u5B66\u5458\u300D\u300C\u6E20\u9053\u65B9\u300D\uFF09\u3002\u5E38\u89C1\u8DEF\u5F84\uFF1A\u6F5C\u5BA2 \u2192 \u610F\u5411\u5B66\u5458 \u2192 \u5B66\u5458 \u2192 \u6821\u53CB \u2192 \u610F\u5411\u7532\u65B9 \u2192 \u7532\u65B9\u3002\u5FAE\u4FE1\u6807\u7B7E\u91CC\u5199\u660E\u7684\u8EAB\u4EFD\u6700\u786C\uFF08\u5982\u300CAI\u7F16\u7A0B N23 \u671F\u5B66\u5458\u300D\u5C31\u662F\u5B66\u5458\uFF09\u3002\u6CA1\u6709\u4F9D\u636E\u5C31\u7559\u7A7A\uFF0C\u4E0D\u8981\u7F16\u3002\u66F4\u65B0\u65F6\u4F20\u5165\u5B8C\u6574\u5217\u8868\u4F1A\u6574\u4F53\u66FF\u6362\u65E7\u5217\u8868\u3002"
|
|
20357
20463
|
},
|
|
20464
|
+
{
|
|
20465
|
+
name: "orgs",
|
|
20466
|
+
type: "object[]",
|
|
20467
|
+
fields: orgFields,
|
|
20468
|
+
guide: "\u5173\u8054\u7684\u673A\u6784\uFF1A\u8FD9\u4E2A\u4EBA\u6302\u7740\u7684\u6240\u6709\u5355\u4F4D\u3002\u4E00\u4E2A\u4EBA\u5E38\u5E38\u540C\u65F6\u6709\u591A\u4E2A\uFF08\u9AD8\u6821\u6559\u5E08 + \u535A\u58EB\u5728\u8BFB + \u5E73\u53F0\u5171\u5EFA\uFF1B\u4F01\u4E1A\u670D\u52A1\u5E73\u53F0 + \u534F\u4F1A\u4EFB\u804C + \u56ED\u533A\u5E73\u53F0\u53D1\u8D77\u4EBA\uFF09\uFF0C\u90FD\u5199\u8FDB\u6765\u3002\u5143\u7D20\u5F62\u5982 {org:'\u540C\u6D4E\u5927\u5B66\u5EFA\u7B51\u4E0E\u57CE\u5E02\u89C4\u5212\u5B66\u9662', role:'\u5728\u804C\u6559\u5E08', status:'current'}\u3002status \u533A\u5206\u73B0\u5728\u8FD8\u662F\u8FC7\u53BB\uFF08\u5728\u804C / \u5DF2\u79BB\u804C / \u5728\u8BFB / \u6821\u53CB / \u521B\u59CB\u4EBA / \u987E\u95EE / \u672A\u660E\u793A\uFF09\uFF0C\u5C65\u5386\u4E0E\u73B0\u4EFB\u90FD\u5199\uFF0C\u522B\u53EA\u7559\u73B0\u5728\u7684\u3002\u6CA1\u6709\u4F9D\u636E\u5C31\u7701\u7565\uFF0C\u4E0D\u8981\u7F16\u9020\u3002\u66F4\u65B0\u65F6\u4F20\u5165\u5B8C\u6574\u5217\u8868\u4F1A\u6574\u4F53\u66FF\u6362\u65E7\u5217\u8868\uFF1B\u4E0D\u4F20\u5219\u4E0D\u52A8\u3002"
|
|
20469
|
+
},
|
|
20358
20470
|
{ name: "summary", type: "string", guide: "\u4E00\u6BB5\u8BDD\u6982\u62EC\u8FD9\u4E2A\u5BA2\u6237\u662F\u8C01\u3001\u5F53\u524D\u5904\u4E8E\u4EC0\u4E48\u9636\u6BB5" },
|
|
20359
20471
|
{ name: "painPoints", type: "string[]", guide: "\u75DB\u70B9\u6807\u7B7E\uFF0C\u6BCF\u6761\u7B80\u77ED\uFF08\u51E0\u4E2A\u5B57\u5230\u4E00\u53E5\u8BDD\uFF09\u3002\u540C\u4E00\u4E2A\u75DB\u70B9\u590D\u7528\u5DF2\u6709\u6807\u7B7E\u7684\u5199\u6CD5\uFF0C\u4FBF\u4E8E\u6309\u6807\u7B7E\u805A\u5408" },
|
|
20360
20472
|
{ name: "goals", type: "string[]", guide: "\u77ED\u671F\u76EE\u6807\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD" },
|
|
@@ -20448,7 +20560,7 @@ function renderPrompt(text, customer) {
|
|
|
20448
20560
|
// package.json
|
|
20449
20561
|
var package_default = {
|
|
20450
20562
|
name: "insightcrm",
|
|
20451
|
-
version: "0.1.
|
|
20563
|
+
version: "0.1.8",
|
|
20452
20564
|
description: "Command line and agent skill for InsightCRM: file customers from chats and screenshots with your own AI agent. Non-interactive, --json output, stable exit codes.",
|
|
20453
20565
|
license: "MIT",
|
|
20454
20566
|
type: "module",
|
|
@@ -20560,6 +20672,22 @@ function createClient(apiUrl, token) {
|
|
|
20560
20672
|
};
|
|
20561
20673
|
}
|
|
20562
20674
|
|
|
20675
|
+
// src/org.ts
|
|
20676
|
+
function parseOrg(s) {
|
|
20677
|
+
const parts = s.split(":").map((p) => p.trim());
|
|
20678
|
+
const org = parts[0] ?? "";
|
|
20679
|
+
if (!org) throw new CliError("usage", `Can't read organization "${s}". Use name[:role[:status]], e.g. \u540C\u6D4E\u5927\u5B66:\u5728\u804C\u6559\u5E08:\u5728\u804C`, EXIT.usage);
|
|
20680
|
+
if (parts.length === 1) return { org, status: "unknown" };
|
|
20681
|
+
if (parts.length === 2) {
|
|
20682
|
+
const second = parts[1];
|
|
20683
|
+
return isKnownOrgStatus(second) ? { org, status: second } : { org, role: second, status: "unknown" };
|
|
20684
|
+
}
|
|
20685
|
+
const role = parts.slice(1, -1).join(":");
|
|
20686
|
+
const status = parts[parts.length - 1];
|
|
20687
|
+
return { org, ...role ? { role } : {}, status };
|
|
20688
|
+
}
|
|
20689
|
+
var orgKey = (o) => JSON.stringify([o.org, o.status]);
|
|
20690
|
+
|
|
20563
20691
|
// src/prompts.ts
|
|
20564
20692
|
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
20565
20693
|
import path2 from "path";
|
|
@@ -20725,7 +20853,9 @@ Examples:
|
|
|
20725
20853
|
$ echo '{"name":"Wang Ming","company":"ACME","conversionPotential":"High"}' | crm add - --json
|
|
20726
20854
|
$ crm add --name "\u738B\u5C0F\u660E" --social channels:@san3 email:wang@example.com --json
|
|
20727
20855
|
$ crm add --name "\u738B\u5C0F\u660E" --relationship \u5B66\u5458 --relationship \u793E\u7FA4\u6210\u5458 --json
|
|
20856
|
+
$ crm add --name "\u738B\u5C0F\u660E" --org "\u540C\u6D4E\u5927\u5B66:\u5728\u804C\u6559\u5E08:\u5728\u804C" "\u6D59\u6C5F\u7406\u5DE5\u5927\u5B66:\u535A\u58EB\u5728\u8BFB:\u5728\u8BFB" --json
|
|
20728
20857
|
$ crm list --potential high --city Beijing --due-today --json
|
|
20858
|
+
$ crm list --org \u540C\u6D4E --json
|
|
20729
20859
|
$ crm update 3f2a\u2026 --summary "Needs a quote by Friday" --json
|
|
20730
20860
|
$ crm hook add --title "Opened with a peer case" --desc "Led with a competitor's result, then asked about theirs" --customer 3f2a\u2026
|
|
20731
20861
|
$ crm export -o backup.json`
|
|
@@ -20803,9 +20933,9 @@ function parseSocial(s) {
|
|
|
20803
20933
|
return { platform: platform2, handle };
|
|
20804
20934
|
}
|
|
20805
20935
|
function withCustomerOptions(cmd, forUpdate) {
|
|
20806
|
-
cmd.option("--name <s>", "name").option("--company <s>").option("--title <s>", "job title").option("--city <s>").option("--wechat <s>", "WeChat id").option("--summary <s>").option("--current-action <s>").option("--notes <s>").option("--potential <High|Medium|Low>").option("--cycle-days <n>", "predicted conversion window in days").option("--pain <a,b,c>", `pain-point tags, comma separated${forUpdate ? " (replaces the whole list)" : ""}`).option("--goal <s...>", `goals${forUpdate ? " (replaces the whole list)" : ""}`).option("--event <date:type:title...>", `calendar events${forUpdate ? " (replaces the whole calendar; see --add-event)" : ""}`).option("--social <platform:handle...>", `social accounts, e.g. channels:@san xiaohongshu:san${forUpdate ? " (replaces the whole list; see --add-social)" : ""}`).option("--relationship <r...>", `relationship to the user, e.g. \u5B66\u5458 \u7532\u65B9${forUpdate ? " (replaces the whole list; see --add-relationship)" : ""}`);
|
|
20936
|
+
cmd.option("--name <s>", "name").option("--company <s>").option("--title <s>", "job title").option("--city <s>").option("--wechat <s>", "WeChat id").option("--summary <s>").option("--current-action <s>").option("--notes <s>").option("--potential <High|Medium|Low>").option("--cycle-days <n>", "predicted conversion window in days").option("--pain <a,b,c>", `pain-point tags, comma separated${forUpdate ? " (replaces the whole list)" : ""}`).option("--goal <s...>", `goals${forUpdate ? " (replaces the whole list)" : ""}`).option("--event <date:type:title...>", `calendar events${forUpdate ? " (replaces the whole calendar; see --add-event)" : ""}`).option("--social <platform:handle...>", `social accounts, e.g. channels:@san xiaohongshu:san${forUpdate ? " (replaces the whole list; see --add-social)" : ""}`).option("--relationship <r...>", `relationship to the user, e.g. \u5B66\u5458 \u7532\u65B9${forUpdate ? " (replaces the whole list; see --add-relationship)" : ""}`).option("--org <name:role:status...>", `organizations, e.g. \u540C\u6D4E\u5927\u5B66:\u5728\u804C\u6559\u5E08:\u5728\u804C\uFF08\u673A\u6784\u540D:\u8EAB\u4EFD:\u72B6\u6001\uFF0C\u8EAB\u4EFD\u53EF\u7701\u7565\uFF09${forUpdate ? " (replaces the whole list; see --add-org)" : ""}`);
|
|
20807
20937
|
if (forUpdate) {
|
|
20808
|
-
cmd.option("--add-pain <s...>", "append pain-point tags, keeping existing ones").option("--add-goal <s...>", "append goals, keeping existing ones").option("--add-event <date:type:title...>", "append calendar events, keeping existing ones").option("--add-social <platform:handle...>", "append social accounts, keeping existing ones").option("--add-relationship <r...>", "append relationships, keeping existing ones").option("--clear-events", "remove all calendar events");
|
|
20938
|
+
cmd.option("--add-pain <s...>", "append pain-point tags, keeping existing ones").option("--add-goal <s...>", "append goals, keeping existing ones").option("--add-event <date:type:title...>", "append calendar events, keeping existing ones").option("--add-social <platform:handle...>", "append social accounts, keeping existing ones").option("--add-relationship <r...>", "append relationships, keeping existing ones").option("--add-org <name:role:status...>", "append organizations, keeping existing ones (\u673A\u6784\u540D:\u8EAB\u4EFD:\u72B6\u6001)").option("--clear-events", "remove all calendar events");
|
|
20809
20939
|
} else {
|
|
20810
20940
|
cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
|
|
20811
20941
|
}
|
|
@@ -20836,6 +20966,7 @@ function buildCustomerBody(base, o) {
|
|
|
20836
20966
|
if (o.clearEvents) body.upcomingEvents = [];
|
|
20837
20967
|
if (o.social) body.socials = o.social.map(parseSocial);
|
|
20838
20968
|
if (o.relationship) body.relationships = o.relationship;
|
|
20969
|
+
if (o.org) body.orgs = o.org.map(parseOrg);
|
|
20839
20970
|
if (o.hookTitle || o.hookDesc) {
|
|
20840
20971
|
if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
|
|
20841
20972
|
body.socialHook = { title: o.hookTitle, description: o.hookDesc };
|
|
@@ -20853,6 +20984,7 @@ function detail(c) {
|
|
|
20853
20984
|
["wechat", c.wechatId ?? ""],
|
|
20854
20985
|
["socials", c.socials.map((s) => `${s.platform}: ${s.handle}${s.url ? ` (${s.url})` : ""}`).join("; ")],
|
|
20855
20986
|
["relationship", c.relationships.map((r) => relationshipLabel(r, "zh")).join(", ")],
|
|
20987
|
+
["orgs", (c.orgs ?? []).map((o) => `${o.org}${o.role ? ` \xB7 ${o.role}` : ""} [${orgStatusLabel(o.status, "zh")}]`).join("; ")],
|
|
20856
20988
|
["potential", c.conversionPotential],
|
|
20857
20989
|
["cycle days", String(c.conversionCycleDays)],
|
|
20858
20990
|
["pain points", c.painPoints.join(", ")],
|
|
@@ -20997,12 +21129,12 @@ withCustomerOptions(
|
|
|
20997
21129
|
out(`Created ${line(customer)}`, { customer, created: true });
|
|
20998
21130
|
});
|
|
20999
21131
|
withCustomerOptions(
|
|
21000
|
-
program.command("update").description("Change a customer. Only the fields you pass change. --pain / --goal / --event / --social / --relationship REPLACE the list; --add-pain / --add-goal / --add-event / --add-social / --add-relationship append.").argument("<id>").argument("[json-file]", "JSON file, or - for stdin"),
|
|
21132
|
+
program.command("update").description("Change a customer. Only the fields you pass change. --pain / --goal / --event / --social / --relationship / --org REPLACE the list; --add-pain / --add-goal / --add-event / --add-social / --add-relationship / --add-org append.").argument("<id>").argument("[json-file]", "JSON file, or - for stdin"),
|
|
21001
21133
|
true
|
|
21002
21134
|
).action(async (id, src, o) => {
|
|
21003
21135
|
const api = await client();
|
|
21004
21136
|
const body = buildCustomerBody(await readJsonInput(src), o);
|
|
21005
|
-
if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship) {
|
|
21137
|
+
if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship || o.addOrg) {
|
|
21006
21138
|
const { customer: cur } = await api.getCustomer(id);
|
|
21007
21139
|
if (o.addPain) body.painPoints = [.../* @__PURE__ */ new Set([...body.painPoints ?? cur.painPoints, ...o.addPain])];
|
|
21008
21140
|
if (o.addGoal) body.goals = [.../* @__PURE__ */ new Set([...body.goals ?? cur.goals, ...o.addGoal])];
|
|
@@ -21017,6 +21149,11 @@ withCustomerOptions(
|
|
|
21017
21149
|
const existing = body.relationships ?? cur.relationships;
|
|
21018
21150
|
body.relationships = [...existing, ...o.addRelationship.filter((r) => !existing.includes(r))];
|
|
21019
21151
|
}
|
|
21152
|
+
if (o.addOrg) {
|
|
21153
|
+
const added = o.addOrg.map(parseOrg);
|
|
21154
|
+
const existing = body.orgs ?? cur.orgs;
|
|
21155
|
+
body.orgs = [...existing, ...added.filter((x) => !existing.some((e) => orgKey(e) === orgKey(x)))];
|
|
21156
|
+
}
|
|
21020
21157
|
}
|
|
21021
21158
|
if (!Object.keys(body).length) throw new CliError("usage", "Nothing to change. Pass a JSON input or flags like --summary, --potential, --add-pain", EXIT.usage);
|
|
21022
21159
|
const { customer } = await api.updateCustomer(id, body);
|
|
@@ -21026,7 +21163,7 @@ program.command("get").description("Show one customer").argument("<id>").action(
|
|
|
21026
21163
|
const { customer } = await (await client()).getCustomer(id);
|
|
21027
21164
|
out(detail(customer), { customer });
|
|
21028
21165
|
});
|
|
21029
|
-
program.command("list").description("List customers (newest update first), optionally filtered").option("--potential <High|Medium|Low>").option("--city <s>", "exact city (case-insensitive)").option("--tag <s>", "has this pain-point tag").option("--social-platform <s>", "has a social account on this platform (e.g. xiaohongshu, channels, email)").option("--relationship <s>", "has this relationship to the user (e.g. \u7532\u65B9 / client, \u5B66\u5458 / student, \u6E20\u9053\u65B9 / channel)").option("--due-today", "has a calendar event today (your local date)").option("--due <YYYY-MM-DD>", "has a calendar event on this date").option("-q, --query <s>", "keyword across name, company, title, city, wechat, social accounts, relationships, summary, notes, tags, goals").action(async (o) => {
|
|
21166
|
+
program.command("list").description("List customers (newest update first), optionally filtered").option("--potential <High|Medium|Low>").option("--city <s>", "exact city (case-insensitive)").option("--tag <s>", "has this pain-point tag").option("--social-platform <s>", "has a social account on this platform (e.g. xiaohongshu, channels, email)").option("--relationship <s>", "has this relationship to the user (e.g. \u7532\u65B9 / client, \u5B66\u5458 / student, \u6E20\u9053\u65B9 / channel)").option("--org <s>", "is affiliated with this organization (substring match, e.g. \u540C\u6D4E / \u535A\u4E16)").option("--due-today", "has a calendar event today (your local date)").option("--due <YYYY-MM-DD>", "has a calendar event on this date").option("-q, --query <s>", "keyword across name, company, title, city, wechat, social accounts, relationships, organizations, summary, notes, tags, goals").action(async (o) => {
|
|
21030
21167
|
const { customers } = await (await client()).listCustomers({
|
|
21031
21168
|
potential: o.potential ? potentialOf(o.potential) : void 0,
|
|
21032
21169
|
city: o.city,
|
|
@@ -21034,6 +21171,7 @@ program.command("list").description("List customers (newest update first), optio
|
|
|
21034
21171
|
q: o.query,
|
|
21035
21172
|
socialPlatform: o.socialPlatform,
|
|
21036
21173
|
relationship: o.relationship,
|
|
21174
|
+
org: o.org,
|
|
21037
21175
|
dueOn: o.dueToday ? today() : o.due
|
|
21038
21176
|
});
|
|
21039
21177
|
out(customers.length ? customers.map(line).join("\n") : "No customers match.", { customers, count: customers.length });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightcrm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Command line and agent skill for InsightCRM: file customers from chats and screenshots with your own AI agent. Non-interactive, --json output, stable exit codes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|