insightcrm 0.1.1 → 0.1.2
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 -1
- package/SKILL.md +6 -5
- package/dist/cli.js +29 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ crm login https://<你的服务器> # 浏览器里点「允许」(设备
|
|
|
10
10
|
crm schema --json # 字段契约,含每个字段的填写指引
|
|
11
11
|
echo '{"name":"王小明","company":"ACME"}' | crm add - --json
|
|
12
12
|
crm list --due-today --json
|
|
13
|
-
crm skill
|
|
13
|
+
crm skill # 打印给 agent 的使用说明;在 agent 指令里加一句「先运行 crm skill」
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
- `--json` 时 stdout 只有一个 JSON 对象,过程信息走 stderr。
|
package/SKILL.md
CHANGED
|
@@ -140,9 +140,10 @@ crm import backup.json # 重复导入同一份是安全的(相同 id
|
|
|
140
140
|
|
|
141
141
|
`crm rm <id> --yes` 删除客户,**先问用户**。客户的钩子会保留在钩子库里。
|
|
142
142
|
|
|
143
|
-
##
|
|
143
|
+
## 这份说明从哪来
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
`crm skill` 把这份说明打印出来,内容永远和当前安装的 CLI 版本一致。**处理客户相关的事(录入、更新、查询、推荐)之前先运行一次 `crm skill`,并按它执行。**
|
|
146
|
+
|
|
147
|
+
想让你的 agent 每次都这样做,在它的指令里(`CLAUDE.md`、`AGENTS.md` 或系统提示)加一句:
|
|
148
|
+
|
|
149
|
+
> 处理客户档案之前,先运行 `crm skill` 读最新说明,并按它执行。
|
package/dist/cli.js
CHANGED
|
@@ -7,9 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { spawn } from "child_process";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import path3 from "path";
|
|
10
|
+
import { readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
11
|
+
import { hostname as hostname3, platform } from "os";
|
|
13
12
|
import { fileURLToPath } from "url";
|
|
14
13
|
import { createInterface } from "readline/promises";
|
|
15
14
|
import { Command, Option } from "commander";
|
|
@@ -849,10 +848,10 @@ function mergeDefs(...defs) {
|
|
|
849
848
|
function cloneDef(schema) {
|
|
850
849
|
return mergeDefs(schema._zod.def);
|
|
851
850
|
}
|
|
852
|
-
function getElementAtPath(obj,
|
|
853
|
-
if (!
|
|
851
|
+
function getElementAtPath(obj, path3) {
|
|
852
|
+
if (!path3)
|
|
854
853
|
return obj;
|
|
855
|
-
return
|
|
854
|
+
return path3.reduce((acc, key) => acc?.[key], obj);
|
|
856
855
|
}
|
|
857
856
|
function promiseAllObject(promisesObj) {
|
|
858
857
|
const keys = Object.keys(promisesObj);
|
|
@@ -1192,11 +1191,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1192
1191
|
}
|
|
1193
1192
|
return false;
|
|
1194
1193
|
}
|
|
1195
|
-
function prefixIssues(
|
|
1194
|
+
function prefixIssues(path3, issues) {
|
|
1196
1195
|
return issues.map((iss) => {
|
|
1197
1196
|
var _a3;
|
|
1198
1197
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1199
|
-
iss.path.unshift(
|
|
1198
|
+
iss.path.unshift(path3);
|
|
1200
1199
|
return iss;
|
|
1201
1200
|
});
|
|
1202
1201
|
}
|
|
@@ -1658,16 +1657,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1658
1657
|
}
|
|
1659
1658
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
1660
1659
|
const fieldErrors = { _errors: [] };
|
|
1661
|
-
const processError = (error63,
|
|
1660
|
+
const processError = (error63, path3 = []) => {
|
|
1662
1661
|
for (const issue2 of error63.issues) {
|
|
1663
1662
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1664
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1663
|
+
issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
|
|
1665
1664
|
} else if (issue2.code === "invalid_key") {
|
|
1666
|
-
processError({ issues: issue2.issues }, [...
|
|
1665
|
+
processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
|
|
1667
1666
|
} else if (issue2.code === "invalid_element") {
|
|
1668
|
-
processError({ issues: issue2.issues }, [...
|
|
1667
|
+
processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
|
|
1669
1668
|
} else {
|
|
1670
|
-
const fullpath = [...
|
|
1669
|
+
const fullpath = [...path3, ...issue2.path];
|
|
1671
1670
|
if (fullpath.length === 0) {
|
|
1672
1671
|
fieldErrors._errors.push(mapper(issue2));
|
|
1673
1672
|
} else {
|
|
@@ -1706,17 +1705,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1706
1705
|
}
|
|
1707
1706
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
1708
1707
|
const result = { errors: [] };
|
|
1709
|
-
const processError = (error63,
|
|
1708
|
+
const processError = (error63, path3 = []) => {
|
|
1710
1709
|
var _a3;
|
|
1711
1710
|
for (const issue2 of error63.issues) {
|
|
1712
1711
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1713
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1712
|
+
issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
|
|
1714
1713
|
} else if (issue2.code === "invalid_key") {
|
|
1715
|
-
processError({ issues: issue2.issues }, [...
|
|
1714
|
+
processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
|
|
1716
1715
|
} else if (issue2.code === "invalid_element") {
|
|
1717
|
-
processError({ issues: issue2.issues }, [...
|
|
1716
|
+
processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
|
|
1718
1717
|
} else {
|
|
1719
|
-
const fullpath = [...
|
|
1718
|
+
const fullpath = [...path3, ...issue2.path];
|
|
1720
1719
|
if (fullpath.length === 0) {
|
|
1721
1720
|
result.errors.push(mapper(issue2));
|
|
1722
1721
|
continue;
|
|
@@ -1755,8 +1754,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1755
1754
|
}
|
|
1756
1755
|
function toDotPath(_path) {
|
|
1757
1756
|
const segs = [];
|
|
1758
|
-
const
|
|
1759
|
-
for (const seg of
|
|
1757
|
+
const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1758
|
+
for (const seg of path3) {
|
|
1760
1759
|
if (typeof seg === "number")
|
|
1761
1760
|
segs.push(`[${seg}]`);
|
|
1762
1761
|
else if (typeof seg === "symbol")
|
|
@@ -18894,13 +18893,13 @@ function resolveRef(ref, ctx) {
|
|
|
18894
18893
|
if (!ref.startsWith("#")) {
|
|
18895
18894
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18896
18895
|
}
|
|
18897
|
-
const
|
|
18898
|
-
if (
|
|
18896
|
+
const path3 = ref.slice(1).split("/").filter(Boolean);
|
|
18897
|
+
if (path3.length === 0) {
|
|
18899
18898
|
return ctx.rootSchema;
|
|
18900
18899
|
}
|
|
18901
18900
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18902
|
-
if (
|
|
18903
|
-
const key =
|
|
18901
|
+
if (path3[0] === defsKey) {
|
|
18902
|
+
const key = path3[1] === void 0 ? void 0 : decodeJSONPointerSegment(path3[1]);
|
|
18904
18903
|
if (!key || !ctx.defs[key]) {
|
|
18905
18904
|
throw new Error(`Reference not found: ${ref}`);
|
|
18906
18905
|
}
|
|
@@ -20059,7 +20058,7 @@ function defaultLang(env = process.env) {
|
|
|
20059
20058
|
// package.json
|
|
20060
20059
|
var package_default = {
|
|
20061
20060
|
name: "insightcrm",
|
|
20062
|
-
version: "0.1.
|
|
20061
|
+
version: "0.1.2",
|
|
20063
20062
|
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.",
|
|
20064
20063
|
license: "MIT",
|
|
20065
20064
|
type: "module",
|
|
@@ -20112,6 +20111,7 @@ var program = new Command().name("crm").description("InsightCRM command line: re
|
|
|
20112
20111
|
"after",
|
|
20113
20112
|
`
|
|
20114
20113
|
Recommended workflow (for agents):
|
|
20114
|
+
Read first skill (prints the full agent instructions; do this before your first task)
|
|
20115
20115
|
First time login <server-url> (a human approves in the browser)
|
|
20116
20116
|
Learn the fields schema --json (field types AND how to fill each one: read the "guide" texts)
|
|
20117
20117
|
Before adding search <name> --json (avoid duplicates; if the customer exists, update instead of add)
|
|
@@ -20347,18 +20347,11 @@ program.command("whoami").description("Show the current server and account").act
|
|
|
20347
20347
|
const { user } = await (await client()).me();
|
|
20348
20348
|
out(`${user.email} (${user.role}${user.emailVerified ? "" : ", email NOT verified: read-only"}) on ${name ?? apiUrl} \xB7 ${apiUrl}`, { server: name ?? null, url: apiUrl, user });
|
|
20349
20349
|
});
|
|
20350
|
-
program.command("skill").description("Print the agent
|
|
20350
|
+
program.command("skill").description("Print the agent instructions (SKILL.md) for this CLI. Agents: run this before your first task and follow it. Nothing is installed anywhere.").action(async () => {
|
|
20351
20351
|
const src = fileURLToPath(new URL("../SKILL.md", import.meta.url));
|
|
20352
|
-
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
else process.stdout.write(text);
|
|
20356
|
-
return;
|
|
20357
|
-
}
|
|
20358
|
-
const dest = path3.join(o.dir ? path3.resolve(o.dir) : path3.join(homedir2(), ".claude", "skills"), "insightcrm");
|
|
20359
|
-
await mkdir3(dest, { recursive: true });
|
|
20360
|
-
await cp(src, path3.join(dest, "SKILL.md"));
|
|
20361
|
-
out(`Installed skill to ${dest}/SKILL.md. Restart Claude Code to pick it up.`, { ok: true, path: path3.join(dest, "SKILL.md") });
|
|
20352
|
+
const text = await readFile3(src, "utf8");
|
|
20353
|
+
if (g().json) out("", { path: src, content: text });
|
|
20354
|
+
else process.stdout.write(text);
|
|
20362
20355
|
});
|
|
20363
20356
|
program.command("schema").description('Field definitions AND filling guidance: the contract for writing records. Read the "guide" of every field before you add.').addOption(new Option("--entity <name>", "only this entity").choices([...ENTITIES])).action(async (o) => {
|
|
20364
20357
|
const entities = (o.entity ? [o.entity] : [...ENTITIES]).map((e) => ({ entity: e, ...SCHEMA[e] }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "insightcrm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|