Skip to content

Commit 19e37ca

Browse files
authored
Merge pull request #137 from shelltime/feat/ai-configurable-tips
feat(ai): add configurable tips display via showTips config
2 parents 2381253 + 28ab1cf commit 19e37ca

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ ShellTime CLI configuration is stored in `$HOME/.shelltime/config.toml`. The con
6161
| `ai.agent.view` | boolean | `false` | Allow AI to auto-execute read-only commands |
6262
| `ai.agent.edit` | boolean | `false` | Allow AI to auto-execute file editing commands |
6363
| `ai.agent.delete` | boolean | `false` | Allow AI to auto-execute deletion commands |
64+
| `ai.showTips` | boolean | `true` | Show AI-related tips and suggestions |
6465

6566
#### Analytics Settings
6667

@@ -99,6 +100,9 @@ exclude = [
99100

100101
# AI configuration (optional)
101102
# Controls which command types the AI assistant can automatically execute
103+
[ai]
104+
showTips = true # Show AI-related tips and suggestions (default: true)
105+
102106
[ai.agent]
103107
view = false # Allow AI to execute read-only commands (ls, cat, less, head, tail, etc.)
104108
edit = false # Allow AI to execute file editing commands (vim, nano, code, sed, etc.)

commands/query.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,21 @@ func commandQuery(c *cli.Context) error {
123123
} else {
124124
// Display command with info about why it's not auto-running
125125
displayCommand(newCommand)
126-
if actionType != model.ActionOther {
126+
if shouldShowTips(cfg) && actionType != model.ActionOther {
127127
color.Yellow.Printf("\n💡 Tip: This is a %s command. Enable 'ai.agent.%s' in your config to auto-run it.\n",
128128
actionType, actionType)
129129
}
130130
}
131131
} else {
132132
// No auto-run configured, display the command and tip
133133
displayCommand(newCommand)
134-
color.Yellow.Printf("\n💡 Tip: You can enable AI auto-run in your config file:\n")
135-
color.Yellow.Printf(" [ai.agent]\n")
136-
color.Yellow.Printf(" view = true # Auto-run view commands\n")
137-
color.Yellow.Printf(" edit = true # Auto-run edit commands\n")
138-
color.Yellow.Printf(" delete = true # Auto-run delete commands\n")
134+
if shouldShowTips(cfg) {
135+
color.Yellow.Printf("\n💡 Tip: You can enable AI auto-run in your config file:\n")
136+
color.Yellow.Printf(" [ai.agent]\n")
137+
color.Yellow.Printf(" view = true # Auto-run view commands\n")
138+
color.Yellow.Printf(" edit = true # Auto-run edit commands\n")
139+
color.Yellow.Printf(" delete = true # Auto-run delete commands\n")
140+
}
139141
}
140142

141143
return nil
@@ -146,6 +148,14 @@ func displayCommand(command string) {
146148
color.Cyan.Printf("%s\n", command)
147149
}
148150

151+
func shouldShowTips(cfg model.ShellTimeConfig) bool {
152+
// If ShowTips is not set (nil), default to true
153+
if cfg.AI == nil || cfg.AI.ShowTips == nil {
154+
return true
155+
}
156+
return *cfg.AI.ShowTips
157+
}
158+
149159
func executeCommand(ctx context.Context, command string) error {
150160
// Get the shell to use
151161
shell := os.Getenv("SHELL")

model/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ type AIAgentConfig struct {
1313
}
1414

1515
type AIConfig struct {
16-
Agent AIAgentConfig `toml:"agent"`
16+
Agent AIAgentConfig `toml:"agent"`
17+
ShowTips *bool `toml:"showTips"`
1718
}
1819

1920
type CCUsage struct {
@@ -62,6 +63,7 @@ var DefaultAIConfig = &AIConfig{
6263
Edit: false,
6364
Delete: false,
6465
},
66+
ShowTips: nil, // defaults to true if nil
6567
}
6668

6769
var DefaultConfig = ShellTimeConfig{

0 commit comments

Comments
 (0)