Show existing-agent schedules in CLI listings on request (#11243)

* Show how to include agent targets in schedule listings

* fix(cli): show the schedule hint in every table format

Use the renderer's output settings so the table alias includes the same hint about agent-target schedules.

Co-authored-by: Shane Su <26364206+suniceman@users.noreply.github.com>

---------

Co-authored-by: Shane Su <26364206+suniceman@users.noreply.github.com>
Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com>
This commit is contained in:
paseo-bot[bot]
2026-11-28 20:42:37 +00:00
committed by GitHub
co-authored by Shane Su
parent 9dc533fcd2
commit ddb15230b3
5 changed files with 47 additions and 9 deletions
+6 -3
View File
@@ -41,9 +41,12 @@ export function createScheduleCommand(): Command {
.option("--expires-in <duration>", "Time to live for the schedule"),
).action(withOutput(runCreateCommand));
addJsonAndDaemonHostOptions(schedule.command("ls").description("List schedules")).action(
withOutput(runLsCommand),
);
addJsonAndDaemonHostOptions(
schedule
.command("ls")
.description("List new-agent schedules")
.option("--all", "Include schedules targeting existing agents"),
).action(withOutput(runLsCommand));
addJsonAndDaemonHostOptions(
schedule.command("inspect").description("Inspect a schedule").argument("<id>", "Schedule ID"),
+12 -5
View File
@@ -1,5 +1,5 @@
import type { Command } from "commander";
import type { ListResult } from "../../output/index.js";
import { isHumanOutput, type ListResult } from "../../output/index.js";
import { scheduleSchema } from "./schema.js";
import {
connectScheduleClient,
@@ -10,7 +10,7 @@ import {
} from "./shared.js";
export async function runLsCommand(
options: ScheduleCommandOptions,
options: ScheduleCommandOptions & { all?: boolean },
_command: Command,
): Promise<ListResult<ScheduleRow>> {
const { client } = await connectScheduleClient(options.daemonTarget);
@@ -19,11 +19,18 @@ export async function runLsCommand(
if (payload.error) {
throw new Error(payload.error);
}
const visible = options.all
? payload.schedules
: payload.schedules.filter((schedule) => schedule.target.type === "new-agent");
const hiddenCount = payload.schedules.length - visible.length;
if (hiddenCount > 0 && isHumanOutput(options)) {
console.error(
`Schedules targeting existing agents: ${hiddenCount} hidden. Use --all to include them.`,
);
}
return {
type: "list",
data: payload.schedules
.filter((schedule) => schedule.target.type === "new-agent")
.map(toScheduleRow),
data: visible.map(toScheduleRow),
schema: scheduleSchema,
};
} catch (error) {
+6 -1
View File
@@ -60,4 +60,9 @@ export {
} from "./render-async.js";
// Command wrapper
export { withOutput, createOutputOptions, type CommandOptions } from "./with-output.js";
export {
withOutput,
createOutputOptions,
isHumanOutput,
type CommandOptions,
} from "./with-output.js";
+5
View File
@@ -63,6 +63,11 @@ function extractOutputOptions(options: CommandOptions): OutputOptions {
};
}
export function isHumanOutput(options: CommandOptions): boolean {
const { format, quiet } = extractOutputOptions(options);
return format === "table" && !quiet;
}
/**
* Wrap a command handler to automatically render output.
*
+18
View File
@@ -294,6 +294,24 @@ try {
const createdJson = JSON.parse(created.stdout);
assert.strictEqual(createdJson.target, "agent:0000000");
const human = await ctx.paseo(["schedule", "ls"]);
assert.strictEqual(human.exitCode, 0, human.stderr);
assert.match(human.stderr, /1 hidden.*--all/);
const alias = await ctx.paseo(["--format", "cli", "schedule", "ls"]);
assert.strictEqual(alias.exitCode, 0, alias.stderr);
assert.match(alias.stderr, /1 hidden.*--all/);
const all = await ctx.paseo(["schedule", "ls", "--all", "--json"]);
assert.strictEqual(all.exitCode, 0, all.stderr);
assert(
JSON.parse(all.stdout).some(
(row: { id: string; target: string }) =>
row.id === createdJson.id && row.target === createdJson.target,
),
all.stdout,
);
const deleted = await ctx.paseo(["schedule", "delete", createdJson.id, "--json"]);
assert.strictEqual(deleted.exitCode, 0, deleted.stderr);
assert.strictEqual(JSON.parse(deleted.stdout).id, createdJson.id);