import type { Command } from '../types/command.js'
import { getRelativeSettingsFilePathForSource } from '../utils/settings/settings.js'

const command: Command = {
  name: 'auto-fix',
  description: 'Configure auto-fix: run lint/test after AI edits',
  isEnabled: () => true,
  type: 'prompt',
  progressMessage: 'Configuring auto-fix...',
  contentLength: 0,
  source: 'builtin',
  async getPromptForCommand() {
    const projectSettingsPath = getRelativeSettingsFilePathForSource('projectSettings')
    const localSettingsPath = getRelativeSettingsFilePathForSource('localSettings')
    return [
      {
        type: 'text',
        text:
          'The user wants to configure auto-fix settings. Auto-fix automatically runs lint and test commands after AI file edits, feeding errors back for self-repair.\n\n' +
          `Current settings location: \`${projectSettingsPath}\` or \`${localSettingsPath}\`\n\n` +
          'Example configuration:\n```json\n{\n  "autoFix": {\n    "enabled": true,\n    "lint": "eslint . --fix",\n    "test": "bun test",\n    "maxRetries": 3,\n    "timeout": 30000\n  }\n}\n```\n\n' +
          'Ask the user what lint and test commands they use, then help them set up the configuration.',
      },
    ]
  },
}

export default command
