diff --git a/src/agents/cli-backends.ts b/src/agents/cli-backends.ts index 76ec76fa0..4b62a088d 100644 --- a/src/agents/cli-backends.ts +++ b/src/agents/cli-backends.ts @@ -90,6 +90,7 @@ const DEFAULT_KIRO_BACKEND: CliBackendConfig = { command: "kiro-cli", args: ["chat", "--no-interactive", "--wrap", "never"], output: "text", + outputPrefix: "> ", input: "arg", modelArg: "--model", modelAliases: KIRO_MODEL_ALIASES, diff --git a/src/agents/cli-runner.ts b/src/agents/cli-runner.ts index 6f57c0846..0a3228737 100644 --- a/src/agents/cli-runner.ts +++ b/src/agents/cli-runner.ts @@ -265,6 +265,19 @@ export async function runCliAgent(params: { const outputMode = useResume ? (backend.resumeOutput ?? backend.output) : backend.output; if (outputMode === "text") { + // If outputPrefix is set, extract only lines starting with that prefix + if (backend.outputPrefix) { + const prefix = backend.outputPrefix; + const lines = stdout.split("\n"); + const responseLines: string[] = []; + for (const line of lines) { + if (line.startsWith(prefix)) { + responseLines.push(line.slice(prefix.length)); + } + } + const text = responseLines.join("\n").trim(); + return { text: text || stdout, sessionId: undefined }; + } return { text: stdout, sessionId: undefined }; } if (outputMode === "jsonl") { diff --git a/src/config/types.agent-defaults.ts b/src/config/types.agent-defaults.ts index 2a42d3623..d2b57a324 100644 --- a/src/config/types.agent-defaults.ts +++ b/src/config/types.agent-defaults.ts @@ -55,6 +55,8 @@ export type CliBackendConfig = { output?: "json" | "text" | "jsonl"; /** Output parsing mode when resuming a CLI session. */ resumeOutput?: "json" | "text" | "jsonl"; + /** For text output: prefix that marks response lines (e.g. "> " for kiro-cli). */ + outputPrefix?: string; /** Prompt input mode (default: arg). */ input?: "arg" | "stdin"; /** Max prompt length for arg mode (if exceeded, stdin is used). */