@zhoujw0725/openerp-cli 0.1.0
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 +12 -0
- package/bin/openerp.js +14 -0
- package/install.js +70 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @zhoujw0725/openerp-cli
|
|
2
|
+
|
|
3
|
+
金蝶云·星空 (Kingdee K3 Cloud) ERP CLI —— 为人和 AI Agent 而生。只读查询:BOM/物料/采购/销售/库存/生产等 + 对象发现层 + 对象经验沉淀。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @zhoujw0725/openerp-cli
|
|
7
|
+
openerp --help
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
本包是壳:安装时(postinstall)按平台从 [GitHub Releases](https://github.com/xiaowen-0725/openerp-cli/releases) 下载对应的原生 Go 二进制,并 best-effort 把技能同步到本机各 AI agent(经 `npx skills`)。
|
|
11
|
+
|
|
12
|
+
源码、文档与 Agent 契约见仓库:<https://github.com/xiaowen-0725/openerp-cli>。
|
package/bin/openerp.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 透传 wrapper: 调用 postinstall 下载好的原生二进制。
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
|
|
7
|
+
const binName = process.platform === "win32" ? "openerp-bin.exe" : "openerp-bin";
|
|
8
|
+
const bin = path.join(__dirname, binName);
|
|
9
|
+
if (!fs.existsSync(bin)) {
|
|
10
|
+
console.error("[openerp] 未找到二进制, 请重新安装: npm i -g @zhoujw0725/openerp-cli");
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
14
|
+
process.exit(r.status == null ? 1 : r.status);
|
package/install.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// postinstall: 按平台从 GitHub Releases 下载对应的 openerp 二进制(版本与本包一致)。
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const { execFileSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
const pkg = require("./package.json");
|
|
8
|
+
const REPO = "xiaowen-0725/openerp-cli";
|
|
9
|
+
|
|
10
|
+
const plat = { darwin: "darwin", linux: "linux", win32: "windows" }[process.platform];
|
|
11
|
+
const arch = { x64: "amd64", arm64: "arm64" }[process.arch];
|
|
12
|
+
if (!plat || !arch) {
|
|
13
|
+
console.error(`[openerp] 不支持的平台: ${process.platform}/${process.arch}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ext = plat === "windows" ? "zip" : "tar.gz";
|
|
18
|
+
const asset = `openerp-cli_${pkg.version}_${plat}_${arch}.${ext}`;
|
|
19
|
+
const url = `https://github.com/${REPO}/releases/download/v${pkg.version}/${asset}`;
|
|
20
|
+
const binDir = path.join(__dirname, "bin");
|
|
21
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
22
|
+
const archive = path.join(binDir, asset);
|
|
23
|
+
|
|
24
|
+
(async () => {
|
|
25
|
+
console.log("[openerp] 下载", url);
|
|
26
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
27
|
+
if (!res.ok) throw new Error(`下载失败 HTTP ${res.status} — 确认已发布 v${pkg.version}`);
|
|
28
|
+
fs.writeFileSync(archive, Buffer.from(await res.arrayBuffer()));
|
|
29
|
+
|
|
30
|
+
if (ext === "zip") execFileSync("unzip", ["-o", archive, "-d", binDir], { stdio: "inherit" });
|
|
31
|
+
else execFileSync("tar", ["-xzf", archive, "-C", binDir], { stdio: "inherit" });
|
|
32
|
+
|
|
33
|
+
const src = path.join(binDir, plat === "windows" ? "openerp.exe" : "openerp");
|
|
34
|
+
const dst = path.join(binDir, plat === "windows" ? "openerp-bin.exe" : "openerp-bin");
|
|
35
|
+
fs.renameSync(src, dst);
|
|
36
|
+
fs.chmodSync(dst, 0o755);
|
|
37
|
+
fs.unlinkSync(archive);
|
|
38
|
+
console.log("[openerp] 安装完成");
|
|
39
|
+
|
|
40
|
+
// best-effort: 同步 AI Agent 技能到本机已装的各 agent(失败绝不影响安装)
|
|
41
|
+
syncSkills();
|
|
42
|
+
})().catch((e) => {
|
|
43
|
+
console.error("[openerp]", e.message);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// 把技能同步到本机所有已装 agent;失败只 warn,postinstall 不报错退出。
|
|
48
|
+
function syncSkills() {
|
|
49
|
+
try {
|
|
50
|
+
execFileSync("npx", ["-y", "skills", "add", REPO, "-g", "-y"], { stdio: "inherit" });
|
|
51
|
+
writeSkillsState();
|
|
52
|
+
console.log("[openerp] skills 已同步");
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.warn(`[openerp] skills 同步失败(可稍后手动:npx skills add ${REPO} -g):${e.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 写 skills-state.json 作基准(落 openerp 配置目录,与 config.Dir() 默认一致)。
|
|
59
|
+
function writeSkillsState() {
|
|
60
|
+
const base = process.env.OPENERP_CONFIG_DIR
|
|
61
|
+
? process.env.OPENERP_CONFIG_DIR
|
|
62
|
+
: path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config"), "openerp");
|
|
63
|
+
fs.mkdirSync(base, { recursive: true });
|
|
64
|
+
const state = {
|
|
65
|
+
version: pkg.version,
|
|
66
|
+
last_attempt_version: pkg.version,
|
|
67
|
+
updated_at: new Date().toISOString(),
|
|
68
|
+
};
|
|
69
|
+
fs.writeFileSync(path.join(base, "skills-state.json"), JSON.stringify(state, null, 2) + "\n");
|
|
70
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zhoujw0725/openerp-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "金蝶云·星空 (Kingdee K3 Cloud) ERP CLI — 为人和 AI Agent 而生(只读查询: BOM/物料/采购/销售/库存/生产等 + 对象发现 + 经验沉淀)",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"openerp",
|
|
10
|
+
"kingdee",
|
|
11
|
+
"金蝶",
|
|
12
|
+
"k3cloud",
|
|
13
|
+
"星空",
|
|
14
|
+
"erp",
|
|
15
|
+
"cli",
|
|
16
|
+
"ai-agent",
|
|
17
|
+
"bom"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"openerp": "bin/openerp.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"postinstall": "node install.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"bin/openerp.js",
|
|
27
|
+
"install.js",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"os": [
|
|
34
|
+
"darwin",
|
|
35
|
+
"linux",
|
|
36
|
+
"win32"
|
|
37
|
+
],
|
|
38
|
+
"cpu": [
|
|
39
|
+
"x64",
|
|
40
|
+
"arm64"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|