@kyubiware/commit-mint 0.10.0 → 0.10.2

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/dist/bin.mjs CHANGED
@@ -33,7 +33,7 @@ var __exportAll = (all, no_symbols) => {
33
33
  //#region package.json
34
34
  var package_default = {
35
35
  name: "@kyubiware/commit-mint",
36
- version: "0.10.0",
36
+ version: "0.10.2",
37
37
  description: "🌿 AI-powered git commit tool — auto-group changed files, generate messages, run pre-commit checks",
38
38
  type: "module",
39
39
  bin: { "cmint": "./dist/bin.mjs" },
@@ -1756,8 +1756,8 @@ function buildGroupingUserPrompt(summary) {
1756
1756
  summary
1757
1757
  ].join("\n");
1758
1758
  }
1759
- function buildRetryGroupingPrompt() {
1760
- return [
1759
+ function buildRetryGroupingPrompt(groupCount) {
1760
+ const lines = [
1761
1761
  "PREVIOUS ATTEMPT FAILED: You grouped all files into a single group.",
1762
1762
  "",
1763
1763
  "You MUST split the files into at least 2 groups based on what changed and why.",
@@ -1778,7 +1778,12 @@ function buildRetryGroupingPrompt() {
1778
1778
  "files: array of exact file paths from the input",
1779
1779
  "",
1780
1780
  "Output ONLY valid JSON. No markdown fences, no explanation."
1781
- ].join("\n");
1781
+ ];
1782
+ if (groupCount && groupCount > 0) {
1783
+ lines[0] = "PREVIOUS ATTEMPT FAILED: You created the wrong number of groups.";
1784
+ lines[2] = `You MUST create exactly ${groupCount} groups. Do not create more or fewer.`;
1785
+ }
1786
+ return lines.join("\n");
1782
1787
  }
1783
1788
  /**
1784
1789
  * When a specific group count is requested but there are fewer included files
@@ -1826,9 +1831,9 @@ async function generateGroups(files, apiKey, model, timeout, provider, proxy, gr
1826
1831
  debug("generateGroups: parsed %d raw groups", rawGroups.length);
1827
1832
  let validated = validateGroups(rawGroups, included);
1828
1833
  debug("generateGroups: %d validated groups", validated.length);
1829
- if (isLowQualityGrouping(rawGroups, included)) {
1834
+ if (isLowQualityGrouping(rawGroups, included, groupCount)) {
1830
1835
  debug("generateGroups: low quality result, retrying with stricter prompt");
1831
- rawGroups = await callGroupingAI(client, resolvedModel, buildRetryGroupingPrompt(), userPrompt);
1836
+ rawGroups = await callGroupingAI(client, resolvedModel, buildRetryGroupingPrompt(groupCount), userPrompt);
1832
1837
  debug("generateGroups retry: parsed %d raw groups", rawGroups.length);
1833
1838
  validated = validateGroups(rawGroups, included);
1834
1839
  debug("generateGroups retry: %d validated groups", validated.length);
@@ -1864,9 +1869,10 @@ async function callGroupingAI(client, model, systemPrompt, userPrompt) {
1864
1869
  }
1865
1870
  /** Minimum file count where a single-group result is considered low quality */
1866
1871
  const MIN_FILES_FOR_QUALITY_CHECK = 5;
1867
- function isLowQualityGrouping(groups, allFiles) {
1872
+ function isLowQualityGrouping(groups, allFiles, groupCount) {
1868
1873
  if (allFiles.length === 0) return false;
1869
1874
  if (groups.length === 0) return true;
1875
+ if (groupCount && groupCount > 0 && groups.length !== groupCount) return true;
1870
1876
  if (allFiles.length < MIN_FILES_FOR_QUALITY_CHECK) return false;
1871
1877
  return groups.length === 1;
1872
1878
  }
@@ -3791,6 +3797,7 @@ async function fileMultiSelect(message, options, opts) {
3791
3797
  const prompt = new nt({
3792
3798
  options,
3793
3799
  required,
3800
+ initialValues: opts?.initialValues,
3794
3801
  input: opts?.input,
3795
3802
  output: opts?.output,
3796
3803
  validate: (values) => {
@@ -4009,7 +4016,10 @@ async function showStagingMenu(files, hasChecks) {
4009
4016
  const selected = await fileMultiSelect("Select files to stage:", sorted.map((f) => ({
4010
4017
  label: `${statusLabel(f.status)} ${f.path}`,
4011
4018
  value: f.path
4012
- })), { required: true });
4019
+ })), {
4020
+ required: true,
4021
+ initialValues: sorted.filter((f) => f.staged).map((f) => f.path)
4022
+ });
4013
4023
  if (p$1.isCancel(selected)) return null;
4014
4024
  return {
4015
4025
  files: selected,