mine-auto-cli 2.8.1 → 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
 
@@ -222,6 +223,12 @@ auto ai use deepseek
222
223
 
223
224
  # 查看命令更多帮助信息
224
225
  auto ai -h
226
+
227
+ # 设置 Claude Code 权限
228
+ auto ai config
229
+
230
+ # 查看 Claude Code 配置信息
231
+ auto ai config-ls
225
232
  ```
226
233
 
227
234
  ### 汉化 Claude Code
@@ -234,6 +241,27 @@ auto ai zh
234
241
  auto ai zh-restore
235
242
  ```
236
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
+
237
265
  ### 技术栈
238
266
 
239
267
  - `Vite` + `TypeScript` + `NodeJs`
@@ -251,6 +279,7 @@ auto ai zh-restore
251
279
  - `ora`: 动画效果
252
280
  - `pacote`: 包信息请求器
253
281
  - `semver-utils`: 解析包版本
282
+ - `sharp`: 图片压缩
254
283
  - `strip-json-comments`: 移除 json 注释
255
284
  - `update-notifier`: 检查更新
256
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,23 +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 { join as c, resolve as l } from "path";
5
- import u from "log-symbols";
6
- import d from "ora";
7
- import { execSync as f } from "child_process";
8
- import * as p from "js-yaml";
9
- import ee from "strip-json-comments";
10
- import te from "pacote";
11
- import { parseRange as m } from "semver-utils";
12
- import ne from "download-git-repo";
13
- import h from "inquirer";
14
- import g from "os";
15
- import re from "update-notifier";
16
- //#region package.json
17
- var ie = "mine-auto-cli", ae = "2.8.1", _ = {
18
- name: ie,
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,
19
22
  private: !1,
20
- version: ae,
23
+ version: oe,
21
24
  exports: "./dist/index.js",
22
25
  main: "./dist/index.js",
23
26
  type: "module",
@@ -59,171 +62,168 @@ var ie = "mine-auto-cli", ae = "2.8.1", _ = {
59
62
  email: "biaov@qq.com"
60
63
  }],
61
64
  dependencies: {
62
- chalk: "^5.6.2",
65
+ "@avmc/bun-extractor": "^0.5.1",
66
+ chalk: "^6.0.1",
63
67
  commander: "^15.0.0",
64
68
  "download-git-repo": "^3.0.2",
65
- inquirer: "^14.0.2",
66
- "js-yaml": "^5.1.0",
69
+ inquirer: "^14.2.5",
70
+ "js-yaml": "^5.5.0",
67
71
  "log-symbols": "^7.0.1",
68
72
  ora: "^9.4.1",
69
- pacote: "^22.0.0",
73
+ pacote: "^22.0.1",
70
74
  "semver-utils": "^1.1.4",
75
+ sharp: "^0.35.5",
76
+ "string-width": "^8.3.0",
71
77
  "strip-json-comments": "^5.0.3",
72
78
  "update-notifier": "^7.3.1"
73
79
  },
74
80
  devDependencies: {
75
81
  "@types/js-yaml": "^4.0.9",
76
- "@types/node": "^26.0.0",
82
+ "@types/node": "^26.6.6",
77
83
  "@types/pacote": "^11.1.8",
78
84
  "@types/semver-utils": "^1.1.3",
79
85
  "@types/update-notifier": "^6.0.8",
80
- prettier: "^3.8.4",
81
- typescript: "^6.0.3",
82
- vite: "^8.1.0"
86
+ prettier: "^3.9.10",
87
+ typescript: "^7.0.2",
88
+ vite: "^8.3.5"
83
89
  }
84
- }, v = (e) => {
85
- console.log(`${u.success} ${t.green("SUCCESS")} ${e}`);
86
- }, y = (e) => {
87
- console.log(`${ie} ${u.error} ${t.red("ERROR")} ${e}`);
88
- }, b = (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) => {
89
95
  console.log(e ?? "");
90
- }, oe = (e) => {
91
- b(`开始执行 ${t.cyanBright(e)} 命令`);
92
- let n = d({
96
+ }, se = (e) => {
97
+ M(`开始执行 ${n.cyanBright(e)} 命令`);
98
+ let t = y({
93
99
  text: "正在执行命令中...",
94
100
  color: "yellow"
95
101
  });
96
- n.start(), b(f(e, { cwd: process.cwd() }).toString()), n.succeed(`${t.green(e)} 命令执行成功`), b();
97
- }, se = (e) => [
102
+ t.start(), M(b(e, { cwd: process.cwd() }).toString()), t.succeed(`${n.green(e)} 命令执行成功`), M();
103
+ }, ce = (e) => [
98
104
  "git add -A",
99
105
  `git commit -m ${e}`,
100
106
  "git push"
101
- ], ce = (e, t) => [
107
+ ], le = (e, t) => [
102
108
  `npm run ${e}`,
103
109
  "git add -A",
104
110
  `git commit -m ${t}`,
105
111
  "git push"
106
- ], le = async (e, n = "打包") => {
107
- b(), b(`${t.yellow(">>")} 开始依次执行命令...`), b(), ce(e, n).map(oe), v("全部命令执行完成"), b();
108
- }, x = (t) => {
109
- b(), y(`\`${t}\` 命令错误,请检查你的命令`), b(), e.help();
110
- }, S = (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) => {
111
117
  let [t, n] = ["package.json", "README.md"].map((e) => {
112
- let t = c(process.cwd(), e);
118
+ let t = g(process.cwd(), e);
113
119
  return {
114
120
  path: t,
115
- content: i(t).toString()
121
+ content: s(t).toString()
116
122
  };
117
123
  }), r = JSON.parse(t.content);
118
- 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);
119
- }, 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) => {
120
126
  let t = e.split("version")[1];
121
- if (!t) return x(e);
122
- let n = JSON.parse(i(c(process.cwd(), "package.json")).toString());
127
+ if (!t) return de(e);
128
+ let n = JSON.parse(s(g(process.cwd(), "package.json")).toString());
123
129
  if (t === "++") {
124
- S(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), b(), v("命令执行完成");
130
+ fe(n.version.split(".").reduce((e, t, n, r) => e + (n === r.length - 1 ? +t + 1 : `${t}.`), "")), M(), A("命令执行完成");
125
131
  return;
126
132
  }
127
133
  let r = t.split("@")[1];
128
- r ? (S(r), b(), v("命令执行完成")) : x(e);
129
- }, de = (n, r) => {
130
- if (n.includes("build")) return le(n, r);
131
- if (n.includes("version")) return ue(n);
132
- y(t.hex("#f56c6c")(`\`auto ${n}${r ? ` ${r}` : ""}\` 命令不存在`)), e.help();
133
- }, C = "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";
134
140
  Object.keys({
135
- vue: C,
136
- react: C,
137
- "uni-app": C,
138
- electron: C,
139
- node: C,
140
- "node-simple": C
141
+ vue: N,
142
+ react: N,
143
+ "uni-app": N,
144
+ electron: N,
145
+ node: N,
146
+ "node-simple": N
141
147
  }).reduce((e, t, n) => e + (n ? ", " : "") + t, "");
142
- var w = (e = "jsonc") => `auto-cli.${e}`;
143
- l(import.meta.dirname, "./presetData.json");
144
- var T = (e, t = !1) => {
145
- if (!r(e)) return t ? {} : "";
146
- let n = i(e).toString();
147
- return t ? JSON.parse(ee(n)) : n;
148
- }, fe = (e) => {
149
- if (!r(e)) return {};
150
- 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();
151
157
  try {
152
- return p.load(t);
158
+ return x.load(t);
153
159
  } catch {
154
160
  return {};
155
161
  }
156
- }, E = (e = !1) => T(l(import.meta.dirname, w()), e), D = () => {
157
- let [e, t] = [w(), w("yml")].map((e) => l(process.cwd(), e)), n = E(!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);
158
164
  try {
159
- Object.assign(n, fe(t), T(e, !0));
165
+ Object.assign(n, he(t), F(e, !0));
160
166
  } catch {}
161
167
  return n;
162
- }, pe = (e, t = !1) => {
163
- let n = E(t);
168
+ }, ge = (e, t = !1) => {
169
+ let n = I(t);
164
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;
165
- }, O = (e, t, n = " ") => Array.from({ length: t - e }, () => n).join("");
166
- e.command("init").option("-f, --force", `强制替换 ${w()} 文件内容`, !1).option("--unc, --uncomment", `取消生成 ${w()} 带注释`, !1).option("-y, --yml", `生成 ${w("yml")} 文件`, !1).description("初始化配置文件").action(({ yml: e, uncomment: n, force: i }) => {
167
- b();
168
- let a = w(e ? "yml" : "jsonc"), o = l(process.cwd(), a);
169
- if (r(o) && !i) {
170
- b(t.yellow(`${a} 文件已存在`)), b(), b(t.yellow(`文件目录 ${o}`));
171
- return;
172
- }
173
- s(o, pe(a, n)), v(`${a} 文件创建成功`), b(), b(t.green(`文件目录 ${o}`));
174
- }), e.command("git [描述]").description("简化 Git 提交命令").action(async (e = "更新代码") => {
175
- b(), b(`${t.yellow(">>")} 开始依次执行命令...`), b(), se(e).forEach(oe), v("全部命令执行完成"), b();
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();
176
178
  });
177
- //#endregion
178
- //#region src/commander/commands/mkdir.ts
179
- var k = [
179
+ // src/commander/commands/mkdir.ts
180
+ var ve = [
180
181
  "dist",
181
182
  "node_modules",
182
183
  ".git",
183
184
  "miniprogram_npm"
184
- ], A = 0, j = !1, M = !1, N = 20, P = ({ prev: e, i: t, index: n, arr: r, curText: i }) => {
185
- 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: N + A - s }).reduce((e) => `${e}-`, " ");
186
- return !j && (A = Math.max(A, s)), `${o}${i}${M ? c : ""}\n`;
187
- }, F = (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) => {
188
189
  let a;
189
- return n.children ? (a = `├── ${n.name}`, P({
190
+ return n.children ? (a = `├── ${n.name}`, xe({
190
191
  prev: e,
191
192
  i: t,
192
193
  index: r,
193
194
  arr: i,
194
195
  curText: a
195
- }) + F(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, P({
196
+ }) + V(n.children, t + 1)) : (a = `${r === i.length - 1 ? "└── " : "├── "}${n.name}`, xe({
196
197
  prev: e,
197
198
  i: t,
198
199
  index: r,
199
200
  arr: i,
200
201
  curText: a
201
202
  }));
202
- }, ""), I = (e) => a(e, { withFileTypes: !0 }).sort((e, t) => t.isDirectory() - +e.isDirectory());
203
- e.command("mkdir").option("-l, --line [数量]", "数量", !1).option("-n, --name [文件名称]", "文件名称", !1).option("-d, --depth [深度值]", "深度值", "3").description("生成目录结构文件").action(({ line: e, name: t }) => {
204
- M = !!e, typeof e == "string" && (N = +e);
205
- let n = process.cwd(), a = c(n, ".gitignore");
206
- if (r(a)) {
207
- let e = i(a).toString().split("\r\n");
208
- k.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);
209
210
  }
210
- let o = [{
211
+ let i = [{
211
212
  name: n.split("\\").at(-1),
212
- children: I(n).map((e) => {
213
+ children: Se(n).map((e) => {
213
214
  let { name: t } = e, n = { name: t };
214
- return !k.includes(t) && e.isDirectory() && (n.children = I(c(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;
215
216
  })
216
217
  }];
217
- M && (F(o), j = !0), s(c(n, `${typeof t == "string" && t || "directory"}.md`), F(o));
218
+ B && (V(i), ye = !0), p(g(n, `${typeof t == "string" && t || "directory"}.md`), V(i));
218
219
  });
219
- //#endregion
220
- //#region src/commander/commands/check.ts
221
- var L = D(), [R] = ["package.json"].map((e) => l(process.cwd(), e)), me = (e, n) => {
222
- 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);
223
223
  process.stdout.write(i);
224
- }, he = (e, t, n) => {
224
+ }, we = (e, t, n) => {
225
225
  let r = "latest";
226
- return L.resolve.some((t) => {
226
+ return H.resolve.some((t) => {
227
227
  let n = t.lastIndexOf("@");
228
228
  if (n <= 0) return !0;
229
229
  let i = t.slice(0, n), a = t.slice(n + 1);
@@ -231,25 +231,25 @@ var L = D(), [R] = ["package.json"].map((e) => l(process.cwd(), e)), me = (e, n)
231
231
  }), {
232
232
  name: e,
233
233
  value: t,
234
- newVersion: L.prefix + n[r],
234
+ newVersion: H.prefix + n[r],
235
235
  tag: r
236
236
  };
237
- }, ge = (e, t) => (+!t + 1) * e.length, z = (e) => {
238
- let [{ major: t = 0, minor: n = 0, patch: r = 0, release: i = "" }] = m(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);
239
239
  return [
240
240
  +t,
241
241
  +n,
242
242
  +r,
243
243
  i
244
244
  ];
245
- }, B = (e, n) => e ? "-" + t[n](e) : "", _e = (e, n) => {
246
- let [r, i, a, o] = z(e), [s, c, l, u] = z(n);
247
- return s > r ? t.red(n) : s < r ? !1 : c > i ? `${s}.${t.yellow(c)}.${t.yellow(l)}${B(u, "yellow")}` : c < i ? !1 : l > a ? `${s}.${c}.${t.green(l)}${B(u, "green")}` : l === a && u && u !== o ? `${s}.${c}.${l}${B(u, "green")}` : !1;
248
- }, ve = (e) => {
249
- 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 = {};
250
250
  e.forEach((e) => {
251
- Object.entries(e).forEach(([e, t]) => {
252
- 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);
253
253
  });
254
254
  }), e.unshift({
255
255
  name: "包名",
@@ -264,91 +264,88 @@ var L = D(), [R] = ["package.json"].map((e) => l(process.cwd(), e)), me = (e, n)
264
264
  value: i,
265
265
  newVersion: a,
266
266
  tag: o
267
- }).map(([e, t]) => O(ge(t, s), n[e])), f = t.yellow("→"), p = !0;
267
+ }).map(([e, n]) => R(Te(n, s), t[e])), f = n.yellow("→"), p = !0;
268
268
  if (s) {
269
- let e = _e(i, a);
269
+ let e = De(i, a);
270
270
  e ? a = e : p = !1;
271
- } else e = t.green(e), i = t.green(i), a = t.green(a), o = t.green(o), f = " ";
272
- let ee = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
273
- p && r.push(ee);
274
- }), r.length > 1 ? r.forEach(b) : v("所有版本已是最新");
275
- }, ye = async (e, t, n) => {
276
- b();
271
+ } else e = n.green(e), i = n.green(i), a = n.green(a), o = n.green(o), f = " ";
272
+ let m = `${e + c} ${l + i} ${f} ${u + a} ${d + o}`;
273
+ p && r.push(m);
274
+ }), r.length > 1 ? r.forEach(M) : A("所有版本已是最新");
275
+ }, ke = async (e, t, n) => {
276
+ M();
277
277
  let r = 0, i = [], a = Object.entries(e), o = a.map(async ([e, o]) => {
278
- let s = he(e, o, (await te.packument(e, { registry: L.registry }))["dist-tags"]);
278
+ let s = we(e, o, (await C.packument(e, { registry: H.registry }))["dist-tags"]);
279
279
  i.push(s), t.forEach((t) => {
280
280
  let r = n[t];
281
281
  r && r[e] && (r[e] = s.newVersion);
282
- }), r++, await me(r, a.length);
282
+ }), r++, await Ce(r, a.length);
283
283
  });
284
- return await Promise.all(o), b(), b(), i;
284
+ return await Promise.all(o), M(), M(), i;
285
285
  };
286
- e.command("check").option("-u, --update", "更新 package.json 依赖内容", !1).description("升级 package.json 依赖版本").action(async ({ update: e }) => {
287
- if (!r(R)) return y("package.json 文件不存在");
288
- let t = e || L.check, n = i(R).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 = [
289
289
  "dependencies",
290
290
  "devDependencies",
291
291
  "optionalDependencies"
292
- ], c = {}, l = JSON.parse(n);
293
- o.forEach((e) => {
294
- a[e] && Object.entries(a[e]).forEach(([e, t]) => {
295
- !L.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);
296
296
  });
297
297
  });
298
- let u = await ye(c, o, l);
299
- t ? (s(R, JSON.stringify(l, null, 2)), v("文件 package.json 已更新"), b()) : ve(u);
298
+ let l = await ke(o, i, c);
299
+ t ? (p(U, JSON.stringify(c, null, 2)), A("文件 package.json 已更新"), M()) : Oe(l);
300
300
  });
301
- //#endregion
302
- //#region src/commander/commands/comment.ts
303
- var be = D(), V = "comment.md", [H, U] = ["package.json", V].map((e) => l(process.cwd(), e));
304
- e.command("comment").description("生成依赖注释文件").action(() => {
305
- if (!r(H)) return y("package.json 文件不存在");
306
- let e = i(H).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 = [
307
306
  "dependencies",
308
307
  "devDependencies",
309
308
  "optionalDependencies"
310
- ], o = "### 依赖解析\n\n";
311
- a.forEach((e) => {
312
- n[e] && (o += `#### ${e}\n\n`, Object.keys(n[e]).forEach((e) => {
313
- o += `- \`${e}\`: ${be.comment[e] || ""}\n`;
314
- }), o += "\n");
315
- }), o = o.slice(0, -1), s(U, o), b(), v(`${V} 文件创建成功`), b(), b(t.green(`文件目录 ${U}`));
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}`));
316
315
  });
317
- //#endregion
318
- //#region src/commander/commands/vscode.ts
319
- var W = {
316
+ // src/commander/commands/vscode.ts
317
+ var Pe = {
320
318
  recursive: !0,
321
319
  force: !0
322
320
  };
323
- e.command("vscode-config").description("更新 .vscode 配置文件").action(() => {
324
- let e = `${+/* @__PURE__ */ new Date()}`, t = c(process.cwd()), r = c(t, e);
325
- ne("direct:https://gitee.com/biaovorg/vscode-config.git#master", r, { clone: !0 }, async (e) => {
326
- !e && n(c(r, ".vscode"), c(t, ".vscode"), W), o(r, W);
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);
327
325
  });
328
326
  });
329
- //#endregion
330
- //#region src/commander/commands/node.ts
331
- var G = (e, t, n) => {
327
+ // src/commander/commands/node.ts
328
+ var Fe = (e, t, n) => {
332
329
  let r = Object.entries(t), i = r.findIndex(([t]) => e === t), [a, o] = r[i];
333
330
  if (o) {
334
- if (n[a] === o) return i === r.length - 1 ? !0 : G(r[i + 1][0], t, n);
331
+ if (n[a] === o) return i === r.length - 1 || Fe(r[i + 1][0], t, n);
335
332
  } else return !0;
336
- }, K = (e) => {
337
- e && (f(`nvm use ${e}`), b(), v(`切换成功 当前版本:${e}`), b());
338
- }, q = (e) => {
339
- e && f(`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}`);
340
337
  };
341
- e.command("node [版本号]").option("-i, --install", "是否安装此版本", !1).description("切换 node 版本,默认选择第一个版本").action((e, n) => {
342
- let r = m(f("nvm ls").toString()), [{ major: i, minor: a, patch: o }] = m(e), s = [], c = r.find((e) => {
343
- if (e.major === i) return s.push(e), G("minor", {
344
- minor: a,
345
- 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
346
343
  }, e);
347
344
  });
348
- if (c) K(c.semver);
349
- else if (b(), b(t.red(`输入的版本 ${e} 不存在`)), b(), s.length) {
350
- let t = s.map((e) => e.semver);
351
- h.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({
352
349
  type: "list",
353
350
  name: "preset",
354
351
  message: "请选择相似版本或输入版本进行安装:",
@@ -358,144 +355,308 @@ e.command("node [版本号]").option("-i, --install", "是否安装此版本", !
358
355
  "取消"
359
356
  ]
360
357
  }).then(({ preset: t }) => {
361
- if (t !== "取消") if (t === e) {
362
- if (!o) return;
363
- q(t);
364
- } else K(t);
358
+ if (t !== "取消") {
359
+ if (t === e) {
360
+ if (!s) return;
361
+ G(t);
362
+ } else Ie(t);
363
+ }
365
364
  });
366
365
  } else {
367
- if (!o) return;
368
- if (n.install) {
369
- q(e);
366
+ if (!s) return;
367
+ if (t.install) {
368
+ G(e);
370
369
  return;
371
370
  }
372
- h.prompt({
371
+ E.prompt({
373
372
  type: "confirm",
374
373
  name: "isInstall",
375
374
  message: `是否安装 ${e}?`
376
375
  }).then(({ isInstall: t }) => {
377
- t && q(e);
376
+ t && G(e);
378
377
  });
379
378
  }
380
379
  });
381
- //#endregion
382
- //#region src/commander/commands/ai.ts
383
- var J = [
380
+ // src/commander/commands/ai.ts
381
+ var K = [
384
382
  "ANTHROPIC_AUTH_TOKEN",
385
383
  "ANTHROPIC_BASE_URL",
386
384
  "ANTHROPIC_MODEL",
387
385
  "ANTHROPIC_SMALL_FAST_MODEL"
388
- ], xe = T(l(import.meta.dirname, "ai.jsonc"), !0), Se = Object.entries(xe)[0], Y = l(g.homedir(), ".claude/settings.json"), X = l(g.homedir(), ".claude/settings.local.json"), Z = l(g.homedir(), ".ai-model.json"), Ce = () => {
389
- r(Y) || (y(`${Y} 文件不存在,请先检查或者去安装 Claude Code`), process.exit(1));
390
- let e = JSON.parse(i(Y).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());
391
389
  return !e.env && (e.env = {}), e;
392
- }, we = () => {
393
- b(), r(Z) || (y("配置不存在,请先使用 `ai init` 初始化 AI 模型配置"), process.exit(1));
394
- let e = JSON.parse(i(Z).toString()), n = Object.entries(e).filter(([e, t]) => {
395
- if (e === Se[0]) return !1;
396
- let n = t.env, r = Se[1].env;
397
- return !(!n || J.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]));
398
396
  });
399
- return n.length || (b(`暂无已配置的 AI 模型,请先配置,路径 ${t.green(Z)}`), process.exit(1)), [n, e];
400
- }, Te = () => {
401
- if (b(), r(Z)) {
402
- b(`配置已存在,路径 ${t.green(Z)}`);
403
- return;
404
- }
405
- s(Z, JSON.stringify(xe, null, 2)), v(`配置已初始化,路径 ${t.green(Z)}`);
406
- }, Ee = (e) => e.replace(/[\u4e00-\u9fa5]/g, "aa").length, De = () => {
407
- let [e] = we(), n = 0, r = -1, i = Ce();
408
- e.forEach(([e, t], a) => {
409
- n = Math.max(n, Ee(e)), r < 0 && !J.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);
410
404
  }), e.forEach(([e, i], a) => {
411
405
  let { ANTHROPIC_BASE_URL: o } = i.env;
412
- b(`${a === r ? t.green("*") : " "} ${e} ${O(Ee(e), n + 4, "-")} ${o}`);
406
+ M(`${a === r ? n.green("*") : " "} ${e} ${R(Ve(e), t + 4, "-")} ${o}`);
413
407
  });
414
- }, Oe = async (e) => {
415
- let n = Ce(), [r, i] = we();
416
- r.some(([t]) => t === e) || (b(`模型 ${t.red(e)} 不存在`), process.exit(1)), J.some((t) => n.env[t] !== i[e].env[t]) ? (n.env = i[e].env, s(Y, JSON.stringify(n, null, 2)), v(`模型 ${t.green(e)} 已切换`)) : b(`当前正处于 ${t.green(e)} 模型,无需切换`);
417
- }, ke = () => {
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 = () => {
418
412
  let e = "@anthropic-ai/claude-code";
419
413
  try {
420
- f(`npm list -g ${e} --depth=0`).toString().trim().includes(e) || (y(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1));
421
- let i = f("npm root -g").toString().trim(), a = l(i, e, "cli.js"), o = l(i, e, "cli.bak.js"), s = l(i, e, "bin/claude.exe"), c = l(i, e, "bin/claude.bak.exe"), u = !1;
422
- return r(s) ? (!r(c) && n(s, c), u = !0) : !r(o) && n(a, o), {
423
- 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,
424
418
  cliPathBak: o,
425
419
  exePath: s,
426
- exePathBak: c,
420
+ exeZhPath: c,
421
+ exePathBak: l,
427
422
  isExistExe: u
428
423
  };
429
424
  } catch {
430
- y(t.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
425
+ j(n.red(`请使用 nodejs 安装 ${e}`)), process.exit(1);
431
426
  }
432
- }, Ae = async () => {
433
- b(), b("开始汉化 Claude Code");
434
- let { cliPath: e, exePath: t, exePathBak: n, isExistExe: r } = ke();
435
- if (r) {
436
- let e = i(n), r = (await import("./keyword-latest-Bj5j_G4f.js")).default;
437
- Object.entries(r).forEach(([t, n]) => {
438
- let r = Buffer.from(t, "utf8"), i = Buffer.from(n, "utf8");
439
- if (!e.includes(r) || i.length > r.length) return;
440
- let a = 0;
441
- for (; (a = e.indexOf(r, a)) !== -1;) i.copy(e, a), e.fill(32, a + i.length, a + r.length), a += r.length;
442
- }), s(t, e);
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);
433
+ return;
434
+ }
435
+ await Ye(e), i(r, n);
443
436
  } else {
444
- let t = i(e).toString(), n = (await import("./keyword-Bs4ml7oW.js")).default;
445
- s(e, 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]) => {
446
438
  let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
447
439
  return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
448
- }, t));
449
- }
450
- v("Claude Code 已汉化");
451
- }, je = () => {
452
- b(), b("开始恢复 Claude Code");
453
- let { cliPath: e, cliPathBak: t, exePath: r, exePathBak: i, isExistExe: a } = ke();
454
- a ? n(i, r) : n(t, e), v("Claude Code 已恢复成英文");
455
- }, Me = async () => {
456
- b();
457
- let e = (await import("./claude.settings-BShJAaF1.js")).default;
458
- s(X, JSON.stringify(e, null, 2)), v(`Claude Code 配置成功,请前往查看:${t.yellow(X)}`);
459
- }, Ne = async () => {
460
- if (b(), b("开始配置 Claude Code 默认权限"), b(), !r(X)) {
461
- Me();
462
- return;
440
+ }, e);
441
+ p(t, r);
463
442
  }
464
- h.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({
465
454
  type: "confirm",
466
455
  name: "isOk",
467
- message: "存在本地配置文件,继续配置会直接覆盖本地配置文件,是否继续 ?"
456
+ message: "存在本地配置文件,继续配置会直接覆盖本地配置文件里的属性内容,是否继续 ?"
468
457
  }).then(({ isOk: e }) => {
469
- e && Me();
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]) => {
464
+ let r = t.replace(/\n/g, "\\\\n").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = n.replace(/\n/g, "\\n");
465
+ return ["`", "\\"].includes(r[0]) ? e.replace(new RegExp(r, "g"), n) : e.replace(RegExp(`\"${r}\"`, "g"), `\"${i}\"`).replace(RegExp(`(\'${r}\')`, "g"), `\'${i}\'`);
466
+ }, d), h = Array.from(m).map((e) => {
467
+ let t = e.charCodeAt(0);
468
+ return t >= 19968 && t <= 40959 ? `\\u${t.toString(16).padStart(4, "0")}` : e;
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)}`);
470
579
  });
471
- }, Q = e.command("ai").description("AI 命令,详细操作请查看 ai -h").helpOption("-h, --help", "输出所有命令").helpCommand(!1);
472
- Q.command("init").description("初始化 AI 模型配置").action(Te), Q.command("ls").description("查看当前已配置的 AI 模型").action(De), Q.command("use <模型>").description("切换 AI 模型").action(Oe), Q.command("zh").description("汉化 Claude Code").action(Ae), Q.command("zh-restore").description("恢复汉化 Claude Code").action(je), Q.command("config").description("配置 Claude Code 默认权限").action(Ne), e.usage("[commands] [options]").version(ae, "-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) => {
473
- de(e, t);
474
- }), process.argv.length < 3 ? e.help() : e.parse(process.argv);
475
- //#endregion
476
- //#region src/update.ts
477
- var $ = re({
478
- pkg: _,
479
- updateCheckInterval: 1e3 * 1
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
480
644
  });
481
- if ($.update && $.update.latest !== _.version) {
645
+ if ($.update && $.update.latest !== k.version) {
482
646
  let e = "";
483
647
  switch ($.update.type) {
484
648
  case "major":
485
- e = t.red("{latestVersion}");
649
+ e = n.red("{latestVersion}");
486
650
  break;
487
651
  case "minor":
488
- e = t.yellow("{latestVersion}");
489
- break;
490
- default:
491
- e = t.green("{latestVersion}");
652
+ e = n.yellow("{latestVersion}");
492
653
  break;
654
+ default: e = n.green("{latestVersion}");
493
655
  }
494
- let n = `https://github.com/biaov/${_.name}/compare/v${_.version}...v{latestVersion}`;
656
+ let t = `https://github.com/biaov/${k.name}/compare/v${k.version}...v{latestVersion}`;
495
657
  $.notify({
496
658
  defer: !1,
497
659
  isGlobal: !0,
498
- 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)}`
499
661
  });
500
662
  }
501
- //#endregion
@@ -1,25 +1,39 @@
1
- //#region src/config/keyword.ts
1
+ // src/config/keyword.ts
2
2
  var e = {
3
3
  "Auto-compact": "自动压缩",
4
+ "Switch models when a message is flagged": "当消息被标记时切换模型",
4
5
  "Show tips": "显示提示",
5
6
  "Reduce motion": "减少动画效果",
6
7
  "Thinking mode": "深度思考模式",
8
+ "Session recap": "会话总结",
7
9
  "`Fast mode (${Ok} only)`": "`快速模式(仅限 ${Ok})`",
8
10
  "Prompt suggestions": "提示词建议",
9
- "Rewind code (checkpoints)": "代码回退(检查点)",
11
+ "Rewind code (checkpoints)": "代码回退(检查点)",
10
12
  "Verbose output": "详细输出",
11
13
  "Terminal progress bar": "终端进度条",
12
14
  "Show turn duration": "显示每轮耗时条",
15
+ "Dynamic workflows": "动态工作流",
16
+ "Ultracode keyword trigger": "Ultracode 关键词触发",
17
+ "Dynamic workflow size": "动态工作流大小",
13
18
  "Default permission mode": "默认权限模式",
19
+ "Worktree base ref": "工作树基础引用",
20
+ "Use auto mode during plan": "在计划中使用自动模式",
14
21
  "Respect .gitignore in file picker": "文件选择器中遵守 .gitignore 规则",
22
+ "Skip the /copy picker": "跳过 /copy 选择器",
23
+ "Open agents view by default": "默认打开智能体视图",
24
+ "opens agents": "打开智能体",
15
25
  "Always copy full response (skip /copy picker)": "始终复制完整回复(跳过 /copy 选择器)",
16
26
  "Auto-update channel": "自动更新频道",
17
27
  Theme: "主题",
18
28
  Notifications: "通知",
29
+ "Local notifications": "本地通知",
19
30
  "Output style": "输出风格",
20
31
  Language: "语言",
21
32
  "Editor mode": "编辑器模式",
33
+ "Question auto-continue timeout": "问题自动继续超时时间",
34
+ "Show last response in external editor": "在外部编辑器中显示最后一条回复",
22
35
  Model: "模型",
36
+ "Diff tool": "差异工具",
23
37
  "Auto-install IDE extension": "自动安装 IDE 扩展",
24
38
  "Enable Claude in Chrome by default": "默认启用 Chrome 中的 Claude",
25
39
  Usage: "使用量",
@@ -130,5 +144,4 @@ var e = {
130
144
  "accept edits": "接受编辑",
131
145
  "Search settings…": "搜索设置…"
132
146
  };
133
- //#endregion
134
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.1",
4
+ "version": "2.9.0",
5
5
  "exports": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "type": "module",
@@ -45,15 +45,18 @@
45
45
  }
46
46
  ],
47
47
  "dependencies": {
48
- "chalk": "^5.6.2",
48
+ "@avmc/bun-extractor": "^0.5.1",
49
+ "chalk": "^6.0.1",
49
50
  "commander": "^15.0.0",
50
51
  "download-git-repo": "^3.0.2",
51
- "inquirer": "^14.0.2",
52
- "js-yaml": "^5.1.0",
52
+ "inquirer": "^14.2.5",
53
+ "js-yaml": "^5.5.0",
53
54
  "log-symbols": "^7.0.1",
54
55
  "ora": "^9.4.1",
55
- "pacote": "^22.0.0",
56
+ "pacote": "^22.0.1",
56
57
  "semver-utils": "^1.1.4",
58
+ "sharp": "^0.35.5",
59
+ "string-width": "^8.3.0",
57
60
  "strip-json-comments": "^5.0.3",
58
61
  "update-notifier": "^7.3.1"
59
62
  },
@@ -1,24 +0,0 @@
1
- var e = {
2
- permissions: {
3
- allow: [
4
- "Read",
5
- "Write",
6
- "Edit",
7
- "Delete",
8
- "Bash(*)"
9
- ],
10
- deny: ["Bash(git *)"],
11
- defaultMode: "acceptEdits"
12
- },
13
- enabledPlugins: {
14
- "context7@claude-plugins-official": !0,
15
- "frontend-design@claude-plugins-official": !0,
16
- "superpowers@claude-plugins-official": !0,
17
- "claude-mem@thedotmack": !0,
18
- "code-simplifier@claude-plugins-official": !0
19
- },
20
- language: "Chinese",
21
- theme: "dark-daltonized"
22
- };
23
- //#endregion
24
- export { e as default };
@@ -1,95 +0,0 @@
1
- //#region src/config/keyword-latest.ts
2
- var e = {
3
- "Search settings": "搜索",
4
- "Auto-compact": "自动压缩",
5
- "Show tips": "提示",
6
- "Reduce motion": "减少动画",
7
- "Thinking mode": "深度思考",
8
- "Session recap": "会议",
9
- "Rewind code (checkpoints)": "代码回退",
10
- "Dynamic workflows": "动态工作流",
11
- "Ultracode keyword trigger": "关键词触发",
12
- "Verbose output": "详细输出",
13
- "Terminal progress bar": "进度条",
14
- "Show turn duration": "耗时条",
15
- "Default permission mode": "默认权限",
16
- "Worktree base ref": "工作树引用",
17
- "Use auto mode during plan": "计划时自动模式",
18
- "Respect .gitignore in file picker": "选择文件遵守.gitignore",
19
- "Skip the /copy picker": "跳过/copy选择",
20
- "Open agents view by default": "默认打开代理视图",
21
- "opens agents": "代理",
22
- "Auto-update channel": "自动更新",
23
- "Local notifications": "本地通知",
24
- "Output style": "输出风格",
25
- "\"Language\"": "\"语言\"",
26
- "Editor mode": "编辑",
27
- "Show last response in external editor": "显示最新回复",
28
- "Show PR status footer": "显示PR状态",
29
- "Auto-connect to IDE (external terminal)": "自动连接到IDE",
30
- "Auto-install IDE extension": "自动安装IDE扩展",
31
- "Diff tool": "对比",
32
- "Claude in Chrome enabled by default": "Claude在Chrome启用",
33
- "Welcome back!": "欢迎回来!",
34
- "Tips for getting started": "入门技巧",
35
- "What's new": "最新",
36
- "API Usage Billing": "API使用计费",
37
- "Run /init to create a CLAUDE.md file with instructions for Claude": "/init创建CLAUDE.md文件,包含 Claude 的说明",
38
- "Recent activity": "最近活动记录",
39
- "No recent activity": "暂无最近活动记录",
40
- "create a util logging.py that...": "创建logging.py,用于...",
41
- "Initialize a new CLAUDE.md file with codebase documentation": "初始化新的 CLAUDE.md 文件,写入相关文档说明",
42
- "Review changed code for reuse, quality, and efficiency, then fix any issues found.": "检查修改过的代码,评估其可复用性、代码质量和执行效率,然后修复发现的所有问题。",
43
- "Add a new working directory": "添加新的目录",
44
- "Clear conversation history and free up context": "清除对话历史记录,释放上下文空间",
45
- "Set the prompt bar color for this session": "设置本次会话的提示栏颜色",
46
- "Clear conversation history but keep a summary in context. Optional: /compact [instructions for summarization]": "清除对话历史记录,但在上下文中保留一份摘要。可选:/compact [摘要的自定义指令]",
47
- "Open config panel": "设置",
48
- "Copy Claude's last response to clipboard (or /copy N for the Nth-latest)": "复制 Claude 最新回复到剪贴板(/copy N复制第N条)",
49
- "Show the total cost and duration of the current session": "显示当前会话的总费用和持续时间",
50
- "Continue the current session in Claude Desktop": "在 Claude Desktop 中继续当前会话",
51
- "View uncommitted changes and per-turn diffs": "查看未提交的差异",
52
- "Diagnose and verify your Claude Code installation and settings": "诊断并验证 Claude Code 的安装和设置",
53
- "Set effort level for model usage": "设置模型使用等级",
54
- "Exit the REPL": "退出 REPL",
55
- "Export the current conversation to a file or clipboard": "将当前对话导出到文件或剪贴板",
56
- "Show help and available commands": "显示帮助和命令",
57
- "View hook configurations for tool events": "查看工具事件的钩子配置",
58
- "Manage IDE integrations and show status": "管理 IDE 集成并显示状态",
59
- "Set up Claude GitHub Actions for a repository": "为仓库配置 Claude GitHub Actions",
60
- "Install the Claude Slack app": "安装 Claude Slack 应用",
61
- "Sign in with your Anthropic account": "使用 Anthropic 账号登录",
62
- "Sign out from your Anthropic account": "退出 Anthropic 账号",
63
- "Manage MCP servers": "管理 MCP",
64
- "Edit Claude memory files": "编辑 Claude 记忆",
65
- "Show QR code to download the Claude mobile app": "显示二维码下载 Claude App",
66
- "Manage allow & deny tool permission rules": "管理工具的权限规则",
67
- "Enable plan mode or view the current session plan": "启用计划模式或查看当前会话计划",
68
- "Manage Claude Code plugins": "管理 Claude Code 插件",
69
- "View release notes": "查看发布说明",
70
- "Activate pending plugin changes in the current session": "在当前会话中激活待生效的插件更改",
71
- "Rename the current conversation": "重命名当前对话",
72
- "Resume a previous conversation": "恢复之前的对话",
73
- "Restore the code and/or conversation to a previous point": "将代码和/或对话恢复到之前的某个节点",
74
- "List available skills": "列出可用的技能",
75
- "Show your Claude Code usage statistics and activity": "显示 Claude Code 的使用统计和活动记录",
76
- "Show Claude Code status including version, model, account, API connectivity, and tool statuses": "显示 Claude Code 状态,包括版本、模型、账号、API 连接和工具状态",
77
- "Order Claude Code stickers": "订购 Claude Code 贴纸",
78
- "List and manage background tasks": "列出并管理后台任务",
79
- "Install Shift+Enter key binding for newlines": "安装 Shift+Enter 换行快捷键绑定",
80
- "Change the theme": "更改主题",
81
- "Upgrade to Max for higher rate limits and more Opus": "升级 Max 获得高速率和更多 Opus",
82
- "Show plan usage limits": "显示计划用量限制",
83
- "Toggle between Vim and Normal editing modes": "在 Vim 和普通编辑模式之间切换",
84
- "Generate a report analyzing your Claude Code sessions": "生成分析 Claude Code 会话的报告",
85
- "Get comments from a GitHub pull request": "获取 GitHub Pull Request 的评论",
86
- "Review a pull request": "审查 Pull Request",
87
- "Complete a security review of the pending changes on the current branch": "对当前分支的待提交更改进行安全审查",
88
- "Set up Claude Code's status line UI": "配置 Claude Code 的状态栏 UI",
89
- "Type to filter": "过滤",
90
- "Ask a quick side question without interrupting the main conversation": "提问一个临时问题,不打断主对话",
91
- "Config dialog dismissed": "对话框已关闭",
92
- "Manage agent configurations": "管理 Agent 配置"
93
- };
94
- //#endregion
95
- export { e as default };