insightcrm 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/SKILL.md +41 -6
- package/dist/cli.js +44 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ crm add --name "王小明" --org "同济大学:在职教师:在职"
|
|
|
16
16
|
crm list --relationship 甲方 --json # 甲方名单
|
|
17
17
|
crm list --org 同济 --json # 挂在某个机构的客户
|
|
18
18
|
crm list --due-today --json
|
|
19
|
+
crm list --sort urgent --limit 20 --json # 最紧迫的 20 个;--offset 取下一页,返回里有 hasMore / nextOffset
|
|
19
20
|
crm version # 当前版本 + npm 上有没有新版
|
|
20
21
|
crm skill # 打印给 agent 的使用说明;在 agent 指令里加一句「先运行 crm skill」
|
|
21
22
|
```
|
package/SKILL.md
CHANGED
|
@@ -41,8 +41,8 @@ crm login https://<服务器地址>
|
|
|
41
41
|
|
|
42
42
|
**身份与联系**:`name`、`company`、`title`;`wechatId`、`city`。只填材料里明确出现的。看不到就省略,不要猜。
|
|
43
43
|
- **`name` 只写姓名本身**(含常用英文名,如「李源枫 Philip F. Yuan」),不超过 40 字,**不要带括号注释**。「白微微(微信名…,昵称…,微信号…)」这种写法会被服务端拒绝。
|
|
44
|
-
- 微信号(登录用的 ID)写 `wechatId`;微信昵称 / 显示名 / 群昵称写进 `socials`(`platform` 用 `wechat`,见下);职务、城市写各自字段;「真名未知」「shadow 备注」之类的说明写进
|
|
45
|
-
- 无法确定真名时,`name`
|
|
44
|
+
- 微信号(登录用的 ID)写 `wechatId`;微信昵称 / 显示名 / 群昵称写进 `socials`(`platform` 用 `wechat`,见下);职务、城市写各自字段;「真名未知」「shadow 备注」之类的说明写进 notes(`--note-fact`,见「写 notes」)。
|
|
45
|
+
- 无法确定真名时,`name` 写对方使用的称呼,并追加一条 `--note-fact "真名未知,暂用对方自称"`。
|
|
46
46
|
`city` 取 `crm schema --json` 里 `city` 字段的 `values`(城市枚举);写成「上海市」「Shanghai」「臺北」也会被自动归一化成「上海」「上海」「台北」,所以直接按你看到的写就行。
|
|
47
47
|
|
|
48
48
|
**画像**:
|
|
@@ -107,7 +107,27 @@ crm login https://<服务器地址>
|
|
|
107
107
|
- 只在元数据里出现、原图上找不到的,写成「导出元数据记作 X(图片未佐证)」,别当成事实。
|
|
108
108
|
- **判断是不是同一个人,头像一致是最硬的证据**,比文字描述可靠;不同平台头像不同很正常,不要据此起疑。
|
|
109
109
|
- 性别、真实姓名这类「看起来像事实」的东西,原图上没有书面依据就不要写——微信名片、小红书主页、私信截图都不含性别信息,照片也认不出人,中文名尤其不能靠猜。
|
|
110
|
-
-
|
|
110
|
+
- 核对出旧档案写错了,回头改掉,并追加一条 `--note-fact` **更正说明**写清原来错在哪、正确是什么,别静默改掉——错值留痕才知道当时错在哪。
|
|
111
|
+
|
|
112
|
+
## 写 notes
|
|
113
|
+
|
|
114
|
+
`notes` **不能直接写**:没有 `--notes`,JSON 里带 `notes` 也会被拒。它是服务端维护的 markdown,你只能**追加一条**或**删一条**,服务端负责拼成 `事实 / 判断 / 待核实 / 历史备注` 四段。
|
|
115
|
+
|
|
116
|
+
**notes 装什么**:结构化字段装不下、之后还要回头看的东西——带日期的事实、你的判断、还没确认的事。
|
|
117
|
+
**不要放**:微信号 / 昵称 / 视频号 / 标签(有 `wechatId` / `socials` / `relationships`)、下一步动作(写 `currentAction`)、对话原文、截图逐字转录。
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
crm update <id> --note-fact "做 AI 画框,硬件是微雪屏 + 润芯微开发板" --note-source 直播答疑 --note-date 10-28
|
|
121
|
+
crm update <id> --note-judgment "艺术化 IP + 小硬件方向可行,暂无采购意向"
|
|
122
|
+
crm update <id> --note-todo "是否有量产计划"
|
|
123
|
+
crm update <id> --note-drop fact:2 # 序号取自 crm get 的输出
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- `--note-fact`:发生过什么、对方说了什么。`--note-judgment`:你的结论,一两句。`--note-todo`:还没确认的。
|
|
127
|
+
- **每条一句话,≤150 字,单行。** 超了就拆,或只留要紧的。`--note-source` ≤20 字(「名片」「朋友圈」),`--note-date` 写事情发生的日期(`YYYY-MM-DD` 或 `MM-DD`),不写默认今天;它们作用于本次调用追加的全部条目。
|
|
128
|
+
- **同一件事改写原条目,不要重复追加**:先 `--note-drop` 旧的,再 `--note-fact` 新的。每段最多 20 条。
|
|
129
|
+
- **预算 3000 字**(硬上限 10000)。超了服务端拒绝追加,报错里会说现有多少字。这时先压缩再写:`--note-drop` 删过时条目;老客户的存量自由文本显示为 `legacy`(历史备注),把里面还有用的内容提炼成几条短条目追加,再用 `--note-legacy "压缩后的文本"` 整段改写(传 `''` 清空)。同一条命令里可以先压缩再追加。
|
|
130
|
+
- `crm get` 里结构化的 notes 按 `fact:1`、`todo:2` 带序号显示;老客户没有结构标记的会标 `(legacy free text)`,原样保留,不用管它,除非要追加时被预算挡住。
|
|
111
131
|
|
|
112
132
|
## 成功钩子
|
|
113
133
|
|
|
@@ -158,6 +178,21 @@ crm list --related 李雅婷 --json # 和李雅婷有关系的人
|
|
|
158
178
|
crm get <id> --json
|
|
159
179
|
```
|
|
160
180
|
|
|
181
|
+
### 排序与分页(客户多时用)
|
|
182
|
+
|
|
183
|
+
`list` / `search` 默认一次返回**全部**客户,顺序是「最近更新在前」。库里人多时,别拉全库,用 `--sort` 取最该先处理的,再用 `--limit` 分页:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
crm list --sort urgent --limit 20 --json # 黄金窗口最紧迫的 20 个(已过期的排最前)
|
|
187
|
+
crm list --sort urgent --limit 20 --offset 20 --json # 下一页(offset 用上一页返回的 nextOffset)
|
|
188
|
+
crm list --potential high --sort urgent --limit 10 --json # 筛选和排序、分页可以叠加
|
|
189
|
+
crm search 跨境 --limit 10 --json
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
- `--sort`:`urgent` 窗口到期最早在前 · `updated` 最近更新在前(默认)· `added` 最近添加在前 · `potential` High→Medium→Low,同级按紧迫 · `name` 姓名 A→Z。
|
|
193
|
+
- 不带 `--limit` 返回 `{customers, count}`。带了 `--limit` 只取一页,返回里多出 `total`(筛选后的总数)、`all`(全库总数)、`limit`、`offset`、`hasMore`、`nextOffset`。循环到 `hasMore` 为 `false` 就取完了;`nextOffset` 就是下一次的 `--offset`。
|
|
194
|
+
- `--offset` 必须和 `--limit` 一起用。`--sort` / `--limit` / `--offset` 写错值会以退出码 `2` 退出。
|
|
195
|
+
|
|
161
196
|
## 变更历史(这个客户什么时候被改过)
|
|
162
197
|
|
|
163
198
|
服务端记录每次改动**改了哪些字段、旧值和新值**。用它回答「这个人什么时候从潜客变成学员」「潜力是什么时候升上去的」「哪一次改动把机构加上的」。
|
|
@@ -180,11 +215,11 @@ crm history --all --json # 全局身份迁移:谁的主身份从什么变
|
|
|
180
215
|
|
|
181
216
|
```bash
|
|
182
217
|
crm lint --json # 全库体检:只报告,不改数据
|
|
183
|
-
crm lint --severity error --json # 只看会造成实际问题的(notes
|
|
218
|
+
crm lint --severity error --json # 只看会造成实际问题的(notes 超硬上限、状态越界、过期日程、悬空引用)
|
|
184
219
|
crm lint --kind company-prose --json # 只看某一类
|
|
185
220
|
```
|
|
186
221
|
|
|
187
|
-
报告的类别:`notes-over-limit
|
|
222
|
+
报告的类别:`notes-over-limit`(超 10000 字硬上限)、`notes-long`(超 3000 字预算,已不再接受追加,先压缩)、`unknown-status`(状态不在受控词表里,按状态聚合会漏)、
|
|
188
223
|
`expired-event`(过期日程)、`dangling-related-id`(相关人物指向库里没有的人)、
|
|
189
224
|
`related-ambiguous`(相关人物没写 id 也没写微信号,而它的名字在库里有 ≥2 个同名客户——指哪一位说不准)、
|
|
190
225
|
`related-wechat-unmatched`(相关人物写了微信号,但库里查不到这个号——可能拼错了,也可能对方还没入库)、
|
|
@@ -197,7 +232,7 @@ crm lint --kind company-prose --json # 只看某一类
|
|
|
197
232
|
**批量清洗存量请走 `db:backfill-*` 脚本**(保留 `last_updated`、写审计日志),别用 update 循环。
|
|
198
233
|
|
|
199
234
|
写入时 CLI 会把拿不准的地方打到 stderr 当提醒(未知的 `orgs.status`、清单外的城市、过期的日程、写成说明文的 company)。
|
|
200
|
-
|
|
235
|
+
**这些是提醒不是错误**,写入照常成功。notes 不在此列:它的规则由服务端强制,违反会被拒(见「写 notes」)。
|
|
201
236
|
|
|
202
237
|
## 推荐库(是用户的库存,不是聊天里挖出来的东西)
|
|
203
238
|
|
package/dist/cli.js
CHANGED
|
@@ -20752,7 +20752,7 @@ function renderPrompt(text, customer) {
|
|
|
20752
20752
|
// package.json
|
|
20753
20753
|
var package_default = {
|
|
20754
20754
|
name: "insightcrm",
|
|
20755
|
-
version: "0.1.
|
|
20755
|
+
version: "0.1.15",
|
|
20756
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.",
|
|
20757
20757
|
license: "MIT",
|
|
20758
20758
|
type: "module",
|
|
@@ -20852,7 +20852,8 @@ function createClient(apiUrl, token) {
|
|
|
20852
20852
|
`/customers${qs({
|
|
20853
20853
|
...f,
|
|
20854
20854
|
limit: p?.limit === void 0 ? void 0 : String(p.limit),
|
|
20855
|
-
offset: p?.offset === void 0 ? void 0 : String(p.offset)
|
|
20855
|
+
offset: p?.offset === void 0 ? void 0 : String(p.offset),
|
|
20856
|
+
sort: p?.sort
|
|
20856
20857
|
})}`
|
|
20857
20858
|
),
|
|
20858
20859
|
getCustomer: (id) => call("GET", `/customers/${enc(id)}`),
|
|
@@ -21251,15 +21252,43 @@ async function client(requireToken = true) {
|
|
|
21251
21252
|
return createClient(apiUrl, token);
|
|
21252
21253
|
}
|
|
21253
21254
|
var LIST_PAGE_SIZE = 500;
|
|
21254
|
-
async function fetchAllCustomers(api, f) {
|
|
21255
|
+
async function fetchAllCustomers(api, f, sort) {
|
|
21255
21256
|
const all = [];
|
|
21256
21257
|
for (let offset = 0; ; offset += LIST_PAGE_SIZE) {
|
|
21257
|
-
const r = await api.listCustomers(f, { limit: LIST_PAGE_SIZE, offset });
|
|
21258
|
+
const r = await api.listCustomers(f, { limit: LIST_PAGE_SIZE, offset, sort });
|
|
21258
21259
|
all.push(...r.customers);
|
|
21259
21260
|
if (r.customers.length < LIST_PAGE_SIZE || all.length >= r.total) break;
|
|
21260
21261
|
}
|
|
21261
21262
|
return all;
|
|
21262
21263
|
}
|
|
21264
|
+
var CUSTOMER_SORTS = ["urgent", "updated", "added", "potential", "name"];
|
|
21265
|
+
function pageOf(o) {
|
|
21266
|
+
if (o.sort !== void 0 && !CUSTOMER_SORTS.includes(o.sort)) {
|
|
21267
|
+
throw new CliError("usage", `--sort must be one of ${CUSTOMER_SORTS.join(", ")} (got "${o.sort}")`, EXIT.usage);
|
|
21268
|
+
}
|
|
21269
|
+
const int2 = (name, v, min) => {
|
|
21270
|
+
if (v === void 0) return void 0;
|
|
21271
|
+
const n = Number(v);
|
|
21272
|
+
if (!Number.isInteger(n) || n < min) throw new CliError("usage", `--${name} must be an integer >= ${min} (got "${v}")`, EXIT.usage);
|
|
21273
|
+
return n;
|
|
21274
|
+
};
|
|
21275
|
+
const limit = int2("limit", o.limit, 1);
|
|
21276
|
+
const offset = int2("offset", o.offset, 0);
|
|
21277
|
+
if (limit === void 0 && offset !== void 0) throw new CliError("usage", "--offset needs --limit", EXIT.usage);
|
|
21278
|
+
return { sort: o.sort, limit, offset: offset ?? 0 };
|
|
21279
|
+
}
|
|
21280
|
+
async function listForCli(api, f, o) {
|
|
21281
|
+
const { sort, limit, offset } = pageOf(o);
|
|
21282
|
+
if (limit === void 0) {
|
|
21283
|
+
const customers = await fetchAllCustomers(api, f, sort);
|
|
21284
|
+
return { customers, count: customers.length };
|
|
21285
|
+
}
|
|
21286
|
+
const r = await api.listCustomers(f, { limit, offset, sort });
|
|
21287
|
+
const next = offset + r.customers.length;
|
|
21288
|
+
const hasMore = next < r.total && r.customers.length > 0;
|
|
21289
|
+
return { customers: r.customers, count: r.customers.length, total: r.total, all: r.all, limit, offset, hasMore, nextOffset: hasMore ? next : null };
|
|
21290
|
+
}
|
|
21291
|
+
var PAGE_OPTS = (c) => c.option("--sort <key>", `order: ${CUSTOMER_SORTS.join(" | ")} (default updated = newest update first; urgent = golden window expiring soonest, overdue first)`).option("--limit <n>", "return one page of n customers (adds total/hasMore/nextOffset to --json); omit to get everyone").option("--offset <n>", "skip this many (needs --limit); continue with nextOffset");
|
|
21263
21292
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
21264
21293
|
function openBrowser(url2) {
|
|
21265
21294
|
const [cmd, args] = platform() === "darwin" ? ["open", [url2]] : platform() === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
@@ -21692,8 +21721,10 @@ program.command("lint").description("Audit every customer record and report what
|
|
|
21692
21721
|
].join("\n");
|
|
21693
21722
|
out(human, { scanned: customers.length, count: issues.length, errors, warns, infos, issues, perCustomer });
|
|
21694
21723
|
});
|
|
21695
|
-
|
|
21696
|
-
|
|
21724
|
+
PAGE_OPTS(
|
|
21725
|
+
program.command("list").description("List customers, optionally filtered. Default order is newest update first; --sort changes it, --limit/--offset page through large books.").option("--potential <High|Medium|Low>").option("--city <s>", "exact city (case-insensitive)").option("--tag <s>", "has this pain-point tag").option("--social-platform <s>", "has a social account on this platform (e.g. xiaohongshu, channels, email)").option("--relationship <s>", "has this relationship to the user (e.g. \u7532\u65B9 / client, \u5B66\u5458 / student, \u6E20\u9053\u65B9 / channel)").option("--org <s>", "is affiliated with this organization (substring match, e.g. \u540C\u6D4E / \u535A\u4E16)").option("--related <s>", "is connected to this person (substring match on the related-people list; also matches records that point at this customer)").option("--due-today", "has a calendar event today (your local date)").option("--due <YYYY-MM-DD>", "has a calendar event on this date").option("--expired [date]", "has a calendar event before this date (default: today) \u2014 overdue events nobody cleaned up").option("-q, --query <s>", "keyword across name, company, title, city, wechat, social accounts, relationships, organizations, related people, summary, notes, tags, goals")
|
|
21726
|
+
).action(async (o) => {
|
|
21727
|
+
const r = await listForCli(await client(), {
|
|
21697
21728
|
potential: o.potential ? potentialOf(o.potential) : void 0,
|
|
21698
21729
|
city: o.city,
|
|
21699
21730
|
tag: o.tag,
|
|
@@ -21704,12 +21735,14 @@ program.command("list").description("List customers (newest update first), optio
|
|
|
21704
21735
|
related: o.related,
|
|
21705
21736
|
dueOn: o.dueToday ? today() : o.due,
|
|
21706
21737
|
expiredBefore: o.expired ? o.expired === true ? today() : o.expired : void 0
|
|
21707
|
-
});
|
|
21708
|
-
out(customers.length ? customers.map(line).join("\n") : "No customers match.",
|
|
21738
|
+
}, o);
|
|
21739
|
+
out(r.customers.length ? r.customers.map(line).join("\n") : "No customers match.", r);
|
|
21709
21740
|
});
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21741
|
+
PAGE_OPTS(
|
|
21742
|
+
program.command("search").description("Search customers by keyword (same as `list -q`). Run this before `add` to avoid duplicates.").argument("<keyword>")
|
|
21743
|
+
).action(async (keyword, o) => {
|
|
21744
|
+
const r = await listForCli(await client(), { q: keyword }, o);
|
|
21745
|
+
out(r.customers.length ? r.customers.map(line).join("\n") : "No customers match.", r);
|
|
21713
21746
|
});
|
|
21714
21747
|
program.command("rm").description("Delete a customer (their hooks stay in the hook library)").argument("<id>").option("-y, --yes", "skip the confirmation (required when not a TTY)").action(async (id, o) => {
|
|
21715
21748
|
await confirm(`Delete customer ${id}?`, o.yes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightcrm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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",
|