From 68230f3ffbb7732d8e6646689cb8d22cfe517012 Mon Sep 17 00:00:00 2001 From: gnanam1990 Date: Wed, 8 Apr 2026 14:23:47 +0530 Subject: [PATCH] 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 --- src/services/autoFix/autoFixConfig.test.ts | 29 ++++++++++++++++++++++ src/utils/settings/types.ts | 7 ++++++ 2 files changed, 36 insertions(+) diff --git a/src/services/autoFix/autoFixConfig.test.ts b/src/services/autoFix/autoFixConfig.test.ts index dd700048..465240fa 100644 --- a/src/services/autoFix/autoFixConfig.test.ts +++ b/src/services/autoFix/autoFixConfig.test.ts @@ -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) + }) +}) diff --git a/src/utils/settings/types.ts b/src/utils/settings/types.ts index 65e0d906..dc2ed93e 100644 --- a/src/utils/settings/types.ts +++ b/src/utils/settings/types.ts @@ -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