Skip to content

MAI-48: nodemaiass - auto-pick AI commit model by diff size#22

Merged
vsmash merged 1 commit into
developfrom
feature/MAI-48_auto-model-by-diff-size
Jun 1, 2026
Merged

MAI-48: nodemaiass - auto-pick AI commit model by diff size#22
vsmash merged 1 commit into
developfrom
feature/MAI-48_auto-model-by-diff-size

Conversation

@vsmash
Copy link
Copy Markdown
Owner

@vsmash vsmash commented Jun 1, 2026

Summary

CLI half of MAI-48 (sibling PR in maiass-proxy for the worker half).

Replaces the single-source AI commit model picker (MAIASS_AI_MODEL || 'gpt-3.5-turbo') with a layered resolver in lib/commit.js:

  1. OverrideMAIASS_AI_COMMIT_MODEL (new env var) wins absolutely. Skips all picker logic.
  2. Legacy back-compatMAIASS_AI_MODEL (unchanged) used when commit override is unset. Preserves prior behaviour for users who configured it explicitly.
  3. Auto-pick — when neither is set, ladder by post-truncation diff char count:
    • < 30000 chars -> gpt-4o-mini (tier 1, common case given the 8000-char default cap)
    • 30000..100000 chars -> gpt-4-turbo (tier 2)
    • > 100000 chars -> gpt-4o (tier 3)

Tiers 2 and 3 only fire when a user raises MAIASS_AI_MAX_CHARACTERS above 30000 — the ladder is intentionally forward-compatible with future cap increases.

Under MAIASS_DEBUG=true the picker logs the chosen tier, diff length, and threshold range.

Changes

  • lib/commit.js — new exported pickCommitModel(diffLength, env) helper; wired into the commit suggestion flow after diff truncation; debug log added
  • lib/maiass-variables.js — register MAIASS_AI_COMMIT_MODEL
  • lib/config-manager.js + lib/config-command.js — add MAIASS_AI_COMMIT_MODEL to the AI category groupings
  • test/unit/commit-model-picker.test.js — 13 cases covering override, legacy fallback, tier boundaries (0, 29999, 30000, 100000, 100001, 250000), defensive negative input

Out of scope

  • Worker changes (sibling PR in maiass-proxy).
  • MAIASS_AI_MAX_CHARACTERS itself — unchanged.
  • Bash CLI parity — separate follow-up.
  • lib/changelog-cleanup.js — per MAI-47 thread, cleanup chunks are too small to need the ladder; already has its own MAIASS_AI_CHANGELOG_MODEL.

Jira

https://velvary.atlassian.net/browse/MAI-48

Test plan

  • npm run test:unit — 92 pass (was 79 before this branch; 13 new tests added)
  • Manual smoke: MAIASS_AI_COMMIT_MODEL=gpt-4o MAIASS_DEBUG=true maiass -c — confirm debug log shows "override via MAIASS_AI_COMMIT_MODEL"
  • Manual smoke: unset both env vars, run with small staged diff — confirm picker logs tier 1 / gpt-4o-mini
  • Manual smoke: with MAIASS_AI_MODEL=gpt-3.5-turbo set and MAIASS_AI_COMMIT_MODEL unset, confirm picker logs "legacy MAIASS_AI_MODEL"

  - add pickCommitModel() in lib/commit.js with override > legacy > auto-pick layering
  - new MAIASS_AI_COMMIT_MODEL env var (commit-only override) takes precedence over MAIASS_AI_MODEL
  - auto-pick by post-truncation diff length: <30k gpt-4o-mini, 30k-100k gpt-4-turbo, >100k gpt-4o
  - debug log shows tier + diff size when MAIASS_DEBUG=true
  - register MAIASS_AI_COMMIT_MODEL in maiass-variables.js and the AI category in config-manager/config-command
  - add commit-model-picker.test.js (13 cases covering override, legacy, tier boundaries)
@vsmash vsmash merged commit 0b8b319 into develop Jun 1, 2026
11 checks passed
@vsmash vsmash deleted the feature/MAI-48_auto-model-by-diff-size branch June 1, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant