Repository navigation
Closed
Description
General Goal of the Epic
To create an automated system that monitors GitHub issues, uses Anthropic's Claude Code to generate solutions, and automates the Git workflow including PR creation.
Current Stage (Issue 4 of N)
This issue focuses on enabling worker processes to set up and manage local Git environments for processing individual GitHub issues. This involves cloning repositories and creating isolated worktrees.
- What's being done in this issue: Implement scripts/modules within the worker to handle repository cloning (efficiently), create new Git worktrees for each issue, and manage branch creation within these worktrees.
- What's been done (from #[URL_OF_ISSUE_1_GOES_HERE], #[URL_OF_ISSUE_2_GOES_HERE], #[URL_OF_ISSUE_3_GOES_HERE]): Authentication, logging, daemon for issue detection, task queue, and basic worker infrastructure (including 'AI-processing' tagging) are established.
- What's remaining: Claude Code integration, automated code changes, PR creation, comprehensive error handling, and cleanup.
Task Details
This task enables the worker to prepare a dedicated coding environment for each issue. (Refers to Proposal Section 2.2)
- Repository Cloning/Fetching Logic (Node.js module:
src/git/repoManager.jsor Bash script):- Develop a function/script that a worker can call with repository details (owner, name, default branch).
- Cloning:
- If the repository is not already cloned locally to a base directory (e.g.,
/opt/git-processor/clones/\<owner>/\<repo_name>), clone it using the GitHub token (from Issue 1'sgithubAuth.js). - Consider shallow clones (
--depth 1) initially for efficiency, but note that Claude might benefit from more history (Sec 2.2.1). Make depth configurable.
- If the repository is not already cloned locally to a base directory (e.g.,
- Fetching Updates:
- If the repository is already cloned, fetch updates (
git fetch origin) to ensure it's up-to-date.
- If the repository is already cloned, fetch updates (
- The base path for clones should be configurable.
- Git Worktree Creation Logic (part of
repoManager.jsor separate script):- Develop a function/script to create a new Git worktree for a given issue. (Sec 2.2.2)
- Inputs: Path to the main cloned repository, issue ID, issue title, base branch name (e.g., 'main', 'develop' - should be configurable per repo or globally).
- Worktree Path: Create a unique path for the worktree (e.g.,
/opt/git-processor/worktrees/\<owner>/\<repo_name>/\<issue_id>). This base path should be configurable. - Branch Creation:
- Create a new branch for the worktree, named systematically (e.g.,
ai-fix/${issue_id}-${sanitized_issue_title}). (Sec 2.2.3) - Use
git worktree add <path> -b <new_branch_name> <base_branch_name>.
- Create a new branch for the worktree, named systematically (e.g.,
- Return the path to the created worktree directory.
- Directory Structure and Configuration:
- Define and document the local directory structure for cloned repos and worktrees (Sec 2.2.4).
- Ensure base paths for clones and worktrees are configurable via environment variables.
- Error Handling:
- Implement robust error handling for all Git commands (clone, fetch, worktree add). Log errors clearly.
- If a Git operation fails, the worker should report this failure back to the main worker loop (to be handled by updating issue state/tags in a later issue).
- Worker Integration:
- The worker script (
src/worker.jsfrom Issue 3) should call these Git management functions after picking up a task and before Claude execution. - The path to the worktree should be passed to subsequent processing steps.
- The worker script (
Acceptance Criteria
- Worker can clone a new repository if it doesn't exist locally.
- Worker can fetch updates for an existing local repository clone.
- Worker can create a new Git worktree from a specified base branch, creating a new issue-specific branch.
- Branch and worktree directory naming conventions are followed.
- Paths for clones and worktrees are configurable.
- Basic error handling for Git operations is implemented and logged.
- The worker script integrates these steps successfully.
Metadata
Metadata
Assignees
Labels
No labels
Activity
integry commentedon May 23, 2025
Suggested Implementation (Node.js / Bash)
Node.js is preferred for easier integration with the existing worker, using libraries like
simple-gitor by spawninggitchild processes. Bash can be used for standalone git utility scripts invoked by the worker.1. Node.js Example using
simple-git(Installsimple-git)This comment provides initial code suggestions. Ensure
simple-gitandfs-extraare installed (npm install simple-git fs-extra). Error handling and cleanup logic (especially for orphaned worktrees or failed removals) should be robust.feat(ai): All changes are in place. Here's a summary of what was addr…
feat(ai): All changes are in place and verified. Here's a summary of …
The implementation is complete. Here's a summary of what I did.
The implementation is complete. Here's a summary of what I did.
feat(ai): This report was for an older commit. Four of the five failu…
Done. Here's what I found and implemented.
feat(ai): Both outstanding points are implemented, and the two struct…
feat(ai): I made all six fixes. All 1954 UI unit tests pass and lint …
feat(ai): All requested work is now complete and verified. Here's the…