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.py
More file actions
executable file
·58 lines (48 loc) · 1.69 KB
/
aider_is_programmable_2.py
File metadata and controls
executable file
·58 lines (48 loc) · 1.69 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
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.9"
# dependencies = []
# ///
# Script that automates creating a TypeScript todo app using Aider and Git operations
import subprocess
import os
# Create directory if it doesn't exist
todo_dir = "./cc_todo"
os.makedirs(todo_dir, exist_ok=True)
todo_file = f"{todo_dir}/todo.ts"
# Generate a random branch name
branch_name = f"feature-todo-app"
try:
# 1. Create and checkout a new branch
print(f"Creating and checking out new branch: {branch_name}")
subprocess.run(["git", "checkout", "-b", branch_name], check=True)
# 2. Run aider directly with the todo task
print("Running aider to create todo app...")
aider_cmd = [
"aider",
"--no-git", # We'll handle git ourselves
todo_file,
"--message",
"CREATE ./cc_todo/todo.ts: a zero library CLI todo app with basic CRUD.",
]
subprocess.run(aider_cmd, check=True)
# 3. Git operations - stage and commit
print("Staging and committing changes...")
subprocess.run(["git", "add", "."], check=True)
subprocess.run(
["git", "commit", "-m", "Add TypeScript todo app with CRUD functionality"],
check=True,
)
# 4. Switch back to main branch
print("Switching back to main branch...")
subprocess.run(["git", "checkout", "main"], check=True)
print(f"Task completed. Changes committed to branch: {branch_name}")
except subprocess.CalledProcessError as e:
print(f"Command failed: {e}")
except Exception as e:
print(f"Error: {e}")
# Try to return to main branch if something went wrong
try:
subprocess.run(["git", "checkout", "main"], check=True)
except:
pass