zen-code 2.1.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.
@@ -1,4 +1,4 @@
1
- import { r as P, u as d, p as _ } from "./app-CdJSgzzZ.mjs";
1
+ import { r as P, u as d, p as _ } from "./graph-DDkv1rqg.mjs";
2
2
  var v, m, g = 0, O = 0;
3
3
  function h(r, e, n) {
4
4
  var f = 0, t = e || new Array(16);
@@ -0,0 +1,22 @@
1
+ import { Low as e } from "lowdb";
2
+ import { JSONFile as t } from "lowdb/node";
3
+ import c from "node:os";
4
+ import r from "node:path";
5
+ const o = {
6
+ config: {
7
+ main_model: "claude-sonnet-4-5",
8
+ model_provider: "openai"
9
+ }
10
+ }, s = c.homedir(), d = r.join(s, ".code-graph.json"), _ = new t(d), a = new e(_, o), l = async () => {
11
+ await a.read(), (!a.data || !a.data.config) && (a.data = o, await a.write()), i();
12
+ }, u = () => a.data.config, i = () => {
13
+ a.data.config.model_provider && (process.env.MODEL_PROVIDER = a.data.config.model_provider), a.data.config.openai_api_key && (process.env.OPENAI_API_KEY = a.data.config.openai_api_key), a.data.config.openai_base_url && (process.env.OPENAI_BASE_URL = a.data.config.openai_base_url), a.data.config.anthropic_api_key && (process.env.ANTHROPIC_API_KEY = a.data.config.anthropic_api_key), a.data.config.anthropic_base_url && (process.env.ANTHROPIC_BASE_URL = a.data.config.anthropic_base_url);
14
+ }, v = async (n) => {
15
+ Object.assign(a.data.config, n), await a.write(), i();
16
+ };
17
+ export {
18
+ d,
19
+ u as g,
20
+ l as i,
21
+ v as u
22
+ };
@@ -1,5 +1,6 @@
1
- import { u as C } from "./id-Bh5iJfyi.mjs";
2
- import { B as v, c as x, T as $, m as I } from "./app-CdJSgzzZ.mjs";
1
+ import { u as C } from "./id-CzaxLw8O.mjs";
2
+ import { B as v, c as x, T as $, m as I } from "./app-DSomQ6O6.mjs";
3
+ import "./graph-DDkv1rqg.mjs";
3
4
  import { createClient as O, createCluster as N } from "redis";
4
5
  const W = [
5
6
  {
@@ -105,7 +106,7 @@ const W = [
105
106
  }
106
107
  }
107
108
  ];
108
- var E = class m extends v {
109
+ var L = class m extends v {
109
110
  client;
110
111
  ttlConfig;
111
112
  constructor(e, t) {
@@ -459,5 +460,5 @@ function g(w) {
459
460
  });
460
461
  }
461
462
  export {
462
- E as RedisSaver
463
+ L as RedisSaver
463
464
  };
@@ -0,0 +1,45 @@
1
+ import { HumanMessage as c } from "langchain";
2
+ import { g as l } from "./graph-DDkv1rqg.mjs";
3
+ import { i as m, g } from "./index-B5v_6qaq.mjs";
4
+ async function d() {
5
+ return new Promise((r, t) => {
6
+ let o = "";
7
+ process.stdin.setEncoding("utf8"), process.stdin.on("data", (n) => {
8
+ o += n;
9
+ }), process.stdin.on("end", () => {
10
+ r(o);
11
+ }), process.stdin.on("error", (n) => {
12
+ t(n);
13
+ });
14
+ });
15
+ }
16
+ async function u(r, t = !1) {
17
+ await m();
18
+ const o = g();
19
+ let n = r || "";
20
+ if (t)
21
+ try {
22
+ n = (await d()).trim();
23
+ } catch (e) {
24
+ throw console.error("❌ 读取 stdin 失败:", e), e;
25
+ }
26
+ n || (console.error("❌ 错误: 未提供输入内容"), console.error(`
27
+ 用法:`), console.error(' zen-code -p "你的任务描述"'), console.error(' echo "内容" | zen-code'), process.exit(1));
28
+ try {
29
+ const e = {
30
+ messages: [new c(n)],
31
+ main_model: o.main_model,
32
+ enable_thinking: o.enable_thinking
33
+ }, s = await l.invoke(e, {
34
+ recursionLimit: 200
35
+ }), i = s.messages || [], a = i[i.length - 1];
36
+ return a && console.log(a.text), s;
37
+ } catch (e) {
38
+ throw console.error(`
39
+ ❌ 执行失败: ${e instanceof Error ? e.message : String(e)}
40
+ `), e;
41
+ }
42
+ }
43
+ export {
44
+ u as runNonInteractive
45
+ };
@@ -1,4 +1,4 @@
1
- import { a as u, C as h } from "./app-CdJSgzzZ.mjs";
1
+ import { a as u, C as h } from "./app-DSomQ6O6.mjs";
2
2
  import { createClient as n } from "redis";
3
3
  class r extends u {
4
4
  constructor(s, e = !0, i = 300) {
@@ -1,5 +1,6 @@
1
- import { u as $ } from "./id-Bh5iJfyi.mjs";
2
- import { B as g } from "./app-CdJSgzzZ.mjs";
1
+ import { u as $ } from "./id-CzaxLw8O.mjs";
2
+ import { B as g } from "./app-DSomQ6O6.mjs";
3
+ import "./graph-DDkv1rqg.mjs";
3
4
  import { createClient as T } from "redis";
4
5
  function k(u) {
5
6
  if (u === null || typeof u != "object") return JSON.stringify(u);
@@ -86,7 +87,7 @@ const S = [{
86
87
  }
87
88
  }
88
89
  }];
89
- var C = class w extends g {
90
+ var O = class w extends g {
90
91
  client;
91
92
  ttlConfig;
92
93
  constructor(t, e) {
@@ -327,5 +328,5 @@ var C = class w extends g {
327
328
  }
328
329
  };
329
330
  export {
330
- C as ShallowRedisSaver
331
+ O as ShallowRedisSaver
331
332
  };
package/dist/zen-code.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./use-input-CQELhJxU.mjs";
2
2
  import "chalk";
3
- import "./app-CdJSgzzZ.mjs";
3
+ import "./app-DSomQ6O6.mjs";
package/dist/zen-init.mjs CHANGED
@@ -1,6 +1,7 @@
1
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
- import { u as A, S as O, M as T, a as B, b as R, d as K, g as M, c as v, i as L } from "./MultiSelect-C_hSPGpl.mjs";
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";
4
5
  const N = ({ onNext: l, onExit: i }) => {
5
6
  A((c, d) => {
6
7
  d.return ? l() : d.ctrl && c === "c" && i();
@@ -335,7 +336,7 @@ const N = ({ onNext: l, onExit: i }) => {
335
336
  ] }),
336
337
  /* @__PURE__ */ e.jsxs(o, { children: [
337
338
  /* @__PURE__ */ e.jsx(r, { color: "blue", children: "配置路径 ::" }),
338
- /* @__PURE__ */ e.jsx(r, { color: "gray", children: K })
339
+ /* @__PURE__ */ e.jsx(r, { color: "gray", children: M })
339
340
  ] })
340
341
  ] }),
341
342
  /* @__PURE__ */ e.jsxs(o, { marginBottom: 1, flexDirection: "column", gap: 0, children: [
@@ -405,7 +406,7 @@ const N = ({ onNext: l, onExit: i }) => {
405
406
  try {
406
407
  const h = process.env.MODEL_PROVIDER, E = process.env.OPENAI_API_KEY, a = process.env.ANTHROPIC_API_KEY;
407
408
  process.env.MODEL_PROVIDER = n, n === "openai" ? process.env.OPENAI_API_KEY = s || "temp" : process.env.ANTHROPIC_API_KEY = s || "temp";
408
- const _ = (await M()).filter((P) => P.provider === n);
409
+ const _ = (await K()).filter((P) => P.provider === n);
409
410
  p(_), h && (process.env.MODEL_PROVIDER = h), E && (process.env.OPENAI_API_KEY = E), a && (process.env.ANTHROPIC_API_KEY = a);
410
411
  } catch (h) {
411
412
  g(`加载模型失败: ${h instanceof Error ? h.message : String(h)}`), p([]);
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "zen-code",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
- "main": "cli.js",
6
- "bin": "cli.js",
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",
@@ -51,7 +50,6 @@
51
50
  "diff-match-patch": "^1.0.5",
52
51
  "ink": "^6.6.0",
53
52
  "ink-markdown": "^1.0.4",
54
- "ink-select-input": "^6.2.0",
55
53
  "ink-spinner": "^5.0.0",
56
54
  "ink-syntax-highlight": "^2.0.2",
57
55
  "ink-text-input": "^6.0.0",
package/cli.js DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- const args = process.argv.slice(2);
3
-
4
- if (args[0] === 'init') {
5
- import('./dist/zen-init.mjs');
6
- } else if (args[0] === 'keyboard') {
7
- import('./dist/zen-keyboard.mjs');
8
- } else {
9
- import('./dist/zen-code.mjs');
10
- }