mine-auto-cli 2.8.2 → 2.9.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/README.md CHANGED
@@ -22,6 +22,7 @@
22
22
  - [x] [切换 Node 版本](#切换-node-版本)
23
23
  - [x] [切换 AI 模型](#切换-ai-模型)
24
24
  - [x] [汉化 Claude Code](#汉化-claude-code)
25
+ - [x] [压缩图片](#压缩图片)
25
26
 
26
27
  ## 全局安装
27
28
 
@@ -225,6 +226,9 @@ auto ai -h
225
226
 
226
227
  # 设置 Claude Code 权限
227
228
  auto ai config
229
+
230
+ # 查看 Claude Code 配置信息
231
+ auto ai config-ls
228
232
  ```
229
233
 
230
234
  ### 汉化 Claude Code
@@ -237,6 +241,27 @@ auto ai zh
237
241
  auto ai zh-restore
238
242
  ```
239
243
 
244
+ ### 压缩图片
245
+
246
+ - 基于 `sharp` 压缩图片,默认采用 TinyPNG 风格的智能有损压缩(PNG 调色板量化、JPEG 优化量化表)
247
+ - 递归处理子目录并保持原目录结构,默认输出到图片目录下的 `mini` 子目录
248
+ - 压缩后体积未减小的图片会原样输出;GIF / SVG 等不支持的文件会跳过
249
+ - 需要画质完全不变时添加 `--lossless` 切换为无损压缩(体积会明显更大)
250
+
251
+ ```sh
252
+ # 压缩 images 目录,输出到 images/mini
253
+ auto mini ./images
254
+
255
+ # 指定输出目录
256
+ auto mini ./images ./dist-images
257
+
258
+ # 转换为 webp(可选 png / jpg / webp / avif / tiff)
259
+ auto mini ./images -e webp
260
+
261
+ # 无损压缩
262
+ auto mini ./images --lossless
263
+ ```
264
+
240
265
  ### 技术栈
241
266
 
242
267
  - `Vite` + `TypeScript` + `NodeJs`
@@ -254,6 +279,7 @@ auto ai zh-restore
254
279
  - `ora`: 动画效果
255
280
  - `pacote`: 包信息请求器
256
281
  - `semver-utils`: 解析包版本
282
+ - `sharp`: 图片压缩
257
283
  - `strip-json-comments`: 移除 json 注释
258
284
  - `update-notifier`: 检查更新
259
285
 
@@ -0,0 +1,41 @@
1
+ var e = {
2
+ env: { DISABLE_AUTOUPDATER: "1" },
3
+ permissions: {
4
+ allow: [
5
+ "Read(//**)",
6
+ "Edit(//**)",
7
+ "Delete(//**)",
8
+ "Bash(*)"
9
+ ],
10
+ deny: [
11
+ "Bash(git add *)",
12
+ "Bash(git commit *)",
13
+ "Bash(git push *)",
14
+ "Bash(git reset *)",
15
+ "Bash(git checkout *)",
16
+ "Bash(git switch *)",
17
+ "Bash(git merge *)",
18
+ "Bash(git rebase *)",
19
+ "Bash(git branch *)",
20
+ "Bash(git rm *)",
21
+ "Bash(git mv *)",
22
+ "Bash(git tag *)",
23
+ "Bash(git stash *)",
24
+ "Bash(git clean *)",
25
+ "Bash(git cherry-pick *)",
26
+ "Bash(git revert *)"
27
+ ],
28
+ defaultMode: "bypassPermissions"
29
+ },
30
+ enabledPlugins: {
31
+ "context7@claude-plugins-official": !0,
32
+ "frontend-design@claude-plugins-official": !0,
33
+ "superpowers@claude-plugins-official": !0,
34
+ "claude-mem@thedotmack": !0,
35
+ "code-simplifier@claude-plugins-official": !0
36
+ },
37
+ language: "Chinese",
38
+ skipDangerousModePermissionPrompt: !0,
39
+ theme: "dark-daltonized"
40
+ };
41
+ export { e as default };
package/dist/index.js CHANGED
@@ -1,24 +1,26 @@
1
- import { program as e } from "commander";
2
- import t from "chalk";
3
- import { cpSync as n, existsSync as r, readFileSync as i, readdirSync as a, rmSync as o, writeFileSync as s } from "fs";
4
- import { dirname as c, join as l, resolve as u } from "path";
5
- import d from "log-symbols";
6
- import f from "ora";
7
- import { execSync as p } from "child_process";
8
- import * as m from "js-yaml";
9
- import ee from "strip-json-comments";
10
- import h from "pacote";
11
- import { parseRange as g } from "semver-utils";
12
- import _ from "download-git-repo";
13
- import v from "inquirer";
14
- import y from "os";
15
- import { openBinary as te } from "@avmc/bun-extractor";
16
- import ne from "update-notifier";
17
- //#region package.json
18
- var re = "mine-auto-cli", ie = "2.8.2", b = {
19
- name: re,
1
+ import { Help as e, program as t } from "commander";
2
+ import n from "chalk";
3
+ import { copyFileSync as r, cpSync as i, existsSync as a, mkdirSync as o, readFileSync as s, readdirSync as c, renameSync as l, rmSync as u, statSync as d, unlinkSync as f, writeFileSync as p } from "fs";
4
+ import { basename as m, dirname as ee, extname as h, join as g, relative as te, resolve as _ } from "path";
5
+ import v from "log-symbols";
6
+ import y from "ora";
7
+ import { execSync as b } from "child_process";
8
+ import * as x from "js-yaml";
9
+ import S from "strip-json-comments";
10
+ import C from "pacote";
11
+ import { parseRange as w } from "semver-utils";
12
+ import T from "download-git-repo";
13
+ import E from "inquirer";
14
+ import D from "os";
15
+ import { openBinary as ne } from "@avmc/bun-extractor";
16
+ import O from "string-width";
17
+ import re from "sharp";
18
+ import ie from "update-notifier";
19
+ // package.json
20
+ var ae = "mine-auto-cli", oe = "2.9.0", k = {
21
+ name: ae,
20
22
  private: !1,
21
- version: ie,
23
+ version: oe,
22
24
  exports: "./dist/index.js",
23
25
  main: "./dist/index.js",
24
26
  type: "module",
@@ -61,171 +63,167 @@ var re = "mine-auto-cli", ie = "2.8.2", b = {
61
63
  }],
62
64
  dependencies: {
63
65
  "@avmc/bun-extractor": "^0.5.1",
64
- chalk: "^5.6.2",
66
+ chalk: "^6.0.1",
65
67
  commander: "^15.0.0",
66
68
  "download-git-repo": "^3.0.2",
67
- inquirer: "^14.0.2",
68
- "js-yaml": "^5.1.0",
69
+ inquirer: "^14.2.5",
70
+ "js-yaml": "^5.5.0",
69
71
  "log-symbols": "^7.0.1",
70
72
  ora: "^9.4.1",
71
- pacote: "^22.0.0",
73
+ pacote: "^22.0.1",
72
74
  "semver-utils": "^1.1.4",
75
+ sharp: "^0.35.5",
76
+ "string-width": "^8.3.0",
73
77
  "strip-json-comments": "^5.0.3",
74
78
  "update-notifier": "^7.3.1"
75
79
  },
76
80
  devDependencies: {
77
81
  "@types/js-yaml": "^4.0.9",
78
- "@types/node": "^26.0.0",
82
+ "@types/node": "^26.6.6",
79
83
  "@types/pacote": "^11.1.8",
80
84
  "@types/semver-utils": "^1.1.3",
81
85
  "@types/update-notifier": "^6.0.8",
82
- prettier: "^3.8.4",
83
- typescript: "^6.0.3",
84
- vite: "^8.1.0"
86
+ prettier: "^3.9.10",
87
+ typescript: "^7.0.2",
88
+ vite: "^8.3.5"
85
89
  }
86
- }, x = (e) => {
87
- console.log(`${d.success} ${t.green("SUCCESS")} ${e}`);
88
- }, S = (e) => {
89
- console.log(`${re} ${d.error} ${t.red("ERROR")} ${e}`);
90
- }, C = (e) => {
90
+ }, A = (e) => {
91
+ console.log(`${v.success} ${n.green("SUCCESS")} ${e}`);
92
+ }, j = (e) => {
93
+ console.log(`${ae} ${v.error} ${n.red("ERROR")} ${e}`);
94
+ }, M = (e) => {
91
95
  console.log(e ?? "");
92
- }, w = (e) => {
93
- C(`开始执行 ${t.cyanBright(e)} 命令`);
94
- let n = f({
96
+ }, se = (e) => {
97
+ M(`开始执行 ${n.cyanBright(e)} 命令`);
98
+ let t = y({
95
99
  text: "正在执行命令中...",
96
100
  color: "yellow"
97
101
  });
98
- n.start(), C(p(e, { cwd: process.cwd() }).toString()), n.succeed(`${t.green(e)} 命令执行成功`), C();
99
- }, ae = (e) => [
102
+ t.start(), M(b(e, { cwd: process.cwd() }).toString()), t.succeed(`${n.green(e)} 命令执行成功`), M();
103
+ }, ce = (e) => [
100
104
  "git add -A",
101
105
  `git commit -m ${e}`,
102
106
  "git push"
103
- ], oe = (e, t) => [
107
+ ], le = (e, t) => [
104
108
  `npm run ${e}`,
105
109
  "git add -A",
106
110
  `git commit -m ${t}`,
107
111
  "git push"
108
- ], se = async (e, n = "打包") => {
109
- C(), C(`${t.yellow(">>")} 开始依次执行命令...`), C(), oe(e, n).map(w), x("全部命令执行完成"), C();
110
- }, ce = (t) => {
111
- C(), S(`\`${t}\` 命令错误,请检查你的命令`), C(), e.help();
112
- }, le = (e) => {
112
+ ], ue = async (e, t = "打包") => {
113
+ M(), M(`${n.yellow(">>")} 开始依次执行命令...`), M(), le(e, t).map(se), A("全部命令执行完成"), M();
114
+ }, de = (e) => {
115
+ M(), j(`\`${e}\` 命令错误,请检查你的命令`), M(), t.help();
116
+ }, fe = (e) => {
113
117
  let [t, n] = ["package.json", "README.md"].map((e) => {
114
- let t = l(process.cwd(), e);
118
+ let t = g(process.cwd(), e);
115
119
  return {
116
120
  path: t,
117
- content: i(t).toString()
121
+ content: s(t).toString()
118
122
  };
119
123
  }), r = JSON.parse(t.content);
120
- e ? r.version = e : r.version = r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), s(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), s(n.path, n.content);
121
- }, ue = async (e) => {
124
+ r.version = e || r.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), ""), p(t.path, JSON.stringify(r, null, 2)), n.content = n.content.replace(/version\-v.+\-blue/, () => `version-v${r.version}-blue`), p(n.path, n.content);
125
+ }, pe = async (e) => {
122
126
  let t = e.split("version")[1];
123
- if (!t) return ce(e);
124
- let n = JSON.parse(i(l(process.cwd(), "package.json")).toString());
127
+ if (!t) return de(e);
128
+ let n = JSON.parse(s(g(process.cwd(), "package.json")).toString());
125
129
  if (t === "++") {
126
- le(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), C(), x("命令执行完成");
130
+ fe(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), M(), A("命令执行完成");
127
131
  return;
128
132
  }
129
133
  let r = t.split("@")[1];
130
- r ? (le(r), C(), x("命令执行完成")) : ce(e);
131
- }, de = (n, r) => {
132
- if (n.includes("build")) return se(n, r);
133
- if (n.includes("version")) return ue(n);
134
- S(t.hex("#f56c6c")(`\`auto ${n}${r ? ` ${r}` : ""}\` 命令不存在`)), e.help();
135
- }, T = "https://gitee.com/biaovorg/project-template.git";
134
+ r ? (fe(r), M(), A("命令执行完成")) : de(e);
135
+ }, me = (e, r) => {
136
+ if (e.includes("build")) return ue(e, r);
137
+ if (e.includes("version")) return pe(e);
138
+ j(n.hex("#f56c6c")(`\`auto ${e}${r ? ` ${r}` : ""}\` 命令不存在`)), t.help();
139
+ }, N = "https://gitee.com/biaovorg/project-template.git";
136
140
  Object.keys({
137
- vue: T,
138
- react: T,
139
- "uni-app": T,
140
- electron: T,
141
- node: T,
142
- "node-simple": T
141
+ vue: N,
142
+ react: N,
143
+ "uni-app": N,
144
+ electron: N,
145
+ node: N,
146
+ "node-simple": N
143
147
  }).reduce((e, t, n) => e + (n ? ", " : "") + t, "");
144
- var E = (e = "jsonc") => `auto-cli.${e}`;
145
- u(import.meta.dirname, "./presetData.json");
146
- var D = (e, t = !1) => {
147
- if (!r(e)) return t ? {} : "";
148
- let n = i(e).toString();
149
- return t ? JSON.parse(ee(n)) : n;
150
- }, fe = (e) => {
151
- if (!r(e)) return {};
152
- let t = i(e).toString();
148
+ var P = (e = "jsonc") => `auto-cli.${e}`;
149
+ _(import.meta.dirname, "./presetData.json");
150
+ var F = (e, t = !1) => {
151
+ if (!a(e)) return t ? {} : "";
152
+ let n = s(e).toString();
153
+ return t ? JSON.parse(S(n)) : n;
154
+ }, he = (e) => {
155
+ if (!a(e)) return {};
156
+ let t = s(e).toString();
153
157
  try {
154
- return m.load(t);
158
+ return x.load(t);
155
159
  } catch {
156
160
  return {};
157
161
  }
158
- }, O = (e = !1) => D(u(import.meta.dirname, E()), e), k = () => {
159
- let [e, t] = [E(), E("yml")].map((e) => u(process.cwd(), e)), n = O(!0);
162
+ }, I = (e = !1) => F(_(import.meta.dirname, P()), e), L = () => {
163
+ let [e, t] = [P(), P("yml")].map((e) => _(process.cwd(), e)), n = I(!0);
160
164
  try {
161
- Object.assign(n, fe(t), D(e, !0));
165
+ Object.assign(n, he(t), F(e, !0));
162
166
  } catch {}
163
167
  return n;
164
- }, pe = (e, t = !1) => {
165
- let n = O(t);
168
+ }, ge = (e, t = !1) => {
169
+ let n = I(t);
166
170
  return t && (n = JSON.stringify(n, null, 2)), e.includes(".yml") ? n.trim().split("\n").slice(1, -1).reduce((e, t) => e + t.trim().replace(/[",]/g, "").replace("// ", "# ") + "\n", "") : n;
167
- }, A = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), me = () => `${+/* @__PURE__ */ new Date()}${Math.random().toString(36).substring(2, 6)}`;
168
- e.command("init").option("-f, --force", `强制替换 ${E()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${E()} 带注释`, !1).option("-y, --yml", `生成 ${E("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: n, force: i }) => {
169
- C();
170
- let a = E(e ? "yml" : "jsonc"), o = u(process.cwd(), a);
171
- if (r(o) && !i) {
172
- C(t.yellow(`${a} 文件已存在`)), C(), C(t.yellow(`文件目录 ${o}`));
173
- return;
174
- }
175
- s(o, pe(a, n)), x(`${a} 文件创建成功`), C(), C(t.green(`文件目录 ${o}`));
176
- }), e.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
177
- C(), C(`${t.yellow(">>")} 开始依次执行命令...`), C(), ae(e).forEach(w), x("全部命令执行完成"), C();
171
+ }, R = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join(""), _e = () => `${+/* @__PURE__ */ new Date()}${Math.random().toString(36).substring(2, 6)}`;
172
+ t.command("init").option("-f, --force", `强制替换 ${P()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${P()} 带注释`, !1).option("-y, --yml", `生成 ${P("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: t, force: r }) => {
173
+ M();
174
+ let i = P(e ? "yml" : "jsonc"), o = _(process.cwd(), i);
175
+ a(o) && !r ? (M(n.yellow(`${i} 文件已存在`)), M(), M(n.yellow(`文件目录 ${o}`))) : (p(o, ge(i, t)), A(`${i} 文件创建成功`), M(), M(n.green(`文件目录 ${o}`)));
176
+ }), t.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
177
+ M(), M(`${n.yellow(">>")} 开始依次执行命令...`), M(), ce(e).forEach(se), A("全部命令执行完成"), M();
178
178
  });
179
- //#endregion
180
- //#region src/commander/commands/mkdir.ts
181
- var j = [
179
+ // src/commander/commands/mkdir.ts
180
+ var ve = [
182
181
  "dist",
183
182
  "node_modules",
184
183
  ".git",
185
184
  "miniprogram_npm"
186
- ], M = 0, N = !1, P = !1, F = 20, I = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
187
- let a = Array.from({ length: t }).reduce((e) => e + `${t === 1 && n === r.length - 1 ? "└ " : "│ "} `, ""), o = e + a, s = (a + i).length, c = Array.from({ length: F + M - s }).reduce((e) => `${e}-`, " ");
188
- return !N && (M = Math.max(M, s)), `${o}${i}${P ? c : ""}\n`;
189
- }, L = (e, t = 0) => e.reduce((e, n, r, i) => {
185
+ ], z = 0, ye = !1, B = !1, be = 20, xe = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
186
+ let a = Array.from({ length: t }).reduce((e) => e + `${t === 1 && n === r.length - 1 ? "└ " : "│ "} `, ""), o = e + a, s = (a + i).length, c = Array.from({ length: be + z - s }).reduce((e) => `${e}-`, " ");
187
+ return !ye && (z = Math.max(z, s)), `${o}${i}${B ? c : ""}\n`;
188
+ }, V = (e, t = 0) => e.reduce((e, n, r, i) => {
190
189
  let a;
191
- return n.children ? (a = `├── ${n.name}`, I({
190
+ return n.children ? (a = `├── ${n.name}`, xe({
192
191
  prev: e,
193
192
  i: t,
194
193
  index: r,
195
194
  arr: i,
196
195
  curText: a
197
- }) + L(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, I({
196
+ }) + V(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, xe({
198
197
  prev: e,
199
198
  i: t,
200
199
  index: r,
201
200
  arr: i,
202
201
  curText: a
203
202
  }));
204
- }, ""), R = (e) => a(e, { withFileTypes: !0 }).sort((e, t) => t.isDirectory() - +e.isDirectory());
205
- e.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
206
- P = !!e, typeof e == "string" && (F = +e);
207
- let n = process.cwd(), a = l(n, ".gitignore");
208
- if (r(a)) {
209
- let e = i(a).toString().split("\r\n");
210
- j.push(...e);
203
+ }, ""), Se = (e) => c(e, { withFileTypes: !0 }).sort((e, t) => +t.isDirectory() - e.isDirectory());
204
+ t.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
205
+ B = !!e, typeof e == "string" && (be = +e);
206
+ let n = process.cwd(), r = g(n, ".gitignore");
207
+ if (a(r)) {
208
+ let e = s(r).toString().split("\r\n");
209
+ ve.push(...e);
211
210
  }
212
- let o = [{
211
+ let i = [{
213
212
  name: n.split("\\").at(-1),
214
- children: R(n).map((e) => {
213
+ children: Se(n).map((e) => {
215
214
  let { name: t } = e, n = { name: t };
216
- return !j.includes(t) && e.isDirectory() && (n.children = R(l(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
215
+ return !ve.includes(t) && e.isDirectory() && (n.children = Se(g(e.path, t)).map(({ name: e }) => ({ name: e }))), n;
217
216
  })
218
217
  }];
219
- P && (L(o), N = !0), s(l(n, `${typeof t == "string" && t || "directory"}.md`), L(o));
218
+ B && (V(i), ye = !0), p(g(n, `${typeof t == "string" && t || "directory"}.md`), V(i));
220
219
  });
221
- //#endregion
222
- //#region src/commander/commands/check.ts
223
- var z = k(), [B] = ["package.json"].map((e) => u(process.cwd(), e)), he = (e, n) => {
224
- let r = `\r查找进度:[${Array.from({ length: n }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${n} ${~~(e / n * 100)}%\r`, i = e === n ? t.green(r) : t.yellow(r);
220
+ // src/commander/commands/check.ts
221
+ var H = L(), [U] = ["package.json"].map((e) => _(process.cwd(), e)), Ce = (e, t) => {
222
+ let r = `\r查找进度:[${Array.from({ length: t }, (t, n) => n < e ? "=" : " ").join("")}] ${e}/${t} ${~~(e / t * 100)}%\r`, i = e === t ? n.green(r) : n.yellow(r);
225
223
  process.stdout.write(i);
226
- }, ge = (e, t, n) => {
224
+ }, we = (e, t, n) => {
227
225
  let r = "latest";
228
- return z.resolve.some((t) => {
226
+ return H.resolve.some((t) => {
229
227
  let n = t.lastIndexOf("@");
230
228
  if (n <= 0) return !0;
231
229
  let i = t.slice(0, n), a = t.slice(n + 1);
@@ -233,25 +231,25 @@ var z = k(), [B] = ["package.json"].map((e) => u(process.cwd(), e)), he = (e, n)
233
231
  }), {
234
232
  name: e,
235
233
  value: t,
236
- newVersion: z.prefix + n[r],
234
+ newVersion: H.prefix + n[r],
237
235
  tag: r
238
236
  };
239
- }, _e = (e, t) => (+!t + 1) * e.length, V = (e) => {
240
- let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = g(e);
237
+ }, Te = (e, t) => (+!t + 1) * e.length, Ee = (e) => {
238
+ let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = w(e);
241
239
  return [
242
240
  +t,
243
241
  +n,
244
242
  +r,
245
243
  i
246
244
  ];
247
- }, H = (e, n) => e ? "-" + t[n](e) : "", ve = (e, n) => {
248
- let [r, i, a, o] = V(e), [s, c, l, u] = V(n);
249
- return s > r ? t.red(n) : s < r ? !1 : c > i ? `${s}.${t.yellow(c)}.${t.yellow(l)}${H(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${t.green(l)}${H(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${H(u, "green")}` : !1;
250
- }, ye = (e) => {
251
- let n = {};
245
+ }, W = (e, t) => e ? "-" + n[t](e) : "", De = (e, t) => {
246
+ let [r, i, a, o] = Ee(e), [s, c, l, u] = Ee(t);
247
+ return s > r ? n.red(t) : s < r ? !1 : c > i ? `${s}.${n.yellow(c)}.${n.yellow(l)}${W(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${n.green(l)}${W(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${W(u, "green")}` : !1;
248
+ }, Oe = (e) => {
249
+ let t = {};
252
250
  e.forEach((e) => {
253
- Object.entries(e).forEach(([e, t]) => {
254
- n[e] = Math.max(t.length, n[e] ?? 0);
251
+ Object.entries(e).forEach(([e, n]) => {
252
+ t[e] = Math.max(n.length, t[e] ?? 0);
255
253
  });
256
254
  }), e.unshift({
257
255
  name: "包名",
@@ -266,91 +264,88 @@ var z = k(), [B] = ["package.json"].map((e) => u(process.cwd(), e)), he = (e, n)
266
264
  value: i,
267
265
  newVersion: a,
268
266
  tag: o
269
- }).map(([e, t]) => A(_e(t, s), n[e])), f = t.yellow("→"), p = !0;
267
+ }).map(([e, n]) => R(Te(n, s), t[e])), f = n.yellow("→"), p = !0;
270
268
  if (s) {
271
- let e = ve(i, a);
269
+ let e = De(i, a);
272
270
  e ? a = e : p = !1;
273
- } else e = t.green(e), i = t.green(i), a = t.green(a), o = t.green(o), f = " ";
271
+ } else e = n.green(e), i = n.green(i), a = n.green(a), o = n.green(o), f = " ";
274
272
  let m = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
275
273
  p && r.push(m);
276
- }), r.length > 1 ? r.forEach(C) : x("所有版本已是最新");
277
- }, be = async (e, t, n) => {
278
- C();
274
+ }), r.length > 1 ? r.forEach(M) : A("所有版本已是最新");
275
+ }, ke = async (e, t, n) => {
276
+ M();
279
277
  let r = 0, i = [], a = Object.entries(e), o = a.map(async ([e, o]) => {
280
- let s = ge(e, o, (await h.packument(e, { registry: z.registry }))["dist-tags"]);
278
+ let s = we(e, o, (await C.packument(e, { registry: H.registry }))["dist-tags"]);
281
279
  i.push(s), t.forEach((t) => {
282
280
  let r = n[t];
283
281
  r && r[e] && (r[e] = s.newVersion);
284
- }), r++, await he(r, a.length);
282
+ }), r++, await Ce(r, a.length);
285
283
  });
286
- return await Promise.all(o), C(), C(), i;
284
+ return await Promise.all(o), M(), M(), i;
287
285
  };
288
- e.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
289
- if (!r(B)) return S("package.json 文件不存在");
290
- let t = e || z.check, n = i(B).toString(), a = JSON.parse(n), o = [
286
+ t.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
287
+ if (!a(U)) return j("package.json 文件不存在");
288
+ let t = e || H.check, n = s(U).toString(), r = JSON.parse(n), i = [
291
289
  "dependencies",
292
290
  "devDependencies",
293
291
  "optionalDependencies"
294
- ], c = {}, l = JSON.parse(n);
295
- o.forEach((e) => {
296
- a[e] && Object.entries(a[e]).forEach(([e, t]) => {
297
- !z.reject.includes(e) && (c[e] = t);
292
+ ], o = {}, c = JSON.parse(n);
293
+ i.forEach((e) => {
294
+ r[e] && Object.entries(r[e]).forEach(([e, t]) => {
295
+ !H.reject.includes(e) && (o[e] = t);
298
296
  });
299
297
  });
300
- let u = await be(c, o, l);
301
- t ? (s(B, JSON.stringify(l, null, 2)), x("文件 package.json 已更新"), C()) : ye(u);
298
+ let l = await ke(o, i, c);
299
+ t ? (p(U, JSON.stringify(c, null, 2)), A("文件 package.json 已更新"), M()) : Oe(l);
302
300
  });
303
- //#endregion
304
- //#region src/commander/commands/comment.ts
305
- var xe = k(), U = "comment.md", [W, G] = ["package.json", U].map((e) => u(process.cwd(), e));
306
- e.command("comment").description("生成依赖注释文件").action(() => {
307
- if (!r(W)) return S("package.json 文件不存在");
308
- let e = i(W).toString(), n = JSON.parse(e), a = [
301
+ // src/commander/commands/comment.ts
302
+ var Ae = L(), je = "comment.md", [Me, Ne] = ["package.json", je].map((e) => _(process.cwd(), e));
303
+ t.command("comment").description("生成依赖注释文件").action(() => {
304
+ if (!a(Me)) return j("package.json 文件不存在");
305
+ let e = s(Me).toString(), t = JSON.parse(e), r = [
309
306
  "dependencies",
310
307
  "devDependencies",
311
308
  "optionalDependencies"
312
- ], o = "### 依赖解析\n\n";
313
- a.forEach((e) => {
314
- n[e] && (o += `#### ${e}\n\n`, Object.keys(n[e]).forEach((e) => {
315
- o += `- \`${e}\`: ${xe.comment[e] || ""}\n`;
316
- }), o += "\n");
317
- }), o = o.slice(0, -1), s(G, o), C(), x(`${U} 文件创建成功`), C(), C(t.green(`文件目录 ${G}`));
309
+ ], i = "### 依赖解析\n\n";
310
+ r.forEach((e) => {
311
+ t[e] && (i += `#### ${e}\n\n`, Object.keys(t[e]).forEach((e) => {
312
+ i += `- \`${e}\`: ${Ae.comment[e] || ""}\n`;
313
+ }), i += "\n");
314
+ }), i = i.slice(0, -1), p(Ne, i), M(), A(`${je} 文件创建成功`), M(), M(n.green(`文件目录 ${Ne}`));
318
315
  });
319
- //#endregion
320
- //#region src/commander/commands/vscode.ts
321
- var Se = {
316
+ // src/commander/commands/vscode.ts
317
+ var Pe = {
322
318
  recursive: !0,
323
319
  force: !0
324
320
  };
325
- e.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
326
- let e = `${+/* @__PURE__ */ new Date()}`, t = l(process.cwd()), r = l(t, e);
327
- _("direct:https://gitee.com/biaovorg/vscode-config.git#master", r, { clone: !0 }, async (e) => {
328
- !e && n(l(r, ".vscode"), l(t, ".vscode"), Se), o(r, Se);
321
+ t.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
322
+ let e = `${+/* @__PURE__ */ new Date()}`, t = g(process.cwd()), n = g(t, e);
323
+ T("direct:https://gitee.com/biaovorg/vscode-config.git#master", n, { clone: !0 }, async (e) => {
324
+ !e && i(g(n, ".vscode"), g(t, ".vscode"), Pe), u(n, Pe);
329
325
  });
330
326
  });
331
- //#endregion
332
- //#region src/commander/commands/node.ts
333
- var Ce = (e, t, n) => {
327
+ // src/commander/commands/node.ts
328
+ var Fe = (e, t, n) => {
334
329
  let r = Object.entries(t), i = r.findIndex(([t]) => e === t), [a, o] = r[i];
335
330
  if (o) {
336
- if (n[a] === o) return i === r.length - 1 ? !0 : Ce(r[i + 1][0], t, n);
331
+ if (n[a] === o) return i === r.length - 1 || Fe(r[i + 1][0], t, n);
337
332
  } else return !0;
338
- }, we = (e) => {
339
- e && (p(`nvm use ${e}`), C(), x(`切换成功 当前版本:${e}`), C());
340
- }, K = (e) => {
341
- e && p(`nvm install ${e}`);
333
+ }, Ie = (e) => {
334
+ e && (b(`nvm use ${e}`), M(), A(`切换成功 当前版本:${e}`), M());
335
+ }, G = (e) => {
336
+ e && b(`nvm install ${e}`);
342
337
  };
343
- e.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, n) => {
344
- let r = g(p("nvm ls").toString()), [{ major: i, minor: a, patch: o }] = g(e), s = [], c = r.find((e) => {
345
- if (e.major === i) return s.push(e), Ce("minor", {
346
- minor: a,
347
- patch: o
338
+ t.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, t) => {
339
+ let r = b("nvm ls").toString(), i = w(r), [{ major: a, minor: o, patch: s }] = w(e), c = [], l = i.find((e) => {
340
+ if (e.major === a) return c.push(e), Fe("minor", {
341
+ minor: o,
342
+ patch: s
348
343
  }, e);
349
344
  });
350
- if (c) we(c.semver);
351
- else if (C(), C(t.red(`输入的版本 ${e} 不存在`)), C(), s.length) {
352
- let t = s.map((e) => e.semver);
353
- v.prompt({
345
+ if (l) Ie(l.semver);
346
+ else if (M(), M(n.red(`输入的版本 ${e} 不存在`)), M(), c.length) {
347
+ let t = c.map((e) => e.semver);
348
+ E.prompt({
354
349
  type: "list",
355
350
  name: "preset",
356
351
  message: "请选择相似版本或输入版本进行安装:",
@@ -360,157 +355,308 @@ e.command("node [版本号]").option("-i, --install", "是否安装此版本", !
360
355
  "取消"
361
356
  ]
362
357
  }).then(({ preset: t }) => {
363
- if (t !== "取消") if (t === e) {
364
- if (!o) return;
365
- K(t);
366
- } else we(t);
358
+ if (t !== "取消") {
359
+ if (t === e) {
360
+ if (!s) return;
361
+ G(t);
362
+ } else Ie(t);
363
+ }
367
364
  });
368
365
  } else {
369
- if (!o) return;
370
- if (n.install) {
371
- K(e);
366
+ if (!s) return;
367
+ if (t.install) {
368
+ G(e);
372
369
  return;
373
370
  }
374
- v.prompt({
371
+ E.prompt({
375
372
  type: "confirm",
376
373
  name: "isInstall",
377
374
  message: `是否安装 ${e}?`
378
375
  }).then(({ isInstall: t }) => {
379
- t && K(e);
376
+ t && G(e);
380
377
  });
381
378
  }
382
379
  });
383
- //#endregion
384
- //#region src/commander/commands/ai.ts
385
- var q = [
380
+ // src/commander/commands/ai.ts
381
+ var K = [
386
382
  "ANTHROPIC_AUTH_TOKEN",
387
383
  "ANTHROPIC_BASE_URL",
388
384
  "ANTHROPIC_MODEL",
389
385
  "ANTHROPIC_SMALL_FAST_MODEL"
390
- ], Te = D(u(import.meta.dirname, "ai.jsonc"), !0), Ee = Object.entries(Te)[0], J = u(y.homedir(), ".claude/settings.json"), De = u(y.homedir(), ".claude/settings.local.json"), Y = u(y.homedir(), ".ai-model.json"), X = () => {
391
- r(J) || (S(`${J} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
392
- let e = JSON.parse(i(J).toString());
386
+ ], Le = F(_(import.meta.dirname, "ai.jsonc"), !0), Re = Object.entries(Le)[0], q = _(D.homedir(), ".claude/settings.json"), J = _(D.homedir(), ".ai-model.json"), Y = () => {
387
+ a(q) || (j(`${q} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
388
+ let e = JSON.parse(s(q).toString());
393
389
  return !e.env && (e.env = {}), e;
394
- }, Oe = () => {
395
- C(), r(Y) || (S("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
396
- let e = JSON.parse(i(Y).toString()), n = Object.entries(e).filter(([e, t]) => {
397
- if (e === Ee[0]) return !1;
398
- let n = t.env, r = Ee[1].env;
399
- return !(!n || q.some((e) => !n[e] || n[e] === r[e]));
390
+ }, ze = () => {
391
+ M(), a(J) || (j("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
392
+ let e = JSON.parse(s(J).toString()), t = Object.entries(e).filter(([e, t]) => {
393
+ if (e === Re[0]) return !1;
394
+ let n = t.env, r = Re[1].env;
395
+ return !(!n || K.some((e) => !n[e] || n[e] === r[e]));
400
396
  });
401
- return n.length || (C(`暂无已配置的 AI 模型,请先配置,路径 ${t.green(Y)}`), process.exit(1)), [n, e];
402
- }, ke = () => {
403
- if (C(), r(Y)) {
404
- C(`配置已存在,路径 ${t.green(Y)}`);
405
- return;
406
- }
407
- s(Y, JSON.stringify(Te, null, 2)), x(`配置已初始化,路径 ${t.green(Y)}`);
408
- }, Ae = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, je = () => {
409
- let [e] = Oe(), n = 0, r = -1, i = X();
410
- e.forEach(([e, t], a) => {
411
- n = Math.max(n, Ae(e)), r < 0 && !q.some((e) => i.env[e] !== t.env[e]) && (r = a);
397
+ return t.length || (M(`暂无已配置的 AI 模型,请先配置,路径 ${n.green(J)}`), process.exit(1)), [t, e];
398
+ }, Be = () => {
399
+ M(), a(J) ? M(`配置已存在,路径 ${n.green(J)}`) : (p(J, JSON.stringify(Le, null, 2)), A(`配置已初始化,路径 ${n.green(J)}`));
400
+ }, Ve = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, He = () => {
401
+ let [e] = ze(), t = 0, r = -1, i = Y();
402
+ e.forEach(([e, n], a) => {
403
+ t = Math.max(t, Ve(e)), r < 0 && !K.some((e) => i.env[e] !== n.env[e]) && (r = a);
412
404
  }), e.forEach(([e, i], a) => {
413
405
  let { ANTHROPIC_BASE_URL: o } = i.env;
414
- C(`${a === r ? t.green("*") : " "} ${e} ${A(Ae(e), n + 4, "-")} ${o}`);
406
+ M(`${a === r ? n.green("*") : " "} ${e} ${R(Ve(e), t + 4, "-")} ${o}`);
415
407
  });
416
- }, Me = async (e) => {
417
- let n = X(), [r, i] = Oe();
418
- r.some(([t]) => t === e) || (C(`模型 ${t.red(e)} 不存在`), process.exit(1)), q.some((t) => n.env[t] !== i[e].env[t]) ? (n.env = i[e].env, s(J, JSON.stringify(n, null, 2)), x(`模型 ${t.green(e)} 已切换`)) : C(`当前正处于 ${t.green(e)} 模型,无需切换`);
419
- }, Z = () => {
408
+ }, Ue = async (e) => {
409
+ let t = Y(), [r, i] = ze();
410
+ r.some(([t]) => t === e) || (M(`模型 ${n.red(e)} 不存在`), process.exit(1)), K.some((n) => t.env[n] !== i[e].env[n]) ? (t.env = i[e].env, p(q, JSON.stringify(t, null, 2)), A(`模型 ${n.green(e)} 已切换`)) : M(`当前正处于 ${n.green(e)} 模型,无需切换`);
411
+ }, We = () => {
420
412
  let e = "@anthropic-ai/claude-code";
421
413
  try {
422
- p(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (S(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
423
- let i = p("npm root -g").toString().trim(), a = u(i, e, "cli.js"), o = u(i, e, "cli.bak.js"), s = u(i, e, "bin/claude.exe"), c = u(i, e, "bin/claude.zh.exe"), l = u(i, e, "bin/claude.bak.exe"), d = !1;
424
- return r(s) ? (!r(l) && n(s, l), d = !0) : !r(o) && n(a, o), {
425
- cliPath: a,
414
+ b(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (j(n.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
415
+ let t = b("npm root -g").toString().trim(), r = _(t, e, "cli.js"), o = _(t, e, "cli.bak.js"), s = _(t, e, "bin/claude.exe"), c = _(t, e, "bin/claude.zh.exe"), l = _(t, e, "bin/claude.bak.exe"), u = !1;
416
+ return a(s) ? (!a(l) && i(s, l), u = !0) : !a(o) && i(r, o), {
417
+ cliPath: r,
426
418
  cliPathBak: o,
427
419
  exePath: s,
428
420
  exeZhPath: c,
429
421
  exePathBak: l,
430
- isExistExe: d
422
+ isExistExe: u
431
423
  };
432
424
  } catch {
433
- S(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
425
+ j(n.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
434
426
  }
435
- }, Ne = async () => {
436
- C(), C("开始汉化 Claude Code");
437
- let e = Z(), { cliPath: t, exePath: a, exeZhPath: o, isExistExe: c } = e;
438
- if (c) {
439
- if (r(o)) {
440
- n(o, a);
427
+ }, Ge = async () => {
428
+ M(), M("开始汉化 Claude Code");
429
+ let e = We(), { cliPath: t, exePath: n, exeZhPath: r, isExistExe: o } = e;
430
+ if (o) {
431
+ if (a(r)) {
432
+ i(r, n);
441
433
  return;
442
434
  }
443
- await Le(e), n(o, a);
435
+ await Ye(e), i(r, n);
444
436
  } else {
445
- let e = i(t).toString(), n = (await import("./keyword-B5vOiHTH.js")).default;
446
- s(t, Object.entries(n).reduce((e, [t, n]) => {
437
+ let e = s(t).toString(), n = (await import("./keyword-CgLMNoOo.js")).default, r = Object.entries(n).reduce((e, [t, n]) => {
447
438
  let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
448
439
  return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
449
- }, e));
450
- }
451
- x("Claude Code 已汉化");
452
- }, Pe = () => {
453
- C(), C("开始恢复 Claude Code");
454
- let { cliPath: e, cliPathBak: t, exePath: r, exePathBak: i, isExistExe: a } = Z();
455
- a ? n(i, r) : n(t, e), x("Claude Code 已恢复成英文");
456
- }, Fe = async () => {
457
- C();
458
- let e = (await import("./claude.settings-D0MSYWxl.js")).default, n = X();
459
- Object.assign(n, e), s(J, JSON.stringify(n, null, 2)), x(`Claude Code 配置成功,请前往查看:${t.yellow(J)}`);
460
- }, Ie = async () => {
461
- if (C(), C("开始配置 Claude Code 默认权限"), C(), !r(De)) {
462
- Fe();
463
- return;
440
+ }, e);
441
+ p(t, r);
464
442
  }
465
- v.prompt({
443
+ A("Claude Code 已汉化");
444
+ }, Ke = () => {
445
+ M(), M("开始恢复 Claude Code");
446
+ let { cliPath: e, cliPathBak: t, exePath: n, exePathBak: r, isExistExe: a } = We();
447
+ a ? i(r, n) : i(t, e), A("Claude Code 已恢复成英文");
448
+ }, qe = async () => {
449
+ M();
450
+ let e = (await import("./claude.settings-D209xJfD.js")).default, t = Y();
451
+ e.env && Object.assign(e.env, t.env), Object.assign(t, e), p(q, JSON.stringify(t, null, 2)), A(`Claude Code 配置成功,请前往查看:${n.yellow(q)}`);
452
+ }, Je = async () => {
453
+ M(), M("开始配置 Claude Code 默认权限"), M(), a(q) ? E.prompt({
466
454
  type: "confirm",
467
455
  name: "isOk",
468
456
  message: "存在本地配置文件,继续配置会直接覆盖本地配置文件里的属性内容,是否继续 ?"
469
457
  }).then(({ isOk: e }) => {
470
- e && Fe();
471
- });
472
- }, Le = async ({ cliPath: e, exePath: t, exeZhPath: n, exePathBak: r, isExistExe: a }) => {
473
- let o = c(t), l = t, d = u(o, me());
474
- p(`npx bun-extractor "${l}" -o "${d}"`, { stdio: "ignore" });
475
- let f = u(d, te(i(l)).entryPoint.path), m = i(f).toString(), ee = (await import("./keyword-B5vOiHTH.js")).default, h = Object.entries(ee).reduce((e, [t, n]) => {
458
+ e && qe();
459
+ }) : qe();
460
+ }, Ye = async ({ cliPath: e, exePath: t, exeZhPath: n, exePathBak: r, isExistExe: i }) => {
461
+ let a = ee(t), o = t, c = _(a, _e());
462
+ b(`npx bun-extractor "${o}" -o "${c}"`, { stdio: "ignore" });
463
+ let l = ne(s(o)), u = _(c, l.entryPoint.path), d = s(u).toString(), f = (await import("./keyword-CgLMNoOo.js")).default, m = Object.entries(f).reduce((e, [t, n]) => {
476
464
  let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
477
465
  return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
478
- }, m), g = Array.from(h).map((e) => {
466
+ }, d), h = Array.from(m).map((e) => {
479
467
  let t = e.charCodeAt(0);
480
468
  return t >= 19968 && t <= 40959 ? `\\u${t.toString(16).padStart(4, "0")}` : e;
481
- }).join(""), _ = f.slice(0, -3) + ".zh.js";
482
- s(_, g);
483
- let v = `import { dirname, resolve } from 'node:path'
484
- await import(resolve(dirname(process.execPath), "${_.replace(/\\/g, "/")}"))`, y = u(d, "entry.js");
485
- s(y, v), p(`bun build ${y} --compile --icon=claude-code.ico --outfile ${l.slice(0, -4) + ".zh.exe"}`, { stdio: "ignore" });
486
- }, Q = e.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
487
- Q.command("init").description("初始化 AI 模型配置").action(ke), Q.command("ls").description("查看当前已配置的 AI 模型").action(je), Q.command("use <模型>").description("切换 AI 模型").action(Me), Q.command("zh").description("汉化 Claude Code").action(Ne), Q.command("zh-restore").description("恢复汉化 Claude Code").action(Pe), Q.command("config").description("配置 Claude Code 默认权限").action(Ie), e.usage("[commands] [options]").version(ie, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令"), e.command("build[:环境] [描述]").description("简化打包提交命令"), e.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本"), e.arguments("<cmd> [env]").action((e, t) => {
488
- de(e, t);
489
- }), process.argv.length < 3 ? e.help() : e.parse(process.argv);
490
- //#endregion
491
- //#region src/update.ts
492
- var $ = ne({
493
- pkg: b,
494
- updateCheckInterval: 1e3 * 1
469
+ }).join(""), g = u.slice(0, -3) + ".zh.js";
470
+ p(g, h);
471
+ let te = `import { dirname, resolve } from 'node:path'
472
+ await import(resolve(dirname(process.execPath), "${g.replace(/\\/g, "/")}"))`, v = _(c, "entry.js");
473
+ p(v, te), b(`bun build ${v} --compile --icon=claude-code.ico --outfile ${o.slice(0, -4) + ".zh.exe"}`, { stdio: "ignore" });
474
+ }, Xe = async () => {
475
+ M(), M("查看 Claude Code 默认配置"), M(), a(q) ? M(JSON.parse(s(q).toString())) : j("Claude Code 未配置,默认配置文件不存在");
476
+ }, X = t.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
477
+ X.command("init").description("初始化 AI 模型配置").action(Be), X.command("ls").description("查看当前已配置的 AI 模型").action(He), X.command("use <模型>").description("切换 AI 模型").action(Ue), X.command("zh").description("汉化 Claude Code").action(Ge), X.command("zh-restore").description("恢复汉化 Claude Code").action(Ke), X.command("config").description("配置 Claude Code 默认权限").action(Je), X.command("config-ls").description("查看 Claude Code 默认配置").action(Xe);
478
+ // src/commander/commands/mini.ts
479
+ var Ze = [
480
+ "jpg",
481
+ "jpeg",
482
+ "png",
483
+ "webp",
484
+ "avif",
485
+ "tiff",
486
+ "tif"
487
+ ], Qe = [
488
+ "jpg",
489
+ "jpeg",
490
+ "png",
491
+ "webp",
492
+ "avif",
493
+ "tiff",
494
+ "tif"
495
+ ], Z = (e) => d(e).size, Q = (e) => {
496
+ let t = [
497
+ "B",
498
+ "KB",
499
+ "MB",
500
+ "GB"
501
+ ], n = 0, r = e;
502
+ for (; r >= 1024 && n < t.length - 1;) r /= 1024, n++;
503
+ return `${r.toFixed(n === 0 ? 0 : 2)} ${t[n]}`;
504
+ }, $e = (e, t) => c(e, { withFileTypes: !0 }).reduce((n, r) => {
505
+ let i = g(e, r.name);
506
+ return r.isDirectory() ? (t.includes(_(i)) || n.push(...$e(i, t)), n) : (Ze.includes(h(r.name).slice(1).toLowerCase()) && n.push(i), n);
507
+ }, []), et = async (e, t, n, r) => {
508
+ let i = re(e);
509
+ if (((await i.metadata()).pages ?? 1) > 1) return !1;
510
+ let a = i.rotate();
511
+ switch (n) {
512
+ case "png":
513
+ await a.png(r ? {
514
+ compressionLevel: 9,
515
+ adaptiveFiltering: !0
516
+ } : {
517
+ palette: !0,
518
+ quality: 100,
519
+ effort: 10,
520
+ dither: 1,
521
+ compressionLevel: 9,
522
+ adaptiveFiltering: !0
523
+ }).toFile(t);
524
+ break;
525
+ case "webp":
526
+ await a.webp(r ? {
527
+ lossless: !0,
528
+ effort: 6
529
+ } : {
530
+ quality: 80,
531
+ effort: 6
532
+ }).toFile(t);
533
+ break;
534
+ case "avif":
535
+ await a.avif(r ? {
536
+ lossless: !0,
537
+ effort: 9
538
+ } : {
539
+ quality: 60,
540
+ effort: 9
541
+ }).toFile(t);
542
+ break;
543
+ case "tiff":
544
+ case "tif":
545
+ await a.tiff({ compression: "lzw" }).toFile(t);
546
+ break;
547
+ default: await a.jpeg(r ? {
548
+ quality: 100,
549
+ mozjpeg: !0,
550
+ chromaSubsampling: "4:4:4"
551
+ } : {
552
+ quality: 80,
553
+ mozjpeg: !0,
554
+ progressive: !0,
555
+ chromaSubsampling: "4:2:0"
556
+ }).toFile(t);
557
+ }
558
+ return !0;
559
+ }, tt = (e) => {
560
+ if (!e.length) return;
561
+ let t = e.map(({ file: e, from: t, to: n, status: r }) => {
562
+ let i = r === "失败" ? "-" : `${t ? ((t - n) / t * 100).toFixed(1) : "0.0"}%`;
563
+ return {
564
+ file: e,
565
+ from: Q(t),
566
+ to: r === "失败" ? "-" : Q(n),
567
+ saved: i,
568
+ status: r
569
+ };
570
+ }), r = {
571
+ file: "文件",
572
+ from: "原大小",
573
+ to: "新大小",
574
+ saved: "节省",
575
+ status: "状态"
576
+ }, i = Object.keys(r).reduce((e, n) => (e[n] = Math.max(O(r[n]), ...t.map((e) => O(e[n]))), e), {}), a = (e, t) => e + " ".repeat(t - O(e)), o = (e) => e === "压缩" ? n.green(e) : e === "转换" ? n.cyan(e) : e === "跳过" ? n.yellow(e) : n.red(e);
577
+ M(), M(n.bold(`${a(r.file, i.file)} ${a(r.from, i.from)} ${a(r.to, i.to)} ${a(r.saved, i.saved)} ${r.status}`)), M(n.gray("─".repeat(i.file + i.from + i.to + i.saved + i.status + 8))), t.forEach(({ file: e, from: t, to: n, saved: r, status: s }) => {
578
+ M(`${a(e, i.file)} ${a(t, i.from)} ${a(n, i.to)} ${a(r, i.saved)} ${o(s)}`);
579
+ });
580
+ };
581
+ t.command("mini <图片目录> [输出目录]").option("-e, --extension [扩展名]", "目标扩展名,如 png / jpg / webp / avif / tiff,默认保持原格式", "").option("--lossless", "使用无损压缩(体积更大,画质完全不变)", !1).description("压缩图片(默认 TinyPNG 风格智能有损,支持格式转换)").action(async (e, t, i) => {
582
+ let s = _(process.cwd(), e);
583
+ if (!a(s) || !d(s).isDirectory()) return j(`图片目录不存在:${s}`);
584
+ let c = !!i?.lossless, u = typeof i?.extension == "string" ? i.extension.replace(/^\./, "").trim().toLowerCase() : "";
585
+ if (u && !Qe.includes(u)) return j(`不支持的扩展名:${u},可选值:${Qe.join(" / ")}`);
586
+ let p = _(process.cwd(), t || g(s, "mini")), v = $e(s, [p, _(s, "mini")]);
587
+ if (!v.length) return M("未找到可处理的图片");
588
+ let b = y({
589
+ text: "正在压缩图片...",
590
+ color: "yellow"
591
+ }).start(), x = [];
592
+ for (let e of v) {
593
+ let t = Z(e), i = te(s, e), d = g(p, ee(i)), v = h(e).slice(1).toLowerCase(), y = u || v, S = y !== v, C = g(d, `${m(e, h(e))}.${y}`), w = _(C) === _(e), T = `${C}.mini-temp`, E = w ? T : C;
594
+ b.text = `正在处理 ${n.cyan(i)}`;
595
+ try {
596
+ o(d, { recursive: !0 });
597
+ let n = await et(e, E, y, c);
598
+ if (n && (S || Z(E) < t)) w && l(T, C), x.push({
599
+ file: i,
600
+ from: t,
601
+ to: Z(C),
602
+ status: S ? "转换" : "压缩"
603
+ });
604
+ else if (a(T) && f(T), n || w) x.push({
605
+ file: i,
606
+ from: t,
607
+ to: t,
608
+ status: "跳过"
609
+ });
610
+ else {
611
+ let n = S ? g(d, m(e)) : C;
612
+ _(n) !== _(e) && r(e, n), x.push({
613
+ file: i,
614
+ from: t,
615
+ to: t,
616
+ status: "跳过"
617
+ });
618
+ }
619
+ } catch (e) {
620
+ a(T) && f(T), x.push({
621
+ file: i,
622
+ from: t,
623
+ to: 0,
624
+ status: "失败"
625
+ }), b.stop(), j(`${i} 处理失败:${e?.message || e}`), b.start();
626
+ }
627
+ }
628
+ b.stop(), tt(x);
629
+ let S = x.filter(({ status: e }) => e === "压缩"), C = x.filter(({ status: e }) => e === "转换"), w = x.filter(({ status: e }) => e === "跳过"), T = x.filter(({ status: e }) => e === "失败"), E = x.reduce((e, { from: t }) => e + t, 0), D = x.reduce((e, { from: t, to: n, status: r }) => e + (r === "失败" ? t : n), 0), ne = E ? ((E - D) / E * 100).toFixed(1) : "0.0";
630
+ M(), A(`共 ${x.length} 张图片,压缩 ${S.length} 张,转换 ${C.length} 张,跳过 ${w.length} 张,失败 ${T.length} 张`), M(`${n.gray("模式")} ${c ? "无损" : "智能有损(TinyPNG 风格)"}`), M(`${n.gray("总计")} ${Q(E)} ${n.gray("→")} ${Q(D)} ${n.green(`节省 ${ne}%`)}`), M(n.green(`输出目录 ${p}`));
631
+ }), t.usage("[commands] [options]").version(oe, "-v, --version", "输出版本号").helpOption("-h, --help", "输出所有命令"), t.command("build[:环境] [描述]").description("简化打包提交命令"), t.command("version<[++]|[@<版本号>]>").description("例如:version++ 或者 version@1.0.0;自动更新 package.json 版本号,自动更新 `README.md` 中的 `version-v<version>-blue` 图标版本");
632
+ var nt = class extends e {
633
+ displayWidth(e) {
634
+ return O(e);
635
+ }
636
+ };
637
+ t.createHelp = () => new nt(), t.configureHelp({ sortSubcommands: !1 }), t.arguments("<cmd> [env]").action((e, t) => {
638
+ me(e, t);
639
+ }), process.argv.length < 3 ? t.help() : t.parse(process.argv);
640
+ // src/update.ts
641
+ var $ = ie({
642
+ pkg: k,
643
+ updateCheckInterval: 1e3
495
644
  });
496
- if ($.update && $.update.latest !== b.version) {
645
+ if ($.update && $.update.latest !== k.version) {
497
646
  let e = "";
498
647
  switch ($.update.type) {
499
648
  case "major":
500
- e = t.red("{latestVersion}");
649
+ e = n.red("{latestVersion}");
501
650
  break;
502
651
  case "minor":
503
- e = t.yellow("{latestVersion}");
504
- break;
505
- default:
506
- e = t.green("{latestVersion}");
652
+ e = n.yellow("{latestVersion}");
507
653
  break;
654
+ default: e = n.green("{latestVersion}");
508
655
  }
509
- let n = `https://github.com/biaov/${b.name}/compare/v${b.version}...v{latestVersion}`;
656
+ let t = `https://github.com/biaov/${k.name}/compare/v${k.version}...v{latestVersion}`;
510
657
  $.notify({
511
658
  defer: !1,
512
659
  isGlobal: !0,
513
- message: `有更新 ${t.dim("{currentVersion}")}${t.reset(" → ")}${e}\n运行 ${t.cyan("{updateCommand}@latest")} 命令更新\n${t.dim.underline(n)}`
660
+ message: `有更新 ${n.dim("{currentVersion}")}${n.reset(" → ")}${e}\n运行 ${n.cyan("{updateCommand}@latest")} 命令更新\n${n.dim.underline(t)}`
514
661
  });
515
662
  }
516
- //#endregion
@@ -1,4 +1,4 @@
1
- //#region src/config/keyword.ts
1
+ // src/config/keyword.ts
2
2
  var e = {
3
3
  "Auto-compact": "自动压缩",
4
4
  "Switch models when a message is flagged": "当消息被标记时切换模型",
@@ -144,5 +144,4 @@ var e = {
144
144
  "accept edits": "接受编辑",
145
145
  "Search settings…": "搜索设置…"
146
146
  };
147
- //#endregion
148
147
  export { e as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mine-auto-cli",
3
3
  "private": false,
4
- "version": "2.8.2",
4
+ "version": "2.9.0",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",
@@ -46,15 +46,17 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@avmc/bun-extractor": "^0.5.1",
49
- "chalk": "^5.6.2",
49
+ "chalk": "^6.0.1",
50
50
  "commander": "^15.0.0",
51
51
  "download-git-repo": "^3.0.2",
52
- "inquirer": "^14.0.2",
53
- "js-yaml": "^5.1.0",
52
+ "inquirer": "^14.2.5",
53
+ "js-yaml": "^5.5.0",
54
54
  "log-symbols": "^7.0.1",
55
55
  "ora": "^9.4.1",
56
- "pacote": "^22.0.0",
56
+ "pacote": "^22.0.1",
57
57
  "semver-utils": "^1.1.4",
58
+ "sharp": "^0.35.5",
59
+ "string-width": "^8.3.0",
58
60
  "strip-json-comments": "^5.0.3",
59
61
  "update-notifier": "^7.3.1"
60
62
  },
@@ -1,23 +0,0 @@
1
- var e = {
2
- permissions: {
3
- allow: [
4
- "Read(//**)",
5
- "Edit(//**)",
6
- "Delete(//**)",
7
- "Bash(*)"
8
- ],
9
- deny: ["Bash(git *)"],
10
- defaultMode: "acceptEdits"
11
- },
12
- enabledPlugins: {
13
- "context7@claude-plugins-official": !0,
14
- "frontend-design@claude-plugins-official": !0,
15
- "superpowers@claude-plugins-official": !0,
16
- "claude-mem@thedotmack": !0,
17
- "code-simplifier@claude-plugins-official": !0
18
- },
19
- language: "Chinese",
20
- theme: "dark-daltonized"
21
- };
22
- //#endregion
23
- export { e as default };