@@ -16,6 +16,9 @@ FORCE_REINSTALL=false
1616SKIP_EXAMPLES=false
1717SKIP_COMMIT=false
1818SKIP_AGENT_START=false
19+ CREATE_PR=false
20+ AUTO_MERGE_PR=false
21+ PR_BRANCH=" "
1922
2023# Parse command-line arguments
2124while [[ $# -gt 0 ]]; do
@@ -49,6 +52,24 @@ while [[ $# -gt 0 ]]; do
4952 SKIP_AGENT_START=true
5053 shift
5154 ;;
55+ --create-pr)
56+ CREATE_PR=true
57+ shift
58+ ;;
59+ --auto-merge)
60+ AUTO_MERGE_PR=true
61+ CREATE_PR=true # Auto-merge implies creating a PR
62+ shift
63+ ;;
64+ --pr-branch)
65+ if [[ -n " $2 " && ! " $2 " =~ ^-- ]]; then
66+ PR_BRANCH=" $2 "
67+ shift 2
68+ else
69+ echo " Error: --pr-branch requires a branch name"
70+ exit 1
71+ fi
72+ ;;
5273 --help)
5374 echo " Code Conductor Universal Installer"
5475 echo " "
@@ -62,6 +83,9 @@ while [[ $# -gt 0 ]]; do
6283 echo " --skip-examples Skip copying example configurations"
6384 echo " --skip-commit Skip auto-committing changes to Git"
6485 echo " --skip-agent-start Skip starting a dev agent after installation"
86+ echo " --create-pr Create a pull request after installation"
87+ echo " --auto-merge Enable auto-merge on the created PR (implies --create-pr)"
88+ echo " --pr-branch <name> Specify branch name for PR (default: auto-generated)"
6589 echo " --help Show this help message"
6690 echo " "
6791 echo " Examples:"
@@ -73,6 +97,9 @@ while [[ $# -gt 0 ]]; do
7397 echo " "
7498 echo " # Force upgrade in non-interactive mode"
7599 echo " curl -fsSL ... | bash -s -- --auto --upgrade"
100+ echo " "
101+ echo " # Create PR with auto-merge after installation"
102+ echo " curl -fsSL ... | bash -s -- --auto --create-pr --auto-merge"
76103 exit 0
77104 ;;
78105 * )
@@ -610,6 +637,147 @@ else
610637 fi
611638fi
612639
640+ # Step 7.5: Create Pull Request if requested
641+ if [ " $CREATE_PR " = true ] && [ " $SKIP_COMMIT " = false ]; then
642+ echo " "
643+ echo -e " ${YELLOW} 🔄 Creating pull request...${NC} "
644+
645+ # Check if GitHub CLI is available and authenticated
646+ if ! command -v gh > /dev/null 2>&1 ; then
647+ echo -e " ${RED} ❌ GitHub CLI (gh) not found. Cannot create PR.${NC} "
648+ echo " Install GitHub CLI and run 'gh auth login' to enable PR creation."
649+ CREATE_PR=false
650+ elif ! gh auth status > /dev/null 2>&1 ; then
651+ echo -e " ${RED} ❌ GitHub CLI not authenticated. Cannot create PR.${NC} "
652+ echo " Run 'gh auth login' to authenticate, then try again."
653+ CREATE_PR=false
654+ else
655+ # Check if we have changes committed
656+ CURRENT_BRANCH=$( git branch --show-current)
657+ DEFAULT_BRANCH=$( git symbolic-ref refs/remotes/origin/HEAD 2> /dev/null | sed ' s@^refs/remotes/origin/@@' || echo " main" )
658+
659+ # Generate PR branch name if not provided
660+ if [ -z " $PR_BRANCH " ]; then
661+ TIMESTAMP=$( date +%Y%m%d-%H%M%S)
662+ if [ " $IS_UPGRADE " = true ]; then
663+ PR_BRANCH=" conductor-upgrade-$NEW_VERSION -$TIMESTAMP "
664+ else
665+ PR_BRANCH=" conductor-setup-$TIMESTAMP "
666+ fi
667+ fi
668+
669+ # Check if we're on the default branch
670+ if [ " $CURRENT_BRANCH " = " $DEFAULT_BRANCH " ]; then
671+ echo -e " ${YELLOW} 📝 Creating new branch for PR: $PR_BRANCH ${NC} "
672+ git checkout -b " $PR_BRANCH " || {
673+ echo -e " ${RED} ❌ Failed to create branch.${NC} "
674+ CREATE_PR=false
675+ }
676+ else
677+ # Already on a feature branch, use it
678+ PR_BRANCH=" $CURRENT_BRANCH "
679+ echo -e " ${YELLOW} 📝 Using current branch for PR: $PR_BRANCH ${NC} "
680+ fi
681+
682+ if [ " $CREATE_PR " = true ]; then
683+ # Push the branch
684+ echo -e " ${YELLOW} 📤 Pushing branch to origin...${NC} "
685+ git push -u origin " $PR_BRANCH " || {
686+ echo -e " ${RED} ❌ Failed to push branch.${NC} "
687+ CREATE_PR=false
688+ }
689+
690+ if [ " $CREATE_PR " = true ]; then
691+ # Create the PR
692+ if [ " $IS_UPGRADE " = true ]; then
693+ PR_TITLE=" 🔧 Upgrade Code Conductor from $CURRENT_VERSION to $NEW_VERSION "
694+ PR_BODY=" ## Summary
695+ This PR upgrades Code Conductor to version $NEW_VERSION .
696+
697+ ### Changes
698+ - Updated core scripts and utilities
699+ - Updated role definitions
700+ - Updated GitHub workflows
701+ - Preserved existing configuration
702+
703+ ### Testing
704+ - [ ] Installation/upgrade completed successfully
705+ - [ ] Conductor commands work as expected
706+ - [ ] GitHub integration functional
707+
708+ ### Auto-generated
709+ This PR was automatically created by the Code Conductor installer."
710+ else
711+ PR_TITLE=" 🚀 Initialize Code Conductor for AI agent orchestration"
712+ PR_BODY=" ## Summary
713+ This PR sets up Code Conductor to enable multiple AI agents to work on this codebase simultaneously.
714+
715+ ### What is Code Conductor?
716+ Code Conductor is an AI agent coordination system that:
717+ - Enables multiple AI coding agents (Claude Code, Conductor, Warp) to work in parallel
718+ - Uses GitHub Issues as a task queue with automatic conflict prevention
719+ - Provides isolated git worktrees for each agent
720+ - Includes AI-powered code reviews on all PRs
721+
722+ ### Changes
723+ - Added \` .conductor\` directory with scripts and configuration
724+ - Added GitHub workflows for automation
725+ - Configured agent roles based on detected technology stack
726+ - Created initial tasks for agents to claim
727+
728+ ### Next Steps
729+ 1. Merge this PR to enable Code Conductor
730+ 2. AI agents can start claiming and working on tasks
731+ 3. Monitor progress via GitHub Issues labeled \` conductor:task\`
732+
733+ ### Auto-generated
734+ This PR was automatically created by the Code Conductor installer."
735+ fi
736+
737+ echo -e " ${YELLOW} 📝 Creating pull request...${NC} "
738+ PR_URL=$( gh pr create \
739+ --title " $PR_TITLE " \
740+ --body " $PR_BODY " \
741+ --base " $DEFAULT_BRANCH " \
742+ --head " $PR_BRANCH " 2>&1 ) || {
743+ echo -e " ${RED} ❌ Failed to create PR: $PR_URL ${NC} "
744+ CREATE_PR=false
745+ }
746+
747+ if [ " $CREATE_PR " = true ]; then
748+ echo -e " ${GREEN} ✅ Pull request created successfully!${NC} "
749+ echo -e " ${GREEN} 📎 PR URL: $PR_URL ${NC} "
750+
751+ # Enable auto-merge if requested
752+ if [ " $AUTO_MERGE_PR " = true ]; then
753+ echo -e " ${YELLOW} 🤖 Enabling auto-merge...${NC} "
754+ gh pr merge --auto --merge " $PR_URL " || {
755+ echo -e " ${YELLOW} ⚠️ Could not enable auto-merge. You may need to:${NC} "
756+ echo " 1. Ensure branch protection rules allow auto-merge"
757+ echo " 2. Wait for required checks to be configured"
758+ echo " 3. Enable auto-merge manually with: gh pr merge --auto $PR_URL "
759+ }
760+ fi
761+
762+ # Add labels
763+ gh pr edit " $PR_URL " --add-label " conductor:setup,automation" 2> /dev/null || true
764+
765+ echo " "
766+ echo -e " ${GREEN} 🎉 Next steps:${NC} "
767+ echo " 1. Review the PR: $PR_URL "
768+ if [ " $AUTO_MERGE_PR " = false ]; then
769+ echo " 2. Merge the PR to activate Code Conductor"
770+ echo " 3. Other agents can then see and use the system"
771+ else
772+ echo " 2. PR will auto-merge once checks pass"
773+ echo " 3. Other agents will then see and use the system"
774+ fi
775+ fi
776+ fi
777+ fi
778+ fi
779+ fi
780+
613781# Step 8: Development Environment Selection - skip for upgrades
614782if [ " $IS_UPGRADE " = false ]; then
615783 if [ " $AUTO_MODE " = true ]; then
0 commit comments