insightcrm 0.1.12 → 0.1.14
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/dist/cli.js +138 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -88,6 +88,7 @@ var CITIES = [
|
|
|
88
88
|
"\u5927\u7406",
|
|
89
89
|
"\u4E09\u4E9A",
|
|
90
90
|
"\u5317\u6D77",
|
|
91
|
+
"\u6D4E\u5B81",
|
|
91
92
|
// 港澳台
|
|
92
93
|
"\u9999\u6E2F",
|
|
93
94
|
"\u6FB3\u95E8",
|
|
@@ -111,7 +112,10 @@ var CITIES = [
|
|
|
111
112
|
"\u6089\u5C3C",
|
|
112
113
|
"\u58A8\u5C14\u672C",
|
|
113
114
|
"\u8FEA\u62DC",
|
|
114
|
-
"\u67CF\u6797"
|
|
115
|
+
"\u67CF\u6797",
|
|
116
|
+
"\u8FBE\u62C9\u65AF",
|
|
117
|
+
"\u5DF4\u585E\u7F57\u90A3",
|
|
118
|
+
"\u4F2F\u5229\u6052"
|
|
115
119
|
];
|
|
116
120
|
var SOCIAL_PLATFORMS = [
|
|
117
121
|
"email",
|
|
@@ -258,6 +262,10 @@ var CITY_ALIASES = {
|
|
|
258
262
|
melbourne: "\u58A8\u5C14\u672C",
|
|
259
263
|
dubai: "\u8FEA\u62DC",
|
|
260
264
|
berlin: "\u67CF\u6797",
|
|
265
|
+
dallas: "\u8FBE\u62C9\u65AF",
|
|
266
|
+
barcelona: "\u5DF4\u585E\u7F57\u90A3",
|
|
267
|
+
bethlehem: "\u4F2F\u5229\u6052",
|
|
268
|
+
jining: "\u6D4E\u5B81",
|
|
261
269
|
// 整词差异(繁简字符表管不到的那些)
|
|
262
270
|
\u6C49\u57CE: "\u9996\u5C14",
|
|
263
271
|
\u96EA\u68A8: "\u6089\u5C3C",
|
|
@@ -646,9 +654,51 @@ function wechatKey(input2) {
|
|
|
646
654
|
return (input2 ?? "").replace(/\s+/g, "").trim().toLowerCase();
|
|
647
655
|
}
|
|
648
656
|
|
|
649
|
-
// ../shared/src/
|
|
657
|
+
// ../shared/src/notes.ts
|
|
658
|
+
var NOTE_KINDS = ["fact", "judgment", "todo"];
|
|
659
|
+
var NOTE_HEADINGS = { fact: "\u4E8B\u5B9E", judgment: "\u5224\u65AD", todo: "\u5F85\u6838\u5B9E" };
|
|
660
|
+
var NOTE_LEGACY_HEADING = "\u5386\u53F2\u5907\u6CE8";
|
|
650
661
|
var NOTES_MAX = 1e4;
|
|
651
|
-
var
|
|
662
|
+
var NOTES_BUDGET = 3e3;
|
|
663
|
+
var NOTE_ENTRY_MAX = 150;
|
|
664
|
+
var NOTE_SOURCE_MAX = 20;
|
|
665
|
+
var FM_RE = /^---\n([\s\S]*?)\n---\n?/;
|
|
666
|
+
var emptyEntries = () => ({ fact: [], judgment: [], todo: [] });
|
|
667
|
+
function parseNotes(notes) {
|
|
668
|
+
const text = (notes ?? "").replace(/\r\n/g, "\n");
|
|
669
|
+
const fm = FM_RE.exec(text);
|
|
670
|
+
const version2 = fm ? /^v:\s*(\d+)\s*$/m.exec(fm[1])?.[1] : void 0;
|
|
671
|
+
if (!fm || version2 !== "1") return { structured: false, entries: emptyEntries(), legacy: text.trim() };
|
|
672
|
+
const updated = /^updated:\s*(\S+)\s*$/m.exec(fm[1])?.[1];
|
|
673
|
+
const body = text.slice(fm[0].length);
|
|
674
|
+
const entries = emptyEntries();
|
|
675
|
+
let legacy = "";
|
|
676
|
+
let current = null;
|
|
677
|
+
const lines = body.split("\n");
|
|
678
|
+
for (let i = 0; i < lines.length; i++) {
|
|
679
|
+
const line2 = lines[i];
|
|
680
|
+
const h = /^##\s+(.+?)\s*$/.exec(line2);
|
|
681
|
+
if (h) {
|
|
682
|
+
const kind = NOTE_KINDS.find((k) => NOTE_HEADINGS[k] === h[1]);
|
|
683
|
+
if (kind) {
|
|
684
|
+
current = kind;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (h[1] === NOTE_LEGACY_HEADING) {
|
|
688
|
+
legacy = lines.slice(i + 1).join("\n").trim();
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (current) {
|
|
693
|
+
const m = /^-\s+(.+)$/.exec(line2);
|
|
694
|
+
if (m) entries[current].push(m[1].trim());
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
return { structured: true, ...updated ? { updated } : {}, entries, legacy };
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// ../shared/src/profile.ts
|
|
701
|
+
var NOTES_LONG = NOTES_BUDGET;
|
|
652
702
|
var COMPANY_LONG = 80;
|
|
653
703
|
var NAME_MAX = 40;
|
|
654
704
|
function nameProblem(name) {
|
|
@@ -20454,17 +20504,40 @@ var customerShape = {
|
|
|
20454
20504
|
currentAction: short(2e3),
|
|
20455
20505
|
conversionPotential: external_exports.enum(CONVERSION_POTENTIALS),
|
|
20456
20506
|
conversionCycleDays: external_exports.number().int().min(0).max(3650),
|
|
20457
|
-
notes: short(
|
|
20507
|
+
notes: short(NOTES_MAX).nullable(),
|
|
20458
20508
|
capturedAt: external_exports.iso.datetime({ offset: true }),
|
|
20459
20509
|
/** 整体替换:传了就用这组覆盖旧日程,不传不动 */
|
|
20460
20510
|
upcomingEvents: external_exports.array(eventInput).max(200)
|
|
20461
20511
|
};
|
|
20512
|
+
var noteOp = external_exports.discriminatedUnion("op", [
|
|
20513
|
+
external_exports.object({
|
|
20514
|
+
op: external_exports.literal("add"),
|
|
20515
|
+
kind: external_exports.enum(NOTE_KINDS),
|
|
20516
|
+
text: external_exports.string().trim().min(1).max(NOTE_ENTRY_MAX),
|
|
20517
|
+
source: external_exports.string().trim().max(NOTE_SOURCE_MAX).optional(),
|
|
20518
|
+
date: external_exports.string().regex(/^(\d{4}-)?\d{2}-\d{2}$/, "date must be YYYY-MM-DD or MM-DD").optional()
|
|
20519
|
+
}),
|
|
20520
|
+
external_exports.object({ op: external_exports.literal("drop"), kind: external_exports.enum(NOTE_KINDS), index: external_exports.number().int().min(1) }),
|
|
20521
|
+
external_exports.object({ op: external_exports.literal("legacy"), text: external_exports.string().max(NOTES_MAX).nullable() })
|
|
20522
|
+
]);
|
|
20523
|
+
var noteOps = external_exports.array(noteOp).min(1).max(50);
|
|
20462
20524
|
var customerCreate = external_exports.object({
|
|
20463
20525
|
...customerShape,
|
|
20526
|
+
noteOps,
|
|
20464
20527
|
/** 创建时可附带一条「成功钩子」,会同时写入钩子库并关联到这个客户 */
|
|
20465
20528
|
socialHook: socialHookInput
|
|
20466
20529
|
}).partial().required({ name: true });
|
|
20467
|
-
var
|
|
20530
|
+
var { notes: _rawNotes, ...writableShape } = customerShape;
|
|
20531
|
+
var rawNotesRejected = {
|
|
20532
|
+
notes: external_exports.never({ error: "notes is read-only here: write it with noteOps (CLI: --note-fact / --note-judgment / --note-todo)" }).optional()
|
|
20533
|
+
};
|
|
20534
|
+
var customerAdd = external_exports.object({
|
|
20535
|
+
...writableShape,
|
|
20536
|
+
...rawNotesRejected,
|
|
20537
|
+
noteOps,
|
|
20538
|
+
socialHook: socialHookInput
|
|
20539
|
+
}).partial().required({ name: true });
|
|
20540
|
+
var customerPatch = external_exports.object({ ...writableShape, ...rawNotesRejected, noteOps }).partial();
|
|
20468
20541
|
var hookCreate = external_exports.object({
|
|
20469
20542
|
title: short(200).min(1),
|
|
20470
20543
|
description: short(5e3).min(1),
|
|
@@ -20512,6 +20585,14 @@ var orgFields = [
|
|
|
20512
20585
|
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"
|
|
20513
20586
|
}
|
|
20514
20587
|
];
|
|
20588
|
+
var noteOpFields = [
|
|
20589
|
+
{ name: "op", type: "enum", values: ["add", "drop", "legacy"], required: true, guide: "add \u8FFD\u52A0\u4E00\u6761 / drop \u5220\u6389\u7B2C index \u6761 / legacy \u6574\u6BB5\u6539\u5199\u5386\u53F2\u5907\u6CE8" },
|
|
20590
|
+
{ name: "kind", type: "enum", values: [...NOTE_KINDS], guide: "fact \u4E8B\u5B9E\uFF08\u53D1\u751F\u8FC7\u4EC0\u4E48\u3001\u5BF9\u65B9\u8BF4\u4E86\u4EC0\u4E48\uFF09/ judgment \u5224\u65AD\uFF08\u4F60\u7684\u7ED3\u8BBA\uFF0C\u4E00\u4E24\u53E5\uFF09/ todo \u5F85\u6838\u5B9E\uFF08\u8FD8\u6CA1\u786E\u8BA4\u7684\u4E8B\uFF09\u3002add\u3001drop \u5FC5\u586B" },
|
|
20591
|
+
{ name: "text", type: "string", guide: `add\uFF1A\u4E00\u53E5\u8BDD\u6B63\u6587\uFF0C\u2264${NOTE_ENTRY_MAX} \u5B57\uFF0C\u5355\u884C\uFF0C\u4E0D\u8981\u4EE5 # \u6216 - \u5F00\u5934\u3002legacy\uFF1A\u6539\u5199\u540E\u7684\u5386\u53F2\u5907\u6CE8\u5168\u6587\uFF0C\u7559\u7A7A / null \u5C31\u662F\u6E05\u6389` },
|
|
20592
|
+
{ name: "source", type: "string", guide: `add \u53EF\u9009\uFF1A\u6765\u6E90\u77ED\u6807\u7B7E\uFF0C\u2264${NOTE_SOURCE_MAX} \u5B57\uFF0C\u5982\u300C\u76F4\u64AD\u7B54\u7591\u300D\u300C\u540D\u7247\u300D\u300C\u670B\u53CB\u5708\u300D` },
|
|
20593
|
+
{ name: "date", type: "string", guide: "add \u53EF\u9009\uFF1A\u8FD9\u4EF6\u4E8B\u53D1\u751F\u7684\u65E5\u671F YYYY-MM-DD \u6216 MM-DD\uFF0C\u9ED8\u8BA4\u4ECA\u5929" },
|
|
20594
|
+
{ name: "index", type: "integer", guide: "drop \u5FC5\u586B\uFF1A\u8BE5\u6BB5\u91CC\u7B2C\u51E0\u6761\uFF0C\u4ECE 1 \u5F00\u59CB\uFF08crm get \u91CC\u80FD\u770B\u5230\u5E8F\u53F7\uFF09" }
|
|
20595
|
+
];
|
|
20515
20596
|
var relatedFields = [
|
|
20516
20597
|
{ 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" },
|
|
20517
20598
|
{ name: "wechatId", type: "string", nullable: true, guide: "\u5BF9\u65B9\u5FAE\u4FE1\u53F7\u3002\u8FD9\u6761\u94FE\u4E0A\u552F\u4E00\u53EF\u9760\u7684\u6807\u8BC6\uFF1A\u540C\u4E00\u4E2A\u8D26\u53F7\u4E0B\u5FAE\u4FE1\u53F7\u4E0D\u91CD\u590D\uFF0C\u540C\u540D\u4E0D\u540C\u4EBA\u65F6\u9760\u5B83\u5206\u51FA\u662F\u54EA\u4E00\u4F4D\u3002\u6750\u6599\u91CC\u51FA\u73B0\u4E86\u5BF9\u65B9\u7684\u5FAE\u4FE1\u53F7\u5C31\u586B\u4E0A\u2014\u2014\u6CA1\u6709\u5B83\uFF0C\u670D\u52A1\u7AEF\u53EA\u80FD\u6309\u59D3\u540D\u731C\uFF0C\u731C\u4E0D\u4E2D\u5C31\u7559\u7A7A" },
|
|
@@ -20560,7 +20641,18 @@ var SCHEMA = {
|
|
|
20560
20641
|
{ name: "conversionCycleDays", type: "integer", guide: "\u9884\u4F30\u7684\u8F6C\u5316\u9EC4\u91D1\u7A97\u53E3\u5929\u6570\uFF1B\u4FE1\u53F7\u8D8A\u5F31\u8D8A\u957F\uFF0C\u4FE1\u53F7\u660E\u786E\u53EF\u77ED\u81F3 7-14 \u5929" },
|
|
20561
20642
|
{ name: "upcomingEvents", type: "object[]", fields: eventFields, guide: "\u4E92\u52A8\u65E5\u5386\u3002\u66F4\u65B0\u65F6\u4F20\u5165\u5B8C\u6574\u5217\u8868\u4F1A\u6574\u4F53\u66FF\u6362\u65E7\u65E5\u7A0B\uFF1B\u4E0D\u4F20\u5219\u4E0D\u52A8" },
|
|
20562
20643
|
{ name: "socialHook", type: "object", fields: hookFields, guide: "\uFF08\u4EC5\u521B\u5EFA\u65F6\u53EF\u7528\uFF09\u5206\u6790\u5BF9\u8BDD\u4E2D\u54EA\u53E5\u8BDD\u3001\u54EA\u4E2A\u8BF4\u6CD5\u6210\u529F\u5F15\u8D77\u5BF9\u65B9\u6CE8\u610F\u6216\u89E6\u53D1\u6B63\u5411\u56DE\u590D\u3002\u7ED3\u6784\u5316 {title, description}\u3002\u627E\u4E0D\u5230\u5C31\u7701\u7565\uFF0C\u4E0D\u8981\u7F16\u9020\u3002" },
|
|
20563
|
-
{
|
|
20644
|
+
{
|
|
20645
|
+
name: "notes",
|
|
20646
|
+
type: "string",
|
|
20647
|
+
nullable: true,
|
|
20648
|
+
guide: "\u53EA\u8BFB\uFF0C\u4E0D\u80FD\u76F4\u63A5\u5199\u3002\u88C5\u7ED3\u6784\u5316\u5B57\u6BB5\u653E\u4E0D\u4E0B\u3001\u4E4B\u540E\u8FD8\u8981\u56DE\u5934\u770B\u7684\u4E1C\u897F\uFF1A\u5E26\u65E5\u671F\u7684\u4E8B\u5B9E\u3001\u5224\u65AD\u3001\u5F85\u6838\u5B9E\u9879\u3002\u4E0D\u8981\u653E\u5FAE\u4FE1\u53F7 / \u6635\u79F0 / \u89C6\u9891\u53F7 / \u6807\u7B7E\uFF08\u6709 wechatId / socials / relationships\uFF09\uFF0C\u4E5F\u4E0D\u8981\u653E\u4E0B\u4E00\u6B65\u52A8\u4F5C\uFF08\u5199 currentAction\uFF09\uFF0C\u66F4\u4E0D\u8981\u8D34\u5BF9\u8BDD\u539F\u6587\u6216\u622A\u56FE\u8F6C\u5F55\u3002\u5199\u5165\u7528 noteOps\uFF08CLI\uFF1A--note-fact / --note-judgment / --note-todo / --note-drop\uFF09\uFF0C\u6BCF\u6761\u4E00\u53E5\u8BDD\u3001\u2264150 \u5B57\uFF0C\u683C\u5F0F `\u65E5\u671F \u6765\u6E90\uFF5C\u6B63\u6587`\uFF1B\u540C\u4E00\u4EF6\u4E8B\u6539\u5199\u539F\u6761\u76EE\uFF0C\u4E0D\u8981\u91CD\u590D\u8FFD\u52A0\u3002\u6574\u6761 notes \u9884\u7B97 3000 \u5B57\uFF0C\u8D85\u4E86\u5148\u538B\u7F29\uFF08drop / \u6539\u5199\u5386\u53F2\u5907\u6CE8\uFF09\u518D\u5199\uFF0C\u786C\u4E0A\u9650 10000 \u5B57\u3002\u6CA1\u6709\u7ED3\u6784\u5316\u6807\u8BB0\u7684\u8001 notes \u89C6\u4E3A\u300C\u5386\u53F2\u5907\u6CE8\u300D\uFF0C\u539F\u6837\u4FDD\u7559\uFF0C\u9700\u8981\u65F6\u7528 {op:'legacy'} \u6574\u6BB5\u538B\u7F29\u3002"
|
|
20649
|
+
},
|
|
20650
|
+
{
|
|
20651
|
+
name: "noteOps",
|
|
20652
|
+
type: "object[]",
|
|
20653
|
+
fields: noteOpFields,
|
|
20654
|
+
guide: "\uFF08\u53EA\u5199\uFF09notes \u7684\u8FFD\u52A0 / \u5220\u9664\u64CD\u4F5C\uFF0C\u6309\u987A\u5E8F\u5E94\u7528\u3002{op:'add', kind:'fact'|'judgment'|'todo', text, source?, date?}\u3001{op:'drop', kind, index}\u3001{op:'legacy', text}\u3002"
|
|
20655
|
+
},
|
|
20564
20656
|
{ name: "capturedAt", type: "datetime", guide: "\u7EBF\u7D22\u9996\u6B21\u88AB\u53D1\u73B0\u7684\u65F6\u95F4\uFF08ISO 8601\uFF09\uFF0C\u9ED8\u8BA4\u5F53\u524D\u65F6\u95F4" }
|
|
20565
20657
|
]
|
|
20566
20658
|
},
|
|
@@ -20660,7 +20752,7 @@ function renderPrompt(text, customer) {
|
|
|
20660
20752
|
// package.json
|
|
20661
20753
|
var package_default = {
|
|
20662
20754
|
name: "insightcrm",
|
|
20663
|
-
version: "0.1.
|
|
20755
|
+
version: "0.1.14",
|
|
20664
20756
|
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.",
|
|
20665
20757
|
license: "MIT",
|
|
20666
20758
|
type: "module",
|
|
@@ -20806,8 +20898,8 @@ function lintCustomers(customers, today2) {
|
|
|
20806
20898
|
}
|
|
20807
20899
|
for (const c of customers) {
|
|
20808
20900
|
const notesLen = (c.notes ?? "").length;
|
|
20809
|
-
if (notesLen > NOTES_MAX) push(c, "notes-over-limit", "error", `notes ${notesLen} \u5B57\u7B26\uFF0C\u8D85\
|
|
20810
|
-
else if (notesLen > NOTES_LONG) push(c, "notes-long", "warn", `notes ${notesLen} \u5B57\u7B26\uFF0C\
|
|
20901
|
+
if (notesLen > NOTES_MAX) push(c, "notes-over-limit", "error", `notes ${notesLen} \u5B57\u7B26\uFF0C\u8D85\u786C\u4E0A\u9650 ${NOTES_MAX}\u3002\u5148\u538B\u7F29\u518D\u5199\uFF1A--note-drop \u5220\u8FC7\u65F6\u6761\u76EE\uFF0C\u6216\u7528 --note-legacy \u628A\u5386\u53F2\u5907\u6CE8\u6539\u5199\u77ED`);
|
|
20902
|
+
else if (notesLen > NOTES_LONG) push(c, "notes-long", "warn", `notes ${notesLen} \u5B57\u7B26\uFF0C\u8D85\u8FC7 ${NOTES_BUDGET} \u5B57\u9884\u7B97\uFF0C\u5DF2\u4E0D\u518D\u63A5\u53D7\u8FFD\u52A0\u3002\u7528 --note-legacy \u538B\u7F29\u5386\u53F2\u5907\u6CE8 / --note-drop \u5220\u8FC7\u65F6\u6761\u76EE`);
|
|
20811
20903
|
const nameIssue = nameProblem(c.name);
|
|
20812
20904
|
if (nameIssue) push(c, "name-annotated", "warn", `${nameIssue}\uFF1A\u300C${c.name.slice(0, 40)}${c.name.length > 40 ? "\u2026" : ""}\u300D`);
|
|
20813
20905
|
for (const o of c.orgs ?? []) {
|
|
@@ -21222,9 +21314,9 @@ var splitRelationships = (values) => values.flatMap((v) => {
|
|
|
21222
21314
|
return parts.length > 1 && parts.every(isKnownRelationship) ? parts : [v];
|
|
21223
21315
|
});
|
|
21224
21316
|
function withCustomerOptions(cmd, forUpdate) {
|
|
21225
|
-
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("--
|
|
21317
|
+
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("--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("--note-fact <s...>", "append a fact to notes: one sentence, \u2264150 chars, what happened / what they said (dated today unless --note-date)").option("--note-judgment <s...>", "append a judgment to notes: your conclusion, one or two sentences").option("--note-todo <s...>", "append an unverified item to notes: something still to confirm").option("--note-source <label>", "source label for the notes added in this call, \u226420 chars, e.g. \u76F4\u64AD\u7B54\u7591 / \u540D\u7247").option("--note-date <date>", "date the noted thing happened, YYYY-MM-DD or MM-DD (default today)").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\uFF1B\u5E26\u5FAE\u4FE1\u53F7\u5199 \u59D3\u540D:\u5173\u7CFB:wx=\u5FAE\u4FE1\u53F7${forUpdate ? " (replaces the whole list; see --add-related)" : ""}`);
|
|
21226
21318
|
if (forUpdate) {
|
|
21227
|
-
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\uFF1B\u5FAE\u4FE1\u53F7\u5199 \u59D3\u540D:\u5173\u7CFB:wx=\u5FAE\u4FE1\u53F7)").option("--remove-event <date:keyword...>", "remove calendar events on that date (YYYY-MM-DD), or with date:keyword only those whose title contains the keyword; other events stay").option("--clear-events", "remove all calendar events");
|
|
21319
|
+
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\uFF1B\u5FAE\u4FE1\u53F7\u5199 \u59D3\u540D:\u5173\u7CFB:wx=\u5FAE\u4FE1\u53F7)").option("--remove-event <date:keyword...>", "remove calendar events on that date (YYYY-MM-DD), or with date:keyword only those whose title contains the keyword; other events stay").option("--clear-events", "remove all calendar events").option("--note-drop <kind:n...>", "delete note entries by kind and 1-based number as shown by `crm get`, e.g. fact:2 todo:1").option("--note-legacy <s>", "rewrite the whole \u5386\u53F2\u5907\u6CE8 block (old free-text notes) with this text; pass '' to clear it. Use it to compress old notes before appending");
|
|
21228
21320
|
} else {
|
|
21229
21321
|
cmd.option("--hook-title <s>", "also record a successful hook for this customer (needs --hook-desc)").option("--hook-desc <s>");
|
|
21230
21322
|
}
|
|
@@ -21242,7 +21334,6 @@ function buildCustomerBody(base, o) {
|
|
|
21242
21334
|
set2("wechatId", o.wechat);
|
|
21243
21335
|
set2("summary", o.summary);
|
|
21244
21336
|
set2("currentAction", o.currentAction);
|
|
21245
|
-
set2("notes", o.notes);
|
|
21246
21337
|
if (o.potential) body.conversionPotential = potentialOf(o.potential);
|
|
21247
21338
|
if (o.cycleDays !== void 0) {
|
|
21248
21339
|
const n = Number(o.cycleDays);
|
|
@@ -21257,18 +21348,36 @@ function buildCustomerBody(base, o) {
|
|
|
21257
21348
|
if (o.relationship) body.relationships = splitRelationships(o.relationship);
|
|
21258
21349
|
if (o.org) body.orgs = o.org.map(parseOrg);
|
|
21259
21350
|
if (o.related) body.relatedPeople = o.related.map(parseRelated);
|
|
21351
|
+
const noteOps2 = buildNoteOps(o);
|
|
21352
|
+
if (noteOps2.length) body.noteOps = [...body.noteOps ?? [], ...noteOps2];
|
|
21260
21353
|
if (o.hookTitle || o.hookDesc) {
|
|
21261
21354
|
if (!o.hookTitle || !o.hookDesc) throw new CliError("usage", "--hook-title and --hook-desc go together", EXIT.usage);
|
|
21262
21355
|
body.socialHook = { title: o.hookTitle, description: o.hookDesc };
|
|
21263
21356
|
}
|
|
21264
21357
|
return body;
|
|
21265
21358
|
}
|
|
21266
|
-
function
|
|
21267
|
-
const
|
|
21268
|
-
if (
|
|
21359
|
+
function buildNoteOps(o) {
|
|
21360
|
+
const ops = [];
|
|
21361
|
+
if (o.noteLegacy !== void 0) ops.push({ op: "legacy", text: o.noteLegacy.trim() ? o.noteLegacy : null });
|
|
21362
|
+
const drops = (o.noteDrop ?? []).map((d) => {
|
|
21363
|
+
const m = /^(fact|judgment|todo):(\d+)$/.exec(d.trim());
|
|
21364
|
+
if (!m) throw new CliError("usage", `--note-drop expects <fact|judgment|todo>:<number>, got "${d}"`, EXIT.usage);
|
|
21365
|
+
return { op: "drop", kind: m[1], index: Number(m[2]) };
|
|
21366
|
+
});
|
|
21367
|
+
ops.push(...drops.sort((a, b) => b.index - a.index));
|
|
21368
|
+
const extra = { ...o.noteSource ? { source: o.noteSource } : {}, ...o.noteDate ? { date: o.noteDate } : {} };
|
|
21369
|
+
const adds = [["fact", o.noteFact], ["judgment", o.noteJudgment], ["todo", o.noteTodo]];
|
|
21370
|
+
for (const [kind, texts] of adds) for (const text of texts ?? []) ops.push({ op: "add", kind, text, ...extra });
|
|
21371
|
+
if ((o.noteSource || o.noteDate) && !adds.some(([, t]) => t?.length)) {
|
|
21372
|
+
throw new CliError("usage", "--note-source / --note-date only apply together with --note-fact / --note-judgment / --note-todo", EXIT.usage);
|
|
21373
|
+
}
|
|
21374
|
+
return ops;
|
|
21375
|
+
}
|
|
21376
|
+
function rejectRawNotes(body) {
|
|
21377
|
+
if (body.notes !== void 0) {
|
|
21269
21378
|
throw new CliError(
|
|
21270
21379
|
"usage",
|
|
21271
|
-
|
|
21380
|
+
"notes cannot be written directly. Add entries with --note-fact / --note-judgment / --note-todo (or noteOps in the JSON); compress old free-text notes with --note-legacy",
|
|
21272
21381
|
EXIT.usage
|
|
21273
21382
|
);
|
|
21274
21383
|
}
|
|
@@ -21292,6 +21401,16 @@ function warnPayload(body) {
|
|
|
21292
21401
|
for (const w of warns) info(`\u26A0 ${w}`);
|
|
21293
21402
|
}
|
|
21294
21403
|
var line = (c) => `${c.id} ${c.name}${c.company || c.title ? ` (${[c.company, c.title].filter(Boolean).join(" \xB7 ")})` : ""}${c.city ? ` ${c.city}` : ""} ${c.conversionPotential} ${c.conversionCycleDays}d${c.painPoints.length ? ` [${c.painPoints.join(", ")}]` : ""}`;
|
|
21404
|
+
function notesView(notes) {
|
|
21405
|
+
if (!notes) return "";
|
|
21406
|
+
const p = parseNotes(notes);
|
|
21407
|
+
if (!p.structured) return `(legacy free text, ${notes.length} chars)
|
|
21408
|
+
${notes}`;
|
|
21409
|
+
const pad = "\n ";
|
|
21410
|
+
const entries = NOTE_KINDS.flatMap((k) => p.entries[k].map((e, i) => `${k}:${i + 1} ${e}`));
|
|
21411
|
+
const legacy = p.legacy ? [`legacy (${p.legacy.length} chars) ${p.legacy}`] : [];
|
|
21412
|
+
return [...entries, ...legacy].join(pad);
|
|
21413
|
+
}
|
|
21295
21414
|
function detail(c) {
|
|
21296
21415
|
const rows = [
|
|
21297
21416
|
["id", c.id],
|
|
@@ -21310,7 +21429,7 @@ function detail(c) {
|
|
|
21310
21429
|
["goals", c.goals.join("; ")],
|
|
21311
21430
|
["current action", c.currentAction],
|
|
21312
21431
|
["summary", c.summary],
|
|
21313
|
-
["notes", c.notes
|
|
21432
|
+
["notes", notesView(c.notes)],
|
|
21314
21433
|
["events", c.upcomingEvents.map((e) => `${e.date} ${e.type} ${e.title}`).join("\n ")],
|
|
21315
21434
|
["captured", c.capturedAt],
|
|
21316
21435
|
["updated", c.lastUpdated]
|
|
@@ -21444,7 +21563,7 @@ withCustomerOptions(
|
|
|
21444
21563
|
).action(async (src, o) => {
|
|
21445
21564
|
const body = buildCustomerBody(await readJsonInput(src), o);
|
|
21446
21565
|
if (!body.name) throw new CliError("usage", "name is required (pass --name or include it in the JSON)", EXIT.usage);
|
|
21447
|
-
|
|
21566
|
+
rejectRawNotes(body);
|
|
21448
21567
|
warnPayload(body);
|
|
21449
21568
|
const { customer } = await (await client()).addCustomer(body);
|
|
21450
21569
|
out(`Created ${line(customer)}`, { customer, created: true });
|
|
@@ -21485,7 +21604,7 @@ withCustomerOptions(
|
|
|
21485
21604
|
}
|
|
21486
21605
|
}
|
|
21487
21606
|
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);
|
|
21488
|
-
|
|
21607
|
+
rejectRawNotes(body);
|
|
21489
21608
|
warnPayload(body);
|
|
21490
21609
|
const { customer } = await api.updateCustomer(id, body);
|
|
21491
21610
|
out(`Updated ${line(customer)}`, { customer, updated: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightcrm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
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",
|