@getgavel/cli 0.1.12 → 0.1.14
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 +2 -0
- package/dist/bridge/bridge.js +5 -2
- package/dist/gavel.js +120 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,6 +32,8 @@ gavel ask --file decision.json # put a decision to your person
|
|
|
32
32
|
gavel wait D-12 --timeout 60 # until it's decided
|
|
33
33
|
gavel watch # one GAVEL_WAKE line per new thing for you; run it in the background
|
|
34
34
|
gavel find "nudge a decision" # the API's routes for what you want, and who may call each
|
|
35
|
+
gavel work claim # when you're free: your next ready task; work done W-12 when it ships
|
|
36
|
+
gavel link-cursor-run # in Cursor, when Gavel didn't start you: link this chat (then --code)
|
|
35
37
|
gavel help # every command
|
|
36
38
|
gavel act --help # one command's usage
|
|
37
39
|
```
|
package/dist/bridge/bridge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { basename, dirname, join, relative } from "node:path";
|
|
6
6
|
import { claudeOpen, claudeResume, claudeSessions, claudeSettingsFile, claudeWords, withWakeHook } from "./claude-code.js";
|
|
@@ -154,7 +154,10 @@ async function bridge(run, ctx) {
|
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
156
|
mkdirSync(dirname(settings), { recursive: true });
|
|
157
|
-
|
|
157
|
+
// Claude Code reads it whenever it likes: it changes whole, through a temp file and a rename.
|
|
158
|
+
const temp = `${settings}.${process.pid}.tmp`;
|
|
159
|
+
writeFileSync(temp, next);
|
|
160
|
+
renameSync(temp, settings);
|
|
158
161
|
if (want) {
|
|
159
162
|
const ignored = keepOutOfGit(settingsName, ctx.cwd);
|
|
160
163
|
say(`Added Gavel's wake hook to ${settingsName}, so an open session hears from ${me.person.name} even while idle; it comes out when the chat is off or the bridge stops.${ignored ? ` (${ignored}.)` : ""}`);
|
package/dist/gavel.js
CHANGED
|
@@ -57,21 +57,31 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
57
57
|
gavel work file (<title> | --title <words>) [--status <status>] [--description <words>]
|
|
58
58
|
[--worker <email or agent> | --worker none] [--reporter <email or agent>]
|
|
59
59
|
[--waiting-on <email or agent>] [--decision <D-12>] [--code <url>]... [--label <Group: Name>]...
|
|
60
|
+
[--waits-on <W-3,W-4>]
|
|
60
61
|
a work item on the Board's Being done (W-12), when you
|
|
61
62
|
start: you're its worker unless you name another, Backlog
|
|
62
63
|
unless --status (Triage, Backlog, Needs Decision, Queued,
|
|
63
|
-
Building, Blocked, Deployed, Icebox, Closed, Duplicate)
|
|
64
|
+
Building, Blocked, Deployed, Icebox, Closed, Duplicate);
|
|
65
|
+
--waits-on the items it waits on
|
|
64
66
|
gavel work move <W-12> [<status>] [--waiting-on <email or agent>] [--decision <D-12>]
|
|
65
67
|
[--code <url>]... [--worker <email or agent> | --worker none] [--title <words>]
|
|
66
|
-
[--description <words>] [--label <Group: Name>]... [--label none]
|
|
68
|
+
[--description <words>] [--label <Group: Name>]... [--label none] [--waits-on <W-3,W-4> | --waits-on none]
|
|
67
69
|
move it as your work moves: Building, Blocked with
|
|
68
70
|
--waiting-on, Needs Decision with --decision, Deployed
|
|
69
71
|
with --code (a commit or pull request; again for each);
|
|
70
|
-
--label sets all its labels (again for each)
|
|
72
|
+
--label sets all its labels (again for each), --waits-on
|
|
73
|
+
all the items it waits on
|
|
71
74
|
gavel work show <W-12> an item and its history
|
|
72
75
|
gavel work list [--worker me|<email or agent>] [--status <status>] [--open true]
|
|
73
76
|
the workspace's items, the latest changed first, and
|
|
74
77
|
its labels
|
|
78
|
+
gavel work claim [--label <Group: Name>] [--area <area>]
|
|
79
|
+
when you're free: the next ready item, yours in Building
|
|
80
|
+
while you work (any call keeps it; 10 minutes quiet and
|
|
81
|
+
it goes back to Queued); none ready, what's waiting
|
|
82
|
+
gavel work renew <W-12> keep your claim through a long quiet stretch
|
|
83
|
+
gavel work release <W-12> [--why <words>] let it go: back to Queued, the why in its history
|
|
84
|
+
gavel work done <W-12> [--code <url>]... finish it: Deployed with its code, your claim ends
|
|
75
85
|
gavel message (--to-agent <id> | --to-person <email>) (<text> | --text <words>) [--decision <D-12>]
|
|
76
86
|
start a conversation with another agent
|
|
77
87
|
gavel message --conversation <C-12> (<text> | --text <words>)
|
|
@@ -110,6 +120,10 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
110
120
|
gavel call <GET|POST|PUT|PATCH|DELETE> </v1/path> [--query <name=value>] [--body <file.json>]
|
|
111
121
|
[--for-person true] any route of the API as you, or as your person with
|
|
112
122
|
--for-person: MCP's do_action, the answer as it comes
|
|
123
|
+
gavel link-cursor-run [<bc-…> | none] [--code <code>]
|
|
124
|
+
your own Cursor run, when Gavel didn't start you (this
|
|
125
|
+
one by default, in a Cursor agent's shell): Gavel sends a
|
|
126
|
+
code into that chat; link again with --code; none unlinks
|
|
113
127
|
gavel find (<words> | --query <words>) [--limit <n>]
|
|
114
128
|
the API's routes for what you want to do, who may call each
|
|
115
129
|
gavel me
|
|
@@ -175,7 +189,7 @@ const USAGE = `gavel: Gavel from the command line (https://getgavel.ai/agents)
|
|
|
175
189
|
a stuck decision to someone else, for them: an Admin's
|
|
176
190
|
gavel workspace-settings its name, triage person, depth and untrusted areas
|
|
177
191
|
gavel edit-workspace [--name <name>] [--triage-person <person id>|none] [--sub-agent-depth <n>]
|
|
178
|
-
[--never-trusted <area id,area id>|none]
|
|
192
|
+
[--never-trusted <area id,area id>|none] [--coordinator <agent id>|none]
|
|
179
193
|
Admins and Owners; only what you give changes
|
|
180
194
|
gavel workspace-people everyone, with their role
|
|
181
195
|
gavel set-role <person id> --role owner|admin|member
|
|
@@ -241,7 +255,7 @@ const FLAGS = {
|
|
|
241
255
|
act: ["note"],
|
|
242
256
|
inbox: [],
|
|
243
257
|
status: ["text", "description", "folders", "state", "issue", "waiting-on", "item"],
|
|
244
|
-
work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open"],
|
|
258
|
+
work: ["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "open", "waits-on", "area", "why"],
|
|
245
259
|
message: ["to-agent", "to-person", "conversation", "text", "decision"],
|
|
246
260
|
conversations: [],
|
|
247
261
|
"wait-for-reply": ["timeout"],
|
|
@@ -260,6 +274,7 @@ const FLAGS = {
|
|
|
260
274
|
"move-agent": ["under"],
|
|
261
275
|
call: ["query", "body", "for-person"],
|
|
262
276
|
find: ["query", "limit"],
|
|
277
|
+
"link-cursor-run": ["code"],
|
|
263
278
|
me: [],
|
|
264
279
|
"my-queue": ["view", "before", "limit"],
|
|
265
280
|
"decide-mine": ["option", "text", "note", "their-words"],
|
|
@@ -299,7 +314,7 @@ const FLAGS = {
|
|
|
299
314
|
"nudge-mine": [],
|
|
300
315
|
reassign: ["to-person", "to-agent", "note"],
|
|
301
316
|
"workspace-settings": [],
|
|
302
|
-
"edit-workspace": ["name", "triage-person", "sub-agent-depth", "never-trusted"],
|
|
317
|
+
"edit-workspace": ["name", "triage-person", "sub-agent-depth", "never-trusted", "coordinator"],
|
|
303
318
|
"workspace-people": [],
|
|
304
319
|
"set-role": ["role"],
|
|
305
320
|
invitations: [],
|
|
@@ -458,29 +473,55 @@ function workRequest(p, f, code, label) {
|
|
|
458
473
|
const description = f.description === undefined ? undefined : readText(f.description);
|
|
459
474
|
const links = code.length ? code.map((url) => ({ url })) : undefined;
|
|
460
475
|
const labels = !label.length ? undefined : label.length === 1 && label[0] === "none" ? [] : label;
|
|
476
|
+
const waitsOn = f["waits-on"] === undefined ? undefined : f["waits-on"] === "none" ? [] : f["waits-on"].split(",").map((r) => r.trim()).filter(Boolean);
|
|
461
477
|
const ref = (value) => {
|
|
462
478
|
if (!value || !/^W-\d+$/i.test(value))
|
|
463
479
|
throw new UsageError(`work ${sub} needs its item, like W-12`);
|
|
464
480
|
return encodeURIComponent(value.toUpperCase());
|
|
465
481
|
};
|
|
482
|
+
const onlyItem = () => {
|
|
483
|
+
if (rest.length > 1)
|
|
484
|
+
throw new UsageError(`work ${sub} doesn't take "${rest[1]}"`);
|
|
485
|
+
return ref(rest[0]);
|
|
486
|
+
};
|
|
466
487
|
switch (sub) {
|
|
467
488
|
case "file": {
|
|
468
|
-
only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label"]);
|
|
489
|
+
only(["title", "status", "description", "worker", "reporter", "waiting-on", "decision", "code", "label", "waits-on"]);
|
|
469
490
|
if (f.title !== undefined && rest.length)
|
|
470
491
|
throw new UsageError("give the title once: as words or as --title");
|
|
471
492
|
const title = readText(need(f.title ?? rest.join(" "), "the item's title"));
|
|
472
|
-
return {
|
|
493
|
+
return {
|
|
494
|
+
method: "POST",
|
|
495
|
+
path: "/v1/work",
|
|
496
|
+
body: compact({ title, status: f.status, description, worker, reporter: f.reporter, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn }),
|
|
497
|
+
};
|
|
473
498
|
}
|
|
474
499
|
case "move": {
|
|
475
|
-
only(["title", "status", "description", "worker", "waiting-on", "decision", "code", "label"]);
|
|
500
|
+
only(["title", "status", "description", "worker", "waiting-on", "decision", "code", "label", "waits-on"]);
|
|
476
501
|
const [item, ...words] = rest;
|
|
477
502
|
if (f.status !== undefined && words.length)
|
|
478
503
|
throw new UsageError("give the status once: as words or as --status");
|
|
479
|
-
const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels });
|
|
504
|
+
const body = compact({ status: f.status ?? (words.join(" ") || undefined), title: f.title, description, worker, waitingOn: f["waiting-on"], decision: f.decision, code: links, labels, waitsOn });
|
|
480
505
|
if (!Object.keys(body).length)
|
|
481
506
|
throw new UsageError("work move needs a status or something to change");
|
|
482
507
|
return { method: "PATCH", path: `/v1/work/${ref(item)}`, body };
|
|
483
508
|
}
|
|
509
|
+
case "claim":
|
|
510
|
+
only(["label", "area"]);
|
|
511
|
+
if (rest.length)
|
|
512
|
+
throw new UsageError(`work claim doesn't take "${rest[0]}"`);
|
|
513
|
+
if (label.length > 1)
|
|
514
|
+
throw new UsageError("work claim takes one --label");
|
|
515
|
+
return { method: "POST", path: "/v1/work/claim", body: compact({ label: label[0], area: f.area }) };
|
|
516
|
+
case "renew":
|
|
517
|
+
only([]);
|
|
518
|
+
return { method: "POST", path: `/v1/work/${onlyItem()}/renew`, body: {} };
|
|
519
|
+
case "release":
|
|
520
|
+
only(["why"]);
|
|
521
|
+
return { method: "POST", path: `/v1/work/${onlyItem()}/release`, body: compact({ why: f.why === undefined ? undefined : readText(f.why) }) };
|
|
522
|
+
case "done":
|
|
523
|
+
only(["code"]);
|
|
524
|
+
return { method: "POST", path: `/v1/work/${onlyItem()}/done`, body: compact({ code: links }) };
|
|
484
525
|
case "show":
|
|
485
526
|
only([]);
|
|
486
527
|
if (rest.length > 1)
|
|
@@ -496,7 +537,7 @@ function workRequest(p, f, code, label) {
|
|
|
496
537
|
return { method: "GET", path: `/v1/work${query.size ? `?${query}` : ""}` };
|
|
497
538
|
}
|
|
498
539
|
default:
|
|
499
|
-
throw new UsageError(sub ? `work doesn't take "${sub}": use file, move, show or
|
|
540
|
+
throw new UsageError(sub ? `work doesn't take "${sub}": use file, move, show, list, claim, renew, release or done` : "work needs file, move, show, list, claim, renew, release or done");
|
|
500
541
|
}
|
|
501
542
|
}
|
|
502
543
|
// gavel my-queue … overrule: your person's actions, as them (FOR_PERSON).
|
|
@@ -704,6 +745,7 @@ function personRequest(command, p, f, options) {
|
|
|
704
745
|
triagePersonId: orNone("triage-person"),
|
|
705
746
|
subAgentMaxDepth: depth === undefined ? undefined : Number(depth),
|
|
706
747
|
neverTrustableAreaIds: untrusted === undefined ? undefined : untrusted === "none" ? [] : list(untrusted),
|
|
748
|
+
coordinatorAgentId: orNone("coordinator"),
|
|
707
749
|
});
|
|
708
750
|
if (!Object.keys(body).length)
|
|
709
751
|
throw new UsageError("edit-workspace needs something to change");
|
|
@@ -1077,6 +1119,20 @@ export function toRequest(argv) {
|
|
|
1077
1119
|
agentId: f.agent,
|
|
1078
1120
|
}),
|
|
1079
1121
|
};
|
|
1122
|
+
case "link-cursor-run": {
|
|
1123
|
+
upTo(1);
|
|
1124
|
+
if ((lists.code ?? []).length > 1)
|
|
1125
|
+
throw new UsageError("give --code once");
|
|
1126
|
+
if (p[0] === "none") {
|
|
1127
|
+
if (f.code !== undefined)
|
|
1128
|
+
throw new UsageError("--code goes with a run, not with none");
|
|
1129
|
+
return { linkRun: { cursorAgentId: null } };
|
|
1130
|
+
}
|
|
1131
|
+
const run = need(p[0] ?? cursorRunHere(process.env), "your Cursor run (bc-…, as cursor.com/agents/bc-… shows it), or none to unlink");
|
|
1132
|
+
if (!CURSOR_RUN.test(run))
|
|
1133
|
+
throw new UsageError(`a Cursor run is bc-…, as cursor.com/agents/bc-… shows it, not "${run}"`);
|
|
1134
|
+
return { linkRun: { cursorAgentId: run, ...(f.code !== undefined ? { code: need(f.code, "the code Gavel sent into that chat") } : {}) } };
|
|
1135
|
+
}
|
|
1080
1136
|
case "find": {
|
|
1081
1137
|
const q = words("query", p, "what you want to do, in words");
|
|
1082
1138
|
const limit = f.limit;
|
|
@@ -1457,6 +1513,10 @@ export function wakeLine(item) {
|
|
|
1457
1513
|
return "GAVEL_WAKE chat: your person wrote to you in Gavel: read it with gavel chat";
|
|
1458
1514
|
case "health":
|
|
1459
1515
|
return "GAVEL_WAKE health: Gavel's chat self-check: see gavel inbox";
|
|
1516
|
+
case "claim":
|
|
1517
|
+
return `GAVEL_WAKE claim on ${item.ref} ran out, back in Queued: see gavel inbox, then give it to an agent or let one claim it`;
|
|
1518
|
+
case "work":
|
|
1519
|
+
return `GAVEL_WAKE work ${item.ref} Blocked half an hour: move it, or name it Blocked again with gavel work move ${item.ref} Blocked`;
|
|
1460
1520
|
default:
|
|
1461
1521
|
return "GAVEL_WAKE something new: see gavel inbox";
|
|
1462
1522
|
}
|
|
@@ -1472,7 +1532,7 @@ async function watch(token, as) {
|
|
|
1472
1532
|
for (;;) {
|
|
1473
1533
|
let res;
|
|
1474
1534
|
try {
|
|
1475
|
-
res = await fetch(`${base}/v1/inbox/watch?watch=${id}&timeout=50&kinds=health${start ? "&start=true" : ""}`, {
|
|
1535
|
+
res = await fetch(`${base}/v1/inbox/watch?watch=${id}&timeout=50&kinds=health,claim,work${start ? "&start=true" : ""}`, {
|
|
1476
1536
|
headers: { authorization: `Bearer ${token}`, accept: "application/json", ...agentHeader(as) },
|
|
1477
1537
|
});
|
|
1478
1538
|
}
|
|
@@ -1559,6 +1619,39 @@ async function actionsEnv(as) {
|
|
|
1559
1619
|
console.log(JSON.stringify({ set: ["GAVEL_TOKEN", "GAVEL_API_URL", "GAVEL_MCP_URL"], agent: run.agent, workspace: run.workspace, server: run.server, expiresAt: run.expiresAt }, null, 2));
|
|
1560
1620
|
return 0;
|
|
1561
1621
|
}
|
|
1622
|
+
// ---------- gavel link-cursor-run ----------
|
|
1623
|
+
// A Cursor agent's shell names its own run in CURSOR_CONVERSATION_ID, "bc-…" on Cursor's cloud and on
|
|
1624
|
+
// a worker; any other id there isn't a run a link takes.
|
|
1625
|
+
const CURSOR_RUN = /^bc-[A-Za-z0-9-]{1,100}$/;
|
|
1626
|
+
function cursorRunHere(env) {
|
|
1627
|
+
const id = env.CURSOR_CONVERSATION_ID?.trim();
|
|
1628
|
+
return id && CURSOR_RUN.test(id) ? id : undefined;
|
|
1629
|
+
}
|
|
1630
|
+
// The route names the agent, so the caller's own id comes first (GET /v1/me); an exit code when it
|
|
1631
|
+
// can't be had.
|
|
1632
|
+
async function linkRunRequest(base, token, as, { cursorAgentId, code }) {
|
|
1633
|
+
const res = await fetch(`${base}/v1/me`, { headers: { authorization: `Bearer ${token}`, accept: "application/json", ...agentHeader(as) } });
|
|
1634
|
+
const text = await res.text();
|
|
1635
|
+
if (!res.ok) {
|
|
1636
|
+
console.error(pretty(text) || `HTTP ${res.status}`);
|
|
1637
|
+
return 1;
|
|
1638
|
+
}
|
|
1639
|
+
const id = JSON.parse(text).agent?.id;
|
|
1640
|
+
if (typeof id !== "string") {
|
|
1641
|
+
console.error("gavel: link-cursor-run links an agent's own run: GAVEL_TOKEN must be its agent token");
|
|
1642
|
+
return 2;
|
|
1643
|
+
}
|
|
1644
|
+
const path = `/v1/agents/${encodeURIComponent(id)}/cursor-run`;
|
|
1645
|
+
return cursorAgentId === null ? { method: "DELETE", path } : { method: "PUT", path, body: { cursorAgentId, ...(code !== undefined ? { code } : {}) } };
|
|
1646
|
+
}
|
|
1647
|
+
function pretty(text) {
|
|
1648
|
+
try {
|
|
1649
|
+
return JSON.stringify(JSON.parse(text), null, 2);
|
|
1650
|
+
}
|
|
1651
|
+
catch {
|
|
1652
|
+
return text;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1562
1655
|
async function main(argvIn) {
|
|
1563
1656
|
let request;
|
|
1564
1657
|
let as = null;
|
|
@@ -1597,26 +1690,28 @@ async function main(argvIn) {
|
|
|
1597
1690
|
return watch(token, as);
|
|
1598
1691
|
if ("upload" in request)
|
|
1599
1692
|
return upload(token, as, request.upload);
|
|
1600
|
-
|
|
1601
|
-
|
|
1693
|
+
let call;
|
|
1694
|
+
if ("linkRun" in request) {
|
|
1695
|
+
const linking = await linkRunRequest(base, token, as, request.linkRun);
|
|
1696
|
+
if (typeof linking === "number")
|
|
1697
|
+
return linking;
|
|
1698
|
+
call = linking;
|
|
1699
|
+
}
|
|
1700
|
+
else
|
|
1701
|
+
call = request;
|
|
1702
|
+
const res = await fetch(base + call.path, {
|
|
1703
|
+
method: call.method,
|
|
1602
1704
|
headers: {
|
|
1603
1705
|
authorization: `Bearer ${token}`,
|
|
1604
1706
|
accept: "application/json",
|
|
1605
1707
|
"x-gavel-waiting": "1",
|
|
1606
1708
|
...agentHeader(as),
|
|
1607
|
-
...(
|
|
1608
|
-
...(
|
|
1709
|
+
...(call.forPerson ? { "x-gavel-for-person": "true" } : {}),
|
|
1710
|
+
...(call.body !== undefined ? { "content-type": "application/json" } : {}),
|
|
1609
1711
|
},
|
|
1610
|
-
...(
|
|
1712
|
+
...(call.body !== undefined ? { body: JSON.stringify(call.body) } : {}),
|
|
1611
1713
|
});
|
|
1612
|
-
const
|
|
1613
|
-
let out = text;
|
|
1614
|
-
try {
|
|
1615
|
-
out = JSON.stringify(JSON.parse(text), null, 2);
|
|
1616
|
-
}
|
|
1617
|
-
catch {
|
|
1618
|
-
// not JSON: print as it came
|
|
1619
|
-
}
|
|
1714
|
+
const out = pretty(await res.text());
|
|
1620
1715
|
if (!res.ok) {
|
|
1621
1716
|
console.error(out || `HTTP ${res.status}`);
|
|
1622
1717
|
return 1;
|
package/package.json
CHANGED