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/zen-init.mjs CHANGED
@@ -1,17 +1,46 @@
1
- import { a as t, j as e, B as o, T as r, r as U } from "./use-input-1eSjZocJ.mjs";
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 A, S as O, M as T, a as B, b as R, g as K } from "./get_allowed_models-tD7oPVgc.mjs";
4
- import { c as M, u as v, i as L } from "./index-BG-c4_r3.mjs";
5
- const N = ({ onNext: l, onExit: i }) => {
6
- A((c, p) => {
7
- p.return ? l() : p.ctrl && c === "c" && i();
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 [j, x] = t.useState(0);
10
- return t.useEffect(() => {
11
- const u = setInterval(() => {
12
- x((m) => (m + 1) % 92);
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(u);
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((c) => /* @__PURE__ */ e.jsx(O, { interval: 40, text: c, globalIndex: j }, c)) }),
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
- }, k = [
133
+ }, F = [
105
134
  { label: "OpenAI (GPT-4, o1 等)", value: "openai" },
106
135
  { label: "Anthropic (Claude)", value: "anthropic" }
107
- ], V = ({ provider: l, onSelect: i, onNext: j }) => {
108
- const x = t.useMemo(() => l ? [l] : [], [l]);
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: k,
129
- values: x,
130
- onChange: (c) => {
131
- c.length > 0 && i(c[0]);
157
+ options: F,
158
+ values: d,
159
+ onChange: (l) => {
160
+ l.length > 0 && t(l[0]);
132
161
  },
133
- onSubmit: j,
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
- }, w = {
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: l,
160
- apiKey: i,
161
- baseUrl: j,
162
- onApiKeyChange: x,
163
- onBaseUrlChange: c,
164
- onNext: p,
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: u
196
+ error: p
168
197
  }) => {
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
- }, s = (a) => {
172
- f(a), c(a);
173
- }, h = (a) => {
174
- a = a.trim(), n(a), p();
175
- }, E = (a) => {
176
- a = a.trim(), s(a), p();
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 A((a, S) => {
179
- if (S.ctrl && a === "c" && I(), S.escape) {
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: l.toUpperCase() })
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
- D
226
+ w
198
227
  ] }) }),
199
228
  /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(
200
229
  B,
201
230
  {
202
- value: d,
203
- onChange: s,
231
+ value: h,
232
+ onChange: i,
204
233
  onSubmit: E,
205
- placeholder: D
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[l]
240
+ G[s]
212
241
  ] }) }),
213
- /* @__PURE__ */ e.jsx(o, { marginBottom: m === "apiKey" && u ? 0 : 1, children: /* @__PURE__ */ e.jsx(
242
+ /* @__PURE__ */ e.jsx(o, { marginBottom: j === "apiKey" && p ? 0 : 1, children: /* @__PURE__ */ e.jsx(
214
243
  B,
215
244
  {
216
- value: b,
245
+ value: g,
217
246
  onChange: n,
218
- onSubmit: h,
247
+ onSubmit: f,
219
248
  placeholder: "sk-...",
220
249
  autoFocus: !1
221
250
  }
222
251
  ) }),
223
- u && m === "apiKey" && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
252
+ p && j === "apiKey" && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
224
253
  "✗ ",
225
- u
254
+ p
226
255
  ] }) }),
227
- m === "baseUrl" && !d && /* @__PURE__ */ e.jsx(o, { children: /* @__PURE__ */ e.jsx(r, { color: "gray", dimColor: !0, children: "💡 留空使用默认值" }) })
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: l,
244
- models: i,
245
- selectedModel: j,
246
- onSelect: x,
247
- onRefresh: c,
248
- onNext: p,
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: u,
252
- error: m
280
+ isLoading: p,
281
+ error: j
253
282
  }) => {
254
- const g = i.map((d) => ({
255
- label: d.name,
256
- value: d.id
257
- })), b = j ? [j] : [], y = t.useCallback(
258
- (d) => {
259
- d.length > 0 && (x(d[0]), p());
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
- [x, p]
290
+ [d, a]
262
291
  );
263
- return A((d, f) => {
264
- (d === "r" || d === "R") && !u && c(), f.escape && C();
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: l.toUpperCase() })
303
+ /* @__PURE__ */ e.jsx(r, { color: "white", children: s.toUpperCase() })
275
304
  ] }),
276
- u && i.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { children: [
277
- /* @__PURE__ */ e.jsx(R, { type: "dots" }),
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
- !u && i.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { color: "yellow", children: "未找到可用模型,请按 R 刷新" }) }),
281
- !u && i.length > 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsx(r, { color: "gray", children: "选择您偏好的模型:" }) }),
282
- !u && i.length > 0 && /* @__PURE__ */ e.jsx(
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: g,
286
- values: b,
287
- onChange: (d) => {
288
- d.length > 0 && x(d[0]);
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
- m && /* @__PURE__ */ e.jsx(o, { marginTop: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
324
+ j && /* @__PURE__ */ e.jsx(o, { marginTop: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "red", children: [
296
325
  "✗ ",
297
- m
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
- }, F = {
342
+ }, H = {
314
343
  openai: "OpenAI",
315
344
  anthropic: "Anthropic"
316
- }, H = ({ provider: l, model: i, onExit: j }) => (A((x, c) => {
317
- (x || c.return) && j();
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: F[l] })
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: i })
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: M.getConfigPath() })
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 [l, i] = t.useState(z), [j, x] = t.useState([]), c = t.useCallback(() => {
370
- i((n) => {
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 !== w.openai && (process.env.OPENAI_BASE_URL = n.baseUrl)) : (process.env.ANTHROPIC_API_KEY = n.apiKey, n.baseUrl && n.baseUrl !== w.anthropic && (process.env.ANTHROPIC_BASE_URL = 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 s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
379
- return h < s.length - 1 ? { ...n, step: s[h + 1], error: null } : n;
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
- }, []), p = t.useCallback(() => {
382
- i((n) => {
383
- const s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
384
- return h > 0 ? { ...n, step: s[h - 1], error: null } : n;
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 = t.useCallback((n) => {
387
- process.env.MODEL_PROVIDER = n, i((s) => ({
388
- ...s,
415
+ }, []), C = c.useCallback((n) => {
416
+ process.env.MODEL_PROVIDER = n, t((i) => ({
417
+ ...i,
389
418
  provider: n,
390
- baseUrl: w[n],
419
+ baseUrl: A[n],
391
420
  apiKey: "",
392
421
  selectedModel: ""
393
422
  }));
394
- }, []), I = t.useCallback((n) => {
395
- i((s) => ({ ...s, apiKey: n, error: null }));
396
- }, []), u = t.useCallback((n) => {
397
- i((s) => ({ ...s, baseUrl: n, error: null }));
398
- }, []), m = t.useCallback((n) => {
399
- i((s) => ({ ...s, selectedModel: n, error: null }));
400
- }, []), g = t.useCallback((n) => {
401
- i((s) => ({ ...s, error: n }));
402
- }, []), b = t.useCallback((n) => {
403
- i((s) => ({ ...s, isLoading: n }));
404
- }, []), y = t.useCallback(async (n, s) => {
405
- b(!0), g(null);
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 h = process.env.MODEL_PROVIDER, E = process.env.OPENAI_API_KEY, a = process.env.ANTHROPIC_API_KEY;
408
- process.env.MODEL_PROVIDER = n, n === "openai" ? process.env.OPENAI_API_KEY = s || "temp" : process.env.ANTHROPIC_API_KEY = s || "temp";
409
- const _ = (await K()).filter((P) => P.provider === n);
410
- x(_), h && (process.env.MODEL_PROVIDER = h), E && (process.env.OPENAI_API_KEY = E), a && (process.env.ANTHROPIC_API_KEY = a);
411
- } catch (h) {
412
- g(`加载模型失败: ${h instanceof Error ? h.message : String(h)}`), x([]);
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
- b(!1);
443
+ g(!1);
415
444
  }
416
- }, []), d = t.useCallback(async () => {
417
- if (!l.provider || !l.apiKey || !l.selectedModel)
418
- return g("配置不完整"), !1;
419
- b(!0), g(null);
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: l.selectedModel,
423
- model_provider: l.provider
451
+ main_model: s.selectedModel,
452
+ model_provider: s.provider
424
453
  };
425
- return l.provider === "openai" ? (n.openai_api_key = l.apiKey, l.baseUrl && l.baseUrl !== w.openai && (n.openai_base_url = l.baseUrl)) : (n.anthropic_api_key = l.apiKey, l.baseUrl && l.baseUrl !== w.anthropic && (n.anthropic_base_url = l.baseUrl)), await v(n), !0;
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 g(`保存配置失败: ${n instanceof Error ? n.message : String(n)}`), !1;
456
+ return m(`保存配置失败: ${n instanceof Error ? n.message : String(n)}`), !1;
428
457
  } finally {
429
- b(!1);
458
+ g(!1);
430
459
  }
431
- }, [l]), f = t.useCallback(() => {
460
+ }, [s]), b = c.useCallback(() => {
432
461
  process.exit(0);
433
462
  }, []);
434
- t.useEffect(() => {
435
- l.step === "model" && l.provider && l.apiKey && y(l.provider, l.apiKey);
436
- }, [l.step, l.provider, l.apiKey, y]), A((n, s) => {
437
- s.ctrl && n === "c" ? process.exit(0) : s.escape && p();
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 D = () => {
440
- switch (l.step) {
468
+ const w = () => {
469
+ switch (s.step) {
441
470
  case "welcome":
442
- return /* @__PURE__ */ e.jsx(N, { onNext: c, onExit: f });
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: l.provider,
476
+ provider: s.provider,
448
477
  onSelect: (n) => {
449
478
  C(n);
450
479
  },
451
- onNext: c,
452
- onExit: f
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: l.provider,
460
- apiKey: l.apiKey,
461
- baseUrl: l.baseUrl,
488
+ provider: s.provider,
489
+ apiKey: s.apiKey,
490
+ baseUrl: s.baseUrl,
462
491
  onApiKeyChange: I,
463
- onBaseUrlChange: u,
464
- onNext: c,
465
- onBack: p,
466
- onExit: f,
467
- error: l.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: l.provider,
475
- models: j,
476
- selectedModel: l.selectedModel,
477
- onSelect: m,
478
- onRefresh: () => y(l.provider, l.apiKey),
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 d() && c();
509
+ await h() && l();
481
510
  },
482
- onBack: p,
483
- onExit: f,
484
- isLoading: l.isLoading,
485
- error: l.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(H, { provider: l.provider, model: l.selectedModel, onExit: f });
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: D() });
521
+ return /* @__PURE__ */ e.jsx(o, { flexDirection: "column", height: "100%", width: "100%", children: w() });
493
522
  };
494
- async function $() {
495
- await L(), U(/* @__PURE__ */ e.jsx(W, {}));
523
+ async function Z() {
524
+ await v(), U(/* @__PURE__ */ e.jsx(W, {}));
496
525
  }
497
- $();
526
+ Z();
@@ -1,4 +1,4 @@
1
- import { r as a, j as n, a as c, u as f, T as x } from "./use-input-1eSjZocJ.mjs";
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.0.4",
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": "^1.1.15",
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/union-client": "1.0.0",
67
- "@codegraph/config": "1.0.0"
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": [