zen-code 2.4.0 → 3.0.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/dist/FileSystemConfigStore-Bog5vylu.mjs +47 -0
- package/dist/FileSystemPluginStore-ChortK7z.mjs +64 -0
- package/dist/FileSystemSkillStore-yvEvcRxB.mjs +94 -0
- package/dist/{app-lHPjGHmt.mjs → app-DBEp0HbC.mjs} +4882 -3541
- package/dist/{checkpoint-1sAx_j1E-C0EYTuT-.mjs → checkpoint-1sAx_j1E-BlqgvrDY.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-CAOqcFbm.mjs → checkpoint-DxiUsHMy-BWVXO0Oa.mjs} +2 -2
- package/dist/{MultiSelect-DrVbSEyF.mjs → get_allowed_models-I8bki8ev.mjs} +38 -39
- package/dist/{graph-aTwGGPhX.mjs → graphBuilder-BttmR-dZ.mjs} +5024 -4669
- package/dist/{id-D-r9rdKn.mjs → id-C3QYmEcI.mjs} +1 -1
- package/dist/{index-CXBzoLA3.mjs → index-BmxiURq0.mjs} +3 -3
- package/dist/index-P-c4tqBO.mjs +194 -0
- package/dist/nonInteractive.mjs +31 -26
- package/dist/{queue-D6tEGCGs-84eznfPM.mjs → queue-D6tEGCGs-BLJPuWhS.mjs} +1 -1
- package/dist/{shallow-BYTBwLe_.mjs → shallow-Cn-uyrVQ.mjs} +3 -3
- package/dist/tasks-BemLKkuC.mjs +112 -0
- package/dist/zen-code.mjs +1 -1
- package/dist/zen-init.mjs +43 -43
- package/package.json +5 -2
- package/dist/index-DpsJ-2by.mjs +0 -23
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Low as a } from "lowdb";
|
|
2
|
+
import { JSONFile as r } from "lowdb/node";
|
|
3
|
+
import s from "node:os";
|
|
4
|
+
import t from "node:path";
|
|
5
|
+
import d from "node:fs";
|
|
6
|
+
const o = {
|
|
7
|
+
config: {
|
|
8
|
+
main_model: "claude-sonnet-4-5",
|
|
9
|
+
model_provider: "openai"
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
class g {
|
|
13
|
+
db;
|
|
14
|
+
zenConfigDir;
|
|
15
|
+
dbPath;
|
|
16
|
+
constructor() {
|
|
17
|
+
const i = s.homedir();
|
|
18
|
+
this.zenConfigDir = t.join(i, ".zen-code");
|
|
19
|
+
const e = t.join(this.zenConfigDir, "settings.json"), n = new r(e);
|
|
20
|
+
this.dbPath = e, this.db = new a(n, o);
|
|
21
|
+
}
|
|
22
|
+
async initialize() {
|
|
23
|
+
await d.promises.mkdir(this.zenConfigDir, { recursive: !0 }), await this.db.read(), (!this.db.data || !this.db.data.config) && (this.db.data = o, await this.db.write()), this.syncEnvFromConfig();
|
|
24
|
+
}
|
|
25
|
+
async getConfig() {
|
|
26
|
+
return await this.db.read(), this.db.data.config;
|
|
27
|
+
}
|
|
28
|
+
async updateConfig(i) {
|
|
29
|
+
await this.db.read(), Object.assign(this.db.data.config, i), await this.db.write(), this.syncEnvFromConfig();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 将配置同步到环境变量
|
|
33
|
+
*/
|
|
34
|
+
syncEnvFromConfig() {
|
|
35
|
+
const i = this.db.data.config;
|
|
36
|
+
i.model_provider && (process.env.MODEL_PROVIDER = i.model_provider), i.openai_api_key && (process.env.OPENAI_API_KEY = i.openai_api_key), i.openai_base_url && (process.env.OPENAI_BASE_URL = i.openai_base_url), i.anthropic_api_key && (process.env.ANTHROPIC_API_KEY = i.anthropic_api_key), i.anthropic_base_url && (process.env.ANTHROPIC_BASE_URL = i.anthropic_base_url);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 获取配置目录路径
|
|
40
|
+
*/
|
|
41
|
+
getZenConfigDir() {
|
|
42
|
+
return this.zenConfigDir;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
g as FileSystemConfigStore
|
|
47
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import r from "node:fs/promises";
|
|
2
|
+
import s from "node:path";
|
|
3
|
+
import a from "node:os";
|
|
4
|
+
class f {
|
|
5
|
+
pluginsDir;
|
|
6
|
+
constructor() {
|
|
7
|
+
const i = a.homedir();
|
|
8
|
+
this.pluginsDir = s.join(i, ".zen-code", "plugins");
|
|
9
|
+
}
|
|
10
|
+
async listPlugins() {
|
|
11
|
+
try {
|
|
12
|
+
const i = await r.readdir(this.pluginsDir, { withFileTypes: !0 }), n = [];
|
|
13
|
+
for (const t of i)
|
|
14
|
+
if (t.isDirectory()) {
|
|
15
|
+
const e = s.join(this.pluginsDir, t.name, "plugin.json");
|
|
16
|
+
try {
|
|
17
|
+
const u = await r.readFile(e, "utf-8"), o = JSON.parse(u);
|
|
18
|
+
n.push({
|
|
19
|
+
name: t.name,
|
|
20
|
+
version: o.version || "0.0.0",
|
|
21
|
+
enabled: o.enabled !== !1
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return n;
|
|
27
|
+
} catch {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async getPluginConfig(i) {
|
|
32
|
+
const n = s.join(this.pluginsDir, i, "plugin.json");
|
|
33
|
+
try {
|
|
34
|
+
const t = await r.readFile(n, "utf-8");
|
|
35
|
+
return JSON.parse(t);
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async updatePluginConfig(i, n) {
|
|
41
|
+
const t = s.join(this.pluginsDir, i);
|
|
42
|
+
await r.mkdir(t, { recursive: !0 });
|
|
43
|
+
const e = s.join(t, "plugin.json");
|
|
44
|
+
await r.writeFile(e, JSON.stringify(n, null, 2), "utf-8");
|
|
45
|
+
}
|
|
46
|
+
async installPlugin(i, n) {
|
|
47
|
+
const t = s.join(this.pluginsDir, i);
|
|
48
|
+
await r.mkdir(t, { recursive: !0 });
|
|
49
|
+
const e = {
|
|
50
|
+
name: i,
|
|
51
|
+
version: "0.0.1",
|
|
52
|
+
enabled: !0,
|
|
53
|
+
source: n
|
|
54
|
+
};
|
|
55
|
+
await this.updatePluginConfig(i, e);
|
|
56
|
+
}
|
|
57
|
+
async uninstallPlugin(i) {
|
|
58
|
+
const n = s.join(this.pluginsDir, i);
|
|
59
|
+
await r.rm(n, { recursive: !0, force: !0 });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
f as FileSystemPluginStore
|
|
64
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import n from "node:fs/promises";
|
|
2
|
+
import e from "node:path";
|
|
3
|
+
import m from "node:os";
|
|
4
|
+
import o from "yaml";
|
|
5
|
+
class f {
|
|
6
|
+
skillsDir;
|
|
7
|
+
projectSkillsDir;
|
|
8
|
+
constructor() {
|
|
9
|
+
const t = m.homedir();
|
|
10
|
+
this.skillsDir = e.join(t, ".deepagents", "code", "skills"), this.projectSkillsDir = e.join(process.cwd(), ".claude", "skills");
|
|
11
|
+
}
|
|
12
|
+
async listSkills() {
|
|
13
|
+
const t = [], i = await this.listSkillsInDir(this.skillsDir);
|
|
14
|
+
t.push(...i);
|
|
15
|
+
const s = await this.listSkillsInDir(this.projectSkillsDir);
|
|
16
|
+
return t.push(...s), t;
|
|
17
|
+
}
|
|
18
|
+
async listSkillsInDir(t) {
|
|
19
|
+
try {
|
|
20
|
+
const i = await n.readdir(t, { withFileTypes: !0 }), s = [];
|
|
21
|
+
for (const r of i)
|
|
22
|
+
if (r.isDirectory()) {
|
|
23
|
+
const l = e.join(t, r.name, "SKILL.md");
|
|
24
|
+
try {
|
|
25
|
+
const a = await n.readFile(l, "utf-8"), c = this.parseFrontmatter(a);
|
|
26
|
+
s.push({
|
|
27
|
+
name: r.name,
|
|
28
|
+
description: c.description || "",
|
|
29
|
+
path: l
|
|
30
|
+
});
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return s;
|
|
35
|
+
} catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async getSkill(t) {
|
|
40
|
+
const i = e.join(this.projectSkillsDir, t, "SKILL.md");
|
|
41
|
+
try {
|
|
42
|
+
const r = await n.readFile(i, "utf-8");
|
|
43
|
+
return this.parseSkillContent(r);
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
const s = e.join(this.skillsDir, t, "SKILL.md");
|
|
47
|
+
try {
|
|
48
|
+
const r = await n.readFile(s, "utf-8");
|
|
49
|
+
return this.parseSkillContent(r);
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async saveSkill(t, i) {
|
|
55
|
+
const s = e.join(this.skillsDir, t);
|
|
56
|
+
await n.mkdir(s, { recursive: !0 });
|
|
57
|
+
const r = this.formatSkillContent(i);
|
|
58
|
+
await n.writeFile(e.join(s, "SKILL.md"), r, "utf-8");
|
|
59
|
+
}
|
|
60
|
+
async deleteSkill(t) {
|
|
61
|
+
const i = e.join(this.skillsDir, t);
|
|
62
|
+
await n.rm(i, { recursive: !0, force: !0 });
|
|
63
|
+
}
|
|
64
|
+
async syncFromRemote(t) {
|
|
65
|
+
const i = await t.listRemoteSkills();
|
|
66
|
+
for (const s of i) {
|
|
67
|
+
const r = await t.fetchSkill(s.name);
|
|
68
|
+
r && await this.saveSkill(s.name, r);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
parseFrontmatter(t) {
|
|
72
|
+
const i = t.match(/^---\n(.+?)\n---/s);
|
|
73
|
+
if (!i) return {};
|
|
74
|
+
try {
|
|
75
|
+
return o.parse(i[1]);
|
|
76
|
+
} catch {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
parseSkillContent(t) {
|
|
81
|
+
const i = this.parseFrontmatter(t), s = t.replace(/^---\n.+?\n---\n*/s, "");
|
|
82
|
+
return { frontmatter: i, markdown: s };
|
|
83
|
+
}
|
|
84
|
+
formatSkillContent(t) {
|
|
85
|
+
return `---
|
|
86
|
+
${o.stringify(t.frontmatter).trim()}
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
${t.markdown}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
f as FileSystemSkillStore
|
|
94
|
+
};
|