setup

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package setup implements `bumper init`: wiring bumper into a coding agent (Claude Code or Augment). It installs the guardrail hooks (terraform apply-guard + dependency install-block/post-install scan), registers the hosted Advisor MCP, ignores the verdict store, and drops the workflow notes into CLAUDE.md.

Every mutation is merge-not-clobber and idempotent: existing config is preserved, and re-running init changes nothing once wired. User-scope files are written atomically (temp + rename) with a one-time backup.

Index

Constants

View Source
const DefaultAdvisorURL = "https://advisor.bumper.sh"

DefaultAdvisorURL is the hosted, public Advisor used when no override is given.

Variables

This section is empty.

Functions

func BinPath

func BinPath() string

BinPath returns the command to invoke bumper in generated config: the bare "bumper" when it is on PATH (clean, relocatable), else the absolute path to the running binary.

func SkillsDir added in v1.2.1

func SkillsDir(a Agent, scope Scope, env Env) string

SkillsDir is where agent skills are written for the agent + scope: <agentcfg>/skills under the project (project scope) or home (user scope).

func SupportsSkills added in v1.2.1

func SupportsSkills(a Agent) bool

SupportsSkills reports whether the agent reads SKILL.md agent skills. Claude Code and Gemini CLI do; Augment (AGENTS.md-based) does not.

Types

type Action

type Action int

Action describes what a single file mutation did.

const (
	Unchanged Action = iota
	Created
	Updated
)

func EnsureClaudeMd

func EnsureClaudeMd(path string) (Action, error)

EnsureClaudeMd appends the bumper workflow stanza if its marker is absent.

func EnsureDepsClaudeMd added in v1.2.0

func EnsureDepsClaudeMd(path string) (Action, error)

EnsureDepsClaudeMd appends the dependency-guardrail stanza if its marker is absent.

func EnsureGitignore

func EnsureGitignore(path string) (Action, error)

EnsureGitignore adds the verdict-store directory to .gitignore if absent.

func MergeAdvisorMCP added in v1.2.0

func MergeAdvisorMCP(path, url string, agent Agent) (Action, error)

MergeAdvisorMCP registers the hosted Advisor as a streamable-http MCP server. Only package coordinates ever reach it — never source. Idempotent. The entry shape is per-agent: Claude Code / Augment use {"type":"http","url":…}; Gemini CLI uses {"httpUrl":…} for a streamable-HTTP server.

func MergeDepsHooks added in v1.2.0

func MergeDepsHooks(path, binPath string, agent Agent) (Action, error)

MergeDepsHooks installs the dependency guardrail hooks: `deps guard` (PreToolUse, blocks malicious installs) and `deps watch` (PostToolUse, scans after install). Idempotent and additive — it coexists with the terraform guard hook.

func MergeHook

func MergeHook(path, binPath string, agent Agent) (Action, error)

MergeHook installs the terraform guard as a pre-tool shell-tool hook in a settings.json file. The matcher, the event key, and the baked --client flag come from the agent (Claude → "Bash"/PreToolUse + no flag; Augment → "launch-process"/ PreToolUse + --client=augment; Gemini → "run_shell_command"/BeforeTool + --client=gemini).

func (Action) String

func (a Action) String() string

type Agent added in v1.2.0

type Agent string

Agent is a coding agent bumper can wire into. All three read the same stdin payload (tool_name / tool_input.command) and use the same nested hook entry shape; they differ in the shell-tool name the hook matches, the settings.json event keys (Claude/Augment: PreToolUse/PostToolUse; Gemini: BeforeTool/AfterTool), the MCP entry shape (Claude/Augment: {type,url}; Gemini: {httpUrl}), and where config + notes live on disk.

const (
	AgentClaude  Agent = "claude"
	AgentAugment Agent = "augment"
	AgentGemini  Agent = "gemini"
)

func ParseAgent added in v1.2.0

func ParseAgent(s string) (Agent, bool)

ParseAgent validates an agent string from a flag.

func (Agent) Label added in v1.2.0

func (a Agent) Label() string

Label is the human-facing name for the agent.

func (Agent) PostToolEvent added in v1.2.1

func (a Agent) PostToolEvent() string

func (Agent) PreToolEvent added in v1.2.1

func (a Agent) PreToolEvent() string

PreToolEvent and PostToolEvent are the settings.json event keys the hooks are written under (and the hookEventName a hook echoes back in its JSON output). Claude Code and Augment use PreToolUse/PostToolUse; Gemini CLI uses BeforeTool/AfterTool.

func (Agent) ShellTool added in v1.2.0

func (a Agent) ShellTool() string

ShellTool is the tool name the agent uses for shell execution — what the hook matcher selects and what the guard checks tool_name against.

type Env

type Env struct {
	Bin          string // command to invoke bumper in generated config
	ClaudeFound  bool   // the `claude` CLI is on PATH
	AugmentFound bool   // the `auggie`/`augment` CLI is on PATH
	GeminiFound  bool   // the `gemini` CLI is on PATH
	Cwd          string // project directory
	Home         string // user home
	GitRepo      bool   // cwd is a git repo
}

Env is the detected environment `bumper init` wires into.

func Detect

func Detect() (Env, error)

Detect inspects the current environment.

type Options

type Options struct {
	Agent        Agent  // which coding agent to wire (claude|augment)
	HookScope    Scope  // project|user|none — where the hook(s) are written
	Terraform    bool   // install the terraform apply-guard hook
	Deps         bool   // install the dependency hooks (deps guard + deps watch)
	Advisor      bool   // register the hosted advisor MCP
	AdvisorScope Scope  // project|user — where the advisor MCP entry is written
	AdvisorURL   string // override for self-hosting; "" → the public default
	Skills       bool   // install the agent skills (SKILL.md playbooks)
	Env          Env
}

Options is a chosen init configuration. Hooks self-filter at runtime, so wiring a guardrail that isn't used yet is harmless (it simply never fires) — that's why the defaults wire everything and a monorepo that adds Terraform later is already covered. The hosted advisor is the single MCP (the local stdio server is gone).

type Scope

type Scope string

Scope is where a piece of config is written.

const (
	ScopeProject Scope = "project" // shared with the team (committed)
	ScopeUser    Scope = "user"    // global, all projects
	ScopeNone    Scope = "none"    // skip
)

func ParseScope

func ParseScope(s string) (Scope, bool)

ParseScope validates a scope string from a flag.

func (Scope) Next

func (s Scope) Next() Scope

Next cycles a scope: project → user → none → project. Used by the TUI.

type Step

type Step struct {
	Title string
	Path  string
	Run   func() (Action, error)
}

Step is one file mutation, deferred so a plan can be previewed before applying.

func Plan

func Plan(o Options) []Step

Plan turns options into the ordered list of file mutations. The same plan drives the preview (Title/Path) and the apply (Run) in both the TUI and the flag-driven path. .gitignore and CLAUDE.md are always included (project-local helpers for the verify workflow).

func (Step) RelPath

func (s Step) RelPath(env Env) string

RelPath returns the step's path relative to the project dir when it's inside it, else the absolute path (so user-scope ~/.claude paths stay readable).

Jump to

Keyboard shortcuts

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