insightcrm 0.1.4 → 0.1.7

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,16 +46,44 @@ 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
 
73
+ **图片材料以原图为准**:
74
+
75
+ 截图里的**名字、账号、地区、英文缩写**必须放大逐字核对再写进字段。导出工具附带的元数据(`chat.txt` 里的昵称、地区、关键词)是自动抽取的结果,**会错**:图上可能根本没有那个字段,也可能把 OPC 抽成 OPIC、把城市抽成「中国社会」。用户的口头转述同样可能沿用了错值,以图为准。
76
+
77
+ - 放大核对:先看尺寸,再裁出目标区域放大到能逐字辨认。
78
+ ```bash
79
+ sips -g pixelWidth -g pixelHeight screen.png
80
+ ffmpeg -i screen.png -vf "crop=290:120:0:0,scale=1160:480:flags=lanczos" out.png
81
+ ```
82
+ - 只在元数据里出现、原图上找不到的,写成「导出元数据记作 X(图片未佐证)」,别当成事实。
83
+ - **判断是不是同一个人,头像一致是最硬的证据**,比文字描述可靠;不同平台头像不同很正常,不要据此起疑。
84
+ - 性别、真实姓名这类「看起来像事实」的东西,原图上没有书面依据就不要写——微信名片、小红书主页、私信截图都不含性别信息,照片也认不出人,中文名尤其不能靠猜。
85
+ - 核对出旧档案写错了,回头改掉,并在 `notes` 里留一段**更正说明**写清原来错在哪、正确是什么,别静默改掉——错值留痕才知道当时错在哪。
86
+
59
87
  ## 成功钩子
60
88
 
61
89
  钩子 = 对话里**哪句话、哪个说法成功引起了对方的注意,或带来了正向回复**,以及为什么有效。它是跨客户复用的话术资产,是这个产品最有价值的数据。
@@ -72,12 +100,14 @@ crm login https://<服务器地址>
72
100
 
73
101
  | 想做的事 | 用 |
74
102
  |---|---|
75
- | 在已有基础上**追加**标签 / 目标 / 日程 | `--add-pain` / `--add-goal` / `--add-event` |
76
- | **整体替换**整个列表 | `--pain` / `--goal` / `--event`,或 JSON 里直接传数组 |
103
+ | 在已有基础上**追加**标签 / 目标 / 日程 / 社交账号 / 关系 | `--add-pain` / `--add-goal` / `--add-event` / `--add-social` / `--add-relationship` |
104
+ | **整体替换**整个列表 | `--pain` / `--goal` / `--event` / `--social` / `--relationship`,或 JSON 里直接传数组 |
77
105
  | 清空日程 | `--clear-events` |
78
106
 
79
107
  `upcomingEvents` 在 JSON 里传了就是**整体替换**。只想加一个日程,用 `--add-event 2026-10-25:deadline:报价截止`,不要把一个事件的数组传上去把旧的冲掉。
80
108
 
109
+ `socials` 同理:传了就是**整体替换**。只想补一个号,用 `--add-social channels:@san三`。
110
+
81
111
  `summary` 是对这个客户的整体描述。合并新材料时,是在原有摘要上补充,不是整段覆盖掉已有的信息:先 `crm get <id> --json` 读出旧内容再写。
82
112
 
83
113
  ## 查询
@@ -86,7 +116,9 @@ crm login https://<服务器地址>
86
116
  crm list --potential high --city 北京 --json # 按等级、城市、标签筛选
87
117
  crm list --due-today --json # 今天有日程的客户(今天要联系谁)
88
118
  crm list --due 2026-10-20 --json
89
- crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、摘要、备注、标签、目标
119
+ crm list -q 跨境 --json # 关键词:姓名、公司、职位、城市、微信、社交账号、摘要、备注、标签、目标
120
+ crm list --social-platform xiaohongshu --json # 有小红书账号的客户
121
+ crm list --relationship 甲方 --json # 甲方名单(写 client 一样命中)
90
122
  crm get <id> --json
91
123
  ```
92
124
 
@@ -118,6 +150,8 @@ crm prompts show gift --customer <id> --json # --json 里带上 customer 档
118
150
 
119
151
  内置的任务模板:`draft`(起草消息)、`gift`(送礼策略)、`starters`(社交破冰)、`advice`(关系升温)。用户让你「给王小明起草一条消息」「想想送什么礼物」这类事时,先 `show` 对应模板再照着做;模板里带 `[请补充]` 的地方要向用户问清楚或自己补全。
120
152
 
153
+ 可用占位符:`{{name}}` `{{company}}` `{{title}}` `{{city}}` `{{wechatId}}` `{{socials}}`(社交账号,渲染成「视频号: @san3, 邮箱: san@example.com」这样的一行)。
154
+
121
155
  用户想改模板时:
122
156
 
123
157
  ```bash
package/dist/cli.js CHANGED
@@ -113,6 +113,60 @@ 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
+ "guest",
160
+ // 访谈嘉宾:上过我的访谈节目
161
+ "supplier",
162
+ // 服务方:给我干活的外包、乙方
163
+ "mentor",
164
+ // 前辈:介绍资源、给建议
165
+ "friend",
166
+ // 个人关系:朋友、私交
167
+ "other"
168
+ // 其他
169
+ ];
116
170
  var EXIT = {
117
171
  ok: 0,
118
172
  error: 1,
@@ -278,6 +332,209 @@ function normalizeCity(input2) {
278
332
  return cleaned;
279
333
  }
280
334
 
335
+ // ../shared/src/social.ts
336
+ var SOCIAL_PLATFORM_ALIASES = {
337
+ // 邮箱
338
+ email: "email",
339
+ mail: "email",
340
+ "e-mail": "email",
341
+ \u90AE\u7BB1: "email",
342
+ \u90AE\u4EF6: "email",
343
+ \u7535\u5B50\u90AE\u4EF6: "email",
344
+ // 视频号
345
+ channels: "channels",
346
+ wechat_channels: "channels",
347
+ \u89C6\u9891\u53F7: "channels",
348
+ \u5FAE\u4FE1\u89C6\u9891\u53F7: "channels",
349
+ // 小红书
350
+ xiaohongshu: "xiaohongshu",
351
+ xhs: "xiaohongshu",
352
+ red: "xiaohongshu",
353
+ \u5C0F\u7EA2\u4E66: "xiaohongshu",
354
+ // 抖音
355
+ douyin: "douyin",
356
+ \u6296\u97F3: "douyin",
357
+ // 微博
358
+ weibo: "weibo",
359
+ \u5FAE\u535A: "weibo",
360
+ // B站
361
+ bilibili: "bilibili",
362
+ bili: "bilibili",
363
+ b\u7AD9: "bilibili",
364
+ \u54D4\u54E9\u54D4\u54E9: "bilibili",
365
+ // 知乎
366
+ zhihu: "zhihu",
367
+ \u77E5\u4E4E: "zhihu",
368
+ // 公众号
369
+ mp: "mp",
370
+ wechat_mp: "mp",
371
+ \u516C\u4F17\u53F7: "mp",
372
+ \u8BA2\u9605\u53F7: "mp",
373
+ \u5FAE\u4FE1\u516C\u4F17\u53F7: "mp",
374
+ // LinkedIn
375
+ linkedin: "linkedin",
376
+ \u9886\u82F1: "linkedin",
377
+ // 个人网站
378
+ website: "website",
379
+ \u7F51\u7AD9: "website",
380
+ \u5B98\u7F51: "website",
381
+ \u535A\u5BA2: "website",
382
+ blog: "website",
383
+ // 其他
384
+ other: "other",
385
+ \u5176\u4ED6: "other"
386
+ };
387
+ var LOOKUP2 = /* @__PURE__ */ new Map();
388
+ for (const p of SOCIAL_PLATFORMS) LOOKUP2.set(p.toLowerCase(), p);
389
+ for (const [alias, canonical] of Object.entries(SOCIAL_PLATFORM_ALIASES)) LOOKUP2.set(alias.toLowerCase(), canonical);
390
+ var CONTAINS_KEYS = [...LOOKUP2.keys()].filter((k) => /[^\x00-\x7F]/.test(k)).sort((a, b) => b.length - a.length);
391
+ function normalizeSocialPlatform(input2) {
392
+ if (!input2) return "";
393
+ const cleaned = input2.replace(/[ \s]+/g, " ").trim();
394
+ if (!cleaned) return "";
395
+ const hit = LOOKUP2.get(cleaned.toLowerCase());
396
+ if (hit) return hit;
397
+ const compact = cleaned.replace(/\s+/g, "");
398
+ for (const key of CONTAINS_KEYS) {
399
+ if (compact.includes(key)) return LOOKUP2.get(key);
400
+ }
401
+ return cleaned;
402
+ }
403
+ var SOCIAL_PLATFORM_LABELS = {
404
+ email: { zh: "\u90AE\u7BB1", en: "Email" },
405
+ channels: { zh: "\u89C6\u9891\u53F7", en: "Channels" },
406
+ xiaohongshu: { zh: "\u5C0F\u7EA2\u4E66", en: "Xiaohongshu" },
407
+ douyin: { zh: "\u6296\u97F3", en: "Douyin" },
408
+ weibo: { zh: "\u5FAE\u535A", en: "Weibo" },
409
+ bilibili: { zh: "B\u7AD9", en: "Bilibili" },
410
+ zhihu: { zh: "\u77E5\u4E4E", en: "Zhihu" },
411
+ mp: { zh: "\u516C\u4F17\u53F7", en: "WeChat MP" },
412
+ linkedin: { zh: "\u9886\u82F1", en: "LinkedIn" },
413
+ website: { zh: "\u4E2A\u4EBA\u7F51\u7AD9", en: "Website" },
414
+ other: { zh: "\u5176\u4ED6", en: "Other" }
415
+ };
416
+ function socialPlatformLabel(platform2, lang = "zh") {
417
+ return SOCIAL_PLATFORM_LABELS[platform2]?.[lang] ?? platform2;
418
+ }
419
+
420
+ // ../shared/src/relationship.ts
421
+ var RELATIONSHIP_ALIASES = {
422
+ // 潜客
423
+ lead: "lead",
424
+ \u6F5C\u5BA2: "lead",
425
+ \u7EBF\u7D22: "lead",
426
+ // 意向学员
427
+ student_intent: "student_intent",
428
+ potential_student: "student_intent",
429
+ \u610F\u5411\u5B66\u5458: "student_intent",
430
+ \u5B66\u5458\u610F\u5411: "student_intent",
431
+ \u51C6\u5B66\u5458: "student_intent",
432
+ \u60F3\u62A5\u540D: "student_intent",
433
+ // 学员
434
+ student: "student",
435
+ \u5B66\u5458: "student",
436
+ \u5B66\u751F: "student",
437
+ \u5728\u518C\u5B66\u5458: "student",
438
+ \u6B63\u5F0F\u5B66\u5458: "student",
439
+ // 校友
440
+ alumni: "alumni",
441
+ graduate: "alumni",
442
+ \u6821\u53CB: "alumni",
443
+ \u6BD5\u4E1A\u751F: "alumni",
444
+ \u7ED3\u4E1A\u5B66\u5458: "alumni",
445
+ \u8001\u5B66\u5458: "alumni",
446
+ \u5F80\u5C4A\u5B66\u5458: "alumni",
447
+ // 意向甲方
448
+ prospect_client: "prospect_client",
449
+ potential_client: "prospect_client",
450
+ \u610F\u5411\u7532\u65B9: "prospect_client",
451
+ \u6F5C\u5728\u7532\u65B9: "prospect_client",
452
+ \u610F\u5411\u5BA2\u6237: "prospect_client",
453
+ \u5F85\u7B7E\u5BA2\u6237: "prospect_client",
454
+ // 甲方
455
+ client: "client",
456
+ customer: "client",
457
+ \u7532\u65B9: "client",
458
+ \u5BA2\u6237: "client",
459
+ \u5BA2\u6237\u65B9: "client",
460
+ \u5DF2\u7B7E\u7EA6: "client",
461
+ // 渠道方
462
+ channel: "channel",
463
+ \u6E20\u9053\u65B9: "channel",
464
+ \u6E20\u9053: "channel",
465
+ \u6E20\u9053\u4F19\u4F34: "channel",
466
+ \u5206\u9500\u65B9: "channel",
467
+ \u4EE3\u7406: "channel",
468
+ // 合伙人
469
+ partner: "partner",
470
+ \u5408\u4F19\u4EBA: "partner",
471
+ \u5408\u4F5C\u65B9: "partner",
472
+ \u5408\u4F5C\u4F19\u4F34: "partner",
473
+ \u8054\u5408\u521B\u59CB\u4EBA: "partner",
474
+ // 社群成员
475
+ member: "member",
476
+ \u793E\u7FA4\u6210\u5458: "member",
477
+ \u7FA4\u53CB: "member",
478
+ \u793E\u533A\u6210\u5458: "member",
479
+ \u793E\u7FA4: "member",
480
+ // 访谈嘉宾
481
+ guest: "guest",
482
+ podcast_guest: "guest",
483
+ \u8BBF\u8C08\u5609\u5BBE: "guest",
484
+ \u53D7\u8BBF\u5609\u5BBE: "guest",
485
+ \u64AD\u5BA2\u5609\u5BBE: "guest",
486
+ \u5609\u5BBE: "guest",
487
+ // 服务方
488
+ supplier: "supplier",
489
+ vendor: "supplier",
490
+ \u670D\u52A1\u65B9: "supplier",
491
+ \u4F9B\u5E94\u5546: "supplier",
492
+ \u5916\u5305\u65B9: "supplier",
493
+ \u4E59\u65B9: "supplier",
494
+ // 前辈
495
+ mentor: "mentor",
496
+ \u524D\u8F88: "mentor",
497
+ \u5BFC\u5E08: "mentor",
498
+ \u987E\u95EE: "mentor",
499
+ // 个人关系
500
+ friend: "friend",
501
+ \u670B\u53CB: "friend",
502
+ \u4E2A\u4EBA\u5173\u7CFB: "friend",
503
+ \u79C1\u4EA4: "friend",
504
+ // 其他
505
+ other: "other",
506
+ \u5176\u4ED6: "other",
507
+ \u5176\u5B83: "other"
508
+ };
509
+ var LOOKUP3 = /* @__PURE__ */ new Map();
510
+ for (const r of RELATIONSHIPS) LOOKUP3.set(r.toLowerCase(), r);
511
+ for (const [alias, canonical] of Object.entries(RELATIONSHIP_ALIASES)) LOOKUP3.set(alias.toLowerCase(), canonical);
512
+ function normalizeRelationship(input2) {
513
+ if (!input2) return "";
514
+ const cleaned = input2.replace(/[ \s]+/g, " ").trim();
515
+ if (!cleaned) return "";
516
+ return LOOKUP3.get(cleaned.toLowerCase()) ?? cleaned;
517
+ }
518
+ var RELATIONSHIP_LABELS = {
519
+ lead: { zh: "\u6F5C\u5BA2", en: "Lead" },
520
+ student_intent: { zh: "\u610F\u5411\u5B66\u5458", en: "Prospective student" },
521
+ student: { zh: "\u5B66\u5458", en: "Student" },
522
+ alumni: { zh: "\u6821\u53CB", en: "Alumni" },
523
+ prospect_client: { zh: "\u610F\u5411\u7532\u65B9", en: "Prospective client" },
524
+ client: { zh: "\u7532\u65B9", en: "Client" },
525
+ channel: { zh: "\u6E20\u9053\u65B9", en: "Channel partner" },
526
+ partner: { zh: "\u5408\u4F19\u4EBA", en: "Partner" },
527
+ member: { zh: "\u793E\u7FA4\u6210\u5458", en: "Community member" },
528
+ guest: { zh: "\u8BBF\u8C08\u5609\u5BBE", en: "Podcast guest" },
529
+ supplier: { zh: "\u670D\u52A1\u65B9", en: "Supplier" },
530
+ mentor: { zh: "\u524D\u8F88", en: "Mentor" },
531
+ friend: { zh: "\u4E2A\u4EBA\u5173\u7CFB", en: "Friend" },
532
+ other: { zh: "\u5176\u4ED6", en: "Other" }
533
+ };
534
+ function relationshipLabel(relationship, lang = "zh") {
535
+ return RELATIONSHIP_LABELS[relationship]?.[lang] ?? relationship;
536
+ }
537
+
281
538
  // ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
282
539
  var external_exports = {};
283
540
  __export(external_exports, {
@@ -20000,6 +20257,11 @@ var short = (max) => external_exports.string().trim().max(max);
20000
20257
  var tags = external_exports.array(external_exports.string().trim().min(1).max(200)).max(50);
20001
20258
  var isoDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "YYYY-MM-DD");
20002
20259
  var city = external_exports.string().trim().max(100).transform(normalizeCity);
20260
+ var socialLink = external_exports.object({
20261
+ platform: external_exports.string().trim().min(1).max(50).transform(normalizeSocialPlatform),
20262
+ handle: external_exports.string().trim().min(1).max(200),
20263
+ url: external_exports.string().trim().max(2e3).nullable().optional()
20264
+ });
20003
20265
  var eventInput = external_exports.object({
20004
20266
  title: short(200).min(1),
20005
20267
  date: isoDate,
@@ -20015,6 +20277,10 @@ var customerShape = {
20015
20277
  title: short(200),
20016
20278
  city,
20017
20279
  wechatId: short(100).nullable(),
20280
+ /** 其他社交账号(视频号 / 小红书 / 邮箱…)。整体替换:传了就用这组覆盖旧的 */
20281
+ socials: external_exports.array(socialLink).max(50),
20282
+ /** 关系:这个人是谁。可以多个,按重要性从高到低。整体替换 */
20283
+ relationships: external_exports.array(external_exports.string().trim().min(1).max(50).transform(normalizeRelationship)).max(20),
20018
20284
  summary: short(5e3),
20019
20285
  painPoints: tags,
20020
20286
  goals: tags,
@@ -20057,6 +20323,17 @@ var hookFields = [
20057
20323
  { 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
20324
  { 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
20325
  ];
20326
+ var socialFields = [
20327
+ {
20328
+ name: "platform",
20329
+ type: "enum",
20330
+ required: true,
20331
+ values: SOCIAL_PLATFORMS,
20332
+ 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"
20333
+ },
20334
+ { 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
+ { 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
+ ];
20060
20337
  var SCHEMA = {
20061
20338
  customer: {
20062
20339
  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 +20343,18 @@ var SCHEMA = {
20066
20343
  { name: "title", type: "string", guide: "\u804C\u4F4D\u6216\u8EAB\u4EFD" },
20067
20344
  { 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
20345
  { name: "wechatId", type: "string", nullable: true, guide: "\u5FAE\u4FE1\u53F7\u3002\u53EA\u5728\u5BF9\u8BDD\u91CC\u660E\u786E\u51FA\u73B0\u65F6\u586B\u5199" },
20346
+ {
20347
+ name: "socials",
20348
+ type: "object[]",
20349
+ fields: socialFields,
20350
+ 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"
20351
+ },
20352
+ {
20353
+ name: "relationships",
20354
+ type: "string[]",
20355
+ values: RELATIONSHIPS,
20356
+ 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
+ },
20069
20358
  { 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
20359
  { 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
20360
  { name: "goals", type: "string[]", guide: "\u77ED\u671F\u76EE\u6807\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD" },
@@ -20151,14 +20440,15 @@ var DEFAULT_PROMPTS = [
20151
20440
  function renderPrompt(text, customer) {
20152
20441
  return text.replace(/\{\{\s*(\w+)\s*\}\}/g, (whole, key) => {
20153
20442
  const v = customer?.[key];
20154
- return v ? v : whole;
20443
+ if (!v || Array.isArray(v) && v.length === 0) return whole;
20444
+ return Array.isArray(v) ? v.join(", ") : v;
20155
20445
  });
20156
20446
  }
20157
20447
 
20158
20448
  // package.json
20159
20449
  var package_default = {
20160
20450
  name: "insightcrm",
20161
- version: "0.1.4",
20451
+ version: "0.1.7",
20162
20452
  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
20453
  license: "MIT",
20164
20454
  type: "module",
@@ -20433,6 +20723,8 @@ Examples:
20433
20723
  $ crm login https://crm.example.com
20434
20724
  $ crm schema --json
20435
20725
  $ echo '{"name":"Wang Ming","company":"ACME","conversionPotential":"High"}' | crm add - --json
20726
+ $ crm add --name "\u738B\u5C0F\u660E" --social channels:@san3 email:wang@example.com --json
20727
+ $ crm add --name "\u738B\u5C0F\u660E" --relationship \u5B66\u5458 --relationship \u793E\u7FA4\u6210\u5458 --json
20436
20728
  $ crm list --potential high --city Beijing --due-today --json
20437
20729
  $ crm update 3f2a\u2026 --summary "Needs a quote by Friday" --json
20438
20730
  $ 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 +20795,17 @@ var potentialOf = (v) => {
20503
20795
  if (!CONVERSION_POTENTIALS.includes(p)) throw new CliError("usage", `--potential must be one of ${CONVERSION_POTENTIALS.join(", ")}`, EXIT.usage);
20504
20796
  return p;
20505
20797
  };
20798
+ function parseSocial(s) {
20799
+ const at = s.indexOf(":");
20800
+ const platform2 = at === -1 ? "" : s.slice(0, at).trim();
20801
+ const handle = at === -1 ? "" : s.slice(at + 1).trim();
20802
+ 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);
20803
+ return { platform: platform2, handle };
20804
+ }
20506
20805
  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)" : ""}`);
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)" : ""}`);
20508
20807
  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");
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");
20510
20809
  } else {
20511
20810
  cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
20512
20811
  }
@@ -20535,6 +20834,8 @@ function buildCustomerBody(base, o) {
20535
20834
  if (o.goal) body.goals = o.goal;
20536
20835
  if (o.event) body.upcomingEvents = o.event.map(parseEvent);
20537
20836
  if (o.clearEvents) body.upcomingEvents = [];
20837
+ if (o.social) body.socials = o.social.map(parseSocial);
20838
+ if (o.relationship) body.relationships = o.relationship;
20538
20839
  if (o.hookTitle || o.hookDesc) {
20539
20840
  if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
20540
20841
  body.socialHook = { title: o.hookTitle, description: o.hookDesc };
@@ -20550,6 +20851,8 @@ function detail(c) {
20550
20851
  ["title", c.title],
20551
20852
  ["city", c.city],
20552
20853
  ["wechat", c.wechatId ?? ""],
20854
+ ["socials", c.socials.map((s) => `${s.platform}: ${s.handle}${s.url ? ` (${s.url})` : ""}`).join("; ")],
20855
+ ["relationship", c.relationships.map((r) => relationshipLabel(r, "zh")).join(", ")],
20553
20856
  ["potential", c.conversionPotential],
20554
20857
  ["cycle days", String(c.conversionCycleDays)],
20555
20858
  ["pain points", c.painPoints.join(", ")],
@@ -20694,16 +20997,26 @@ withCustomerOptions(
20694
20997
  out(`Created ${line(customer)}`, { customer, created: true });
20695
20998
  });
20696
20999
  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"),
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"),
20698
21001
  true
20699
21002
  ).action(async (id, src, o) => {
20700
21003
  const api = await client();
20701
21004
  const body = buildCustomerBody(await readJsonInput(src), o);
20702
- if (o.addPain || o.addGoal || o.addEvent) {
21005
+ if (o.addPain || o.addGoal || o.addEvent || o.addSocial || o.addRelationship) {
20703
21006
  const { customer: cur } = await api.getCustomer(id);
20704
21007
  if (o.addPain) body.painPoints = [.../* @__PURE__ */ new Set([...body.painPoints ?? cur.painPoints, ...o.addPain])];
20705
21008
  if (o.addGoal) body.goals = [.../* @__PURE__ */ new Set([...body.goals ?? cur.goals, ...o.addGoal])];
20706
21009
  if (o.addEvent) body.upcomingEvents = [...body.upcomingEvents ?? cur.upcomingEvents.map(({ title, date: date5, type }) => ({ title, date: date5, type })), ...o.addEvent.map(parseEvent)];
21010
+ if (o.addSocial) {
21011
+ const added = o.addSocial.map(parseSocial);
21012
+ const key = (s) => JSON.stringify([s.platform, s.handle]);
21013
+ const existing = body.socials ?? cur.socials;
21014
+ body.socials = [...existing, ...added.filter((s) => !existing.some((e) => key(e) === key(s)))];
21015
+ }
21016
+ if (o.addRelationship) {
21017
+ const existing = body.relationships ?? cur.relationships;
21018
+ body.relationships = [...existing, ...o.addRelationship.filter((r) => !existing.includes(r))];
21019
+ }
20707
21020
  }
20708
21021
  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
21022
  const { customer } = await api.updateCustomer(id, body);
@@ -20713,12 +21026,14 @@ program.command("get").description("Show one customer").argument("<id>").action(
20713
21026
  const { customer } = await (await client()).getCustomer(id);
20714
21027
  out(detail(customer), { customer });
20715
21028
  });
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) => {
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) => {
20717
21030
  const { customers } = await (await client()).listCustomers({
20718
21031
  potential: o.potential ? potentialOf(o.potential) : void 0,
20719
21032
  city: o.city,
20720
21033
  tag: o.tag,
20721
21034
  q: o.query,
21035
+ socialPlatform: o.socialPlatform,
21036
+ relationship: o.relationship,
20722
21037
  dueOn: o.dueToday ? today() : o.due
20723
21038
  });
20724
21039
  out(customers.length ? customers.map(line).join("\n") : "No customers match.", { customers, count: customers.length });
@@ -20790,11 +21105,11 @@ prompts.command("list").description("List templates. `customized` marks the ones
20790
21105
  { prompts: list, path: promptsPath }
20791
21106
  );
20792
21107
  });
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) => {
21108
+ 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
21109
  const p = resolvePrompts(langOf(o), await loadCustom()).find((x) => x.id === id);
20795
21110
  if (!p) throw new CliError("not_found", `No template "${id}". Run \`crm prompts list\``, EXIT.usage);
20796
21111
  const customer = o.customer ? (await (await client()).getCustomer(o.customer)).customer : void 0;
20797
- const rendered = renderPrompt(p.prompt, customer);
21112
+ const rendered = renderPrompt(p.prompt, customer && { ...customer, socials: customer.socials.map((s) => `${socialPlatformLabel(s.platform, langOf(o))}: ${s.handle}`) });
20798
21113
  out(rendered, { id: p.id, kind: p.kind, label: p.label, prompt: rendered, template: p.prompt, customized: p.customized, ...customer ? { customer } : {} });
20799
21114
  });
20800
21115
  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.7",
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",