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",
|
command: "kiro-cli",
|
||||||
args: ["chat", "--no-interactive", "--wrap", "never"],
|
args: ["chat", "--no-interactive", "--wrap", "never"],
|
||||||
output: "text",
|
output: "text",
|
||||||
|
outputPrefix: "> ",
|
||||||
input: "arg",
|
input: "arg",
|
||||||
modelArg: "--model",
|
modelArg: "--model",
|
||||||
modelAliases: KIRO_MODEL_ALIASES,
|
modelAliases: KIRO_MODEL_ALIASES,
|
||||||
|
|||||||
@ -265,6 +265,19 @@ export async function runCliAgent(params: {
|
|||||||
const outputMode = useResume ? (backend.resumeOutput ?? backend.output) : backend.output;
|
const outputMode = useResume ? (backend.resumeOutput ?? backend.output) : backend.output;
|
||||||
|
|
||||||
if (outputMode === "text") {
|
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 };
|
return { text: stdout, sessionId: undefined };
|
||||||
}
|
}
|
||||||
if (outputMode === "jsonl") {
|
if (outputMode === "jsonl") {
|
||||||
|
|||||||
@ -55,6 +55,8 @@ export type CliBackendConfig = {
|
|||||||
output?: "json" | "text" | "jsonl";
|
output?: "json" | "text" | "jsonl";
|
||||||
/** Output parsing mode when resuming a CLI session. */
|
/** Output parsing mode when resuming a CLI session. */
|
||||||
resumeOutput?: "json" | "text" | "jsonl";
|
resumeOutput?: "json" | "text" | "jsonl";
|
||||||
|
/** For text output: prefix that marks response lines (e.g. "> " for kiro-cli). */
|
||||||
|
outputPrefix?: string;
|
||||||
/** Prompt input mode (default: arg). */
|
/** Prompt input mode (default: arg). */
|
||||||
input?: "arg" | "stdin";
|
input?: "arg" | "stdin";
|
||||||
/** Max prompt length for arg mode (if exceeded, stdin is used). */
|
/** Max prompt length for arg mode (if exceeded, stdin is used). */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user