zen-code 4.0.0 → 4.2.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/{MultiLineTextInput-DjNvaZzA.mjs → MultiLineTextInput-e7hD79Wp.mjs} +2 -2
- package/dist/{_commonjsHelpers-ByX85dGu.mjs → _commonjsHelpers-DQNKXVTB.mjs} +2 -2
- package/dist/app-DWJrZDvr.mjs +12316 -0
- package/dist/{checkpoint-1sAx_j1E-vdL63_qZ.mjs → checkpoint-1sAx_j1E-C7OZFRPe.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-DSc-mf5U.mjs → checkpoint-DxiUsHMy-LKqXeDEy.mjs} +2 -2
- package/dist/{devtools-DpL9Fl6d.mjs → devtools-CzaVuYnh.mjs} +1 -1
- package/dist/{graphBuilder-ulTm2bmI.mjs → graphBuilder-B3T9KyfH.mjs} +11869 -11311
- package/dist/{id-BHzJB_zk.mjs → id-DAEnqc1v.mjs} +5 -5
- package/dist/{index-BrsJ_rEy.mjs → index-B9w1j1Jz.mjs} +5 -5
- package/dist/{index-hjtoWC6i.mjs → index-D7W7mYQR.mjs} +3 -3
- package/dist/{memories-C_p4qG-9.mjs → memories-D7PFLLlR.mjs} +1 -1
- package/dist/nonInteractive.mjs +21 -22
- package/dist/{queue-D6tEGCGs-dshzv8m6.mjs → queue-D6tEGCGs-C8z6cY9y.mjs} +1 -1
- package/dist/{shallow-BJVbNSyQ.mjs → shallow-ChkcFpXh.mjs} +3 -3
- package/dist/subTasks-PsCKmIx0.mjs +210 -0
- package/dist/tasks-Dmf3N6e4.mjs +237 -0
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +1 -526
- package/dist/zen-keyboard.mjs +1 -1
- package/package.json +2 -2
- package/dist/FileSystemConfigStore-Bog5vylu.mjs +0 -47
- package/dist/app-QzdcE86p.mjs +0 -11834
- package/dist/ask_agents-bHg8fyUp.mjs +0 -67
- package/dist/get_allowed_models-DWso18Ri.mjs +0 -253
- package/dist/index-BG-c4_r3.mjs +0 -449
- package/dist/subagents-DnvCjtPv.mjs +0 -95
- package/dist/tasks-DhCRIevp.mjs +0 -113
package/dist/zen-init.mjs
CHANGED
|
@@ -1,526 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import "chalk";
|
|
3
|
-
import { u as D, M as T, S as O, g as R } from "./get_allowed_models-DWso18Ri.mjs";
|
|
4
|
-
import { c as K, u as M, i as v } from "./index-BG-c4_r3.mjs";
|
|
5
|
-
const L = (s, t, x) => {
|
|
6
|
-
const d = parseInt(s.slice(1, 3), 16), l = parseInt(s.slice(3, 5), 16), a = parseInt(s.slice(5, 7), 16), C = parseInt(t.slice(1, 3), 16), I = parseInt(t.slice(3, 5), 16), p = parseInt(t.slice(5, 7), 16), j = Math.round(d + x * (C - d)), m = Math.round(l + x * (I - l)), g = Math.round(a + x * (p - a));
|
|
7
|
-
return `#${((1 << 24) + (j << 16) + (m << 8) + g).toString(16).slice(1).toUpperCase()}`;
|
|
8
|
-
}, N = ({
|
|
9
|
-
text: s,
|
|
10
|
-
highlightColor: t = "#00FFFF",
|
|
11
|
-
// Cyan
|
|
12
|
-
baseColor: x = "#003333",
|
|
13
|
-
// Dark Cyan
|
|
14
|
-
interval: d = 20,
|
|
15
|
-
spread: l = 32,
|
|
16
|
-
globalIndex: a
|
|
17
|
-
}) => {
|
|
18
|
-
const [C, I] = c.useState(0), p = a !== void 0 ? a : C;
|
|
19
|
-
return c.useEffect(() => {
|
|
20
|
-
if (a !== void 0) return;
|
|
21
|
-
const j = setInterval(() => {
|
|
22
|
-
I((m) => (m + 1) % (s.length + l * 2));
|
|
23
|
-
}, d);
|
|
24
|
-
return () => clearInterval(j);
|
|
25
|
-
}, [s.length, l, d, a]), /* @__PURE__ */ e.jsx(r, { children: s.split("").map((j, m) => {
|
|
26
|
-
const g = p - l, y = Math.abs(m - g);
|
|
27
|
-
let h = x, b = !1;
|
|
28
|
-
if (y < l) {
|
|
29
|
-
const w = Math.cos(y / l * (Math.PI / 2)), n = Math.pow(w, 2);
|
|
30
|
-
h = L(x, t, n), b = y < 1;
|
|
31
|
-
}
|
|
32
|
-
return /* @__PURE__ */ e.jsx(r, { color: h, bold: b, children: j }, m);
|
|
33
|
-
}) });
|
|
34
|
-
}, k = ({ onNext: s, onExit: t }) => {
|
|
35
|
-
D((l, a) => {
|
|
36
|
-
a.return ? s() : a.ctrl && l === "c" && t();
|
|
37
|
-
});
|
|
38
|
-
const [x, d] = c.useState(0);
|
|
39
|
-
return c.useEffect(() => {
|
|
40
|
-
const p = setInterval(() => {
|
|
41
|
-
d((j) => (j + 1) % 92);
|
|
42
|
-
}, 40);
|
|
43
|
-
return () => clearInterval(p);
|
|
44
|
-
}, []), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
45
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
46
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
47
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: "设置向导" }),
|
|
48
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "[1/4]" })
|
|
49
|
-
] }),
|
|
50
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", marginTop: 1, gap: 2, children: [
|
|
51
|
-
/* @__PURE__ */ e.jsx(o, { flexDirection: "column", children: `███████╗███████╗███╗ ██╗
|
|
52
|
-
╚══███╔╝██╔════╝████╗ ██║
|
|
53
|
-
███╔╝ █████╗ ██╔██╗ ██║
|
|
54
|
-
███╔╝ ██╔══╝ ██║╚██╗██║
|
|
55
|
-
███████╗███████╗██║ ╚████║
|
|
56
|
-
╚══════╝╚══════╝╚═╝ ╚═══╝`.split(`
|
|
57
|
-
`).map((l) => /* @__PURE__ */ e.jsx(N, { interval: 40, text: l, globalIndex: x }, l)) }),
|
|
58
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", justifyContent: "center", flexGrow: 1, children: [
|
|
59
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "yellow", bold: !0, children: [
|
|
60
|
-
" ",
|
|
61
|
-
"⚡ 初始化中"
|
|
62
|
-
] }) }),
|
|
63
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", gap: 0, children: [
|
|
64
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
65
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "产品 ::" }),
|
|
66
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: "Zen Code" })
|
|
67
|
-
] }),
|
|
68
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
69
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "类型 ::" }),
|
|
70
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: "AI 驱动的命令行助手" })
|
|
71
|
-
] }),
|
|
72
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
73
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "状态 ::" }),
|
|
74
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", children: "准备配置" })
|
|
75
|
-
] })
|
|
76
|
-
] }),
|
|
77
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, flexDirection: "column", gap: 0, children: [
|
|
78
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", bold: !0, children: "设置步骤:" }),
|
|
79
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", children: [
|
|
80
|
-
" ",
|
|
81
|
-
"● 选择提供商"
|
|
82
|
-
] }),
|
|
83
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", children: [
|
|
84
|
-
" ",
|
|
85
|
-
"● API 配置"
|
|
86
|
-
] }),
|
|
87
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", children: [
|
|
88
|
-
" ",
|
|
89
|
-
"● 选择模型"
|
|
90
|
-
] }),
|
|
91
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", children: [
|
|
92
|
-
" ",
|
|
93
|
-
"● 完成"
|
|
94
|
-
] })
|
|
95
|
-
] })
|
|
96
|
-
] })
|
|
97
|
-
] }),
|
|
98
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
99
|
-
/* @__PURE__ */ e.jsxs(o, { gap: 3, children: [
|
|
100
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
101
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", children: "●" }),
|
|
102
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", dimColor: !0, children: [
|
|
103
|
-
" ",
|
|
104
|
-
"AI 智能体"
|
|
105
|
-
] })
|
|
106
|
-
] }),
|
|
107
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
108
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", children: "●" }),
|
|
109
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", dimColor: !0, children: [
|
|
110
|
-
" ",
|
|
111
|
-
"文件系统"
|
|
112
|
-
] })
|
|
113
|
-
] }),
|
|
114
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
115
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", children: "●" }),
|
|
116
|
-
/* @__PURE__ */ e.jsxs(r, { color: "white", dimColor: !0, children: [
|
|
117
|
-
" ",
|
|
118
|
-
"记忆系统"
|
|
119
|
-
] })
|
|
120
|
-
] })
|
|
121
|
-
] }),
|
|
122
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
123
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: ">>> 按 [Enter] 开始" }),
|
|
124
|
-
/* @__PURE__ */ e.jsxs(r, { color: "cyan", dimColor: !0, children: [
|
|
125
|
-
" ",
|
|
126
|
-
"▌"
|
|
127
|
-
] })
|
|
128
|
-
] })
|
|
129
|
-
] })
|
|
130
|
-
] }),
|
|
131
|
-
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
132
|
-
] });
|
|
133
|
-
}, F = [
|
|
134
|
-
{ label: "OpenAI (GPT-4, o1 等)", value: "openai" },
|
|
135
|
-
{ label: "Anthropic (Claude)", value: "anthropic" }
|
|
136
|
-
], V = ({ provider: s, onSelect: t, onNext: x }) => {
|
|
137
|
-
const d = c.useMemo(() => s ? [s] : [], [s]);
|
|
138
|
-
return /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
139
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
140
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
141
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: "选择提供商" }),
|
|
142
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "[2/4]" })
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
145
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
146
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "步骤 ::" }),
|
|
147
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: " 选择 AI 提供商" })
|
|
148
|
-
] }),
|
|
149
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
|
|
150
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "选择您要使用的 AI 服务:" }),
|
|
151
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "• OpenAI: GPT-4, o1 等模型" }),
|
|
152
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "• Anthropic: Claude 3.5 Sonnet, Opus" })
|
|
153
|
-
] }),
|
|
154
|
-
/* @__PURE__ */ e.jsx(o, { marginTop: 1, marginBottom: 1, children: /* @__PURE__ */ e.jsx(
|
|
155
|
-
T,
|
|
156
|
-
{
|
|
157
|
-
options: F,
|
|
158
|
-
values: d,
|
|
159
|
-
onChange: (l) => {
|
|
160
|
-
l.length > 0 && t(l[0]);
|
|
161
|
-
},
|
|
162
|
-
onSubmit: x,
|
|
163
|
-
singleSelect: !0,
|
|
164
|
-
autoFocus: !0
|
|
165
|
-
}
|
|
166
|
-
) })
|
|
167
|
-
] }),
|
|
168
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
169
|
-
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "↑/↓ 导航 | Enter 确认" }) }),
|
|
170
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
171
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: ">>> 选择提供商" }),
|
|
172
|
-
/* @__PURE__ */ e.jsxs(r, { color: "cyan", dimColor: !0, children: [
|
|
173
|
-
" ",
|
|
174
|
-
"▌"
|
|
175
|
-
] })
|
|
176
|
-
] })
|
|
177
|
-
] })
|
|
178
|
-
] }),
|
|
179
|
-
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
180
|
-
] });
|
|
181
|
-
}, A = {
|
|
182
|
-
openai: "https://api.openai.com/v1",
|
|
183
|
-
anthropic: "https://api.anthropic.com"
|
|
184
|
-
}, G = {
|
|
185
|
-
openai: "https://platform.openai.com/api-keys",
|
|
186
|
-
anthropic: "https://console.anthropic.com/settings/keys"
|
|
187
|
-
}, X = ({
|
|
188
|
-
provider: s,
|
|
189
|
-
apiKey: t,
|
|
190
|
-
baseUrl: x,
|
|
191
|
-
onApiKeyChange: d,
|
|
192
|
-
onBaseUrlChange: l,
|
|
193
|
-
onNext: a,
|
|
194
|
-
onBack: C,
|
|
195
|
-
onExit: I,
|
|
196
|
-
error: p
|
|
197
|
-
}) => {
|
|
198
|
-
const [j, m] = c.useState("apiKey"), [g, y] = c.useState(t), [h, b] = c.useState(x), w = A[s], n = (u) => {
|
|
199
|
-
y(u), d(u);
|
|
200
|
-
}, i = (u) => {
|
|
201
|
-
b(u), l(u);
|
|
202
|
-
}, f = (u) => {
|
|
203
|
-
u = u.trim(), n(u), a();
|
|
204
|
-
}, E = (u) => {
|
|
205
|
-
u = u.trim(), i(u), a();
|
|
206
|
-
};
|
|
207
|
-
return D((u, S) => {
|
|
208
|
-
if (S.ctrl && u === "c" && I(), S.escape) {
|
|
209
|
-
C();
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
}), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
213
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
214
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
215
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: "API CONFIGURATION" }),
|
|
216
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "[3/4]" })
|
|
217
|
-
] }),
|
|
218
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
219
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
220
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "PROVIDER::" }),
|
|
221
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: s.toUpperCase() })
|
|
222
|
-
] }),
|
|
223
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { bold: !0, children: "Base URL (可选)" }) }),
|
|
224
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "gray", children: [
|
|
225
|
-
"默认值: ",
|
|
226
|
-
w
|
|
227
|
-
] }) }),
|
|
228
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(
|
|
229
|
-
B,
|
|
230
|
-
{
|
|
231
|
-
value: h,
|
|
232
|
-
onChange: i,
|
|
233
|
-
onSubmit: E,
|
|
234
|
-
placeholder: w
|
|
235
|
-
}
|
|
236
|
-
) }),
|
|
237
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { bold: !0, children: "API 密钥" }) }),
|
|
238
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "gray", children: [
|
|
239
|
-
"获取地址: ",
|
|
240
|
-
G[s]
|
|
241
|
-
] }) }),
|
|
242
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom: j === "apiKey" && p ? 0 : 1, children: /* @__PURE__ */ e.jsx(
|
|
243
|
-
B,
|
|
244
|
-
{
|
|
245
|
-
value: g,
|
|
246
|
-
onChange: n,
|
|
247
|
-
onSubmit: f,
|
|
248
|
-
placeholder: "sk-...",
|
|
249
|
-
autoFocus: !1
|
|
250
|
-
}
|
|
251
|
-
) }),
|
|
252
|
-
p && j === "apiKey" && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
|
|
253
|
-
"✗ ",
|
|
254
|
-
p
|
|
255
|
-
] }) }),
|
|
256
|
-
j === "baseUrl" && !h && /* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "💡 留空使用默认值" }) })
|
|
257
|
-
] }),
|
|
258
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
259
|
-
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "Tab/Shift+Tab 切换 | Enter 确认 | Esc 返回" }) }),
|
|
260
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
261
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: ">>> 输入 API 密钥" }),
|
|
262
|
-
/* @__PURE__ */ e.jsxs(r, { color: "cyan", dimColor: !0, children: [
|
|
263
|
-
" ",
|
|
264
|
-
"▌"
|
|
265
|
-
] })
|
|
266
|
-
] })
|
|
267
|
-
] })
|
|
268
|
-
] }),
|
|
269
|
-
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
270
|
-
] });
|
|
271
|
-
}, Y = ({
|
|
272
|
-
provider: s,
|
|
273
|
-
models: t,
|
|
274
|
-
selectedModel: x,
|
|
275
|
-
onSelect: d,
|
|
276
|
-
onRefresh: l,
|
|
277
|
-
onNext: a,
|
|
278
|
-
onBack: C,
|
|
279
|
-
onExit: I,
|
|
280
|
-
isLoading: p,
|
|
281
|
-
error: j
|
|
282
|
-
}) => {
|
|
283
|
-
const m = t.map((h) => ({
|
|
284
|
-
label: h.name,
|
|
285
|
-
value: h.id
|
|
286
|
-
})), g = x ? [x] : [], y = c.useCallback(
|
|
287
|
-
(h) => {
|
|
288
|
-
h.length > 0 && (d(h[0]), a());
|
|
289
|
-
},
|
|
290
|
-
[d, a]
|
|
291
|
-
);
|
|
292
|
-
return D((h, b) => {
|
|
293
|
-
(h === "r" || h === "R") && !p && l(), b.escape && C();
|
|
294
|
-
}), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
295
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
296
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
297
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: "选择模型" }),
|
|
298
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "[4/4]" })
|
|
299
|
-
] }),
|
|
300
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
301
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
302
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "提供商 ::" }),
|
|
303
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: s.toUpperCase() })
|
|
304
|
-
] }),
|
|
305
|
-
p && t.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { children: [
|
|
306
|
-
/* @__PURE__ */ e.jsx(O, { type: "dots" }),
|
|
307
|
-
" 检测可用模型中..."
|
|
308
|
-
] }) }),
|
|
309
|
-
!p && t.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { color: "yellow", children: "未找到可用模型,请按 R 刷新" }) }),
|
|
310
|
-
!p && t.length > 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { color: "gray", children: "选择您偏好的模型:" }) }),
|
|
311
|
-
!p && t.length > 0 && /* @__PURE__ */ e.jsx(
|
|
312
|
-
T,
|
|
313
|
-
{
|
|
314
|
-
options: m,
|
|
315
|
-
values: g,
|
|
316
|
-
onChange: (h) => {
|
|
317
|
-
h.length > 0 && d(h[0]);
|
|
318
|
-
},
|
|
319
|
-
onSubmit: y,
|
|
320
|
-
singleSelect: !0,
|
|
321
|
-
autoFocus: !0
|
|
322
|
-
}
|
|
323
|
-
),
|
|
324
|
-
j && /* @__PURE__ */ e.jsx(o, { marginTop: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
|
|
325
|
-
"✗ ",
|
|
326
|
-
j
|
|
327
|
-
] }) })
|
|
328
|
-
] }),
|
|
329
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
330
|
-
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "↑/↓ 导航 | Enter 确认 | R 刷新 | Esc 返回" }) }),
|
|
331
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
332
|
-
/* @__PURE__ */ e.jsx(r, { color: "cyan", bold: !0, children: ">>> 选择模型" }),
|
|
333
|
-
/* @__PURE__ */ e.jsxs(r, { color: "cyan", dimColor: !0, children: [
|
|
334
|
-
" ",
|
|
335
|
-
"▌"
|
|
336
|
-
] })
|
|
337
|
-
] })
|
|
338
|
-
] })
|
|
339
|
-
] }),
|
|
340
|
-
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
341
|
-
] });
|
|
342
|
-
}, H = {
|
|
343
|
-
openai: "OpenAI",
|
|
344
|
-
anthropic: "Anthropic"
|
|
345
|
-
}, $ = ({ provider: s, model: t, onExit: x }) => (D((d, l) => {
|
|
346
|
-
(d || l.return) && x();
|
|
347
|
-
}), /* @__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: [
|
|
348
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
349
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", bold: !0, children: "✓ 配置完成" }),
|
|
350
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "[完成]" })
|
|
351
|
-
] }),
|
|
352
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
353
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
354
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "状态 ::" }),
|
|
355
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", children: "配置已保存" })
|
|
356
|
-
] }),
|
|
357
|
-
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginBottom: 2, gap: 1, children: [
|
|
358
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
359
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "提供商 ::" }),
|
|
360
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: H[s] })
|
|
361
|
-
] }),
|
|
362
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
363
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "模型 ::" }),
|
|
364
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children: t })
|
|
365
|
-
] }),
|
|
366
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
367
|
-
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "配置路径 ::" }),
|
|
368
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: K.getConfigPath() })
|
|
369
|
-
] })
|
|
370
|
-
] }),
|
|
371
|
-
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
|
|
372
|
-
/* @__PURE__ */ e.jsxs(r, { color: "green", bold: !0, children: [
|
|
373
|
-
" ",
|
|
374
|
-
"✓ 准备就绪!"
|
|
375
|
-
] }),
|
|
376
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children: "请重新启动 zen-code 开始使用" })
|
|
377
|
-
] })
|
|
378
|
-
] }),
|
|
379
|
-
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
380
|
-
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "按任意键退出" }) }),
|
|
381
|
-
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
382
|
-
/* @__PURE__ */ e.jsx(r, { color: "green", bold: !0, children: ">>> 全部完成" }),
|
|
383
|
-
/* @__PURE__ */ e.jsxs(r, { color: "green", dimColor: !0, children: [
|
|
384
|
-
" ",
|
|
385
|
-
"▌"
|
|
386
|
-
] })
|
|
387
|
-
] })
|
|
388
|
-
] })
|
|
389
|
-
] }) })), z = {
|
|
390
|
-
step: "welcome",
|
|
391
|
-
provider: null,
|
|
392
|
-
apiKey: "",
|
|
393
|
-
baseUrl: "",
|
|
394
|
-
selectedModel: "",
|
|
395
|
-
isLoading: !1,
|
|
396
|
-
error: null
|
|
397
|
-
}, W = () => {
|
|
398
|
-
const [s, t] = c.useState(z), [x, d] = c.useState([]), l = c.useCallback(() => {
|
|
399
|
-
t((n) => {
|
|
400
|
-
if (n.step === "model" && !n.selectedModel)
|
|
401
|
-
return { ...n, error: "请选择一个模型" };
|
|
402
|
-
if (n.step === "apiAndBaseUrl") {
|
|
403
|
-
if (!n.apiKey)
|
|
404
|
-
return { ...n, error: "请输入 API Key" };
|
|
405
|
-
n.provider && (process.env.MODEL_PROVIDER = n.provider, n.provider === "openai" ? (process.env.OPENAI_API_KEY = n.apiKey, n.baseUrl && n.baseUrl !== A.openai && (process.env.OPENAI_BASE_URL = n.baseUrl)) : (process.env.ANTHROPIC_API_KEY = n.apiKey, n.baseUrl && n.baseUrl !== A.anthropic && (process.env.ANTHROPIC_BASE_URL = n.baseUrl)));
|
|
406
|
-
}
|
|
407
|
-
const i = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], f = i.indexOf(n.step);
|
|
408
|
-
return f < i.length - 1 ? { ...n, step: i[f + 1], error: null } : n;
|
|
409
|
-
});
|
|
410
|
-
}, []), a = c.useCallback(() => {
|
|
411
|
-
t((n) => {
|
|
412
|
-
const i = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], f = i.indexOf(n.step);
|
|
413
|
-
return f > 0 ? { ...n, step: i[f - 1], error: null } : n;
|
|
414
|
-
});
|
|
415
|
-
}, []), C = c.useCallback((n) => {
|
|
416
|
-
process.env.MODEL_PROVIDER = n, t((i) => ({
|
|
417
|
-
...i,
|
|
418
|
-
provider: n,
|
|
419
|
-
baseUrl: A[n],
|
|
420
|
-
apiKey: "",
|
|
421
|
-
selectedModel: ""
|
|
422
|
-
}));
|
|
423
|
-
}, []), I = c.useCallback((n) => {
|
|
424
|
-
t((i) => ({ ...i, apiKey: n, error: null }));
|
|
425
|
-
}, []), p = c.useCallback((n) => {
|
|
426
|
-
t((i) => ({ ...i, baseUrl: n, error: null }));
|
|
427
|
-
}, []), j = c.useCallback((n) => {
|
|
428
|
-
t((i) => ({ ...i, selectedModel: n, error: null }));
|
|
429
|
-
}, []), m = c.useCallback((n) => {
|
|
430
|
-
t((i) => ({ ...i, error: n }));
|
|
431
|
-
}, []), g = c.useCallback((n) => {
|
|
432
|
-
t((i) => ({ ...i, isLoading: n }));
|
|
433
|
-
}, []), y = c.useCallback(async (n, i) => {
|
|
434
|
-
g(!0), m(null);
|
|
435
|
-
try {
|
|
436
|
-
const f = process.env.MODEL_PROVIDER, E = process.env.OPENAI_API_KEY, u = process.env.ANTHROPIC_API_KEY;
|
|
437
|
-
process.env.MODEL_PROVIDER = n, n === "openai" ? process.env.OPENAI_API_KEY = i || "temp" : process.env.ANTHROPIC_API_KEY = i || "temp";
|
|
438
|
-
const _ = (await R()).filter((P) => P.provider === n);
|
|
439
|
-
d(_), f && (process.env.MODEL_PROVIDER = f), E && (process.env.OPENAI_API_KEY = E), u && (process.env.ANTHROPIC_API_KEY = u);
|
|
440
|
-
} catch (f) {
|
|
441
|
-
m(`加载模型失败: ${f instanceof Error ? f.message : String(f)}`), d([]);
|
|
442
|
-
} finally {
|
|
443
|
-
g(!1);
|
|
444
|
-
}
|
|
445
|
-
}, []), h = c.useCallback(async () => {
|
|
446
|
-
if (!s.provider || !s.apiKey || !s.selectedModel)
|
|
447
|
-
return m("配置不完整"), !1;
|
|
448
|
-
g(!0), m(null);
|
|
449
|
-
try {
|
|
450
|
-
const n = {
|
|
451
|
-
main_model: s.selectedModel,
|
|
452
|
-
model_provider: s.provider
|
|
453
|
-
};
|
|
454
|
-
return s.provider === "openai" ? (n.openai_api_key = s.apiKey, s.baseUrl && s.baseUrl !== A.openai && (n.openai_base_url = s.baseUrl)) : (n.anthropic_api_key = s.apiKey, s.baseUrl && s.baseUrl !== A.anthropic && (n.anthropic_base_url = s.baseUrl)), await M(n), !0;
|
|
455
|
-
} catch (n) {
|
|
456
|
-
return m(`保存配置失败: ${n instanceof Error ? n.message : String(n)}`), !1;
|
|
457
|
-
} finally {
|
|
458
|
-
g(!1);
|
|
459
|
-
}
|
|
460
|
-
}, [s]), b = c.useCallback(() => {
|
|
461
|
-
process.exit(0);
|
|
462
|
-
}, []);
|
|
463
|
-
c.useEffect(() => {
|
|
464
|
-
s.step === "model" && s.provider && s.apiKey && y(s.provider, s.apiKey);
|
|
465
|
-
}, [s.step, s.provider, s.apiKey, y]), D((n, i) => {
|
|
466
|
-
i.ctrl && n === "c" ? process.exit(0) : i.escape && a();
|
|
467
|
-
});
|
|
468
|
-
const w = () => {
|
|
469
|
-
switch (s.step) {
|
|
470
|
-
case "welcome":
|
|
471
|
-
return /* @__PURE__ */ e.jsx(k, { onNext: l, onExit: b });
|
|
472
|
-
case "provider":
|
|
473
|
-
return /* @__PURE__ */ e.jsx(
|
|
474
|
-
V,
|
|
475
|
-
{
|
|
476
|
-
provider: s.provider,
|
|
477
|
-
onSelect: (n) => {
|
|
478
|
-
C(n);
|
|
479
|
-
},
|
|
480
|
-
onNext: l,
|
|
481
|
-
onExit: b
|
|
482
|
-
}
|
|
483
|
-
);
|
|
484
|
-
case "apiAndBaseUrl":
|
|
485
|
-
return /* @__PURE__ */ e.jsx(
|
|
486
|
-
X,
|
|
487
|
-
{
|
|
488
|
-
provider: s.provider,
|
|
489
|
-
apiKey: s.apiKey,
|
|
490
|
-
baseUrl: s.baseUrl,
|
|
491
|
-
onApiKeyChange: I,
|
|
492
|
-
onBaseUrlChange: p,
|
|
493
|
-
onNext: l,
|
|
494
|
-
onBack: a,
|
|
495
|
-
onExit: b,
|
|
496
|
-
error: s.error
|
|
497
|
-
}
|
|
498
|
-
);
|
|
499
|
-
case "model":
|
|
500
|
-
return /* @__PURE__ */ e.jsx(
|
|
501
|
-
Y,
|
|
502
|
-
{
|
|
503
|
-
provider: s.provider,
|
|
504
|
-
models: x,
|
|
505
|
-
selectedModel: s.selectedModel,
|
|
506
|
-
onSelect: j,
|
|
507
|
-
onRefresh: () => y(s.provider, s.apiKey),
|
|
508
|
-
onNext: async () => {
|
|
509
|
-
await h() && l();
|
|
510
|
-
},
|
|
511
|
-
onBack: a,
|
|
512
|
-
onExit: b,
|
|
513
|
-
isLoading: s.isLoading,
|
|
514
|
-
error: s.error
|
|
515
|
-
}
|
|
516
|
-
);
|
|
517
|
-
case "complete":
|
|
518
|
-
return /* @__PURE__ */ e.jsx($, { provider: s.provider, model: s.selectedModel, onExit: b });
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
return /* @__PURE__ */ e.jsx(o, { flexDirection: "column", height: "100%", width: "100%", children: w() });
|
|
522
|
-
};
|
|
523
|
-
async function Z() {
|
|
524
|
-
await v(), U(/* @__PURE__ */ e.jsx(W, {}));
|
|
525
|
-
}
|
|
526
|
-
Z();
|
|
1
|
+
console.log("Please zen-code and use /m to configure models");
|
package/dist/zen-keyboard.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as a, j as n, a as c, u as f, T as x } from "./MultiLineTextInput-
|
|
1
|
+
import { r as a, j as n, a as c, u as f, T as x } from "./MultiLineTextInput-e7hD79Wp.mjs";
|
|
2
2
|
a(/* @__PURE__ */ n.jsx(l, {}));
|
|
3
3
|
function l() {
|
|
4
4
|
const [r, u] = c.useState(`Press any key...
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-code",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cli.mjs",
|
|
6
6
|
"bin": "./dist/cli.mjs",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"vite-bundle-analyzer": "^1.3.2",
|
|
64
64
|
"vite-plugin-static-copy": "^3.1.4",
|
|
65
65
|
"vitest": "^4.0.18",
|
|
66
|
-
"@codegraph/agent": "1.0.0",
|
|
67
66
|
"@codegraph/config": "1.0.0",
|
|
67
|
+
"@codegraph/agent": "1.0.0",
|
|
68
68
|
"ink-pro": "1.0.0",
|
|
69
69
|
"@codegraph/union-client": "1.0.0"
|
|
70
70
|
},
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
};
|