@zzclub/z-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/readme.md +47 -78
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzclub/z-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "all-in-one 工具箱,专为提升日常及工作效率而生",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -39,10 +39,10 @@
39
39
  "type-check": "bun run tsc --noEmit",
40
40
  "prepublishOnly": "bun run type-check && bun run build",
41
41
  "release": "bun run release:patch",
42
- "release:patch": "bunx changelogen@latest --patch --release --push --publish",
43
- "release:minor": "bunx changelogen@latest --minor --release --push --publish",
44
- "release:major": "bunx changelogen@latest --major --release --push --publish",
45
- "release:main": "bunx changelogen@latest -r 1.0.0 --release --push --publish"
42
+ "release:patch": "bunx changelogen@latest --patch --release --push",
43
+ "release:minor": "bunx changelogen@latest --minor --release --push",
44
+ "release:major": "bunx changelogen@latest --major --release --push",
45
+ "release:main": "bunx changelogen@latest -r 1.0.0 --release --push"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=18.18.0",
package/readme.md CHANGED
@@ -222,105 +222,74 @@ z config --reset
222
222
  }
223
223
  ```
224
224
 
225
- ## 🔌 Skills 集成指南
225
+ ## 🔌 Skills 中使用
226
226
 
227
- 如果你想在 OpenCode Skills 或其他自动化工具中使用 z-cli,可以通过以下方式集成:
227
+ 如果你想在 OpenCode Skills 或其他自动化脚本中使用 z-cli,推荐使用 `bunx` 或 `npx` 调用。
228
228
 
229
- ### 方式 1: 直接调用命令
229
+ ### 前置要求
230
230
 
231
- ```typescript
232
- // 在 skill 中使用 bash 工具调用
233
- import { bash } from './tools';
231
+ 确保已安装 Bun 或 Node.js:
234
232
 
235
- // 压缩图片
236
- await bash('z tiny -f ./images -r -q 85');
233
+ ```bash
234
+ # 检查 Bun 是否安装
235
+ bun --version
237
236
 
238
- // 获取配置
239
- await bash('z config');
237
+ # 如果未安装,安装 Bun(推荐)
238
+ curl -fsSL https://bun.sh/install | bash # macOS/Linux
239
+ # 或
240
+ powershell -c "irm bun.sh/install.ps1 | iex" # Windows
240
241
  ```
241
242
 
242
- ### 方式 2: 编程调用(需要源码集成)
243
+ ### 基础用法
243
244
 
244
- ```typescript
245
- // 如果需要编程式调用,可以直接导入模块
246
- import { ImageCompressor } from '@zzclub/z-cli/dist/commands/tiny/compressor.js';
247
- import { FileProcessor } from '@zzclub/z-cli/dist/commands/tiny/file-processor.js';
245
+ ```bash
246
+ # 使用 bunx(推荐)
247
+ bunx @zzclub/z-cli tiny -f ./images -r -q 85
248
+
249
+ # 或使用 npx(Node.js)
250
+ npx @zzclub/z-cli tiny -f ./images -r -q 85
251
+ ```
248
252
 
249
- // 创建压缩器
250
- const compressor = new ImageCompressor({ quality: 80 });
253
+ ### 在 Skill 的 skill.md 中使用
251
254
 
252
- // 压缩单个文件
253
- const result = await compressor.compress('./image.jpg', './output.jpg');
254
- console.log(`压缩率: ${result.compressionRatio}%`);
255
+ 直接在你的 Skill 说明中添加压缩命令即可:
255
256
 
256
- // 批量处理
257
- const processor = new FileProcessor(compressor, {
258
- recursive: true,
259
- overwrite: false,
260
- outputDir: './compressed'
261
- });
257
+ ```markdown
258
+ ## 图片处理流程
262
259
 
263
- const stats = await processor.process('./images');
264
- console.log(`成功: ${stats.successful}, 失败: ${stats.failed}`);
260
+ 1. 下载图片到 `./downloads` 目录
261
+ 2. 压缩图片:
262
+ ```bash
263
+ bunx @zzclub/z-cli tiny -f ./downloads -r -q 85 --output ./compressed
264
+ ```
265
+ 3. 上传压缩后的图片
265
266
  ```
266
267
 
267
- ### 方式 3: 在 MCP Skill 中配置
268
-
269
- 如果你要创建一个图片压缩 Skill,可以在 `skill.json` 中配置:
268
+ ### 常用命令
270
269
 
271
- ```json
272
- {
273
- "name": "image-compressor",
274
- "version": "1.0.0",
275
- "description": "使用 z-cli 压缩图片",
276
- "dependencies": {
277
- "@zzclub/z-cli": "^1.0.0"
278
- },
279
- "commands": {
280
- "compress": {
281
- "command": "z tiny -f {{file}} -q {{quality}} {{flags}}",
282
- "parameters": {
283
- "file": {
284
- "type": "string",
285
- "required": true,
286
- "description": "要压缩的文件或目录"
287
- },
288
- "quality": {
289
- "type": "number",
290
- "default": 80,
291
- "description": "压缩质量 (1-100)"
292
- },
293
- "flags": {
294
- "type": "string",
295
- "default": "",
296
- "description": "额外的标志,如 -r -o"
297
- }
298
- }
299
- }
300
- }
301
- }
302
- ```
270
+ ```bash
271
+ # 压缩单个文件
272
+ bunx @zzclub/z-cli tiny -f ./image.jpg -q 80
303
273
 
304
- ### 方式 4: 作为子进程调用
274
+ # 递归压缩目录
275
+ bunx @zzclub/z-cli tiny -f ./images -r -q 85
305
276
 
306
- ```typescript
307
- import { spawn } from 'child_process';
277
+ # 压缩并覆盖原文件
278
+ bunx @zzclub/z-cli tiny -f ./images -r -o
308
279
 
309
- function compressImage(file: string, quality: number = 80): Promise<void> {
310
- return new Promise((resolve, reject) => {
311
- const process = spawn('z', ['tiny', '-f', file, '-q', quality.toString()]);
312
-
313
- process.on('close', (code) => {
314
- if (code === 0) resolve();
315
- else reject(new Error(`压缩失败,退出码: ${code}`));
316
- });
317
- });
318
- }
280
+ # 压缩到指定目录
281
+ bunx @zzclub/z-cli tiny -f ./images -r --output ./compressed
319
282
 
320
- // 使用
321
- await compressImage('./image.jpg', 85);
283
+ # 查看帮助
284
+ bunx @zzclub/z-cli --help
322
285
  ```
323
286
 
287
+ ### 优势
288
+
289
+ - ✅ **自动安装依赖** - bunx/npx 会自动下载 z-cli 及其依赖(包括 Sharp)
290
+ - ✅ **无需全局安装** - 每次运行时自动使用最新版本
291
+ - ✅ **简单直接** - 一行命令完成压缩
292
+
324
293
  ## 🛠️ 开发
325
294
 
326
295
  ### 克隆仓库