-
Notifications
You must be signed in to change notification settings - Fork 36
Refactor: Move misplaced functions from add_command.go to domain-specific files #3761
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
Conversation
- Move 5 setup functions to copilot-agents.go - Move checkCleanWorkingDirectory to git.go - Move createPR to pr_command.go - Remove unused imports from add_command.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ific files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.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.
Pull Request Overview
This PR refactors add_command.go by moving 7 misplaced functions to their appropriate domain-specific files, improving code organization and maintainability. The refactoring reduces add_command.go from 1,018 to 858 lines and removes two unused imports (encoding/json and os/exec).
- Five agent setup functions moved to
copilot-agents.gofor better cohesion with existing agent management code - One git operation function moved to
git.goto group with other git utilities - One PR creation function moved to
pr_command.goto consolidate PR-related operations
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/add_command.go | Removed 7 misplaced functions and 2 unused imports, reducing file size by 160 lines |
| pkg/cli/copilot-agents.go | Added 5 agent setup functions (ensureCopilotInstructions, ensureAgenticWorkflowPrompt, and 3 ensure*Agent functions) |
| pkg/cli/git.go | Added checkCleanWorkingDirectory function to group with other git utilities |
| pkg/cli/pr_command.go | Added createPR function to consolidate PR operations |
| docs/src/content/docs/status.mdx | Unrelated change: added schedule to Changeset Generator workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | [Blog Auditor](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/blog-auditor.md) | claude | [](https://github.com/githubnext/gh-aw/actions/workflows/blog-auditor.lock.yml) | `0 12 * * 3` | - | | ||
| | [Brave Web Search Agent](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/brave.md) | copilot | [](https://github.com/githubnext/gh-aw/actions/workflows/brave.lock.yml) | - | `/brave` | | ||
| | [Changeset Generator](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/changeset.md) | copilot | [](https://github.com/githubnext/gh-aw/actions/workflows/changeset.lock.yml) | - | - | | ||
| | [Changeset Generator](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/changeset.md) | copilot | [](https://github.com/githubnext/gh-aw/actions/workflows/changeset.lock.yml) | `0 */2 * * *` | - | |
Copilot
AI
Nov 12, 2025
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.
This change adds a schedule to the Changeset Generator workflow (0 */2 * * * - every 2 hours), which appears unrelated to the stated purpose of this PR (refactoring functions from add_command.go to domain-specific files). This change should either be removed from this PR or explicitly mentioned in the PR description.
| | [Changeset Generator](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/changeset.md) | copilot | [](https://github.com/githubnext/gh-aw/actions/workflows/changeset.lock.yml) | `0 */2 * * *` | - | | |
| | [Changeset Generator](https://github.com/githubnext/gh-aw/blob/main/.github/workflows/changeset.md) | copilot | [](https://github.com/githubnext/gh-aw/actions/workflows/changeset.lock.yml) | - | - | |
The
add_command.gofile contained 7 functions unrelated to workflow addition: 5 agent setup utilities, 1 git operation, and 1 PR creation helper. This violated separation of concerns and made code discovery difficult.Changes
Moved to
copilot-agents.go:ensureCopilotInstructions- creates/updates Copilot instruction filesensureAgenticWorkflowPrompt- removes deprecated prompt filesensureAgenticWorkflowAgent- ensures create-agentic-workflow agent existsensureSharedAgenticWorkflowAgent- ensures shared workflow agent existsensureSetupAgenticWorkflowsAgent- ensures setup guide agent existsMoved to
git.go:checkCleanWorkingDirectory- validates no uncommitted changesMoved to
pr_command.go:createPR- creates pull request via GitHub CLIImpact
add_command.go: 1,018 → 858 lines (-160)encoding/json,os/execEach file now has a single clear domain: workflow addition, agent setup, git operations, or PR management.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.