prompt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package prompt wraps charmbracelet/huh for the small number of interactive confirms slice 1 needs. The wizard slice (14) will reuse these helpers and add richer forms.

All prompts are TTY-gated: if stdin isn't a terminal the call returns a CodeInconsistency error instead of hanging or silently picking a default. Scripted callers should pass explicit flags rather than rely on prompt defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(question string, defaultYes bool) (bool, error)

Confirm asks a yes/no question. Returns the user's choice.

If stdin isn't a TTY, returns (false, *errors.Error{Code: CodeInconsistency}) so non-interactive callers see a deterministic refuse and a meaningful error message rather than a silent default.

func PickScaffoldDir

func PickScaffoldDir(options []string) (string, error)

PickScaffoldDir asks the user which agent dir to scaffold. options drives the picker order (sourced from config.AgentDirs in production, so a user who customised their detection list sees the same names they configured). A free-text "other" choice lets the user type a name not in the list.

Returns:

  • CodeInconsistency if stdin isn't a TTY or output is in JSON mode
  • CodeRefusedSafety on user dismiss
  • (dirName, nil) on selection

The returned name is not validated here; callers apply their own constraints (e.g. reject "/" or empty) before passing it into the scaffolder.

func PickScaffoldFile

func PickScaffoldFile() (string, error)

PickScaffoldFile asks which filename to write inside the scaffolded agent dir. AGENTS.md is the default (cross-tool convention); CLAUDE.md is offered for Claude-specific projects; "other" drops to free-text.

Types

type GitignoreTarget

type GitignoreTarget int

GitignoreTarget is the user's choice for where to record an agent dir gitignore entry. Display order matches Slice 4's spec: repo .gitignore is the default because it survives clones and is scoped to the repo.

const (
	// TargetRepoGitignore appends to <repo>/.gitignore. Survives clones,
	// scoped to this repo. Default selection.
	TargetRepoGitignore GitignoreTarget = iota
	// TargetGlobalExcludes appends to git's core.excludesFile (or the
	// XDG default). Machine-wide, applies to every repo.
	TargetGlobalExcludes
	// TargetRepoExclude appends to .git/info/exclude. Repo-local and
	// does not survive clones; lore pull re-runs the picker after fresh
	// clones (slice 10).
	TargetRepoExclude
)

func PickGitignoreTarget

func PickGitignoreTarget(agentDirName string) (GitignoreTarget, error)

PickGitignoreTarget shows a three-option picker asking the user how to gitignore agentDirName. Returns:

  • CodeInconsistency if stdin isn't a TTY OR output is in JSON mode. Picker can't run without a human at the keyboard or with stdout reserved for a JSON envelope; both cases need explicit setup, not an interactive fallback.
  • CodeRefusedSafety on user dismiss (huh.ErrUserAborted from Ctrl+C or ESC). The user saw the choice and walked away; lore respects that and refuses to proceed.
  • (choice, nil) on a selection.

agentDirName is rendered into the picker title so the prompt is concrete ("Gitignore .claude/ where?" rather than a generic question).

Jump to

Keyboard shortcuts

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