@botbuddy/cli 1.70.0 → 1.71.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/CHANGELOG.md +3 -0
- package/claude-plugin/.claude-plugin/marketplace.json +1 -1
- package/claude-plugin/bb-status/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/bb-status/hooks/register.js +68 -28
- package/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +1 -1
- package/src/commands.mjs +19 -5
- package/src/session-bootstrap.mjs +3 -0
- package/src/status-band-read.mjs +36 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.71.0
|
|
4
|
+
|
|
5
|
+
- `bb bootstrap --project-id P-BOT-39` registers a coordinator session: one that runs a Linear project (an epic) and starts a session per ticket, with no ticket branch of its own. No ticket and no `--no-ticket-reason` are needed, and `--ticket-id` may be added. BB checks that the project belongs to the repo's tenant and refuses a malformed or foreign id before any session is kept. The bb-status band on such a session shows the project row, `Coordinating · 9 done · 2 in progress · 1 blocked · 3 todo`, linked to BB and Linear, and it updates on the project's own wake. When a band has nothing to show, its hint now names the tenant's own prefix (`ENT-` on Supply Guard) and the coordinator option. The band's plugin version moves to 1.3.0, so `bb update` installs it.
|
|
3
6
|
## 1.69.8
|
|
4
7
|
|
|
5
8
|
- The bb-status band's context row is simpler: just `Context 45%`, right-aligned, without the token counts. It turns amber above 30% context use and red above 50%, on every surface, so a session running low on context stands out. The colour is judged on the rounded percent the row shows. The band's plugin version moves to 1.1.1, so `bb update` re-installs it.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"name": "bb-status",
|
|
12
12
|
"source": "./bb-status",
|
|
13
13
|
"description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.3.0"
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bb-status",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "BotBuddy"
|
|
@@ -31,6 +31,8 @@ let unbound = false;
|
|
|
31
31
|
// with the free `$.session.usage()` and then only from `session.measure`,
|
|
32
32
|
// which the engine pushes after each main-thread turn: never polled.
|
|
33
33
|
let context = null;
|
|
34
|
+
// BOT-3213: the tenant's ticket prefix the adapter named with ticket_missing.
|
|
35
|
+
let hintPrefix = null;
|
|
34
36
|
// BOT-3212: the waits badge pulses once, for PULSE_MS, when the count changes.
|
|
35
37
|
const PULSE_MS = 2000;
|
|
36
38
|
let pulsing = false;
|
|
@@ -59,7 +61,7 @@ const ERRORS = {
|
|
|
59
61
|
agent_mismatch:
|
|
60
62
|
"BB returned a different agent. Reconnect BB for this session.",
|
|
61
63
|
worktree_mismatch: "BB identity belongs to a different worktree.",
|
|
62
|
-
ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live
|
|
64
|
+
ticket_missing: "Use a ticket branch (bot-… or ent-…) or /bb-status live <KEY>, or register as coordinator: bb bootstrap --project-id P-….",
|
|
63
65
|
ticket_scope_mismatch: "Linear issue or workspace does not match BotBuddy.",
|
|
64
66
|
blockers_incomplete: "Blocker list is incomplete. Status is unknown.",
|
|
65
67
|
source_unauthorized:
|
|
@@ -70,6 +72,12 @@ const ERRORS = {
|
|
|
70
72
|
cli_outdated: "Update the bb CLI (bb update) to use this band.",
|
|
71
73
|
};
|
|
72
74
|
function errorText() {
|
|
75
|
+
// BOT-3213 AC-4: the hint speaks in the tenant's own prefix when it is known.
|
|
76
|
+
if (errorCode === "ticket_missing" && hintPrefix)
|
|
77
|
+
return (
|
|
78
|
+
"Use a ticket branch (" + hintPrefix.toLowerCase() + "-…) or /bb-status live " + hintPrefix +
|
|
79
|
+
"-123, or register as coordinator: bb bootstrap --project-id P-" + hintPrefix + "-…."
|
|
80
|
+
);
|
|
73
81
|
return (
|
|
74
82
|
ERRORS[errorCode] ||
|
|
75
83
|
"Status unavailable. Check BB and Linear connections, then refresh."
|
|
@@ -109,6 +117,18 @@ const PR_STATES = ["open", "draft", "merged", "closed"];
|
|
|
109
117
|
const LINEAR_PROJECT_URL = /^https:\/\/linear\.app\/[a-z0-9-]{1,64}\/project\/[a-z0-9-]{1,200}$/;
|
|
110
118
|
const PROJECT_IDENTIFIER = /^P-[A-Z][A-Z0-9]{1,9}-[1-9]\d{0,5}$/;
|
|
111
119
|
const PROJECT_STATES = ["backlog", "planned", "started", "paused", "completed", "canceled"];
|
|
120
|
+
// BOT-3213: a coordinator project's tickets by state; the four add up to total.
|
|
121
|
+
const COUNT_KEYS = ["done", "in_progress", "blocked", "todo"];
|
|
122
|
+
function validCounts(c) {
|
|
123
|
+
return (
|
|
124
|
+
!!c &&
|
|
125
|
+
[...COUNT_KEYS, "total"].every((k) => Number.isSafeInteger(c[k]) && c[k] >= 0 && c[k] <= 100000) &&
|
|
126
|
+
COUNT_KEYS.reduce((n, k) => n + c[k], 0) === c.total
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
function countsText(c) {
|
|
130
|
+
return [c.done + " done", c.in_progress + " in progress", c.blocked + " blocked", c.todo + " todo"].join(" · ");
|
|
131
|
+
}
|
|
112
132
|
function validSnapshot(value, harness, now) {
|
|
113
133
|
const prefix = TENANT_PREFIX[value?.tenant];
|
|
114
134
|
const ownKey = (k) => KEY.test(k) && k.startsWith(prefix + "-");
|
|
@@ -122,15 +142,17 @@ function validSnapshot(value, harness, now) {
|
|
|
122
142
|
!safeLabel(value.agent?.name, 100) ||
|
|
123
143
|
!safeLabel(value.branch) ||
|
|
124
144
|
!Array.isArray(value.tickets) ||
|
|
125
|
-
value.tickets.length < 1 ||
|
|
126
145
|
value.tickets.length > 5 ||
|
|
127
146
|
!value.tickets.every(
|
|
128
147
|
(t) => ownKey(t?.key) && safeLabel(t.title) && safeLabel(t.status, 40),
|
|
129
148
|
) ||
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
// BOT-3213: only a coordinator's project binding may carry no ticket.
|
|
150
|
+
(value.tickets.length === 0
|
|
151
|
+
? !(value.binding === "project" && value.ticket === null && value.epic?.role === "coordinator")
|
|
152
|
+
: value.ticket?.key !== value.tickets[0].key ||
|
|
153
|
+
!safeLabel(value.ticket.title) ||
|
|
154
|
+
!safeLabel(value.ticket.status, 40) ||
|
|
155
|
+
(value.ticket.url !== null && !safeLink(value.ticket.url, value.ticket.key))) ||
|
|
134
156
|
(value.prs !== null &&
|
|
135
157
|
!(
|
|
136
158
|
Array.isArray(value.prs) &&
|
|
@@ -158,7 +180,9 @@ function validSnapshot(value, harness, now) {
|
|
|
158
180
|
(value.epic.identifier == null || PROJECT_IDENTIFIER.test(value.epic.identifier)) &&
|
|
159
181
|
Number.isSafeInteger(value.epic.percent) &&
|
|
160
182
|
value.epic.percent >= 0 &&
|
|
161
|
-
value.epic.percent <= 100
|
|
183
|
+
value.epic.percent <= 100 &&
|
|
184
|
+
(value.epic.role === undefined || value.epic.role === "coordinator") &&
|
|
185
|
+
(value.epic.counts === undefined || validCounts(value.epic.counts))
|
|
162
186
|
)) ||
|
|
163
187
|
(value.blockers !== null &&
|
|
164
188
|
!(value.tenant === "botbuddy" && Array.isArray(value.blockers) && value.blockers.length <= 100)) ||
|
|
@@ -312,10 +336,12 @@ async function refresh($, { wake = false, keep = false } = {}) {
|
|
|
312
336
|
snapshot = null;
|
|
313
337
|
return;
|
|
314
338
|
}
|
|
315
|
-
if (result.exitCode !== 0)
|
|
339
|
+
if (result.exitCode !== 0) {
|
|
340
|
+
hintPrefix = data?.error === "ticket_missing" && /^[A-Z]{2,10}$/.test(data.prefix ?? "") ? data.prefix : null;
|
|
316
341
|
throw new Error(
|
|
317
342
|
typeof data.error === "string" ? data.error : "source_unavailable",
|
|
318
343
|
);
|
|
344
|
+
}
|
|
319
345
|
currentTime = await $.clock.now();
|
|
320
346
|
if (request !== generation) return;
|
|
321
347
|
if (previous && data && data.epic_skipped === true) data = keepKnown(data, previous);
|
|
@@ -340,6 +366,7 @@ async function refresh($, { wake = false, keep = false } = {}) {
|
|
|
340
366
|
});
|
|
341
367
|
}
|
|
342
368
|
snapshot = data;
|
|
369
|
+
hintPrefix = TENANT_PREFIX[data.tenant] || null;
|
|
343
370
|
relayFault = null;
|
|
344
371
|
if (!wake) startRelay($);
|
|
345
372
|
}
|
|
@@ -379,7 +406,7 @@ function waitConditions(s) {
|
|
|
379
406
|
conds.push("pr-state:repo=" + p.repo + ",pr=" + p.number);
|
|
380
407
|
// Blockers are read for the primary ticket only, and an `unblocked:` wait on
|
|
381
408
|
// a ticket that is not blocked is granted at once: never arm it for others.
|
|
382
|
-
if (s.tenant === "botbuddy" && s.blockers && s.blockers.length > 0)
|
|
409
|
+
if (s.tenant === "botbuddy" && s.ticket && s.blockers && s.blockers.length > 0)
|
|
383
410
|
conds.push("unblocked:" + s.ticket.key);
|
|
384
411
|
// BOT-3136 AC-1: the epic row wakes on its Linear project's progress.
|
|
385
412
|
if (s.epic && UUID.test(s.epic.id))
|
|
@@ -502,7 +529,7 @@ function startRelay($) {
|
|
|
502
529
|
// (BB's work list covers 3 days); keep what the last full read knew.
|
|
503
530
|
function keepKnown(data, previous) {
|
|
504
531
|
const { epic_skipped, ...rest } = data;
|
|
505
|
-
const samePrimary = previous.tenant === data.tenant && previous.ticket
|
|
532
|
+
const samePrimary = previous.tenant === data.tenant && previous.ticket?.key === data.ticket?.key;
|
|
506
533
|
const known = new Map(previous.tickets.map((t) => [t.key, t]));
|
|
507
534
|
return {
|
|
508
535
|
...rest,
|
|
@@ -884,7 +911,10 @@ function bandLines(el, $, inPane) {
|
|
|
884
911
|
],
|
|
885
912
|
icon: lead(el, "◇", epicHex(s.epic.state), "epic " + s.epic.state + " " + s.epic.percent + "%", epicIcon(s.epic.state, s.epic.percent)),
|
|
886
913
|
status: [{ text: s.epic.percent + "% done", color: epicHex(s.epic.state) }],
|
|
887
|
-
|
|
914
|
+
// BOT-3213: the project a coordinator session runs, with its tickets by state.
|
|
915
|
+
title: s.epic.role === "coordinator"
|
|
916
|
+
? "Coordinating · " + (s.epic.counts ? countsText(s.epic.counts) + " · " : "") + s.epic.name
|
|
917
|
+
: s.epic.name,
|
|
888
918
|
});
|
|
889
919
|
else if (s.epic_unreadable)
|
|
890
920
|
specs.push({ key: k("line-epic"), ids: [], icon: el.Text({ color: "warning", children: ["◇ "] }), status: [], title: UNREAD.epic, dim: true });
|
|
@@ -1033,17 +1063,26 @@ export function register(on) {
|
|
|
1033
1063
|
else {
|
|
1034
1064
|
children.push(
|
|
1035
1065
|
Text({ bold: true, children: [snapshot.agent.name] }),
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1066
|
+
...(snapshot.ticket
|
|
1067
|
+
? [
|
|
1068
|
+
Text({
|
|
1069
|
+
children: [snapshot.ticket.key + " · " + snapshot.ticket.title],
|
|
1070
|
+
}),
|
|
1071
|
+
Text({
|
|
1072
|
+
color: "cyan",
|
|
1073
|
+
// BotBuddy status is read from Linear; SupplyGuard's from BB's copy.
|
|
1074
|
+
children: [
|
|
1075
|
+
(snapshot.ticket.url ? "Linear · " : "BB · ") +
|
|
1076
|
+
snapshot.ticket.status,
|
|
1077
|
+
],
|
|
1078
|
+
}),
|
|
1079
|
+
]
|
|
1080
|
+
: [
|
|
1081
|
+
// BOT-3213: a coordinator session has a project, not a ticket.
|
|
1082
|
+
Text({
|
|
1083
|
+
children: ["Coordinator · " + (snapshot.epic.identifier || snapshot.epic.short_id) + " · " + snapshot.epic.name],
|
|
1084
|
+
}),
|
|
1085
|
+
]),
|
|
1047
1086
|
Text({ children: ["Agent · " + activity] }),
|
|
1048
1087
|
Text({ dimColor: true, children: [snapshot.branch] }),
|
|
1049
1088
|
);
|
|
@@ -1060,11 +1099,12 @@ export function register(on) {
|
|
|
1060
1099
|
// The same three items the band shows, one row each in full.
|
|
1061
1100
|
surface = e.surface;
|
|
1062
1101
|
children.push(...bandLines($.ui.resolve(e), $, true));
|
|
1063
|
-
|
|
1102
|
+
// BOT-3213: a coordinator has no ticket, so it has no ticket blockers to list.
|
|
1103
|
+
if (snapshot.ticket && snapshot.blockers === null)
|
|
1064
1104
|
children.push(
|
|
1065
1105
|
Text({ dimColor: true, children: ["Blockers are read from the BotBuddy Linear workspace only."] }),
|
|
1066
1106
|
);
|
|
1067
|
-
else
|
|
1107
|
+
else if (snapshot.ticket)
|
|
1068
1108
|
children.push(
|
|
1069
1109
|
Text({
|
|
1070
1110
|
bold: true,
|
|
@@ -1084,10 +1124,10 @@ export function register(on) {
|
|
|
1084
1124
|
children.push(
|
|
1085
1125
|
Text({ children: ["No open blockers at the last refresh."] }),
|
|
1086
1126
|
);
|
|
1087
|
-
const links =
|
|
1088
|
-
Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) })
|
|
1089
|
-
|
|
1090
|
-
if (snapshot.ticket
|
|
1127
|
+
const links = snapshot.ticket
|
|
1128
|
+
? [Link({ label: "Open ticket ↗", href: LINKS.ticket(snapshot.ticket.key) })]
|
|
1129
|
+
: [Link({ label: "Open project ↗", href: LINKS.project(snapshot.epic.id) })];
|
|
1130
|
+
if (snapshot.ticket?.url)
|
|
1091
1131
|
links.push(Link({ label: "Linear ↗", href: snapshot.ticket.url }));
|
|
1092
1132
|
links.push(Link({ label: "Open BB ↗", href: APP }));
|
|
1093
1133
|
children.push(Box({ flexDirection: "row", columnGap: 2, children: links }));
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.71.0",
|
|
3
|
+
"source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
|
|
4
|
+
"source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.71.0",
|
|
3
|
+
"source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
|
|
4
|
+
"source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.71.0",
|
|
4
|
+
"source_commit": "7c235f027430345a12424c54bbdac7d6dc564680",
|
|
5
|
+
"source_sha256": "aff57a1da3bc1fa35da3dfa38fcbc4062bc3d123536c2c59b5f59e9cc28b1987",
|
|
6
6
|
"targets": {
|
|
7
7
|
"darwin-arm64": {
|
|
8
8
|
"goos": "darwin",
|
|
9
9
|
"goarch": "arm64",
|
|
10
10
|
"binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "d931c9d6f3f25d7acc5b964ef8c1f7fde5d4e191dad0b6be78c044a706c15570",
|
|
12
12
|
"mode": "0755"
|
|
13
13
|
},
|
|
14
14
|
"linux-x64": {
|
|
15
15
|
"goos": "linux",
|
|
16
16
|
"goarch": "amd64",
|
|
17
17
|
"binary": "daemon/bin/linux-x64/botbuddy-daemon",
|
|
18
|
-
"sha256": "
|
|
18
|
+
"sha256": "1089d5e0bb7c2930935d6574c289b88ee3eca465f468c424bf1f01fca78dc9ec",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/commands.mjs
CHANGED
|
@@ -79,10 +79,20 @@ export function routeHelpArgv(argv) {
|
|
|
79
79
|
|
|
80
80
|
const TICKET_KEY_RE = /^[A-Za-z][A-Za-z0-9]{1,9}-\d{1,6}$/;
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
// BOT-3213: Linear's project identifier shape (the server re-checks it, and
|
|
83
|
+
// that the project belongs to this repo's tenant).
|
|
84
|
+
const PROJECT_ID_RE = /^P-[A-Z][A-Z0-9]{0,9}-[1-9][0-9]{0,6}$/i;
|
|
85
|
+
|
|
86
|
+
export function validateBootstrapLinkage(ticketId, noTicketReason, projectId = null) {
|
|
83
87
|
const ticket = typeof ticketId === "string" ? ticketId.trim() : "";
|
|
84
88
|
const reason = typeof noTicketReason === "string" ? noTicketReason.trim() : "";
|
|
85
|
-
|
|
89
|
+
const project = typeof projectId === "string" ? projectId.trim() : "";
|
|
90
|
+
if (project) {
|
|
91
|
+
if (!PROJECT_ID_RE.test(project)) return "bb bootstrap --project-id must be a Linear project identifier like P-BOT-39";
|
|
92
|
+
if (reason) return "bb bootstrap --project-id registers a coordinator; pass it with or without --ticket-id, but not also --no-ticket-reason";
|
|
93
|
+
} else if (!!ticket === !!reason) {
|
|
94
|
+
return "bb bootstrap requires exactly one of --ticket-id <ticket> or --no-ticket-reason <reason>, or --project-id <P-…> for a coordinator";
|
|
95
|
+
}
|
|
86
96
|
if (ticket && !TICKET_KEY_RE.test(ticket)) return "bb bootstrap --ticket-id must be a ticket key like BOT-123";
|
|
87
97
|
return null;
|
|
88
98
|
}
|
|
@@ -1228,6 +1238,7 @@ export async function cmdBootstrap(args, {
|
|
|
1228
1238
|
let ticketId = null;
|
|
1229
1239
|
let ticketUrl = null;
|
|
1230
1240
|
let noTicketReason = null;
|
|
1241
|
+
let projectId = null;
|
|
1231
1242
|
let prId = null;
|
|
1232
1243
|
let prNumber = null;
|
|
1233
1244
|
let prUrl = null;
|
|
@@ -1244,18 +1255,20 @@ export async function cmdBootstrap(args, {
|
|
|
1244
1255
|
else if (args[i] === "--ticket-id") ticketId = args[++i] || null;
|
|
1245
1256
|
else if (args[i] === "--ticket-url") ticketUrl = args[++i] || null;
|
|
1246
1257
|
else if (args[i] === "--no-ticket-reason") noTicketReason = args[++i] || null;
|
|
1258
|
+
else if (args[i] === "--project-id") projectId = args[++i] || null;
|
|
1247
1259
|
else if (args[i] === "--pr-id") prId = args[++i] || null;
|
|
1248
1260
|
else if (args[i] === "--pr-number") prNumber = Number(args[++i]);
|
|
1249
1261
|
else if (args[i] === "--pr-url") prUrl = args[++i] || null;
|
|
1250
1262
|
else if (args[i] === "--model") model = args[++i] || null;
|
|
1251
1263
|
else if (args[i] === "--effort") effort = args[++i] || null;
|
|
1252
|
-
else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
|
|
1264
|
+
else fail("Usage: bb bootstrap --session-id <harness UUID> (--ticket-id <ticket> | --project-id <P-…> [--ticket-id <ticket>] | --no-ticket-reason <reason>) [--type codex|claude|gpt|custom] [--codex-thread-id <UUID>] [--name <technical-name>] [--branch <branch>] [--ticket-url <url>] [--model <model>] [--effort <effort>]");
|
|
1253
1265
|
}
|
|
1254
1266
|
if (!harnessSessionId) fail("bb bootstrap requires --session-id <harness UUID>");
|
|
1255
|
-
const linkageError = validateBootstrapLinkage(ticketId, noTicketReason);
|
|
1267
|
+
const linkageError = validateBootstrapLinkage(ticketId, noTicketReason, projectId);
|
|
1256
1268
|
if (linkageError) fail(linkageError);
|
|
1257
1269
|
ticketId = ticketId?.trim() || null;
|
|
1258
1270
|
noTicketReason = noTicketReason?.trim() || null;
|
|
1271
|
+
projectId = projectId?.trim().toUpperCase() || null;
|
|
1259
1272
|
const nativeIdentityError = validateBootstrapNativeIdentity({ type, ticketId, codexThreadId, claudeDesktopSessionId });
|
|
1260
1273
|
if (nativeIdentityError) fail(nativeIdentityError);
|
|
1261
1274
|
if (!nameExplicit) name = `${name}-${harnessSessionId.slice(0, 8)}`;
|
|
@@ -1269,6 +1282,7 @@ export async function cmdBootstrap(args, {
|
|
|
1269
1282
|
ticketId,
|
|
1270
1283
|
ticketUrl,
|
|
1271
1284
|
noTicketReason,
|
|
1285
|
+
projectId,
|
|
1272
1286
|
prId,
|
|
1273
1287
|
prNumber: Number.isSafeInteger(prNumber) && prNumber > 0 ? prNumber : null,
|
|
1274
1288
|
prUrl,
|
|
@@ -1282,7 +1296,7 @@ export async function cmdBootstrap(args, {
|
|
|
1282
1296
|
// BOT-2058: the launcher must see a known-holder warning before it starts a
|
|
1283
1297
|
// new harness. Keep it out of the credential cache, but preserve the
|
|
1284
1298
|
// non-secret concurrency payload in this command receipt.
|
|
1285
|
-
log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
|
|
1299
|
+
log(JSON.stringify({ agent_id: state.agent_id, display_name: state.display_name, session_id: state.session_id, expires_at: state.expires_at, ...(projectId ? { project_id: projectId, role: "coordinator" } : {}), ...(state.ticket_signals?.concurrency ? { ticket_session_warning: state.ticket_signals.concurrency } : {}), ...(state.replaced_cached_session ? { replaced_cached_session: state.replaced_cached_session } : {}) }));
|
|
1286
1300
|
}
|
|
1287
1301
|
|
|
1288
1302
|
/** BOT-2457: local preflight mirrors the server's ticket-link identity gate. */
|
|
@@ -289,6 +289,8 @@ export async function bootstrapHarnessSession({
|
|
|
289
289
|
ticketId = null,
|
|
290
290
|
ticketUrl = null,
|
|
291
291
|
noTicketReason = null,
|
|
292
|
+
// BOT-3213: register as this Linear project's coordinator (P-BOT-39).
|
|
293
|
+
projectId = null,
|
|
292
294
|
prId = null,
|
|
293
295
|
prNumber = null,
|
|
294
296
|
prUrl = null,
|
|
@@ -341,6 +343,7 @@ export async function bootstrapHarnessSession({
|
|
|
341
343
|
...(ticketId ? { ticket_id: ticketId } : {}),
|
|
342
344
|
...(ticketUrl ? { ticket_url: ticketUrl } : {}),
|
|
343
345
|
...(noTicketReason ? { no_ticket_reason: noTicketReason } : {}),
|
|
346
|
+
...(projectId ? { project_id: projectId } : {}),
|
|
344
347
|
...(prId ? { pr_id: prId } : {}),
|
|
345
348
|
...(prNumber != null ? { pr_number: prNumber } : {}),
|
|
346
349
|
...(prUrl ? { pr_url: prUrl } : {}),
|
package/src/status-band-read.mjs
CHANGED
|
@@ -61,8 +61,21 @@ function waitsOf(own) {
|
|
|
61
61
|
if (typeof w.oldest_at !== "string" || !Number.isFinite(Date.parse(w.oldest_at))) return null;
|
|
62
62
|
return { count: w.active, oldest_at: new Date(w.oldest_at).toISOString() };
|
|
63
63
|
}
|
|
64
|
-
function refuse(code) {
|
|
65
|
-
throw new Error(code);
|
|
64
|
+
function refuse(code, extra = {}) {
|
|
65
|
+
throw Object.assign(new Error(code), extra);
|
|
66
|
+
}
|
|
67
|
+
// BOT-3213: the project a session registered to coordinate, with its ticket
|
|
68
|
+
// counts by state; null when BB did not say or sent something malformed.
|
|
69
|
+
function coordinatorOf(own) {
|
|
70
|
+
const c = own?.coordinator;
|
|
71
|
+
if (!c || c.role !== "coordinator" || !UUID_LOWER.test(c.linear_project_id)) return null;
|
|
72
|
+
const n = (v) => (Number.isSafeInteger(v) && v >= 0 && v <= 100000 ? v : null);
|
|
73
|
+
const counts = c.counts && typeof c.counts === "object"
|
|
74
|
+
? { done: n(c.counts.done), in_progress: n(c.counts.in_progress), blocked: n(c.counts.blocked), todo: n(c.counts.todo), total: n(c.counts.total) }
|
|
75
|
+
: null;
|
|
76
|
+
const ok = counts && Object.values(counts).every((v) => v !== null) &&
|
|
77
|
+
counts.done + counts.in_progress + counts.blocked + counts.todo === counts.total;
|
|
78
|
+
return { ...c, counts: ok ? counts : null };
|
|
66
79
|
}
|
|
67
80
|
function label(value, max = 240) {
|
|
68
81
|
if (
|
|
@@ -250,15 +263,19 @@ export async function readStatus({
|
|
|
250
263
|
const sessionKeys = ownOk && !selected
|
|
251
264
|
? [...new Set(own.tickets.map((x) => String(x?.key || "").toUpperCase()).filter((k) => keyPattern.test(k)))].slice(0, 5)
|
|
252
265
|
: [];
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
const
|
|
266
|
+
// BOT-3213: a session registered as a project's coordinator, with no ticket of
|
|
267
|
+
// its own, is bound to that project; a branch key is only ever a guess.
|
|
268
|
+
const coordinator = ownOk ? coordinatorOf(own) : null;
|
|
269
|
+
const bindingKind = selected ? "selected" : sessionKeys.length ? "session" : coordinator ? "project" : "branch";
|
|
270
|
+
const keys = selected ?? (sessionKeys.length ? sessionKeys : bindingKind === "project" ? [] : branchKeys);
|
|
271
|
+
// The hint names this tenant's own key prefix (BOT-3213 AC-4).
|
|
272
|
+
if (!keys.length && bindingKind !== "project") refuse("ticket_missing", { prefix });
|
|
273
|
+
const key = keys[0] ?? null;
|
|
274
|
+
const useSession = bindingKind === "session" || bindingKind === "project";
|
|
258
275
|
// The Linear ticket read and the BB reads are independent, so they run
|
|
259
276
|
// together; a refused BB read blanks only its line. The epic read is the slow
|
|
260
277
|
// one (~7 s live), so it gets a longer budget, and a relay wake skips it.
|
|
261
|
-
const linearGraph = useLinear
|
|
278
|
+
const linearGraph = useLinear && key
|
|
262
279
|
? jsonRequest(
|
|
263
280
|
"https://api.linear.app/graphql",
|
|
264
281
|
{
|
|
@@ -284,7 +301,7 @@ export async function readStatus({
|
|
|
284
301
|
]);
|
|
285
302
|
let linearTicket = null;
|
|
286
303
|
const blockers = [];
|
|
287
|
-
if (useLinear) {
|
|
304
|
+
if (useLinear && key) {
|
|
288
305
|
const graph = await linearGraph;
|
|
289
306
|
const issue = graph?.data?.issue;
|
|
290
307
|
if (
|
|
@@ -407,6 +424,12 @@ export async function readStatus({
|
|
|
407
424
|
total,
|
|
408
425
|
percent: Number.isFinite(se.progress_pct) ? Math.max(0, Math.min(100, Math.round(se.progress_pct))) : total ? Math.round((100 * done) / total) : 0,
|
|
409
426
|
};
|
|
427
|
+
// BOT-3213: the project this session coordinates carries its counts by state.
|
|
428
|
+
if (coordinator && coordinator.linear_project_id === epic.id) {
|
|
429
|
+
epic.role = "coordinator";
|
|
430
|
+
if (coordinator.counts) epic.counts = coordinator.counts;
|
|
431
|
+
if (!epic.identifier && PROJECT_IDENTIFIER.test(coordinator.identifier || "")) epic.identifier = coordinator.identifier;
|
|
432
|
+
}
|
|
410
433
|
}
|
|
411
434
|
if (owner) {
|
|
412
435
|
const total = Math.max(0, (owner.children_total ?? 0) - (owner.children_canceled ?? 0));
|
|
@@ -469,7 +492,7 @@ export async function readStatus({
|
|
|
469
492
|
id: state.agent_id,
|
|
470
493
|
name: label(identity.agent.display_name, 100),
|
|
471
494
|
},
|
|
472
|
-
ticket: linearTicket || { ...tickets[0], url: null },
|
|
495
|
+
ticket: linearTicket || (tickets.length ? { ...tickets[0], url: null } : null),
|
|
473
496
|
tickets,
|
|
474
497
|
prs,
|
|
475
498
|
epic,
|
|
@@ -481,7 +504,7 @@ export async function readStatus({
|
|
|
481
504
|
// BOT-3136: where the tickets came from — the registered session, an explicit
|
|
482
505
|
// pick, or (only when the session registered none) a guess from the branch.
|
|
483
506
|
binding: bindingKind,
|
|
484
|
-
blockers: useLinear
|
|
507
|
+
blockers: useLinear && key
|
|
485
508
|
? [...new Map(blockers.map((b) => [b.key, b])).values()].sort((a, b) =>
|
|
486
509
|
a.key.localeCompare(b.key),
|
|
487
510
|
)
|
|
@@ -717,7 +740,8 @@ export async function main(args, {
|
|
|
717
740
|
return 0;
|
|
718
741
|
} catch (error) {
|
|
719
742
|
const known = /^[a-z_]+$/.test(error?.message ?? "") ? error.message : "status_unavailable";
|
|
720
|
-
|
|
743
|
+
const prefix = known === "ticket_missing" && /^[A-Z]{2,10}$/.test(error?.prefix ?? "") ? { prefix: error.prefix } : {};
|
|
744
|
+
out.write(JSON.stringify({ error: known, ...prefix }) + "\n");
|
|
721
745
|
return 1;
|
|
722
746
|
}
|
|
723
747
|
}
|