-
Notifications
You must be signed in to change notification settings - Fork 4
feat: integrate Copilot suggestions and automate PR creation #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
15aa421
2109e07
9f5fb92
0f6d768
01b39ca
3fa2e61
3c6d14f
a36a987
456ef83
38b54a8
60387c5
2c8e1c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,234 +1,72 @@ | ||||||||||||
| package main | ||||||||||||
|
|
||||||||||||
| import ( | ||||||||||||
| "bauer/internal/config" | ||||||||||||
| "bauer/internal/github" | ||||||||||||
| "bauer/internal/orchestrator" | ||||||||||||
| "bauer/internal/workflow" | ||||||||||||
| "context" | ||||||||||||
| "flag" | ||||||||||||
| "fmt" | ||||||||||||
| "log" | ||||||||||||
| "log/slog" | ||||||||||||
| "os" | ||||||||||||
| "path/filepath" | ||||||||||||
| "strings" | ||||||||||||
| "time" | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| func runGithub() { | ||||||||||||
| // 1. Parse a GitHub repo (works with all 3 formats) | ||||||||||||
| // Using default repo for now | ||||||||||||
| defaultRepo := "canonical/canonical.com" | ||||||||||||
| repo, err := github.ParseGitHubRepo(defaultRepo) | ||||||||||||
| if err != nil { | ||||||||||||
| log.Fatal(err) | ||||||||||||
| } | ||||||||||||
| fmt.Printf("✅ Parsed: %s/%s\n", repo.Owner, repo.Name) | ||||||||||||
|
|
||||||||||||
| // 2. Check if gh CLI is installed | ||||||||||||
| if !github.IsGhCLIInstalled() { | ||||||||||||
| log.Fatal("❌ gh CLI not installed.") | ||||||||||||
| } | ||||||||||||
| fmt.Println("✅ gh CLI detected") | ||||||||||||
|
|
||||||||||||
| // 3. Validate GitHub authentication | ||||||||||||
| if err := github.ValidateGitHubAuth(); err != nil { | ||||||||||||
| log.Fatal("❌ Not authenticated. Run: gh auth login") | ||||||||||||
| } | ||||||||||||
| fmt.Println("✅ GitHub authenticated") | ||||||||||||
|
|
||||||||||||
| // 4. Clone/update repo (creates temp directory) | ||||||||||||
| localPath := "/tmp/test-bauer-repo" | ||||||||||||
| if err := github.CloneOrUpdateRepo(repo, localPath); err != nil { | ||||||||||||
| log.Fatal(err) | ||||||||||||
| } | ||||||||||||
| fmt.Printf("✅ Repo ready at: %s\n", localPath) | ||||||||||||
|
|
||||||||||||
| // 5. Create feature branch | ||||||||||||
| // Using default branch name for now | ||||||||||||
| branchName := "bauer/test-phase1" | ||||||||||||
| if err := github.CreateFeatureBranch(localPath, branchName); err != nil { | ||||||||||||
| log.Fatal(err) | ||||||||||||
| func main() { | ||||||||||||
| // Parse CLI flags | ||||||||||||
| githubRepo := flag.String("github-repo", "", "GitHub repository (owner/repo or HTTPS URL)") | ||||||||||||
| docID := flag.String("doc-id", "", "Google Doc ID") | ||||||||||||
| credentialsPath := flag.String("credentials", "bau-test-creds.json", "Path to service account credentials JSON") | ||||||||||||
| localRepoPath := flag.String("local-repo-path", "/tmp/ubuntu.com", "Local path for cloned repository") | ||||||||||||
| dryRun := flag.Bool("dry-run", false, "Perform a dry run without creating PR") | ||||||||||||
| outputDir := flag.String("output-dir", "bauer-output", "Output directory for Bauer results") | ||||||||||||
| branchPrefix := flag.String("branch-prefix", "bauer", "Branch naming prefix") | ||||||||||||
|
|
||||||||||||
| flag.Parse() | ||||||||||||
|
|
||||||||||||
| // Validate required flags | ||||||||||||
| if *githubRepo == "" { | ||||||||||||
| fmt.Fprintf(os.Stderr, "ERROR: --github-repo is required\n") | ||||||||||||
| os.Exit(1) | ||||||||||||
| } | ||||||||||||
| fmt.Printf("✅ Branch created: %s\n", branchName) | ||||||||||||
|
|
||||||||||||
| // 6. Check current branch | ||||||||||||
| current, err := github.GetCurrentBranch(localPath) | ||||||||||||
| if err != nil { | ||||||||||||
| log.Fatal(err) | ||||||||||||
| if *docID == "" { | ||||||||||||
| fmt.Fprintf(os.Stderr, "ERROR: --doc-id is required\n") | ||||||||||||
| os.Exit(1) | ||||||||||||
| } | ||||||||||||
| fmt.Printf("✅ Currently on: %s\n", current) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func runBauer() error { | ||||||||||||
|
|
||||||||||||
| fmt.Println(strings.Repeat("=", 80)) | ||||||||||||
| fmt.Println("Bauer - A tool to automate BAU tasks") | ||||||||||||
| fmt.Println(strings.Repeat("=", 80)) | ||||||||||||
| fmt.Println() | ||||||||||||
|
|
||||||||||||
| // 1. Load Configuration | ||||||||||||
| cfg, err := config.Load() | ||||||||||||
| // Create workflow input from CLI flags/config | ||||||||||||
| ghToken, err := github.GetGitHubToken() | ||||||||||||
| if err != nil { | ||||||||||||
| return fmt.Errorf("error loading configuration\n%w", err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // 1b. Change to target repository if specified | ||||||||||||
| if cfg.TargetRepo != "" { | ||||||||||||
| // Convert credentials path to absolute before changing directory | ||||||||||||
| absCredsPath, err := filepath.Abs(cfg.CredentialsPath) | ||||||||||||
| if err != nil { | ||||||||||||
| return fmt.Errorf("failed to resolve credentials path: %w", err) | ||||||||||||
| } | ||||||||||||
| cfg.CredentialsPath = absCredsPath | ||||||||||||
|
|
||||||||||||
| // Convert output directory to absolute before changing directory | ||||||||||||
| absOutputDir, err := filepath.Abs(cfg.OutputDir) | ||||||||||||
| if err != nil { | ||||||||||||
| return fmt.Errorf("failed to resolve output directory path: %w", err) | ||||||||||||
| } | ||||||||||||
| cfg.OutputDir = absOutputDir | ||||||||||||
|
|
||||||||||||
| if err := os.Chdir(cfg.TargetRepo); err != nil { | ||||||||||||
| return fmt.Errorf("failed to change to target repository %q: %w", cfg.TargetRepo, err) | ||||||||||||
| } | ||||||||||||
| cwd, _ := os.Getwd() | ||||||||||||
| fmt.Printf("Working directory: %s\n\n", cwd) | ||||||||||||
| fmt.Fprintf(os.Stderr, "WARNING: Could not get GitHub token: %v\n", err) | ||||||||||||
| ghToken = "" | ||||||||||||
|
Comment on lines
+44
to
+45
|
||||||||||||
| fmt.Fprintf(os.Stderr, "WARNING: Could not get GitHub token: %v\n", err) | |
| ghToken = "" | |
| fmt.Fprintf(os.Stderr, "ERROR: Could not get GitHub token: %v\n", err) | |
| fmt.Fprintln(os.Stderr, "Please provide a GitHub token via the appropriate environment variable or by running `gh auth login`.") | |
| os.Exit(1) |
Copilot
AI
Feb 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI doesn't expose flags for ChunkSize, PageRefresh, or Model configuration options that are available in the WorkflowInput. Users must rely on defaults (ChunkSize=0, PageRefresh=false, Model="") which will be set by config.Validate(). Consider adding CLI flags for these options to provide users with the same configurability that was available in the previous CLI version.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| { | ||||||
| "doc_id": "1WJ-N_Xkkx4r_6knxW7h200oIDyi4mVMzgh1xYt5xaU0", | ||||||
| "credentials": "bau-test-creds.json", | ||||||
| "chunk_size": 1, | ||||||
| "page_refresh": false, | ||||||
| "output_dir": "bauer-output", | ||||||
| "model": "gpt-5-mini-high", | ||||||
| "summary_model": "gpt-5-mini-high", | ||||||
| "target_repo": "../canonical.com", | ||||||
|
||||||
| "target_repo": "../canonical.com", | |
| "target_repo": "./canonical.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI now requires --github-repo and --doc-id flags but doesn't provide backward compatibility with the previous interface that could run Bauer processing standalone. Users who were using the CLI without GitHub integration will experience a breaking change. Consider adding a flag or subcommand to support both standalone Bauer processing and the full workflow, or document this breaking change in release notes.