insightcrm 0.1.7 → 0.1.9

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 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,24 @@ 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
+
71
+ **相关人物 `relatedPeople`**:这个人牵连到的**其他人**——人与人之间的关系。
72
+ - 元素形如 `{"name":"李雅婷","relation":"转介绍人","note":"07-15 发了她的名片说「这位同事推荐的」"}`。`name` 必填;`id` 和 `note` 选填。
73
+ - **跟 `relationships` 不是一回事**:`relationships` 是「这个人在我这里是什么身份」(对我),`relatedPeople` 是「人与人之间」(对内)。别把两者混着填。
74
+ - `relation` 是**自由文本**,不是受控词表。推荐写法:转介绍人 / 被转介绍人 / 对接协调方 / 拍板决策人 / 同场协作 / 同场竞争 / 同事 / 同学 / 导师 / 师傅 / 联合创始人 / 团队成员 / 投资人 / 介绍人。材料里没有的关系**不要编**。
75
+ - `id` 可以省略:省略后服务端会按**同一用户名下唯一同名**自动补上。**库外的人**(导师、师傅、联合创始人、团队成员……)只留名字就行,照样要记。
76
+ - **名字要照抄材料里的写法**,不要合并全名和简称。同名多人时服务端宁可不补 id,也不要指错人——所以靠 id 或全名才可靠,靠字符串匹配会误命中(库里有「谢」和另一个叫「谢扬」的人)。
77
+ - **按人筛是包含匹配**:`crm list --related 谢` 会把「老谢」「谢扬」这些不同的人一起带出来。要精确指某一个人,用全名或看档案里的 `relatedPeople.id`。
78
+ - **典型要记的场景**:谁把谁介绍来的、谁在中间做推进、谁跟谁一起做过事、谁跟谁在抢同一批名额。
79
+ - 材料里没出现就整条省略,**不要编造**。命令行写法:`--related "李雅婷:转介绍人" "柴老师:导师"`(姓名:关系,关系必填,说明可省略)。
80
+
63
81
  **日程 `upcomingEvents`**:`{title, date, type}` 的数组,`date` 是 `YYYY-MM-DD`,`type` 是 `meeting` / `follow_up` / `deadline` / `other`。
64
82
  - 今天是几号要自己确认,相对日期(「下周三」)按今天换算成具体日期。
65
83
  - **已经过去的日期不要录**。
@@ -100,14 +118,18 @@ crm login https://<服务器地址>
100
118
 
101
119
  | 想做的事 | 用 |
102
120
  |---|---|
103
- | 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` |
104
- | **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship`,或 JSON 里直接传数组 |
121
+ | 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 / 单位 / 相关人物 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` / `--add-org` / `--add-related` |
122
+ | **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship` / `--org` / `--related`,或 JSON 里直接传数组 |
105
123
  | 清空日程 | `--clear-events` |
106
124
 
107
125
  `upcomingEvents` 在 JSON 里传了就是**整体替换**。只想加一个日程,用 `--add-event 2026-10-25:deadline:报价截止`,不要把一个事件的数组传上去把旧的冲掉。
108
126
 
109
127
  `socials` 同理:传了就是**整体替换**。只想补一个号,用 `--add-social channels:@san三`。
110
128
 
129
+ `orgs` 也一样:传了就是**整体替换**。只想补一个单位,用 `--add-org "同济大学:在职教师:在职"`。
130
+
131
+ `relatedPeople` 也一样:传了就是**整体替换**。只想补一个人,用 `--add-related "李雅婷:转介绍人"`。
132
+
111
133
  `summary` 是对这个客户的整体描述。合并新材料时,是在原有摘要上补充,不是整段覆盖掉已有的信息:先 `crm get <id> --json` 读出旧内容再写。
112
134
 
113
135
  ## 查询
@@ -116,9 +138,11 @@ crm login https://<服务器地址>
116
138
  crm list --potential high --city 北京 --json # 按等级、城市、标签筛选
117
139
  crm list --due-today --json # 今天有日程的客户(今天要联系谁)
118
140
  crm list --due 2026-10-20 --json
119
- crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、摘要、备注、标签、目标
141
+ crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、关系、单位、相关人物、摘要、备注、标签、目标
120
142
  crm list --social-platform xiaohongshu --json # 有小红书账号的客户
121
143
  crm list --relationship 甲方 --json # 甲方名单(写 client 一样命中)
144
+ crm list --org 同济 --json # 挂在某个机构的客户(包含匹配,简称也能命中)
145
+ crm list --related 李雅婷 --json # 和李雅婷有关系的人(含「被指向」的反向关联)
122
146
  crm get <id> --json
123
147
  ```
124
148
 
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,88 @@ 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
+
626
+ // ../shared/src/related.ts
627
+ function normalizeRelatedName(input2) {
628
+ if (!input2) return "";
629
+ return input2.replace(/[ \s]+/g, " ").trim();
630
+ }
631
+ function normalizeRelatedRelation(input2) {
632
+ if (!input2) return "";
633
+ return input2.replace(/[ \s]+/g, " ").trim();
634
+ }
635
+
538
636
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
539
637
  var external_exports = {};
540
638
  __export(external_exports, {
@@ -20262,6 +20360,17 @@ var socialLink = external_exports.object({
20262
20360
  handle: external_exports.string().trim().min(1).max(200),
20263
20361
  url: external_exports.string().trim().max(2e3).nullable().optional()
20264
20362
  });
20363
+ var orgLink = external_exports.object({
20364
+ org: external_exports.string().trim().min(1).max(200).transform(normalizeOrgName),
20365
+ role: external_exports.string().trim().max(200).nullable().optional(),
20366
+ status: external_exports.string().trim().min(1).max(50).transform(normalizeOrgStatus)
20367
+ });
20368
+ var relatedPerson = external_exports.object({
20369
+ name: external_exports.string().trim().min(1).max(100).transform(normalizeRelatedName),
20370
+ id: external_exports.string().trim().max(64).nullable().optional(),
20371
+ relation: external_exports.string().trim().min(1).max(100).transform(normalizeRelatedRelation),
20372
+ note: external_exports.string().trim().max(500).nullable().optional()
20373
+ });
20265
20374
  var eventInput = external_exports.object({
20266
20375
  title: short(200).min(1),
20267
20376
  date: isoDate,
@@ -20281,6 +20390,10 @@ var customerShape = {
20281
20390
  socials: external_exports.array(socialLink).max(50),
20282
20391
  /** 关系:这个人是谁。可以多个,按重要性从高到低。整体替换 */
20283
20392
  relationships: external_exports.array(external_exports.string().trim().min(1).max(50).transform(normalizeRelationship)).max(20),
20393
+ /** 关联的机构:一个人可以挂多个单位。整体替换 */
20394
+ orgs: external_exports.array(orgLink).max(30),
20395
+ /** 相关人物:这个人牵连到的其他人。整体替换 */
20396
+ relatedPeople: external_exports.array(relatedPerson).max(50),
20284
20397
  summary: short(5e3),
20285
20398
  painPoints: tags,
20286
20399
  goals: tags,
@@ -20334,13 +20447,30 @@ var socialFields = [
20334
20447
  { 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
20448
  { 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
20449
  ];
20450
+ var orgFields = [
20451
+ { 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" },
20452
+ { 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" },
20453
+ {
20454
+ name: "status",
20455
+ type: "enum",
20456
+ required: true,
20457
+ values: ORG_STATUSES,
20458
+ 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"
20459
+ }
20460
+ ];
20461
+ var relatedFields = [
20462
+ { 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" },
20463
+ { 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" },
20464
+ { 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" },
20465
+ { 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" }
20466
+ ];
20337
20467
  var SCHEMA = {
20338
20468
  customer: {
20339
20469
  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
20470
  fields: [
20341
20471
  { 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: "\u6240\u5728\u516C\u53F8\u6216\u7EC4\u7EC7" },
20343
- { name: "title", type: "string", guide: "\u804C\u4F4D\u6216\u8EAB\u4EFD" },
20472
+ { 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" },
20473
+ { 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
20474
  { 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
20475
  { name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199" },
20346
20476
  {
@@ -20355,6 +20485,18 @@ var SCHEMA = {
20355
20485
  values: RELATIONSHIPS,
20356
20486
  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
20487
  },
20488
+ {
20489
+ name: "orgs",
20490
+ type: "object[]",
20491
+ fields: orgFields,
20492
+ 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"
20493
+ },
20494
+ {
20495
+ name: "relatedPeople",
20496
+ type: "object[]",
20497
+ fields: relatedFields,
20498
+ 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"
20499
+ },
20358
20500
  { 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
20501
  { 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
20502
  { name: "goals", type: "string[]", guide: "\u77ED\u671F\u76EE\u6807\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD" },
@@ -20448,7 +20590,7 @@ function renderPrompt(text, customer) {
20448
20590
  // package.json
20449
20591
  var package_default = {
20450
20592
  name: "insightcrm",
20451
- version: "0.1.7",
20593
+ version: "0.1.9",
20452
20594
  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
20595
  license: "MIT",
20454
20596
  type: "module",
@@ -20560,6 +20702,34 @@ function createClient(apiUrl, token) {
20560
20702
  };
20561
20703
  }
20562
20704
 
20705
+ // src/org.ts
20706
+ function parseOrg(s) {
20707
+ const parts = s.split(":").map((p) => p.trim());
20708
+ const org = parts[0] ?? "";
20709
+ 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);
20710
+ if (parts.length === 1) return { org, status: "unknown" };
20711
+ if (parts.length === 2) {
20712
+ const second = parts[1];
20713
+ return isKnownOrgStatus(second) ? { org, status: second } : { org, role: second, status: "unknown" };
20714
+ }
20715
+ const role = parts.slice(1, -1).join(":");
20716
+ const status = parts[parts.length - 1];
20717
+ return { org, ...role ? { role } : {}, status };
20718
+ }
20719
+ var orgKey = (o) => JSON.stringify([o.org, o.status]);
20720
+
20721
+ // src/related.ts
20722
+ function parseRelated(s) {
20723
+ const parts = s.split(":").map((p) => p.trim());
20724
+ const name = parts[0] ?? "";
20725
+ 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);
20726
+ const relation = parts[1] ?? "";
20727
+ 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);
20728
+ const note = parts.length > 2 ? parts.slice(2).join(":").trim() : "";
20729
+ return { name, relation, ...note ? { note } : {} };
20730
+ }
20731
+ var relatedKey = (p) => JSON.stringify([p.name, p.relation]);
20732
+
20563
20733
  // src/prompts.ts
20564
20734
  import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
20565
20735
  import path2 from "path";
@@ -20725,7 +20895,11 @@ Examples:
20725
20895
  $ echo '{"name":"Wang Ming","company":"ACME","conversionPotential":"High"}' | crm add - --json
20726
20896
  $ crm add --name "\u738B\u5C0F\u660E" --social channels:@san3 email:wang@example.com --json
20727
20897
  $ crm add --name "\u738B\u5C0F\u660E" --relationship \u5B66\u5458 --relationship \u793E\u7FA4\u6210\u5458 --json
20898
+ $ 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
20899
  $ crm list --potential high --city Beijing --due-today --json
20900
+ $ crm list --org \u540C\u6D4E --json
20901
+ $ crm add --name "\u738B\u5C0F\u660E" --related "\u674E\u96C5\u5A77:\u8F6C\u4ECB\u7ECD\u4EBA" "\u67F4\u8001\u5E08:\u5BFC\u5E08" --json
20902
+ $ crm list --related \u674E\u96C5\u5A77 --json
20729
20903
  $ crm update 3f2a\u2026 --summary "Needs a quote by Friday" --json
20730
20904
  $ crm hook add --title "Opened with a peer case" --desc "Led with a competitor's result, then asked about theirs" --customer 3f2a\u2026
20731
20905
  $ crm export -o backup.json`
@@ -20803,9 +20977,9 @@ function parseSocial(s) {
20803
20977
  return { platform: platform2, handle };
20804
20978
  }
20805
20979
  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)" : ""}`);
20980
+ 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)" : ""}`);
20807
20981
  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");
20982
+ 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");
20809
20983
  } else {
20810
20984
  cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
20811
20985
  }
@@ -20836,6 +21010,8 @@ function buildCustomerBody(base, o) {
20836
21010
  if (o.clearEvents) body.upcomingEvents = [];
20837
21011
  if (o.social) body.socials = o.social.map(parseSocial);
20838
21012
  if (o.relationship) body.relationships = o.relationship;
21013
+ if (o.org) body.orgs = o.org.map(parseOrg);
21014
+ if (o.related) body.relatedPeople = o.related.map(parseRelated);
20839
21015
  if (o.hookTitle || o.hookDesc) {
20840
21016
  if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
20841
21017
  body.socialHook = { title: o.hookTitle, description: o.hookDesc };
@@ -20853,6 +21029,8 @@ function detail(c) {
20853
21029
  ["wechat", c.wechatId ?? ""],
20854
21030
  ["socials", c.socials.map((s) => `${s.platform}: ${s.handle}${s.url ? ` (${s.url})` : ""}`).join("; ")],
20855
21031
  ["relationship", c.relationships.map((r) => relationshipLabel(r, "zh")).join(", ")],
21032
+ ["orgs", (c.orgs ?? []).map((o) => `${o.org}${o.role ? ` \xB7 ${o.role}` : ""} [${orgStatusLabel(o.status, "zh")}]`).join("; ")],
21033
+ ["related", (c.relatedPeople ?? []).map((p) => `${p.name} \xB7 ${p.relation}${p.note ? `\uFF08${p.note}\uFF09` : ""}`).join("; ")],
20856
21034
  ["potential", c.conversionPotential],
20857
21035
  ["cycle days", String(c.conversionCycleDays)],
20858
21036
  ["pain points", c.painPoints.join(", ")],
@@ -20997,12 +21175,12 @@ withCustomerOptions(
20997
21175
  out(`Created ${line(customer)}`, { customer, created: true });
20998
21176
  });
20999
21177
  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"),
21178
+ 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"),
21001
21179
  true
21002
21180
  ).action(async (id, src, o) => {
21003
21181
  const api = await client();
21004
21182
  const body = buildCustomerBody(await readJsonInput(src), o);
21005
- if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship) {
21183
+ if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship || o.addOrg || o.addRelated) {
21006
21184
  const { customer: cur } = await api.getCustomer(id);
21007
21185
  if (o.addPain) body.painPoints = [.../* @__PURE__ */ new Set([...body.painPoints ?? cur.painPoints, ...o.addPain])];
21008
21186
  if (o.addGoal) body.goals = [.../* @__PURE__ */ new Set([...body.goals ?? cur.goals, ...o.addGoal])];
@@ -21017,6 +21195,16 @@ withCustomerOptions(
21017
21195
  const existing = body.relationships ?? cur.relationships;
21018
21196
  body.relationships = [...existing, ...o.addRelationship.filter((r) => !existing.includes(r))];
21019
21197
  }
21198
+ if (o.addOrg) {
21199
+ const added = o.addOrg.map(parseOrg);
21200
+ const existing = body.orgs ?? cur.orgs;
21201
+ body.orgs = [...existing, ...added.filter((x) => !existing.some((e) => orgKey(e) === orgKey(x)))];
21202
+ }
21203
+ if (o.addRelated) {
21204
+ const added = o.addRelated.map(parseRelated);
21205
+ const existing = body.relatedPeople ?? cur.relatedPeople;
21206
+ body.relatedPeople = [...existing, ...added.filter((x) => !existing.some((e) => relatedKey(e) === relatedKey(x)))];
21207
+ }
21020
21208
  }
21021
21209
  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
21210
  const { customer } = await api.updateCustomer(id, body);
@@ -21026,7 +21214,7 @@ program.command("get").description("Show one customer").argument("<id>").action(
21026
21214
  const { customer } = await (await client()).getCustomer(id);
21027
21215
  out(detail(customer), { customer });
21028
21216
  });
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) => {
21217
+ 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("-q, --query <s>", "keyword across name, company, title, city, wechat, social accounts, relationships, organizations, related people, summary, notes, tags, goals").action(async (o) => {
21030
21218
  const { customers } = await (await client()).listCustomers({
21031
21219
  potential: o.potential ? potentialOf(o.potential) : void 0,
21032
21220
  city: o.city,
@@ -21034,6 +21222,8 @@ program.command("list").description("List customers (newest update first), optio
21034
21222
  q: o.query,
21035
21223
  socialPlatform: o.socialPlatform,
21036
21224
  relationship: o.relationship,
21225
+ org: o.org,
21226
+ related: o.related,
21037
21227
  dueOn: o.dueToday ? today() : o.due
21038
21228
  });
21039
21229
  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.7",
3
+ "version": "0.1.9",
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",