Skip to content

refactor: split internal/github into internal/forge and internal/forge/github - #133

Closed
ralphbean wants to merge 6 commits into
mainfrom
agent-refactor-forge-interface
Closed

refactor: split internal/github into internal/forge and internal/forge/github#133
ralphbean wants to merge 6 commits into
mainfrom
agent-refactor-forge-interface

Conversation

@ralphbean

Copy link
Copy Markdown
Member

Summary

  • Extract forge-neutral interface (Client, Repository, ChangeProposal) into internal/forge/ package
  • Move GitHub-specific implementation (LiveClient, AppConfig) to internal/forge/github/
  • Update all consumers (internal/install/, internal/cli/) to use the new package structure
  • Move test fake to internal/forge/ with forge-neutral naming

This is a pure structural refactor with no behavior changes. All existing tests pass unchanged (modulo import paths and type name updates).

Key renames

Before After
github.PullRequest forge.ChangeProposal
github.Client forge.Client
github.Repository forge.Repository
CreatePullRequest() CreateChangeProposal()
Result.PRs Result.Proposals
pr.HTMLURL proposal.URL

Verification

All four checks pass clean:

  • go build ./...
  • go vet ./...
  • go test ./... -count=1 -timeout 60s
  • golangci-lint run ./...

Implement a Go CLI tool using Cobra that demonstrates the installation
and bootstrap workflow described in issue #124. The CLI uses
charmbracelet/lipgloss for styled terminal output.

What's included:
- `fullsend install <org>` command with --repo, --agents, --dry-run flags
- GitHub App configuration with minimum required permissions
- .fullsend config repo creation with safe defaults (auto_merge: false)
- Enrollment PR generation for enabled repositories
- Reusable GitHub Actions workflow generation
- CODEOWNERS file generation
- Comprehensive unit tests (46 tests, 92-100% coverage)
- golangci-lint configuration and CI integration
- Go build/test/lint/vet/fmt targets in Makefile

The install command uses a fake GitHub client for the PoC to demonstrate
the full workflow without requiring real API credentials. The Client
interface is designed for easy replacement with a real implementation.

Note: The .github/workflows/lint.yml update (adding Go CI job) requires
the workflow scope and should be applied separately by a maintainer.

Resolves #124

Assisted-by: OpenCode claude-opus-4-6@default
The end-of-file-fixer pre-commit hook requires exactly one trailing
newline. The previous version had two.

Assisted-by: OpenCode claude-opus-4-6@default
No code uses Go 1.26-specific features. All dependencies require
Go 1.18 or lower, so lowering the minimum version is safe.

Assisted-by: OpenCode claude-opus-4-6@default
Replace the simulated install flow with a real GitHub API client that
creates repos, files, branches, and PRs via the REST API. Address all
findings from code review.

Changes:
- Add LiveClient implementing Client interface with real HTTP calls
- Authenticate via GITHUB_TOKEN environment variable (removed --token flag)
- Add security hardening: io.LimitReader (10MB cap), pagination limit
  (100 pages), URL path escaping on all user inputs, dedicated
  http.Client with 30s timeout, GitHub Actions env vars instead of
  inline interpolation to prevent script injection
- Use discovered DefaultBranch for PR base (not hardcoded 'main')
- Default .fullsend repo to private
- Validate org name format and --repo values against discovered repos
- Fix DefaultAgents slice aliasing (now returns fresh copy)
- Sort validation error messages for determinism
- Validate per-repo agent lists in config
- Unexport ui style variables (internal use only)
- Remove all PoC/demo language from code and help text
- Be honest about GitHub App creation (manual step, not automated)
- Add comprehensive tests: httptest-based client tests, org name
  validation, default branch handling, config validation, repo warnings

Note: .github/workflows/lint.yml update (adding Go CI job) requires
the workflow scope and should be applied separately by a maintainer.

Assisted-by: OpenCode claude-opus-4-6@default
Add token resolution chain: GH_TOKEN > GITHUB_TOKEN > gh auth token.
If the user has already authenticated with the gh CLI, fullsend picks
up their stored credentials automatically — no env var needed.

Assisted-by: OpenCode claude-opus-4-6@default
…e/github

Extract forge-neutral interface (Client, Repository, ChangeProposal) into
internal/forge/ and move the GitHub-specific implementation to
internal/forge/github/. This is a pure structural refactor with no behavior
changes, preparing the codebase for multi-forge support (GitLab, Forgejo).

Key renames:
- PullRequest -> ChangeProposal (with URL instead of HTMLURL)
- CreatePullRequest -> CreateChangeProposal
- Result.PRs -> Result.Proposals
- FakeClient moved to forge package with neutral test URLs

Assisted-by: OpenCode claude-opus-4-6@default
@ralphbean

Copy link
Copy Markdown
Member Author

Closing this in favor of #142

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.

1 participant