Documentation
¶
Overview ¶
Package appsetup handles creating and installing per-role GitHub Apps using the manifest flow. It checks for existing app installations before creating new ones, and supports reusing apps whose private keys are already stored as secrets.
Index ¶
- Constants
- Variables
- func AppSlug(appSet, role string) string
- func ValidateAppSet(appSet string) error
- func ValidateRSAPEM(data []byte) error
- type AppCredentials
- type BrowserOpener
- type DefaultBrowser
- type NopBrowser
- type Prompter
- type SecretExistsFunc
- type Setup
- func (s *Setup) PermissionErrors() error
- func (s *Setup) Run(ctx context.Context, org, role string) (*AppCredentials, error)
- func (s *Setup) WithAppSet(appSet string) *Setup
- func (s *Setup) WithKnownSlugs(slugs map[string]string) *Setup
- func (s *Setup) WithPublicApps(public bool) *Setup
- func (s *Setup) WithSecretExists(fn SecretExistsFunc) *Setup
- func (s *Setup) WithStoreSecret(fn StoreSecretFunc) *Setup
- func (s *Setup) WithStoredAppIDs(ids map[string]string) *Setup
- type StdinPrompter
- type StoreSecretFunc
Constants ¶
const DefaultAppSet = "fullsend-ai"
DefaultAppSet is the default app set prefix for GitHub Apps. The official GitHub Apps maintained by the fullsend-ai organization use the "fullsend-ai" prefix (fullsend-ai-fullsend, fullsend-ai-coder, etc.). Orgs that created apps under a different prefix (e.g., "fullsend") must pass --app-set explicitly.
Variables ¶
var LegacyAppSets = []string{"fullsend"}
LegacyAppSets lists app-set prefixes used by previous fullsend versions. During uninstall, these are checked in addition to the current default so that apps created under an older naming convention are not silently skipped.
Functions ¶
func AppSlug ¶ added in v0.8.0
AppSlug returns the conventional app slug for a given app set and role.
func ValidateAppSet ¶ added in v0.8.0
ValidateAppSet checks that an app set slug is well-formed. The max length is 23 characters because the final GitHub App name is "{appSet}-{role}" and GitHub limits app names to 34 characters. The longest built-in role is "prioritize" (10 chars), so: 23 + 1 + 10 = 34.
func ValidateRSAPEM ¶ added in v0.8.0
ValidateRSAPEM checks that data contains a valid RSA private key in PEM format.
Types ¶
type AppCredentials ¶
type AppCredentials struct {
AppID int
Slug string
Name string
PEM string
ClientID string
ClientSecret string
WebhookSecret *string
HTMLURL string
}
AppCredentials holds the credentials returned from the manifest flow.
type BrowserOpener ¶
BrowserOpener opens URLs in the user's browser.
type DefaultBrowser ¶
type DefaultBrowser struct{}
DefaultBrowser opens URLs using platform-specific commands.
type NopBrowser ¶ added in v0.12.0
type NopBrowser struct{}
NopBrowser is a no-op browser used in CI/automated environments.
type Prompter ¶
type Prompter interface {
WaitForEnter(prompt string) error
Confirm(prompt string) (bool, error)
ReadLine(prompt string) (string, error)
}
Prompter handles user interaction during app setup.
type SecretExistsFunc ¶
SecretExistsFunc checks if a secret exists for a given role.
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
Setup orchestrates the creation or reuse of GitHub Apps for agent roles.
func NewSetup ¶
func NewSetup(client forge.Client, prompter Prompter, browser BrowserOpener, printer *ui.Printer) *Setup
NewSetup creates a new Setup instance.
func (*Setup) PermissionErrors ¶ added in v0.1.0
checkPermissions warns if the installed app is missing permissions that the current manifest expects. PermissionErrors returns a combined error if any apps have stale permissions, or nil if all permissions are up to date. Call after all roles have been processed so the user sees every mismatch at once.
func (*Setup) Run ¶
Run creates or reuses a GitHub App for the given org and role.
The flow:
- Check for an existing installation matching this org/role.
- If found and the PEM secret exists, offer to reuse.
- If found but PEM is lost, return an error.
- If not installed but app exists (PEM stored, installation missing), resume by installing the existing app on the org.
- If not found, run the manifest flow to create a new app.
- After creation, store the PEM immediately, then install on the org.
func (*Setup) WithAppSet ¶ added in v0.8.0
WithAppSet sets the app set prefix for GitHub App naming. Apps are named "{appSet}-{role}" (e.g., "fullsend-ai-coder"). Callers must validate appSet via ValidateAppSet before calling this method.
func (*Setup) WithKnownSlugs ¶
WithKnownSlugs sets a mapping of role → app slug for matching existing installations that don't follow the default naming convention.
func (*Setup) WithPublicApps ¶ added in v0.8.0
WithPublicApps sets whether created apps should be public (unlisted). Public apps can be installed by any org via URL.
func (*Setup) WithSecretExists ¶
func (s *Setup) WithSecretExists(fn SecretExistsFunc) *Setup
WithSecretExists sets the function used to check whether a private key secret already exists for a given role.
func (*Setup) WithStoreSecret ¶ added in v0.5.0
func (s *Setup) WithStoreSecret(fn StoreSecretFunc) *Setup
WithStoreSecret sets the function used to store a PEM secret immediately after creating a new app, before proceeding to the next role.
type StdinPrompter ¶
type StdinPrompter struct{}
StdinPrompter reads user input from stdin.
func (StdinPrompter) ReadLine ¶ added in v0.8.0
func (StdinPrompter) ReadLine(prompt string) (string, error)
func (StdinPrompter) WaitForEnter ¶
func (StdinPrompter) WaitForEnter(prompt string) error