feat: support slash commands in ACP adapter (#1402)#1518
Closed
solo386 wants to merge 2 commits into
Closed
Conversation
Added logic to detect leading '/' in prompts and route them to a local command handler instead of the LLM. This fixes issue NousResearch#1402.
…ousResearch#1402) Implemented a layer in `acp_adapter/server.py` to intercept prompts starting with a forward slash. Key changes: - Detects slash commands in the `prompt` method. - Routes detected commands to the existing `ChatConsole.process_command` logic from `cli.py`. - Uses `contextlib.redirect_stdout` to capture TUI output and return it as a string to the ACP client. - Ensures consistency by passing the current session's agent to the console instance. This allows IDE integrations to natively use commands like /help, /tools, /model, etc. Closes NousResearch#1402
Contributor
|
Thanks for working on this! The concept is right but the implementation has some issues that would cause runtime crashes:
The correct approach is to handle commands directly in the ACP adapter without going through the TUI layer:
I'll be opening a follow-up PR with a correct implementation. Appreciate you surfacing the issue! |
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.
What does this PR do?
This PR adds support for slash commands (/help, /model, etc.) in the ACP adapter. It intercepts prompts starting with / and routes them to the existing CLI logic instead of the LLM.
Related Issue
Fixes #1402
Changes Made
acp_adapter/server.py:
Intercepts / commands in the prompt method.
Uses contextlib.redirect_stdout to capture output from ChatConsole.process_command (cli.py).
Passes the current agent instance to ensure state consistency (e.g., for /model).
How to Test
Run hermes acp.
Connect a client and send /help or /model.
Verify you receive formatted CLI output instead of an LLM response.
Checklist
[x] Read Contributing Guide
[x] Followed Conventional Commits
[x] PR contains only related changes
[x] Tested on Codespaces/Linux