@getgavel/cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/gavel.js +80 -5
  2. package/package.json +1 -1
package/dist/gavel.js CHANGED
@@ -44,11 +44,28 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
44
44
  what you did with the answer
45
45
  gavel inbox what's waiting on you
46
46
  gavel status (<title> | --text <words>) [--description <words>] [--folders <a,b>]
47
- [--state working|blocked|idle] [--issue <MA-482>] [--waiting-on <email or agent>]
47
+ [--state working|blocked|idle] [--issue <MA-482>] [--waiting-on <email or agent>] [--item <W-12>]
48
48
  what you're doing now: a title of two to four words in
49
49
  title case ("Privacy Page & Terms"; "" clears it), and a
50
50
  sentence or two in --description; --waiting-on names the
51
- person or agent you're blocked on
51
+ person or agent you're blocked on; --item your work item,
52
+ which follows your state (Building, or Blocked)
53
+ gavel work file (<title> | --title <words>) [--status <status>] [--description <words>]
54
+ [--worker <email or agent> | --worker none] [--reporter <email or agent>]
55
+ [--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]...
56
+ a work item on the Board's Being done (W-12), when you
57
+ start: you're its worker unless you name another, Backlog
58
+ unless --status (Triage, Backlog, Needs Decision, Queued,
59
+ Building, Blocked, Deployed, Icebox, Closed, Duplicate)
60
+ gavel work move <W-12> [<status>] [--waiting-on <email or agent>] [--decision <D-12>]
61
+ [--code <url>]... [--worker <email or agent> | --worker none] [--title <words>]
62
+ [--description <words>]
63
+ move it as your work moves: Building, Blocked with
64
+ --waiting-on, Needs Decision with --decision, Deployed
65
+ with --code (a commit or pull request; again for each)
66
+ gavel work show <W-12> an item and its history
67
+ gavel work list [--worker me|<email or agent>] [--status <status>] [--open true]
68
+ the workspace's items, the latest changed first
52
69
  gavel message (--to-agent <id> | --to-person <email>) (<text> | --text <words>) [--decision <D-12>]
53
70
  start a conversation with another agent
54
71
  gavel message --conversation <C-12> (<text> | --text <words>)
@@ -108,7 +125,8 @@ const FLAGS = {
108
125
  answer: ["response"],
109
126
  act: ["note"],
110
127
  inbox: [],
111
- status: ["text", "description", "folders", "state", "issue", "waiting-on"],
128
+ status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
129
+ work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "open"],
112
130
  message: ["to-agent", "to-person", "conversation", "text", "decision"],
113
131
  conversations: [],
114
132
  "wait-for-reply": ["timeout"],
@@ -143,12 +161,15 @@ export function usageOf(command) {
143
161
  }
144
162
  class UsageError extends Error {
145
163
  }
164
+ // Only --option (a multiple question's picks) and --code (a work item's commits and pull requests)
165
+ // may come again: `flags` holds each flag's value and `lists` every one given.
166
+ const REPEATABLE = ["option", "code"];
146
167
  export function parseArgs(argv, command) {
147
168
  const positional = [];
148
169
  const flags = {};
149
170
  const lists = {};
150
171
  const set = (name, value) => {
151
- if (Object.hasOwn(flags, name) && name !== "option")
172
+ if (Object.hasOwn(flags, name) && !REPEATABLE.includes(name))
152
173
  throw new UsageError(`give --${name} once`);
153
174
  flags[name] = value;
154
175
  (lists[name] ??= []).push(value);
@@ -175,6 +196,58 @@ export function parseArgs(argv, command) {
175
196
  }
176
197
  return { positional, flags, lists };
177
198
  }
199
+ // gavel work file|move|show|list: a work item on the Board's Being done (features/work).
200
+ function workRequest(p, f, code) {
201
+ const [sub, ...rest] = p;
202
+ const only = (allowed) => {
203
+ const extra = Object.keys(f).find((k) => !allowed.includes(k));
204
+ if (extra)
205
+ throw new UsageError(`work ${sub} doesn't take --${extra}`);
206
+ };
207
+ const worker = f.worker === undefined ? undefined : f.worker === "none" ? null : f.worker;
208
+ const description = f.description === undefined ? undefined : readText(f.description);
209
+ const links = code.length ? code.map((url) => ({ url })) : undefined;
210
+ const ref = (value) => {
211
+ if (!value || !/^W-\d+$/i.test(value))
212
+ throw new UsageError(`work ${sub} needs its item, like W-12`);
213
+ return encodeURIComponent(value.toUpperCase());
214
+ };
215
+ switch (sub) {
216
+ case "file": {
217
+ only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code"]);
218
+ if (f.title !== undefined && rest.length)
219
+ throw new UsageError("give the title once: as words or as --title");
220
+ const title = readText(need(f.title ?? rest.join(" "), "the item's title"));
221
+ return { method: "POST", path: "/v1/work", body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links }) };
222
+ }
223
+ case "move": {
224
+ only(["title", "status", "description", "worker", "waiting-on", "decision", "code"]);
225
+ const [item, ...words] = rest;
226
+ if (f.status !== undefined && words.length)
227
+ throw new UsageError("give the status once: as words or as --status");
228
+ const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links });
229
+ if (!Object.keys(body).length)
230
+ throw new UsageError("work move needs a status or something to change");
231
+ return { method: "PATCH", path: `/v1/work/${ref(item)}`, body };
232
+ }
233
+ case "show":
234
+ only([]);
235
+ if (rest.length > 1)
236
+ throw new UsageError(`work show doesn't take "${rest[1]}"`);
237
+ return { method: "GET", path: `/v1/work/${ref(rest[0])}` };
238
+ case "list": {
239
+ only(["worker", "status", "open"]);
240
+ if (rest.length)
241
+ throw new UsageError(`work list doesn't take "${rest[0]}"`);
242
+ if (f.open !== undefined && f.open !== "true" && f.open !== "false")
243
+ throw new UsageError("--open is true or false");
244
+ const query = new URLSearchParams(compact({ worker: f.worker, status: f.status, open: f.open }));
245
+ return { method: "GET", path: `/v1/work${query.size ? `?${query}` : ""}` };
246
+ }
247
+ default:
248
+ throw new UsageError(sub ? `work doesn't take "${sub}": use file, move, show or list` : "work needs file, move, show or list");
249
+ }
250
+ }
178
251
  // One --option is optionId; several, on a multiple question, are optionIds.
179
252
  const picks = (options) => (options && options.length > 1 ? { optionIds: options } : { optionId: options?.[0] });
180
253
  let stdinCache = null;
@@ -339,8 +412,10 @@ export function toRequest(argv) {
339
412
  throw new UsageError('missing what you\'re doing now (or "" to clear it)');
340
413
  const folders = f.folders?.split(",").map((s) => s.trim()).filter(Boolean);
341
414
  const description = f.description === undefined ? undefined : readText(f.description);
342
- return { method: "PATCH", path: "/v1/agents/me/status", body: compact({ text: readText(said) || null, description, folders, state: f.state, linearIssue: f.issue, waitingOn: f["waiting-on"] }) };
415
+ return { method: "PATCH", path: "/v1/agents/me/status", body: compact({ text: readText(said) || null, description, folders, state: f.state, linearIssue: f.issue, waitingOn: f["waiting-on"], item: f.item }) };
343
416
  }
417
+ case "work":
418
+ return workRequest(p, f, lists.code ?? []);
344
419
  case "message": {
345
420
  const text = readText(words("text", p, "what to say"));
346
421
  if ([f.conversation, f["to-agent"], f["to-person"]].filter(Boolean).length !== 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgavel/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "The gavel command: an agent's Gavel from a shell (pair, ask, wait, watch and the rest)",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://getgavel.ai/agents",