Documentation
¶
Index ¶
- func ColorsDisabled() bool
- func ExpandHome(path string) string
- func FileExists(path string) bool
- func IsRunningInContainer() bool
- func NewPublicOnlyHTTPClient(timeout time.Duration) *http.Client
- func OnShutdownSignal(fn func())
- func ProcessAlive(pid int) bool
- func PruneClipboardImages(dir string)
- func PruneFilesByModTime(dir string, keep int, maxAge time.Duration, match func(os.DirEntry) bool)
- func RandomToken() (string, error)
- func RunGit(ctx context.Context, workdir string, args ...string) ([]byte, error)
- func RunGitStdin(ctx context.Context, workdir, stdin string, args ...string) ([]byte, error)
- func SeedFS(fsys fs.FS, root, destDir string, overwrite bool) error
- func SetColorsDisabled(disabled bool)
- func ShortID(id string) string
- func StripANSI(s string) string
- func WriteViperConfigSparse(v *viper.Viper, indent int) error
- func WriteViperConfigWithIndent(v *viper.Viper, indent int) error
- type TokenBucketRateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorsDisabled ¶
func ColorsDisabled() bool
ColorsDisabled reports whether CLI output colors are disabled.
func ExpandHome ¶ added in v0.223.0
ExpandHome expands a leading ~ or ~/ to the user's home directory. Other tilde forms such as ~user cannot be resolved reliably and return unchanged, as does the whole input when the home directory is unavailable.
func FileExists ¶ added in v0.246.2
FileExists reports whether a path exists on disk, whatever its type.
func IsRunningInContainer ¶
func IsRunningInContainer() bool
IsRunningInContainer detects if the CLI is running inside a container Checks multiple indicators to reliably detect containerized environments
func NewPublicOnlyHTTPClient ¶ added in v0.182.1
NewPublicOnlyHTTPClient returns an *http.Client that refuses loopback, private, link-local (including cloud metadata), multicast and unspecified addresses, for URLs from untrusted sources with no host allow-list. It checks the resolved IP at dial time and on every redirect, so DNS rebinding cannot bypass it.
func OnShutdownSignal ¶ added in v0.178.1
func OnShutdownSignal(fn func())
OnShutdownSignal runs fn on SIGINT, SIGTERM or SIGHUP and then exits. SIGHUP is what a closing terminal sends. Pair it with sync.OnceFunc and defer the same fn on the normal exit path, so cleanup runs exactly once.
func ProcessAlive ¶ added in v0.178.1
ProcessAlive reports whether a process with the given PID exists, on every platform. A pid that is not positive never names one of ours, even where the OS gives pid 0 to a system process.
func PruneClipboardImages ¶ added in v0.178.1
func PruneClipboardImages(dir string)
PruneClipboardImages removes stale clipboard-image files from dir, keeping the newest 20 and anything younger than 24 hours. Recently pasted images must outlive the message that referenced them - the model may read the file via ImageDecode after the send.
func PruneFilesByModTime ¶ added in v0.178.1
PruneFilesByModTime removes files in dir that fall outside the retention window: when keep > 0 only the newest keep files matching match survive, and when maxAge > 0 files older than maxAge are removed regardless of count. Zero values disable the respective limit. Only files accepted by match are ever touched, so a producer's unrelated files stay safe.
func RandomToken ¶ added in v0.246.2
RandomToken is 24 crypto-random bytes hex encoded: an opaque token for a service binding.
func RunGit ¶ added in v0.178.1
RunGit runs a git command in workdir (process cwd when empty) and returns its stdout. The context bounds the command's lifetime and stderr is folded into the returned error. Git never prompts on the terminal, so a missing credential fails fast instead of taking over the user's TTY.
func RunGitStdin ¶ added in v0.178.1
RunGitStdin is RunGit with stdin piped to the command, for plumbing that reads a patch from standard input (git apply, git am).
func SeedFS ¶ added in v0.266.0
SeedFS writes the tree under root in fsys into destDir, mirroring its layout. A file is written only when absent unless overwrite is set, so the user's edits to a seeded file survive a re-run of `infer init`.
func SetColorsDisabled ¶
func SetColorsDisabled(disabled bool)
SetColorsDisabled records whether CLI output colors are disabled.
func ShortID ¶ added in v0.246.2
ShortID returns the first eight characters of an id, enough to tell ids apart in a log line.
func WriteViperConfigSparse ¶
WriteViperConfigSparse writes only the keys present in v, without seeding from DefaultConfig. That keeps a project ./.infer/config.yaml a sparse override that inherits every unset key from ~/.infer/. WriteViperConfigWithIndent writes the full baseline instead.
func WriteViperConfigWithIndent ¶
WriteViperConfigWithIndent writes the current Viper config with specified indentation. It writes the full baseline, the same structure as config init, and keeps every key of the existing file that Config does not declare, so a setting another tool stores in config.yaml, such as the desktop app's projects.root, survives the write.
Types ¶
type TokenBucketRateLimiter ¶
type TokenBucketRateLimiter struct {
// contains filtered or unexported fields
}
TokenBucketRateLimiter implements token bucket rate limiting for computer use actions
func NewRateLimiter ¶
func NewRateLimiter(cfg config.RateLimitConfig) *TokenBucketRateLimiter
NewRateLimiter creates a new rate limiter
func (*TokenBucketRateLimiter) CheckAndRecord ¶
func (rl *TokenBucketRateLimiter) CheckAndRecord(toolName string) error
CheckAndRecord checks if the action is within rate limits and records it Returns an error if the rate limit is exceeded