import { Context, TaskRegistry } from '@things-factory/integration-base' import simpleGit from 'simple-git' import path from 'path' async function gitCommit(step, { domain, data }: Context) { const { repoPath, filePath, message, push } = step.params if (!repoPath || !filePath) { throw new Error(`repoPath와 filePath는 필수 파라미터입니다.`) } const git = simpleGit(repoPath) try { // ✅ 변경된 파일을 Git 스테이징 영역에 추가 await git.add(filePath) // ✅ 커밋 메시지가 없으면 기본 메시지 생성 const commitMessage = message || `AI 리팩토링 적용 - ${new Date().toISOString()}` // ✅ Git 커밋 실행 await git.commit(commitMessage) // ✅ 필요하면 자동 푸시 수행 if (push) { await git.push() } return { data: { success: true, commitMessage } } } catch (error) { throw new Error(`Git 커밋 오류: ${error.message}`) } } // ✅ 태스크 등록 TaskRegistry.registerTaskHandler('git-commit', gitCommit)