fix: polish agentrun mutation next steps
This commit is contained in:
@@ -592,7 +592,7 @@ function renderResultSummary(command: string, raw: Record<string, unknown>, opti
|
||||
return renderedCliResult(raw.ok !== false, command, lines.join("\n"));
|
||||
}
|
||||
|
||||
function renderMutationSummary(command: string, raw: Record<string, unknown>, options: AgentRunResourceOptions, headline: string): RenderedCliResult {
|
||||
function renderMutationSummary(command: string, raw: Record<string, unknown>, options: AgentRunResourceOptions, headline: string, overrideNextLines?: string[]): RenderedCliResult {
|
||||
if (options.raw) return renderMachine(command, raw, "json", raw.ok !== false);
|
||||
if (options.output === "json" || options.output === "yaml") return renderMachine(command, raw, options.output, raw.ok !== false);
|
||||
const data = record(innerData(raw));
|
||||
@@ -603,11 +603,15 @@ function renderMutationSummary(command: string, raw: Record<string, unknown>, op
|
||||
];
|
||||
if (id !== null) lines.push(`Name: ${id}`);
|
||||
const next = record(raw.next ?? data.next);
|
||||
const nextLines = Object.values(next).map(String).filter((line) => line.length > 0).slice(0, 5);
|
||||
const nextLines = (overrideNextLines ?? Object.values(next).map(String)).filter((line) => line.length > 0).slice(0, 5);
|
||||
if (nextLines.length > 0) lines.push("", "Next:", ...nextLines.map((line) => ` ${line}`));
|
||||
return renderedCliResult(raw.ok !== false, command, lines.join("\n"));
|
||||
}
|
||||
|
||||
function rerunWithoutDryRun(command: string): string {
|
||||
return `bun scripts/cli.ts ${command.replace(/\s+--dry-run\b/gu, "").trim()}`;
|
||||
}
|
||||
|
||||
function renderMachine(command: string, value: unknown, mode: "json" | "yaml", ok = true): RenderedCliResult {
|
||||
const text = mode === "json" ? `${JSON.stringify(value, null, 2)}\n` : `${Bun.YAML.stringify(value)}\n`;
|
||||
return renderedCliResult(ok, command, text, mode === "json" ? "application/json" : "application/yaml");
|
||||
|
||||
Reference in New Issue
Block a user