index.ts
1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { createCommitAgent } from '../../../agents/commit-agent';
import { formatGitCommitInstruction } from '../../../agents/commit-agent/instruction';
import { logger } from '../../../utils/logger';
import type { GitCommitOptions, GitCommitResult } from '../types';
import path from 'path';
/**
* Public API: commit changes using commit agent.
* Delegates to the commit-agent, passing appPath via instruction.
*/
export async function commit(options?: GitCommitOptions): Promise<GitCommitResult> {
try {
if (!options?.appPath) {
throw new Error('commit() requires options.appPath');
}
const appPath = path.resolve(options.appPath);
const agent = createCommitAgent();
const instruction = formatGitCommitInstruction({
appPath,
iteration: options.iteration,
});
await agent.run(instruction);
logger.printSuccessLog('Commit completed!');
return {
success: true,
message: 'Commit workflow completed',
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
logger.printErrorLog(`Commit failed: ${errorMessage}`);
return {
success: false,
message: errorMessage,
};
}
}