feat: add autoFix field to SettingsSchema with integration tests
Integrates AutoFixConfigSchema into SettingsSchema so autoFix settings are validated at the settings layer. Adds two integration tests verifying that valid configs are accepted and invalid configs (enabled with no commands) are rejected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -75,3 +75,32 @@ describe('getAutoFixConfig', () => {
|
||||
expect(result!.lint).toBe('eslint .')
|
||||
})
|
||||
})
|
||||
|
||||
describe('SettingsSchema autoFix integration', () => {
|
||||
test('SettingsSchema accepts autoFix field', async () => {
|
||||
const { SettingsSchema } = await import('../../utils/settings/types.js')
|
||||
const settings = {
|
||||
autoFix: {
|
||||
enabled: true,
|
||||
lint: 'eslint .',
|
||||
test: 'bun test',
|
||||
maxRetries: 3,
|
||||
timeout: 30000,
|
||||
},
|
||||
}
|
||||
const result = SettingsSchema().safeParse(settings)
|
||||
expect(result.success).toBe(true)
|
||||
})
|
||||
|
||||
test('SettingsSchema rejects invalid autoFix', async () => {
|
||||
const { SettingsSchema } = await import('../../utils/settings/types.js')
|
||||
const settings = {
|
||||
autoFix: {
|
||||
enabled: true,
|
||||
// missing lint and test - should fail refine
|
||||
},
|
||||
}
|
||||
const result = SettingsSchema().safeParse(settings)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -27,6 +27,7 @@ export {
|
||||
|
||||
// Also import for use within this file
|
||||
import { type HookCommand, HooksSchema } from '../../schemas/hooks.js'
|
||||
import { AutoFixConfigSchema } from '../../services/autoFix/autoFixConfig.js'
|
||||
import { count } from '../array.js'
|
||||
|
||||
/**
|
||||
@@ -435,6 +436,12 @@ export const SettingsSchema = lazySchema(() =>
|
||||
hooks: HooksSchema()
|
||||
.optional()
|
||||
.describe('Custom commands to run before/after tool executions'),
|
||||
autoFix: AutoFixConfigSchema
|
||||
.optional()
|
||||
.describe(
|
||||
'Auto-fix configuration: automatically run lint/test after AI file edits ' +
|
||||
'and feed errors back for self-repair.',
|
||||
),
|
||||
worktree: z
|
||||
.object({
|
||||
symlinkDirectories: z
|
||||
|
||||
Reference in New Issue
Block a user