fix: summarize agentrun status output
This commit is contained in:
+84
-2
@@ -96,7 +96,11 @@ export async function runAgentRunCommand(config: UniDeskConfig | null, args: str
|
||||
if (group === "control-plane") {
|
||||
if (action === "plan") return await controlPlanePlan(config, parseStatusOptions(actionArgs));
|
||||
if (action === "apply") return await controlPlaneApply(config, parseLaneConfirmOptions(actionArgs));
|
||||
if (action === "status") return await status(config, parseStatusOptions(actionArgs));
|
||||
if (action === "status") {
|
||||
const options = parseStatusOptions(actionArgs);
|
||||
const result = await status(config, options);
|
||||
return options.full || options.raw ? result : renderAgentRunControlPlaneStatusSummary(result);
|
||||
}
|
||||
if (action === "secret-sync") return await secretSync(config, parseSecretSyncOptions(actionArgs));
|
||||
if (action === "restart") return await restartYamlLane(config, parseLaneConfirmOptions(actionArgs));
|
||||
if (action === "expose") return await exposeAgentRun(config, parseConfirmOptions(actionArgs));
|
||||
@@ -2415,6 +2419,77 @@ function agentRunControlPlaneStatusCommand(spec: AgentRunLaneSpec, options: Pick
|
||||
].filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
function renderAgentRunControlPlaneStatusSummary(result: Record<string, unknown>): RenderedCliResult {
|
||||
const summary = record(result.summary);
|
||||
const target = record(result.target);
|
||||
const node = record(target.node);
|
||||
const runtimeTarget = record(target.runtime);
|
||||
const ciTarget = record(target.ci);
|
||||
const source = record(summary.source);
|
||||
const gitMirror = record(summary.gitMirror);
|
||||
const ci = record(summary.ci);
|
||||
const ciRun = record(ci.pipelineRun);
|
||||
const argo = record(summary.argo);
|
||||
const runtime = record(summary.runtime);
|
||||
const runtimeManager = record(runtime.manager);
|
||||
const nextAction = record(summary.nextAction);
|
||||
const next = record(result.next);
|
||||
const disclosure = record(result.disclosure);
|
||||
const timings = record(result.timings);
|
||||
const blockers = Array.isArray(summary.blockers) ? summary.blockers.map(String) : [];
|
||||
const warnings = Array.isArray(summary.warnings) ? summary.warnings.map(String) : [];
|
||||
const lines = [
|
||||
"AGENTRUN CONTROL-PLANE STATUS",
|
||||
renderTable(
|
||||
["NODE", "LANE", "NAMESPACE", "SOURCE", "PIPELINE", "ALIGNED", "RUNTIME", "BLOCKERS"],
|
||||
[[
|
||||
displayValue(node.id ?? target.node ?? "-"),
|
||||
displayValue(target.lane ?? "-"),
|
||||
displayValue(runtimeTarget.namespace ?? "-"),
|
||||
shortSha(summary.sourceCommit),
|
||||
displayValue(summary.expectedPipelineRun ?? "-"),
|
||||
yesNo(summary.aligned),
|
||||
yesNo(summary.runtimeAligned),
|
||||
blockers.length === 0 ? "-" : blockers.join(","),
|
||||
]],
|
||||
),
|
||||
"",
|
||||
renderTable(
|
||||
["COMPONENT", "STATUS", "DETAIL"],
|
||||
[
|
||||
["source", yesNo(source.workspaceClean), `branch=${displayValue(source.branch)} commit=${shortSha(source.remoteBranchCommit)} detached=${yesNo(source.workspaceDetached)}`],
|
||||
["git-mirror", yesNo(gitMirror.alreadySynced), `read=${yesNo(gitMirror.readReady)} write=${yesNo(gitMirror.writeReady)} gitops=${shortSha(gitMirror.gitopsCommit)}`],
|
||||
["ci", yesNo(ciRun.status === "True"), `run=${displayValue(ciRun.name)} status=${displayValue(ciRun.status)} reason=${displayValue(ciRun.reason)} evidenceMissing=${yesNo(ci.evidenceMissing)}`],
|
||||
["argo", yesNo(argo.syncedToGitops), `sync=${displayValue(argo.syncStatus)} health=${displayValue(argo.healthStatus)} revision=${shortSha(argo.revision)}`],
|
||||
["runtime", yesNo(runtimeManager.sourceMatchesExpected), `manager=${shortSha(runtimeManager.sourceCommit)} secrets=${yesNo(runtime.secretsReady)} dbSecret=${yesNo(runtime.databaseSecretPresent)} localPgAbsent=${yesNo(runtime.localPostgresAbsent)}`],
|
||||
],
|
||||
),
|
||||
"",
|
||||
warnings.length === 0 ? "WARNINGS\n-" : ["WARNINGS", ...warnings.map((warning) => `- ${warning}`)].join("\n"),
|
||||
"",
|
||||
"NEXT",
|
||||
` action: ${displayValue(nextAction.summary ?? "-")}`,
|
||||
nextAction.command ? ` run: ${displayValue(nextAction.command)}` : null,
|
||||
` full: ${displayValue(next.statusFull ?? disclosure.fullCommand ?? "bun scripts/cli.ts agentrun control-plane status --full")}`,
|
||||
"",
|
||||
`TIMINGS source=${displayValue(timings.sourceMs)}ms runtime=${displayValue(timings.runtimeMs)}ms gitMirror=${displayValue(timings.gitMirrorMs)}ms total=${displayValue(timings.totalMs)}ms`,
|
||||
].filter((line): line is string => line !== null);
|
||||
return renderedCliResult(result.ok !== false, "agentrun control-plane status", `${lines.join("\n")}\n`);
|
||||
}
|
||||
|
||||
function yesNo(value: unknown): string {
|
||||
if (value === true) return "yes";
|
||||
if (value === false) return "no";
|
||||
if (value === null || value === undefined) return "-";
|
||||
return displayValue(value);
|
||||
}
|
||||
|
||||
function shortSha(value: unknown): string {
|
||||
const text = displayValue(value);
|
||||
if (/^[0-9a-f]{40}$/u.test(text)) return text.slice(0, 12);
|
||||
return text;
|
||||
}
|
||||
|
||||
function compactLaneSecretsStatus(secrets: Record<string, unknown>): Record<string, unknown> {
|
||||
const items = Array.isArray(secrets.items) ? secrets.items.filter((item): item is Record<string, unknown> => typeof item === "object" && item !== null && !Array.isArray(item)) : [];
|
||||
const missing = items
|
||||
@@ -7012,7 +7087,14 @@ async function timedStatusStage<T>(stage: string, action: () => Promise<T>): Pro
|
||||
}
|
||||
|
||||
function progressEvent(event: string, payload: Record<string, unknown>): void {
|
||||
process.stderr.write(`${JSON.stringify({ event, at: new Date().toISOString(), ...payload })}\n`);
|
||||
const stage = displayValue(payload.stage ?? event);
|
||||
const status = displayValue(payload.status ?? "-");
|
||||
const details = [
|
||||
payload.exitCode === undefined ? null : `exit=${displayValue(payload.exitCode)}`,
|
||||
payload.elapsedMs === undefined ? null : `elapsed=${displayValue(payload.elapsedMs)}ms`,
|
||||
payload.error === undefined ? null : `error=${truncateOneLine(displayValue(payload.error), 160)}`,
|
||||
].filter((item): item is string => item !== null);
|
||||
process.stderr.write(`status ${stage} ${status}${details.length === 0 ? "" : ` ${details.join(" ")}`}\n`);
|
||||
}
|
||||
|
||||
function isCaptureResult(value: unknown): value is SshCaptureResult {
|
||||
|
||||
Reference in New Issue
Block a user