Skip to content

feat: CLI restoration with all flags and config manager (Phase 1 — T1.1, T1.2, T1.3)#38

Open
canonical-muhammadbassiony wants to merge 5 commits into
feat/phase-0b-artifacts-configfrom
feat/phase-1-cli-restore
Open

feat: CLI restoration with all flags and config manager (Phase 1 — T1.1, T1.2, T1.3)#38
canonical-muhammadbassiony wants to merge 5 commits into
feat/phase-0b-artifacts-configfrom
feat/phase-1-cli-restore

Conversation

@canonical-muhammadbassiony

Copy link
Copy Markdown
Collaborator

Summary

Rewrites cmd/bauer/main.go to use the layered config resolver, restores all original CLI flags, and fixes dry-run semantics.

Tasks Implemented

  • T1.1: Restored all CLI flags (--doc-id, --credentials, --chunk-size, --page-refresh, --model, --summary-model, --dry-run, --artifacts-dir, --open-pr, --open-issue, --branch-prefix). Switched to flag.FlagSet for testability. Wired through config.NewResolver.
  • T1.2: Fixed --dry-run semantics — standalone mode skips Copilot entirely; --open-pr mode applies changes locally but skips PR creation.
  • T1.3: Updated Taskfile.yml — split build/build-api, run uses {{.CLI_ARGS}}, added run-api, test, lint, enhanced verify-figma.

Files Changed

  • cmd/bauer/main.go — full rewrite with flag.FlagSet, all flags, mutual-exclusion guard, mode dispatch
  • internal/config/cli.goCLIFlags extended with BranchPrefix, OpenPR, OpenIssue
  • internal/config/manager.goDefaultsSource adds CredentialsPath: "credentials.json" fallback
  • Taskfile.yml — build/run/test/lint tasks

Part of the Bauer v2 stacked PR series (Branch 3 of 12).

Bauer Agent added 3 commits May 20, 2026 12:51
- T1.1: rewrite cmd/bauer/main.go with all flags restored + config resolver
- T1.2: fix --dry-run semantics (skip Copilot in standalone, skip PR in --open-pr)
- T1.3: update Taskfile with build, run, run-api, test, verify-figma tasks
…emantics

- Fix .gitignore: use /bauer (root-anchored) to stop ignoring cmd/bauer/ directory
- Extract checkMutualExclusion() helper from main() for testability
- Test --open-pr + --open-issue returns descriptive error
- Test runOpenIssue/runOpenPR stubs return 'not yet implemented'
- Test dry-run standalone mode skips ExecuteChunk via trackingAgent spy

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores and rewrites the Bauer CLI entrypoint to use the layered config resolver, reintroduces the full set of CLI flags, and updates developer workflows in the Taskfile.

Changes:

  • Rewrote cmd/bauer/main.go to use flag.FlagSet, resolve layered config via config.NewResolver, and dispatch between standalone / --open-pr / --open-issue modes (with Phase 2 stubs).
  • Extended config flag plumbing (CLIFlags, FlagsSource, defaults) to include BranchPrefix, OpenPR, and OpenIssue, plus a default credentials path fallback.
  • Updated Taskfile.yml to split CLI vs API build/run flows and enhance verify-figma.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Taskfile.yml Splits build targets (CLI vs API), updates run/test/lint tasks, improves verify-figma checks.
internal/config/manager.go Adds default CredentialsPath fallback; maps additional CLI flag fields into resolved config.
internal/config/cli.go Extends CLIFlags with branch prefix and PR/issue mode booleans.
docs/implementation-log.md Marks Phase 1 branch as done and fills in the phase summary/files list.
cmd/bauer/main.go Replaces old workflow-based main with layered config + flagset parsing + mode dispatch helpers.
cmd/bauer/main_test.go Adds unit tests for resolver precedence, mutual exclusion, dry-run behavior, and mode stubs.
.gitignore Adjusts ignore rule for the built bauer binary to be repo-root specific.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/bauer/main.go Outdated
Comment on lines +16 to +17
fs := flag.NewFlagSet(os.Args[0], flag.ExitOnError)

Comment thread cmd/bauer/main.go Outdated
os.Exit(1)
}

cfg.ApplyDefaults()
Comment thread internal/config/cli.go
Comment on lines 18 to +23
SummaryModel string
TargetRepo string
ArtifactsDir string
BranchPrefix string
OpenPR *bool
OpenIssue *bool

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Comment thread cmd/bauer/main.go
Comment on lines +95 to 111
ctx := context.Background()

cwd, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: failed to get working directory: %v\n", err)
fmt.Fprintln(os.Stderr, "ERROR: failed to get working directory:", err)
os.Exit(1)
}

copilotAgent, err := copilotcli.NewClient(cwd)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: failed to create Copilot client: %v\n", err)
fmt.Fprintln(os.Stderr, "ERROR: failed to create Copilot client:", err)
os.Exit(1)
}

sources := source.NewManager(absCredentials)
arts := artifacts.NewManager("")
sources := source.NewManager(cfg.CredentialsPath)
arts := artifacts.NewManager(cfg.ArtifactsDir)
orch := orchestrator.New(copilotAgent, sources, arts)
Comment thread cmd/bauer/main.go
Comment on lines +35 to +44
fmt.Fprintf(os.Stderr, "\nEnvironment variables:\n\n")
fmt.Fprintf(os.Stderr, "\tBAUER_DOC_ID Override for --doc-id\n")
fmt.Fprintf(os.Stderr, "\tBAUER_CREDENTIALS_PATH Override for --credentials\n")
fmt.Fprintf(os.Stderr, "\tGOOGLE_APPLICATION_CREDENTIALS Fallback credentials path\n")
fmt.Fprintf(os.Stderr, "\tBAUER_MODEL Override for --model\n")
fmt.Fprintf(os.Stderr, "\tBAUER_SUMMARY_MODEL Override for --summary-model\n")
fmt.Fprintf(os.Stderr, "\tBAUER_DRY_RUN Override for --dry-run (true/false)\n")
fmt.Fprintf(os.Stderr, "\tBAUER_ARTIFACTS_DIR Override for --artifacts-dir\n")
fmt.Fprintf(os.Stderr, "\tBAUER_BRANCH_PREFIX Override for --branch-prefix\n")
fmt.Fprintf(os.Stderr, "\n")
Comment thread Taskfile.yml
Comment on lines +45 to +56
TOKEN="${BAUER_FIGMA_TOKEN:-$FIGMA_TOKEN}"
if [ -z "$TOKEN" ]; then
echo "ERROR: set BAUER_FIGMA_TOKEN or FIGMA_TOKEN"; exit 1
fi
- |
if [ -z "{{.FILE_KEY}}" ]; then
echo "ERROR: provide FILE_KEY=your-figma-file-key"; exit 1
fi
echo "Figma token is set."
- |
curl -sf -H "Authorization: Bearer ${BAUER_FIGMA_TOKEN:-$FIGMA_TOKEN}" \
"https://api.figma.com/v1/files/{{.FILE_KEY}}/meta" \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('name','?'), d.get('lastModified','?'))"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Comment thread cmd/bauer/main.go
Comment on lines +20 to +24
credentialsPath := fs.String("credentials", "", "Path to service account credentials JSON\n\t(falls back to BAUER_CREDENTIALS_PATH → GOOGLE_APPLICATION_CREDENTIALS → credentials.json)")
chunkSize := fs.Int("chunk-size", 0, "Total number of chunks (default: 1, or 5 if --page-refresh)")
pageRefresh := fs.Bool("page-refresh", false, "Use page-refresh-instructions template (default chunk-size: 5)")
model := fs.String("model", "", "Copilot model for sessions (default: gpt-5-mini-high)")
summaryModel := fs.String("summary-model", "", "Copilot model for summary session (default: gpt-5-mini-high)")
Comment thread cmd/bauer/main.go
// In standalone dry-run mode, skip Copilot client initialization
// so the CLI works on machines without the Copilot CLI installed.
var copilotAgent agent.Agent
if !(*dryRun && !*openPR && !*openIssue) {
Comment on lines 103 to +110
return &Config{
Model: "gpt-5-mini-high",
SummaryModel: "gpt-5-mini-high",
ChunkSize: 1,
ArtifactsDir: "./bauer-artifacts",
BranchPrefix: "bauer",
PageRefresh: BoolPtr(false),
DryRun: BoolPtr(false),
OpenPR: BoolPtr(false),
OpenIssue: BoolPtr(false),
Model: "gpt-5-mini-high",
SummaryModel: "gpt-5-mini-high",
ChunkSize: 1,
ArtifactsDir: "./bauer-artifacts",
BranchPrefix: "bauer",
CredentialsPath: "credentials.json",
PageRefresh: BoolPtr(false),
Comment thread cmd/bauer/main_test.go
Comment on lines +104 to +107
spy := &trackingAgent{}
arts := artifacts.NewManager(t.TempDir())
src := source.NewManager("") // no credentials needed; Fetch is not called in this test

Comment thread cmd/bauer/main.go
Comment on lines +164 to +166
copy := *original
copy.DryRun = config.BoolPtr(false)
return &copy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants