@bbigbang/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cliSupport.d.ts +166 -0
- package/dist/cliSupport.js +1306 -0
- package/dist/commandCatalog.d.ts +36 -0
- package/dist/commandCatalog.js +152 -0
- package/dist/commands/actionCommands.d.ts +3 -0
- package/dist/commands/actionCommands.js +43 -0
- package/dist/commands/authManualCommands.d.ts +3 -0
- package/dist/commands/authManualCommands.js +60 -0
- package/dist/commands/channelWorkspaceCommands.d.ts +3 -0
- package/dist/commands/channelWorkspaceCommands.js +105 -0
- package/dist/commands/contextCommands.d.ts +3 -0
- package/dist/commands/contextCommands.js +253 -0
- package/dist/commands/memoryCommands.d.ts +3 -0
- package/dist/commands/memoryCommands.js +154 -0
- package/dist/commands/messageCommands.d.ts +3 -0
- package/dist/commands/messageCommands.js +241 -0
- package/dist/commands/panelCommands.d.ts +3 -0
- package/dist/commands/panelCommands.js +218 -0
- package/dist/commands/reminderCommands.d.ts +3 -0
- package/dist/commands/reminderCommands.js +220 -0
- package/dist/commands/skillToolAttachmentCommands.d.ts +3 -0
- package/dist/commands/skillToolAttachmentCommands.js +261 -0
- package/dist/commands/taskCommands.d.ts +3 -0
- package/dist/commands/taskCommands.js +195 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/manual/generated/command-catalog.json +12452 -0
- package/dist/manual/topics/cli-overview.md +116 -0
- package/dist/manual/topics/commands.md +706 -0
- package/dist/manual/topics/examples.md +194 -0
- package/dist/manual/topics/index.md +11 -0
- package/dist/program.d.ts +5 -0
- package/dist/program.js +52 -0
- package/package.json +43 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { AGENT_COMMAND_ERROR_CODES, AgentCommandError, MUTATION_HINTS, appendCommonBody, createRuntime, formatTaskHeld, isHeldResponse, normalizeAgentTaskStatus, normalizeTaskListStatus, normalizeTaskScope, parseJsonStringOrThrow, parsePositiveInteger, parsePositiveIntegerList, parseRequiredPositiveInteger, readOptionalStdin, repeatOption, requireString, responseError, summarizeClaimResults, summarizeTaskHistory, summarizeTaskList, summarizeTaskLookup, withHint, writeOutput } from '../cliSupport.js';
|
|
2
|
+
export function registerTaskCommands(program, options) {
|
|
3
|
+
const task = program.command('task').description('Task operations');
|
|
4
|
+
task.command('create')
|
|
5
|
+
.description('Create tasks from stdin JSON or flags')
|
|
6
|
+
.option('--channel <target>', 'Channel or DM target')
|
|
7
|
+
.option('--title <title>', 'Task title; repeatable', repeatOption)
|
|
8
|
+
.option('--description <text>', 'Task description when using --title')
|
|
9
|
+
.action(async (opts) => {
|
|
10
|
+
const runtime = createRuntime(program, options);
|
|
11
|
+
const stdin = (await readOptionalStdin(runtime.io.stdin)) ?? '';
|
|
12
|
+
const body = stdin
|
|
13
|
+
? parseJsonStringOrThrow(stdin, 'task create JSON payload')
|
|
14
|
+
: (() => {
|
|
15
|
+
const titles = opts.title ?? [];
|
|
16
|
+
if (titles.length === 0) {
|
|
17
|
+
throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.INVALID_ARG, '--title is required when no task create JSON payload is piped on stdin.');
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
channel: requireString(opts.channel, '--channel'),
|
|
21
|
+
tasks: titles.map((title) => ({
|
|
22
|
+
title,
|
|
23
|
+
description: requireString(opts.description, '--description'),
|
|
24
|
+
})),
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks`, appendCommonBody(runtime, body));
|
|
28
|
+
if (!response.ok)
|
|
29
|
+
throw responseError(response, 'create tasks failed');
|
|
30
|
+
const data = response.data;
|
|
31
|
+
writeOutput(runtime, withHint(`Created ${data?.tasks?.length ?? 0} task(s).`, MUTATION_HINTS.taskCreate), response.data);
|
|
32
|
+
});
|
|
33
|
+
task.command('list')
|
|
34
|
+
.description('List tasks for a channel or DM target')
|
|
35
|
+
.requiredOption('--channel <target>', 'Channel or canonical DM target')
|
|
36
|
+
.option('--status <status>', 'Filter: all, todo, in_progress, in_review, done', 'all')
|
|
37
|
+
.action(async (opts) => {
|
|
38
|
+
const runtime = createRuntime(program, options);
|
|
39
|
+
const channel = requireString(opts.channel, '--channel');
|
|
40
|
+
const status = normalizeTaskListStatus(opts.status);
|
|
41
|
+
const params = new URLSearchParams();
|
|
42
|
+
params.set('channel', channel);
|
|
43
|
+
if (status !== 'all')
|
|
44
|
+
params.set('status', status);
|
|
45
|
+
const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks?${params.toString()}`);
|
|
46
|
+
if (!response.ok)
|
|
47
|
+
throw responseError(response, 'list tasks failed');
|
|
48
|
+
writeOutput(runtime, summarizeTaskList(response.data, 'No tasks found.'), response.data);
|
|
49
|
+
});
|
|
50
|
+
task.command('my')
|
|
51
|
+
.description('List tasks visible to the current agent')
|
|
52
|
+
.option('--status <status>', 'Filter: all, todo, in_progress, in_review, done', 'all')
|
|
53
|
+
.option('--scope <scope>', 'Scope: all, dm, channel', 'all')
|
|
54
|
+
.action(async (opts) => {
|
|
55
|
+
const runtime = createRuntime(program, options);
|
|
56
|
+
const status = normalizeTaskListStatus(opts.status);
|
|
57
|
+
const scope = normalizeTaskScope(opts.scope);
|
|
58
|
+
const params = new URLSearchParams();
|
|
59
|
+
params.set('status', status);
|
|
60
|
+
params.set('scope', scope);
|
|
61
|
+
const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/my-tasks?${params.toString()}`);
|
|
62
|
+
if (!response.ok)
|
|
63
|
+
throw responseError(response, 'list my tasks failed');
|
|
64
|
+
writeOutput(runtime, summarizeTaskList(response.data, 'No visible tasks found.'), response.data);
|
|
65
|
+
});
|
|
66
|
+
task.command('status')
|
|
67
|
+
.description('Read one task by agent task ref')
|
|
68
|
+
.requiredOption('--task-ref <ref>', 'Agent task ref, e.g. task_ab12cd34ef56')
|
|
69
|
+
.action(async (opts) => {
|
|
70
|
+
const runtime = createRuntime(program, options);
|
|
71
|
+
const params = new URLSearchParams();
|
|
72
|
+
params.set('task_ref', requireString(opts.taskRef, '--task-ref'));
|
|
73
|
+
const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/by-ref?${params.toString()}`);
|
|
74
|
+
if (!response.ok)
|
|
75
|
+
throw responseError(response, 'task status failed');
|
|
76
|
+
writeOutput(runtime, summarizeTaskLookup(response.data), response.data);
|
|
77
|
+
});
|
|
78
|
+
task.command('history')
|
|
79
|
+
.description('Read task history events by agent task ref')
|
|
80
|
+
.requiredOption('--task-ref <ref>', 'Agent task ref, e.g. task_ab12cd34ef56')
|
|
81
|
+
.option('--limit <n>', 'Maximum events')
|
|
82
|
+
.action(async (opts) => {
|
|
83
|
+
const runtime = createRuntime(program, options);
|
|
84
|
+
const params = new URLSearchParams();
|
|
85
|
+
params.set('task_ref', requireString(opts.taskRef, '--task-ref'));
|
|
86
|
+
const limit = parsePositiveInteger('limit', opts.limit);
|
|
87
|
+
if (limit !== undefined)
|
|
88
|
+
params.set('limit', String(Math.min(limit, 200)));
|
|
89
|
+
const response = await runtime.client.request('GET', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/history?${params.toString()}`);
|
|
90
|
+
if (!response.ok)
|
|
91
|
+
throw responseError(response, 'task history failed');
|
|
92
|
+
writeOutput(runtime, summarizeTaskHistory(response.data), response.data);
|
|
93
|
+
});
|
|
94
|
+
task.command('claim')
|
|
95
|
+
.description('Claim existing tasks or promote messages into claimed tasks')
|
|
96
|
+
.requiredOption('--channel <target>', 'Channel or DM target')
|
|
97
|
+
.option('--task-number <n>', 'Task number to claim; repeatable', repeatOption)
|
|
98
|
+
.option('--message-id <id>', 'Message id/prefix to promote and claim; repeatable', repeatOption)
|
|
99
|
+
.option('--title <title>', 'Optional title override when claiming by message id')
|
|
100
|
+
.option('--description <text>', 'Required brief when claiming by message id')
|
|
101
|
+
.option('--collaborator-name <name>', 'Collaborator agent name; repeatable', repeatOption)
|
|
102
|
+
.action(async (opts) => {
|
|
103
|
+
const runtime = createRuntime(program, options);
|
|
104
|
+
const taskNumbers = parsePositiveIntegerList('task-number', opts.taskNumber);
|
|
105
|
+
const messageIds = Array.isArray(opts.messageId)
|
|
106
|
+
? opts.messageId.map((value) => value.trim()).filter(Boolean)
|
|
107
|
+
: undefined;
|
|
108
|
+
if ((!taskNumbers || taskNumbers.length === 0) && (!messageIds || messageIds.length === 0)) {
|
|
109
|
+
throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.INVALID_ARG, 'Provide at least one --task-number or --message-id.');
|
|
110
|
+
}
|
|
111
|
+
if (messageIds?.length && !String(opts.description ?? '').trim()) {
|
|
112
|
+
throw new AgentCommandError(AGENT_COMMAND_ERROR_CODES.INVALID_ARG, '--description is required when claiming by --message-id.');
|
|
113
|
+
}
|
|
114
|
+
const collaborators = Array.isArray(opts.collaboratorName)
|
|
115
|
+
? opts.collaboratorName.map((value) => value.trim()).filter(Boolean)
|
|
116
|
+
: undefined;
|
|
117
|
+
const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/claim`, appendCommonBody(runtime, {
|
|
118
|
+
channel: requireString(opts.channel, '--channel'),
|
|
119
|
+
...(taskNumbers?.length ? { task_numbers: taskNumbers } : {}),
|
|
120
|
+
...(messageIds?.length ? { message_ids: messageIds } : {}),
|
|
121
|
+
...(opts.title ? { title: String(opts.title) } : {}),
|
|
122
|
+
...(opts.description ? { description: String(opts.description) } : {}),
|
|
123
|
+
...(collaborators?.length ? { collaborator_names: collaborators } : {}),
|
|
124
|
+
}));
|
|
125
|
+
if (!response.ok)
|
|
126
|
+
throw responseError(response, 'claim tasks failed');
|
|
127
|
+
writeOutput(runtime, withHint(summarizeClaimResults(response.data), MUTATION_HINTS.taskClaim), response.data);
|
|
128
|
+
});
|
|
129
|
+
task.command('unclaim')
|
|
130
|
+
.description('Release the current agent claim on a task')
|
|
131
|
+
.requiredOption('--channel <target>', 'Channel or DM target')
|
|
132
|
+
.requiredOption('--number <n>', 'Task number to unclaim')
|
|
133
|
+
.action(async (opts) => {
|
|
134
|
+
const runtime = createRuntime(program, options);
|
|
135
|
+
const taskNumber = parseRequiredPositiveInteger('number', opts.number);
|
|
136
|
+
const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/unclaim`, appendCommonBody(runtime, {
|
|
137
|
+
channel: requireString(opts.channel, '--channel'),
|
|
138
|
+
task_number: taskNumber,
|
|
139
|
+
}));
|
|
140
|
+
if (!response.ok)
|
|
141
|
+
throw responseError(response, 'unclaim task failed');
|
|
142
|
+
writeOutput(runtime, `Task #${taskNumber} unclaimed.`, response.data);
|
|
143
|
+
});
|
|
144
|
+
task.command('update')
|
|
145
|
+
.description('Update task status')
|
|
146
|
+
.requiredOption('--channel <target>', 'Channel target')
|
|
147
|
+
.requiredOption('--number <n>', 'Task number')
|
|
148
|
+
.requiredOption('--status <status>', 'New status')
|
|
149
|
+
.action(async (opts) => {
|
|
150
|
+
const runtime = createRuntime(program, options);
|
|
151
|
+
const channel = requireString(opts.channel, '--channel');
|
|
152
|
+
const taskNumber = parseRequiredPositiveInteger('number', opts.number);
|
|
153
|
+
const status = normalizeAgentTaskStatus(opts.status);
|
|
154
|
+
const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/update-status`, appendCommonBody(runtime, {
|
|
155
|
+
channel,
|
|
156
|
+
task_number: taskNumber,
|
|
157
|
+
status,
|
|
158
|
+
}));
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
if (isHeldResponse(response.data)) {
|
|
161
|
+
writeOutput(runtime, formatTaskHeld('update', channel, response.data), response.data);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
throw responseError(response, 'update task status failed');
|
|
165
|
+
}
|
|
166
|
+
writeOutput(runtime, `Task #${taskNumber} moved to ${status}.`, response.data);
|
|
167
|
+
});
|
|
168
|
+
task.command('update-details')
|
|
169
|
+
.description('Update a task title and brief')
|
|
170
|
+
.requiredOption('--channel <target>', 'Channel or DM target')
|
|
171
|
+
.requiredOption('--number <n>', 'Task number')
|
|
172
|
+
.requiredOption('--title <title>', 'New task title')
|
|
173
|
+
.requiredOption('--description <text>', 'New task brief')
|
|
174
|
+
.action(async (opts) => {
|
|
175
|
+
const runtime = createRuntime(program, options);
|
|
176
|
+
const channel = requireString(opts.channel, '--channel');
|
|
177
|
+
const taskNumber = parseRequiredPositiveInteger('number', opts.number);
|
|
178
|
+
const title = requireString(opts.title, '--title');
|
|
179
|
+
const description = requireString(opts.description, '--description');
|
|
180
|
+
const response = await runtime.client.request('POST', `/api/internal/agent/${encodeURIComponent(runtime.context.agentId)}/tasks/update-details`, appendCommonBody(runtime, {
|
|
181
|
+
channel,
|
|
182
|
+
task_number: taskNumber,
|
|
183
|
+
title,
|
|
184
|
+
description,
|
|
185
|
+
}));
|
|
186
|
+
if (!response.ok) {
|
|
187
|
+
if (isHeldResponse(response.data)) {
|
|
188
|
+
writeOutput(runtime, formatTaskHeld('update', channel, response.data), response.data);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
throw responseError(response, 'update task details failed');
|
|
192
|
+
}
|
|
193
|
+
writeOutput(runtime, `Task #${taskNumber} details updated.`, response.data);
|
|
194
|
+
});
|
|
195
|
+
}
|
package/dist/index.d.ts
ADDED