zen-code 2.0.0 → 2.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/MultiSelect-DPUY1M3X.mjs +651 -0
- package/dist/{_commonjsHelpers-DQNKXVTB.mjs → _commonjsHelpers-ByX85dGu.mjs} +2 -2
- package/dist/app-DSomQ6O6.mjs +9425 -0
- package/dist/{checkpoint-1sAx_j1E-C7vuWMYk.mjs → checkpoint-1sAx_j1E-DxhHzrFo.mjs} +2 -1
- package/dist/{checkpoint-DxiUsHMy-BAS0QTsO.mjs → checkpoint-DxiUsHMy-DQXGrxXE.mjs} +4 -3
- package/dist/cli.mjs +33 -0
- package/dist/{devtools-m8Lnvjy_.mjs → devtools-BxIzBVXg.mjs} +1 -1
- package/dist/{app-BYHr8LGb.mjs → graph-DDkv1rqg.mjs} +21511 -31014
- package/dist/{id-D9MvPv5H.mjs → id-CzaxLw8O.mjs} +1 -1
- package/dist/index-B5v_6qaq.mjs +22 -0
- package/dist/{index-CUBPsTPx.mjs → index-C1CZncrT.mjs} +5 -4
- package/dist/nonInteractive.mjs +45 -0
- package/dist/{queue-BSCnCent-Ct_0uFlj.mjs → queue-BSCnCent-CSGRBLST.mjs} +1 -1
- package/dist/{shallow-CZp172oK.mjs → shallow-DwTxKmlC.mjs} +5 -4
- package/dist/{MultiSelect-CZS5qXWj.mjs → use-input-CQELhJxU.mjs} +10200 -10340
- package/dist/zen-code.mjs +2 -2
- package/dist/zen-init.mjs +45 -43
- package/dist/zen-keyboard.mjs +13 -0
- package/package.json +5 -6
- package/cli.js +0 -8
package/dist/zen-code.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./use-input-CQELhJxU.mjs";
|
|
2
2
|
import "chalk";
|
|
3
|
-
import "./app-
|
|
3
|
+
import "./app-DSomQ6O6.mjs";
|
package/dist/zen-init.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as t, j as e, B as o, T as r, r as U } from "./use-input-CQELhJxU.mjs";
|
|
2
2
|
import "chalk";
|
|
3
|
-
|
|
3
|
+
import { u as A, S as O, M as T, a as B, b as R, g as K } from "./MultiSelect-DPUY1M3X.mjs";
|
|
4
|
+
import { d as M, u as v, i as L } from "./index-B5v_6qaq.mjs";
|
|
5
|
+
const N = ({ onNext: l, onExit: i }) => {
|
|
4
6
|
A((c, d) => {
|
|
5
|
-
d.return ? l() : d.ctrl && c === "c" &&
|
|
7
|
+
d.return ? l() : d.ctrl && c === "c" && i();
|
|
6
8
|
});
|
|
7
|
-
const [j, p] =
|
|
8
|
-
return
|
|
9
|
+
const [j, p] = t.useState(0);
|
|
10
|
+
return t.useEffect(() => {
|
|
9
11
|
const u = setInterval(() => {
|
|
10
12
|
p((m) => (m + 1) % 92);
|
|
11
13
|
}, 40);
|
|
@@ -23,7 +25,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
23
25
|
███╔╝ ██╔══╝ ██║╚██╗██║
|
|
24
26
|
███████╗███████╗██║ ╚████║
|
|
25
27
|
╚══════╝╚══════╝╚═╝ ╚═══╝`.split(`
|
|
26
|
-
`).map((c) => /* @__PURE__ */ e.jsx(
|
|
28
|
+
`).map((c) => /* @__PURE__ */ e.jsx(O, { interval: 40, text: c, globalIndex: j }, c)) }),
|
|
27
29
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", justifyContent: "center", flexGrow: 1, children: [
|
|
28
30
|
/* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { color: "yellow", bold: !0, children: [
|
|
29
31
|
" ",
|
|
@@ -102,8 +104,8 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
102
104
|
}, k = [
|
|
103
105
|
{ label: "OpenAI (GPT-4, o1 等)", value: "openai" },
|
|
104
106
|
{ label: "Anthropic (Claude)", value: "anthropic" }
|
|
105
|
-
], V = ({ provider: l, onSelect:
|
|
106
|
-
const c =
|
|
107
|
+
], V = ({ provider: l, onSelect: i, onNext: j, onExit: p }) => {
|
|
108
|
+
const c = t.useMemo(() => l ? [l] : [], [l]);
|
|
107
109
|
return /* @__PURE__ */ e.jsxs(o, { flexDirection: "column", flexGrow: 1, justifyContent: "center", paddingX: 2, children: [
|
|
108
110
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, marginBottom: 1, children: [
|
|
109
111
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -126,7 +128,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
126
128
|
options: k,
|
|
127
129
|
values: c,
|
|
128
130
|
onChange: (d) => {
|
|
129
|
-
d.length > 0 &&
|
|
131
|
+
d.length > 0 && i(d[0]);
|
|
130
132
|
},
|
|
131
133
|
onSubmit: j,
|
|
132
134
|
singleSelect: !0,
|
|
@@ -155,7 +157,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
155
157
|
anthropic: "https://console.anthropic.com/settings/keys"
|
|
156
158
|
}, X = ({
|
|
157
159
|
provider: l,
|
|
158
|
-
apiKey:
|
|
160
|
+
apiKey: i,
|
|
159
161
|
baseUrl: j,
|
|
160
162
|
onApiKeyChange: p,
|
|
161
163
|
onBaseUrlChange: c,
|
|
@@ -164,7 +166,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
164
166
|
onExit: I,
|
|
165
167
|
error: u
|
|
166
168
|
}) => {
|
|
167
|
-
const [m, g] =
|
|
169
|
+
const [m, g] = t.useState("apiKey"), [b, y] = t.useState(i), [x, f] = t.useState(j), D = w[l], n = (a) => {
|
|
168
170
|
y(a), p(a);
|
|
169
171
|
}, s = (a) => {
|
|
170
172
|
f(a), c(a);
|
|
@@ -239,7 +241,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
239
241
|
] });
|
|
240
242
|
}, Y = ({
|
|
241
243
|
provider: l,
|
|
242
|
-
models:
|
|
244
|
+
models: i,
|
|
243
245
|
selectedModel: j,
|
|
244
246
|
onSelect: p,
|
|
245
247
|
onRefresh: c,
|
|
@@ -249,10 +251,10 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
249
251
|
isLoading: u,
|
|
250
252
|
error: m
|
|
251
253
|
}) => {
|
|
252
|
-
const g =
|
|
254
|
+
const g = i.map((x) => ({
|
|
253
255
|
label: x.name,
|
|
254
256
|
value: x.id
|
|
255
|
-
})), b = j ? [j] : [], y =
|
|
257
|
+
})), b = j ? [j] : [], y = t.useCallback(
|
|
256
258
|
(x) => {
|
|
257
259
|
x.length > 0 && (p(x[0]), d());
|
|
258
260
|
},
|
|
@@ -271,13 +273,13 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
271
273
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "提供商 ::" }),
|
|
272
274
|
/* @__PURE__ */ e.jsx(r, { color: "white", children: l.toUpperCase() })
|
|
273
275
|
] }),
|
|
274
|
-
u &&
|
|
275
|
-
/* @__PURE__ */ e.jsx(
|
|
276
|
+
u && i.length === 0 && /* @__PURE__ */ e.jsx(o, { marginBottom: 1, children: /* @__PURE__ */ e.jsxs(r, { children: [
|
|
277
|
+
/* @__PURE__ */ e.jsx(R, { type: "dots" }),
|
|
276
278
|
" 检测可用模型中..."
|
|
277
279
|
] }) }),
|
|
278
|
-
!u &&
|
|
279
|
-
!u &&
|
|
280
|
-
!u &&
|
|
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(
|
|
281
283
|
T,
|
|
282
284
|
{
|
|
283
285
|
options: g,
|
|
@@ -311,7 +313,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
311
313
|
}, F = {
|
|
312
314
|
openai: "OpenAI",
|
|
313
315
|
anthropic: "Anthropic"
|
|
314
|
-
}, H = ({ provider: l, model:
|
|
316
|
+
}, H = ({ provider: l, model: i, onExit: j }) => (A((p, c) => {
|
|
315
317
|
(p || c.return) && j();
|
|
316
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: [
|
|
317
319
|
/* @__PURE__ */ e.jsxs(o, { flexDirection: "row", justifyContent: "space-between", borderBottom: !1, children: [
|
|
@@ -330,11 +332,11 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
330
332
|
] }),
|
|
331
333
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
332
334
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "模型 ::" }),
|
|
333
|
-
/* @__PURE__ */ e.jsx(r, { color: "white", children:
|
|
335
|
+
/* @__PURE__ */ e.jsx(r, { color: "white", children: i })
|
|
334
336
|
] }),
|
|
335
337
|
/* @__PURE__ */ e.jsxs(o, { children: [
|
|
336
338
|
/* @__PURE__ */ e.jsx(r, { color: "blue", children: "配置路径 ::" }),
|
|
337
|
-
/* @__PURE__ */ e.jsx(r, { color: "gray", children:
|
|
339
|
+
/* @__PURE__ */ e.jsx(r, { color: "gray", children: M })
|
|
338
340
|
] })
|
|
339
341
|
] }),
|
|
340
342
|
/* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
|
|
@@ -364,8 +366,8 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
364
366
|
isLoading: !1,
|
|
365
367
|
error: null
|
|
366
368
|
}, W = () => {
|
|
367
|
-
const [l,
|
|
368
|
-
|
|
369
|
+
const [l, i] = t.useState(z), [j, p] = t.useState([]), c = t.useCallback(() => {
|
|
370
|
+
i((n) => {
|
|
369
371
|
if (n.step === "model" && !n.selectedModel)
|
|
370
372
|
return { ...n, error: "请选择一个模型" };
|
|
371
373
|
if (n.step === "apiAndBaseUrl") {
|
|
@@ -376,30 +378,30 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
376
378
|
const s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
|
|
377
379
|
return h < s.length - 1 ? { ...n, step: s[h + 1], error: null } : n;
|
|
378
380
|
});
|
|
379
|
-
}, []), d =
|
|
380
|
-
|
|
381
|
+
}, []), d = t.useCallback(() => {
|
|
382
|
+
i((n) => {
|
|
381
383
|
const s = ["welcome", "provider", "apiAndBaseUrl", "model", "complete"], h = s.indexOf(n.step);
|
|
382
384
|
return h > 0 ? { ...n, step: s[h - 1], error: null } : n;
|
|
383
385
|
});
|
|
384
|
-
}, []), C =
|
|
385
|
-
process.env.MODEL_PROVIDER = n,
|
|
386
|
+
}, []), C = t.useCallback((n) => {
|
|
387
|
+
process.env.MODEL_PROVIDER = n, i((s) => ({
|
|
386
388
|
...s,
|
|
387
389
|
provider: n,
|
|
388
390
|
baseUrl: w[n],
|
|
389
391
|
apiKey: "",
|
|
390
392
|
selectedModel: ""
|
|
391
393
|
}));
|
|
392
|
-
}, []), I =
|
|
393
|
-
|
|
394
|
-
}, []), u =
|
|
395
|
-
|
|
396
|
-
}, []), m =
|
|
397
|
-
|
|
398
|
-
}, []), g =
|
|
399
|
-
|
|
400
|
-
}, []), b =
|
|
401
|
-
|
|
402
|
-
}, []), y =
|
|
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) => {
|
|
403
405
|
b(!0), g(null);
|
|
404
406
|
try {
|
|
405
407
|
const h = process.env.MODEL_PROVIDER, E = process.env.OPENAI_API_KEY, a = process.env.ANTHROPIC_API_KEY;
|
|
@@ -411,7 +413,7 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
411
413
|
} finally {
|
|
412
414
|
b(!1);
|
|
413
415
|
}
|
|
414
|
-
}, []), x =
|
|
416
|
+
}, []), x = t.useCallback(async () => {
|
|
415
417
|
if (!l.provider || !l.apiKey || !l.selectedModel)
|
|
416
418
|
return g("配置不完整"), !1;
|
|
417
419
|
b(!0), g(null);
|
|
@@ -426,10 +428,10 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
426
428
|
} finally {
|
|
427
429
|
b(!1);
|
|
428
430
|
}
|
|
429
|
-
}, [l]), f =
|
|
431
|
+
}, [l]), f = t.useCallback(() => {
|
|
430
432
|
process.exit(0);
|
|
431
433
|
}, []);
|
|
432
|
-
|
|
434
|
+
t.useEffect(() => {
|
|
433
435
|
l.step === "model" && l.provider && l.apiKey && y(l.provider, l.apiKey);
|
|
434
436
|
}, [l.step, l.provider, l.apiKey, y]), A((n, s) => {
|
|
435
437
|
s.ctrl && n === "c" ? process.exit(0) : s.escape && d();
|
|
@@ -490,6 +492,6 @@ const N = ({ onNext: l, onExit: t }) => {
|
|
|
490
492
|
return /* @__PURE__ */ e.jsx(o, { flexDirection: "column", height: "100%", width: "100%", children: D() });
|
|
491
493
|
};
|
|
492
494
|
async function $() {
|
|
493
|
-
await
|
|
495
|
+
await L(), U(/* @__PURE__ */ e.jsx(W, {}));
|
|
494
496
|
}
|
|
495
497
|
$();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { r as a, j as n, a as c, u as f, T as x } from "./use-input-CQELhJxU.mjs";
|
|
2
|
+
a(/* @__PURE__ */ n.jsx(l, {}));
|
|
3
|
+
function l() {
|
|
4
|
+
const [r, u] = c.useState(`Press any key...
|
|
5
|
+
`);
|
|
6
|
+
return f((i, o, p) => {
|
|
7
|
+
const t = ["\x1B[2J\x1B[H", "input:", JSON.stringify(i), "", "key:"], e = Object.entries(o).filter(([, s]) => s === !0);
|
|
8
|
+
for (const [s] of e)
|
|
9
|
+
t.push(` ${s}: true`);
|
|
10
|
+
e.length === 0 && t.push(" (no true values)"), t.push(JSON.stringify(p, null, 2)), u(t.join(`
|
|
11
|
+
`));
|
|
12
|
+
}), /* @__PURE__ */ n.jsx(x, { children: r });
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-code",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "cli.
|
|
6
|
-
"bin": "cli.
|
|
5
|
+
"main": "./dist/cli.mjs",
|
|
6
|
+
"bin": "./dist/cli.mjs",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"cli.js"
|
|
8
|
+
"dist"
|
|
10
9
|
],
|
|
11
10
|
"keywords": [],
|
|
12
11
|
"author": "KonghaYao",
|
|
@@ -30,6 +29,7 @@
|
|
|
30
29
|
"node-sqlite3-wasm": "^0.8.52",
|
|
31
30
|
"openai": "^6.15.0",
|
|
32
31
|
"path-exists": "^5.0.0",
|
|
32
|
+
"string-width": "^8.1.0",
|
|
33
33
|
"tempy": "^3.1.0",
|
|
34
34
|
"xdg-basedir": "^5.1.0",
|
|
35
35
|
"yaml": "^2.8.2",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"diff-match-patch": "^1.0.5",
|
|
51
51
|
"ink": "^6.6.0",
|
|
52
52
|
"ink-markdown": "^1.0.4",
|
|
53
|
-
"ink-select-input": "^6.2.0",
|
|
54
53
|
"ink-spinner": "^5.0.0",
|
|
55
54
|
"ink-syntax-highlight": "^2.0.2",
|
|
56
55
|
"ink-text-input": "^6.0.0",
|