fix(kiro-cli): parse output prefix to strip banner from responses
This commit is contained in:
parent
f17b614d50
commit
5f8e2be75a
@ -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,
|
||||
|
||||
@ -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") {
|
||||
|
||||
@ -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). */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user