@ckpack/ai-commit 1.0.2 → 1.0.4

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
@@ -26,7 +26,7 @@ pnpm add -g @ckpack/ai-commit
26
26
  在包含变更的 git 仓库中运行:
27
27
 
28
28
  ```bash
29
- ai-commit
29
+ ai-commit codex
30
30
  ```
31
31
 
32
32
  输出示例:
@@ -38,7 +38,7 @@ feat: add commit message generator
38
38
  你也可以直接调用源码(开发时):
39
39
 
40
40
  ```bash
41
- pnpm dev
41
+ pnpm dev -- codex
42
42
  ```
43
43
 
44
44
  ## 环境变量
@@ -49,7 +49,7 @@ pnpm dev
49
49
  示例:
50
50
 
51
51
  ```bash
52
- CODEX_BIN=codex CODEX_ARGS="exec" ai-commit
52
+ CODEX_BIN=codex CODEX_ARGS="exec" ai-commit codex
53
53
  ```
54
54
 
55
55
  ## 生成逻辑
package/dist/index.mjs CHANGED
@@ -2,8 +2,15 @@
2
2
  import { spawnSync } from "node:child_process";
3
3
  import { EOL } from "node:os";
4
4
  import process from "node:process";
5
+ import { consola } from "consola";
6
+ import { Command } from "commander";
5
7
 
6
- //#region src/index.ts
8
+ //#region src/command/codex.ts
9
+ function codex(program$1) {
10
+ program$1.command("codex", { isDefault: true }).action(() => {
11
+ runCodexCommand();
12
+ });
13
+ }
7
14
  function runCommand(command, args, options = {}) {
8
15
  const result = spawnSync(command, args, {
9
16
  encoding: "utf-8",
@@ -87,18 +94,36 @@ function fallbackMessage() {
87
94
  if (files.length === 0) return "chore: update changes";
88
95
  return `chore: update ${files.slice(0, 3).map((line) => line.replace(/^\S+\s+/, "")).join(", ")}${files.length > 3 ? ` and ${files.length - 3} more` : ""}`;
89
96
  }
90
- function main() {
97
+ function runCodexCommand() {
91
98
  try {
92
99
  const candidate = sanitizeMessage(tryCodex(buildPrompt(ensureNonEmptyDiff())) ?? "");
93
100
  const message = isConventional(candidate) ? candidate : fallbackMessage();
94
- console.log(message);
101
+ consola.log(message);
95
102
  } catch (error) {
96
103
  const fallback = fallbackMessage();
97
- console.warn(`[commit-msg] ${error instanceof Error ? error.message : String(error)}. Using fallback message.`);
98
- console.log(fallback);
104
+ consola.warn(`[commit-msg] ${error instanceof Error ? error.message : String(error)}. Using fallback message.`);
105
+ consola.log(fallback);
99
106
  }
100
107
  }
101
- main();
108
+
109
+ //#endregion
110
+ //#region src/command/index.ts
111
+ function initCommand(program$1) {
112
+ codex(program$1);
113
+ }
114
+
115
+ //#endregion
116
+ //#region package.json
117
+ var name = "@ckpack/ai-commit";
118
+ var version = "1.0.4";
119
+ var description = "根据 git diff 信息 生成符合 Conventional Commits 的提交信息.";
120
+
121
+ //#endregion
122
+ //#region src/index.ts
123
+ const program = new Command();
124
+ program.name(name).description(description).version(version);
125
+ initCommand(program);
126
+ program.parse();
102
127
 
103
128
  //#endregion
104
129
  export { };
package/package.json CHANGED
@@ -1,23 +1,27 @@
1
1
  {
2
2
  "name": "@ckpack/ai-commit",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "private": false,
6
6
  "packageManager": "pnpm@10.12.1+sha512.f0dda8580f0ee9481c5c79a1d927b9164f2c478e90992ad268bbb2465a736984391d6333d2c327913578b2804af33474ca554ba29c04a8b13060a717675ae3ac",
7
- "description": "使用 Codex 根据 git diff 生成符合 Conventional Commits 的提交信息.",
7
+ "description": "根据 git diff 信息 生成符合 Conventional Commits 的提交信息.",
8
8
  "author": "ckvv",
9
9
  "license": "MIT",
10
10
  "repository": "https://github.com/ckpack/ai-commit",
11
+ "imports": {
12
+ "#command": "./src/command/index.ts",
13
+ "#command/*": "./src/command/*"
14
+ },
11
15
  "exports": {
12
- ".": "./dist/index.js",
16
+ ".": "./dist/index.mjs",
13
17
  "./package.json": "./package.json"
14
18
  },
19
+ "main": "./dist/index.mjs",
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
15
22
  "bin": {
16
- "ai-commit": "./dist/index.js"
23
+ "ai-commit": "./dist/index.mjs"
17
24
  },
18
- "main": "./dist/index.js",
19
- "module": "./dist/index.js",
20
- "types": "./dist/index.d.ts",
21
25
  "files": [
22
26
  "dist"
23
27
  ],
@@ -30,9 +34,14 @@
30
34
  "publish:npm": "npm run build && npm publish --registry https://registry.npmjs.org/ --access public",
31
35
  "release": "npx changelogen --release --push"
32
36
  },
37
+ "dependencies": {
38
+ "commander": "^14.0.2",
39
+ "consola": "^3.4.2"
40
+ },
33
41
  "devDependencies": {
34
- "@types/node": "^24",
35
42
  "@antfu/eslint-config": "^6.7.3",
43
+ "@commander-js/extra-typings": "^14.0.0",
44
+ "@types/node": "^24",
36
45
  "eslint": "^9.39.2",
37
46
  "lint-staged": "^16.2.7",
38
47
  "simple-git-hooks": "^2.13.1",
@@ -47,4 +56,4 @@
47
56
  "eslint --fix"
48
57
  ]
49
58
  }
50
- }
59
+ }