Skip to content

feat: make commit-check AI-native with JSON output and Python API#396

Merged
shenxianpeng merged 8 commits intomainfrom
copilot/make-project-ai-native
Apr 9, 2026
Merged

feat: make commit-check AI-native with JSON output and Python API#396
shenxianpeng merged 8 commits intomainfrom
copilot/make-project-ai-native

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

commit-check outputs human-readable ASCII art, making it hard for AI agents and automation toolchains to consume results programmatically. This adds two complementary AI-native interfaces without breaking any existing behaviour.

--format json CLI flag

Suppresses decorative terminal output; emits structured JSON to stdout. Exit code unchanged.

echo "bad commit" | commit-check -m --format json
{
  "status": "fail",
  "checks": [
    {
      "check": "message",
      "status": "fail",
      "value": "bad commit",
      "error": "The commit message should follow Conventional Commits…",
      "suggest": "Use <type>(<scope>): <description>…"
    }
  ]
}

commit_check/api.py — in-process Python API

Validates commits without spawning a subprocess. All functions return the same {"status", "checks"} schema.

from commit_check.api import validate_message, validate_branch, validate_all

validate_message("feat: add streaming support")["status"]  # "pass"

result = validate_all(
    message="feat: implement feature",
    branch="feature/implement-feature",
    author_email="dev@example.com",
    config={"commit": {"allow_commit_types": ["feat", "fix"]}},
)
for check in result["checks"]:
    if check["status"] == "fail":
        print(check["error"], "→", check["suggest"])

API surface: validate_message, validate_branch, validate_author, validate_all — all accept an optional config dict to override defaults inline.

Engine changes (commit_check/engine.py)

  • CheckOutcome dataclass — per-rule structured result (check, status, value, error, suggest)
  • ValidationEngine.validate_all_detailed() — runs all validators with output suppressed, returns list[CheckOutcome]
  • BaseValidator._suppress_output / _last_failure — allows silent failure capture without changing validator call signatures

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 9, 2026

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit 3913f25
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/69d763ebdd441500082c4803
😎 Deploy Preview https://deploy-preview-396--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Agent-Logs-Url: https://github.com/commit-check/commit-check/sessions/f17f4f74-1169-40df-ad73-8ae8dfc61fb1

Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com>
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 9, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will improve performance by 10.4%

⚡ 1 improved benchmark
✅ 201 untouched benchmarks
🆕 36 new benchmarks
⏩ 108 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_result_contains_check_names N/A 1.2 ms N/A
🆕 test_no_terminal_output_produced N/A 821.2 µs N/A
🆕 test_wip_commit_fails_by_default N/A 868.3 µs N/A
🆕 test_invalid_commit_returns_fail N/A 810.1 µs N/A
🆕 test_valid_conventional_commit_passes N/A 1.2 ms N/A
🆕 test_all_valid_returns_pass N/A 1.6 ms N/A
🆕 test_no_terminal_output N/A 984.6 µs N/A
🆕 test_author_validation_included N/A 2 ms N/A
🆕 test_invalid_message_causes_fail N/A 951.1 µs N/A
🆕 test_invalid_branch_causes_fail N/A 1.6 ms N/A
🆕 test_combined_checks_appear_in_result N/A 1.6 ms N/A
🆕 test_valid_feature_branch_passes N/A 653.6 µs N/A
🆕 test_fix_commit_passes N/A 1.2 ms N/A
🆕 test_invalid_branch_fails N/A 653.3 µs N/A
🆕 test_valid_name_and_email_pass N/A 1 ms N/A
🆕 test_no_terminal_output_produced N/A 680.4 µs N/A
🆕 test_invalid_email_fails N/A 658.7 µs N/A
🆕 test_valid_email_passes N/A 654.4 µs N/A
🆕 test_custom_config_restricts_types N/A 825.8 µs N/A
🆕 test_custom_allowed_types N/A 677.2 µs N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing copilot/make-project-ai-native (3913f25) with main (c978951)2

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (5bb84b6) during the generation of this report, so c978951 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Agent-Logs-Url: https://github.com/commit-check/commit-check/sessions/f17f4f74-1169-40df-ad73-8ae8dfc61fb1

Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance project for AI-native integration feat: make commit-check AI-native with JSON output and Python API Apr 9, 2026
Copilot AI requested a review from shenxianpeng April 9, 2026 06:41
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 97.05882% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.45%. Comparing base (5bb84b6) to head (3913f25).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
commit_check/api.py 96.96% 2 Missing ⚠️
commit_check/engine.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #396      +/-   ##
==========================================
+ Coverage   95.40%   95.45%   +0.05%     
==========================================
  Files           9       10       +1     
  Lines         892      991      +99     
==========================================
+ Hits          851      946      +95     
- Misses         41       45       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng shenxianpeng marked this pull request as ready for review April 9, 2026 07:46
@shenxianpeng shenxianpeng requested a review from a team as a code owner April 9, 2026 07:46
@shenxianpeng shenxianpeng added major-rfe For changelog: Major enhancement. Will be highlighted on the top and removed documentation Improvements or additions to documentation labels Apr 9, 2026
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 9, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

@shenxianpeng shenxianpeng removed the documentation Improvements or additions to documentation label Apr 9, 2026
@shenxianpeng shenxianpeng merged commit 726451f into main Apr 9, 2026
35 checks passed
@shenxianpeng shenxianpeng deleted the copilot/make-project-ai-native branch April 9, 2026 09:19
@shenxianpeng shenxianpeng added the minor A minor version bump label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major-rfe For changelog: Major enhancement. Will be highlighted on the top minor A minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants