zen-code 3.0.4 → 4.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/{use-input-1eSjZocJ.mjs → MultiLineTextInput-DjNvaZzA.mjs} +11966 -11473
- package/dist/app-QzdcE86p.mjs +11834 -0
- package/dist/ask_agents-bHg8fyUp.mjs +67 -0
- package/dist/{checkpoint-1sAx_j1E-DddugKQb.mjs → checkpoint-1sAx_j1E-vdL63_qZ.mjs} +2 -2
- package/dist/{checkpoint-DxiUsHMy-B5V5-cLZ.mjs → checkpoint-DxiUsHMy-DSc-mf5U.mjs} +2 -2
- package/dist/get_allowed_models-DWso18Ri.mjs +253 -0
- package/dist/{graphBuilder-B6OHvcgJ.mjs → graphBuilder-ulTm2bmI.mjs} +17628 -34829
- package/dist/{id-BclYO3iE.mjs → id-BHzJB_zk.mjs} +10 -10
- package/dist/index-BrsJ_rEy.mjs +212 -0
- package/dist/{index-CnZgr5T4.mjs → index-hjtoWC6i.mjs} +3 -3
- package/dist/load-Bh8eo6qE.mjs +119 -0
- package/dist/load-Cjl9cJ0o.mjs +105 -0
- package/dist/memories-C_p4qG-9.mjs +115 -0
- package/dist/nonInteractive.mjs +26 -22
- package/dist/{queue-D6tEGCGs-dM7Qa7Il.mjs → queue-D6tEGCGs-dshzv8m6.mjs} +1 -1
- package/dist/{shallow-VHsFXFdT.mjs → shallow-BJVbNSyQ.mjs} +3 -3
- package/dist/subagents-DnvCjtPv.mjs +95 -0
- package/dist/{tasks-Clf8LhHz.mjs → tasks-DhCRIevp.mjs} +1 -1
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +189 -160
- package/dist/zen-keyboard.mjs +1 -1
- package/package.json +7 -5
- package/dist/app-D748EsP_.mjs +0 -18686
- package/dist/get_allowed_models-tD7oPVgc.mjs +0 -774
package/dist/zen-init.mjs
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as c, j as e, T as r, B as o, M as B, r as U } from "./MultiLineTextInput-DjNvaZzA.mjs";
|
|
2
2
|
import "chalk";
|
|
3
|
-
import { u as
|
|
4
|
-
import { c as
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
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();
|
|
8
37
|
});
|
|
9
|
-
const [
|
|
10
|
-
return
|
|
11
|
-
const
|
|
12
|
-
|
|
38
|
+
const [x, d] = c.useState(0);
|
|
39
|
+
return c.useEffect(() => {
|
|
40
|
+
const p = setInterval(() => {
|
|
41
|
+
d((j) => (j + 1) % 92);
|
|
13
42
|
}, 40);
|
|
14
|
-
return () => clearInterval(
|
|
43
|
+
return () => clearInterval(p);
|
|
15
44
|
}, []), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
16
45
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
17
46
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -25,7 +54,7 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
25
54
|
███╔╝ ██╔══╝ ██║╚██╗██║
|
|
26
55
|
███████╗███████╗██║ ╚████║
|
|
27
56
|
╚══════╝╚══════╝╚═╝ ╚═══╝`.split(`
|
|
28
|
-
`).map((
|
|
57
|
+
`).map((l) => /* @__PURE__ */ e.jsx(N, { interval: 40, text: l, globalIndex: x }, l)) }),
|
|
29
58
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", justifyContent: "center", flexGrow: 1, children: [
|
|
30
59
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "yellow", bold: !0, children: [
|
|
31
60
|
" ",
|
|
@@ -101,11 +130,11 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
101
130
|
] }),
|
|
102
131
|
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
103
132
|
] });
|
|
104
|
-
},
|
|
133
|
+
}, F = [
|
|
105
134
|
{ label: "OpenAI (GPT-4, o1 等)", value: "openai" },
|
|
106
135
|
{ label: "Anthropic (Claude)", value: "anthropic" }
|
|
107
|
-
], V = ({ provider:
|
|
108
|
-
const
|
|
136
|
+
], V = ({ provider: s, onSelect: t, onNext: x }) => {
|
|
137
|
+
const d = c.useMemo(() => s ? [s] : [], [s]);
|
|
109
138
|
return /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
110
139
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
111
140
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -125,12 +154,12 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
125
154
|
/* @__PURE__ */ e.jsx(o, { marginTop: 1, marginBottom: 1, children: /* @__PURE__ */ e.jsx(
|
|
126
155
|
T,
|
|
127
156
|
{
|
|
128
|
-
options:
|
|
129
|
-
values:
|
|
130
|
-
onChange: (
|
|
131
|
-
|
|
157
|
+
options: F,
|
|
158
|
+
values: d,
|
|
159
|
+
onChange: (l) => {
|
|
160
|
+
l.length > 0 && t(l[0]);
|
|
132
161
|
},
|
|
133
|
-
onSubmit:
|
|
162
|
+
onSubmit: x,
|
|
134
163
|
singleSelect: !0,
|
|
135
164
|
autoFocus: !0
|
|
136
165
|
}
|
|
@@ -149,34 +178,34 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
149
178
|
] }),
|
|
150
179
|
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
151
180
|
] });
|
|
152
|
-
},
|
|
181
|
+
}, A = {
|
|
153
182
|
openai: "https://api.openai.com/v1",
|
|
154
183
|
anthropic: "https://api.anthropic.com"
|
|
155
184
|
}, G = {
|
|
156
185
|
openai: "https://platform.openai.com/api-keys",
|
|
157
186
|
anthropic: "https://console.anthropic.com/settings/keys"
|
|
158
187
|
}, X = ({
|
|
159
|
-
provider:
|
|
160
|
-
apiKey:
|
|
161
|
-
baseUrl:
|
|
162
|
-
onApiKeyChange:
|
|
163
|
-
onBaseUrlChange:
|
|
164
|
-
onNext:
|
|
188
|
+
provider: s,
|
|
189
|
+
apiKey: t,
|
|
190
|
+
baseUrl: x,
|
|
191
|
+
onApiKeyChange: d,
|
|
192
|
+
onBaseUrlChange: l,
|
|
193
|
+
onNext: a,
|
|
165
194
|
onBack: C,
|
|
166
195
|
onExit: I,
|
|
167
|
-
error:
|
|
196
|
+
error: p
|
|
168
197
|
}) => {
|
|
169
|
-
const [
|
|
170
|
-
y(
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
}, E = (
|
|
176
|
-
|
|
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();
|
|
177
206
|
};
|
|
178
|
-
return
|
|
179
|
-
if (S.ctrl &&
|
|
207
|
+
return D((u, S) => {
|
|
208
|
+
if (S.ctrl && u === "c" && I(), S.escape) {
|
|
180
209
|
C();
|
|
181
210
|
return;
|
|
182
211
|
}
|
|
@@ -189,42 +218,42 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
189
218
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
190
219
|
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
191
220
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "PROVIDER::" }),
|
|
192
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children:
|
|
221
|
+
/* @__PURE__ */ e.jsx(r, { color: "white", children: s.toUpperCase() })
|
|
193
222
|
] }),
|
|
194
223
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { bold: !0, children: "Base URL (可选)" }) }),
|
|
195
224
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "gray", children: [
|
|
196
225
|
"默认值: ",
|
|
197
|
-
|
|
226
|
+
w
|
|
198
227
|
] }) }),
|
|
199
228
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(
|
|
200
229
|
B,
|
|
201
230
|
{
|
|
202
|
-
value:
|
|
203
|
-
onChange:
|
|
231
|
+
value: h,
|
|
232
|
+
onChange: i,
|
|
204
233
|
onSubmit: E,
|
|
205
|
-
placeholder:
|
|
234
|
+
placeholder: w
|
|
206
235
|
}
|
|
207
236
|
) }),
|
|
208
237
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { bold: !0, children: "API 密钥" }) }),
|
|
209
238
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "gray", children: [
|
|
210
239
|
"获取地址: ",
|
|
211
|
-
G[
|
|
240
|
+
G[s]
|
|
212
241
|
] }) }),
|
|
213
|
-
/* @__PURE__ */ e.jsx(o, { marginBottom:
|
|
242
|
+
/* @__PURE__ */ e.jsx(o, { marginBottom: j === "apiKey" && p ? 0 : 1, children: /* @__PURE__ */ e.jsx(
|
|
214
243
|
B,
|
|
215
244
|
{
|
|
216
|
-
value:
|
|
245
|
+
value: g,
|
|
217
246
|
onChange: n,
|
|
218
|
-
onSubmit:
|
|
247
|
+
onSubmit: f,
|
|
219
248
|
placeholder: "sk-...",
|
|
220
249
|
autoFocus: !1
|
|
221
250
|
}
|
|
222
251
|
) }),
|
|
223
|
-
|
|
252
|
+
p && j === "apiKey" && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
|
|
224
253
|
"✗ ",
|
|
225
|
-
|
|
254
|
+
p
|
|
226
255
|
] }) }),
|
|
227
|
-
|
|
256
|
+
j === "baseUrl" && !h && /* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "💡 留空使用默认值" }) })
|
|
228
257
|
] }),
|
|
229
258
|
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
230
259
|
/* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "Tab/Shift+Tab 切换 | Enter 确认 | Esc 返回" }) }),
|
|
@@ -240,28 +269,28 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
240
269
|
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
241
270
|
] });
|
|
242
271
|
}, Y = ({
|
|
243
|
-
provider:
|
|
244
|
-
models:
|
|
245
|
-
selectedModel:
|
|
246
|
-
onSelect:
|
|
247
|
-
onRefresh:
|
|
248
|
-
onNext:
|
|
272
|
+
provider: s,
|
|
273
|
+
models: t,
|
|
274
|
+
selectedModel: x,
|
|
275
|
+
onSelect: d,
|
|
276
|
+
onRefresh: l,
|
|
277
|
+
onNext: a,
|
|
249
278
|
onBack: C,
|
|
250
279
|
onExit: I,
|
|
251
|
-
isLoading:
|
|
252
|
-
error:
|
|
280
|
+
isLoading: p,
|
|
281
|
+
error: j
|
|
253
282
|
}) => {
|
|
254
|
-
const
|
|
255
|
-
label:
|
|
256
|
-
value:
|
|
257
|
-
})),
|
|
258
|
-
(
|
|
259
|
-
|
|
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());
|
|
260
289
|
},
|
|
261
|
-
[
|
|
290
|
+
[d, a]
|
|
262
291
|
);
|
|
263
|
-
return
|
|
264
|
-
(
|
|
292
|
+
return D((h, b) => {
|
|
293
|
+
(h === "r" || h === "R") && !p && l(), b.escape && C();
|
|
265
294
|
}), /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
266
295
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
267
296
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -271,30 +300,30 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
271
300
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginTop: 1, children: [
|
|
272
301
|
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, children: [
|
|
273
302
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "提供商 ::" }),
|
|
274
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children:
|
|
303
|
+
/* @__PURE__ */ e.jsx(r, { color: "white", children: s.toUpperCase() })
|
|
275
304
|
] }),
|
|
276
|
-
|
|
277
|
-
/* @__PURE__ */ e.jsx(
|
|
305
|
+
p && t.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { children: [
|
|
306
|
+
/* @__PURE__ */ e.jsx(O, { type: "dots" }),
|
|
278
307
|
" 检测可用模型中..."
|
|
279
308
|
] }) }),
|
|
280
|
-
!
|
|
281
|
-
!
|
|
282
|
-
!
|
|
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(
|
|
283
312
|
T,
|
|
284
313
|
{
|
|
285
|
-
options:
|
|
286
|
-
values:
|
|
287
|
-
onChange: (
|
|
288
|
-
|
|
314
|
+
options: m,
|
|
315
|
+
values: g,
|
|
316
|
+
onChange: (h) => {
|
|
317
|
+
h.length > 0 && d(h[0]);
|
|
289
318
|
},
|
|
290
319
|
onSubmit: y,
|
|
291
320
|
singleSelect: !0,
|
|
292
321
|
autoFocus: !0
|
|
293
322
|
}
|
|
294
323
|
),
|
|
295
|
-
|
|
324
|
+
j && /* @__PURE__ */ e.jsx(o, { marginTop: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
|
|
296
325
|
"✗ ",
|
|
297
|
-
|
|
326
|
+
j
|
|
298
327
|
] }) })
|
|
299
328
|
] }),
|
|
300
329
|
/* @__PURE__ */ e.jsxs(o, { marginTop: 1, paddingTop: 1, borderTop: !1, flexDirection: "row", justifyContent: "space-between", children: [
|
|
@@ -310,11 +339,11 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
310
339
|
] }),
|
|
311
340
|
/* @__PURE__ */ e.jsx(o, { flexDirection: "row", justifyContent: "center", children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "[Ctrl+C 退出]" }) })
|
|
312
341
|
] });
|
|
313
|
-
},
|
|
342
|
+
}, H = {
|
|
314
343
|
openai: "OpenAI",
|
|
315
344
|
anthropic: "Anthropic"
|
|
316
|
-
},
|
|
317
|
-
(
|
|
345
|
+
}, $ = ({ provider: s, model: t, onExit: x }) => (D((d, l) => {
|
|
346
|
+
(d || l.return) && x();
|
|
318
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: [
|
|
319
348
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
320
349
|
/* @__PURE__ */ e.jsx(r, { color: "green", bold: !0, children: "✓ 配置完成" }),
|
|
@@ -328,15 +357,15 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
328
357
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", marginBottom: 2, gap: 1, children: [
|
|
329
358
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
330
359
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "提供商 ::" }),
|
|
331
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children:
|
|
360
|
+
/* @__PURE__ */ e.jsx(r, { color: "white", children: H[s] })
|
|
332
361
|
] }),
|
|
333
362
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
334
363
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "模型 ::" }),
|
|
335
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children:
|
|
364
|
+
/* @__PURE__ */ e.jsx(r, { color: "white", children: t })
|
|
336
365
|
] }),
|
|
337
366
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
338
367
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "配置路径 ::" }),
|
|
339
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children:
|
|
368
|
+
/* @__PURE__ */ e.jsx(r, { color: "gray", children: K.getConfigPath() })
|
|
340
369
|
] })
|
|
341
370
|
] }),
|
|
342
371
|
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
|
|
@@ -366,132 +395,132 @@ const N = ({ onNext: l, onExit: i }) => {
|
|
|
366
395
|
isLoading: !1,
|
|
367
396
|
error: null
|
|
368
397
|
}, W = () => {
|
|
369
|
-
const [
|
|
370
|
-
|
|
398
|
+
const [s, t] = c.useState(z), [x, d] = c.useState([]), l = c.useCallback(() => {
|
|
399
|
+
t((n) => {
|
|
371
400
|
if (n.step === "model" && !n.selectedModel)
|
|
372
401
|
return { ...n, error: "请选择一个模型" };
|
|
373
402
|
if (n.step === "apiAndBaseUrl") {
|
|
374
403
|
if (!n.apiKey)
|
|
375
404
|
return { ...n, error: "请输入 API Key" };
|
|
376
|
-
n.provider && (process.env.MODEL_PROVIDER = n.provider, n.provider === "openai" ? (process.env.OPENAI_API_KEY = n.apiKey, n.baseUrl && n.baseUrl !==
|
|
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)));
|
|
377
406
|
}
|
|
378
|
-
const
|
|
379
|
-
return
|
|
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;
|
|
380
409
|
});
|
|
381
|
-
}, []),
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
return
|
|
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;
|
|
385
414
|
});
|
|
386
|
-
}, []), C =
|
|
387
|
-
process.env.MODEL_PROVIDER = n,
|
|
388
|
-
...
|
|
415
|
+
}, []), C = c.useCallback((n) => {
|
|
416
|
+
process.env.MODEL_PROVIDER = n, t((i) => ({
|
|
417
|
+
...i,
|
|
389
418
|
provider: n,
|
|
390
|
-
baseUrl:
|
|
419
|
+
baseUrl: A[n],
|
|
391
420
|
apiKey: "",
|
|
392
421
|
selectedModel: ""
|
|
393
422
|
}));
|
|
394
|
-
}, []), I =
|
|
395
|
-
|
|
396
|
-
}, []),
|
|
397
|
-
|
|
398
|
-
}, []),
|
|
399
|
-
|
|
400
|
-
}, []),
|
|
401
|
-
|
|
402
|
-
}, []),
|
|
403
|
-
|
|
404
|
-
}, []), y =
|
|
405
|
-
|
|
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);
|
|
406
435
|
try {
|
|
407
|
-
const
|
|
408
|
-
process.env.MODEL_PROVIDER = n, n === "openai" ? process.env.OPENAI_API_KEY =
|
|
409
|
-
const _ = (await
|
|
410
|
-
|
|
411
|
-
} catch (
|
|
412
|
-
|
|
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([]);
|
|
413
442
|
} finally {
|
|
414
|
-
|
|
443
|
+
g(!1);
|
|
415
444
|
}
|
|
416
|
-
}, []),
|
|
417
|
-
if (!
|
|
418
|
-
return
|
|
419
|
-
|
|
445
|
+
}, []), h = c.useCallback(async () => {
|
|
446
|
+
if (!s.provider || !s.apiKey || !s.selectedModel)
|
|
447
|
+
return m("配置不完整"), !1;
|
|
448
|
+
g(!0), m(null);
|
|
420
449
|
try {
|
|
421
450
|
const n = {
|
|
422
|
-
main_model:
|
|
423
|
-
model_provider:
|
|
451
|
+
main_model: s.selectedModel,
|
|
452
|
+
model_provider: s.provider
|
|
424
453
|
};
|
|
425
|
-
return
|
|
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;
|
|
426
455
|
} catch (n) {
|
|
427
|
-
return
|
|
456
|
+
return m(`保存配置失败: ${n instanceof Error ? n.message : String(n)}`), !1;
|
|
428
457
|
} finally {
|
|
429
|
-
|
|
458
|
+
g(!1);
|
|
430
459
|
}
|
|
431
|
-
}, [
|
|
460
|
+
}, [s]), b = c.useCallback(() => {
|
|
432
461
|
process.exit(0);
|
|
433
462
|
}, []);
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}, [
|
|
437
|
-
|
|
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();
|
|
438
467
|
});
|
|
439
|
-
const
|
|
440
|
-
switch (
|
|
468
|
+
const w = () => {
|
|
469
|
+
switch (s.step) {
|
|
441
470
|
case "welcome":
|
|
442
|
-
return /* @__PURE__ */ e.jsx(
|
|
471
|
+
return /* @__PURE__ */ e.jsx(k, { onNext: l, onExit: b });
|
|
443
472
|
case "provider":
|
|
444
473
|
return /* @__PURE__ */ e.jsx(
|
|
445
474
|
V,
|
|
446
475
|
{
|
|
447
|
-
provider:
|
|
476
|
+
provider: s.provider,
|
|
448
477
|
onSelect: (n) => {
|
|
449
478
|
C(n);
|
|
450
479
|
},
|
|
451
|
-
onNext:
|
|
452
|
-
onExit:
|
|
480
|
+
onNext: l,
|
|
481
|
+
onExit: b
|
|
453
482
|
}
|
|
454
483
|
);
|
|
455
484
|
case "apiAndBaseUrl":
|
|
456
485
|
return /* @__PURE__ */ e.jsx(
|
|
457
486
|
X,
|
|
458
487
|
{
|
|
459
|
-
provider:
|
|
460
|
-
apiKey:
|
|
461
|
-
baseUrl:
|
|
488
|
+
provider: s.provider,
|
|
489
|
+
apiKey: s.apiKey,
|
|
490
|
+
baseUrl: s.baseUrl,
|
|
462
491
|
onApiKeyChange: I,
|
|
463
|
-
onBaseUrlChange:
|
|
464
|
-
onNext:
|
|
465
|
-
onBack:
|
|
466
|
-
onExit:
|
|
467
|
-
error:
|
|
492
|
+
onBaseUrlChange: p,
|
|
493
|
+
onNext: l,
|
|
494
|
+
onBack: a,
|
|
495
|
+
onExit: b,
|
|
496
|
+
error: s.error
|
|
468
497
|
}
|
|
469
498
|
);
|
|
470
499
|
case "model":
|
|
471
500
|
return /* @__PURE__ */ e.jsx(
|
|
472
501
|
Y,
|
|
473
502
|
{
|
|
474
|
-
provider:
|
|
475
|
-
models:
|
|
476
|
-
selectedModel:
|
|
477
|
-
onSelect:
|
|
478
|
-
onRefresh: () => y(
|
|
503
|
+
provider: s.provider,
|
|
504
|
+
models: x,
|
|
505
|
+
selectedModel: s.selectedModel,
|
|
506
|
+
onSelect: j,
|
|
507
|
+
onRefresh: () => y(s.provider, s.apiKey),
|
|
479
508
|
onNext: async () => {
|
|
480
|
-
await
|
|
509
|
+
await h() && l();
|
|
481
510
|
},
|
|
482
|
-
onBack:
|
|
483
|
-
onExit:
|
|
484
|
-
isLoading:
|
|
485
|
-
error:
|
|
511
|
+
onBack: a,
|
|
512
|
+
onExit: b,
|
|
513
|
+
isLoading: s.isLoading,
|
|
514
|
+
error: s.error
|
|
486
515
|
}
|
|
487
516
|
);
|
|
488
517
|
case "complete":
|
|
489
|
-
return /* @__PURE__ */ e.jsx(
|
|
518
|
+
return /* @__PURE__ */ e.jsx($, { provider: s.provider, model: s.selectedModel, onExit: b });
|
|
490
519
|
}
|
|
491
520
|
};
|
|
492
|
-
return /* @__PURE__ */ e.jsx(o, { flexDirection: "column", height: "100%", width: "100%", children:
|
|
521
|
+
return /* @__PURE__ */ e.jsx(o, { flexDirection: "column", height: "100%", width: "100%", children: w() });
|
|
493
522
|
};
|
|
494
|
-
async function
|
|
495
|
-
await
|
|
523
|
+
async function Z() {
|
|
524
|
+
await v(), U(/* @__PURE__ */ e.jsx(W, {}));
|
|
496
525
|
}
|
|
497
|
-
|
|
526
|
+
Z();
|
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 "./
|
|
1
|
+
import { r as a, j as n, a as c, u as f, T as x } from "./MultiLineTextInput-DjNvaZzA.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": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/cli.mjs",
|
|
6
6
|
"bin": "./dist/cli.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
15
15
|
"@langchain/anthropic": "1.3.10",
|
|
16
|
-
"@langchain/core": "
|
|
16
|
+
"@langchain/core": "1.1.15",
|
|
17
17
|
"@langchain/langgraph": "^1.1.0",
|
|
18
18
|
"@langchain/openai": "1.1.3",
|
|
19
19
|
"@langgraph-js/pure-graph": "^2.10.0",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"tempy": "^3.1.0",
|
|
35
35
|
"xdg-basedir": "^5.1.0",
|
|
36
36
|
"yaml": "^2.8.2",
|
|
37
|
-
"zod": "^4.3.5"
|
|
37
|
+
"zod": "^4.3.5",
|
|
38
|
+
"@langgraph-js/standard-agent": "1.1.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@inkjs/ui": "^2.0.0",
|
|
@@ -63,8 +64,9 @@
|
|
|
63
64
|
"vite-plugin-static-copy": "^3.1.4",
|
|
64
65
|
"vitest": "^4.0.18",
|
|
65
66
|
"@codegraph/agent": "1.0.0",
|
|
66
|
-
"@codegraph/
|
|
67
|
-
"
|
|
67
|
+
"@codegraph/config": "1.0.0",
|
|
68
|
+
"ink-pro": "1.0.0",
|
|
69
|
+
"@codegraph/union-client": "1.0.0"
|
|
68
70
|
},
|
|
69
71
|
"babel": {
|
|
70
72
|
"presets": [
|