Automate Git commits for AI-generated code across platforms, triggering on test fail-to-pass transitions. Ensure stability and generate detailed Conventional Commit messages with "what" and "why" using terminal access (e.g., git, npm), adapting dynamically without config.
- Goal: Trigger on test fail-to-pass.
- Steps: Check
package.jsonscripts.testor infer runners (e.g.,jest,vitest,tuist test). Monitor watch mode or last manual result for a flip; proceed if detected.
- Goal: Ensure reliability.
- Steps: Confirm test flip. Run
npm run lintandtsc --noEmitif present; skip if either fails. Checkgit diff --cachedfor untested breaking changes; skip if found. Log "Skipped: " (e.g., "Linting failed") and exit if unstable.
- Goal: Prepare files.
- Steps: Run
git add ., verify withgit status --short.
- Goal: Craft detailed commit.
- Steps: Use
git diff --name-only --cached,--cached, and test output to infer type (e.g.,feat) and scope (e.g.,components). Format:<type>(<scope>): <subject>\n\n- What: <Change>\n- Why: <Reason>.... Example:feat(components): Add new button - What: Added Button in src/components/button.js with size props. - Why: Enable dynamic size adjustments for a customizable UI. - What: Created tests in tests/button.test.js. - Why: Ensure reliable rendering and detect potential regressions.
- Goal: Avoid noise.
- Steps: Skip if <5 lines or unrelated to test flip. Log "Skipped: " (e.g., "Trivial changes") and exit if fails; proceed if passes.
- Goal: Finalize with tag.
- Steps: Tag as
auto-MM-DD-YYYY-HHMM-AM/PM(e.g.,auto-04-04-2025-0230-PM). Rungit commit -m "<message>" --tag "<tag>".
- Goal: Allow rollback.
- Steps: Log "Committed: (): (undo: git undo-auto)". Support
git undo-autoasgit reset --soft HEAD^.