initcmd

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package initcmd implements the `slack-acp init` first-run wizard.

The wizard's only job is to collapse the after-manifest-paste steps — capture the two Slack tokens, sanity-check them, and persist them somewhere a supervisor unit can find them — into a single command.

$ slack-acp init
Bot token (xoxb-…): xoxb-...
App-level token (xapp-…): xapp-...
verifying with Slack auth.test … ok (team T01… user U01…)
wrote /Users/you/.config/slack-acp/config.json
wrote /Users/you/.config/slack-acp/env
next: run `slack-acp` (or set up a supervisor with the deploy skill)

Tokens can also come from flags (`--bot-token` / `--app-token`) for non-interactive provisioning, in which case stdin isn't read at all.

Verification (a live `auth.test` call) is on by default and can be skipped with `--skip-verify` for offline bootstrap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultVerifier

func DefaultVerifier(ctx context.Context, botToken, appToken string) (string, error)

DefaultVerifier calls Slack's auth.test with the bot token and returns a human-readable identity string on success. The app-level token is currently only shape-checked (a full Socket Mode handshake would add complexity for little gain — operators who fat-finger the app token find out within seconds of `slack-acp` starting).

Honours SLACK_API_BASE for parity with internal/slackproto so the e2e harness's mock Slack works with `init` too.

func Run

func Run(ctx context.Context, opts Options) error

Run executes the wizard. Returns nil on success; the caller (main) should treat any error as fatal.

Types

type Options

type Options struct {
	// Pre-set tokens (from --bot-token / --app-token). Empty → prompt.
	BotToken string
	AppToken string

	// Output paths. Zero → config.DefaultConfigPath / DefaultEnvPath.
	ConfigPath string
	EnvPath    string

	// Behaviour switches.
	NonInteractive bool // if true and a required token is missing, fail instead of prompting
	SkipVerify     bool // if true, don't call Verifier
	Force          bool // if true, overwrite existing files; otherwise refuse

	// IO. Zero → os.Stdin / os.Stdout.
	In  io.Reader
	Out io.Writer

	// Verifier. Zero → DefaultVerifier.
	Verify Verifier
}

Options bundles the wizard's inputs. Zero values are filled in with sensible defaults by Run.

type Verifier

type Verifier func(ctx context.Context, botToken, appToken string) (displayName string, err error)

Verifier validates a (bot, app) token pair against Slack. The returned displayName is shown to the operator on success (e.g. "team T01ABC user U02XYZ"). Stubbed in tests; the default implementation lives in DefaultVerifier and uses slack-go.

Jump to

Keyboard shortcuts

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