feat(cli): NDJSON stdin protocol, list subcommands, modularize run.ts#11597
Merged
feat(cli): NDJSON stdin protocol, list subcommands, modularize run.ts#11597
Conversation
…e run.ts Overhaul the stdin prompt stream from raw text lines to a structured NDJSON command protocol (start/message/cancel/ping/shutdown) with requestId correlation, ack/done/error lifecycle events, and queue telemetry. Add list subcommands (commands, modes, models) for programmatic discovery. Extract stdin stream logic from run.ts into stdin-stream.ts and add shared isRecord guard utility. Includes unit tests for all new modules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <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
start,message,cancel,ping,shutdown) withrequestIdcorrelation, ack/done/error lifecycle events, and queue telemetrylist commands,list modes, andlist modelsfor programmatic discovery of available resources (JSON and text output formats)stdin-stream.ts, reducingrun.tsfrom 917 to ~330 lines. Extract sharedisRecordtype guard intolib/utils/guards.tsemitControl()andemitQueue()methods,requestIdProviderfor automatic correlation, and schema/protocol/capabilities metadata foriniteventsFiles changed
src/commands/cli/stdin-stream.tssrc/commands/cli/list.tsrequestFromExtension<T>helpersrc/lib/utils/guards.tsisRecordtype guardsrc/commands/cli/run.tsrunStdinStreamMode()callsrc/agent/json-event-emitter.tssrc/types/json-events.tscontrol/queueevent types, new fieldssrc/commands/cli/index.tssrc/index.tsscripts/test-stdin-stream.tsTests added
parse-stdin-command.test.ts— 19 tests for NDJSON command parsing (valid commands, error cases)json-event-emitter-control.test.ts— 8 tests for control event emission and requestId injectionlist.test.ts— 6 tests forparseFormatutilityguards.test.ts— 5 tests forisRecordtype guardTest plan
pnpm lintpasses (0 warnings)pnpm check-typespassespnpm testpasses (438 tests, 0 failures)scripts/test-stdin-stream.tsagainst a running provider🤖 Generated with Claude Code
Start a new Roo Code Cloud session on this branch