bootstrap

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package bootstrap implements the `stringer init` command, which detects repository characteristics and generates a starter configuration.

Index

Constants

This section is empty.

Variables

FS is the file system implementation used by this package. Override in tests with a testable.MockFileSystem.

GitOpener is the opener used to access git repositories in the bootstrap package. Defaults to testable.DefaultGitOpener. Tests can replace this to inject mocks.

Functions

This section is empty.

Types

type Action

type Action struct {
	File        string // e.g. ".stringer.yaml", "AGENTS.md"
	Operation   string // "created", "updated", "skipped"
	Description string // human-readable detail
}

Action records a single file operation performed during init.

func AppendAgentSnippet

func AppendAgentSnippet(repoPath string) (Action, error)

AppendAgentSnippet appends the stringer integration snippet to AGENTS.md. It uses marker comments for idempotency:

  • If AGENTS.md has the markers: skip (already present)
  • If AGENTS.md exists, no markers: append snippet
  • If no AGENTS.md: create minimal file with snippet

func GenerateConfig

func GenerateConfig(repoPath string, hasGitHub bool, force bool, wizard *WizardResult) (Action, error)

GenerateConfig renders and writes .stringer.yaml to the repo root. If wizard is non-nil, uses wizard selections; otherwise uses auto-detected defaults. Returns the Action taken ("created", "skipped").

func GenerateMCPConfig added in v0.6.0

func GenerateMCPConfig(repoPath string) (Action, error)

GenerateMCPConfig generates or updates .mcp.json with a stringer MCP server entry. It only acts when Claude Code is detected (presence of .claude/ directory).

type GitHubRemote

type GitHubRemote struct {
	Owner string
	Repo  string
}

GitHubRemote holds the parsed owner/repo from a GitHub remote URL.

func DetectGitHubRemote

func DetectGitHubRemote(repoPath string) *GitHubRemote

DetectGitHubRemote opens the git repository at repoPath and checks whether the origin remote points to GitHub. Returns nil (not an error) when the directory is not a git repo or the remote is not GitHub.

type HTTPClient added in v0.9.0

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface for HTTP requests, allowing test injection.

type InitConfig

type InitConfig struct {
	RepoPath    string
	Force       bool
	Interactive bool      // Run the interactive wizard.
	Stdin       io.Reader // For wizard prompts (required if Interactive).
	Stdout      io.Writer // For wizard output (required if Interactive).
}

InitConfig holds the inputs for the init command.

type InitResult

type InitResult struct {
	Actions   []Action
	Language  string
	HasGitHub bool
}

InitResult holds the outcome of an init run.

func Run

func Run(cfg InitConfig) (*InitResult, error)

Run orchestrates the init process: detect repo characteristics, generate config, and append the AGENTS.md snippet.

type WizardResult added in v0.9.0

type WizardResult struct {
	Collectors        map[string]bool
	GitDepth          int
	GitSince          string
	LargeFileThresh   int
	LotteryThreshold  int
	GitHubTokenValid  bool
	AnthropicKeyValid bool
}

WizardResult holds the user's choices from the interactive wizard.

func RunWizard added in v0.9.0

func RunWizard(r io.Reader, w io.Writer, repoPath string) (*WizardResult, error)

RunWizard runs the interactive init wizard, prompting the user for configuration choices. It returns WizardResult with all selections.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL