fix(commit-message): use Kimi --prompt instead of Claude --print (#11674)

* fix(commit-message): use Kimi --prompt instead of Claude --print

kimi-code rejects --print (suggesting --prompt). Deliver the generation
prompt as the --prompt argv value so branch auto-rename and commit
message generation work when Kimi is the selected agent.

Fixes #11669

* test(commit-message): cover Kimi argument defaults
This commit is contained in:
BingZ 2026-08-08 11:19:45 +08:00 committed by GitHub
parent a7e31e5e10
commit 523feda462
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 46 additions and 3 deletions

View File

@ -46,6 +46,27 @@ describe('COMMIT_MESSAGE_AGENT_SPECS', () => {
expect(COMMIT_MESSAGE_AGENT_SPECS.pi?.defaultModelId).toBe('github-copilot/gpt-5.4-mini')
})
it('uses --prompt (not Claude --print) for Kimi non-interactive generation', () => {
// Why: kimi-code 0.31+ rejects --print; non-interactive mode is --prompt/-p (#11669).
const spec = COMMIT_MESSAGE_AGENT_SPECS.kimi
expect(spec).toBeDefined()
expect(spec!.promptDelivery).toBe('argv')
const args = spec!.buildArgs({
prompt: 'Name a branch for adding login',
model: 'kimi-code/kimi-for-coding',
thinkingLevel: 'on'
})
expect(args).toContain('--prompt')
expect(args).not.toContain('--print')
// Why: with argv delivery the prompt is the value of --prompt.
const promptIndex = args.indexOf('--prompt')
expect(promptIndex).toBeGreaterThanOrEqual(0)
expect(args[promptIndex + 1]).toBe('Name a branch for adding login')
expect(args).toContain('--quiet')
expect(args).toContain('--thinking')
expect(args).toEqual(expect.arrayContaining(['--model', 'kimi-code/kimi-for-coding']))
})
it('uses the provider-qualified Kimi model id accepted by the CLI', () => {
expect(COMMIT_MESSAGE_AGENT_SPECS.kimi?.models.map((m) => m.id)).toEqual([
'default',
@ -53,6 +74,25 @@ describe('COMMIT_MESSAGE_AGENT_SPECS', () => {
])
})
it('maps Kimi thinking off and omission to distinct argv', () => {
const spec = COMMIT_MESSAGE_AGENT_SPECS.kimi!
const offArgs = spec.buildArgs({ prompt: 'PROMPT', model: 'default', thinkingLevel: 'off' })
const defaultArgs = spec.buildArgs({ prompt: 'PROMPT', model: 'default' })
expect(offArgs).toContain('--no-thinking')
expect(offArgs).not.toContain('--thinking')
expect(defaultArgs).not.toContain('--thinking')
expect(defaultArgs).not.toContain('--no-thinking')
})
it('omits Kimi --model for the config default and an empty model', () => {
const spec = COMMIT_MESSAGE_AGENT_SPECS.kimi!
for (const model of ['default', '']) {
expect(spec.buildArgs({ prompt: 'PROMPT', model })).not.toContain('--model')
}
})
it('lists Copilot hosted CLI models even when account policy filters the picker', () => {
expect(COMMIT_MESSAGE_AGENT_SPECS.copilot?.defaultModelId).toBe('gpt-5.4')
expect(COMMIT_MESSAGE_AGENT_SPECS.copilot?.models.map((m) => m.id)).toEqual([

View File

@ -568,9 +568,12 @@ export const COMMIT_MESSAGE_AGENT_SPECS: Partial<Record<TuiAgent, CommitMessageA
id: 'kimi',
label: 'Kimi',
binary: 'kimi',
promptDelivery: 'stdin',
buildArgs: ({ model, thinkingLevel }) => [
'--print',
// Why: kimi-code accepts the generation prompt only via --prompt/-p (Claude's
// --print is rejected). Deliver on argv so --prompt receives the text (#11669).
promptDelivery: 'argv',
buildArgs: ({ prompt, model, thinkingLevel }) => [
'--prompt',
prompt,
'--quiet',
...(model && model !== 'default' ? ['--model', model] : []),
...(thinkingLevel === 'on'