Skip to main content

Module modes

Module modes 

Source
Expand description

Output modes. Mirrors the v1-relevant slice of the TS packages/coding-agent/src/modes/{print-mode,json-event,rpc-mode}.ts — the three run shapes a harness-backed CLI needs:

  • [print] — single-shot: send the prompt(s), print the final assistant text (or the error) to stdout, exit. Mirrors TS runPrintMode (text mode).
  • json — single-shot streaming: emit each harness event as a JSON line on stdout, then the final outcome. Mirrors TS runPrintMode (mode === "json") + [json_event::toJsonEvent].
  • interactive — a minimal line-oriented REPL: read prompts from stdin, run each, print the assistant text, loop until EOF / /exit. v1 does NOT port the TS InteractiveMode TUI (modes/interactive/* — a full terminal UI with Ink/React components); this is a deliberately minimal replacement, documented in docs/m6-cli-open-questions.md.

All three drive the same AgentHarness via AgentLane::prompt_text.

Functions§

assistant_text
Extract the concatenated text content from an assistant message. Mirrors the TS print-mode loop (for content of assistantMsg.content if type===text).
interactive
interactive mode: a minimal line-oriented REPL. NOT a port of the TS TUI.
json
json mode: emit each harness event as a JSON line on stdout, run the prompts, then emit a terminal result line carrying the outcome + final text. Mirrors TS runPrintMode (mode === "json") streaming every event.
outcome_exit_code
The exit code a run’s outcome maps to. Mirrors TS print mode: error/aborted ⇒ exit 1; everything else ⇒ 0.
print
print mode: send the initial message (prompt text + inline @file expansions), then any follow-up messages, print the final assistant text, return the exit code. Mirrors TS runPrintMode (text).