insightcrm 0.1.4 → 0.1.6

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
@@ -9,6 +9,9 @@ npm i -g insightcrm # 得到 insightcrm 和 crm 两个命令(crm 是别
9
9
  crm login https://<你的服务器> # 浏览器里点「允许」(设备码登录)
10
10
  crm schema --json # 字段契约,含每个字段的填写指引
11
11
  echo '{"name":"王小明","company":"ACME"}' | crm add - --json
12
+ crm add --name "王小明" --social channels:@wm email:wm@example.com # 视频号 / 小红书 / 邮箱等社交账号
13
+ crm add --name "王小明" --relationship 学员 社群成员 # 他在你这里是什么身份(可多个)
14
+ crm list --relationship 甲方 --json # 甲方名单
12
15
  crm list --due-today --json
13
16
  crm version # 当前版本 + npm 上有没有新版
14
17
  crm skill # 打印给 agent 的使用说明;在 agent 指令里加一句「先运行 crm skill」
package/SKILL.md CHANGED
@@ -46,14 +46,28 @@ crm login https://<服务器地址>
46
46
  - `conversionPotential`:`High` / `Medium` / `Low`。综合痛点的紧迫度、预算信号、对方的决策角色来判断,拿不准填 `Medium`。
47
47
  - `conversionCycleDays`:预估的转化黄金窗口(天)。信号越弱越长,信号明确可以短到 7–14 天。
48
48
 
49
+ **社交账号 `socials`**:客户在其他平台上的号——视频号、小红书、邮箱、抖音、B站、公众号等。
50
+ - 元素形如 `{"platform":"channels","handle":"@san三"}`。`platform` 直接写中文也行(`视频号`、`小红书`、`邮箱`),会自动归一化到标准值。
51
+ - **微信不要放这里**,微信号统一写 `wechatId`。
52
+ - 有主页链接就补 `"url"`,没有就省略,不要猜。
53
+ - 材料里没出现就整条省略,**不要编造**。邮箱也是:只在材料里明确写了邮箱才填。
54
+ - 命令行写法:`--social channels:@san三 email:zhang@example.com`(平台:账号)。
55
+
56
+ **关系 `relationships`**:这个人在我这里是什么身份——甲方 / 渠道方 / 学员 / 社群成员……
57
+ - **可以同时多个**,按重要性从高到低(第一个是当前最主要的关系)。写中文就行(`甲方`、`学员`、`渠道方`),会自动归一化;也可以写英文键(`client`、`student`、`channel`)。
58
+ - 常见路径:潜客 → 意向学员 → 学员 → 校友 → 意向甲方 → 甲方。
59
+ - **微信标签里写明的身份最硬**(「AI编程 N23 期学员」就是学员)。注意区分:职位(产品经理、老师)不是关系,别混进 `title` 和 `relationships`。
60
+ - 转化了**追加**新关系,别删旧的——学员变甲方,两个都留着,路径才追得回。
61
+ - 没有依据就留空,不要编。命令行写法:`--relationship 学员 甲方`。
62
+
49
63
  **日程 `upcomingEvents`**:`{title, date, type}` 的数组,`date` 是 `YYYY-MM-DD`,`type` 是 `meeting` / `follow_up` / `deadline` / `other`。
50
64
  - 今天是几号要自己确认,相对日期(「下周三」)按今天换算成具体日期。
51
65
  - **已经过去的日期不要录**。
52
66
  - 没有明确日期的约定不要编日期。
53
67
 
54
68
  **按材料类型**:
55
- - **朋友圈 / 社交平台截图**:重点抽**兴趣和需求**,写进 `painPoints` 和 `summary`。
56
- - **名片**:重点是身份(`name` / `company` / `title`),别的字段通常没有。
69
+ - **朋友圈 / 社交平台截图**:重点抽**兴趣和需求**,写进 `painPoints` 和 `summary`;截图里露出的账号信息(小红书号、抖音号、邮箱)写进 `socials`。
70
+ - **名片**:重点是身份(`name` / `company` / `title`),名片上的邮箱写进 `socials`(`platform` 用 `email`)。
57
71
  - **聊天记录**:除了画像,还要找**钩子**(见下)。
58
72
 
59
73
  ## 成功钩子
@@ -72,12 +86,14 @@ crm login https://<服务器地址>
72
86
 
73
87
  | 想做的事 | 用 |
74
88
  |---|---|
75
- | 在已有基础上**追加**标签 / 目标 / 日程 | `--add-pain` / `--add-goal` / `--add-event` |
76
- | **整体替换**整个列表 | `--pain` / `--goal` / `--event`,或 JSON 里直接传数组 |
89
+ | 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` |
90
+ | **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship`,或 JSON 里直接传数组 |
77
91
  | 清空日程 | `--clear-events` |
78
92
 
79
93
  `upcomingEvents` 在 JSON 里传了就是**整体替换**。只想加一个日程,用 `--add-event 2026-10-25:deadline:报价截止`,不要把一个事件的数组传上去把旧的冲掉。
80
94
 
95
+ `socials` 同理:传了就是**整体替换**。只想补一个号,用 `--add-social channels:@san三`。
96
+
81
97
  `summary` 是对这个客户的整体描述。合并新材料时,是在原有摘要上补充,不是整段覆盖掉已有的信息:先 `crm get <id> --json` 读出旧内容再写。
82
98
 
83
99
  ## 查询
@@ -86,7 +102,9 @@ crm login https://<服务器地址>
86
102
  crm list --potential high --city 北京 --json # 按等级、城市、标签筛选
87
103
  crm list --due-today --json # 今天有日程的客户(今天要联系谁)
88
104
  crm list --due 2026-10-20 --json
89
- crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、摘要、备注、标签、目标
105
+ crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、摘要、备注、标签、目标
106
+ crm list --social-platform xiaohongshu --json # 有小红书账号的客户
107
+ crm list --relationship 甲方 --json # 甲方名单(写 client 一样命中)
90
108
  crm get <id> --json
91
109
  ```
92
110
 
@@ -118,6 +136,8 @@ crm prompts show gift --customer <id> --json # --json 里带上 customer 档
118
136
 
119
137
  内置的任务模板:`draft`(起草消息)、`gift`(送礼策略)、`starters`(社交破冰)、`advice`(关系升温)。用户让你「给王小明起草一条消息」「想想送什么礼物」这类事时,先 `show` 对应模板再照着做;模板里带 `[请补充]` 的地方要向用户问清楚或自己补全。
120
138
 
139
+ 可用占位符:`{{name}}` `{{company}}` `{{title}}` `{{city}}` `{{wechatId}}` `{{socials}}`(社交账号,渲染成「视频号: @san3, 邮箱: san@example.com」这样的一行)。
140
+
121
141
  用户想改模板时:
122
142
 
123
143
  ```bash
package/dist/cli.js CHANGED
@@ -113,6 +113,58 @@ var CITIES = [
113
113
  "\u8FEA\u62DC",
114
114
  "\u67CF\u6797"
115
115
  ];
116
+ var SOCIAL_PLATFORMS = [
117
+ "email",
118
+ // 邮箱
119
+ "channels",
120
+ // 视频号
121
+ "xiaohongshu",
122
+ // 小红书
123
+ "douyin",
124
+ // 抖音
125
+ "weibo",
126
+ // 微博
127
+ "bilibili",
128
+ // B站
129
+ "zhihu",
130
+ // 知乎
131
+ "mp",
132
+ // 公众号
133
+ "linkedin",
134
+ // LinkedIn
135
+ "website",
136
+ // 个人网站
137
+ "other"
138
+ // 其他
139
+ ];
140
+ var RELATIONSHIPS = [
141
+ "lead",
142
+ // 潜客:泛线索,还看不出要什么
143
+ "student_intent",
144
+ // 意向学员:问价、想报名,还没付款
145
+ "student",
146
+ // 学员:在册
147
+ "alumni",
148
+ // 校友:学过 / 结业
149
+ "prospect_client",
150
+ // 意向甲方:有明确需求与预算,还没签约
151
+ "client",
152
+ // 甲方:已付费的 B2B 客户(含内训甲方、陪跑甲方)
153
+ "channel",
154
+ // 渠道方:带单、分销、联合办课
155
+ "partner",
156
+ // 合伙人:合作项目、联合孵化
157
+ "member",
158
+ // 社群成员
159
+ "supplier",
160
+ // 服务方:给我干活的外包、乙方
161
+ "mentor",
162
+ // 前辈:介绍资源、给建议
163
+ "friend",
164
+ // 个人关系:朋友、私交
165
+ "other"
166
+ // 其他
167
+ ];
116
168
  var EXIT = {
117
169
  ok: 0,
118
170
  error: 1,
@@ -278,6 +330,201 @@ function normalizeCity(input2) {
278
330
  return cleaned;
279
331
  }
280
332
 
333
+ // ../shared/src/social.ts
334
+ var SOCIAL_PLATFORM_ALIASES = {
335
+ // 邮箱
336
+ email: "email",
337
+ mail: "email",
338
+ "e-mail": "email",
339
+ \u90AE\u7BB1: "email",
340
+ \u90AE\u4EF6: "email",
341
+ \u7535\u5B50\u90AE\u4EF6: "email",
342
+ // 视频号
343
+ channels: "channels",
344
+ wechat_channels: "channels",
345
+ \u89C6\u9891\u53F7: "channels",
346
+ \u5FAE\u4FE1\u89C6\u9891\u53F7: "channels",
347
+ // 小红书
348
+ xiaohongshu: "xiaohongshu",
349
+ xhs: "xiaohongshu",
350
+ red: "xiaohongshu",
351
+ \u5C0F\u7EA2\u4E66: "xiaohongshu",
352
+ // 抖音
353
+ douyin: "douyin",
354
+ \u6296\u97F3: "douyin",
355
+ // 微博
356
+ weibo: "weibo",
357
+ \u5FAE\u535A: "weibo",
358
+ // B站
359
+ bilibili: "bilibili",
360
+ bili: "bilibili",
361
+ b\u7AD9: "bilibili",
362
+ \u54D4\u54E9\u54D4\u54E9: "bilibili",
363
+ // 知乎
364
+ zhihu: "zhihu",
365
+ \u77E5\u4E4E: "zhihu",
366
+ // 公众号
367
+ mp: "mp",
368
+ wechat_mp: "mp",
369
+ \u516C\u4F17\u53F7: "mp",
370
+ \u8BA2\u9605\u53F7: "mp",
371
+ \u5FAE\u4FE1\u516C\u4F17\u53F7: "mp",
372
+ // LinkedIn
373
+ linkedin: "linkedin",
374
+ \u9886\u82F1: "linkedin",
375
+ // 个人网站
376
+ website: "website",
377
+ \u7F51\u7AD9: "website",
378
+ \u5B98\u7F51: "website",
379
+ \u535A\u5BA2: "website",
380
+ blog: "website",
381
+ // 其他
382
+ other: "other",
383
+ \u5176\u4ED6: "other"
384
+ };
385
+ var LOOKUP2 = /* @__PURE__ */ new Map();
386
+ for (const p of SOCIAL_PLATFORMS) LOOKUP2.set(p.toLowerCase(), p);
387
+ for (const [alias, canonical] of Object.entries(SOCIAL_PLATFORM_ALIASES)) LOOKUP2.set(alias.toLowerCase(), canonical);
388
+ var CONTAINS_KEYS = [...LOOKUP2.keys()].filter((k) => /[^\x00-\x7F]/.test(k)).sort((a, b) => b.length - a.length);
389
+ function normalizeSocialPlatform(input2) {
390
+ if (!input2) return "";
391
+ const cleaned = input2.replace(/[ \s]+/g, " ").trim();
392
+ if (!cleaned) return "";
393
+ const hit = LOOKUP2.get(cleaned.toLowerCase());
394
+ if (hit) return hit;
395
+ const compact = cleaned.replace(/\s+/g, "");
396
+ for (const key of CONTAINS_KEYS) {
397
+ if (compact.includes(key)) return LOOKUP2.get(key);
398
+ }
399
+ return cleaned;
400
+ }
401
+ var SOCIAL_PLATFORM_LABELS = {
402
+ email: { zh: "\u90AE\u7BB1", en: "Email" },
403
+ channels: { zh: "\u89C6\u9891\u53F7", en: "Channels" },
404
+ xiaohongshu: { zh: "\u5C0F\u7EA2\u4E66", en: "Xiaohongshu" },
405
+ douyin: { zh: "\u6296\u97F3", en: "Douyin" },
406
+ weibo: { zh: "\u5FAE\u535A", en: "Weibo" },
407
+ bilibili: { zh: "B\u7AD9", en: "Bilibili" },
408
+ zhihu: { zh: "\u77E5\u4E4E", en: "Zhihu" },
409
+ mp: { zh: "\u516C\u4F17\u53F7", en: "WeChat MP" },
410
+ linkedin: { zh: "\u9886\u82F1", en: "LinkedIn" },
411
+ website: { zh: "\u4E2A\u4EBA\u7F51\u7AD9", en: "Website" },
412
+ other: { zh: "\u5176\u4ED6", en: "Other" }
413
+ };
414
+ function socialPlatformLabel(platform2, lang = "zh") {
415
+ return SOCIAL_PLATFORM_LABELS[platform2]?.[lang] ?? platform2;
416
+ }
417
+
418
+ // ../shared/src/relationship.ts
419
+ var RELATIONSHIP_ALIASES = {
420
+ // 潜客
421
+ lead: "lead",
422
+ \u6F5C\u5BA2: "lead",
423
+ \u7EBF\u7D22: "lead",
424
+ // 意向学员
425
+ student_intent: "student_intent",
426
+ potential_student: "student_intent",
427
+ \u610F\u5411\u5B66\u5458: "student_intent",
428
+ \u5B66\u5458\u610F\u5411: "student_intent",
429
+ \u51C6\u5B66\u5458: "student_intent",
430
+ \u60F3\u62A5\u540D: "student_intent",
431
+ // 学员
432
+ student: "student",
433
+ \u5B66\u5458: "student",
434
+ \u5B66\u751F: "student",
435
+ \u5728\u518C\u5B66\u5458: "student",
436
+ \u6B63\u5F0F\u5B66\u5458: "student",
437
+ // 校友
438
+ alumni: "alumni",
439
+ graduate: "alumni",
440
+ \u6821\u53CB: "alumni",
441
+ \u6BD5\u4E1A\u751F: "alumni",
442
+ \u7ED3\u4E1A\u5B66\u5458: "alumni",
443
+ \u8001\u5B66\u5458: "alumni",
444
+ \u5F80\u5C4A\u5B66\u5458: "alumni",
445
+ // 意向甲方
446
+ prospect_client: "prospect_client",
447
+ potential_client: "prospect_client",
448
+ \u610F\u5411\u7532\u65B9: "prospect_client",
449
+ \u6F5C\u5728\u7532\u65B9: "prospect_client",
450
+ \u610F\u5411\u5BA2\u6237: "prospect_client",
451
+ \u5F85\u7B7E\u5BA2\u6237: "prospect_client",
452
+ // 甲方
453
+ client: "client",
454
+ customer: "client",
455
+ \u7532\u65B9: "client",
456
+ \u5BA2\u6237: "client",
457
+ \u5BA2\u6237\u65B9: "client",
458
+ \u5DF2\u7B7E\u7EA6: "client",
459
+ // 渠道方
460
+ channel: "channel",
461
+ \u6E20\u9053\u65B9: "channel",
462
+ \u6E20\u9053: "channel",
463
+ \u6E20\u9053\u4F19\u4F34: "channel",
464
+ \u5206\u9500\u65B9: "channel",
465
+ \u4EE3\u7406: "channel",
466
+ // 合伙人
467
+ partner: "partner",
468
+ \u5408\u4F19\u4EBA: "partner",
469
+ \u5408\u4F5C\u65B9: "partner",
470
+ \u5408\u4F5C\u4F19\u4F34: "partner",
471
+ \u8054\u5408\u521B\u59CB\u4EBA: "partner",
472
+ // 社群成员
473
+ member: "member",
474
+ \u793E\u7FA4\u6210\u5458: "member",
475
+ \u7FA4\u53CB: "member",
476
+ \u793E\u533A\u6210\u5458: "member",
477
+ \u793E\u7FA4: "member",
478
+ // 服务方
479
+ supplier: "supplier",
480
+ vendor: "supplier",
481
+ \u670D\u52A1\u65B9: "supplier",
482
+ \u4F9B\u5E94\u5546: "supplier",
483
+ \u5916\u5305\u65B9: "supplier",
484
+ \u4E59\u65B9: "supplier",
485
+ // 前辈
486
+ mentor: "mentor",
487
+ \u524D\u8F88: "mentor",
488
+ \u5BFC\u5E08: "mentor",
489
+ \u987E\u95EE: "mentor",
490
+ // 个人关系
491
+ friend: "friend",
492
+ \u670B\u53CB: "friend",
493
+ \u4E2A\u4EBA\u5173\u7CFB: "friend",
494
+ \u79C1\u4EA4: "friend",
495
+ // 其他
496
+ other: "other",
497
+ \u5176\u4ED6: "other",
498
+ \u5176\u5B83: "other"
499
+ };
500
+ var LOOKUP3 = /* @__PURE__ */ new Map();
501
+ for (const r of RELATIONSHIPS) LOOKUP3.set(r.toLowerCase(), r);
502
+ for (const [alias, canonical] of Object.entries(RELATIONSHIP_ALIASES)) LOOKUP3.set(alias.toLowerCase(), canonical);
503
+ function normalizeRelationship(input2) {
504
+ if (!input2) return "";
505
+ const cleaned = input2.replace(/[ \s]+/g, " ").trim();
506
+ if (!cleaned) return "";
507
+ return LOOKUP3.get(cleaned.toLowerCase()) ?? cleaned;
508
+ }
509
+ var RELATIONSHIP_LABELS = {
510
+ lead: { zh: "\u6F5C\u5BA2", en: "Lead" },
511
+ student_intent: { zh: "\u610F\u5411\u5B66\u5458", en: "Prospective student" },
512
+ student: { zh: "\u5B66\u5458", en: "Student" },
513
+ alumni: { zh: "\u6821\u53CB", en: "Alumni" },
514
+ prospect_client: { zh: "\u610F\u5411\u7532\u65B9", en: "Prospective client" },
515
+ client: { zh: "\u7532\u65B9", en: "Client" },
516
+ channel: { zh: "\u6E20\u9053\u65B9", en: "Channel partner" },
517
+ partner: { zh: "\u5408\u4F19\u4EBA", en: "Partner" },
518
+ member: { zh: "\u793E\u7FA4\u6210\u5458", en: "Community member" },
519
+ supplier: { zh: "\u670D\u52A1\u65B9", en: "Supplier" },
520
+ mentor: { zh: "\u524D\u8F88", en: "Mentor" },
521
+ friend: { zh: "\u4E2A\u4EBA\u5173\u7CFB", en: "Friend" },
522
+ other: { zh: "\u5176\u4ED6", en: "Other" }
523
+ };
524
+ function relationshipLabel(relationship, lang = "zh") {
525
+ return RELATIONSHIP_LABELS[relationship]?.[lang] ?? relationship;
526
+ }
527
+
281
528
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
282
529
  var external_exports = {};
283
530
  __export(external_exports, {
@@ -20000,6 +20247,11 @@ var short = (max) => external_exports.string().trim().max(max);
20000
20247
  var tags = external_exports.array(external_exports.string().trim().min(1).max(200)).max(50);
20001
20248
  var isoDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "YYYY-MM-DD");
20002
20249
  var city = external_exports.string().trim().max(100).transform(normalizeCity);
20250
+ var socialLink = external_exports.object({
20251
+ platform: external_exports.string().trim().min(1).max(50).transform(normalizeSocialPlatform),
20252
+ handle: external_exports.string().trim().min(1).max(200),
20253
+ url: external_exports.string().trim().max(2e3).nullable().optional()
20254
+ });
20003
20255
  var eventInput = external_exports.object({
20004
20256
  title: short(200).min(1),
20005
20257
  date: isoDate,
@@ -20015,6 +20267,10 @@ var customerShape = {
20015
20267
  title: short(200),
20016
20268
  city,
20017
20269
  wechatId: short(100).nullable(),
20270
+ /** 其他社交账号(视频号 / 小红书 / 邮箱…)。整体替换:传了就用这组覆盖旧的 */
20271
+ socials: external_exports.array(socialLink).max(50),
20272
+ /** 关系:这个人是谁。可以多个,按重要性从高到低。整体替换 */
20273
+ relationships: external_exports.array(external_exports.string().trim().min(1).max(50).transform(normalizeRelationship)).max(20),
20018
20274
  summary: short(5e3),
20019
20275
  painPoints: tags,
20020
20276
  goals: tags,
@@ -20057,6 +20313,17 @@ var hookFields = [
20057
20313
  { name: "title", type: "string", required: true, guide: "\u94A9\u5B50\u540D\u79F0\uFF0C\u4E00\u53E5\u8BDD\u6982\u62EC\uFF0C\u5982\u300C\u7528\u884C\u4E1A\u5BF9\u6807\u6848\u4F8B\u5F00\u573A\u300D" },
20058
20314
  { name: "description", type: "string", required: true, guide: "\u53EF\u590D\u7528\u7684\u5177\u4F53\u8BDD\u672F\u6216\u903B\u8F91\uFF0C\u5199\u6E05\u695A\u4E3A\u4EC0\u4E48\u6709\u6548\uFF0C\u8BA9\u522B\u7684\u5BA2\u6237\u573A\u666F\u4E5F\u80FD\u7167\u7740\u7528" }
20059
20315
  ];
20316
+ var socialFields = [
20317
+ {
20318
+ name: "platform",
20319
+ type: "enum",
20320
+ required: true,
20321
+ values: SOCIAL_PLATFORMS,
20322
+ 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\u4E0D\u8981\u653E\u8FD9\u91CC\uFF0C\u5FAE\u4FE1\u53F7\u5199 wechatId\u3002"
20323
+ },
20324
+ { 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" },
20325
+ { 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" }
20326
+ ];
20060
20327
  var SCHEMA = {
20061
20328
  customer: {
20062
20329
  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",
@@ -20066,6 +20333,18 @@ var SCHEMA = {
20066
20333
  { name: "title", type: "string", guide: "\u804C\u4F4D\u6216\u8EAB\u4EFD" },
20067
20334
  { 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" },
20068
20335
  { name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199" },
20336
+ {
20337
+ name: "socials",
20338
+ type: "object[]",
20339
+ fields: socialFields,
20340
+ guide: "\u5BA2\u6237\u7684\u5176\u4ED6\u793E\u4EA4\u8D26\u53F7\uFF1A\u89C6\u9891\u53F7\u3001\u5C0F\u7EA2\u4E66\u3001\u90AE\u7BB1\u3001\u6296\u97F3\u3001B\u7AD9\u7B49\u3002\u5143\u7D20\u5F62\u5982 {platform:'channels', handle:'@san\u4E09'}\u3002\u53EA\u5728\u6750\u6599\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\uFF0C\u6CA1\u6709\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"
20341
+ },
20342
+ {
20343
+ name: "relationships",
20344
+ type: "string[]",
20345
+ values: RELATIONSHIPS,
20346
+ 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"
20347
+ },
20069
20348
  { 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" },
20070
20349
  { 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" },
20071
20350
  { name: "goals", type: "string[]", guide: "\u77ED\u671F\u76EE\u6807\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD" },
@@ -20151,14 +20430,15 @@ var DEFAULT_PROMPTS = [
20151
20430
  function renderPrompt(text, customer) {
20152
20431
  return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (whole, key) => {
20153
20432
  const v = customer?.[key];
20154
- return v ? v : whole;
20433
+ if (!v || Array.isArray(v) && v.length === 0) return whole;
20434
+ return Array.isArray(v) ? v.join(", ") : v;
20155
20435
  });
20156
20436
  }
20157
20437
 
20158
20438
  // package.json
20159
20439
  var package_default = {
20160
20440
  name: "insightcrm",
20161
- version: "0.1.4",
20441
+ version: "0.1.6",
20162
20442
  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.",
20163
20443
  license: "MIT",
20164
20444
  type: "module",
@@ -20433,6 +20713,8 @@ Examples:
20433
20713
  $ crm login https://crm.example.com
20434
20714
  $ crm schema --json
20435
20715
  $ echo '{"name":"Wang Ming","company":"ACME","conversionPotential":"High"}' | crm add - --json
20716
+ $ crm add --name "\u738B\u5C0F\u660E" --social channels:@san3 email:wang@example.com --json
20717
+ $ crm add --name "\u738B\u5C0F\u660E" --relationship \u5B66\u5458 --relationship \u793E\u7FA4\u6210\u5458 --json
20436
20718
  $ crm list --potential high --city Beijing --due-today --json
20437
20719
  $ crm update 3f2a\u2026 --summary "Needs a quote by Friday" --json
20438
20720
  $ crm hook add --title "Opened with a peer case" --desc "Led with a competitor's result, then asked about theirs" --customer 3f2a\u2026
@@ -20503,10 +20785,17 @@ var potentialOf = (v) => {
20503
20785
  if (!CONVERSION_POTENTIALS.includes(p)) throw new CliError("usage", `--potential must be one of ${CONVERSION_POTENTIALS.join(", ")}`, EXIT.usage);
20504
20786
  return p;
20505
20787
  };
20788
+ function parseSocial(s) {
20789
+ const at = s.indexOf(":");
20790
+ const platform2 = at === -1 ? "" : s.slice(0, at).trim();
20791
+ const handle = at === -1 ? "" : s.slice(at + 1).trim();
20792
+ if (!platform2 || !handle) throw new CliError("usage", `Can't read social "${s}". Use platform:handle, e.g. channels:@san or email:zhang@example.com`, EXIT.usage);
20793
+ return { platform: platform2, handle };
20794
+ }
20506
20795
  function withCustomerOptions(cmd, forUpdate) {
20507
- 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)" : ""}`);
20796
+ 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)" : ""}`);
20508
20797
  if (forUpdate) {
20509
- 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("--clear-events", "remove all calendar events");
20798
+ 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");
20510
20799
  } else {
20511
20800
  cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
20512
20801
  }
@@ -20535,6 +20824,8 @@ function buildCustomerBody(base, o) {
20535
20824
  if (o.goal) body.goals = o.goal;
20536
20825
  if (o.event) body.upcomingEvents = o.event.map(parseEvent);
20537
20826
  if (o.clearEvents) body.upcomingEvents = [];
20827
+ if (o.social) body.socials = o.social.map(parseSocial);
20828
+ if (o.relationship) body.relationships = o.relationship;
20538
20829
  if (o.hookTitle || o.hookDesc) {
20539
20830
  if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
20540
20831
  body.socialHook = { title: o.hookTitle, description: o.hookDesc };
@@ -20550,6 +20841,8 @@ function detail(c) {
20550
20841
  ["title", c.title],
20551
20842
  ["city", c.city],
20552
20843
  ["wechat", c.wechatId ?? ""],
20844
+ ["socials", c.socials.map((s) => `${s.platform}: ${s.handle}${s.url ? ` (${s.url})` : ""}`).join("; ")],
20845
+ ["relationship", c.relationships.map((r) => relationshipLabel(r, "zh")).join(", ")],
20553
20846
  ["potential", c.conversionPotential],
20554
20847
  ["cycle days", String(c.conversionCycleDays)],
20555
20848
  ["pain points", c.painPoints.join(", ")],
@@ -20694,16 +20987,26 @@ withCustomerOptions(
20694
20987
  out(`Created ${line(customer)}`, { customer, created: true });
20695
20988
  });
20696
20989
  withCustomerOptions(
20697
- program.command("update").description("Change a customer. Only the fields you pass change. --pain / --goal / --event REPLACE the list; --add-pain / --add-goal / --add-event append.").argument("<id>").argument("[json-file]", "JSON file, or - for stdin"),
20990
+ 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"),
20698
20991
  true
20699
20992
  ).action(async (id, src, o) => {
20700
20993
  const api = await client();
20701
20994
  const body = buildCustomerBody(await readJsonInput(src), o);
20702
- if (o.addPain || o.addGoal || o.addEvent) {
20995
+ if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship) {
20703
20996
  const { customer: cur } = await api.getCustomer(id);
20704
20997
  if (o.addPain) body.painPoints = [.../* @__PURE__ */ new Set([...body.painPoints ?? cur.painPoints, ...o.addPain])];
20705
20998
  if (o.addGoal) body.goals = [.../* @__PURE__ */ new Set([...body.goals ?? cur.goals, ...o.addGoal])];
20706
20999
  if (o.addEvent) body.upcomingEvents = [...body.upcomingEvents ?? cur.upcomingEvents.map(({ title, date: date5, type }) => ({ title, date: date5, type })), ...o.addEvent.map(parseEvent)];
21000
+ if (o.addSocial) {
21001
+ const added = o.addSocial.map(parseSocial);
21002
+ const key = (s) => JSON.stringify([s.platform, s.handle]);
21003
+ const existing = body.socials ?? cur.socials;
21004
+ body.socials = [...existing, ...added.filter((s) => !existing.some((e) => key(e) === key(s)))];
21005
+ }
21006
+ if (o.addRelationship) {
21007
+ const existing = body.relationships ?? cur.relationships;
21008
+ body.relationships = [...existing, ...o.addRelationship.filter((r) => !existing.includes(r))];
21009
+ }
20707
21010
  }
20708
21011
  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);
20709
21012
  const { customer } = await api.updateCustomer(id, body);
@@ -20713,12 +21016,14 @@ program.command("get").description("Show one customer").argument("<id>").action(
20713
21016
  const { customer } = await (await client()).getCustomer(id);
20714
21017
  out(detail(customer), { customer });
20715
21018
  });
20716
- 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("--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, summary, notes, tags, goals").action(async (o) => {
21019
+ 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) => {
20717
21020
  const { customers } = await (await client()).listCustomers({
20718
21021
  potential: o.potential ? potentialOf(o.potential) : void 0,
20719
21022
  city: o.city,
20720
21023
  tag: o.tag,
20721
21024
  q: o.query,
21025
+ socialPlatform: o.socialPlatform,
21026
+ relationship: o.relationship,
20722
21027
  dueOn: o.dueToday ? today() : o.due
20723
21028
  });
20724
21029
  out(customers.length ? customers.map(line).join("\n") : "No customers match.", { customers, count: customers.length });
@@ -20790,11 +21095,11 @@ prompts.command("list").description("List templates. `customized` marks the ones
20790
21095
  { prompts: list, path: promptsPath }
20791
21096
  );
20792
21097
  });
20793
- prompts.command("show").description("Print a template. With --customer, {{name}} {{company}} {{title}} {{city}} {{wechatId}} are filled in from that customer (and --json includes the customer profile as context).").argument("<id>", "template id, see `crm prompts list`").option("--customer <id>", "fill the placeholders from this customer").addOption(langOption()).action(async (id, o) => {
21098
+ prompts.command("show").description("Print a template. With --customer, {{name}} {{company}} {{title}} {{city}} {{wechatId}} {{socials}} are filled in from that customer (and --json includes the customer profile as context).").argument("<id>", "template id, see `crm prompts list`").option("--customer <id>", "fill the placeholders from this customer").addOption(langOption()).action(async (id, o) => {
20794
21099
  const p = resolvePrompts(langOf(o), await loadCustom()).find((x) => x.id === id);
20795
21100
  if (!p) throw new CliError("not_found", `No template "${id}". Run \`crm prompts list\``, EXIT.usage);
20796
21101
  const customer = o.customer ? (await (await client()).getCustomer(o.customer)).customer : void 0;
20797
- const rendered = renderPrompt(p.prompt, customer);
21102
+ const rendered = renderPrompt(p.prompt, customer && { ...customer, socials: customer.socials.map((s) => `${socialPlatformLabel(s.platform, langOf(o))}: ${s.handle}`) });
20798
21103
  out(rendered, { id: p.id, kind: p.kind, label: p.label, prompt: rendered, template: p.prompt, customized: p.customized, ...customer ? { customer } : {} });
20799
21104
  });
20800
21105
  prompts.command("set").description("Change a built-in template or add your own. Text comes from --prompt, a file, or stdin (`-`). Saved on this machine only.").argument("<id>", "a built-in id (to override it) or a new id (letters, digits, - and _)").argument("[file]", "file with the template text, or - for stdin").option("--prompt <text>", "template text").option("--label <text>", "display name").action(async (id, src, o) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "insightcrm",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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",