@hifullmoon/aicommit 2.6.10 → 2.6.12

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/src/split.js CHANGED
@@ -75,6 +75,7 @@ import {
75
75
  invalidPlanMessages,
76
76
  applyMessageCorrections,
77
77
  summarizeChanges,
78
+ summarizeGroupChanges,
78
79
  } from './change-analysis.js';
79
80
  import { updateGitHash, spoolGit } from './git-spool.js';
80
81
  import { createAnalysisCache } from './analysis-cache.js';
@@ -1686,7 +1687,7 @@ export async function splitFlow(
1686
1687
  ['diff', u, '--cached'],
1687
1688
  ['diff', u],
1688
1689
  ];
1689
- const captured = captureChanges(commands, projectRoot, allFiles, config);
1690
+ const captured = captureChanges(commands, projectRoot, allFiles, config, { split: true });
1690
1691
  const diff = captured.diff || '';
1691
1692
  const untrackedSnapshot =
1692
1693
  scope === 'all'
@@ -1825,6 +1826,7 @@ export async function splitFlow(
1825
1826
  machineOutput,
1826
1827
  cancelMessage: 'Split cancelled.',
1827
1828
  failureMessage: 'Split planning failed',
1829
+ analysisBudget: planningConfig.analysisBudget,
1828
1830
  task: async (stream) => {
1829
1831
  if (large) {
1830
1832
  let plan;
@@ -2114,25 +2116,6 @@ export async function splitFlow(
2114
2116
  });
2115
2117
 
2116
2118
  for (const idx of picked) {
2117
- const rawGroupDiff = analysis
2118
- ? await summarizeChanges(
2119
- planningConfig,
2120
- analysis.facts.filter((fact) => groups[idx].files.includes(fact.path)),
2121
- )
2122
- : getGroupDiff(
2123
- projectRoot,
2124
- head,
2125
- scope,
2126
- groups[idx],
2127
- allFiles,
2128
- config.diffContextLines,
2129
- planningConfig.stripFiles,
2130
- protectModelInput,
2131
- untrackedSnapshot.previews,
2132
- );
2133
- const groupDiff = protectModelInput
2134
- ? protectSensitiveDiff(rawGroupDiff).diff
2135
- : rawGroupDiff;
2136
2119
  if (
2137
2120
  getSplitStateFingerprint(projectRoot, head, undefined, scope) !== plannedStateFingerprint
2138
2121
  ) {
@@ -2159,14 +2142,46 @@ export async function splitFlow(
2159
2142
  machineOutput,
2160
2143
  cancelMessage: 'Split cancelled.',
2161
2144
  failureMessage: `Group ${idx + 1} regenerate failed`,
2162
- task: (stream) =>
2163
- generateCommitMessage(
2145
+ analysisBudget: planningConfig.analysisBudget,
2146
+ task: async (stream) => {
2147
+ const rawGroupDiff = analysis
2148
+ ? await summarizeGroupChanges(
2149
+ planningConfig,
2150
+ analysis,
2151
+ groups[idx].files,
2152
+ captured.manifest,
2153
+ )
2154
+ : getGroupDiff(
2155
+ projectRoot,
2156
+ head,
2157
+ scope,
2158
+ groups[idx],
2159
+ allFiles,
2160
+ config.diffContextLines,
2161
+ planningConfig.stripFiles,
2162
+ protectModelInput,
2163
+ untrackedSnapshot.previews,
2164
+ );
2165
+ const groupDiff = protectModelInput
2166
+ ? protectSensitiveDiff(rawGroupDiff).diff
2167
+ : rawGroupDiff;
2168
+ if (
2169
+ getSplitStateFingerprint(projectRoot, head, undefined, scope) !==
2170
+ plannedStateFingerprint
2171
+ ) {
2172
+ throw fail(
2173
+ ERROR_CATEGORIES.CONCURRENT_MODIFICATION,
2174
+ 'The working tree changed while preparing message regeneration; no request was sent.',
2175
+ );
2176
+ }
2177
+ return generateCommitMessage(
2164
2178
  analysis ? planningConfig : config,
2165
2179
  groupDiff,
2166
2180
  regenCounts[idx],
2167
2181
  groups[idx].message,
2168
2182
  stream,
2169
- ),
2183
+ );
2184
+ },
2170
2185
  successMessage(result) {
2171
2186
  let done = `Group ${idx + 1} regenerated in ${chalk.bold(formatMs(result.elapsed))}`;
2172
2187
  if (result.usage) done += chalk.dim(` · tokens: ${formatUsage(result.usage)}`);
@@ -2178,6 +2193,7 @@ export async function splitFlow(
2178
2193
  rewriteCount += 1 + (corrections || 0);
2179
2194
  } catch (err) {
2180
2195
  regenCounts[idx]--;
2196
+ if (err.category === ERROR_CATEGORIES.CONCURRENT_MODIFICATION) throw err;
2181
2197
  console.log(`\n ${indentError(err)}\n`);
2182
2198
  }
2183
2199
  }
package/src/ui.js CHANGED
@@ -10,6 +10,7 @@ import editor from '@inquirer/editor';
10
10
  import wrapAnsi from 'wrap-ansi';
11
11
 
12
12
  import { sanitizeTerminalText } from './utils.js';
13
+ import { validateCommitCandidate } from './policy.js';
13
14
 
14
15
  // Shared status → color/icon maps (A/M/D/R/C/T from git, '?' = untracked)
15
16
  export const statusColor = {
@@ -527,25 +528,40 @@ export async function confirmAction(message, reasoning) {
527
528
  return action;
528
529
  }
529
530
 
530
- export async function editMessage(message) {
531
+ export async function editMessage(message, { policy, diff = '' } = {}) {
531
532
  // `postfix` is the temp file's extension (not a help text) — ".md" gives
532
533
  // the editor markdown highlighting; guidance belongs in `message`.
533
- const edited = await editor({
534
- message: 'Edit your commit message (save and close to continue, leave empty to cancel)',
535
- default: message,
536
- postfix: '.md',
537
- waitForUseInput: false,
538
- });
539
-
540
- const cleaned = sanitizeTerminalText(edited).trim();
541
- if (!cleaned) return null;
534
+ let current = message;
535
+ while (true) {
536
+ const edited = await editor({
537
+ message: 'Edit your commit message (save and close to continue, leave empty to cancel)',
538
+ default: current,
539
+ postfix: '.md',
540
+ waitForUseInput: false,
541
+ });
542
+
543
+ const cleaned = sanitizeTerminalText(edited).trim();
544
+ if (!cleaned) return null;
545
+
546
+ const validation = validateCommitCandidate(cleaned, { policy, diff });
547
+ if (!validation.valid) {
548
+ for (const error of validation.errors) {
549
+ console.log(chalk.yellow(` commitPolicy: ${error.message}`));
550
+ }
551
+ current = cleaned;
552
+ continue;
553
+ }
554
+ for (const warning of validation.warnings) {
555
+ console.log(chalk.yellow(` Quality check: ${warning.message}`));
556
+ }
542
557
 
543
- displayMessage(cleaned);
544
- const reconfirm = await confirm({
545
- message: 'Commit with this edited message?',
546
- default: true,
547
- theme: { prefix: { idle: chalk.dim('?'), done: chalk.green('?') } },
548
- });
558
+ displayMessage(cleaned);
559
+ const reconfirm = await confirm({
560
+ message: 'Commit with this edited message?',
561
+ default: true,
562
+ theme: { prefix: { idle: chalk.dim('?'), done: chalk.green('?') } },
563
+ });
549
564
 
550
- return reconfirm ? cleaned : null;
565
+ return reconfirm ? cleaned : null;
566
+ }
551
567
  }