insightcrm 0.1.8 → 0.1.10
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 +1 -0
- package/SKILL.md +48 -5
- package/dist/cli.js +249 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ crm login https://<你的服务器> # 浏览器里点「允许」(设备
|
|
|
10
10
|
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
|
+
crm add --name "王小明" --wechat wm2024 --social wechat:小明 # 微信号用 --wechat,微信昵称用 wechat 平台;name 只写姓名本身
|
|
13
14
|
crm add --name "王小明" --relationship 学员 社群成员 # 他在你这里是什么身份(可多个)
|
|
14
15
|
crm add --name "王小明" --org "同济大学:在职教师:在职" # 他挂着的单位(可多个,机构名:身份:状态)
|
|
15
16
|
crm list --relationship 甲方 --json # 甲方名单
|
package/SKILL.md
CHANGED
|
@@ -37,6 +37,9 @@ crm login https://<服务器地址>
|
|
|
37
37
|
## 怎么从材料里抽取
|
|
38
38
|
|
|
39
39
|
**身份与联系**:`name`、`company`、`title`;`wechatId`、`city`。只填材料里明确出现的。看不到就省略,不要猜。
|
|
40
|
+
- **`name` 只写姓名本身**(含常用英文名,如「李源枫 Philip F. Yuan」),不超过 40 字,**不要带括号注释**。「白微微(微信名…,昵称…,微信号…)」这种写法会被服务端拒绝。
|
|
41
|
+
- 微信号(登录用的 ID)写 `wechatId`;微信昵称 / 显示名 / 群昵称写进 `socials`(`platform` 用 `wechat`,见下);职务、城市写各自字段;「真名未知」「shadow 备注」之类的说明写进 `notes`。
|
|
42
|
+
- 无法确定真名时,`name` 写对方使用的称呼,并在 `notes` 里注明真名未知。
|
|
40
43
|
`city` 取 `crm schema --json` 里 `city` 字段的 `values`(城市枚举);写成「上海市」「Shanghai」「臺北」也会被自动归一化成「上海」「上海」「台北」,所以直接按你看到的写就行。
|
|
41
44
|
|
|
42
45
|
**画像**:
|
|
@@ -48,7 +51,7 @@ crm login https://<服务器地址>
|
|
|
48
51
|
|
|
49
52
|
**社交账号 `socials`**:客户在其他平台上的号——视频号、小红书、邮箱、抖音、B站、公众号等。
|
|
50
53
|
- 元素形如 `{"platform":"channels","handle":"@san三"}`。`platform` 直接写中文也行(`视频号`、`小红书`、`邮箱`),会自动归一化到标准值。
|
|
51
|
-
-
|
|
54
|
+
- **微信昵称 / 显示名**用 `platform: "wechat"`,如 `{"platform":"wechat","handle":"白生"}`(`微信昵称` 也会归一化)。**微信号(ID)不放这里**,统一写 `wechatId`。
|
|
52
55
|
- 有主页链接就补 `"url"`,没有就省略,不要猜。
|
|
53
56
|
- 材料里没出现就整条省略,**不要编造**。邮箱也是:只在材料里明确写了邮箱才填。
|
|
54
57
|
- 命令行写法:`--social channels:@san三 email:zhang@example.com`(平台:账号)。
|
|
@@ -68,6 +71,16 @@ crm login https://<服务器地址>
|
|
|
68
71
|
- 机构名**照抄材料里的写法**,不要擅自合并全称和简称(「上海开索人工智能科技有限公司」和「开索 AI」是两个写法,别自己并成一个)。按机构筛选用的是包含匹配,简称也能命中。
|
|
69
72
|
- 材料里没出现就整条省略,**不要编造**。命令行写法:`--org "同济大学:在职教师:在职" "浙江理工大学:博士在读:在读"`(机构名:身份:状态,身份可省略)。
|
|
70
73
|
|
|
74
|
+
**相关人物 `relatedPeople`**:这个人牵连到的**其他人**——人与人之间的关系。
|
|
75
|
+
- 元素形如 `{"name":"李雅婷","relation":"转介绍人","note":"07-15 发了她的名片说「这位同事推荐的」"}`。`name` 必填;`id` 和 `note` 选填。
|
|
76
|
+
- **跟 `relationships` 不是一回事**:`relationships` 是「这个人在我这里是什么身份」(对我),`relatedPeople` 是「人与人之间」(对内)。别把两者混着填。
|
|
77
|
+
- `relation` 是**自由文本**,不是受控词表。推荐写法:转介绍人 / 被转介绍人 / 对接协调方 / 拍板决策人 / 同场协作 / 同场竞争 / 同事 / 同学 / 导师 / 师傅 / 联合创始人 / 团队成员 / 投资人 / 介绍人。材料里没有的关系**不要编**。
|
|
78
|
+
- `id` 可以省略:省略后服务端会按**同一用户名下唯一同名**自动补上。**库外的人**(导师、师傅、联合创始人、团队成员……)只留名字就行,照样要记。
|
|
79
|
+
- **名字要照抄材料里的写法**,不要合并全名和简称。同名多人时服务端宁可不补 id,也不要指错人——所以靠 id 或全名才可靠,靠字符串匹配会误命中(库里有「谢」和另一个叫「谢扬」的人)。
|
|
80
|
+
- **按人筛是包含匹配**:`crm list --related 谢` 会把「老谢」「谢扬」这些不同的人一起带出来。要精确指某一个人,用全名或看档案里的 `relatedPeople.id`。
|
|
81
|
+
- **典型要记的场景**:谁把谁介绍来的、谁在中间做推进、谁跟谁一起做过事、谁跟谁在抢同一批名额。
|
|
82
|
+
- 材料里没出现就整条省略,**不要编造**。命令行写法:`--related "李雅婷:转介绍人" "柴老师:导师"`(姓名:关系,关系必填,说明可省略)。
|
|
83
|
+
|
|
71
84
|
**日程 `upcomingEvents`**:`{title, date, type}` 的数组,`date` 是 `YYYY-MM-DD`,`type` 是 `meeting` / `follow_up` / `deadline` / `other`。
|
|
72
85
|
- 今天是几号要自己确认,相对日期(「下周三」)按今天换算成具体日期。
|
|
73
86
|
- **已经过去的日期不要录**。
|
|
@@ -101,6 +114,8 @@ crm login https://<服务器地址>
|
|
|
101
114
|
- 写 `description` 时让别的客户场景也能照着用:写清楚话术本身和有效的原因,不要只写「聊得很好」。
|
|
102
115
|
- **找不到就别编。** 没有明确的「这句话奏效了」的证据,就不要创建钩子。宁可没有,不要一条虚构的。
|
|
103
116
|
- 想给新对话找灵感时:`crm hook list --json`。
|
|
117
|
+
- 钩子是独立库、按 `customerId` 关联的:`crm get <id>` 会把这个客户已有的钩子一起列出来(`--json` 时在 `hooks` 字段里)。
|
|
118
|
+
看到某个客户已经有钩子,就别重复建;看到没有、而这次对话里确实有一句话奏效了,就补一条。
|
|
104
119
|
|
|
105
120
|
## 更新已有客户
|
|
106
121
|
|
|
@@ -108,8 +123,8 @@ crm login https://<服务器地址>
|
|
|
108
123
|
|
|
109
124
|
| 想做的事 | 用 |
|
|
110
125
|
|---|---|
|
|
111
|
-
| 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 / 单位 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` / `--add-org` |
|
|
112
|
-
| **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship` / `--org`,或 JSON 里直接传数组 |
|
|
126
|
+
| 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 / 单位 / 相关人物 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` / `--add-org` / `--add-related` |
|
|
127
|
+
| **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship` / `--org` / `--related`,或 JSON 里直接传数组 |
|
|
113
128
|
| 清空日程 | `--clear-events` |
|
|
114
129
|
|
|
115
130
|
`upcomingEvents` 在 JSON 里传了就是**整体替换**。只想加一个日程,用 `--add-event 2026-10-25:deadline:报价截止`,不要把一个事件的数组传上去把旧的冲掉。
|
|
@@ -118,6 +133,8 @@ crm login https://<服务器地址>
|
|
|
118
133
|
|
|
119
134
|
`orgs` 也一样:传了就是**整体替换**。只想补一个单位,用 `--add-org "同济大学:在职教师:在职"`。
|
|
120
135
|
|
|
136
|
+
`relatedPeople` 也一样:传了就是**整体替换**。只想补一个人,用 `--add-related "李雅婷:转介绍人"`。
|
|
137
|
+
|
|
121
138
|
`summary` 是对这个客户的整体描述。合并新材料时,是在原有摘要上补充,不是整段覆盖掉已有的信息:先 `crm get <id> --json` 读出旧内容再写。
|
|
122
139
|
|
|
123
140
|
## 查询
|
|
@@ -126,13 +143,39 @@ crm login https://<服务器地址>
|
|
|
126
143
|
crm list --potential high --city 北京 --json # 按等级、城市、标签筛选
|
|
127
144
|
crm list --due-today --json # 今天有日程的客户(今天要联系谁)
|
|
128
145
|
crm list --due 2026-10-20 --json
|
|
129
|
-
crm list
|
|
146
|
+
crm list --expired --json # 有过期日程的客户(日期早于今天,默认就是今天)
|
|
147
|
+
crm list --expired 2026-10-01 --json # 更早的截止日
|
|
148
|
+
crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、关系、单位、相关人物、摘要、备注、标签、目标
|
|
130
149
|
crm list --social-platform xiaohongshu --json # 有小红书账号的客户
|
|
131
150
|
crm list --relationship 甲方 --json # 甲方名单(写 client 一样命中)
|
|
132
|
-
crm list --org 同济 --json #
|
|
151
|
+
crm list --org 同济 --json # 挂在某个机构的客户(包含匹配,简称也能命中;company 和 orgs 都查)
|
|
152
|
+
crm list --related 李雅婷 --json # 和李雅婷有关系的人(含「被指向」的反向关联)
|
|
133
153
|
crm get <id> --json
|
|
134
154
|
```
|
|
135
155
|
|
|
156
|
+
## 体检(`crm lint`)
|
|
157
|
+
|
|
158
|
+
写入路径对拿不准的值是**刻意宽松**的:认不出来的 `orgs.status`、清单外的城市、过期日期都原样保留、不报错,
|
|
159
|
+
这是批量归档时想要的(一条写歪的记录不该打断整批)。代价是脏数据会悄悄攒起来。`crm lint` 就是那个能看见它们的入口。
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
crm lint --json # 全库体检:只报告,不改数据
|
|
163
|
+
crm lint --severity error --json # 只看会造成实际问题的(notes 超上限、状态越界、过期日程、悬空引用)
|
|
164
|
+
crm lint --kind company-prose --json # 只看某一类
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
报告的类别:`notes-over-limit`(会被服务端拒)、`notes-long`、`unknown-status`(状态不在受控词表里,按状态聚合会漏)、
|
|
168
|
+
`expired-event`(过期日程)、`dangling-related-id`(相关人物指向库里没有的人)、`duplicate-wechat`、
|
|
169
|
+
`company-prose`(company 写成了说明文而不是简称)、`company-without-orgs`、`orgs-without-company`、
|
|
170
|
+
`no-relationship`(不知道这个人是谁)、`city-off-list`、`half-width-punctuation`。
|
|
171
|
+
|
|
172
|
+
**lint 只报告,不改。** 要改就照着报告里的 id 逐条 `crm update`。
|
|
173
|
+
注意:`crm update` 会把 `last_updated` 顶到当前时间,把这条档案顶到列表最前面——
|
|
174
|
+
**批量清洗存量请走 `db:backfill-*` 脚本**(保留 `last_updated`、写审计日志),别用 update 循环。
|
|
175
|
+
|
|
176
|
+
写入时 CLI 会把拿不准的地方打到 stderr 当提醒(未知的 `orgs.status`、清单外的城市、过期的日程、写成说明文的 company)。
|
|
177
|
+
**这些是提醒不是错误**,写入照常成功——除非 `notes` 超过 10000 字符,那种会被服务端整条拒掉,所以 CLI 提前拦了一道。
|
|
178
|
+
|
|
136
179
|
## 推荐库(是用户的库存,不是聊天里挖出来的东西)
|
|
137
180
|
|
|
138
181
|
推荐库是**用户自己的待推荐库存**:他要推给客户的产品、服务、文章、活动。内容只来自用户本人。
|
package/dist/cli.js
CHANGED
|
@@ -116,6 +116,8 @@ var CITIES = [
|
|
|
116
116
|
var SOCIAL_PLATFORMS = [
|
|
117
117
|
"email",
|
|
118
118
|
// 邮箱
|
|
119
|
+
"wechat",
|
|
120
|
+
// 微信昵称 / 显示名(微信号写 wechatId,不放这里)
|
|
119
121
|
"channels",
|
|
120
122
|
// 视频号
|
|
121
123
|
"xiaohongshu",
|
|
@@ -347,6 +349,7 @@ function normalizeCity(input2) {
|
|
|
347
349
|
}
|
|
348
350
|
return cleaned;
|
|
349
351
|
}
|
|
352
|
+
var isKnownCity = (input2) => CITIES.includes(normalizeCity(input2));
|
|
350
353
|
|
|
351
354
|
// ../shared/src/social.ts
|
|
352
355
|
var SOCIAL_PLATFORM_ALIASES = {
|
|
@@ -357,6 +360,12 @@ var SOCIAL_PLATFORM_ALIASES = {
|
|
|
357
360
|
\u90AE\u7BB1: "email",
|
|
358
361
|
\u90AE\u4EF6: "email",
|
|
359
362
|
\u7535\u5B50\u90AE\u4EF6: "email",
|
|
363
|
+
// 微信昵称(微信号是 wechatId,不是这里)
|
|
364
|
+
wechat: "wechat",
|
|
365
|
+
\u5FAE\u4FE1: "wechat",
|
|
366
|
+
\u5FAE\u4FE1\u6635\u79F0: "wechat",
|
|
367
|
+
\u5FAE\u4FE1\u540D: "wechat",
|
|
368
|
+
\u5FAE\u4FE1\u663E\u793A\u540D: "wechat",
|
|
360
369
|
// 视频号
|
|
361
370
|
channels: "channels",
|
|
362
371
|
wechat_channels: "channels",
|
|
@@ -418,6 +427,7 @@ function normalizeSocialPlatform(input2) {
|
|
|
418
427
|
}
|
|
419
428
|
var SOCIAL_PLATFORM_LABELS = {
|
|
420
429
|
email: { zh: "\u90AE\u7BB1", en: "Email" },
|
|
430
|
+
wechat: { zh: "\u5FAE\u4FE1\u6635\u79F0", en: "WeChat name" },
|
|
421
431
|
channels: { zh: "\u89C6\u9891\u53F7", en: "Channels" },
|
|
422
432
|
xiaohongshu: { zh: "\u5C0F\u7EA2\u4E66", en: "Xiaohongshu" },
|
|
423
433
|
douyin: { zh: "\u6296\u97F3", en: "Douyin" },
|
|
@@ -623,6 +633,43 @@ function normalizeOrgName(input2) {
|
|
|
623
633
|
return input2.replace(/[ \s]+/g, " ").trim();
|
|
624
634
|
}
|
|
625
635
|
|
|
636
|
+
// ../shared/src/related.ts
|
|
637
|
+
function normalizeRelatedName(input2) {
|
|
638
|
+
if (!input2) return "";
|
|
639
|
+
return input2.replace(/[ \s]+/g, " ").trim();
|
|
640
|
+
}
|
|
641
|
+
function normalizeRelatedRelation(input2) {
|
|
642
|
+
if (!input2) return "";
|
|
643
|
+
return input2.replace(/[ \s]+/g, " ").trim();
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ../shared/src/profile.ts
|
|
647
|
+
var NOTES_MAX = 1e4;
|
|
648
|
+
var NOTES_LONG = 6e3;
|
|
649
|
+
var COMPANY_LONG = 80;
|
|
650
|
+
var NAME_MAX = 40;
|
|
651
|
+
function nameProblem(name) {
|
|
652
|
+
const n = (name ?? "").trim();
|
|
653
|
+
if (!n) return null;
|
|
654
|
+
const hint = "name \u53EA\u5199\u59D3\u540D\u672C\u8EAB\uFF1A\u5FAE\u4FE1\u53F7\u5199 wechatId\uFF0C\u5FAE\u4FE1\u6635\u79F0 / \u663E\u793A\u540D\u5199\u8FDB socials\uFF08platform=wechat\uFF09\uFF0C\u5176\u4F59\u8BF4\u660E\u5199\u8FDB notes";
|
|
655
|
+
if (n.length > NAME_MAX) return `name \u8FC7\u957F\uFF08${n.length} \u5B57\uFF0C\u4E0A\u9650 ${NAME_MAX}\uFF09\u3002${hint}`;
|
|
656
|
+
if (/[((][^))]*(微信|昵称|显示名|备注|手机|邮箱|真名|未知)/.test(n)) return `name \u91CC\u5E26\u4E86\u6CE8\u91CA\u6027\u62EC\u53F7\u3002${hint}`;
|
|
657
|
+
return null;
|
|
658
|
+
}
|
|
659
|
+
var CJK = /[一-鿿]/g;
|
|
660
|
+
function isProseCompany(company) {
|
|
661
|
+
const c = (company ?? "").trim();
|
|
662
|
+
if (!c) return false;
|
|
663
|
+
if (/^未明示|^未明确/.test(c)) return true;
|
|
664
|
+
const m = /((.+))\s*$/.exec(c);
|
|
665
|
+
if (m && m[1].length > 20 && (m[1].match(CJK) ?? []).length >= 12) return true;
|
|
666
|
+
return c.length > COMPANY_LONG;
|
|
667
|
+
}
|
|
668
|
+
function halfWidthPunctuation(text) {
|
|
669
|
+
const hits = text.match(/[一-鿿][,.:;!?]|[,;:!?][一-鿿]|[一-鿿]\([^)]{1,20}\)/g);
|
|
670
|
+
return hits ? [...new Set(hits)] : [];
|
|
671
|
+
}
|
|
672
|
+
|
|
626
673
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
627
674
|
var external_exports = {};
|
|
628
675
|
__export(external_exports, {
|
|
@@ -20355,6 +20402,12 @@ var orgLink = external_exports.object({
|
|
|
20355
20402
|
role: external_exports.string().trim().max(200).nullable().optional(),
|
|
20356
20403
|
status: external_exports.string().trim().min(1).max(50).transform(normalizeOrgStatus)
|
|
20357
20404
|
});
|
|
20405
|
+
var relatedPerson = external_exports.object({
|
|
20406
|
+
name: external_exports.string().trim().min(1).max(100).transform(normalizeRelatedName),
|
|
20407
|
+
id: external_exports.string().trim().max(64).nullable().optional(),
|
|
20408
|
+
relation: external_exports.string().trim().min(1).max(100).transform(normalizeRelatedRelation),
|
|
20409
|
+
note: external_exports.string().trim().max(500).nullable().optional()
|
|
20410
|
+
});
|
|
20358
20411
|
var eventInput = external_exports.object({
|
|
20359
20412
|
title: short(200).min(1),
|
|
20360
20413
|
date: isoDate,
|
|
@@ -20365,7 +20418,10 @@ var socialHookInput = external_exports.object({
|
|
|
20365
20418
|
description: short(5e3).min(1)
|
|
20366
20419
|
});
|
|
20367
20420
|
var customerShape = {
|
|
20368
|
-
name: short(200).min(1),
|
|
20421
|
+
name: short(200).min(1).superRefine((v, ctx) => {
|
|
20422
|
+
const p = nameProblem(v);
|
|
20423
|
+
if (p) ctx.addIssue({ code: "custom", message: p });
|
|
20424
|
+
}),
|
|
20369
20425
|
company: short(200),
|
|
20370
20426
|
title: short(200),
|
|
20371
20427
|
city,
|
|
@@ -20376,6 +20432,8 @@ var customerShape = {
|
|
|
20376
20432
|
relationships: external_exports.array(external_exports.string().trim().min(1).max(50).transform(normalizeRelationship)).max(20),
|
|
20377
20433
|
/** 关联的机构:一个人可以挂多个单位。整体替换 */
|
|
20378
20434
|
orgs: external_exports.array(orgLink).max(30),
|
|
20435
|
+
/** 相关人物:这个人牵连到的其他人。整体替换 */
|
|
20436
|
+
relatedPeople: external_exports.array(relatedPerson).max(50),
|
|
20379
20437
|
summary: short(5e3),
|
|
20380
20438
|
painPoints: tags,
|
|
20381
20439
|
goals: tags,
|
|
@@ -20424,7 +20482,7 @@ var socialFields = [
|
|
|
20424
20482
|
type: "enum",
|
|
20425
20483
|
required: true,
|
|
20426
20484
|
values: SOCIAL_PLATFORMS,
|
|
20427
|
-
guide: "\u5E73\u53F0\u3002\u5199\u300C\u89C6\u9891\u53F7\u300D\u300C\u5C0F\u7EA2\u4E66\u300D\u300C\u90AE\u7BB1\u300D\u300C\u516C\u4F17\u53F7\u300D\u7B49\u4E2D\u6587\u4F1A\u81EA\u52A8\u5F52\u4E00\u5316\u5230\u6E05\u5355\u91CC\u7684\u503C\uFF1B\u6E05\u5355\u5916\u7684\u5E73\u53F0\uFF08\u5982\u300C\u5FEB\u624B\u300D\uFF09\u4E0D\u62A5\u9519\uFF0C\u539F\u6837\u4FDD\u7559\u3002\u5FAE\u4FE1\
|
|
20485
|
+
guide: "\u5E73\u53F0\u3002\u5199\u300C\u89C6\u9891\u53F7\u300D\u300C\u5C0F\u7EA2\u4E66\u300D\u300C\u90AE\u7BB1\u300D\u300C\u516C\u4F17\u53F7\u300D\u7B49\u4E2D\u6587\u4F1A\u81EA\u52A8\u5F52\u4E00\u5316\u5230\u6E05\u5355\u91CC\u7684\u503C\uFF1B\u6E05\u5355\u5916\u7684\u5E73\u53F0\uFF08\u5982\u300C\u5FEB\u624B\u300D\uFF09\u4E0D\u62A5\u9519\uFF0C\u539F\u6837\u4FDD\u7559\u3002\u5FAE\u4FE1\u6635\u79F0 / \u663E\u793A\u540D\u7528 platform=wechat\uFF1B\u5FAE\u4FE1\u53F7\uFF08ID\uFF09\u4E0D\u653E\u8FD9\u91CC\uFF0C\u5199 wechatId\u3002"
|
|
20428
20486
|
},
|
|
20429
20487
|
{ 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" },
|
|
20430
20488
|
{ 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" }
|
|
@@ -20440,15 +20498,21 @@ var orgFields = [
|
|
|
20440
20498
|
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
20499
|
}
|
|
20442
20500
|
];
|
|
20501
|
+
var relatedFields = [
|
|
20502
|
+
{ name: "name", type: "string", required: true, guide: "\u5BF9\u65B9\u59D3\u540D\u3002\u6750\u6599\u91CC\u51FA\u73B0\u7684\u4EBA\u540D\u7167\u6284\uFF0C\u4E0D\u8981\u6539\u5199\u6210\u5173\u7CFB\u79F0\u8C13" },
|
|
20503
|
+
{ name: "id", type: "string", nullable: true, guide: "\u5BF9\u65B9\u5728 CRM \u91CC\u7684\u5BA2\u6237 id\u3002\u5BF9\u65B9\u4E0D\u5728\u5E93\u91CC\u5C31\u7701\u7565\uFF1B\u7559\u7A7A\u4E14\u5E93\u91CC\u6709\u552F\u4E00\u540C\u540D\u7684\u5BA2\u6237\u65F6\u670D\u52A1\u7AEF\u4F1A\u81EA\u52A8\u8865\u4E0A" },
|
|
20504
|
+
{ name: "relation", type: "string", required: true, guide: "\u4ECE\u672C\u6761\u89C6\u89D2\u770B\u7684\u5173\u7CFB\uFF0C\u81EA\u7531\u6587\u672C\u3002\u63A8\u8350\u5199\u6CD5\uFF1A\u8F6C\u4ECB\u7ECD\u4EBA / \u88AB\u8F6C\u4ECB\u7ECD\u4EBA / \u5BF9\u63A5\u534F\u8C03\u65B9 / \u62CD\u677F\u51B3\u7B56\u4EBA / \u540C\u573A\u534F\u4F5C / \u540C\u573A\u7ADE\u4E89 / \u540C\u4E8B / \u540C\u5B66 / \u5BFC\u5E08 / \u5E08\u5085 / \u8054\u5408\u521B\u59CB\u4EBA / \u56E2\u961F\u6210\u5458 / \u6295\u8D44\u4EBA" },
|
|
20505
|
+
{ name: "note", type: "string", nullable: true, guide: "\u4E00\u53E5\u8BDD\u8BF4\u660E\u8FD9\u6761\u5173\u7CFB\u7684\u6765\u9F99\u53BB\u8109\uFF0C\u5982\u300C07-15 \u53D1\u5979\u7684\u540D\u7247\u8BF4\u300E\u8FD9\u4F4D\u540C\u4E8B\u63A8\u8350\u7684\u300F\u300D" }
|
|
20506
|
+
];
|
|
20443
20507
|
var SCHEMA = {
|
|
20444
20508
|
customer: {
|
|
20445
20509
|
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",
|
|
20446
20510
|
fields: [
|
|
20447
|
-
{ name: "name", type: "string", required: true, guide: "\
|
|
20511
|
+
{ name: "name", type: "string", required: true, guide: "\u53EA\u5199\u59D3\u540D\u672C\u8EAB\uFF08\u542B\u5E38\u7528\u82F1\u6587\u540D\uFF0C\u5982\u300C\u674E\u6E90\u67AB Philip F. Yuan\u300D\uFF09\uFF0C\u4E0D\u8D85\u8FC7 40 \u5B57\uFF0C\u4E0D\u8981\u5E26\u62EC\u53F7\u6CE8\u91CA\u3002\u5FAE\u4FE1\u53F7\u5199 wechatId\uFF0C\u5FAE\u4FE1\u6635\u79F0 / \u663E\u793A\u540D / \u7FA4\u6635\u79F0\u5199\u8FDB socials\uFF08platform=wechat\uFF09\uFF0C\u804C\u52A1\u3001\u57CE\u5E02\u3001\u5907\u6CE8\u5199\u8FDB\u5404\u81EA\u5B57\u6BB5\u6216 notes\u3002\u65E0\u6CD5\u786E\u5B9A\u771F\u540D\u65F6\u5199\u5BF9\u65B9\u4F7F\u7528\u7684\u79F0\u547C\uFF0C\u300C\u771F\u540D\u672A\u77E5\u300D\u4E4B\u7C7B\u7684\u8BF4\u660E\u5199\u8FDB notes" },
|
|
20448
20512
|
{ 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
20513
|
{ 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" },
|
|
20450
20514
|
{ 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" },
|
|
20451
|
-
{ name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199" },
|
|
20515
|
+
{ name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\uFF08\u767B\u5F55\u7528\u7684 ID\uFF0C\u5982 elphawhite\uFF09\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199\u3002\u5FAE\u4FE1\u6635\u79F0 / \u663E\u793A\u540D\u4E0D\u662F\u5FAE\u4FE1\u53F7\uFF0C\u5199\u8FDB socials" },
|
|
20452
20516
|
{
|
|
20453
20517
|
name: "socials",
|
|
20454
20518
|
type: "object[]",
|
|
@@ -20467,6 +20531,12 @@ var SCHEMA = {
|
|
|
20467
20531
|
fields: orgFields,
|
|
20468
20532
|
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
20533
|
},
|
|
20534
|
+
{
|
|
20535
|
+
name: "relatedPeople",
|
|
20536
|
+
type: "object[]",
|
|
20537
|
+
fields: relatedFields,
|
|
20538
|
+
guide: "\u76F8\u5173\u4EBA\u7269\uFF1A\u8FD9\u4E2A\u4EBA\u7275\u8FDE\u5230\u7684\u5176\u4ED6\u4EBA\u3002\u8DDF relationships\uFF08\u8FD9\u4E2A\u4EBA\u5728\u6211\u8FD9\u91CC\u662F\u4EC0\u4E48\u8EAB\u4EFD\uFF09\u4E0D\u662F\u4E00\u56DE\u4E8B\u2014\u2014\u90A3\u662F\u300C\u5BF9\u7528\u6237\u300D\u7684\u5173\u7CFB\uFF0C\u8FD9\u662F\u300C\u4EBA\u4E0E\u4EBA\u4E4B\u95F4\u300D\u7684\u5173\u7CFB\u3002\u5143\u7D20\u5F62\u5982 {name:'\u674E\u96C5\u5A77', relation:'\u8F6C\u4ECB\u7ECD\u4EBA', note:'07-15 \u53D1\u5979\u7684\u540D\u7247\u8BF4\u300C\u8FD9\u4F4D\u540C\u4E8B\u63A8\u8350\u7684\u300D'}\u3002\u8981\u8BB0\u7684\u5178\u578B\u573A\u666F\uFF1A\u8C01\u628A\u8C01\u4ECB\u7ECD\u6765\u7684\u3001\u8C01\u5728\u4E2D\u95F4\u505A\u63A8\u8FDB\u3001\u8C01\u8DDF\u8C01\u4E00\u8D77\u505A\u8FC7\u4E8B\u3001\u8C01\u8DDF\u8C01\u5728\u62A2\u540C\u4E00\u6279\u540D\u989D\u3002\u5BFC\u5E08\u3001\u5E08\u5085\u3001\u8054\u5408\u521B\u59CB\u4EBA\u3001\u56E2\u961F\u6210\u5458\u8FD9\u4E9B\u4E0D\u5728 CRM \u91CC\u7684\u4EBA\u4E5F\u8981\u8BB0\uFF0C\u53EA\u7559\u540D\u5B57\u5373\u53EF\u3002relation \u662F\u81EA\u7531\u6587\u672C\uFF0C\u4E0D\u8981\u7F16\u9020\u6750\u6599\u91CC\u6CA1\u6709\u7684\u5173\u7CFB\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"
|
|
20539
|
+
},
|
|
20470
20540
|
{ 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" },
|
|
20471
20541
|
{ 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" },
|
|
20472
20542
|
{ name: "goals", type: "string[]", guide: "\u77ED\u671F\u76EE\u6807\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD" },
|
|
@@ -20560,7 +20630,7 @@ function renderPrompt(text, customer) {
|
|
|
20560
20630
|
// package.json
|
|
20561
20631
|
var package_default = {
|
|
20562
20632
|
name: "insightcrm",
|
|
20563
|
-
version: "0.1.
|
|
20633
|
+
version: "0.1.10",
|
|
20564
20634
|
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.",
|
|
20565
20635
|
license: "MIT",
|
|
20566
20636
|
type: "module",
|
|
@@ -20672,6 +20742,83 @@ function createClient(apiUrl, token) {
|
|
|
20672
20742
|
};
|
|
20673
20743
|
}
|
|
20674
20744
|
|
|
20745
|
+
// src/lint.ts
|
|
20746
|
+
function lintCustomers(customers, today2) {
|
|
20747
|
+
const issues = [];
|
|
20748
|
+
const ids = new Set(customers.map((c) => c.id));
|
|
20749
|
+
const push = (c, kind, severity, detail2) => issues.push({ id: c.id, name: c.name, kind, severity, detail: detail2 });
|
|
20750
|
+
const byWechat = /* @__PURE__ */ new Map();
|
|
20751
|
+
for (const c of customers) {
|
|
20752
|
+
const w = (c.wechatId ?? "").trim();
|
|
20753
|
+
if (!w) continue;
|
|
20754
|
+
const arr = byWechat.get(w);
|
|
20755
|
+
if (arr) arr.push(c);
|
|
20756
|
+
else byWechat.set(w, [c]);
|
|
20757
|
+
}
|
|
20758
|
+
for (const c of customers) {
|
|
20759
|
+
const notesLen = (c.notes ?? "").length;
|
|
20760
|
+
if (notesLen > NOTES_MAX) push(c, "notes-over-limit", "error", `notes ${notesLen} \u5B57\u7B26\uFF0C\u8D85\u670D\u52A1\u7AEF\u4E0A\u9650 ${NOTES_MAX}\uFF0C\u518D\u8FFD\u52A0\u4F1A\u88AB\u6574\u6761\u62D2\u7EDD`);
|
|
20761
|
+
else if (notesLen > NOTES_LONG) push(c, "notes-long", "warn", `notes ${notesLen} \u5B57\u7B26\uFF0C\u504F\u81C3\u80BF\uFF08\u4E0A\u9650 ${NOTES_MAX}\uFF09`);
|
|
20762
|
+
const nameIssue = nameProblem(c.name);
|
|
20763
|
+
if (nameIssue) push(c, "name-annotated", "warn", `${nameIssue}\uFF1A\u300C${c.name.slice(0, 40)}${c.name.length > 40 ? "\u2026" : ""}\u300D`);
|
|
20764
|
+
for (const o of c.orgs ?? []) {
|
|
20765
|
+
if (!isKnownOrgStatus(o.status)) {
|
|
20766
|
+
push(c, "unknown-status", "error", `orgs[].status="${o.status}"\uFF08org=${o.org}\uFF09\u4E0D\u5728\u53D7\u63A7\u8BCD\u8868\u91CC\uFF0C\u6309\u72B6\u6001\u805A\u5408\u65F6\u8FD9\u6761\u4F1A\u6F0F\u6389`);
|
|
20767
|
+
}
|
|
20768
|
+
}
|
|
20769
|
+
const company = (c.company ?? "").trim();
|
|
20770
|
+
const orgs = c.orgs ?? [];
|
|
20771
|
+
if (company && !orgs.length) push(c, "company-without-orgs", "warn", "company \u6709\u503C\u4F46 orgs \u4E3A\u7A7A\uFF0C\u673A\u6784\u4FE1\u606F\u53EA\u5B58\u5728\u4E8E\u6458\u8981\u91CC\uFF0C\u6309\u673A\u6784\u7B5B\u4E0D\u5230");
|
|
20772
|
+
if (!company && orgs.length) push(c, "orgs-without-company", "warn", "orgs \u6709\u503C\u4F46 company \u4E3A\u7A7A\uFF0C\u7F3A\u300C\u4E3B\u5355\u4F4D\u300D\u6458\u8981");
|
|
20773
|
+
if (company && isProseCompany(company)) push(c, "company-prose", "warn", `company \u662F\u8BF4\u660E\u6587\u800C\u4E0D\u662F\u7B80\u79F0\uFF1A\u300C${company.slice(0, 40)}${company.length > 40 ? "\u2026" : ""}\u300D`);
|
|
20774
|
+
if (!c.relationships?.length) push(c, "no-relationship", "warn", "relationships \u4E3A\u7A7A\uFF0C\u4E0D\u77E5\u9053\u8FD9\u4E2A\u4EBA\u662F\u8C01");
|
|
20775
|
+
const city2 = (c.city ?? "").trim();
|
|
20776
|
+
if (city2 && !isKnownCity(city2)) push(c, "city-off-list", "warn", `city="${city2}" \u4E0D\u5728\u6807\u51C6\u57CE\u5E02\u8868\u91CC\uFF0C\u6309\u57CE\u5E02\u805A\u5408\u65F6\u8FD9\u6761\u4F1A\u6F0F\u6389`);
|
|
20777
|
+
for (const e of c.upcomingEvents ?? []) {
|
|
20778
|
+
if (e.date && e.date < today2) push(c, "expired-event", "error", `\u65E5\u7A0B\u5DF2\u8FC7\u671F\uFF1A${e.date}\u300C${e.title}\u300D`);
|
|
20779
|
+
}
|
|
20780
|
+
for (const p of c.relatedPeople ?? []) {
|
|
20781
|
+
if (p.id && !ids.has(p.id)) push(c, "dangling-related-id", "error", `relatedPeople[${p.name}].id=${p.id} \u6307\u5411\u5E93\u91CC\u4E0D\u5B58\u5728\u7684\u5BA2\u6237`);
|
|
20782
|
+
}
|
|
20783
|
+
const w = (c.wechatId ?? "").trim();
|
|
20784
|
+
if (w && (byWechat.get(w)?.length ?? 0) > 1) {
|
|
20785
|
+
push(c, "duplicate-wechat", "warn", `wechatId=${w} \u5728 ${byWechat.get(w).length} \u6761\u8BB0\u5F55\u4E0A\u91CD\u590D`);
|
|
20786
|
+
}
|
|
20787
|
+
const texts = [
|
|
20788
|
+
["summary", c.summary ?? ""],
|
|
20789
|
+
["notes", c.notes ?? ""],
|
|
20790
|
+
["currentAction", c.currentAction ?? ""],
|
|
20791
|
+
...(c.painPoints ?? []).map((p) => ["painPoints", p]),
|
|
20792
|
+
...(c.goals ?? []).map((g2) => ["goals", g2])
|
|
20793
|
+
];
|
|
20794
|
+
for (const [field, text] of texts) {
|
|
20795
|
+
if (!text) continue;
|
|
20796
|
+
const hits = halfWidthPunctuation(text);
|
|
20797
|
+
if (hits.length) push(c, "half-width-punctuation", "info", `${field} \u6709 ${hits.length} \u5904\u534A\u89D2\u6807\u70B9\uFF1A${hits.slice(0, 4).join(" ")}`);
|
|
20798
|
+
}
|
|
20799
|
+
}
|
|
20800
|
+
return issues;
|
|
20801
|
+
}
|
|
20802
|
+
function groupLintIssues(issues) {
|
|
20803
|
+
const rank = { error: 0, warn: 1, info: 2 };
|
|
20804
|
+
const perCustomer = /* @__PURE__ */ new Map();
|
|
20805
|
+
for (const i of issues) {
|
|
20806
|
+
const arr = perCustomer.get(i.id);
|
|
20807
|
+
if (arr) arr.push(i);
|
|
20808
|
+
else perCustomer.set(i.id, [i]);
|
|
20809
|
+
}
|
|
20810
|
+
return {
|
|
20811
|
+
issues: [...issues].sort((a, b) => rank[a.severity] - rank[b.severity] || a.name.localeCompare(b.name)),
|
|
20812
|
+
perCustomer: [...perCustomer.entries()].map(([id, list]) => ({
|
|
20813
|
+
id,
|
|
20814
|
+
name: list[0].name,
|
|
20815
|
+
count: list.length,
|
|
20816
|
+
errors: list.filter((i) => i.severity === "error").length,
|
|
20817
|
+
kinds: [...new Set(list.map((i) => i.kind))]
|
|
20818
|
+
})).sort((a, b) => b.errors - a.errors || b.count - a.count)
|
|
20819
|
+
};
|
|
20820
|
+
}
|
|
20821
|
+
|
|
20675
20822
|
// src/org.ts
|
|
20676
20823
|
function parseOrg(s) {
|
|
20677
20824
|
const parts = s.split(":").map((p) => p.trim());
|
|
@@ -20688,6 +20835,18 @@ function parseOrg(s) {
|
|
|
20688
20835
|
}
|
|
20689
20836
|
var orgKey = (o) => JSON.stringify([o.org, o.status]);
|
|
20690
20837
|
|
|
20838
|
+
// src/related.ts
|
|
20839
|
+
function parseRelated(s) {
|
|
20840
|
+
const parts = s.split(":").map((p) => p.trim());
|
|
20841
|
+
const name = parts[0] ?? "";
|
|
20842
|
+
if (!name) throw new CliError("usage", `Can't read related person "${s}". Use name:relation, e.g. \u674E\u96C5\u5A77:\u8F6C\u4ECB\u7ECD\u4EBA`, EXIT.usage);
|
|
20843
|
+
const relation = parts[1] ?? "";
|
|
20844
|
+
if (!relation) throw new CliError("usage", `Can't read related person "${s}". Use name:relation, e.g. \u674E\u96C5\u5A77:\u8F6C\u4ECB\u7ECD\u4EBA`, EXIT.usage);
|
|
20845
|
+
const note = parts.length > 2 ? parts.slice(2).join(":").trim() : "";
|
|
20846
|
+
return { name, relation, ...note ? { note } : {} };
|
|
20847
|
+
}
|
|
20848
|
+
var relatedKey = (p) => JSON.stringify([p.name, p.relation]);
|
|
20849
|
+
|
|
20691
20850
|
// src/prompts.ts
|
|
20692
20851
|
import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
20693
20852
|
import path2 from "path";
|
|
@@ -20839,6 +20998,7 @@ Recommended workflow (for agents):
|
|
|
20839
20998
|
Before adding search <name> --json (avoid duplicates; if the customer exists, update instead of add)
|
|
20840
20999
|
Record a customer add - --json < profile.json (or: add --name ... --potential High)
|
|
20841
21000
|
Update update <id> --add-pain "budget" --add-event 2026-10-20:follow_up:send quote --json
|
|
21001
|
+
Audit the records lint --json (report dirty records; reports only, never writes)
|
|
20842
21002
|
Reuse what works hook list --json (successful phrasings from other customers)
|
|
20843
21003
|
Recommend rec list --json (the user's OWN inventory: pick what fits; add items only when the user asks, never from chat)
|
|
20844
21004
|
House rules prompts show extraction-rules (the user's own extraction rules: follow them when extracting)
|
|
@@ -20855,7 +21015,11 @@ Examples:
|
|
|
20855
21015
|
$ crm add --name "\u738B\u5C0F\u660E" --relationship \u5B66\u5458 --relationship \u793E\u7FA4\u6210\u5458 --json
|
|
20856
21016
|
$ 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
|
|
20857
21017
|
$ crm list --potential high --city Beijing --due-today --json
|
|
21018
|
+
$ crm list --expired --json
|
|
20858
21019
|
$ crm list --org \u540C\u6D4E --json
|
|
21020
|
+
$ crm lint --severity error --json
|
|
21021
|
+
$ crm add --name "\u738B\u5C0F\u660E" --related "\u674E\u96C5\u5A77:\u8F6C\u4ECB\u7ECD\u4EBA" "\u67F4\u8001\u5E08:\u5BFC\u5E08" --json
|
|
21022
|
+
$ crm list --related \u674E\u96C5\u5A77 --json
|
|
20859
21023
|
$ crm update 3f2a\u2026 --summary "Needs a quote by Friday" --json
|
|
20860
21024
|
$ crm hook add --title "Opened with a peer case" --desc "Led with a competitor's result, then asked about theirs" --customer 3f2a\u2026
|
|
20861
21025
|
$ crm export -o backup.json`
|
|
@@ -20933,9 +21097,9 @@ function parseSocial(s) {
|
|
|
20933
21097
|
return { platform: platform2, handle };
|
|
20934
21098
|
}
|
|
20935
21099
|
function withCustomerOptions(cmd, forUpdate) {
|
|
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)" : ""}`);
|
|
21100
|
+
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)" : ""}`).option("--related <name:relation:note...>", `related people, e.g. \u674E\u96C5\u5A77:\u8F6C\u4ECB\u7ECD\u4EBA\uFF08\u59D3\u540D:\u5173\u7CFB\uFF0C\u8BF4\u660E\u53EF\u7701\u7565\uFF09${forUpdate ? " (replaces the whole list; see --add-related)" : ""}`);
|
|
20937
21101
|
if (forUpdate) {
|
|
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");
|
|
21102
|
+
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("--add-related <name:relation:note...>", "append related people, keeping existing ones (\u59D3\u540D:\u5173\u7CFB\uFF0C\u8BF4\u660E\u53EF\u7701\u7565)").option("--clear-events", "remove all calendar events");
|
|
20939
21103
|
} else {
|
|
20940
21104
|
cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
|
|
20941
21105
|
}
|
|
@@ -20967,12 +21131,41 @@ function buildCustomerBody(base, o) {
|
|
|
20967
21131
|
if (o.social) body.socials = o.social.map(parseSocial);
|
|
20968
21132
|
if (o.relationship) body.relationships = o.relationship;
|
|
20969
21133
|
if (o.org) body.orgs = o.org.map(parseOrg);
|
|
21134
|
+
if (o.related) body.relatedPeople = o.related.map(parseRelated);
|
|
20970
21135
|
if (o.hookTitle || o.hookDesc) {
|
|
20971
21136
|
if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
|
|
20972
21137
|
body.socialHook = { title: o.hookTitle, description: o.hookDesc };
|
|
20973
21138
|
}
|
|
20974
21139
|
return body;
|
|
20975
21140
|
}
|
|
21141
|
+
function checkNotesLength(body) {
|
|
21142
|
+
const notes = body.notes;
|
|
21143
|
+
if (typeof notes === "string" && notes.length > NOTES_MAX) {
|
|
21144
|
+
throw new CliError(
|
|
21145
|
+
"usage",
|
|
21146
|
+
`notes is ${notes.length} characters, ${notes.length - NOTES_MAX} over the ${NOTES_MAX} limit. Compress it (move detail into the structured fields) and retry`,
|
|
21147
|
+
EXIT.usage
|
|
21148
|
+
);
|
|
21149
|
+
}
|
|
21150
|
+
}
|
|
21151
|
+
function warnPayload(body) {
|
|
21152
|
+
const warns = [];
|
|
21153
|
+
for (const o of body.orgs ?? []) {
|
|
21154
|
+
if (o?.status && !isKnownOrgStatus(o.status)) {
|
|
21155
|
+
warns.push(`orgs[].status="${o.status}" is not a controlled value (${ORG_STATUSES.join(" | ")}) \u2014 it won't aggregate by status`);
|
|
21156
|
+
}
|
|
21157
|
+
}
|
|
21158
|
+
if (typeof body.city === "string" && body.city.trim() && !isKnownCity(body.city)) {
|
|
21159
|
+
warns.push(`city="${body.city}" is not in the standard city list \u2014 it won't aggregate by city`);
|
|
21160
|
+
}
|
|
21161
|
+
for (const e of body.upcomingEvents ?? []) {
|
|
21162
|
+
if (e?.date && e.date < today()) warns.push(`event "${e.title ?? ""}" ${e.date} is already in the past`);
|
|
21163
|
+
}
|
|
21164
|
+
if (typeof body.company === "string" && isProseCompany(body.company)) {
|
|
21165
|
+
warns.push(`company looks like a note rather than a short name \u2014 keep the name short and move the detail into orgs / notes`);
|
|
21166
|
+
}
|
|
21167
|
+
for (const w of warns) info(`\u26A0 ${w}`);
|
|
21168
|
+
}
|
|
20976
21169
|
var line = (c) => `${c.id} ${c.name}${c.company || c.title ? ` (${[c.company, c.title].filter(Boolean).join(" \xB7 ")})` : ""}${c.city ? ` ${c.city}` : ""} ${c.conversionPotential} ${c.conversionCycleDays}d${c.painPoints.length ? ` [${c.painPoints.join(", ")}]` : ""}`;
|
|
20977
21170
|
function detail(c) {
|
|
20978
21171
|
const rows = [
|
|
@@ -20985,6 +21178,7 @@ function detail(c) {
|
|
|
20985
21178
|
["socials", c.socials.map((s) => `${s.platform}: ${s.handle}${s.url ? ` (${s.url})` : ""}`).join("; ")],
|
|
20986
21179
|
["relationship", c.relationships.map((r) => relationshipLabel(r, "zh")).join(", ")],
|
|
20987
21180
|
["orgs", (c.orgs ?? []).map((o) => `${o.org}${o.role ? ` \xB7 ${o.role}` : ""} [${orgStatusLabel(o.status, "zh")}]`).join("; ")],
|
|
21181
|
+
["related", (c.relatedPeople ?? []).map((p) => `${p.name} \xB7 ${p.relation}${p.note ? `\uFF08${p.note}\uFF09` : ""}`).join("; ")],
|
|
20988
21182
|
["potential", c.conversionPotential],
|
|
20989
21183
|
["cycle days", String(c.conversionCycleDays)],
|
|
20990
21184
|
["pain points", c.painPoints.join(", ")],
|
|
@@ -21125,16 +21319,18 @@ withCustomerOptions(
|
|
|
21125
21319
|
).action(async (src, o) => {
|
|
21126
21320
|
const body = buildCustomerBody(await readJsonInput(src), o);
|
|
21127
21321
|
if (!body.name) throw new CliError("usage", "name is required (pass --name or include it in the JSON)", EXIT.usage);
|
|
21322
|
+
checkNotesLength(body);
|
|
21323
|
+
warnPayload(body);
|
|
21128
21324
|
const { customer } = await (await client()).addCustomer(body);
|
|
21129
21325
|
out(`Created ${line(customer)}`, { customer, created: true });
|
|
21130
21326
|
});
|
|
21131
21327
|
withCustomerOptions(
|
|
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"),
|
|
21328
|
+
program.command("update").description("Change a customer. Only the fields you pass change. --pain / --goal / --event / --social / --relationship / --org / --related REPLACE the list; --add-pain / --add-goal / --add-event / --add-social / --add-relationship / --add-org / --add-related append.").argument("<id>").argument("[json-file]", "JSON file, or - for stdin"),
|
|
21133
21329
|
true
|
|
21134
21330
|
).action(async (id, src, o) => {
|
|
21135
21331
|
const api = await client();
|
|
21136
21332
|
const body = buildCustomerBody(await readJsonInput(src), o);
|
|
21137
|
-
if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship || o.addOrg) {
|
|
21333
|
+
if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship || o.addOrg || o.addRelated) {
|
|
21138
21334
|
const { customer: cur } = await api.getCustomer(id);
|
|
21139
21335
|
if (o.addPain) body.painPoints = [.../* @__PURE__ */ new Set([...body.painPoints ?? cur.painPoints, ...o.addPain])];
|
|
21140
21336
|
if (o.addGoal) body.goals = [.../* @__PURE__ */ new Set([...body.goals ?? cur.goals, ...o.addGoal])];
|
|
@@ -21154,16 +21350,54 @@ withCustomerOptions(
|
|
|
21154
21350
|
const existing = body.orgs ?? cur.orgs;
|
|
21155
21351
|
body.orgs = [...existing, ...added.filter((x) => !existing.some((e) => orgKey(e) === orgKey(x)))];
|
|
21156
21352
|
}
|
|
21353
|
+
if (o.addRelated) {
|
|
21354
|
+
const added = o.addRelated.map(parseRelated);
|
|
21355
|
+
const existing = body.relatedPeople ?? cur.relatedPeople;
|
|
21356
|
+
body.relatedPeople = [...existing, ...added.filter((x) => !existing.some((e) => relatedKey(e) === relatedKey(x)))];
|
|
21357
|
+
}
|
|
21157
21358
|
}
|
|
21158
21359
|
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);
|
|
21360
|
+
checkNotesLength(body);
|
|
21361
|
+
warnPayload(body);
|
|
21159
21362
|
const { customer } = await api.updateCustomer(id, body);
|
|
21160
21363
|
out(`Updated ${line(customer)}`, { customer, updated: true });
|
|
21161
21364
|
});
|
|
21162
21365
|
program.command("get").description("Show one customer").argument("<id>").action(async (id) => {
|
|
21163
|
-
const
|
|
21164
|
-
|
|
21366
|
+
const api = await client();
|
|
21367
|
+
const { customer } = await api.getCustomer(id);
|
|
21368
|
+
const { hooks } = await api.listHooks(id);
|
|
21369
|
+
const rows = [
|
|
21370
|
+
...detail(customer).split("\n"),
|
|
21371
|
+
...hooks.length ? ["", "hooks", ...hooks.map((h) => ` ${h.isEnabled ? " " : "\xD7"} ${h.title}
|
|
21372
|
+
${h.description}`)] : []
|
|
21373
|
+
].join("\n");
|
|
21374
|
+
out(rows, { customer, hooks });
|
|
21375
|
+
});
|
|
21376
|
+
program.command("lint").description("Audit every customer record and report what should be checked or fixed. Reports only \u2014 never writes.").option("--kind <kind>", "only report one kind of issue").option("--severity <level>", "only report this severity: error / warn / info").action(async (o) => {
|
|
21377
|
+
const api = await client();
|
|
21378
|
+
const { customers } = await api.listCustomers({});
|
|
21379
|
+
const all = lintCustomers(customers, today());
|
|
21380
|
+
const issues = all.filter(
|
|
21381
|
+
(i) => (!o.kind || i.kind === o.kind) && (!o.severity || i.severity === o.severity)
|
|
21382
|
+
);
|
|
21383
|
+
const { perCustomer } = groupLintIssues(issues);
|
|
21384
|
+
const errors = issues.filter((i) => i.severity === "error").length;
|
|
21385
|
+
const warns = issues.filter((i) => i.severity === "warn").length;
|
|
21386
|
+
const infos = issues.filter((i) => i.severity === "info").length;
|
|
21387
|
+
const human = [
|
|
21388
|
+
`Scanned ${customers.length} customers \xB7 ${issues.length} issues (${errors} error / ${warns} warn / ${infos} info)`,
|
|
21389
|
+
"",
|
|
21390
|
+
...perCustomer.map(
|
|
21391
|
+
(p) => `${p.count === 1 ? " " : "!"} ${p.name} (${p.id}) ${p.count} issue${p.count > 1 ? "s" : ""}${p.errors ? `, ${p.errors} error` : ""}
|
|
21392
|
+
${p.kinds.join(", ")}`
|
|
21393
|
+
),
|
|
21394
|
+
"",
|
|
21395
|
+
"Per issue:",
|
|
21396
|
+
...issues.map((i) => ` [${i.severity}] ${i.name} \u2014 ${i.kind}: ${i.detail}`)
|
|
21397
|
+
].join("\n");
|
|
21398
|
+
out(human, { scanned: customers.length, count: issues.length, errors, warns, infos, issues, perCustomer });
|
|
21165
21399
|
});
|
|
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) => {
|
|
21400
|
+
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("--related <s>", "is connected to this person (substring match on the related-people list; also matches records that point at this customer)").option("--due-today", "has a calendar event today (your local date)").option("--due <YYYY-MM-DD>", "has a calendar event on this date").option("--expired [date]", "has a calendar event before this date (default: today) \u2014 overdue events nobody cleaned up").option("-q, --query <s>", "keyword across name, company, title, city, wechat, social accounts, relationships, organizations, related people, summary, notes, tags, goals").action(async (o) => {
|
|
21167
21401
|
const { customers } = await (await client()).listCustomers({
|
|
21168
21402
|
potential: o.potential ? potentialOf(o.potential) : void 0,
|
|
21169
21403
|
city: o.city,
|
|
@@ -21172,7 +21406,9 @@ program.command("list").description("List customers (newest update first), optio
|
|
|
21172
21406
|
socialPlatform: o.socialPlatform,
|
|
21173
21407
|
relationship: o.relationship,
|
|
21174
21408
|
org: o.org,
|
|
21175
|
-
|
|
21409
|
+
related: o.related,
|
|
21410
|
+
dueOn: o.dueToday ? today() : o.due,
|
|
21411
|
+
expiredBefore: o.expired ? o.expired === true ? today() : o.expired : void 0
|
|
21176
21412
|
});
|
|
21177
21413
|
out(customers.length ? customers.map(line).join("\n") : "No customers match.", { customers, count: customers.length });
|
|
21178
21414
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightcrm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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",
|