feat(tui): add prompt enhancement via ctrl+x p#17502
Open
rjamestaylor wants to merge 1 commit intoanomalyco:devfrom
Open
feat(tui): add prompt enhancement via ctrl+x p#17502rjamestaylor wants to merge 1 commit intoanomalyco:devfrom
rjamestaylor wants to merge 1 commit intoanomalyco:devfrom
Conversation
Press <leader>p (default ctrl+x p) in the TUI to have a small model rewrite and expand the current prompt before submitting. Enhanced text replaces the input; press esc to immediately revert. - Add built-in `enhance` agent (hidden, primary mode, deny-all tools, temperature 0.3) with a dedicated system prompt - Add `Agent.enhancePrompt()` resolving model via getSmallModel() fallback - Add `prompt_enhance` keybind (default <leader>p) to Config.Keybinds - Wire prompt component: abort-safe async flow, preEnhance undo field, onModel callback for real-time "enhancing (model-name)" footer display - Add 9 unit tests covering agent properties, permissions, model/ temperature config overrides, and keybind defaults - Document in tui.mdx, agents.mdx, and keybinds.mdx Closes anomalyco#10237
1 task
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #10237
Type of change
What does this PR do?
Adds a
prompt_enhancecommand to the TUI. With text in the input field, pressing<leader>p(default:ctrl+x p) sends the draft to a lightweight model that rewrites it for clarity, then replaces the input with the result. Pressingescimmediately reverts to the original, or cancels an in-flight request.Changes:
agent.ts— newenhancebuilt-in agent andAgent.enhancePrompt(). Uses the provider's small model by default; falls back to the session model. Last 5 user turns are passed as context so references like "fix that bug" resolve correctly.prompt/enhance.txt— system prompt for the enhancer.config.ts—prompt_enhancekeybind (default<leader>p).prompt/index.tsx— wires up the command, loading state, esc-to-revert, and footer hints.tui.mdx,agents.mdx,keybinds.mdxupdated.The
enhanceagent is hidden, excluded fromAgent.defaultAgent(), and has all tool access denied (text-in/text-out only). Model is configurable viaagent.enhance.modelinopencode.json.How did you verify your code works?
bun test test/agent-enhance.test.ts— 9 tests pass covering agent definition, permission rules, config overrides, and keybind defaults.bun typecheck— no errors.Screenshots / recordings
Enhance Prompt Demo
https://github.com/user-attachments/assets/4c9955c5-2e8b-401c-b1e3-05973ac32b88
Input field with

ctrl+x phint in footer"Enhance prompt" entry in the command menu

Enhancement in progress (Claude Haiku 4.5)

Enhancement in progress (qwen3.5:35b via Ollama)

Enhanced result with esc-to-revert hint

Error: provider model not found

Error: rate limit / retry exhausted

Enhancement cancelled via esc

Checklist