mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2026-02-09 16:41:32 +01:00
feat(ai): add empty buffer context suggestions
Enable AI suggestions on empty prompts with enhanced environmental context. - Update AI_MIN_INPUT default from 3 to 0 - Add ALLOW_EMPTY_BUFFER opt-in config variable - Remove empty-buffer guards in modify, suggest, enable - Add zle-line-init hook for prompt-time suggestions - Enhance history gathering with PWD-aware priority - Add env context for dir listing, git branch, status - Implement dual prompts: predict vs complete modes - Add prompt artifact stripping for $ and > prefixes - Update README with empty buffer configuration - Add tests for empty buffer and artifact stripping Empty buffer suggestions require zsh 5.3+ and work best with AI strategy, leveraging directory context, git state, and command history to predict likely next actions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8a9c1a2a30
commit
d89bf4ec0d
7 changed files with 282 additions and 31 deletions
19
README.md
19
README.md
|
|
@ -130,9 +130,26 @@ export ZSH_AUTOSUGGEST_STRATEGY=(ai history)
|
|||
| `ZSH_AUTOSUGGEST_AI_ENDPOINT` | `https://api.openai.com/v1/chat/completions` | API endpoint URL |
|
||||
| `ZSH_AUTOSUGGEST_AI_MODEL` | `gpt-3.5-turbo` | Model name to use |
|
||||
| `ZSH_AUTOSUGGEST_AI_TIMEOUT` | `5` | Request timeout in seconds |
|
||||
| `ZSH_AUTOSUGGEST_AI_MIN_INPUT` | `3` | Minimum input length before querying |
|
||||
| `ZSH_AUTOSUGGEST_AI_MIN_INPUT` | `0` | Minimum input length before querying |
|
||||
| `ZSH_AUTOSUGGEST_AI_HISTORY_LINES` | `20` | Number of recent history lines to send as context |
|
||||
| `ZSH_AUTOSUGGEST_AI_PREFER_PWD_HISTORY` | `yes` | Prioritize history from current directory |
|
||||
| `ZSH_AUTOSUGGEST_ALLOW_EMPTY_BUFFER` | (unset) | Set to any value to enable suggestions on empty buffer (requires zsh 5.3+) |
|
||||
|
||||
#### Empty Buffer Suggestions
|
||||
|
||||
By default, suggestions only appear when you start typing. You can enable suggestions on an empty command line by setting `ZSH_AUTOSUGGEST_ALLOW_EMPTY_BUFFER`:
|
||||
|
||||
```sh
|
||||
export ZSH_AUTOSUGGEST_ALLOW_EMPTY_BUFFER=1
|
||||
export ZSH_AUTOSUGGEST_AI_API_KEY="your-api-key-here"
|
||||
export ZSH_AUTOSUGGEST_STRATEGY=(ai history)
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
- Requires zsh 5.3+ for prompt-time suggestions
|
||||
- This feature is primarily designed for the AI strategy, which can predict the next likely command based on your current directory, git status, and recent history
|
||||
- Traditional strategies (history, completion) don't benefit from empty buffer suggestions
|
||||
- **Cost consideration:** With AI strategy, this will make an API request on every new prompt, which may increase API costs
|
||||
|
||||
#### Examples
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue