Restore global agent listing (#1420)

This commit is contained in:
Mohamed Boudra
2026-06-08 23:53:54 +08:00
committed by GitHub
parent a6d0046c97
commit b04ff0e6b8
3 changed files with 38 additions and 6 deletions
+29 -1
View File
@@ -23,11 +23,39 @@ describe("buildAgentLsFetchOptions", () => {
}); });
}); });
it("uses the unscoped archived query for -a", () => { it("fetches global non-archived agents for -g", () => {
expect(buildAgentLsFetchOptions({ global: true })).toEqual({});
});
it("keeps -a within the active scope", () => {
expect(buildAgentLsFetchOptions({ all: true })).toEqual({ expect(buildAgentLsFetchOptions({ all: true })).toEqual({
scope: "active",
filter: { filter: {
includeArchived: true, includeArchived: true,
}, },
}); });
}); });
it("fetches all global agents for -a -g", () => {
expect(buildAgentLsFetchOptions({ all: true, global: true })).toEqual({
filter: {
includeArchived: true,
},
});
});
it("applies filters to global queries", () => {
expect(
buildAgentLsFetchOptions({
global: true,
label: ["surface=workspace"],
thinking: " medium ",
}),
).toEqual({
filter: {
labels: { surface: "workspace" },
thinkingOptionId: "medium",
},
});
});
}); });
+7 -5
View File
@@ -13,7 +13,7 @@ export function addLsOptions(cmd: Command): Command {
return cmd return cmd
.description("List agents. By default excludes archived agents.") .description("List agents. By default excludes archived agents.")
.option("-a, --all", "Include archived agents") .option("-a, --all", "Include archived agents")
.option("-g, --global", "Legacy no-op (kept for compatibility)") .option("-g, --global", "List agents across all directories")
.option( .option(
"--label <key=value>", "--label <key=value>",
"Filter by label (can be used multiple times)", "Filter by label (can be used multiple times)",
@@ -107,7 +107,7 @@ export type AgentLsResult = ListResult<AgentListItem>;
export interface AgentLsOptions extends CommandOptions { export interface AgentLsOptions extends CommandOptions {
/** -a: Include archived agents */ /** -a: Include archived agents */
all?: boolean; all?: boolean;
/** Legacy flag retained for CLI compatibility */ /** -g: List agents across all directories */
global?: boolean; global?: boolean;
/** Filter by specific status */ /** Filter by specific status */
status?: string; status?: string;
@@ -133,7 +133,7 @@ function parseLabelFilters(labels: string[] | undefined): Record<string, string>
} }
export function buildAgentLsFetchOptions( export function buildAgentLsFetchOptions(
options: Pick<AgentLsOptions, "all" | "label" | "thinking">, options: Pick<AgentLsOptions, "all" | "global" | "label" | "thinking">,
): FetchAgentsOptions { ): FetchAgentsOptions {
const labelFilters = parseLabelFilters(options.label); const labelFilters = parseLabelFilters(options.label);
const normalizedThinkingOptionId = options.thinking?.trim(); const normalizedThinkingOptionId = options.thinking?.trim();
@@ -150,7 +150,7 @@ export function buildAgentLsFetchOptions(
} }
const fetchOptions: FetchAgentsOptions = {}; const fetchOptions: FetchAgentsOptions = {};
if (!options.all) { if (!options.global) {
fetchOptions.scope = "active"; fetchOptions.scope = "active";
} }
if (Object.keys(daemonFilter).length > 0) { if (Object.keys(daemonFilter).length > 0) {
@@ -162,7 +162,9 @@ export function buildAgentLsFetchOptions(
/** /**
* Agent ls command semantics: * Agent ls command semantics:
* - `paseo agent ls` → active non-archived agents * - `paseo agent ls` → active non-archived agents
* - `paseo agent ls -a` → include archived agents * - `paseo agent ls -g` → global non-archived agents
* - `paseo agent ls -a` → active agents, including archived
* - `paseo agent ls -ag` → global agents, including archived
*/ */
export async function runLsCommand( export async function runLsCommand(
options: AgentLsOptions, options: AgentLsOptions,
+2
View File
@@ -50,6 +50,8 @@ try {
assert(result.stdout.includes("--all"), "help should mention --all flag"); assert(result.stdout.includes("--all"), "help should mention --all flag");
assert(result.stdout.includes("-g"), "help should mention -g flag"); assert(result.stdout.includes("-g"), "help should mention -g flag");
assert(result.stdout.includes("--global"), "help should mention --global flag"); assert(result.stdout.includes("--global"), "help should mention --global flag");
assert(result.stdout.includes("across all directories"), "help should describe global scope");
assert(!result.stdout.includes("Legacy no-op"), "help should not describe -g as a no-op");
assert(result.stdout.includes("--host"), "help should mention --host option"); assert(result.stdout.includes("--host"), "help should mention --host option");
assert(!result.stdout.includes("--ui"), "help should not mention --ui"); assert(!result.stdout.includes("--ui"), "help should not mention --ui");
console.log("✓ paseo ls --help shows options\n"); console.log("✓ paseo ls --help shows options\n");