Files
iris-context/internal/config/defaults.go
T
shemishtameshandshemishtamesh 89fcd6f830 feat(config): add cobra-probe-enabled toggle option and safeguard cobra probing (#133)
currently, every command that doesn't have a completion spec is assumed
to be a cobra cli and it gets ran with a `__complete` argument. for non
cobra clis this can cause problems if those non-cobra clis have
sideeffects even when ran with the `__complete` argument, and there is
no way to disable this.
one of these problems was solved at #111, but a full solution would
probably require actual sandboxing which is i think is an overkill just
for attempting to get suggestions for unrecognized commands. instead of
sandboxing, this pr adds a config option for allowing only selected
commands to be probed and disallowing the rest.
currently the default is still allowing all (`["*"]`) so default
behavior is the same, but it might be better to just have a long list of
known cobra clis as the default instead.

here's a demo of a side effect caused by the probing, in this case
"deleting" a file with rmtrash without actually trying to run the
command:

https://github.com/user-attachments/assets/5256d363-5291-42e8-bb4f-cf7467927246

---------

Co-authored-by: shemishtamesh <shemishtamail@gmail.com>
2026-08-11 19:24:47 +07:00

72 lines
1.5 KiB
Go

package config
import (
"time"
)
func DefaultConfig() *Config {
return &Config{
Core: CoreConfig{
Version: 1,
Shell: "",
ShellLogin: false,
Mode: "last",
Debug: false,
ExpandAlias: true,
AutoExecute: false,
CobraProbeEnabled: true,
},
UI: UIConfig{
Style: "modern",
GhostText: true,
ShowHiddenFiles: false,
MaxSuggestions: 100,
MaxHeight: 15,
MaxWidth: 0, // 0 means no limit, fallback to terminal width
NerdFonts: true,
},
Git: GitConfig{
FilterActiveBranch: true,
DeduplicateBranches: true,
},
Updater: UpdaterConfig{
CheckOnStartup: true,
Channel: "stable",
CheckInterval: Duration(24 * time.Hour),
AutoUpdate: 0,
},
AI: AIConfig{
Enabled: false,
Provider: "",
DebounceMS: 500,
MinIntervalMS: 1000,
Providers: nil,
SuggestOnEmpty: SuggestOnEmptyConfig{
Enabled: false,
DebounceMS: 800,
MinIntervalMS: 5000,
},
},
Keybindings: KeybindingsConfig{
ToggleMode: "ctrl+r",
ToggleMenu: "shift+tab",
SelectSuggestion: "tab",
NavigateUp: "up",
NavigateDown: "down",
},
}
}
func DefaultState() *State {
return &State{
LastMode: "spec",
Updater: UpdaterState{
LastCheckTime: time.Time{},
SeenVersion: "",
AutoUpdateTarget: "",
AutoUpdateAttempt: 0,
DeclinedVersion: "",
},
}
}