mine-auto-cli 2.6.4 → 2.7.1

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/README.md CHANGED
@@ -20,6 +20,7 @@
20
20
  - [x] [生成依赖注释文件](#生成依赖注释文件)
21
21
  - [x] [更新 `.vscode` 文件](#更新-vscode-文件)
22
22
  - [x] [切换 Node 版本](#切换-node-版本)
23
+ - [x] [切换 AI 模型](#切换-ai-模型)
23
24
 
24
25
  ## 全局安装
25
26
 
@@ -53,7 +54,6 @@ auto init
53
54
  ```
54
55
 
55
56
  - 字段解析:
56
-
57
57
  - `prefix`: 版本前缀,默认为 `^`
58
58
  - `registry`: 依赖来源,默认为 `https://registry.npmmirror.com/`
59
59
  - `check`: 是否更新 `package.json` 文件,为 `true` 时等同于 `auto check -u`, `-u` 优先级最高, 默认为 `false`
@@ -204,6 +204,25 @@ auto node 20
204
204
  auto node 20.12.1
205
205
  ```
206
206
 
207
+ ### 切换 AI 模型
208
+
209
+ - 基于 claude code 切换 ai 模型
210
+ - 初始化、切换模型、查看模型
211
+
212
+ ```sh
213
+ # 初始化
214
+ auto ai init
215
+
216
+ # 查看已配置的模型
217
+ auto ai ls
218
+
219
+ # 切换模型
220
+ auto ai use deepseek
221
+
222
+ # 查看命令更多帮助信息
223
+ auto ai -h
224
+ ```
225
+
207
226
  ### 技术栈
208
227
 
209
228
  - `Vite` + `TypeScript` + `NodeJs`
package/dist/ai.jsonc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "你的模型": {
3
+ // 模型环境变量配置
4
+ "env": {
5
+ "ANTHROPIC_BASE_URL": "https://api.你的模型.com/anthropic", // 模型 API 基础 URL
6
+ "ANTHROPIC_AUTH_TOKEN": "你的 token", // 模型 API 认证 token
7
+ "API_TIMEOUT_MS": "600000", // API 请求超时时间,单位毫秒,默认为 10 分钟
8
+ "ANTHROPIC_MODEL": "你的模型名称", // 模型名称
9
+ "ANTHROPIC_SMALL_FAST_MODEL": "你的模型名称", // 小模型名称
10
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1" // 是否禁用非必要流量,默认为 `1`
11
+ }
12
+ }
13
+ }
package/dist/index.js CHANGED
@@ -1,297 +1,333 @@
1
- import { program as d } from "commander";
1
+ import { program as u } from "commander";
2
2
  import l from "chalk";
3
- import { readFileSync as y, writeFileSync as j, existsSync as w, readdirSync as ae, cpSync as le, rmSync as pe } from "fs";
4
- import { join as g, resolve as b } from "path";
5
- import K from "log-symbols";
6
- import me from "ora";
7
- import { execSync as N } from "child_process";
8
- import ue from "js-yaml";
9
- import de from "strip-json-comments";
10
- import ge from "pacote";
11
- import { parseRange as M } from "semver-utils";
12
- import fe from "download-git-repo";
13
- import F from "inquirer";
14
- import he from "update-notifier";
15
- const Q = "mine-auto-cli", W = "2.6.4", ye = "./dist/index.js", $e = "./dist/index.js", ve = "module", je = { auto: "bin/mine-auto-cli.js" }, we = { name: "biaov", email: "biaov@qq.com", url: "https://biaov.cn" }, be = "一个将多个命令简化成一个命令的工具 😆", Se = { start: "npm run dev", dev: "npm run build -- --watch", build: "vite build", prettier: "prettier --write '**/*.{js,ts,md,json}'", tag: "node scripts/tag" }, ke = { registry: "https://registry.npmjs.org/", "engine-strict": !0, provenance: !0 }, Ce = { node: ">=22.11" }, xe = ["auto", "cli", "vite", "typescript"], Oe = { type: "git", url: "git+https://github.com/biaov/mine-auto-cli.git" }, Ne = "https://github.com/biaov/mine-auto-cli.git", Je = { url: "https://github.com/biaov/mine-auto-cli/issues" }, Pe = "ISC", De = [{ name: "biaov", email: "biaov@qq.com" }], Ee = { chalk: "^5.6.2", commander: "^14.0.0", "download-git-repo": "^3.0.2", inquirer: "^12.9.4", "js-yaml": "^4.1.0", "log-symbols": "^7.0.1", ora: "^8.2.0", pacote: "^21.0.1", "semver-utils": "^1.1.4", "strip-json-comments": "^5.0.3", "update-notifier": "^7.3.1" }, Ve = { "@types/js-yaml": "^4.0.9", "@types/node": "^24.3.1", "@types/pacote": "^11.1.8", "@types/semver-utils": "^1.1.3", "@types/update-notifier": "^6.0.8", prettier: "^3.6.2", typescript: "^5.9.2", vite: "^7.1.5" }, O = {
16
- name: Q,
3
+ import { readFileSync as h, writeFileSync as v, existsSync as $, readdirSync as ve, cpSync as Se, rmSync as je } from "fs";
4
+ import { join as f, resolve as y } from "path";
5
+ import ne from "log-symbols";
6
+ import be from "ora";
7
+ import { execSync as P } from "child_process";
8
+ import we from "js-yaml";
9
+ import Ce from "strip-json-comments";
10
+ import Oe from "pacote";
11
+ import { parseRange as D } from "semver-utils";
12
+ import ke from "download-git-repo";
13
+ import q from "inquirer";
14
+ import oe from "os";
15
+ import Ae from "update-notifier";
16
+ const se = "mine-auto-cli", re = "2.7.0", xe = "./dist/index.js", Ne = "./dist/index.js", Ie = "module", Pe = { auto: "bin/mine-auto-cli.js" }, Ee = { name: "biaov", email: "biaov@qq.com", url: "https://biaov.cn" }, Je = "一个将多个命令简化成一个命令的工具 😆", Me = { start: "npm run dev", dev: "npm run build -- --watch", build: "vite build", prettier: "prettier --write '**/*.{js,ts,md,json}'", tag: "node scripts/tag" }, Le = { registry: "https://registry.npmjs.org/", "engine-strict": !0, provenance: !0 }, De = { node: ">=24.x" }, Te = ["auto", "cli", "vite", "typescript"], Ve = { type: "git", url: "git+https://github.com/biaov/mine-auto-cli.git" }, Re = "https://github.com/biaov/mine-auto-cli.git", _e = { url: "https://github.com/biaov/mine-auto-cli/issues" }, Fe = "ISC", Ue = [{ name: "biaov", email: "biaov@qq.com" }], qe = { chalk: "^5.6.2", commander: "^14.0.3", "download-git-repo": "^3.0.2", inquirer: "^13.3.0", "js-yaml": "^4.1.1", "log-symbols": "^7.0.1", ora: "^9.3.0", pacote: "^21.4.0", "semver-utils": "^1.1.4", "strip-json-comments": "^5.0.3", "update-notifier": "^7.3.1" }, He = { "@types/js-yaml": "^4.0.9", "@types/node": "^25.3.3", "@types/pacote": "^11.1.8", "@types/semver-utils": "^1.1.3", "@types/update-notifier": "^6.0.8", prettier: "^3.8.1", typescript: "^5.9.3", vite: "^7.3.1" }, N = {
17
+ name: se,
17
18
  private: !1,
18
- version: W,
19
- exports: ye,
20
- main: $e,
21
- type: ve,
22
- bin: je,
23
- author: we,
24
- description: be,
25
- scripts: Se,
26
- publishConfig: ke,
27
- engines: Ce,
28
- keywords: xe,
29
- repository: Oe,
30
- homepage: Ne,
31
- bugs: Je,
32
- license: Pe,
33
- contributors: De,
34
- dependencies: Ee,
35
- devDependencies: Ve
36
- }, f = (e) => {
37
- console.log(`${K.success} ${l.green("SUCCESS")} ${e}`);
38
- }, J = (e) => {
39
- console.log(`${Q} ${K.error} ${l.red("ERROR")} ${e}`);
19
+ version: re,
20
+ exports: xe,
21
+ main: Ne,
22
+ type: Ie,
23
+ bin: Pe,
24
+ author: Ee,
25
+ description: Je,
26
+ scripts: Me,
27
+ publishConfig: Le,
28
+ engines: De,
29
+ keywords: Te,
30
+ repository: Ve,
31
+ homepage: Re,
32
+ bugs: _e,
33
+ license: Fe,
34
+ contributors: Ue,
35
+ dependencies: qe,
36
+ devDependencies: He
37
+ }, g = (e) => {
38
+ console.log(`${ne.success} ${l.green("SUCCESS")} ${e}`);
39
+ }, C = (e) => {
40
+ console.log(`${se} ${ne.error} ${l.red("ERROR")} ${e}`);
40
41
  }, a = (e) => {
41
42
  console.log(e ?? "");
42
- }, X = (e) => {
43
+ }, ie = (e) => {
43
44
  a(`开始执行 ${l.cyanBright(e)} 命令`);
44
- const t = me({ text: "正在执行命令中...", color: "yellow" });
45
+ const t = be({ text: "正在执行命令中...", color: "yellow" });
45
46
  t.start();
46
- const o = N(e, { cwd: process.cwd() });
47
- a(o.toString()), t.succeed(`${l.green(e)} 命令执行成功`), a();
48
- }, Me = (e) => ["git add -A", `git commit -m ${e}`, "git push"], Ie = (e, t) => [`npm run ${e}`, "git add -A", `git commit -m ${t}`, "git push"], Le = async (e, t = "打包") => {
49
- a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ie(e, t).map(X), f("全部命令执行完成"), a();
50
- }, T = (e) => {
51
- a(), J(`\`${e}\` 命令错误,请检查你的命令`), a(), d.help();
52
- }, q = (e) => {
53
- const t = ["package.json", "README.md"].map((c) => {
54
- const r = g(process.cwd(), c), i = y(r).toString();
55
- return { path: r, content: i };
56
- }), [o, n] = t, s = JSON.parse(o.content);
47
+ const n = P(e, { cwd: process.cwd() });
48
+ a(n.toString()), t.succeed(`${l.green(e)} 命令执行成功`), a();
49
+ }, Be = (e) => ["git add -A", `git commit -m ${e}`, "git push"], Ge = (e, t) => [`npm run ${e}`, "git add -A", `git commit -m ${t}`, "git push"], Ye = async (e, t = "打包") => {
50
+ a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Ge(e, t).map(ie), g("全部命令执行完成"), a();
51
+ }, H = (e) => {
52
+ a(), C(`\`${e}\` 命令错误,请检查你的命令`), a(), u.help();
53
+ }, B = (e) => {
54
+ const t = ["package.json", "README.md"].map((r) => {
55
+ const i = f(process.cwd(), r), c = h(i).toString();
56
+ return { path: i, content: c };
57
+ }), [n, o] = t, s = JSON.parse(n.content);
57
58
  if (e)
58
59
  s.version = e;
59
60
  else {
60
- const c = s.version.split(".").reduce((r, i, m, p) => r + (m === p.length - 1 ? +i + 1 : `${i}.`), "");
61
- s.version = c;
61
+ const r = s.version.split(".").reduce((i, c, m, p) => i + (m === p.length - 1 ? +c + 1 : `${c}.`), "");
62
+ s.version = r;
62
63
  }
63
- j(o.path, JSON.stringify(s, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${s.version}-blue`), j(n.path, n.content);
64
- }, Ae = async (e) => {
64
+ v(n.path, JSON.stringify(s, null, 2)), o.content = o.content.replace(/version\-v.+\-blue/, () => `version-v${s.version}-blue`), v(o.path, o.content);
65
+ }, Ke = async (e) => {
65
66
  const t = e.split("version")[1];
66
- if (!t) return T(e);
67
- const o = JSON.parse(y(g(process.cwd(), "package.json")).toString());
67
+ if (!t) return H(e);
68
+ const n = JSON.parse(h(f(process.cwd(), "package.json")).toString());
68
69
  if (t === "++") {
69
- const s = o.version.split(".").reduce((c, r, i, m) => c + (i === m.length - 1 ? +r + 1 : `${r}.`), "");
70
- q(s), a(), f("命令执行完成");
70
+ const s = n.version.split(".").reduce((r, i, c, m) => r + (c === m.length - 1 ? +i + 1 : `${i}.`), "");
71
+ B(s), a(), g("命令执行完成");
71
72
  return;
72
73
  }
73
- const n = t.split("@")[1];
74
- n ? (q(n), a(), f("命令执行完成")) : T(e);
75
- }, Fe = (e, t) => {
76
- if (e.includes("build")) return Le(e, t);
77
- if (e.includes("version")) return Ae(e);
78
- J(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), d.help();
79
- }, v = "https://gitee.com/biaovorg/project-template.git", Te = {
80
- vue: v,
81
- react: v,
82
- "uni-app": v,
83
- electron: v,
84
- node: v,
85
- "node-simple": v
86
- }, qe = Object.keys(Te);
87
- qe.reduce((e, t, o) => e + (o ? ", " : "") + t, "");
88
- const h = (e = "jsonc") => `auto-cli.${e}`;
89
- b(import.meta.dirname, "./presetData.json");
90
- const Z = (e, t = !1) => {
91
- if (!w(e)) return t ? {} : "";
92
- const o = y(e).toString();
93
- return t ? JSON.parse(de(o)) : o;
94
- }, Re = (e) => {
95
- if (!w(e)) return {};
96
- const t = y(e).toString();
74
+ const o = t.split("@")[1];
75
+ o ? (B(o), a(), g("命令执行完成")) : H(e);
76
+ }, ze = (e, t) => {
77
+ if (e.includes("build")) return Ye(e, t);
78
+ if (e.includes("version")) return Ke(e);
79
+ C(l.hex("#f56c6c")(`\`auto ${e}${t ? ` ${t}` : ""}\` 命令不存在`)), u.help();
80
+ }, w = "https://gitee.com/biaovorg/project-template.git", Qe = {
81
+ vue: w,
82
+ react: w,
83
+ "uni-app": w,
84
+ electron: w,
85
+ node: w,
86
+ "node-simple": w
87
+ }, We = Object.keys(Qe);
88
+ We.reduce((e, t, n) => e + (n ? ", " : "") + t, "");
89
+ const j = (e = "jsonc") => `auto-cli.${e}`;
90
+ y(import.meta.dirname, "./presetData.json");
91
+ const R = (e, t = !1) => {
92
+ if (!$(e)) return t ? {} : "";
93
+ const n = h(e).toString();
94
+ return t ? JSON.parse(Ce(n)) : n;
95
+ }, Xe = (e) => {
96
+ if (!$(e)) return {};
97
+ const t = h(e).toString();
97
98
  try {
98
- return ue.load(t);
99
+ return we.load(t);
99
100
  } catch {
100
101
  return {};
101
102
  }
102
- }, ee = (e = !1) => Z(b(import.meta.dirname, h()), e), te = () => {
103
- const [e, t] = [h(), h("yml")].map((n) => b(process.cwd(), n)), o = ee(!0);
103
+ }, ce = (e = !1) => R(y(import.meta.dirname, j()), e), ae = () => {
104
+ const [e, t] = [j(), j("yml")].map((o) => y(process.cwd(), o)), n = ce(!0);
104
105
  try {
105
- Object.assign(o, Re(t), Z(e, !0));
106
+ Object.assign(n, Xe(t), R(e, !0));
106
107
  } catch {
107
108
  }
108
- return o;
109
- }, Ue = (e, t = !1) => {
110
- let o = ee(t);
111
- return t && (o = JSON.stringify(o, null, 2)), e.includes(".yml") ? o.trim().split(`
112
- `).slice(1, -1).reduce((n, s) => n + s.trim().replace(/[",]/g, "").replace("// ", "# ") + `
113
- `, "") : o;
114
- }, Ge = ({ yml: e, uncomment: t, force: o }) => {
109
+ return n;
110
+ }, Ze = (e, t = !1) => {
111
+ let n = ce(t);
112
+ return t && (n = JSON.stringify(n, null, 2)), e.includes(".yml") ? n.trim().split(`
113
+ `).slice(1, -1).reduce((o, s) => o + s.trim().replace(/[",]/g, "").replace("// ", "# ") + `
114
+ `, "") : n;
115
+ }, le = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), et = ({ yml: e, uncomment: t, force: n }) => {
115
116
  a();
116
- const n = h(e ? "yml" : "jsonc"), s = b(process.cwd(), n);
117
- if (w(s) && !o) {
118
- a(l.yellow(`${n} 文件已存在`)), a(), a(l.yellow(`文件目录 ${s}`));
117
+ const o = j(e ? "yml" : "jsonc"), s = y(process.cwd(), o);
118
+ if ($(s) && !n) {
119
+ a(l.yellow(`${o} 文件已存在`)), a(), a(l.yellow(`文件目录 ${s}`));
119
120
  return;
120
121
  }
121
- j(s, Ue(n, t)), f(`${n} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
122
+ v(s, Ze(o, t)), g(`${o} 文件创建成功`), a(), a(l.green(`文件目录 ${s}`));
122
123
  };
123
- d.command("init").option("-f, --force", `强制替换 ${h()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${h()} 带注释`, !1).option("-y, --yml", `生成 ${h("yml")} 文件`, !1).description("初始化配置文件").action(Ge);
124
- const _e = async (e = "更新代码") => {
125
- a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Me(e).forEach(X), f("全部命令执行完成"), a();
124
+ u.command("init").option("-f, --force", `强制替换 ${j()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${j()} 带注释`, !1).option("-y, --yml", `生成 ${j("yml")} 文件`, !1).description("初始化配置文件").action(et);
125
+ const tt = async (e = "更新代码") => {
126
+ a(), a(`${l.yellow(">>")} 开始依次执行命令...`), a(), Be(e).forEach(ie), g("全部命令执行完成"), a();
126
127
  };
127
- d.command("git [描述]").description("简化 Git 提交命令").action(_e);
128
- const R = ["dist", "node_modules", ".git", "miniprogram_npm"];
129
- let P = 0, ne = !1, I = !1, oe = 20;
130
- const U = ({ prev: e, i: t, index: o, arr: n, curText: s }) => {
131
- const c = Array.from({ length: t }).reduce((p) => p + `${t === 1 && o === n.length - 1 ? "└ " : "│ "} `, ""), r = e + c, i = (c + s).length, m = Array.from({ length: oe + P - i }).reduce((p) => `${p}-`, " ");
132
- return !ne && (P = Math.max(P, i)), `${r}${s}${I ? m : ""}
128
+ u.command("git [描述]").description("简化 Git 提交命令").action(tt);
129
+ const G = ["dist", "node_modules", ".git", "miniprogram_npm"];
130
+ let E = 0, pe = !1, T = !1, me = 20;
131
+ const Y = ({ prev: e, i: t, index: n, arr: o, curText: s }) => {
132
+ const r = Array.from({ length: t }).reduce((p) => p + `${t === 1 && n === o.length - 1 ? "└ " : "│ "} `, ""), i = e + r, c = (r + s).length, m = Array.from({ length: me + E - c }).reduce((p) => `${p}-`, " ");
133
+ return !pe && (E = Math.max(E, c)), `${i}${s}${T ? m : ""}
133
134
  `;
134
- }, L = (e, t = 0) => e.reduce((o, n, s, c) => {
135
- let r;
136
- return n.children ? (r = `├── ${n.name}`, U({ prev: o, i: t, index: s, arr: c, curText: r }) + L(n.children, t + 1)) : (r = `${s === c.length - 1 ? "└── " : "├── "}${n.name}`, U({ prev: o, i: t, index: s, arr: c, curText: r }));
137
- }, ""), G = (e) => ae(e, { withFileTypes: !0 }).sort((t, o) => +o.isDirectory() - +t.isDirectory()), Be = ({ line: e, name: t }) => {
138
- I = !!e, typeof e == "string" && (oe = +e);
139
- const o = process.cwd(), n = g(o, ".gitignore");
140
- if (w(n)) {
141
- const m = y(n).toString().split(`\r
135
+ }, V = (e, t = 0) => e.reduce((n, o, s, r) => {
136
+ let i;
137
+ return o.children ? (i = `├── ${o.name}`, Y({ prev: n, i: t, index: s, arr: r, curText: i }) + V(o.children, t + 1)) : (i = `${s === r.length - 1 ? "└── " : "├── "}${o.name}`, Y({ prev: n, i: t, index: s, arr: r, curText: i }));
138
+ }, ""), K = (e) => ve(e, { withFileTypes: !0 }).sort((t, n) => +n.isDirectory() - +t.isDirectory()), nt = ({ line: e, name: t }) => {
139
+ T = !!e, typeof e == "string" && (me = +e);
140
+ const n = process.cwd(), o = f(n, ".gitignore");
141
+ if ($(o)) {
142
+ const m = h(o).toString().split(`\r
142
143
  `);
143
- R.push(...m);
144
+ G.push(...m);
144
145
  }
145
- const s = o.split("\\").at(-1), r = G(o).map((m) => {
146
- const { name: p } = m, u = { name: p };
147
- return !R.includes(p) && m.isDirectory() && (u.children = G(g(m.path, p)).map(({ name: S }) => ({ name: S }))), u;
148
- }), i = [{ name: s, children: r }];
149
- I && (L(i), ne = !0), j(g(o, `${typeof t == "string" && t || "directory"}.md`), L(i));
146
+ const s = n.split("\\").at(-1), i = K(n).map((m) => {
147
+ const { name: p } = m, d = { name: p };
148
+ return !G.includes(p) && m.isDirectory() && (d.children = K(f(m.path, p)).map(({ name: O }) => ({ name: O }))), d;
149
+ }), c = [{ name: s, children: i }];
150
+ T && (V(c), pe = !0), v(f(n, `${typeof t == "string" && t || "directory"}.md`), V(c));
150
151
  };
151
- d.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(Be);
152
- const k = te(), [D] = ["package.json"].map((e) => b(process.cwd(), e)), Ye = (e, t) => {
153
- const o = Array.from({ length: t }, (r, i) => i < e ? "=" : " ").join(""), n = ~~(e / t * 100), s = `\r查找进度:[${o}] ${e}/${t} ${n}%\r`, c = e === t ? l.green(s) : l.yellow(s);
154
- process.stdout.write(c);
155
- }, ze = (e, t, o) => {
156
- let n = "latest";
157
- k.resolve.some((c) => {
158
- const r = c.lastIndexOf("@");
159
- if (r <= 0) return !0;
160
- const i = c.slice(0, r), m = c.slice(r + 1);
161
- if (e === i)
162
- return n = m, !0;
152
+ u.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(nt);
153
+ const k = ae(), [J] = ["package.json"].map((e) => y(process.cwd(), e)), ot = (e, t) => {
154
+ const n = Array.from({ length: t }, (i, c) => c < e ? "=" : " ").join(""), o = ~~(e / t * 100), s = `\r查找进度:[${n}] ${e}/${t} ${o}%\r`, r = e === t ? l.green(s) : l.yellow(s);
155
+ process.stdout.write(r);
156
+ }, st = (e, t, n) => {
157
+ let o = "latest";
158
+ k.resolve.some((r) => {
159
+ const i = r.lastIndexOf("@");
160
+ if (i <= 0) return !0;
161
+ const c = r.slice(0, i), m = r.slice(i + 1);
162
+ if (e === c)
163
+ return o = m, !0;
163
164
  });
164
- const s = k.prefix + o[n];
165
- return { name: e, value: t, newVersion: s, tag: n };
166
- }, He = (e, t) => Array.from({ length: t - e }, () => " ").join(""), Ke = (e, t) => (+!t + 1) * e.length, _ = (e) => {
167
- const [{ major: t = 0, minor: o = 0, patch: n = 0, release: s = "" }] = M(e);
168
- return [+t, +o, +n, s];
169
- }, E = (e, t) => e ? "-" + l[t](e) : "", Qe = (e, t) => {
170
- const [o, n, s, c] = _(e), [r, i, m, p] = _(t);
171
- return r > o ? l.red(t) : r < o ? !1 : i > n ? `${r}.${l.yellow(i)}.${l.yellow(m)}${E(p, "yellow")}` : i < n ? !1 : m > s ? `${r}.${i}.${l.green(m)}${E(p, "green")}` : m === s && p && p !== c ? `${r}.${i}.${m}${E(p, "green")}` : !1;
172
- }, We = (e) => {
165
+ const s = k.prefix + n[o];
166
+ return { name: e, value: t, newVersion: s, tag: o };
167
+ }, rt = (e, t) => (+!t + 1) * e.length, z = (e) => {
168
+ const [{ major: t = 0, minor: n = 0, patch: o = 0, release: s = "" }] = D(e);
169
+ return [+t, +n, +o, s];
170
+ }, M = (e, t) => e ? "-" + l[t](e) : "", it = (e, t) => {
171
+ const [n, o, s, r] = z(e), [i, c, m, p] = z(t);
172
+ return i > n ? l.red(t) : i < n ? !1 : c > o ? `${i}.${l.yellow(c)}.${l.yellow(m)}${M(p, "yellow")}` : c < o ? !1 : m > s ? `${i}.${c}.${l.green(m)}${M(p, "green")}` : m === s && p && p !== r ? `${i}.${c}.${m}${M(p, "green")}` : !1;
173
+ }, ct = (e) => {
173
174
  const t = {};
174
- e.forEach((n) => {
175
- Object.entries(n).forEach(([s, c]) => {
176
- t[s] = Math.max(c.length, t[s] ?? 0);
175
+ e.forEach((o) => {
176
+ Object.entries(o).forEach(([s, r]) => {
177
+ t[s] = Math.max(r.length, t[s] ?? 0);
177
178
  });
178
179
  }), e.unshift({ name: "包名", value: "版本", newVersion: "新版本", tag: "标签" });
179
- const o = [];
180
- e.forEach(({ name: n, value: s, newVersion: c, tag: r }, i) => {
181
- const [m, p, u, S] = Object.entries({ name: n, value: s, newVersion: c, tag: r }).map(([C, ie]) => He(Ke(ie, i), t[C]));
182
- let $ = l.yellow("→"), A = !0;
183
- if (i) {
184
- const C = Qe(s, c);
185
- C ? c = C : A = !1;
180
+ const n = [];
181
+ e.forEach(({ name: o, value: s, newVersion: r, tag: i }, c) => {
182
+ const [m, p, d, O] = Object.entries({ name: o, value: s, newVersion: r, tag: i }).map(([A, ye]) => le(rt(ye, c), t[A]));
183
+ let b = l.yellow("→"), U = !0;
184
+ if (c) {
185
+ const A = it(s, r);
186
+ A ? r = A : U = !1;
186
187
  } else
187
- n = l.green(n), s = l.green(s), c = l.green(c), r = l.green(r), $ = " ";
188
- const ce = `${n + m} ${p + s} ${$} ${u + c} ${S + r}`;
189
- A && o.push(ce);
190
- }), o.length > 1 ? o.forEach(a) : f("所有版本已是最新");
191
- }, Xe = async (e, t, o) => {
188
+ o = l.green(o), s = l.green(s), r = l.green(r), i = l.green(i), b = " ";
189
+ const $e = `${o + m} ${p + s} ${b} ${d + r} ${O + i}`;
190
+ U && n.push($e);
191
+ }), n.length > 1 ? n.forEach(a) : g("所有版本已是最新");
192
+ }, at = async (e, t, n) => {
192
193
  a();
193
- let n = 0;
194
- const s = [], c = Object.entries(e), r = c.map(async ([i, m]) => {
195
- const p = await ge.packument(i, { registry: k.registry }), u = ze(i, m, p["dist-tags"]);
196
- s.push(u), t.forEach((S) => {
197
- const $ = o[S];
198
- $ && $[i] && ($[i] = u.newVersion);
199
- }), n++, await Ye(n, c.length);
194
+ let o = 0;
195
+ const s = [], r = Object.entries(e), i = r.map(async ([c, m]) => {
196
+ const p = await Oe.packument(c, { registry: k.registry }), d = st(c, m, p["dist-tags"]);
197
+ s.push(d), t.forEach((O) => {
198
+ const b = n[O];
199
+ b && b[c] && (b[c] = d.newVersion);
200
+ }), o++, await ot(o, r.length);
200
201
  });
201
- return await Promise.all(r), a(), a(), s;
202
- }, Ze = async ({ update: e }) => {
203
- if (!w(D)) return J("package.json 文件不存在");
204
- const t = e || k.check, o = y(D).toString(), n = JSON.parse(o), s = ["dependencies", "devDependencies", "optionalDependencies"], c = {}, r = JSON.parse(o);
202
+ return await Promise.all(i), a(), a(), s;
203
+ }, lt = async ({ update: e }) => {
204
+ if (!$(J)) return C("package.json 文件不存在");
205
+ const t = e || k.check, n = h(J).toString(), o = JSON.parse(n), s = ["dependencies", "devDependencies", "optionalDependencies"], r = {}, i = JSON.parse(n);
205
206
  s.forEach((m) => {
206
- n[m] && Object.entries(n[m]).forEach(([p, u]) => {
207
- !k.reject.includes(p) && (c[p] = u);
207
+ o[m] && Object.entries(o[m]).forEach(([p, d]) => {
208
+ !k.reject.includes(p) && (r[p] = d);
208
209
  });
209
210
  });
210
- const i = await Xe(c, s, r);
211
- t ? (j(D, JSON.stringify(r, null, 2)), f("文件 package.json 已更新"), a()) : We(i);
211
+ const c = await at(r, s, i);
212
+ t ? (v(J, JSON.stringify(i, null, 2)), g("文件 package.json 已更新"), a()) : ct(c);
212
213
  };
213
- d.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(Ze);
214
- const et = te(), se = "comment.md", tt = ["package.json", se], [B, Y] = tt.map((e) => b(process.cwd(), e)), nt = () => {
215
- if (!w(B)) return J("package.json 文件不存在");
216
- const e = y(B).toString(), t = JSON.parse(e), o = ["dependencies", "devDependencies", "optionalDependencies"];
217
- let n = `### 依赖解析
214
+ u.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(lt);
215
+ const pt = ae(), de = "comment.md", mt = ["package.json", de], [Q, W] = mt.map((e) => y(process.cwd(), e)), dt = () => {
216
+ if (!$(Q)) return C("package.json 文件不存在");
217
+ const e = h(Q).toString(), t = JSON.parse(e), n = ["dependencies", "devDependencies", "optionalDependencies"];
218
+ let o = `### 依赖解析
218
219
 
219
220
  `;
220
- o.forEach((s) => {
221
- t[s] && (n += `#### ${s}
221
+ n.forEach((s) => {
222
+ t[s] && (o += `#### ${s}
222
223
 
223
- `, Object.keys(t[s]).forEach((c) => {
224
- n += `- \`${c}\`: ${et.comment[c] || ""}
224
+ `, Object.keys(t[s]).forEach((r) => {
225
+ o += `- \`${r}\`: ${pt.comment[r] || ""}
225
226
  `;
226
- }), n += `
227
+ }), o += `
227
228
  `);
228
- }), n = n.slice(0, -1), j(Y, n), a(), f(`${se} 文件创建成功`), a(), a(l.green(`文件目录 ${Y}`));
229
+ }), o = o.slice(0, -1), v(W, o), a(), g(`${de} 文件创建成功`), a(), a(l.green(`文件目录 ${W}`));
229
230
  };
230
- d.command("comment").description("生成依赖注释文件").action(nt);
231
- const z = { recursive: !0, force: !0 }, ot = () => {
232
- const e = `${+/* @__PURE__ */ new Date()}`, t = g(process.cwd()), o = g(t, e);
233
- fe("direct:https://gitee.com/biaovorg/vscode-config.git#master", o, { clone: !0 }, async (n) => {
234
- !n && le(g(o, ".vscode"), g(t, ".vscode"), z), pe(o, z);
231
+ u.command("comment").description("生成依赖注释文件").action(dt);
232
+ const X = { recursive: !0, force: !0 }, ut = () => {
233
+ const e = `${+/* @__PURE__ */ new Date()}`, t = f(process.cwd()), n = f(t, e);
234
+ ke("direct:https://gitee.com/biaovorg/vscode-config.git#master", n, { clone: !0 }, async (o) => {
235
+ !o && Se(f(n, ".vscode"), f(t, ".vscode"), X), je(n, X);
235
236
  });
236
237
  };
237
- d.command("vscode-config").description("更新 .vscode 配置文件").action(ot);
238
- const re = (e, t, o) => {
239
- const n = Object.entries(t), s = n.findIndex(([i]) => e === i), [c, r] = n[s];
240
- if (r) {
241
- if (o[c] === r) return s === n.length - 1 ? !0 : re(n[s + 1][0], t, o);
238
+ u.command("vscode-config").description("更新 .vscode 配置文件").action(ut);
239
+ const ue = (e, t, n) => {
240
+ const o = Object.entries(t), s = o.findIndex(([c]) => e === c), [r, i] = o[s];
241
+ if (i) {
242
+ if (n[r] === i) return s === o.length - 1 ? !0 : ue(o[s + 1][0], t, n);
242
243
  } else
243
244
  return !0;
244
- }, H = (e) => {
245
- e && (N(`nvm use ${e}`), a(), f(`切换成功 当前版本:${e}`), a());
246
- }, V = (e) => {
247
- e && N(`nvm install ${e}`);
248
- }, st = (e, t) => {
249
- const o = N("nvm ls").toString(), n = M(o), [{ major: s, minor: c, patch: r }] = M(e), i = [], m = n.find((p) => {
245
+ }, Z = (e) => {
246
+ e && (P(`nvm use ${e}`), a(), g(`切换成功 当前版本:${e}`), a());
247
+ }, L = (e) => {
248
+ e && P(`nvm install ${e}`);
249
+ }, gt = (e, t) => {
250
+ const n = P("nvm ls").toString(), o = D(n), [{ major: s, minor: r, patch: i }] = D(e), c = [], m = o.find((p) => {
250
251
  if (p.major === s)
251
- return i.push(p), re("minor", { minor: c, patch: r }, p);
252
+ return c.push(p), ue("minor", { minor: r, patch: i }, p);
252
253
  });
253
254
  if (m)
254
- H(m.semver);
255
- else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(), i.length) {
256
- const p = i.map((u) => u.semver);
257
- F.prompt({
255
+ Z(m.semver);
256
+ else if (a(), a(l.red(`输入的版本 ${e} 不存在`)), a(), c.length) {
257
+ const p = c.map((d) => d.semver);
258
+ q.prompt({
258
259
  type: "list",
259
260
  name: "preset",
260
261
  message: "请选择相似版本或输入版本进行安装:",
261
262
  choices: [...p, e, "取消"]
262
- }).then(({ preset: u }) => {
263
- if (u !== "取消")
264
- if (u === e) {
265
- if (!r) return;
266
- V(u);
263
+ }).then(({ preset: d }) => {
264
+ if (d !== "取消")
265
+ if (d === e) {
266
+ if (!i) return;
267
+ L(d);
267
268
  } else
268
- H(u);
269
+ Z(d);
269
270
  });
270
271
  } else {
271
- if (!r) return;
272
+ if (!i) return;
272
273
  if (t.install) {
273
- V(e);
274
+ L(e);
274
275
  return;
275
276
  }
276
- F.prompt({
277
+ q.prompt({
277
278
  type: "confirm",
278
279
  name: "isInstall",
279
280
  message: `是否安装 ${e}?`
280
281
  }).then(({ isInstall: p }) => {
281
- p && V(e);
282
+ p && L(e);
282
283
  });
283
284
  }
284
285
  };
285
- d.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(st);
286
- d.usage("[commands] [options]").version(W, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令");
287
- d.command("build[:环境] [描述]").description("简化打包提交命令");
288
- d.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
289
- d.arguments("<cmd> [env]").action((e, t) => {
290
- Fe(e, t);
286
+ u.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action(gt);
287
+ const _ = ["ANTHROPIC_AUTH_TOKEN", "ANTHROPIC_BASE_URL", "ANTHROPIC_MODEL", "ANTHROPIC_SMALL_FAST_MODEL"], ge = R(y(import.meta.dirname, "ai.jsonc"), !0), ee = Object.entries(ge)[0], I = y(oe.homedir(), ".claude/settings.json"), S = y(oe.homedir(), ".ai-model.json"), fe = () => {
288
+ $(I) || (C(`${I} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
289
+ const e = JSON.parse(h(I).toString());
290
+ return !e.env && (e.env = {}), e;
291
+ }, he = () => {
292
+ a(), $(S) || (C("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
293
+ const e = JSON.parse(h(S).toString()), t = Object.entries(e).filter(([n, o]) => {
294
+ if (n === ee[0]) return !1;
295
+ const s = o.env, r = ee[1].env;
296
+ return !(!s || _.some((c) => !s[c] || s[c] === r[c]));
297
+ });
298
+ return t.length || (a(`暂无已配置的 AI 模型,请先配置,路径 ${l.green(S)}`), process.exit(1)), [t, e];
299
+ }, ft = () => {
300
+ if (a(), $(S)) {
301
+ a(`配置已存在,路径 ${l.green(S)}`);
302
+ return;
303
+ }
304
+ v(S, JSON.stringify(ge, null, 2)), g(`配置已初始化,路径 ${l.green(S)}`);
305
+ }, te = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, ht = () => {
306
+ const [e] = he();
307
+ let t = 0, n = -1;
308
+ const o = fe();
309
+ e.forEach(([s, r], i) => {
310
+ t = Math.max(t, te(s)), n < 0 && !_.some((c) => o.env[c] !== r.env[c]) && (n = i);
311
+ }), e.forEach(([s, r], i) => {
312
+ const { ANTHROPIC_BASE_URL: c } = r.env, m = i === n ? l.green("*") : " ", p = le(te(s), t + 4, "-"), d = `${m} ${s} ${p} ${c}`;
313
+ a(d);
314
+ });
315
+ }, $t = async (e) => {
316
+ const t = fe(), [n, o] = he();
317
+ n.some(([s]) => s === e) || (a(`模型 ${l.red(e)} 不存在`), process.exit(1)), _.some((s) => t.env[s] !== o[e].env[s]) ? (t.env = o[e].env, v(I, JSON.stringify(t, null, 2)), g(`模型 ${l.green(e)} 已切换`)) : a(`当前正处于 ${l.green(e)} 模型,无需切换`);
318
+ }, F = u.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
319
+ F.command("init").description("初始化 AI 模型配置").action(ft);
320
+ F.command("ls").description("查看当前已配置的 AI 模型").action(ht);
321
+ F.command("use <模型>").description("切换 AI 模型").action($t);
322
+ u.usage("[commands] [options]").version(re, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令");
323
+ u.command("build[:环境] [描述]").description("简化打包提交命令");
324
+ u.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
325
+ u.arguments("<cmd> [env]").action((e, t) => {
326
+ ze(e, t);
291
327
  });
292
- process.argv.length < 3 ? d.help() : d.parse(process.argv);
293
- const x = he({ pkg: O, updateCheckInterval: 1e3 * 1 });
294
- if (x.update && x.update.latest !== O.version) {
328
+ process.argv.length < 3 ? u.help() : u.parse(process.argv);
329
+ const x = Ae({ pkg: N, updateCheckInterval: 1e3 * 1 });
330
+ if (x.update && x.update.latest !== N.version) {
295
331
  let e = "";
296
332
  switch (x.update.type) {
297
333
  case "major":
@@ -304,7 +340,7 @@ if (x.update && x.update.latest !== O.version) {
304
340
  e = l.green("{latestVersion}");
305
341
  break;
306
342
  }
307
- const t = `https://github.com/biaov/${O.name}/compare/v${O.version}...v{latestVersion}`;
343
+ const t = `https://github.com/biaov/${N.name}/compare/v${N.version}...v{latestVersion}`;
308
344
  x.notify({
309
345
  defer: !1,
310
346
  isGlobal: !0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mine-auto-cli",
3
3
  "private": false,
4
- "version": "2.6.4",
4
+ "version": "2.7.1",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",
@@ -18,10 +18,10 @@
18
18
  "publishConfig": {
19
19
  "registry": "https://registry.npmjs.org/",
20
20
  "engine-strict": true,
21
- "provenance": true
21
+ "provenance": false
22
22
  },
23
23
  "engines": {
24
- "node": ">=22.11"
24
+ "node": ">=24.x"
25
25
  },
26
26
  "keywords": [
27
27
  "auto",
@@ -46,13 +46,13 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "chalk": "^5.6.2",
49
- "commander": "^14.0.0",
49
+ "commander": "^14.0.3",
50
50
  "download-git-repo": "^3.0.2",
51
- "inquirer": "^12.9.4",
52
- "js-yaml": "^4.1.0",
51
+ "inquirer": "^13.3.0",
52
+ "js-yaml": "^4.1.1",
53
53
  "log-symbols": "^7.0.1",
54
- "ora": "^8.2.0",
55
- "pacote": "^21.0.1",
54
+ "ora": "^9.3.0",
55
+ "pacote": "^21.4.0",
56
56
  "semver-utils": "^1.1.4",
57
57
  "strip-json-comments": "^5.0.3",
58
58
  "update-notifier": "^7.3.1"