@kud/ai-conventional-commit-cli 0.8.1 → 0.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -79,7 +79,14 @@ var parseDiffFromRaw = (raw) => {
79
79
  };
80
80
  var parseDiff = async () => {
81
81
  const raw = await getStagedDiffRaw();
82
- return parseDiffFromRaw(raw);
82
+ const parsed = parseDiffFromRaw(raw);
83
+ if (parsed.length === 0) {
84
+ const status = await git.status();
85
+ if (status.staged.length) {
86
+ return status.staged.map((f) => ({ file: f, hunks: [], additions: 0, deletions: 0 }));
87
+ }
88
+ }
89
+ return parsed;
83
90
  };
84
91
  var getRecentCommitMessages = async (limit) => {
85
92
  const log = await git.log({ maxCount: limit });
@@ -189,14 +196,18 @@ var buildGenerationMessages = (opts) => {
189
196
  );
190
197
  specLines.push("Primary Output Field: commits[ ].title");
191
198
  specLines.push("Title Format: <type>(<optional-scope>): <subject>");
192
- specLines.push("Max Title Length: 72 characters (hard limit)");
199
+ specLines.push(
200
+ "Title Length Guidance: Aim for <=50 chars ideal; absolute max 72 (do not exceed)."
201
+ );
193
202
  specLines.push("Types (JSON mapping follows on next line)");
194
203
  specLines.push("TypeMap: " + JSON.stringify(TYPE_MAP));
195
204
  specLines.push("Scope Rules: optional; if present, lowercase kebab-case; omit when unclear.");
196
205
  specLines.push(
197
206
  "Subject Rules: imperative mood, present tense, no leading capital unless proper noun, no trailing period."
198
207
  );
199
- specLines.push("Length Rule: Entire title line (including type/scope) must be <= 72 chars.");
208
+ specLines.push(
209
+ "Length Rule: Keep titles concise; prefer 50 or fewer chars; MUST be <=72 including type/scope."
210
+ );
200
211
  specLines.push(
201
212
  "Emoji Rule: " + (config.style === "gitmoji" || config.style === "gitmoji-pure" ? "OPTIONAL single leading gitmoji BEFORE the type only if confidently adds clarity; do not invent or stack; omit if unsure." : "Disallow all emojis and gitmoji codes; output must start directly with the type.")
202
213
  );
@@ -480,11 +491,10 @@ var normalizeConventionalTitle = (title) => {
480
491
  if (leadingEmoji) {
481
492
  result = `${leadingEmoji} ${result}`;
482
493
  }
483
- return result.slice(0, 72);
494
+ return result;
484
495
  };
485
496
  var checkCandidate = (candidate) => {
486
497
  const errs = [];
487
- if (candidate.title.length > 72) errs.push("Title exceeds 72 chars.");
488
498
  if (!CONVENTIONAL_RE.test(candidate.title)) {
489
499
  errs.push("Not a valid conventional commit title.");
490
500
  }
@@ -517,14 +527,13 @@ var EMOJI_MAP = {
517
527
  security: "\u{1F512}",
518
528
  release: "\u{1F3F7}\uFE0F"
519
529
  };
520
- var MAX_LEN = 72;
521
530
  var EMOJI_TYPE_RE = /^([\p{Emoji}\p{So}\p{Sk}])\s+(\w+)(\(.+\))?:\s+(.*)$/u;
522
531
  var TYPE_RE = /^(\w+)(\(.+\))?:\s+(.*)$/;
523
532
  var formatCommitTitle = (raw, opts) => {
524
533
  const { allowGitmoji, mode = "standard" } = opts;
525
534
  let norm = normalizeConventionalTitle(sanitizeTitle(raw, allowGitmoji));
526
535
  if (!allowGitmoji || mode !== "gitmoji" && mode !== "gitmoji-pure") {
527
- return norm.slice(0, MAX_LEN);
536
+ return norm;
528
537
  }
529
538
  if (mode === "gitmoji-pure") {
530
539
  let m2 = norm.match(EMOJI_TYPE_RE);
@@ -540,11 +549,11 @@ var formatCommitTitle = (raw, opts) => {
540
549
  } else if (!/^([\p{Emoji}\p{So}\p{Sk}])+:/u.test(norm)) {
541
550
  norm = `\u{1F527}: ${norm}`;
542
551
  }
543
- return norm.slice(0, MAX_LEN);
552
+ return norm;
544
553
  }
545
554
  let m = norm.match(EMOJI_TYPE_RE);
546
555
  if (m) {
547
- return norm.slice(0, MAX_LEN);
556
+ return norm;
548
557
  }
549
558
  if (m = norm.match(TYPE_RE)) {
550
559
  const type = m[1];
@@ -555,7 +564,7 @@ var formatCommitTitle = (raw, opts) => {
555
564
  } else if (!/^([\p{Emoji}\p{So}\p{Sk}])+\s+\w+.*:/u.test(norm)) {
556
565
  norm = `\u{1F527} chore: ${norm}`;
557
566
  }
558
- return norm.slice(0, MAX_LEN);
567
+ return norm;
559
568
  };
560
569
 
561
570
  // src/workflow/generate.ts
@@ -1115,7 +1124,7 @@ async function runRefine(config, options) {
1115
1124
  // package.json
1116
1125
  var package_default = {
1117
1126
  name: "@kud/ai-conventional-commit-cli",
1118
- version: "0.8.1",
1127
+ version: "0.9.0",
1119
1128
  type: "module",
1120
1129
  description: "Opinionated, style-aware AI assistant for crafting and splitting git commits (opencode-based, provider-agnostic).",
1121
1130
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/ai-conventional-commit-cli",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "Opinionated, style-aware AI assistant for crafting and splitting git commits (opencode-based, provider-agnostic).",
6
6
  "bin": {