forked from disler/claude-code-is-programmable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaider_is_programmable_2.js
More file actions
73 lines (62 loc) · 1.94 KB
/
aider_is_programmable_2.js
File metadata and controls
73 lines (62 loc) · 1.94 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { spawn, execSync } from 'child_process';
import { mkdir, existsSync } from 'fs';
import { dirname } from 'path';
// Create directory if it doesn't exist
const todoDir = './cc_todo';
const todoFile = `${todoDir}/todo.ts`;
try {
// Ensure directory exists
if (!existsSync(todoDir)) {
mkdir(todoDir, { recursive: true }, (err) => {
if (err) throw err;
});
}
// Generate branch name
const branchName = 'feature-todo-app';
// 1. Create and checkout a new branch
console.log(`Creating and checking out new branch: ${branchName}`);
execSync(`git checkout -b ${branchName}`);
// 2. Run aider directly with the todo task
console.log('Running aider to create todo app...');
const aiderProcess = spawn('aider', [
'--no-git',
todoFile,
'--message',
'CREATE ./cc_todo/todo.ts: a zero library CLI todo app with basic CRUD.'
], {
stdio: 'inherit'
});
// Handle aider completion
aiderProcess.on('close', (code) => {
if (code !== 0) {
console.error(`Aider process exited with code ${code}`);
cleanupAndExit(1);
return;
}
try {
// 3. Git operations - stage and commit
console.log('Staging and committing changes...');
execSync('git add .');
execSync('git commit -m "Add TypeScript todo app with CRUD functionality"');
// 4. Switch back to main branch
console.log('Switching back to main branch...');
execSync('git checkout main');
console.log(`Task completed. Changes committed to branch: ${branchName}`);
} catch (error) {
console.error(`Error during git operations: ${error.message}`);
cleanupAndExit(1);
}
});
} catch (error) {
console.error(`Error: ${error.message}`);
cleanupAndExit(1);
}
// Helper function to cleanup and exit
function cleanupAndExit(code) {
try {
execSync('git checkout main');
} catch (error) {
console.error('Failed to switch back to main branch');
}
process.exit(code);
}