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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as C } from "./id-
|
|
2
|
-
import { B as v, c as x, T as $, m as I } from "./app-
|
|
3
|
-
import "./
|
|
1
|
+
import { u as C } from "./id-C3QYmEcI.mjs";
|
|
2
|
+
import { B as v, c as x, T as $, m as I } from "./app-DBEp0HbC.mjs";
|
|
3
|
+
import "./graphBuilder-BttmR-dZ.mjs";
|
|
4
4
|
import { createClient as O, createCluster as N } from "redis";
|
|
5
5
|
const W = [
|
|
6
6
|
{
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import "lowdb";
|
|
2
|
+
import "lowdb/node";
|
|
3
|
+
import "yaml";
|
|
4
|
+
import { z as i } from "zod";
|
|
5
|
+
class d {
|
|
6
|
+
configStore;
|
|
7
|
+
skillStore;
|
|
8
|
+
pluginStore;
|
|
9
|
+
remoteStore;
|
|
10
|
+
_initialized = !1;
|
|
11
|
+
constructor(t, e, r, o) {
|
|
12
|
+
this.configStore = t, this.skillStore = e, this.pluginStore = r, this.remoteStore = o;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 初始化管理器(延迟初始化)
|
|
16
|
+
* 必须在使用其他方法前调用
|
|
17
|
+
*/
|
|
18
|
+
async initialize() {
|
|
19
|
+
this._initialized || ("initialize" in this.configStore && typeof this.configStore.initialize == "function" && await this.configStore.initialize(), "initialize" in this.skillStore && typeof this.skillStore.initialize == "function" && await this.skillStore.initialize(), "initialize" in this.pluginStore && typeof this.pluginStore.initialize == "function" && await this.pluginStore.initialize(), this._initialized = !0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 确保已初始化(内部使用)
|
|
23
|
+
*/
|
|
24
|
+
async ensureInitialized() {
|
|
25
|
+
if (!this._initialized)
|
|
26
|
+
throw new Error("ConfigManager not initialized. Call await manager.initialize() first.");
|
|
27
|
+
}
|
|
28
|
+
// 配置相关
|
|
29
|
+
async getConfig() {
|
|
30
|
+
return await this.ensureInitialized(), await this.configStore.getConfig();
|
|
31
|
+
}
|
|
32
|
+
async updateConfig(t) {
|
|
33
|
+
return await this.ensureInitialized(), await this.configStore.updateConfig(t);
|
|
34
|
+
}
|
|
35
|
+
// Skills 相关
|
|
36
|
+
async listSkills() {
|
|
37
|
+
return await this.ensureInitialized(), await this.skillStore.listSkills();
|
|
38
|
+
}
|
|
39
|
+
async getSkill(t) {
|
|
40
|
+
return await this.ensureInitialized(), await this.skillStore.getSkill(t);
|
|
41
|
+
}
|
|
42
|
+
async saveSkill(t, e) {
|
|
43
|
+
return await this.ensureInitialized(), await this.skillStore.saveSkill(t, e);
|
|
44
|
+
}
|
|
45
|
+
async deleteSkill(t) {
|
|
46
|
+
return await this.ensureInitialized(), await this.skillStore.deleteSkill(t);
|
|
47
|
+
}
|
|
48
|
+
async syncSkillsFromRemote() {
|
|
49
|
+
if (await this.ensureInitialized(), !this.remoteStore)
|
|
50
|
+
throw new Error("Remote store not configured");
|
|
51
|
+
return await this.skillStore.syncFromRemote(this.remoteStore);
|
|
52
|
+
}
|
|
53
|
+
// Plugins 相关
|
|
54
|
+
async listPlugins() {
|
|
55
|
+
return await this.ensureInitialized(), await this.pluginStore.listPlugins();
|
|
56
|
+
}
|
|
57
|
+
async getPluginConfig(t) {
|
|
58
|
+
return await this.ensureInitialized(), await this.pluginStore.getPluginConfig(t);
|
|
59
|
+
}
|
|
60
|
+
async updatePluginConfig(t, e) {
|
|
61
|
+
return await this.ensureInitialized(), await this.pluginStore.updatePluginConfig(t, e);
|
|
62
|
+
}
|
|
63
|
+
async installPlugin(t, e) {
|
|
64
|
+
return await this.ensureInitialized(), await this.pluginStore.installPlugin(t, e);
|
|
65
|
+
}
|
|
66
|
+
async uninstallPlugin(t) {
|
|
67
|
+
return await this.ensureInitialized(), await this.pluginStore.uninstallPlugin(t);
|
|
68
|
+
}
|
|
69
|
+
/** fs 专用 */
|
|
70
|
+
getConfigPath() {
|
|
71
|
+
return this.configStore?.dbPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function p() {
|
|
75
|
+
const { FileSystemConfigStore: n } = await import("./FileSystemConfigStore-Bog5vylu.mjs"), { FileSystemSkillStore: t } = await import("./FileSystemSkillStore-yvEvcRxB.mjs"), { FileSystemPluginStore: e } = await import("./FileSystemPluginStore-ChortK7z.mjs"), r = new n(), o = new t(), g = new e(), l = new d(r, o, g);
|
|
76
|
+
return await l.initialize(), l;
|
|
77
|
+
}
|
|
78
|
+
const m = i.enum(["idea", "bug_report", "feature", "refactor"]), S = i.enum(["low", "medium", "high", "critical"]), h = i.enum(["pending", "planned", "archived"]), f = i.enum(["user_input", "ai_suggestion", "conversation_derived"]), y = i.object({
|
|
79
|
+
id: i.string().uuid(),
|
|
80
|
+
type: m,
|
|
81
|
+
title: i.string().min(1).max(200),
|
|
82
|
+
description: i.string(),
|
|
83
|
+
priority: S.default("medium"),
|
|
84
|
+
source: f,
|
|
85
|
+
status: h.default("pending"),
|
|
86
|
+
createdAt: i.string().datetime(),
|
|
87
|
+
tags: i.array(i.string()).default([]),
|
|
88
|
+
metadata: i.object({
|
|
89
|
+
relatedFiles: i.array(i.string()).optional(),
|
|
90
|
+
conversationContext: i.string().optional(),
|
|
91
|
+
estimatedComplexity: i.enum(["simple", "medium", "complex"]).optional()
|
|
92
|
+
}).optional()
|
|
93
|
+
});
|
|
94
|
+
i.object({
|
|
95
|
+
version: i.literal("1.0"),
|
|
96
|
+
sparks: i.array(y),
|
|
97
|
+
lastUpdated: i.string().datetime()
|
|
98
|
+
});
|
|
99
|
+
const u = i.enum([
|
|
100
|
+
"pickup",
|
|
101
|
+
// 待领取(新任务,未被 agent 接管)
|
|
102
|
+
"running",
|
|
103
|
+
// 运行中(agent 正在执行)
|
|
104
|
+
"complete",
|
|
105
|
+
// 已完成(成功完成)
|
|
106
|
+
"error",
|
|
107
|
+
// 已失败(失败,暂停中)
|
|
108
|
+
"review",
|
|
109
|
+
// 待审核(完成,等待人工确认)
|
|
110
|
+
"feedback"
|
|
111
|
+
// 待反馈(agent 卡住,需要人工输入)
|
|
112
|
+
]), s = i.enum([
|
|
113
|
+
"default",
|
|
114
|
+
"planner",
|
|
115
|
+
"reviewer",
|
|
116
|
+
"refactor",
|
|
117
|
+
"finder",
|
|
118
|
+
"debugger"
|
|
119
|
+
]), w = i.enum(["serial", "parallel"]), c = i.lazy(
|
|
120
|
+
() => i.object({
|
|
121
|
+
// 基本信息
|
|
122
|
+
id: i.string(),
|
|
123
|
+
title: i.string().min(1).max(200),
|
|
124
|
+
description: i.string(),
|
|
125
|
+
// 执行控制
|
|
126
|
+
execution: w.optional(),
|
|
127
|
+
children: i.array(i.lazy(() => c)).optional(),
|
|
128
|
+
// Agent 分配
|
|
129
|
+
agentType: s.optional(),
|
|
130
|
+
threadId: i.string().optional(),
|
|
131
|
+
// 元数据
|
|
132
|
+
estimatedTime: i.string().optional(),
|
|
133
|
+
complexity: i.enum(["simple", "medium", "complex"]).optional(),
|
|
134
|
+
dependencies: i.array(i.string()).optional(),
|
|
135
|
+
acceptanceCriteria: i.array(i.string()).optional(),
|
|
136
|
+
// 状态相关(运行时)
|
|
137
|
+
status: u.optional(),
|
|
138
|
+
startedAt: i.string().datetime().optional(),
|
|
139
|
+
completedAt: i.string().datetime().optional(),
|
|
140
|
+
assignedTo: s.optional(),
|
|
141
|
+
error: i.object({
|
|
142
|
+
message: i.string(),
|
|
143
|
+
stack: i.string().optional(),
|
|
144
|
+
retryCount: i.number().optional()
|
|
145
|
+
}).optional()
|
|
146
|
+
})
|
|
147
|
+
), k = i.object({
|
|
148
|
+
taskId: i.string(),
|
|
149
|
+
planId: i.string(),
|
|
150
|
+
threadId: i.string(),
|
|
151
|
+
// 关联的 LangGraph thread ID
|
|
152
|
+
agentType: s,
|
|
153
|
+
// 改为类型安全的 AgentType
|
|
154
|
+
status: u,
|
|
155
|
+
startedAt: i.string().datetime(),
|
|
156
|
+
completedAt: i.string().datetime().optional(),
|
|
157
|
+
output: i.string().optional(),
|
|
158
|
+
error: i.string().optional(),
|
|
159
|
+
changedFiles: i.array(i.string()).optional()
|
|
160
|
+
});
|
|
161
|
+
i.object({
|
|
162
|
+
version: i.literal("1.0"),
|
|
163
|
+
lastUpdated: i.string().datetime(),
|
|
164
|
+
// 活跃的任务树
|
|
165
|
+
activePlanId: i.string().optional(),
|
|
166
|
+
tasks: i.record(i.string(), c),
|
|
167
|
+
// 执行历史
|
|
168
|
+
history: i.array(k),
|
|
169
|
+
// 全局配置
|
|
170
|
+
config: i.object({
|
|
171
|
+
maxConcurrentAgents: i.number().min(1).max(10).default(3),
|
|
172
|
+
retryLimit: i.number().min(0).max(10).default(3),
|
|
173
|
+
autoResume: i.boolean().default(!1)
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
const a = await p(), z = async () => {
|
|
177
|
+
await a.initialize();
|
|
178
|
+
}, C = async () => await a.getConfig(), b = async (n) => {
|
|
179
|
+
await a.updateConfig(n);
|
|
180
|
+
}, T = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
181
|
+
__proto__: null,
|
|
182
|
+
configStore: a,
|
|
183
|
+
getConfig: C,
|
|
184
|
+
initDb: z,
|
|
185
|
+
updateConfig: b
|
|
186
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
187
|
+
export {
|
|
188
|
+
c as T,
|
|
189
|
+
T as a,
|
|
190
|
+
a as c,
|
|
191
|
+
C as g,
|
|
192
|
+
z as i,
|
|
193
|
+
b as u
|
|
194
|
+
};
|
package/dist/nonInteractive.mjs
CHANGED
|
@@ -1,45 +1,50 @@
|
|
|
1
1
|
import { HumanMessage as c } from "langchain";
|
|
2
|
-
import { g as
|
|
3
|
-
import
|
|
2
|
+
import { g as m } from "./graphBuilder-BttmR-dZ.mjs";
|
|
3
|
+
import "@langchain/langgraph";
|
|
4
|
+
import "zod";
|
|
5
|
+
import "@langchain/openai";
|
|
6
|
+
import "@langchain/anthropic";
|
|
7
|
+
import "yaml";
|
|
8
|
+
import { i as l, g } from "./index-P-c4tqBO.mjs";
|
|
4
9
|
async function d() {
|
|
5
|
-
return new Promise((
|
|
6
|
-
let
|
|
7
|
-
process.stdin.setEncoding("utf8"), process.stdin.on("data", (
|
|
8
|
-
|
|
10
|
+
return new Promise((t, r) => {
|
|
11
|
+
let n = "";
|
|
12
|
+
process.stdin.setEncoding("utf8"), process.stdin.on("data", (e) => {
|
|
13
|
+
n += e;
|
|
9
14
|
}), process.stdin.on("end", () => {
|
|
10
|
-
r(o);
|
|
11
|
-
}), process.stdin.on("error", (n) => {
|
|
12
15
|
t(n);
|
|
16
|
+
}), process.stdin.on("error", (e) => {
|
|
17
|
+
r(e);
|
|
13
18
|
});
|
|
14
19
|
});
|
|
15
20
|
}
|
|
16
|
-
async function
|
|
17
|
-
await
|
|
18
|
-
const
|
|
19
|
-
let
|
|
20
|
-
if (
|
|
21
|
+
async function k(t, r = !1) {
|
|
22
|
+
await l();
|
|
23
|
+
const n = await g();
|
|
24
|
+
let e = t || "";
|
|
25
|
+
if (r)
|
|
21
26
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
throw console.error("❌ 读取 stdin 失败:",
|
|
27
|
+
e = (await d()).trim();
|
|
28
|
+
} catch (o) {
|
|
29
|
+
throw console.error("❌ 读取 stdin 失败:", o), o;
|
|
25
30
|
}
|
|
26
|
-
|
|
31
|
+
e || (console.error("❌ 错误: 未提供输入内容"), console.error(`
|
|
27
32
|
用法:`), console.error(' zen-code -p "你的任务描述"'), console.error(' echo "内容" | zen-code'), process.exit(1));
|
|
28
33
|
try {
|
|
29
|
-
const
|
|
30
|
-
messages: [new c(
|
|
31
|
-
main_model:
|
|
32
|
-
enable_thinking:
|
|
33
|
-
}, s = await
|
|
34
|
+
const o = {
|
|
35
|
+
messages: [new c(e)],
|
|
36
|
+
main_model: n.main_model,
|
|
37
|
+
enable_thinking: n.enable_thinking
|
|
38
|
+
}, s = await m.invoke(o, {
|
|
34
39
|
recursionLimit: 200
|
|
35
40
|
}), i = s.messages || [], a = i[i.length - 1];
|
|
36
41
|
return a && console.log(a.text), s;
|
|
37
|
-
} catch (
|
|
42
|
+
} catch (o) {
|
|
38
43
|
throw console.error(`
|
|
39
|
-
❌ 执行失败: ${
|
|
40
|
-
`),
|
|
44
|
+
❌ 执行失败: ${o instanceof Error ? o.message : String(o)}
|
|
45
|
+
`), o;
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
export {
|
|
44
|
-
|
|
49
|
+
k as runNonInteractive
|
|
45
50
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as $ } from "./id-
|
|
2
|
-
import { B as g } from "./app-
|
|
3
|
-
import "./
|
|
1
|
+
import { u as $ } from "./id-C3QYmEcI.mjs";
|
|
2
|
+
import { B as g } from "./app-DBEp0HbC.mjs";
|
|
3
|
+
import "./graphBuilder-BttmR-dZ.mjs";
|
|
4
4
|
import { createClient as T } from "redis";
|
|
5
5
|
function k(u) {
|
|
6
6
|
if (u === null || typeof u != "object") return JSON.stringify(u);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "lowdb";
|
|
2
|
+
import "lowdb/node";
|
|
3
|
+
import "yaml";
|
|
4
|
+
import "./index-P-c4tqBO.mjs";
|
|
5
|
+
import { T as a } from "./graphBuilder-BttmR-dZ.mjs";
|
|
6
|
+
class r {
|
|
7
|
+
store = null;
|
|
8
|
+
projectRoot;
|
|
9
|
+
constructor(t) {
|
|
10
|
+
this.projectRoot = t;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 初始化 Store
|
|
14
|
+
*/
|
|
15
|
+
async initialize() {
|
|
16
|
+
this.store || (this.store = new a(this.projectRoot), await this.store.initialize());
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 确保 Store 已初始化
|
|
20
|
+
*/
|
|
21
|
+
ensureInitialized() {
|
|
22
|
+
if (!this.store)
|
|
23
|
+
throw new Error("TasksStore not initialized. Call initialize() first.");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 获取所有任务
|
|
27
|
+
*/
|
|
28
|
+
async getAllTasks() {
|
|
29
|
+
return this.ensureInitialized(), await this.store.getAllTasks();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 根据 status 获取任务
|
|
33
|
+
*/
|
|
34
|
+
async getTasksByStatus(t) {
|
|
35
|
+
return this.ensureInitialized(), await this.store.getTasksByStatus(t);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 获取单个任务
|
|
39
|
+
*/
|
|
40
|
+
async getTask(t) {
|
|
41
|
+
return this.ensureInitialized(), await this.store.getTask(t);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 更新任务状态
|
|
45
|
+
*/
|
|
46
|
+
async updateTaskStatus(t, e) {
|
|
47
|
+
return this.ensureInitialized(), await this.store.updateTask(t, { status: e });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 删除任务
|
|
51
|
+
*/
|
|
52
|
+
async deleteTask(t) {
|
|
53
|
+
return this.ensureInitialized(), await this.store.deleteTask(t);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 批量添加任务
|
|
57
|
+
*/
|
|
58
|
+
async addTasks(t) {
|
|
59
|
+
this.ensureInitialized(), await this.store.addTasks(t);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 获取活跃 Plan ID
|
|
63
|
+
*/
|
|
64
|
+
async getActivePlan() {
|
|
65
|
+
return this.ensureInitialized(), await this.store.getActivePlan();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 设置活跃 Plan ID
|
|
69
|
+
*/
|
|
70
|
+
async setActivePlan(t) {
|
|
71
|
+
this.ensureInitialized(), await this.store.setActivePlan(t);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 获取任务统计
|
|
75
|
+
*/
|
|
76
|
+
async getTaskStats() {
|
|
77
|
+
const t = await this.getAllTasks();
|
|
78
|
+
return {
|
|
79
|
+
total: t.length,
|
|
80
|
+
pickup: t.filter((e) => e.status === "pickup").length,
|
|
81
|
+
running: t.filter((e) => e.status === "running").length,
|
|
82
|
+
complete: t.filter((e) => e.status === "complete").length,
|
|
83
|
+
error: t.filter((e) => e.status === "error").length,
|
|
84
|
+
review: t.filter((e) => e.status === "review").length,
|
|
85
|
+
feedback: t.filter((e) => e.status === "feedback").length
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 获取执行历史
|
|
90
|
+
*/
|
|
91
|
+
async getHistory(t) {
|
|
92
|
+
return this.ensureInitialized(), await this.store.getHistory(t);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 清空所有任务(慎用)
|
|
96
|
+
*/
|
|
97
|
+
async clearAllTasks() {
|
|
98
|
+
this.ensureInitialized(), await this.store.clearAllTasks();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let i = null;
|
|
102
|
+
function c(s) {
|
|
103
|
+
if (!i) {
|
|
104
|
+
if (!s)
|
|
105
|
+
throw new Error("projectRoot is required for first initialization");
|
|
106
|
+
i = new r(s);
|
|
107
|
+
}
|
|
108
|
+
return i;
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
c as getTasksStore
|
|
112
|
+
};
|
package/dist/zen-code.mjs
CHANGED
package/dist/zen-init.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { a as t, j as e, B as o, T as r, r as U } from "./use-input-1eSjZocJ.mjs";
|
|
2
2
|
import "chalk";
|
|
3
|
-
import { u as A, S as O, M as T, a as B, b as R, g as K } from "./
|
|
4
|
-
import {
|
|
3
|
+
import { u as A, S as O, M as T, a as B, b as R, g as K } from "./get_allowed_models-I8bki8ev.mjs";
|
|
4
|
+
import { c as M, u as v, i as L } from "./index-P-c4tqBO.mjs";
|
|
5
5
|
const N = ({ onNext: l, onExit: i }) => {
|
|
6
|
-
A((c,
|
|
7
|
-
|
|
6
|
+
A((c, p) => {
|
|
7
|
+
p.return ? l() : p.ctrl && c === "c" && i();
|
|
8
8
|
});
|
|
9
|
-
const [j,
|
|
9
|
+
const [j, x] = t.useState(0);
|
|
10
10
|
return t.useEffect(() => {
|
|
11
11
|
const u = setInterval(() => {
|
|
12
|
-
|
|
12
|
+
x((m) => (m + 1) % 92);
|
|
13
13
|
}, 40);
|
|
14
14
|
return () => clearInterval(u);
|
|
15
15
|
}, []), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
@@ -104,8 +104,8 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
104
104
|
}, k = [
|
|
105
105
|
{ label: "OpenAI (GPT-4, o1 等)", value: "openai" },
|
|
106
106
|
{ label: "Anthropic (Claude)", value: "anthropic" }
|
|
107
|
-
], V = ({ provider: l, onSelect: i, onNext: j
|
|
108
|
-
const
|
|
107
|
+
], V = ({ provider: l, onSelect: i, onNext: j }) => {
|
|
108
|
+
const x = t.useMemo(() => l ? [l] : [], [l]);
|
|
109
109
|
return /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
110
110
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
111
111
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -126,9 +126,9 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
126
126
|
T,
|
|
127
127
|
{
|
|
128
128
|
options: k,
|
|
129
|
-
values:
|
|
130
|
-
onChange: (
|
|
131
|
-
|
|
129
|
+
values: x,
|
|
130
|
+
onChange: (c) => {
|
|
131
|
+
c.length > 0 && i(c[0]);
|
|
132
132
|
},
|
|
133
133
|
onSubmit: j,
|
|
134
134
|
singleSelect: !0,
|
|
@@ -159,21 +159,21 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
159
159
|
provider: l,
|
|
160
160
|
apiKey: i,
|
|
161
161
|
baseUrl: j,
|
|
162
|
-
onApiKeyChange:
|
|
162
|
+
onApiKeyChange: x,
|
|
163
163
|
onBaseUrlChange: c,
|
|
164
|
-
onNext:
|
|
164
|
+
onNext: p,
|
|
165
165
|
onBack: C,
|
|
166
166
|
onExit: I,
|
|
167
167
|
error: u
|
|
168
168
|
}) => {
|
|
169
|
-
const [m, g] = t.useState("apiKey"), [b, y] = t.useState(i), [
|
|
170
|
-
y(a),
|
|
169
|
+
const [m, g] = t.useState("apiKey"), [b, y] = t.useState(i), [d, f] = t.useState(j), D = w[l], n = (a) => {
|
|
170
|
+
y(a), x(a);
|
|
171
171
|
}, s = (a) => {
|
|
172
172
|
f(a), c(a);
|
|
173
173
|
}, h = (a) => {
|
|
174
|
-
a = a.trim(), n(a),
|
|
174
|
+
a = a.trim(), n(a), p();
|
|
175
175
|
}, E = (a) => {
|
|
176
|
-
a = a.trim(), s(a),
|
|
176
|
+
a = a.trim(), s(a), p();
|
|
177
177
|
};
|
|
178
178
|
return A((a, S) => {
|
|
179
179
|
if (S.ctrl && a === "c" && I(), S.escape) {
|
|
@@ -199,7 +199,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
199
199
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(
|
|
200
200
|
B,
|
|
201
201
|
{
|
|
202
|
-
value:
|
|
202
|
+
value: d,
|
|
203
203
|
onChange: s,
|
|
204
204
|
onSubmit: E,
|
|
205
205
|
placeholder: D
|
|
@@ -224,7 +224,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
224
224
|
"✗ ",
|
|
225
225
|
u
|
|
226
226
|
] }) }),
|
|
227
|
-
m === "baseUrl" && !
|
|
227
|
+
m === "baseUrl" && !d && /* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "💡 留空使用默认值" }) })
|
|
228
228
|
] }),
|
|
229
229
|
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
230
230
|
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "Tab/Shift+Tab 切换 | Enter 确认 | Esc 返回" }) }),
|
|
@@ -243,25 +243,25 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
243
243
|
provider: l,
|
|
244
244
|
models: i,
|
|
245
245
|
selectedModel: j,
|
|
246
|
-
onSelect:
|
|
246
|
+
onSelect: x,
|
|
247
247
|
onRefresh: c,
|
|
248
|
-
onNext:
|
|
248
|
+
onNext: p,
|
|
249
249
|
onBack: C,
|
|
250
250
|
onExit: I,
|
|
251
251
|
isLoading: u,
|
|
252
252
|
error: m
|
|
253
253
|
}) => {
|
|
254
|
-
const g = i.map((
|
|
255
|
-
label:
|
|
256
|
-
value:
|
|
254
|
+
const g = i.map((d) => ({
|
|
255
|
+
label: d.name,
|
|
256
|
+
value: d.id
|
|
257
257
|
})), b = j ? [j] : [], y = t.useCallback(
|
|
258
|
-
(
|
|
259
|
-
|
|
258
|
+
(d) => {
|
|
259
|
+
d.length > 0 && (x(d[0]), p());
|
|
260
260
|
},
|
|
261
|
-
[
|
|
261
|
+
[x, p]
|
|
262
262
|
);
|
|
263
|
-
return A((
|
|
264
|
-
(
|
|
263
|
+
return A((d, f) => {
|
|
264
|
+
(d === "r" || d === "R") && !u && c(), f.escape && C();
|
|
265
265
|
}), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
266
266
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
267
267
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -284,8 +284,8 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
284
284
|
{
|
|
285
285
|
options: g,
|
|
286
286
|
values: b,
|
|
287
|
-
onChange: (
|
|
288
|
-
|
|
287
|
+
onChange: (d) => {
|
|
288
|
+
d.length > 0 && x(d[0]);
|
|
289
289
|
},
|
|
290
290
|
onSubmit: y,
|
|
291
291
|
singleSelect: !0,
|
|
@@ -313,8 +313,8 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
313
313
|
}, F = {
|
|
314
314
|
openai: "OpenAI",
|
|
315
315
|
anthropic: "Anthropic"
|
|
316
|
-
}, H = ({ provider: l, model: i, onExit: j }) => (A((
|
|
317
|
-
(
|
|
316
|
+
}, H = ({ provider: l, model: i, onExit: j }) => (A((x, c) => {
|
|
317
|
+
(x || c.return) && j();
|
|
318
318
|
}), /* @__PURE__ */ e.jsx(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "green", paddingX: 1, marginBottom: 1, children: [
|
|
319
319
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
320
320
|
/* @__PURE__ */ e.jsx(r, { color: "green", bold: !0, children: "✓ 配置完成" }),
|
|
@@ -336,7 +336,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
336
336
|
] }),
|
|
337
337
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
338
338
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "配置路径 ::" }),
|
|
339
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: M })
|
|
339
|
+
/* @__PURE__ */ e.jsx(r, { color: "gray", children: M.getConfigPath() })
|
|
340
340
|
] })
|
|
341
341
|
] }),
|
|
342
342
|
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
|
|
@@ -366,7 +366,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
366
366
|
isLoading: !1,
|
|
367
367
|
error: null
|
|
368
368
|
}, W = () => {
|
|
369
|
-
const [l, i] = t.useState(z), [j,
|
|
369
|
+
const [l, i] = t.useState(z), [j, x] = t.useState([]), c = t.useCallback(() => {
|
|
370
370
|
i((n) => {
|
|
371
371
|
if (n.step === "model" && !n.selectedModel)
|
|
372
372
|
return { ...n, error: "请选择一个模型" };
|
|
@@ -378,7 +378,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
378
378
|
const s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
|
|
379
379
|
return h < s.length - 1 ? { ...n, step: s[h + 1], error: null } : n;
|
|
380
380
|
});
|
|
381
|
-
}, []),
|
|
381
|
+
}, []), p = t.useCallback(() => {
|
|
382
382
|
i((n) => {
|
|
383
383
|
const s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
|
|
384
384
|
return h > 0 ? { ...n, step: s[h - 1], error: null } : n;
|
|
@@ -407,13 +407,13 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
407
407
|
const h = process.env.MODEL_PROVIDER, E = process.env.OPENAI_API_KEY, a = process.env.ANTHROPIC_API_KEY;
|
|
408
408
|
process.env.MODEL_PROVIDER = n, n === "openai" ? process.env.OPENAI_API_KEY = s || "temp" : process.env.ANTHROPIC_API_KEY = s || "temp";
|
|
409
409
|
const _ = (await K()).filter((P) => P.provider === n);
|
|
410
|
-
|
|
410
|
+
x(_), h && (process.env.MODEL_PROVIDER = h), E && (process.env.OPENAI_API_KEY = E), a && (process.env.ANTHROPIC_API_KEY = a);
|
|
411
411
|
} catch (h) {
|
|
412
|
-
g(`加载模型失败: ${h instanceof Error ? h.message : String(h)}`),
|
|
412
|
+
g(`加载模型失败: ${h instanceof Error ? h.message : String(h)}`), x([]);
|
|
413
413
|
} finally {
|
|
414
414
|
b(!1);
|
|
415
415
|
}
|
|
416
|
-
}, []),
|
|
416
|
+
}, []), d = t.useCallback(async () => {
|
|
417
417
|
if (!l.provider || !l.apiKey || !l.selectedModel)
|
|
418
418
|
return g("配置不完整"), !1;
|
|
419
419
|
b(!0), g(null);
|
|
@@ -434,7 +434,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
434
434
|
t.useEffect(() => {
|
|
435
435
|
l.step === "model" && l.provider && l.apiKey && y(l.provider, l.apiKey);
|
|
436
436
|
}, [l.step, l.provider, l.apiKey, y]), A((n, s) => {
|
|
437
|
-
s.ctrl && n === "c" ? process.exit(0) : s.escape &&
|
|
437
|
+
s.ctrl && n === "c" ? process.exit(0) : s.escape && p();
|
|
438
438
|
});
|
|
439
439
|
const D = () => {
|
|
440
440
|
switch (l.step) {
|
|
@@ -462,7 +462,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
462
462
|
onApiKeyChange: I,
|
|
463
463
|
onBaseUrlChange: u,
|
|
464
464
|
onNext: c,
|
|
465
|
-
onBack:
|
|
465
|
+
onBack: p,
|
|
466
466
|
onExit: f,
|
|
467
467
|
error: l.error
|
|
468
468
|
}
|
|
@@ -477,9 +477,9 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
477
477
|
onSelect: m,
|
|
478
478
|
onRefresh: () => y(l.provider, l.apiKey),
|
|
479
479
|
onNext: async () => {
|
|
480
|
-
await
|
|
480
|
+
await d() && c();
|
|
481
481
|
},
|
|
482
|
-
onBack:
|
|
482
|
+
onBack: p,
|
|
483
483
|
onExit: f,
|
|
484
484
|
isLoading: l.isLoading,
|
|
485
485
|
error: l.error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-code",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cli.mjs",
|
|
6
6
|
"bin": "./dist/cli.mjs",
|
|
@@ -56,7 +56,10 @@
|
|
|
56
56
|
"react": "^19.2.3",
|
|
57
57
|
"vite": "^7.3.1",
|
|
58
58
|
"vite-bundle-analyzer": "^1.3.2",
|
|
59
|
-
"vite-plugin-static-copy": "^3.1.4"
|
|
59
|
+
"vite-plugin-static-copy": "^3.1.4",
|
|
60
|
+
"@codegraph/config": "1.0.0",
|
|
61
|
+
"@codegraph/union-client": "1.0.0",
|
|
62
|
+
"@codegraph/agent": "1.0.0"
|
|
60
63
|
},
|
|
61
64
|
"babel": {
|
|
62
65
|
"presets": [
|