feat(print): dispatch leading slash lines in -p / non-interactive mode#112
Merged
Conversation
Walk the prompt line by line in the print / codex-exec paths; route each leading line that starts with "/" through the slash handler, stopping at the first non-slash line. The remainder is the prompt that gets echoed. /think and /stream are terminal: their parsed message is the prompt and their durations are slept before the echo, giving orchestrators a generic pacing mechanism in non-interactive mode (where the engine's per-turn timing is otherwise unavailable). Diverges from real claude --print, which sends "/help" to the model as literal text. The divergence is intentional and documented in COMPATIBILITY.md — testagent is a fake driven by orchestrator scripts, not a model proxy. Shared slash.Handler.PrePromptDispatch does the walk; each vendor wires it into its print/exec entry point with vendor-appropriate teardown (claude: Stop + SessionEnd + MCP close; codex: Stop only, ExitError on non-zero /exit; cursor: same as claude on a background context). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
claude -p,codex exec, andcursor agent --printnow dispatch leading/-prefixed lines through the slash handler instead of treating them as opaque prompt text./thinkand/streamare terminal: their parsed message is the prompt and their duration is slept before the echo, so orchestrators can use them as a sleep / pacing primitive in-pmode.Diverges from real claude
--print, which sends/helpto the model as literal text. Documented in COMPATIBILITY.md.Test plan
go test ./...passesgo vetcleangofmt -lclean on files touched by this PRtestagent claude -p "/panel hi"renders panel and exits 0testagent claude -p "/exit 7"exits 7time testagent claude -p "/think 1s hi"≈ 1.01stestagent claude -p $'/panel one\n/panel two\nreal prompt'renders both panels then echoes[test-agent] real prompttestagent codex exec "/exit 3"exits 3testagent cursor --print "/panel hi"renders panel🤖 Generated with Claude Code