MCPcopy Create free account
hub / github.com/HKUDS/AgentSpace / runTaskCommand

Function runTaskCommand

apps/cli/src/commands/task.ts:10–121  ·  view source on GitHub ↗
(
  subcommand: string | undefined,
  args: string[],
  format: OutputFormat,
)

Source from the content-addressed store, hash-verified

8import { writeData, type OutputFormat } from "../lib/format.ts";
9
10export function runTaskCommand(
11 subcommand: string | undefined,
12 args: string[],
13 format: OutputFormat,
14): number {
15 if (subcommand === "list") {
16 const queuedByIssueId = new Map(listQueuedTasksSync().map((task) => [task.issueId ?? "", task]));
17 writeData(
18 format,
19 listTasksSync().map((task) => {
20 const queued = queuedByIssueId.get(task.id);
21 return {
22 ...task,
23 queueStatus: queued?.status ?? "",
24 runtimeId: queued?.runtimeId ?? "",
25 };
26 }),
27 );
28 return 0;
29 }
30
31 if (subcommand === "create") {
32 const { flags } = parseArgs(args);
33 const title = getStringFlag(flags, "title");
34 const channel = getStringFlag(flags, "channel");
35 const assignee = getStringFlag(flags, "assignee");
36 const priorityValue = getStringFlag(flags, "priority");
37 const priority = priorityValue === "low" || priorityValue === "high" ? priorityValue : "medium";
38
39 if (!title || !channel || !assignee) {
40 console.error(
41 'Usage: agent-space task create --title <title> --channel <name> --assignee <employee> [--priority low|medium|high] [--json]',
42 );
43 return 1;
44 }
45
46 const state = createTaskSync({
47 title,
48 channel,
49 assignee,
50 priority,
51 });
52
53 writeData(format, {
54 ok: true,
55 title,
56 channel,
57 assignee,
58 priority,
59 totalTasks: state.tasks.length,
60 });
61 return 0;
62 }
63
64 if (subcommand === "inspect") {
65 const { flags } = parseArgs(args);
66 const id = getStringFlag(flags, "id");
67

Callers 1

mainFunction · 0.90

Calls 9

listQueuedTasksSyncFunction · 0.90
writeDataFunction · 0.90
listTasksSyncFunction · 0.90
parseArgsFunction · 0.90
getStringFlagFunction · 0.90
createTaskSyncFunction · 0.90
updateTaskStatusSyncFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected