environment

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_PROMPT       = "gsh> "
	DEFAULT_AGENT_PROMPT = "🤖> "
)

Variables

This section is empty.

Functions

func AppendToAuthorizedCommands

func AppendToAuthorizedCommands(commandRegex string) error

AppendToAuthorizedCommands appends a command regex to the authorized_commands file

func GetAgentContextWindowTokens

func GetAgentContextWindowTokens(runner *interp.Runner, logger *zap.Logger) int

func GetAgentMacros

func GetAgentMacros(runner *interp.Runner, logger *zap.Logger) map[string]string

func GetAgentName

func GetAgentName(runner *interp.Runner) string

GetAgentName returns the name of the active subagent or defaults to "bish"

func GetAgentPrompt

func GetAgentPrompt(runner *interp.Runner) string

GetAgentPrompt returns the prompt to use when the agent displays commands If BISH_APROMPT is set, it uses that; otherwise uses DEFAULT_AGENT_PROMPT to differentiate agent commands from user commands

func GetApprovedBashCommandRegex

func GetApprovedBashCommandRegex(runner *interp.Runner, logger *zap.Logger) []string

func GetAssistantHeight

func GetAssistantHeight(runner *interp.Runner, logger *zap.Logger) int

func GetAuthorizedCommandsFileForTesting

func GetAuthorizedCommandsFileForTesting() string

func GetConfigDirForTesting

func GetConfigDirForTesting() string

Helper functions for testing

func GetContextNumHistoryConcise

func GetContextNumHistoryConcise(runner *interp.Runner, logger *zap.Logger) int

func GetContextNumHistoryVerbose

func GetContextNumHistoryVerbose(runner *interp.Runner, logger *zap.Logger) int

func GetContextTypesForAgent

func GetContextTypesForAgent(runner *interp.Runner, logger *zap.Logger) []string

func GetContextTypesForExplanation

func GetContextTypesForExplanation(runner *interp.Runner, logger *zap.Logger) []string

func GetContextTypesForPredictionWithPrefix

func GetContextTypesForPredictionWithPrefix(runner *interp.Runner, logger *zap.Logger) []string

func GetContextTypesForPredictionWithoutPrefix

func GetContextTypesForPredictionWithoutPrefix(runner *interp.Runner, logger *zap.Logger) []string

func GetDefaultToYes

func GetDefaultToYes(runner *interp.Runner) bool

GetDefaultToYes returns whether prompts should default to "yes" when Enter is pressed. When true, prompts display Y/n and Enter confirms. When false, prompts display y/N and Enter denies.

func GetHistoryContextLimit

func GetHistoryContextLimit(runner *interp.Runner, logger *zap.Logger) int

func GetHomeDir

func GetHomeDir(runner *interp.Runner) string

func GetIdleSummaryTimeout

func GetIdleSummaryTimeout(runner *interp.Runner, logger *zap.Logger) int

GetIdleSummaryTimeout returns the idle summary timeout in seconds. Returns 0 if disabled, otherwise defaults to 60 seconds.

func GetLogLevel

func GetLogLevel(runner *interp.Runner) zap.AtomicLevel

func GetPrompt

func GetPrompt(runner *interp.Runner, logger *zap.Logger) string

func GetPwd

func GetPwd(runner *interp.Runner) string

func GetUser

func GetUser(runner *interp.Runner) string

func IsBishVariable

func IsBishVariable(name string) bool

IsBishVariable checks if a variable name is a bish-specific variable that should be synced

func IsCommandAuthorized

func IsCommandAuthorized(command string) (bool, error)

IsCommandAuthorized checks if a command matches any of the authorized patterns

func IsCommandPatternAuthorized

func IsCommandPatternAuthorized(commandPattern string) (bool, error)

IsCommandPatternAuthorized checks if a specific command pattern already exists in the authorized_commands file This is used for pre-selecting permissions in the menu - only exact pattern matches should be pre-selected

func LoadAuthorizedCommandsFromFile

func LoadAuthorizedCommandsFromFile() ([]string, error)

LoadAuthorizedCommandsFromFile loads authorized command regex patterns from file

func ResetCacheForTesting

func ResetCacheForTesting()

ResetCacheForTesting resets the authorized commands cache for testing

func SetAuthorizedCommandsFileForTesting

func SetAuthorizedCommandsFileForTesting(file string)

func SetConfigDirForTesting

func SetConfigDirForTesting(dir string)

func SetSessionConfigOverrideGetter

func SetSessionConfigOverrideGetter(getter func(key string) (string, bool))

SetSessionConfigOverrideGetter sets the function to get session config overrides

func ShouldCleanLogFile

func ShouldCleanLogFile(runner *interp.Runner) bool

func SyncVariableToEnv

func SyncVariableToEnv(runner *interp.Runner, varName string)

SyncVariableToEnv syncs a single bish variable to system environment

func SyncVariablesToEnv

func SyncVariablesToEnv(runner *interp.Runner)

SyncVariablesToEnv syncs bish's internal variables to system environment variables This makes variables like BISH_PROMPT visible to external commands like 'env'

func WriteAuthorizedCommandsToFile

func WriteAuthorizedCommandsToFile(patterns []string) error

WriteAuthorizedCommandsToFile writes a list of regex patterns to the authorized_commands file This replaces the entire file content and deduplicates entries

Types

type DynamicEnviron

type DynamicEnviron struct {
	// contains filtered or unexported fields
}

DynamicEnviron implements expand.Environ to provide a dynamic environment that includes both system environment variables and BISH-specific variables

func NewDynamicEnviron

func NewDynamicEnviron() *DynamicEnviron

NewDynamicEnviron creates a new DynamicEnviron that wraps the system environment and adds BISH-specific variables

func (*DynamicEnviron) Each

func (de *DynamicEnviron) Each(fn func(name string, vr expand.Variable) bool)

Each iterates over all variables, including both GSH and system variables

func (*DynamicEnviron) Get

func (de *DynamicEnviron) Get(name string) expand.Variable

Get retrieves a variable by name, checking GSH variables first, then system environment

func (*DynamicEnviron) UpdateBishVar

func (de *DynamicEnviron) UpdateBishVar(name, value string)

UpdateBishVar updates a BISH variable in the dynamic environment

func (*DynamicEnviron) UpdateSystemEnv

func (de *DynamicEnviron) UpdateSystemEnv()

UpdateSystemEnv updates the system environment wrapper

Jump to

Keyboard shortcuts

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