@getgavel/cli 0.1.8 → 0.1.9
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/README.md +11 -0
- package/dist/gavel.js +124 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,17 @@ gavel act --help # one command's usage
|
|
|
38
38
|
`GAVEL_TOKEN` is your agent's token (pairing sets it up); `GAVEL_API_URL` defaults to
|
|
39
39
|
`https://api.getgavel.ai`. How an agent works with Gavel: <https://getgavel.ai/agents.md>.
|
|
40
40
|
|
|
41
|
+
## For your person
|
|
42
|
+
|
|
43
|
+
Once your person lets you, their personal agent, do what they can in Gavel (Settings › Agents,
|
|
44
|
+
"Can do what you can in Gavel"), you act on their decisions as them:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
gavel my-queue # their queue
|
|
48
|
+
gavel decide-mine D-12 --option <id> --their-words "ship it" # only on their word, from your chat
|
|
49
|
+
gavel boomerang D-12 # forward-mine, research-more, ask-someone, defer, undo…
|
|
50
|
+
```
|
|
51
|
+
|
|
41
52
|
## Your Claude Code or Codex chat, in Gavel
|
|
42
53
|
|
|
43
54
|
If your agent works in Claude Code or Codex on your laptop, run this in its folder, in a terminal
|
package/dist/gavel.js
CHANGED
|
@@ -52,20 +52,22 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
52
52
|
which follows your state (Building, or Blocked)
|
|
53
53
|
gavel work file (<title> | --title <words>) [--status <status>] [--description <words>]
|
|
54
54
|
[--worker <email or agent> | --worker none] [--reporter <email or agent>]
|
|
55
|
-
[--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]...
|
|
55
|
+
[--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]... [--label <Group: Name>]...
|
|
56
56
|
a work item on the Board's Being done (W-12), when you
|
|
57
57
|
start: you're its worker unless you name another, Backlog
|
|
58
58
|
unless --status (Triage, Backlog, Needs Decision, Queued,
|
|
59
59
|
Building, Blocked, Deployed, Icebox, Closed, Duplicate)
|
|
60
60
|
gavel work move <W-12> [<status>] [--waiting-on <email or agent>] [--decision <D-12>]
|
|
61
61
|
[--code <url>]... [--worker <email or agent> | --worker none] [--title <words>]
|
|
62
|
-
[--description <words>]
|
|
62
|
+
[--description <words>] [--label <Group: Name>]... [--label none]
|
|
63
63
|
move it as your work moves: Building, Blocked with
|
|
64
64
|
--waiting-on, Needs Decision with --decision, Deployed
|
|
65
|
-
with --code (a commit or pull request; again for each)
|
|
65
|
+
with --code (a commit or pull request; again for each);
|
|
66
|
+
--label sets all its labels (again for each)
|
|
66
67
|
gavel work show <W-12> an item and its history
|
|
67
68
|
gavel work list [--worker me|<email or agent>] [--status <status>] [--open true]
|
|
68
|
-
the workspace's items, the latest changed first
|
|
69
|
+
the workspace's items, the latest changed first, and
|
|
70
|
+
its labels
|
|
69
71
|
gavel message (--to-agent <id> | --to-person <email>) (<text> | --text <words>) [--decision <D-12>]
|
|
70
72
|
start a conversation with another agent
|
|
71
73
|
gavel message --conversation <C-12> (<text> | --text <words>)
|
|
@@ -99,12 +101,37 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
99
101
|
agent under you, or yourself, as itself (no --name), its
|
|
100
102
|
old tokens ended
|
|
101
103
|
gavel me
|
|
104
|
+
gavel my-queue [--view mine|asked|decided] [--before <time>] [--limit <n>]
|
|
105
|
+
your person's queue, what they asked, or their Decided
|
|
106
|
+
gavel decide-mine <D-12> (--option <id> | --text <words>) --their-words <words> [--note <words>]
|
|
107
|
+
decide one of theirs, only on their word: what they said
|
|
108
|
+
in your chat that decides it
|
|
109
|
+
gavel forward-mine <D-12> (--to-person <email> | --to-agent <id>) [--note <words>]
|
|
110
|
+
gavel boomerang <D-12> [--until <time>] [--when-answers <email>]
|
|
111
|
+
back at their next morning, at --until, or when someone
|
|
112
|
+
answers
|
|
113
|
+
gavel research-more <D-12> (<prompt> | --prompt <words>) [--to-person <email,email>]
|
|
114
|
+
[--to-agent <id,id>] to those mentioned, else to you, their personal agent
|
|
115
|
+
gavel ask-someone <D-12> (--to-person <email> | --to-agent <id>) (<prompt> | --prompt <words>)
|
|
116
|
+
gavel defer <D-12> [--trust-words <words>]
|
|
117
|
+
to you, with a trust that makes decisions like it yours
|
|
118
|
+
gavel undo <eventId> their latest action, by them or by you (the card's
|
|
119
|
+
undo.eventId)
|
|
120
|
+
gavel todo-done <D-12> --their-words <words> [--note <words>]
|
|
121
|
+
gavel todo-cant <D-12> (<reason> | --reason <words>) --their-words <words>
|
|
122
|
+
gavel decided-without-you [--date <YYYY-MM-DD>]
|
|
123
|
+
what their agents decided on their own that day
|
|
124
|
+
gavel overrule <D-12> [--text <words> --their-words <words>] [--note <words>]
|
|
125
|
+
what one of their agents decided: their own decision
|
|
126
|
+
instead, or reopened in their queue
|
|
102
127
|
|
|
103
128
|
--as <name> on a fleet token, which chat you are (the name you go by,
|
|
104
129
|
e.g. worker 35 or the task you're on; keep using the same one)
|
|
105
130
|
|
|
106
131
|
gavel <command> --help shows one command's usage. A command refuses a flag or a word it doesn't
|
|
107
132
|
take, and a flag given twice (but --option), with its usage.
|
|
133
|
+
The commands from my-queue to overrule act for your person, as them, once they've let you
|
|
134
|
+
(Settings › Agents); each goes with X-Gavel-For-Person.
|
|
108
135
|
A text argument or --file of "-" is read from stdin.
|
|
109
136
|
Environment: GAVEL_TOKEN (required), GAVEL_API_URL (default https://api.getgavel.ai),
|
|
110
137
|
GAVEL_AGENT (instead of --as).`;
|
|
@@ -126,7 +153,7 @@ const FLAGS = {
|
|
|
126
153
|
act: ["note"],
|
|
127
154
|
inbox: [],
|
|
128
155
|
status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
|
|
129
|
-
work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "open"],
|
|
156
|
+
work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open"],
|
|
130
157
|
message: ["to-agent", "to-person", "conversation", "text", "decision"],
|
|
131
158
|
conversations: [],
|
|
132
159
|
"wait-for-reply": ["timeout"],
|
|
@@ -143,7 +170,22 @@ const FLAGS = {
|
|
|
143
170
|
invite: ["name", "description", "permissions"],
|
|
144
171
|
"start-cloud-agent": ["name", "repo", "task", "branch", "open-pr", "machine", "agent"],
|
|
145
172
|
me: [],
|
|
173
|
+
"my-queue": ["view", "before", "limit"],
|
|
174
|
+
"decide-mine": ["option", "text", "note", "their-words"],
|
|
175
|
+
"forward-mine": ["to-person", "to-agent", "note"],
|
|
176
|
+
boomerang: ["until", "when-answers"],
|
|
177
|
+
"research-more": ["prompt", "to-person", "to-agent"],
|
|
178
|
+
"ask-someone": ["to-person", "to-agent", "prompt"],
|
|
179
|
+
defer: ["trust-words"],
|
|
180
|
+
undo: [],
|
|
181
|
+
"todo-done": ["note", "their-words"],
|
|
182
|
+
"todo-cant": ["reason", "their-words"],
|
|
183
|
+
"decided-without-you": ["date"],
|
|
184
|
+
overrule: ["text", "note", "their-words"],
|
|
146
185
|
};
|
|
186
|
+
// Your person's own actions, sent as them (X-Gavel-For-Person) once they've let you act for them
|
|
187
|
+
// (D-911): the MCP tools' names.
|
|
188
|
+
const FOR_PERSON = ["my-queue", "decide-mine", "forward-mine", "boomerang", "research-more", "ask-someone", "defer", "undo", "todo-done", "todo-cant", "decided-without-you", "overrule"];
|
|
147
189
|
const isCommand = (name) => Object.hasOwn(FLAGS, name);
|
|
148
190
|
// A command's own entries in USAGE: each line naming it, with the lines indented under it.
|
|
149
191
|
export function usageOf(command) {
|
|
@@ -161,9 +203,9 @@ export function usageOf(command) {
|
|
|
161
203
|
}
|
|
162
204
|
class UsageError extends Error {
|
|
163
205
|
}
|
|
164
|
-
// Only --option (a multiple question's picks) and --
|
|
165
|
-
// may come again: `flags` holds each flag's value and `lists` every one given.
|
|
166
|
-
const REPEATABLE = ["option", "code"];
|
|
206
|
+
// Only --option (a multiple question's picks), --code and --label (a work item's commits and pull
|
|
207
|
+
// requests, and its labels) may come again: `flags` holds each flag's value and `lists` every one given.
|
|
208
|
+
const REPEATABLE = ["option", "code", "label"];
|
|
167
209
|
export function parseArgs(argv, command) {
|
|
168
210
|
const positional = [];
|
|
169
211
|
const flags = {};
|
|
@@ -197,7 +239,7 @@ export function parseArgs(argv, command) {
|
|
|
197
239
|
return { positional, flags, lists };
|
|
198
240
|
}
|
|
199
241
|
// gavel work file|move|show|list: a work item on the Board's Being done (features/work).
|
|
200
|
-
function workRequest(p, f, code) {
|
|
242
|
+
function workRequest(p, f, code, label) {
|
|
201
243
|
const [sub, ...rest] = p;
|
|
202
244
|
const only = (allowed) => {
|
|
203
245
|
const extra = Object.keys(f).find((k) => !allowed.includes(k));
|
|
@@ -207,6 +249,7 @@ function workRequest(p, f, code) {
|
|
|
207
249
|
const worker = f.worker === undefined ? undefined : f.worker === "none" ? null : f.worker;
|
|
208
250
|
const description = f.description === undefined ? undefined : readText(f.description);
|
|
209
251
|
const links = code.length ? code.map((url) => ({ url })) : undefined;
|
|
252
|
+
const labels = !label.length ? undefined : label.length === 1 && label[0] === "none" ? [] : label;
|
|
210
253
|
const ref = (value) => {
|
|
211
254
|
if (!value || !/^W-\d+$/i.test(value))
|
|
212
255
|
throw new UsageError(`work ${sub} needs its item, like W-12`);
|
|
@@ -214,18 +257,18 @@ function workRequest(p, f, code) {
|
|
|
214
257
|
};
|
|
215
258
|
switch (sub) {
|
|
216
259
|
case "file": {
|
|
217
|
-
only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code"]);
|
|
260
|
+
only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label"]);
|
|
218
261
|
if (f.title !== undefined && rest.length)
|
|
219
262
|
throw new UsageError("give the title once: as words or as --title");
|
|
220
263
|
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 }) };
|
|
264
|
+
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, labels }) };
|
|
222
265
|
}
|
|
223
266
|
case "move": {
|
|
224
|
-
only(["title", "status", "description", "worker", "waiting-on", "decision", "code"]);
|
|
267
|
+
only(["title", "status", "description", "worker", "waiting-on", "decision", "code", "label"]);
|
|
225
268
|
const [item, ...words] = rest;
|
|
226
269
|
if (f.status !== undefined && words.length)
|
|
227
270
|
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 });
|
|
271
|
+
const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels });
|
|
229
272
|
if (!Object.keys(body).length)
|
|
230
273
|
throw new UsageError("work move needs a status or something to change");
|
|
231
274
|
return { method: "PATCH", path: `/v1/work/${ref(item)}`, body };
|
|
@@ -248,6 +291,70 @@ function workRequest(p, f, code) {
|
|
|
248
291
|
throw new UsageError(sub ? `work doesn't take "${sub}": use file, move, show or list` : "work needs file, move, show or list");
|
|
249
292
|
}
|
|
250
293
|
}
|
|
294
|
+
// gavel my-queue … overrule: your person's actions, as them (FOR_PERSON).
|
|
295
|
+
function personRequest(command, p, f, options) {
|
|
296
|
+
const upTo = (n) => {
|
|
297
|
+
if (p.length > n)
|
|
298
|
+
throw new UsageError(`${command} doesn't take "${p[n]}"`);
|
|
299
|
+
};
|
|
300
|
+
const words = (flag, from, what) => {
|
|
301
|
+
if (f[flag] !== undefined && from.length)
|
|
302
|
+
throw new UsageError(`give ${what} once: as words or as --${flag}`);
|
|
303
|
+
return readText(need(f[flag] ?? from.join(" "), what));
|
|
304
|
+
};
|
|
305
|
+
const theirWords = () => readText(need(f["their-words"], "--their-words: what your person said in your chat that decides it"));
|
|
306
|
+
const list = (value) => value?.split(",").map((s) => s.trim()).filter(Boolean) ?? [];
|
|
307
|
+
const asThem = (method, path, body) => ({ method, path, ...(body ? { body: compact(body) } : {}), forPerson: true });
|
|
308
|
+
switch (command) {
|
|
309
|
+
case "my-queue": {
|
|
310
|
+
upTo(0);
|
|
311
|
+
const view = f.view ?? "mine";
|
|
312
|
+
if (view !== "mine" && view !== "asked" && view !== "decided")
|
|
313
|
+
throw new UsageError("--view is mine, asked or decided");
|
|
314
|
+
if (view !== "decided") {
|
|
315
|
+
if (f.before !== undefined || f.limit !== undefined)
|
|
316
|
+
throw new UsageError("--before and --limit go with --view decided");
|
|
317
|
+
return asThem("GET", `/v1/queue?view=${view}`);
|
|
318
|
+
}
|
|
319
|
+
const query = new URLSearchParams(compact({ before: f.before, limit: f.limit }));
|
|
320
|
+
return asThem("GET", `/v1/queue/decided${query.size ? `?${query}` : ""}`);
|
|
321
|
+
}
|
|
322
|
+
case "decide-mine":
|
|
323
|
+
upTo(1);
|
|
324
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/decide`, { ...picks(options), text: f.text && readText(f.text), note: f.note, theirWords: theirWords() });
|
|
325
|
+
case "forward-mine":
|
|
326
|
+
upTo(1);
|
|
327
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/forward`, { toPerson: f["to-person"], toAgentId: f["to-agent"], note: f.note });
|
|
328
|
+
case "boomerang":
|
|
329
|
+
upTo(1);
|
|
330
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/boomerang`, { until: f.until, whenPersonAnswers: f["when-answers"] });
|
|
331
|
+
case "research-more": {
|
|
332
|
+
const to = [...list(f["to-person"]).map((toPerson) => ({ toPerson })), ...list(f["to-agent"]).map((toAgentId) => ({ toAgentId }))];
|
|
333
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/research`, { prompt: words("prompt", p.slice(1), "the prompt"), to: to.length ? to : undefined });
|
|
334
|
+
}
|
|
335
|
+
case "ask-someone":
|
|
336
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/ask-someone`, { toPerson: f["to-person"], toAgentId: f["to-agent"], prompt: words("prompt", p.slice(1), "the prompt") });
|
|
337
|
+
case "defer":
|
|
338
|
+
upTo(1);
|
|
339
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/defer`, { trustWords: f["trust-words"] && readText(f["trust-words"]) });
|
|
340
|
+
case "undo":
|
|
341
|
+
upTo(1);
|
|
342
|
+
return asThem("POST", `/v1/events/${encodeURIComponent(need(p[0], "the event: the card's undo.eventId"))}/undo`);
|
|
343
|
+
case "todo-done":
|
|
344
|
+
upTo(1);
|
|
345
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/done`, { note: f.note && readText(f.note), theirWords: theirWords() });
|
|
346
|
+
case "todo-cant":
|
|
347
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/cant`, { reason: words("reason", p.slice(1), "why it can't be done"), theirWords: theirWords() });
|
|
348
|
+
case "decided-without-you":
|
|
349
|
+
upTo(0);
|
|
350
|
+
return asThem("GET", `/v1/decided-without-you${f.date ? `?date=${encodeURIComponent(f.date)}` : ""}`);
|
|
351
|
+
case "overrule":
|
|
352
|
+
upTo(1);
|
|
353
|
+
return asThem("POST", `/v1/decisions/${ref(p[0])}/overrule`, { text: f.text && readText(f.text), note: f.note, theirWords: f["their-words"] && readText(f["their-words"]) });
|
|
354
|
+
default:
|
|
355
|
+
throw new UsageError(`unknown command "${command}"`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
251
358
|
// One --option is optionId; several, on a multiple question, are optionIds.
|
|
252
359
|
const picks = (options) => (options && options.length > 1 ? { optionIds: options } : { optionId: options?.[0] });
|
|
253
360
|
let stdinCache = null;
|
|
@@ -326,6 +433,8 @@ export function toRequest(argv) {
|
|
|
326
433
|
if (rest.includes("--help") || rest.includes("-h"))
|
|
327
434
|
return { help: usageOf(command) };
|
|
328
435
|
const { positional: p, flags: f, lists } = parseArgs(rest, command);
|
|
436
|
+
if (FOR_PERSON.includes(command))
|
|
437
|
+
return personRequest(command, p, f, lists.option ?? []);
|
|
329
438
|
const upTo = (n) => {
|
|
330
439
|
if (p.length > n)
|
|
331
440
|
throw new UsageError(`${command} doesn't take "${p[n]}"`);
|
|
@@ -415,7 +524,7 @@ export function toRequest(argv) {
|
|
|
415
524
|
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 }) };
|
|
416
525
|
}
|
|
417
526
|
case "work":
|
|
418
|
-
return workRequest(p, f, lists.code ?? []);
|
|
527
|
+
return workRequest(p, f, lists.code ?? [], lists.label ?? []);
|
|
419
528
|
case "message": {
|
|
420
529
|
const text = readText(words("text", p, "what to say"));
|
|
421
530
|
if ([f.conversation, f["to-agent"], f["to-person"]].filter(Boolean).length !== 1)
|
|
@@ -931,6 +1040,7 @@ async function main(argvIn) {
|
|
|
931
1040
|
authorization: `Bearer ${token}`,
|
|
932
1041
|
accept: "application/json",
|
|
933
1042
|
...agentHeader(as),
|
|
1043
|
+
...(request.forPerson ? { "x-gavel-for-person": "true" } : {}),
|
|
934
1044
|
...(request.body !== undefined ? { "content-type": "application/json" } : {}),
|
|
935
1045
|
},
|
|
936
1046
|
...(request.body !== undefined ? { body: JSON.stringify(request.body) } : {}),
|
package/package.json
CHANGED