cliassist

package
v0.411.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSystemPrompt

func BuildSystemPrompt(info SysInfo) string

BuildSystemPrompt creates the system message instructing the LLM to return only a shell command.

func BuildUserPrompt

func BuildUserPrompt(args []string) string

BuildUserPrompt joins the user's CLI args into a single request string.

func CleanCommand

func CleanCommand(raw string) string

CleanCommand strips markdown code fences from a model response, in case the model disobeys the "no fences" instruction.

func FetchCommand

func FetchCommand(ctx context.Context, cfg *config.Config, systemPrompt, userPrompt string) (string, error)

FetchCommand sends a system+user prompt to the cli-assist model and returns the cleaned command string.

func Run

func Run(ctx context.Context, cfg *config.Config, args []string)

Run is the entrypoint for --cli-assist mode. It detects the OS/shell, builds a prompt, fetches a command from the LLM, shows an interactive menu, and either executes or exits.

func RunCommand

func RunCommand(info SysInfo, command string) int

RunCommand executes the given command in the detected shell. It connects stdin/stdout/stderr directly to the terminal so interactive commands work. Returns the exit code of the process.

Types

type MenuAction int

MenuAction represents the user's choice from the menu.

const (
	ActionExecute     MenuAction = iota // Run the command
	ActionEditPrompt                    // Re-enter the request text and re-fetch
	ActionEditCommand                   // Edit the command inline, then re-show menu
	ActionQuit                          // Exit without executing
)

func ShowMenu

func ShowMenu(command string) (action MenuAction, newCommand string, newPrompt string)

ShowMenu displays the generated command in a Unicode box and waits for a keypress. Returns the chosen action, the (possibly edited) command, and a new prompt if applicable.

type SysInfo

type SysInfo struct {
	OS        string // "linux", "macos", "windows"
	ShellPath string // e.g. "/bin/bash", "C:\Windows\System32\cmd.exe"
	ShellName string // e.g. "bash", "zsh", "fish", "powershell", "cmd"
}

SysInfo holds the detected operating system and shell information.

func DetectSysInfo

func DetectSysInfo() SysInfo

DetectSysInfo detects the current OS and user shell at runtime.

Jump to

Keyboard shortcuts

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